Commit df9761a5 authored by achinta's avatar achinta

feat: add routine with file uploaded

parent 04bae104
......@@ -8,8 +8,12 @@
padding: 20px;
}
}
.logo_section {
display: flex;
justify-content: center;
}
}
.login_wrapper {
display: flex;
justify-content: center;
......
......@@ -54,7 +54,7 @@ export class AuthService {
public getUserRole(): string {
return this.localStorageGetItemByKey('role');
return this.localStorageGetItemByKey('role_name');
}
}
......@@ -16,11 +16,17 @@
</button>
</ng-container>
<ng-container *ngIf="item =='edit' && authService.getUserRole() !== 'student'">
<ng-container *ngIf="item =='edit' && authService.getUserRole() != 'Student'">
<button class="view_button d_inline_block width_auto " (click)="edit(element)">
<span class="material-symbols-outlined">edit</span>
</button>
</ng-container>
<ng-container *ngIf="item =='delete' && authService.getUserRole() != 'Student'">
<button class="view_button d_inline_block width_auto " (click)="delete(element)">
<span class="material-symbols-outlined">delete</span>
</button>
</ng-container>
}
}
</td>
......
......@@ -29,15 +29,18 @@ export class CustomTableComponent {
@Output() emitEdit: EventEmitter<string> = new EventEmitter<string>();
@Output() emitDelete: EventEmitter<string> = new EventEmitter<string>();
public authService = inject(AuthService);
// totalRecords: number = 3400;
// pageSize: number = 50;
public ngOnInit(): void {
// console.log(this.data);
}
get displayedColumns(): string[] {
// console.log(this.data);
return this.columns.map(col => col.key);
......@@ -53,6 +56,10 @@ export class CustomTableComponent {
this.emitEdit.emit(data);
}
public delete(data:any): void {
this.emitDelete.emit(data);
}
onPageChanged(event: any): void {
console.log("event");
console.log(event);
......
......@@ -5,4 +5,4 @@
<mat-option [value]="option.value">{{option.name}}</mat-option>
}
</mat-select>
</mat-form-field>
\ No newline at end of file
</mat-form-field>
\ No newline at end of file
<!-- <mat-form-field style="width: 100%;" appearance="fill">
<mat-label>{{ label }}</mat-label>
<button mat-icon-button matPrefix (click)="fileInput.click()">
<mat-icon>attach_file</mat-icon>
</button>
<input type="file" multiple #fileInput (change)="onFileSelected($event)" style="display: none;" />
<mat-hint *ngIf="selectedFiles().length">
Selected: {{ selectedFiles().length }} file(s)
</mat-hint>
<mat-error *ngIf="!selectedFiles().length">This field is required</mat-error>
</mat-form-field> -->
<mat-form-field style="width: 100%;">
<mat-label>{{ label }}</mat-label>
......@@ -20,10 +6,8 @@
<mat-icon>attach_file</mat-icon>
</button>
<input type="text" readonly matInput />
<input type="file" multiple #f_input (change)="onFileSelected($event)" />
<mat-hint *ngIf="selectedFiles().length">
Selected: {{ selectedFiles().length }} file(s)
</mat-hint>
<input type="text" readonly matInput [value]="fileName" />
<input type="file" multiple #f_input (change)="onFileSelected($event)" hidden />
<mat-error *ngIf="!selectedFiles().length">This field is required</mat-error>
</mat-form-field>
\ No newline at end of file
......@@ -19,12 +19,17 @@ export class FileInputComponent {
@Input() label: string = 'Upload Files';
@Output() filesChange = new EventEmitter<File[]>();
public fileName:string = '';
// Triggered when files are selected
onFileSelected(event: Event): void {
const input = event.target as HTMLInputElement;
if (input.files) {
this.selectedFiles.set(Array.from(input.files)); // Update the signal
this.filesChange.emit(this.selectedFiles()); // Emit the event
console.log(input.files[0].name);
this.fileName = input.files[0].name
}
}
}
......@@ -23,6 +23,9 @@ export class TransmissionMapperService {
public static readonly SAVE_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/saveWebDataSourceFieldsBasedOnDataSourceType?';
public static readonly FILE_UPLOAD_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/uploadFile?';
// 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 =
// TransmissionMapperService.DEV_TRANSMISSION_URL +
......
<h3> Assignments </h3>
<div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn" *ngIf="authService.getUserRole() !== 'student'">
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addAssignment()"
......
......@@ -33,12 +33,7 @@ export class AssignmentComponent implements OnInit {
public authService: AuthService
) { }
public columns = [
{ key: 'class_subject_subject_txt', label: 'Class' },
{ key: 'subject', label: 'Subject' },
{ key: 'section', label: 'Section' },
{ key: 'action', label: 'Action' },
];
public columns:any[] = [];
public data: any[] = [];
......@@ -83,26 +78,23 @@ export class AssignmentComponent implements OnInit {
}
public emitEditFromTable(emitData: string): void {
public emitDeleteFromTable(emitData: string): void {
// rate ? rate.is_edit_enable = true : '';
// this._dialog.open(ManageComponent, {
// data: emitData,
// width: '98vw',
// height: 'auto',
// maxWidth: '70vw',
// maxHeight: '70vh',
// });
let dialogRef = this._dialog.open(ManageComponent, {
data: emitData,
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
alert("Have to Delete ");
// dialogRef.afterClosed().subscribe(data => {
// if (data)
// this._getScheduleOfRates();
// });
}
public addAssignment(): void {
let dialogRef = this._dialog.open(ManageComponent, {
this._dialog.open(ManageComponent, {
data: '',
width: '98vw',
height: 'auto',
......
......@@ -13,28 +13,27 @@ export class PrepareAssignmentTableDataService {
let dataArray = data.map((assignment: Assignment) => {
return {
['id']: assignment.id,
['subject']: assignment.class_subject_subject_txt['en'],
['section_details']: assignment.section_details['en'],
['session_name']: assignment.session_session_name['en'],
['id']: assignment.id,
['action']: ['view', 'edit']
['assigned_on']: assignment.assigned_on['en'],
['action']: ['view', 'delete']
}
})
return dataArray;
// return [];
}
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'section_details', label: 'Class' },
{ key: 'subject', label: 'Subject' },
{ key: 'section_details', label: 'Subject Details' },
{ key: 'session_name', label: 'Session Name' },
{ key: 'assigned_on', label: 'Date' },
{ key: 'action', label: 'Action' },
];
console.log(columnArray);
return columnArray;
}
......
......@@ -5,15 +5,15 @@ export interface Data {
count: number;
id: number | string;
dataSourceName: string;
websiteId: number;
websiteId?: number;
type: string;
foreignKeyMapping: any;
foreignKeyMap: ForeignKeyMap;
requiredPresentationField: string;
foreignKeyMapping?: any;
foreignKeyMap?: ForeignKeyMap;
requiredPresentationField?: string;
favourite: boolean;
icon: string;
dependentFields: any;
dsType: any;
icon?: string;
dependentFields?: any;
dsType?: any;
[index:string]: any;
}
\ No newline at end of file
<h3> Exam schedules </h3>
<div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn">
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addExam()"
......
......@@ -10,6 +10,8 @@ import { UrlConfigService } from '../../service/url-config.service';
import { DataSourceService } from '../../service/data-source.service';
import { PrepareExamTableDataService } from '../service/prepare-exam-table-data.service';
import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
import { AuthService } from '../../../auth/service/auth.service';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
@Component({
selector: 'app-exam',
......@@ -27,7 +29,9 @@ export class ExamComponent {
private _dialog: MatDialog,
private _examSchedule:ExamScheduleService,
private _urlConfig: UrlConfigService,
private _prepareExamTableData: PrepareExamTableDataService
private _prepareExamTableData: PrepareExamTableDataService,
private _matDialogConfig: MatDialogConfigService,
public authService:AuthService
) { }
public columns: any = [];
......@@ -46,19 +50,9 @@ export class ExamComponent {
window.open(docLink, '_blank');
}
private matModalConfig = {
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
}
public emitEditFromTable(emitData: string): void {
public emitDeleteFromTable(emitData: string): void {
this._dialog.open(ManageComponent, {
data: emitData,
...this.matModalConfig
});
alert("Should delete !!")
}
......@@ -66,7 +60,7 @@ export class ExamComponent {
this._dialog.open(ManageComponent, {
data: '',
...this.matModalConfig
...this._matDialogConfig.matModalConfig()
});
}
......@@ -83,7 +77,7 @@ export class ExamComponent {
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 10,
limit: 100,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true
......
......@@ -14,11 +14,11 @@ export class PrepareExamTableDataService {
return {
['id']: schedule.id,
['Term']: schedule.Term['en'],
['image']: schedule.image['en'],
['details']: schedule.details['en'],
['class_details']: schedule.class_details['en'],
['action']: ['view', 'edit']
['details']: schedule.details['en'],
['term']: schedule.Term['en'],
['image']: schedule.image['en'],
['action']: ['view', 'delete']
}
})
......@@ -29,9 +29,9 @@ export class PrepareExamTableDataService {
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'Term', label: 'Term' },
{ key: 'details', label: 'Details' },
{ key: 'class_details', label: 'Class' },
{ key: 'term', label: 'Term' },
{ key: 'details', label: 'Details' },
{ key: 'action', label: 'Action' },
];
......
<!-- <h1> Hi Manage </h1> -->
<form class="login_form" [formGroup]="routineForm">
<div class="container">
<form class="routine_form" [formGroup]="routineForm">
<div class="mat_input_container">
<div class="class_dropdown">
<app-drop-down
[dropDownData] ="classDropDownData"
(emitDropDownData)="classOnChange($event)"
<div class="class_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Class</mat-label>
<mat-select formControlName="class">
@for (class of classDropDownData; track class) {
<mat-option [value]="class.value">{{class.name}}</mat-option>
}
</mat-select>
<mat-error>This field is required</mat-error>
/>
</div>
<div class="section_dropdown">
<app-drop-down
[dropDownData] ="sectionDropDownData"
(emitDropDownData)="sectionOnChange($event)"
</mat-form-field>
/>
</div>
<div class="details_field">
<div class="section_dropdown mat_input">
<mat-form-field class="full_width">
<span class="material-symbols-outlined" matPrefix>
person
</span>
<input
matInput
placeholder="{{ 'Enter details' }}"
#input
formControlName="details"
/>
<mat-label>Select Section</mat-label>
<mat-select formControlName="section">
@for (section of sectionDropDownData; track section) {
<mat-option [value]="section.value">{{section.name}}</mat-option>
}
</mat-select>
<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
/>
<div class="routine_type_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Type</mat-label>
<mat-select formControlName="routineType">
<mat-option value="class_routine">Class Routine</mat-option>
<mat-option value="exam_routine">Exam Routine</mat-option>
</mat-select>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="file_upload mat_input">
<app-file-input [label]="'Upload Document'" (filesChange)="onFilesChanged($event)" />
<mat-error *ngIf="!routineForm.value.schedule" >This field is required</mat-error>
</div>
</div>
<div class="add_btn">
<app-square-button
[buttonIcon]="''"
[buttonText]="'submit'"
(emitSquareButtonClick)="submitRoutine()"
/>
<app-square-button [buttonIcon]="''" [buttonText]="'submit'" (emitSquareButtonClick)="submitRoutine()" />
</div>
</form>
\ No newline at end of file
</form>
</div>
\ No newline at end of file
.container{
padding: 10px;
}
.add_btn{
float: right;
}
.mat_input{
margin-bottom: 5px;
}
......@@ -6,7 +6,6 @@ import { TransmissionMapperService } from "../../../mappers/transmission-mapper.
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 "../../data-source/interface/class";
import {
......@@ -25,20 +24,25 @@ import { StudentSection } from "../../data-source/interface/section";
import { RoutineTransmissionService } from "../../../raintree/transmission/routine-transmission.service";
import { AuthService } from "../../../auth/service/auth.service";
import { RaintreeResponse } from "../../../raintree/interface/raintree-response";
import { Routines } from "../interface/routine";
import { Routine, Routines } from "../interface/routine";
import { ForeignKeyMap } from "../../data-source/interface/foreignKeyMap";
import { MatSelectModule } from "@angular/material/select";
import { FileInputComponent } from "../../../component-library/file-input/file-input.component";
import { FileUploadTransmissionService } from "../../../raintree/transmission/file-upload-transmission.service";
import { ToasterService } from "../../../component-library/toaster/toaster.service";
@Component({
selector: "app-manage",
imports: [
CommonModule,
DropDownComponent,
ReactiveFormsModule,
MatFormFieldModule,
MatInputModule,
MatIconModule,
SquareButtonComponent,
],
MatSelectModule,
FileInputComponent
],
templateUrl: "./manage.component.html",
styleUrl: "./manage.component.scss",
})
......@@ -48,14 +52,19 @@ export class ManageComponent {
private _classTransmission: ClassTransmissionService,
private _urlConfig: UrlConfigService,
private _routineTransmission: RoutineTransmissionService,
private _auth: AuthService
private _auth: AuthService,
private _fileUpload: FileUploadTransmissionService,
private _toaster:ToasterService
) {}
public classDropDownData: Dropdown[] = [];
public sectionDropDownData: Dropdown[] = [];
public routineForm = new FormGroup({
details: new FormControl("", [Validators.required]),
class: new FormControl("", [Validators.required]),
section: new FormControl("", [Validators.required]),
routineType: new FormControl("", [Validators.required]),
schedule: new FormControl("", [Validators.required]),
});
ngOnInit(): void {
......@@ -63,39 +72,58 @@ export class ManageComponent {
this._getSection();
}
public classOnChange(value: string) {
console.log(value);
}
public onFilesChanged(files: File[]): void {
console.log('Selected Files:', files);
const formData = new FormData();
files.forEach(file => formData.append('file', file, file.name));
this._fileUpload.uploadFile(
TransmissionMapperService.FILE_UPLOAD_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`,
formData,
() => { },
() => { },
(response: RaintreeResponse) => {
this.routineForm.value.schedule = `${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}`
},
(error) => {
console.log(error);
},
() => { }
)
public sectionOnChange(value: string) {
console.log(value);
}
public submitRoutine(): void {
// alert("Submit Clicked!!");
// console.log(this.routineFormPayload);
console.log(
this.routineForm.value
)
// this._routineTransmission.submitRoutine(
if(this.routineForm.invalid) return;
this._routineTransmission.submitRoutine(
// TransmissionMapperService.SAVE_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`,
TransmissionMapperService.SAVE_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`,
// this.routineFormPayload,
// () => { },
// () => { },
// (response: RaintreeResponse) => {
this._prepareRoutinePayload(),
() => { },
() => { },
(response: RaintreeResponse) => {
// console.log(response);
this._toaster.success("Routine added successfully",'Done');
window.location.reload();
// },
// (error) => {
// console.log(error);
},
(error) => {
console.log(error);
// },
// () => { }
// );
},
() => { }
);
}
private _getClasses() {
......@@ -166,34 +194,36 @@ export class ManageComponent {
);
}
private routineFormPayload:Routines = {
private _prepareRoutinePayload(): Routines{
return {
themeDataSourceFields: [
{
id: "",
class: {
en: "48f353051f9d724f619491d4f0d0a8ec",
beng: "48f353051f9d724f619491d4f0d0a8ec",
hindi: "48f353051f9d724f619491d4f0d0a8ec",
en: `${this.routineForm.value.class}`,
beng: `${this.routineForm.value.class}`,
hindi: `${this.routineForm.value.class}`,
},
section: {
en: "5d53b27058d1f6067a4b4bd1350a24d4",
beng: "5d53b27058d1f6067a4b4bd1350a24d4",
hindi: "5d53b27058d1f6067a4b4bd1350a24d4",
en: `${this.routineForm.value.section}`,
beng: `${this.routineForm.value.section}`,
hindi: `${this.routineForm.value.section}`,
},
schedule: {
en: "BASE_URL/webomagic/getFile?fid=2910",
beng: "BASE_URL/webomagic/getFile?fid=2910",
hindi: "BASE_URL/webomagic/getFile?fid=2910",
en: `${this.routineForm.value.schedule}`,
beng: `${this.routineForm.value.schedule}`,
hindi: `${this.routineForm.value.schedule}`,
},
details: {
en: "test 1 c",
beng: "test 1 c",
hindi: "test 1 c",
en: "",
beng: "",
hindi: "",
},
session: {
en: "86af4d6b5675a82df4581f00c67f0c7f",
beng: "86af4d6b5675a82df4581f00c67f0c7f",
hindi: "86af4d6b5675a82df4581f00c67f0c7f",
en: `${this.routineForm.value.section}`,
beng: `${this.routineForm.value.section}`,
hindi: `${this.routineForm.value.section}`,
},
document: {
en: "",
......@@ -201,45 +231,45 @@ export class ManageComponent {
hindi: "",
},
routine_type: {
en: "class_routine",
beng: "class_routine",
hindi: "class_routine",
en: `${this.routineForm.value.routineType}`,
beng:`${this.routineForm.value.routineType}`,
hindi: `${this.routineForm.value.routineType}`,
},
},
],
dataSourceName: "Routine",
id: "3021",
type: "1327",
themeId: "278",
dataSourceName: DataSourceService.ROUTINE_DATA_SOURCE_NAME,
id: `${DataSourceService.ROUTINE_DATA_SOURCE_ID}`,
type: `${DataSourceService.ROUTINE_DATA_SOURCE_TYPE}`,
themeId: `${this._auth.localStorageGetItemByKey('project_id')}`,
slideLst: null,
heading: "undefined",
dataSourceTypeFieldsList: [
{
id: "",
class: {
en: "48f353051f9d724f619491d4f0d0a8ec",
beng: "48f353051f9d724f619491d4f0d0a8ec",
hindi: "48f353051f9d724f619491d4f0d0a8ec",
en: `${this.routineForm.value.class}`,
beng: `${this.routineForm.value.class}`,
hindi: `${this.routineForm.value.class}`,
},
section: {
en: "5d53b27058d1f6067a4b4bd1350a24d4",
beng: "5d53b27058d1f6067a4b4bd1350a24d4",
hindi: "5d53b27058d1f6067a4b4bd1350a24d4",
en: `${this.routineForm.value.section}`,
beng: `${this.routineForm.value.section}`,
hindi: `${this.routineForm.value.section}`,
},
schedule: {
en: "BASE_URL/webomagic/getFile?fid=2910",
beng: "BASE_URL/webomagic/getFile?fid=2910",
hindi: "BASE_URL/webomagic/getFile?fid=2910",
en: `${this.routineForm.value.schedule}`,
beng: `${this.routineForm.value.schedule}`,
hindi: `${this.routineForm.value.schedule}`,
},
details: {
en: "test 1 c",
beng: "test 1 c",
hindi: "test 1 c",
en: "",
beng: "",
hindi: "",
},
session: {
en: "86af4d6b5675a82df4581f00c67f0c7f",
beng: "86af4d6b5675a82df4581f00c67f0c7f",
hindi: "86af4d6b5675a82df4581f00c67f0c7f",
en: "",
beng: "",
hindi: "",
},
document: {
en: "",
......@@ -247,20 +277,15 @@ export class ManageComponent {
hindi: "",
},
routine_type: {
en: "class_routine",
beng: "class_routine",
hindi: "class_routine",
en: `${this.routineForm.value.routineType}`,
beng: `${this.routineForm.value.routineType}`,
hindi: `${this.routineForm.value.routineType}`,
},
},
],
count:10,
websiteId: 1,
foreignKeyMapping: {},
foreignKeyMap: {} as ForeignKeyMap,
requiredPresentationField: "",
favourite: true,
icon: "",
dependentFields: {},
dsType: {}
count: 0,
favourite: true
};
}
}
<h3> Routines </h3>
<div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitDelete)="emitDeleteFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn">
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addRoutine()"
......
......@@ -9,13 +9,17 @@ import { SquareButtonComponent } from '../../../component-library/square-button/
import { MatDialog } from '@angular/material/dialog';
import { ManageComponent } from '../manage/manage.component';
import { PrepareRoutineTableDataService } from '../service/prepare-routine-table-data.service';
import { CommonModule } from '@angular/common';
import { AuthService } from '../../../auth/service/auth.service';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
@Component({
selector: 'app-routine',
standalone: true,
imports: [
CustomTableComponent,
SquareButtonComponent
SquareButtonComponent,
CommonModule
],
templateUrl: './routine.component.html',
styleUrl: './routine.component.scss'
......@@ -26,7 +30,9 @@ export class RoutineComponent {
private _routineTransmission: RoutineTransmissionService,
private _urlConfig: UrlConfigService,
private _dialog: MatDialog,
private _prepareRoutineTableData: PrepareRoutineTableDataService
private _prepareRoutineTableData: PrepareRoutineTableDataService,
private _matDialogConfig: MatDialogConfigService,
public authService: AuthService
) { }
public columns: any[] = [];
......@@ -41,12 +47,9 @@ export class RoutineComponent {
}
public addRoutine(): void {
let dialogRef = this._dialog.open(ManageComponent, {
this._dialog.open(ManageComponent, {
data: '',
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
...this._matDialogConfig.matModalConfig()
});
}
......@@ -55,15 +58,8 @@ export class RoutineComponent {
window.open(docLink, '_blank');
}
public emitEditFromTable(emitData: string): void {
let dialogRef = this._dialog.open(ManageComponent, {
data: emitData,
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
public emitDeleteFromTable(emitData: string): void {
alert("Should delete the data");
}
......
......@@ -15,11 +15,12 @@ export class PrepareRoutineTableDataService {
return {
['id']: routine.id,
['session_session_name']: routine.session_session_name?['en']:'',
['class_details']: routine.class_details?['en']:'',
['section_details']: routine.section_details?['en']:'',
['schedule']: routine.schedule['en'],
['action']: ['view', 'edit']
['session_session_name']: routine.session_session_name?.en,
['class_details']: routine.class_details?.en,
['section_details']: routine.section_details?.en,
['routine_type']: routine.routine_type.en,
['schedule']: routine.schedule?.en,
['action']: ['view', 'delete',]
}
})
......@@ -30,9 +31,9 @@ export class PrepareRoutineTableDataService {
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'session_session_name', label: 'Session' },
{ key: 'class_details', label: 'Class' },
{ key: 'section_details', label: 'Section' },
{ key: 'routine_type', label: 'Type' },
{ key: 'action', label: 'Action' },
];
......
......@@ -8,9 +8,16 @@ export class DataSourceService {
constructor() { }
public static readonly ASSIGNMENT_DATA_SOURCE_ID: number = 3188;
// FOR ROUTINE:
public static readonly ROUTINE_DATA_SOURCE_ID: number = 3021;
public static readonly ROUTINE_DATA_SOURCE_NAME: string = 'Routine';
public static readonly ROUTINE_DATA_SOURCE_TYPE: number = 1327;
public static readonly CLASS_DATA_SOURCE_ID: number = 3008;
public static readonly SECTION_DATA_SOURCE_ID: number = 3013;
public static readonly EXAM_SCHEDULE_DATA_SOURCE_ID: number = 3018;
}
export interface RaintreeResponse {
status_code: number;
status: boolean;
message: string;
[index: string]: any;
}
......@@ -7,7 +7,6 @@ import { RaintreeResponse } from "../interface/raintree-response";
export class TransmissionMessageHandlerService {
public hasError(response: RaintreeResponse): boolean {
console.log(response);
let hasError: boolean = false;
let successStatusCode:number[] = [200,201]
......
......@@ -16,7 +16,7 @@ export class FileUploadTransmissionService extends TransmissionService {
onFailure: (error: string) => void,
onComplete: () => void
): void {
this.executePostPayload(
this.executeFormPostPayload(
url,
payload,
onPreExecute,
......
......@@ -10,19 +10,23 @@ export class JWTService {
private _auth:AuthService
) {}
private _jwtToken: string | null = null;
private _expirationDate: Date | null = null;
private _isExpired: boolean | null = null;
private _userId:string = this._auth.localStorageGetItemByKey('user_id');
private _authorizationToken: string = localStorage.getItem('Bearer') || '';
public injectToken(token: string): HttpHeaders {
let authorizationToken: string = localStorage.getItem('Bearer') || '';
let userId = this._auth.localStorageGetItemByKey('user_id');
// TODO: check if token exist in Local storage and handle accordingly
public injectToken(url: string): HttpHeaders {
return new HttpHeaders({
"user-id": userId,
"apikey": authorizationToken,
"user-id": this._userId,
"apikey": this._authorizationToken,
'Content-Type': 'application/json',
});
}
public injectTokenForFormGroupPost(url: string): HttpHeaders {
return new HttpHeaders({
"user-id": this._userId,
"apikey": this._authorizationToken,
});
}
}
......@@ -46,4 +46,5 @@ export class RoutineTransmissionService extends TransmissionService{
true
);
}
}
......@@ -93,11 +93,13 @@ export class TransmissionService {
onPreExecute();
this._http
.post<RaintreeResponse>(url, payload, {
headers: requiresAuthentication
? this._jwt.injectToken(url)
: undefined,
})
.post<RaintreeResponse>(
url,
payload,
{
headers: requiresAuthentication ? this._jwt.injectToken(url) : undefined,
}
)
.pipe(catchError(this._httpErrorHandler.intercept))
.subscribe(
(response: RaintreeResponse) => {
......@@ -199,7 +201,7 @@ export class TransmissionService {
this._http
.post<RaintreeResponse>(url, payload, {
headers: requiresAuthentication
? this._jwt.injectToken(url)
? this._jwt.injectTokenForFormGroupPost(url)
: undefined,
})
.pipe(catchError(this._httpErrorHandler.intercept))
......
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