Commit b97b9938 authored by achinta's avatar achinta

wip: routine add

parent b18b2f83
...@@ -27,7 +27,14 @@ export class AuthService { ...@@ -27,7 +27,14 @@ export class AuthService {
if (this.isBrowser) { if (this.isBrowser) {
localStorage.setItem('isLoggedIn', 'true'); localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('role', userProfileData.role_name); // TODO: This is for temporary
if(userProfileData.role_name === 'Teacher') {
localStorage.setItem('role', 'EDITOR');
} else{
localStorage.setItem('role', userProfileData.role_name);
}
this._router.navigate([RequestMapperService.PORTAL_URL]); this._router.navigate([RequestMapperService.PORTAL_URL]);
} }
......
...@@ -9,7 +9,7 @@ export class RoleMapperService { ...@@ -9,7 +9,7 @@ export class RoleMapperService {
// NOTE:: this will be same value which is come from backend role // NOTE:: this will be same value which is come from backend role
public static readonly TEACHER_ROLE: string = 'Teacher'; public static readonly TEACHER_ROLE: string = 'EDITOR';
public static readonly STUDENT_ROLE: string = 'Student'; public static readonly STUDENT_ROLE: string = 'Student';
public static get getAllRole(): string[] { public static get getAllRole(): string[] {
......
...@@ -19,6 +19,9 @@ export class TransmissionMapperService { ...@@ -19,6 +19,9 @@ export class TransmissionMapperService {
public static readonly GET_TRANSMISSION_URL: string = public static readonly GET_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/getWebDataSourceByWebsiteDataSourceForFilter?'; TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/getWebDataSourceByWebsiteDataSourceForFilter?';
public static readonly SAVE_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/saveWebDataSourceFieldsBasedOnDataSourceType?';
// aggregationOnUniqueFld=false&datasourceId=3188&dontIncludeForeignKey=false&expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1&user_id=206&roleBasedFiltering=true // aggregationOnUniqueFld=false&datasourceId=3188&dontIncludeForeignKey=false&expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1&user_id=206&roleBasedFiltering=true
// public static readonly SCHEDULE_OF_RATES_TRANSMISSION_URL: string = // public static readonly SCHEDULE_OF_RATES_TRANSMISSION_URL: string =
......
import { Data } from "../data-source/interface/data";
import { LocalizedField } from "../data-source/interface/localizedField";
// ThemeDataSourceField Interface
export interface Classes extends Data {
themeDataSourceFields: StudentClass[];
}
// ThemeDataSourceField Interface
export interface StudentClass {
id: string;
className: LocalizedField;
details: LocalizedField;
school: LocalizedField;
}
import { Data } from "../data-source/interface/data";
import { LocalizedField } from "../data-source/interface/localizedField";
// ThemeDataSourceField Interface
export interface Sections extends Data {
themeDataSourceFields: StudentSection[];
}
// ThemeDataSourceField Interface
export interface StudentSection {
id: string;
class: LocalizedField;
section: LocalizedField;
class_teacher: LocalizedField;
details: LocalizedField;
class_details: LocalizedField;
class_teacher_name: LocalizedField;
}
<pre> {{data | json}} </pre> <!-- <h1> Hi Manage </h1> -->
<form class="login_form" [formGroup]="routineForm">
<div class="mat_input_container">
<div class="class_dropdown">
<app-drop-down
[dropDownData] ="classDropDownData"
(emitDropDownData)="classOnChange($event)"
/>
</div>
<div class="section_dropdown">
<app-drop-down
[dropDownData] ="sectionDropDownData"
(emitDropDownData)="sectionOnChange($event)"
/>
</div>
<div class="details_field">
<mat-form-field class="full_width">
<span class="material-symbols-outlined" matPrefix>
person
</span>
<input
matInput
placeholder="{{ 'Enter details' }}"
#input
formControlName="details"
/>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<mat-form-field style="width: 100%;">
<mat-label>Schedule</mat-label>
<button mat-icon-button matPrefix (click)="f_input.click()">
<mat-icon>attach_file</mat-icon>
</button>
<input type="text" readonly matInput />
<input
type="file"
multiple
hidden
#f_input
/>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="add_btn">
<app-square-button
[buttonIcon]="''"
[buttonText]="'submit'"
(emitSquareButtonClick)="submitRoutine()"
/>
</div>
</form>
\ No newline at end of file
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ClassTransmissionService } from '../../../raintree/transmission/class-transmission.service';
import { TransmissionMapperService } from '../../../mappers/transmission-mapper.service';
import { DataSourceService } from '../../service/data-source.service';
import { classResponse } from '../../../raintree/interface/class-respons';
import { UrlConfigService } from '../../service/url-config.service';
import { DropDownComponent } from "../../../component-library/dropdown/drop-down/drop-down.component";
import { Dropdown } from '../../../component-library/dropdown/interface/dropdown';
import { StudentClass } from '../../interface/class';
import { FormControl, FormControlName, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatIconModule } from "@angular/material/icon";
import { SquareButtonComponent } from '../../../component-library/square-button/square-button.component';
import { SectionResponse } from '../../../raintree/interface/section-respons';
import { StudentSection } from '../../interface/section';
import { RoutineTransmissionService } from '../../../raintree/transmission/routine-transmission.service';
import { AuthService } from '../../../auth/service/auth.service';
import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
@Component({ @Component({
selector: 'app-manage', selector: 'app-manage',
imports: [ imports: [
CommonModule CommonModule,
DropDownComponent,
ReactiveFormsModule,
MatFormFieldModule,
MatInputModule,
MatIconModule,
SquareButtonComponent
], ],
templateUrl: './manage.component.html', templateUrl: './manage.component.html',
styleUrl: './manage.component.scss' styleUrl: './manage.component.scss'
}) })
export class ManageComponent { export class ManageComponent {
constructor( constructor(
@Inject(MAT_DIALOG_DATA) public data: any, @Inject(MAT_DIALOG_DATA) public data: any,
private _classTransmission: ClassTransmissionService,
private _urlConfig: UrlConfigService,
private _routineTransmission:RoutineTransmissionService,
private _auth: AuthService
) { } ) { }
public classDropDownData: Dropdown[] = []
public sectionDropDownData: Dropdown[] = []
public routineForm = new FormGroup({
details: new FormControl('', [Validators.required])
})
ngOnInit(): void {
this._getClasses();
this._getSection();
}
public classOnChange(value: string) {
console.log(value);
}
public sectionOnChange(value: string) {
console.log(value);
}
public submitRoutine(): void {
alert("Submit Clicked!!")
// this._routineTransmission.submitRoutine(
// TransmissionMapperService.SAVE_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`,
// this.routineFormPayload,
// () => { },
// () => { },
// (response: RaintreeResponse) => {
// console.log(response);
// },
// (error) => {
// console.log(error);
// },
// () => { }
// );
}
private _getClasses() {
this._classTransmission.getClasses(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: DataSourceService.CLASS_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 100,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true
}),
() => { },
(response) => { },
(response: classResponse) => {
this.classDropDownData = response.data['themeDataSourceFields'].map((sClass: StudentClass) => {
return {
['name']: sClass.details['en'],
['value']: sClass.id
}
})
},
(error) => {
console.log(error);
},
() => { }
)
}
private _getSection(){
this._classTransmission.getSection(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: DataSourceService.SECTION_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 100,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true
}),
() => { },
(response) => { },
(response: SectionResponse) => {
this.sectionDropDownData = response.data['themeDataSourceFields'].map((sSection: StudentSection) => {
return {
['name']: sSection.section['en'],
['value']: sSection.id
}
})
},
(error) => {
console.log(error);
},
() => { }
)
}
private routineFormPayload =
{
"themeDataSourceFields": [
{
"id": "",
"class": {
"en": "48f353051f9d724f619491d4f0d0a8ec",
"beng": "48f353051f9d724f619491d4f0d0a8ec",
"hindi": "48f353051f9d724f619491d4f0d0a8ec"
},
"section": {
"en": "5d53b27058d1f6067a4b4bd1350a24d4",
"beng": "5d53b27058d1f6067a4b4bd1350a24d4",
"hindi": "5d53b27058d1f6067a4b4bd1350a24d4"
},
"schedule": {
"en": "BASE_URL/webomagic/getFile?fid=2910",
"beng": "BASE_URL/webomagic/getFile?fid=2910",
"hindi": "BASE_URL/webomagic/getFile?fid=2910"
},
"details": {
"en": "test 1 c",
"beng": "test 1 c",
"hindi": "test 1 c"
},
"session": {
"en": "86af4d6b5675a82df4581f00c67f0c7f",
"beng": "86af4d6b5675a82df4581f00c67f0c7f",
"hindi": "86af4d6b5675a82df4581f00c67f0c7f"
},
"document": {
"en": "",
"beng": "",
"hindi": ""
},
"routine_type": {
"en": "class_routine",
"beng": "class_routine",
"hindi": "class_routine"
}
}
],
"dataSourceName": "Routine",
"id": "3021",
"type": "1327",
"themeId": "278",
"slideLst": null,
"heading": "undefined",
"dataSourceTypeFieldsList": [
{
"id": "",
"class": {
"en": "48f353051f9d724f619491d4f0d0a8ec",
"beng": "48f353051f9d724f619491d4f0d0a8ec",
"hindi": "48f353051f9d724f619491d4f0d0a8ec"
},
"section": {
"en": "5d53b27058d1f6067a4b4bd1350a24d4",
"beng": "5d53b27058d1f6067a4b4bd1350a24d4",
"hindi": "5d53b27058d1f6067a4b4bd1350a24d4"
},
"schedule": {
"en": "BASE_URL/webomagic/getFile?fid=2910",
"beng": "BASE_URL/webomagic/getFile?fid=2910",
"hindi": "BASE_URL/webomagic/getFile?fid=2910"
},
"details": {
"en": "test 1 c",
"beng": "test 1 c",
"hindi": "test 1 c"
},
"session": {
"en": "86af4d6b5675a82df4581f00c67f0c7f",
"beng": "86af4d6b5675a82df4581f00c67f0c7f",
"hindi": "86af4d6b5675a82df4581f00c67f0c7f"
},
"document": {
"en": "",
"beng": "",
"hindi": ""
},
"routine_type": {
"en": "class_routine",
"beng": "class_routine",
"hindi": "class_routine"
}
}
]
} }
}
...@@ -50,9 +50,12 @@ export class RoutineComponent { ...@@ -50,9 +50,12 @@ export class RoutineComponent {
}); });
} }
public emitViewFromTable(clickedData: string) { public emitViewFromTable(emitData: any) {
alert("Have to view the doc in another page"); // alert("Have to view the doc in another page");
// console.log();
let docLink = emitData.schedule.replace('BASE_URL', TransmissionMapperService.DEV_TRANSMISSION_URL);
window.open(docLink, '_blank');
} }
public emitEditFromTable(emitData: string): void { public emitEditFromTable(emitData: string): void {
......
...@@ -17,7 +17,8 @@ export class PrepareRoutineTableDataService { ...@@ -17,7 +17,8 @@ export class PrepareRoutineTableDataService {
['id']: routine.id, ['id']: routine.id,
['session_session_name']: routine.session_session_name['en'], ['session_session_name']: routine.session_session_name['en'],
['class_details']: routine.class_details['en'], ['class_details']: routine.class_details['en'],
['section_details']:routine.section_details['en'], ['section_details']: routine.section_details['en'],
['schedule']: routine.schedule['en'],
['action']: ['view', 'edit'] ['action']: ['view', 'edit']
} }
}) })
......
...@@ -9,5 +9,7 @@ export class DataSourceService { ...@@ -9,5 +9,7 @@ export class DataSourceService {
public static readonly ASSIGNMENT_DATA_SOURCE_ID: number = 3188; public static readonly ASSIGNMENT_DATA_SOURCE_ID: number = 3188;
public static readonly ROUTINE_DATA_SOURCE_ID: number = 3021; public static readonly ROUTINE_DATA_SOURCE_ID: number = 3021;
public static readonly CLASS_DATA_SOURCE_ID: number = 3008;
public static readonly SECTION_DATA_SOURCE_ID: number = 3013;
} }
import { Classes } from "../../portal/interface/class";
import { RaintreeResponse } from "./raintree-response";
export interface classResponse extends RaintreeResponse {
data: Classes;
}
\ No newline at end of file
import { Sections } from "../../portal/interface/section";
import { RaintreeResponse } from "./raintree-response";
export interface SectionResponse extends RaintreeResponse {
data: Sections;
}
\ No newline at end of file
import { TestBed } from '@angular/core/testing';
import { ClassTransmissionService } from './class-transmission.service';
describe('ClassTransmissionService', () => {
let service: ClassTransmissionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ClassTransmissionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { TransmissionService } from './transmission.service';
@Injectable({
providedIn: 'root'
})
export class ClassTransmissionService extends TransmissionService{
public getClasses(
url: string,
onPreExecute: () => void,
onPostExecute: (response: any) => void,
onSuccess: (response: any) => void,
onFailure: (error: string) => void,
onComplete: () => void
): void {
this.executePostPayload(
url,
{},
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
public getSection(
url: string,
onPreExecute: () => void,
onPostExecute: (response: any) => void,
onSuccess: (response: any) => void,
onFailure: (error: string) => void,
onComplete: () => void
){
this.executePostPayload(
url,
{},
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
}
...@@ -16,11 +16,11 @@ export class JWTService { ...@@ -16,11 +16,11 @@ export class JWTService {
public injectToken(token: string): HttpHeaders { public injectToken(token: string): HttpHeaders {
let authorizationToken: string = localStorage.getItem('Bearer') || ''; let authorizationToken: string = localStorage.getItem('Bearer') || '';
let userId = this._auth.localStorageGetItemByKey('user_id');
// TODO: check if token exist in Local storage and handle accordingly // TODO: check if token exist in Local storage and handle accordingly
return new HttpHeaders({ return new HttpHeaders({
"user-id": this._auth.localStorageGetItemByKey('user_id'), "user-id": userId,
"apikey": authorizationToken, "apikey": authorizationToken,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}); });
......
...@@ -8,6 +8,7 @@ export class RoutineTransmissionService extends TransmissionService{ ...@@ -8,6 +8,7 @@ export class RoutineTransmissionService extends TransmissionService{
public getRoutine( public getRoutine(
url: string, url: string,
payload:string,
onPreExecute: () => void, onPreExecute: () => void,
onPostExecute: (response: any) => void, onPostExecute: (response: any) => void,
onSuccess: (response: any) => void, onSuccess: (response: any) => void,
...@@ -25,4 +26,25 @@ export class RoutineTransmissionService extends TransmissionService{ ...@@ -25,4 +26,25 @@ export class RoutineTransmissionService extends TransmissionService{
true true
); );
} }
public submitRoutine(
url: string,
payload:any,
onPreExecute: () => void,
onPostExecute: (response: any) => void,
onSuccess: (response: any) => void,
onFailure: (error: string) => void,
onComplete: () => void
){
this.executePostPayload(
url,
payload,
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
} }
import { TestBed } from '@angular/core/testing';
import { SectionTransmissionService } from './section-transmission.service';
describe('SectionTransmissionService', () => {
let service: SectionTransmissionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SectionTransmissionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class SectionTransmissionService {
constructor() { }
}
...@@ -103,9 +103,7 @@ export class TransmissionService { ...@@ -103,9 +103,7 @@ export class TransmissionService {
if (response.status_code) onSuccess(response); if (response.status_code) onSuccess(response);
// else // else
// onFailure( // onFailure(
// isEmptyString(response.message)
// ? MessageService.RESOURCE_VALIDATION_FAILED
// : response.message
// ); // );
}, },
(error) => { (error) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment