Commit 7518dedf authored by achinta's avatar achinta

feat: assignment add and delete

parent df9761a5
...@@ -3,6 +3,7 @@ import { UserProfile } from '../interface/user-profile'; ...@@ -3,6 +3,7 @@ import { UserProfile } from '../interface/user-profile';
import { isPlatformBrowser } from '@angular/common'; import { isPlatformBrowser } from '@angular/common';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { RequestMapperService } from '../../mappers/request-mapper.service'; import { RequestMapperService } from '../../mappers/request-mapper.service';
import { LogoutService } from '../../portal/navigation/service/logout.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -12,8 +13,10 @@ export class AuthService { ...@@ -12,8 +13,10 @@ export class AuthService {
public isBrowser: boolean = false; public isBrowser: boolean = false;
constructor( constructor(
@Inject(PLATFORM_ID) private _platformId: Object,
private _router: Router, private _router: Router,
@Inject(PLATFORM_ID) private _platformId: Object) { private _logout: LogoutService,
) {
this.isBrowser = isPlatformBrowser(this._platformId); this.isBrowser = isPlatformBrowser(this._platformId);
} }
...@@ -46,7 +49,7 @@ export class AuthService { ...@@ -46,7 +49,7 @@ export class AuthService {
} }
public localStorageGetItemByKey(key: string): string{ public localStorageGetItemByKey(key: string): string{
const localStorageItem = JSON.parse(localStorage.getItem('userProfile')!); const localStorageItem = JSON.parse(localStorage.getItem('userProfile')!);
return localStorageItem[key] || ''; return localStorageItem[key] || '';
......
...@@ -8,6 +8,4 @@ ...@@ -8,6 +8,4 @@
<input type="text" readonly matInput [value]="fileName" /> <input type="text" readonly matInput [value]="fileName" />
<input type="file" multiple #f_input (change)="onFileSelected($event)" hidden /> <input type="file" multiple #f_input (change)="onFileSelected($event)" hidden />
<mat-error *ngIf="!selectedFiles().length">This field is required</mat-error>
</mat-form-field> </mat-form-field>
\ No newline at end of file
...@@ -23,12 +23,15 @@ export class FileInputComponent { ...@@ -23,12 +23,15 @@ export class FileInputComponent {
// 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 this.fileName = input.files[0].name
} }
} }
......
...@@ -25,6 +25,9 @@ export class TransmissionMapperService { ...@@ -25,6 +25,9 @@ export class TransmissionMapperService {
public static readonly FILE_UPLOAD_TRANSMISSION_URL: string = public static readonly FILE_UPLOAD_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/uploadFile?'; TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/uploadFile?';
public static readonly DELETE_RECORD_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/deleteWebsiteDataSourceFieldsBasedOnDataSourceType?';
// 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 =
......
...@@ -12,6 +12,10 @@ import { PrepareAssignmentTableDataService } from '../service/prepare-assignment ...@@ -12,6 +12,10 @@ import { PrepareAssignmentTableDataService } from '../service/prepare-assignment
import { DataSourceService } from '../../service/data-source.service'; import { DataSourceService } from '../../service/data-source.service';
import { AuthService } from '../../../auth/service/auth.service'; import { AuthService } from '../../../auth/service/auth.service';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
import { DeleteRecordTransmissionService } from '../../../raintree/transmission/delete-record-transmission.service';
import { ToasterService } from '../../../component-library/toaster/toaster.service';
@Component({ @Component({
selector: 'app-assignment', selector: 'app-assignment',
...@@ -30,10 +34,13 @@ export class AssignmentComponent implements OnInit { ...@@ -30,10 +34,13 @@ export class AssignmentComponent implements OnInit {
private _assignmentTransmission: AssignmentTransmissionService, private _assignmentTransmission: AssignmentTransmissionService,
private _urlConfig: UrlConfigService, private _urlConfig: UrlConfigService,
private _prepareAssignmentTableData: PrepareAssignmentTableDataService, private _prepareAssignmentTableData: PrepareAssignmentTableDataService,
public authService: AuthService public matConfig: MatDialogConfigService,
public authService: AuthService,
private _deleteTransmission:DeleteRecordTransmissionService,
private _toaster:ToasterService
) { } ) { }
public columns:any[] = []; public columns: any[] = [];
public data: any[] = []; public data: any[] = [];
...@@ -60,46 +67,54 @@ export class AssignmentComponent implements OnInit { ...@@ -60,46 +67,54 @@ export class AssignmentComponent implements OnInit {
}), }),
() => { }, () => { },
(response) => { }, (response) => { },
(response: AssignmentsResponse) => { (response: RaintreeResponse) => {
this.data = this._prepareAssignmentTableData.prepareMatTableData( this.data = this._prepareAssignmentTableData.prepareMatTableData(
response.data.themeDataSourceFields response['data'].themeDataSourceFields
); );
}, },
(error) => { (error) => {
console.log(error); console.log(error);
}, },
() => { } () => { }
) )
} }
public emitViewFromTable(clickedData: string): void { public emitViewFromTable(emitData: any): void {
alert("Have to view the doc in another page"); let docLink = emitData.document.replace('BASE_URL', TransmissionMapperService.DEV_TRANSMISSION_URL);
window.open(docLink, '_blank');
} }
public emitDeleteFromTable(emitData: string): void { public emitDeleteFromTable(emitData: any): void {
// this._dialog.open(ManageComponent, { if (!confirm("Are you sure to delete ?")) return;
// data: emitData,
// width: '98vw', this._deleteTransmission.deleteRecord(
// height: 'auto', TransmissionMapperService.DELETE_RECORD_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
// maxWidth: '70vw', dataSourceFieldId: `${emitData.id}`,
// maxHeight: '70vh', themeDataSourceId: DataSourceService.ASSIGNMENT_DATA_SOURCE_ID,
// }); }),
() => { },
(response) => { },
(response: RaintreeResponse) => {
alert("Have to Delete "); this._toaster.success("Exam schedule is deleted successfully", 'ok');
this._getAssignments();
},
(error) => {
console.log(error);
},
() => { }
)
} }
public addAssignment(): void { public addAssignment(): void {
// alert("hi")
this._dialog.open(ManageComponent, { this._dialog.open(ManageComponent, {
data: '', data: '',
width: '98vw', ...this.matConfig
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
}); });
} }
......
...@@ -4,21 +4,22 @@ import { LocalizedField } from "../../data-source/interface/localizedField"; ...@@ -4,21 +4,22 @@ import { LocalizedField } from "../../data-source/interface/localizedField";
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
export interface Assignments extends Data { export interface Assignments extends Data {
themeDataSourceFields: Assignment[]; themeDataSourceFields: Assignment[];
dataSourceTypeFieldsList?: Assignment[]
} }
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
export interface Assignment { export interface Assignment {
session: LocalizedField; id: string;
session?: LocalizedField;
subject: LocalizedField; subject: LocalizedField;
assigned_on: LocalizedField; assigned_on: LocalizedField;
last_submission_date: LocalizedField; last_submission_date: LocalizedField;
section: LocalizedField; section: LocalizedField;
docs: LocalizedField; docs: LocalizedField;
class_subject: LocalizedField; class_subject: LocalizedField;
session_session_name: LocalizedField; session_session_name?: LocalizedField;
section_details: LocalizedField; section_details?: LocalizedField;
id: string; subject_subject_name?: LocalizedField;
subject_subject_name: LocalizedField; class_subject_subject_txt?: LocalizedField;
class_subject_subject_txt: LocalizedField;
} }
<pre>{{ data | json }}</pre> <!-- <h1> Hi Manage </h1> -->
<div class="container">
<form class="routine_form" [formGroup]="assignmentForm">
<div class="mat_input_container">
<!-- <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>
</mat-form-field>
</div> -->
<div class="section_dropdown mat_input">
<mat-form-field class="full_width">
<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>
<div class="subject_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Subject</mat-label>
<mat-select formControlName="subject">
@for (subject of subjectDropDownData; track subject) {
<mat-option [value]="subject.value">{{subject.name}}</mat-option>
}
</mat-select>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="date_picker mat_input">
<mat-form-field class="full_width" >
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker" formControlName="lastDate" />
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</div>
<div class="file_upload mat_input">
<app-file-input [label]="'Upload Document'" (filesChange)="onFilesChanged($event)" />
<mat-error *ngIf="!assignmentForm.value.document">This field is required</mat-error>
</div>
</div>
<div class="add_btn">
<app-square-button [buttonIcon]="''" [buttonText]="'submit'" (emitSquareButtonClick)="submitAssignment()" />
</div>
</form>
</div>
\ No newline at end of file
.container{
padding: 10px;
}
.add_btn{
float: right;
}
.mat_input{
margin-bottom: 5px;
}
...@@ -14,10 +14,12 @@ export class PrepareAssignmentTableDataService { ...@@ -14,10 +14,12 @@ export class PrepareAssignmentTableDataService {
return { return {
['id']: assignment.id, ['id']: assignment.id,
['subject']: assignment.class_subject_subject_txt['en'], ['subject']: assignment.subject_subject_name?.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,
['assigned_on']: assignment.assigned_on['en'], ['assigned_on']: assignment.assigned_on?.en,
['last_date']: assignment.last_submission_date['en'],
['document']: assignment.docs['en'],
['action']: ['view', 'delete'] ['action']: ['view', 'delete']
} }
}) })
...@@ -29,9 +31,9 @@ export class PrepareAssignmentTableDataService { ...@@ -29,9 +31,9 @@ export class PrepareAssignmentTableDataService {
public prepareMatTableColumn(): any[] { public prepareMatTableColumn(): any[] {
let columnArray = [ let columnArray = [
{ key: 'section_details', label: 'Class' }, { key: 'section_details', label: 'Section' },
{ key: 'subject', label: 'Subject' }, { key: 'subject', label: 'Subject' },
{ key: 'assigned_on', label: 'Date' }, { key: 'last_date', label: 'Last Date' },
{ key: 'action', label: 'Action' }, { key: 'action', label: 'Action' },
]; ];
......
...@@ -2,7 +2,7 @@ import { ForeignKeyMap } from "./foreignKeyMap"; ...@@ -2,7 +2,7 @@ import { ForeignKeyMap } from "./foreignKeyMap";
// Data Interface // Data Interface
export interface Data { export interface Data {
count: number; count?: number;
id: number | string; id: number | string;
dataSourceName: string; dataSourceName: string;
websiteId?: number; websiteId?: number;
...@@ -10,7 +10,7 @@ export interface Data { ...@@ -10,7 +10,7 @@ export interface Data {
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;
......
import { Data } from "./data";
import { LocalizedField } from "./localizedField";
// ThemeDataSourceField Interface
export interface Subjects extends Data {
themeDataSourceFields: subject[];
}
// ThemeDataSourceField Interface
export interface subject {
id: string;
subject_name: LocalizedField;
}
...@@ -12,6 +12,9 @@ import { PrepareExamTableDataService } from '../service/prepare-exam-table-data. ...@@ -12,6 +12,9 @@ import { PrepareExamTableDataService } from '../service/prepare-exam-table-data.
import { RaintreeResponse } from '../../../raintree/interface/raintree-response'; import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
import { AuthService } from '../../../auth/service/auth.service'; import { AuthService } from '../../../auth/service/auth.service';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service'; import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
import { DeleteRecordTransmissionService } from '../../../raintree/transmission/delete-record-transmission.service';
import { ExamTable } from '../interface/exam-table';
import { ToasterService } from '../../../component-library/toaster/toaster.service';
@Component({ @Component({
selector: 'app-exam', selector: 'app-exam',
...@@ -27,11 +30,13 @@ export class ExamComponent { ...@@ -27,11 +30,13 @@ export class ExamComponent {
constructor( constructor(
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, private _matDialogConfig: MatDialogConfigService,
public authService:AuthService private _deleteTransmission: DeleteRecordTransmissionService,
public _toaster:ToasterService,
public authService: AuthService
) { } ) { }
public columns: any = []; public columns: any = [];
...@@ -50,9 +55,28 @@ export class ExamComponent { ...@@ -50,9 +55,28 @@ export class ExamComponent {
window.open(docLink, '_blank'); window.open(docLink, '_blank');
} }
public emitDeleteFromTable(emitData: string): void { public emitDeleteFromTable(emitData: any): void {
alert("Should delete !!") if(!confirm("Are you sure to delete ?")) return;
this._deleteTransmission.deleteRecord(
TransmissionMapperService.DELETE_RECORD_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
dataSourceFieldId:`${emitData.id}`,
themeDataSourceId: DataSourceService.EXAM_SCHEDULE_DATA_SOURCE_ID,
}),
() => { },
(response) => { },
(response: RaintreeResponse) => {
this._toaster.success("Exam schedule is deleted successfully", 'ok');
this._getExamSchedule();
},
(error) => {
console.log(error);
},
() => { }
)
} }
......
...@@ -6,6 +6,8 @@ import { LocalizedField } from "../../data-source/interface/localizedField"; ...@@ -6,6 +6,8 @@ import { LocalizedField } from "../../data-source/interface/localizedField";
export interface ExamSchedules extends Data { export interface ExamSchedules extends Data {
themeDataSourceFields: ExamSchedule[]; themeDataSourceFields: ExamSchedule[];
dataSourceTypeFieldsList?: ExamSchedule[]
} }
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
...@@ -16,7 +18,7 @@ export interface ExamSchedule { ...@@ -16,7 +18,7 @@ export interface ExamSchedule {
image: LocalizedField; image: LocalizedField;
details: LocalizedField; details: LocalizedField;
class: LocalizedField; class: LocalizedField;
session_session_name: LocalizedField; session_session_name?: LocalizedField;
class_details: LocalizedField; class_details?: LocalizedField;
} }
export interface ExamTable {
id:string;
class_details?: string,
details: string;
term: string;
image: string;
action: string[]
}
\ No newline at end of file
<pre> {{data|json}} </pre> <!-- <h1> Hi Manage </h1> -->
\ No newline at end of file <div class="container">
<form class="routine_form" [formGroup]="examScheduleForm">
<div class="mat_input_container">
<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>
</mat-form-field>
</div>
<div class="section_dropdown mat_input">
<mat-form-field class="full_width">
<mat-label>Select Term</mat-label>
<mat-select formControlName="term">
<mat-option value="First term">First term</mat-option>
<mat-option value="Last term">Last term</mat-option>
</mat-select>
<mat-error>This field is required</mat-error>
</mat-form-field>
</div>
<div class="details_input mat_input">
<mat-form-field class="full_width">
<mat-label>Details</mat-label>
<input
matInput
placeholder="Details"
#input
formControlName="details"
/>
<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="!examScheduleForm.value.document" >This field is required</mat-error>
</div>
</div>
<div class="add_btn">
<app-square-button [buttonIcon]="''" [buttonText]="'submit'" (emitSquareButtonClick)="submitExamSchedule()" />
</div>
</form>
</div>
\ No newline at end of file
.container{
padding: 10px;
}
.add_btn{
float: right;
}
.mat_input{
margin-bottom: 5px;
}
import { CommonModule } from '@angular/common'; import { CommonModule } from "@angular/common";
import { Component, Inject } from '@angular/core'; import { Component, Inject, OnInit } from "@angular/core";
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { FormControl, FormGroup, ReactiveFormsModule, Validators } from "@angular/forms";
import { MAT_DIALOG_DATA } from "@angular/material/dialog";
import { MatInputModule } from "@angular/material/input";
import { MatSelectModule } from "@angular/material/select";
import { FileInputComponent } from "../../../component-library/file-input/file-input.component";
import { SquareButtonComponent } from "../../../component-library/square-button/square-button.component";
import { FileUploadTransmissionService } from "../../../raintree/transmission/file-upload-transmission.service";
import { TransmissionMapperService } from "../../../mappers/transmission-mapper.service";
import { AuthService } from "../../../auth/service/auth.service";
import { RaintreeResponse } from "../../../raintree/interface/raintree-response";
import { ClassTransmissionService } from "../../../raintree/transmission/class-transmission.service";
import { UrlConfigService } from "../../service/url-config.service";
import { DataSourceService } from "../../service/data-source.service";
import { classResponse } from "../../../raintree/interface/class-respons";
import { Dropdown } from "../../../component-library/dropdown/interface/dropdown";
import { StudentClass } from "../../data-source/interface/class";
import { ExamScheduleService } from "../../../raintree/transmission/exam-schedule.service";
import { ToasterService } from "../../../component-library/toaster/toaster.service";
import { ExamSchedules } from "../interface/exam-schedule";
@Component({ @Component({
selector: 'app-manage', selector: "app-manage",
imports: [ imports: [
CommonModule CommonModule,
MatInputModule,
MatSelectModule,
ReactiveFormsModule,
FileInputComponent,
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 _fileUpload: FileUploadTransmissionService,
private _auth: AuthService,
private _classTransmission: ClassTransmissionService,
private _urlConfig: UrlConfigService,
private _examScheduleTransmission: ExamScheduleService,
public toaster: ToasterService
) { } ) { }
public classDropDownData: Dropdown[] = [];
public examScheduleForm = new FormGroup({
class: new FormControl("", [Validators.required]),
term: new FormControl("", [Validators.required]),
details: new FormControl("", [Validators.required]),
document: new FormControl("", [Validators.required]),
});
public ngOnInit(): void {
this._getClasses();
}
public onFilesChanged(files: File[]): void {
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.examScheduleForm.value.document = `${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}`
this.toaster.success(response.message,'Ok')
},
(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: RaintreeResponse) => {
this.classDropDownData = response['data']["themeDataSourceFields"].map(
(sClass: StudentClass) => {
return {
["name"]: sClass.details["en"],
["value"]: sClass.id,
};
}
);
},
(error) => {
console.log(error);
},
() => { }
);
}
public submitExamSchedule(): void {
if (this.examScheduleForm.invalid) return;
this._examScheduleTransmission.addExamSchedule(
TransmissionMapperService.SAVE_TRANSMISSION_URL + `websiteId=${this._auth.localStorageGetItemByKey('project_id')}`,
this._prepareExamSchedulePayload(),
() => { },
() => { },
(response: RaintreeResponse) => {
this.toaster.success("Exam schedule added successfully", 'Done');
window.location.reload();
},
(error) => {
console.log(error);
},
() => { }
);
}
private _prepareExamSchedulePayload(): ExamSchedules {
return {
"themeDataSourceFields": [
{
"id": "",
"session": {
"en": "",
"beng": "",
"hindi": ""
},
"Term": {
"en": `${this.examScheduleForm.value.term}`,
"beng": `${this.examScheduleForm.value.term}`,
"hindi": `${this.examScheduleForm.value.term}`
},
"image": {
"en": `${this.examScheduleForm.value.document}`,
"beng": `${this.examScheduleForm.value.document}`,
"hindi": `${this.examScheduleForm.value.document}`
},
"details": {
"en": `${this.examScheduleForm.value.details}`,
"beng": `${this.examScheduleForm.value.details}`,
"hindi": `${this.examScheduleForm.value.details}`
},
"class": {
"en": `${this.examScheduleForm.value.class}`,
"beng": `${this.examScheduleForm.value.class}`,
"hindi": `${this.examScheduleForm.value.class}`
}
}
],
"dataSourceName": DataSourceService.EXAM_SCHEDULE_DATA_SOURCE_NAME,
"id": DataSourceService.EXAM_SCHEDULE_DATA_SOURCE_ID,
"type": `${DataSourceService.EXAM_SCHEDULE_DATA_SOURCE_TYPE}`,
"themeId": `${this._auth.localStorageGetItemByKey('project_id')}`,
"slideLst": null,
"heading": "undefined",
"dataSourceTypeFieldsList": [
{
"id": "",
"session": {
"en": "",
"beng": "",
"hindi": ""
},
"Term": {
"en": `${this.examScheduleForm.value.term}`,
"beng": `${this.examScheduleForm.value.term}`,
"hindi": `${this.examScheduleForm.value.term}`
},
"image": {
"en": `${this.examScheduleForm.value.document}`,
"beng": `${this.examScheduleForm.value.document}`,
"hindi": `${this.examScheduleForm.value.document}`
},
"details": {
"en": `${this.examScheduleForm.value.details}`,
"beng": `${this.examScheduleForm.value.details}`,
"hindi": `${this.examScheduleForm.value.details}`
},
"class": {
"en": `${this.examScheduleForm.value.class}`,
"beng": `${this.examScheduleForm.value.class}`,
"hindi": `${this.examScheduleForm.value.class}`
}
}
]
};
}
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ExamSchedule } from '../interface/exam-schedule'; import { ExamSchedule } from '../interface/exam-schedule';
import { ExamTable } from '../interface/exam-table';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -8,17 +9,17 @@ export class PrepareExamTableDataService { ...@@ -8,17 +9,17 @@ export class PrepareExamTableDataService {
constructor() { } constructor() { }
public prepareMatTableData(data: ExamSchedule[]): any { public prepareMatTableData(data: ExamSchedule[]): ExamTable[] {
let dataArray = data.map((schedule: ExamSchedule) => { let dataArray = data.map((schedule: ExamSchedule) => {
return { return {
['id']: schedule.id, id: schedule.id,
['class_details']: schedule.class_details['en'], class_details: schedule.class_details?.en,
['details']: schedule.details['en'], details: schedule.details['en'],
['term']: schedule.Term['en'], term: schedule.Term['en'],
['image']: schedule.image['en'], image: schedule.image['en'],
['action']: ['view', 'delete'] action: ['view', 'delete']
} }
}) })
......
...@@ -64,7 +64,7 @@ export class ManageComponent { ...@@ -64,7 +64,7 @@ export class ManageComponent {
class: new FormControl("", [Validators.required]), class: new FormControl("", [Validators.required]),
section: new FormControl("", [Validators.required]), section: new FormControl("", [Validators.required]),
routineType: new FormControl("", [Validators.required]), routineType: new FormControl("", [Validators.required]),
schedule: new FormControl("", [Validators.required]), schedule: new FormControl(""),
}); });
ngOnInit(): void { ngOnInit(): void {
...@@ -73,7 +73,6 @@ export class ManageComponent { ...@@ -73,7 +73,6 @@ export class ManageComponent {
} }
public onFilesChanged(files: File[]): void { public onFilesChanged(files: File[]): void {
console.log('Selected Files:', files);
const formData = new FormData(); const formData = new FormData();
...@@ -90,7 +89,7 @@ export class ManageComponent { ...@@ -90,7 +89,7 @@ export class ManageComponent {
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
this.routineForm.value.schedule = `${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}` this.routineForm.value.schedule = `${TransmissionMapperService.DEV_TRANSMISSION_URL}/webomagic/getFile?fid=${response['data']}`
this._toaster.success(response.message,'Ok')
}, },
(error) => { (error) => {
console.log(error); console.log(error);
...@@ -102,7 +101,7 @@ export class ManageComponent { ...@@ -102,7 +101,7 @@ export class ManageComponent {
} }
public submitRoutine(): void { public submitRoutine(): void {
if(this.routineForm.invalid) return; if(this.routineForm.invalid) return;
this._routineTransmission.submitRoutine( this._routineTransmission.submitRoutine(
...@@ -143,8 +142,8 @@ export class ManageComponent { ...@@ -143,8 +142,8 @@ export class ManageComponent {
}), }),
() => {}, () => {},
(response) => {}, (response) => {},
(response: classResponse) => { (response: RaintreeResponse) => {
this.classDropDownData = response.data["themeDataSourceFields"].map( this.classDropDownData = response['data']["themeDataSourceFields"].map(
(sClass: StudentClass) => { (sClass: StudentClass) => {
return { return {
["name"]: sClass.details["en"], ["name"]: sClass.details["en"],
...@@ -177,8 +176,8 @@ export class ManageComponent { ...@@ -177,8 +176,8 @@ export class ManageComponent {
}), }),
() => {}, () => {},
(response) => {}, (response) => {},
(response: SectionResponse) => { (response: RaintreeResponse) => {
this.sectionDropDownData = response.data["themeDataSourceFields"].map( this.sectionDropDownData = response['data']["themeDataSourceFields"].map(
(sSection: StudentSection) => { (sSection: StudentSection) => {
return { return {
["name"]: sSection.section["en"], ["name"]: sSection.section["en"],
......
...@@ -12,6 +12,9 @@ import { PrepareRoutineTableDataService } from '../service/prepare-routine-table ...@@ -12,6 +12,9 @@ import { PrepareRoutineTableDataService } from '../service/prepare-routine-table
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { AuthService } from '../../../auth/service/auth.service'; import { AuthService } from '../../../auth/service/auth.service';
import { MatDialogConfigService } from '../../service/mat-dialog-config.service'; import { MatDialogConfigService } from '../../service/mat-dialog-config.service';
import { RaintreeResponse } from '../../../raintree/interface/raintree-response';
import { DeleteRecordTransmissionService } from '../../../raintree/transmission/delete-record-transmission.service';
import { ToasterService } from '../../../component-library/toaster/toaster.service';
@Component({ @Component({
selector: 'app-routine', selector: 'app-routine',
...@@ -32,6 +35,8 @@ export class RoutineComponent { ...@@ -32,6 +35,8 @@ export class RoutineComponent {
private _dialog: MatDialog, private _dialog: MatDialog,
private _prepareRoutineTableData: PrepareRoutineTableDataService, private _prepareRoutineTableData: PrepareRoutineTableDataService,
private _matDialogConfig: MatDialogConfigService, private _matDialogConfig: MatDialogConfigService,
private _deleteTransmission: DeleteRecordTransmissionService,
private _toaster:ToasterService,
public authService: AuthService public authService: AuthService
) { } ) { }
...@@ -58,8 +63,28 @@ export class RoutineComponent { ...@@ -58,8 +63,28 @@ export class RoutineComponent {
window.open(docLink, '_blank'); window.open(docLink, '_blank');
} }
public emitDeleteFromTable(emitData: string): void { public emitDeleteFromTable(emitData: any): void {
alert("Should delete the data"); if(!confirm("Are you sure to delete ?")) return;
this._deleteTransmission.deleteRecord(
TransmissionMapperService.DELETE_RECORD_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
dataSourceFieldId:`${emitData.id}`,
themeDataSourceId: DataSourceService.ROUTINE_DATA_SOURCE_ID,
}),
() => { },
(response) => { },
(response: RaintreeResponse) => {
this._toaster.success("Routine is deleted successfully", 'ok');
this._getRoutines();
},
(error) => {
console.log(error);
},
() => { }
)
} }
...@@ -79,9 +104,9 @@ export class RoutineComponent { ...@@ -79,9 +104,9 @@ export class RoutineComponent {
}), }),
() => { }, () => { },
(response) => { }, (response) => { },
(response: RoutineResponse) => { (response: RaintreeResponse) => {
this.data = this._prepareRoutineTableData.prepareMatTableData(response.data.themeDataSourceFields); this.data = this._prepareRoutineTableData.prepareMatTableData(response['data'].themeDataSourceFields);
}, },
(error) => { (error) => {
console.log(error); console.log(error);
......
...@@ -6,18 +6,24 @@ import { Injectable } from '@angular/core'; ...@@ -6,18 +6,24 @@ import { Injectable } from '@angular/core';
export class DataSourceService { export class DataSourceService {
constructor() { } constructor() { }
// FOR ASSIGNMENT:
public static readonly ASSIGNMENT_DATA_SOURCE_ID: number = 3188; public static readonly ASSIGNMENT_DATA_SOURCE_ID: number = 3188;
public static readonly ASSIGNMENT_DATA_SOURCE_NAME: string = 'Assignment';
public static readonly ASSIGNMENT_DATA_SOURCE_TYPE: number = 1330;
// FOR ROUTINE: // 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_NAME: string = 'Routine';
public static readonly ROUTINE_DATA_SOURCE_TYPE: number = 1327; public static readonly ROUTINE_DATA_SOURCE_TYPE: number = 1327;
// FOR EXAM SCHEDULE:
public static readonly EXAM_SCHEDULE_DATA_SOURCE_ID: number = 3018;
public static readonly EXAM_SCHEDULE_DATA_SOURCE_NAME: string = "Exam Schedule";
public static readonly EXAM_SCHEDULE_DATA_SOURCE_TYPE: number = 1329;
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 SUBJECT_DATA_SOURCE_ID: number = 3014;
} }
...@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { TransmissionService } from './transmission.service'; import { TransmissionService } from './transmission.service';
import { RaintreeResponse } from '../interface/raintree-response'; import { RaintreeResponse } from '../interface/raintree-response';
import { AssignmentsResponse } from '../interface/assignment-respons'; import { AssignmentsResponse } from '../interface/assignment-respons';
import { Assignments } from '../../portal/assignment/interface/assignment';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -11,8 +12,8 @@ export class AssignmentTransmissionService extends TransmissionService { ...@@ -11,8 +12,8 @@ export class AssignmentTransmissionService extends TransmissionService {
public getAssignment( public getAssignment(
url: string, url: string,
onPreExecute: () => void, onPreExecute: () => void,
onPostExecute: (response: any) => void, onPostExecute: (response: RaintreeResponse) => void,
onSuccess: (response: any) => void, onSuccess: (response: RaintreeResponse) => void,
onFailure: (error: string) => void, onFailure: (error: string) => void,
onComplete: () => void onComplete: () => void
): void { ): void {
...@@ -27,4 +28,25 @@ export class AssignmentTransmissionService extends TransmissionService { ...@@ -27,4 +28,25 @@ export class AssignmentTransmissionService extends TransmissionService {
true true
); );
} }
public addAssignment(
url: string,
payload:Assignments,
onPreExecute: () => void,
onPostExecute: (response: RaintreeResponse) => void,
onSuccess: (response: RaintreeResponse) => void,
onFailure: (error: string) => void,
onComplete: () => void
){
this.executePostPayload(
url,
payload,
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { TransmissionService } from './transmission.service'; import { TransmissionService } from './transmission.service';
import { RaintreeResponse } from '../interface/raintree-response';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -8,8 +9,8 @@ export class ClassTransmissionService extends TransmissionService{ ...@@ -8,8 +9,8 @@ export class ClassTransmissionService extends TransmissionService{
public getClasses( public getClasses(
url: string, url: string,
onPreExecute: () => void, onPreExecute: () => void,
onPostExecute: (response: any) => void, onPostExecute: (response: RaintreeResponse) => void,
onSuccess: (response: any) => void, onSuccess: (response: RaintreeResponse) => void,
onFailure: (error: string) => void, onFailure: (error: string) => void,
onComplete: () => void onComplete: () => void
): void { ): void {
...@@ -28,8 +29,28 @@ export class ClassTransmissionService extends TransmissionService{ ...@@ -28,8 +29,28 @@ export class ClassTransmissionService extends TransmissionService{
public getSection( public getSection(
url: string, url: string,
onPreExecute: () => void, onPreExecute: () => void,
onPostExecute: (response: any) => void, onPostExecute: (response: RaintreeResponse) => void,
onSuccess: (response: any) => void, onSuccess: (response: RaintreeResponse) => void,
onFailure: (error: string) => void,
onComplete: () => void
){
this.executePostPayload(
url,
{},
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
public getSubject(
url: string,
onPreExecute: () => void,
onPostExecute: (response: RaintreeResponse) => void,
onSuccess: (response: RaintreeResponse) => void,
onFailure: (error: string) => void, onFailure: (error: string) => void,
onComplete: () => void onComplete: () => void
){ ){
......
import { TestBed } from '@angular/core/testing';
import { DeleteRecordTransmissionService } from './delete-record-transmission.service';
describe('DeleteRecordTransmissionService', () => {
let service: DeleteRecordTransmissionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DeleteRecordTransmissionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { TransmissionService } from './transmission.service';
import { RaintreeResponse } from '../interface/raintree-response';
@Injectable({
providedIn: 'root'
})
export class DeleteRecordTransmissionService extends TransmissionService {
public deleteRecord(
url: string,
onPreExecute: () => void,
onPostExecute: (response: RaintreeResponse) => void,
onSuccess: (response: RaintreeResponse) => void,
onFailure: (error: string) => void,
onComplete: () => void
): void {
this.executePostPayload(
url,
{},
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
}
...@@ -26,4 +26,25 @@ export class ExamScheduleService extends TransmissionService { ...@@ -26,4 +26,25 @@ export class ExamScheduleService extends TransmissionService {
true true
); );
} }
public addExamSchedule(
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
);
}
} }
...@@ -10,23 +10,27 @@ export class JWTService { ...@@ -10,23 +10,27 @@ export class JWTService {
private _auth:AuthService private _auth:AuthService
) {} ) {}
private _userId:string = this._auth.localStorageGetItemByKey('user_id'); // private _userId:string = this._auth.localStorageGetItemByKey('user_id') ;
private _authorizationToken: string = localStorage.getItem('Bearer') || ''; // private _authorizationToken: string = localStorage.getItem('Bearer') || '';
public injectToken(url: string): HttpHeaders { public injectToken(url: string): HttpHeaders {
// debugger;
let userId = this._auth.localStorageGetItemByKey('user_id') ;
let authorizationToken = localStorage.getItem('Bearer') || '';
return new HttpHeaders({ return new HttpHeaders({
"user-id": this._userId, "user-id": userId,
"apikey": this._authorizationToken, "apikey": authorizationToken,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}); });
} }
public injectTokenForFormGroupPost(url: string): HttpHeaders { public injectTokenForFormGroupPost(url: string): HttpHeaders {
let userId = this._auth.localStorageGetItemByKey('user_id') ;
let authorizationToken = localStorage.getItem('Bearer') || '';
return new HttpHeaders({ return new HttpHeaders({
"user-id": this._userId, "user-id": userId,
"apikey": this._authorizationToken, "apikey": authorizationToken,
}); });
} }
} }
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