Commit df9761a5 authored by achinta's avatar achinta

feat: add routine with file uploaded

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