Commit ba7fafed authored by achinta's avatar achinta

change: assignment add and get by logged user type

parent 9b474451
...@@ -42,7 +42,7 @@ export class LoginComponent { ...@@ -42,7 +42,7 @@ export class LoginComponent {
public hidePassword: boolean = true; public hidePassword: boolean = true;
public loginForm = new FormGroup({ public loginForm = new FormGroup({
email: new FormControl('achintadey.websofttechs@gmail.com', [Validators.required]), email: new FormControl('baswajit@majhi.com', [Validators.required]),
password: new FormControl('P@$$w0rd', [Validators.required]), password: new FormControl('P@$$w0rd', [Validators.required]),
}); });
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
</button> </button>
</ng-container> </ng-container>
<ng-container *ngIf="item =='edit' && authService.getUserRole() != 'Student'"> <ng-container *ngIf="item =='edit' && authService.getUserRole() !== 'Parent'">
<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'"> <ng-container *ngIf="item =='delete' && authService.getUserRole() !== 'Parent'">
<button class="view_button d_inline_block width_auto " (click)="delete(element)"> <button class="view_button d_inline_block width_auto " (click)="delete(element)">
<span class="material-symbols-outlined">delete</span> <span class="material-symbols-outlined">delete</span>
</button> </button>
......
<h2 mat-dialog-title>Delete file</h2>
<mat-dialog-content>
Would you like to delete cat.jpeg?
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button mat-dialog-close>No</button>
<button mat-button mat-dialog-close cdkFocusInitial>Ok</button>
</mat-dialog-actions>
\ No newline at end of file
button {
margin-right: 8px;
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatConfirmDialogComponent } from './mat-confirm-dialog.component';
describe('MatConfirmDialogComponent', () => {
let component: MatConfirmDialogComponent;
let fixture: ComponentFixture<MatConfirmDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MatConfirmDialogComponent]
})
.compileComponents();
fixture = TestBed.createComponent(MatConfirmDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import {
MatDialogActions,
MatDialogClose,
MatDialogContent,
MatDialogTitle,
} from '@angular/material/dialog';
import { MatInputModule } from '@angular/material/input';
@Component({
selector: 'app-mat-confirm-dialog',
imports: [
MatButtonModule,
MatDialogActions,
MatDialogClose,
MatDialogTitle,
MatDialogContent,
MatInputModule
],
templateUrl: './mat-confirm-dialog.component.html',
styleUrl: './mat-confirm-dialog.component.scss',
standalone: true
})
export class MatConfirmDialogComponent {
}
...@@ -5,12 +5,10 @@ import { Injectable } from '@angular/core'; ...@@ -5,12 +5,10 @@ import { Injectable } from '@angular/core';
}) })
export class RoleMapperService { export class RoleMapperService {
constructor() { }
// NOTE:: this will be same value which is come from backend role // NOTE:: this will be same value which is come from backend role
public static readonly TEACHER_ROLE: string = 'EDITOR'; public static readonly TEACHER_ROLE: string = 'EDITOR';
public static readonly STUDENT_ROLE: string = 'Student'; public static readonly STUDENT_ROLE: string = 'Parent';
public static get getAllRole(): string[] { public static get getAllRole(): string[] {
return [ return [
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
/> />
</div> </div>
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'"> <div class="add_btn" *ngIf="authService.getUserRole() !== 'Parent'">
<app-square-button <app-square-button
[buttonIcon]="'add'" [buttonIcon]="'add'"
(emitSquareButtonClick)="addAssignment()" (emitSquareButtonClick)="addAssignment()"
/> />
</div> </div>
<!-- <app-mat-confirm-dialog /> -->
...@@ -16,6 +16,8 @@ import { DeleteRecordTransmissionService } from '../../../raintree/transmission/ ...@@ -16,6 +16,8 @@ import { DeleteRecordTransmissionService } from '../../../raintree/transmission/
import { ToasterService } from '../../../component-library/toaster/toaster.service'; import { ToasterService } from '../../../component-library/toaster/toaster.service';
import { CustomTableColumn } from '../../../component-library/interface/custom-table-column'; import { CustomTableColumn } from '../../../component-library/interface/custom-table-column';
import { AssignmentTable } from '../interface/assignment-table'; import { AssignmentTable } from '../interface/assignment-table';
import { MatConfirmDialogComponent } from "../../../component-library/mat-confirm-dialog/mat-confirm-dialog.component";
import { RoleMapperService } from '../../../mappers/role-mapper.service';
@Component({ @Component({
selector: 'app-assignment', selector: 'app-assignment',
...@@ -23,7 +25,7 @@ import { AssignmentTable } from '../interface/assignment-table'; ...@@ -23,7 +25,7 @@ import { AssignmentTable } from '../interface/assignment-table';
CustomTableComponent, CustomTableComponent,
CommonModule, CommonModule,
SquareButtonComponent SquareButtonComponent
], ],
templateUrl: './assignment.component.html', templateUrl: './assignment.component.html',
styleUrl: './assignment.component.scss' styleUrl: './assignment.component.scss'
}) })
...@@ -50,6 +52,12 @@ export class AssignmentComponent implements OnInit { ...@@ -50,6 +52,12 @@ export class AssignmentComponent implements OnInit {
this._getAssignments(); this._getAssignments();
} }
openDialog(): void {
this._dialog.open(MatConfirmDialogComponent, {
width: '250px',
});
}
private _getAssignments(): void { private _getAssignments(): void {
this._assignmentTransmission.getAssignment( this._assignmentTransmission.getAssignment(
...@@ -57,13 +65,17 @@ export class AssignmentComponent implements OnInit { ...@@ -57,13 +65,17 @@ export class AssignmentComponent implements OnInit {
aggregationOnUniqueFld: false, aggregationOnUniqueFld: false,
datasourceId: DataSourceService.ASSIGNMENT_DATA_SOURCE_ID, datasourceId: DataSourceService.ASSIGNMENT_DATA_SOURCE_ID,
dontIncludeForeignKey: false, dontIncludeForeignKey: false,
expand: false, expand: true,
isUniqueValueRequiredForFieldToDisplay: false, isUniqueValueRequiredForFieldToDisplay: false,
language: "en", language: "en",
limit: 100, limit: 100,
orderBy: "ASC", orderBy: "ASC",
page: 1, page: 1,
roleBasedFiltering: true roleBasedFiltering: true,
fieldName: this._urlConfig.getFiledNameFilter('assignment'),
operators: this._urlConfig.getFieldOperatorFilter('assignment'),
fieldValues: this._urlConfig.getFieldValuesFilter('assignment'),
// this.authService.localStorageGetItemByKey("user_id"),
}), }),
() => { }, () => { },
(response) => { }, (response) => { },
...@@ -99,7 +111,7 @@ export class AssignmentComponent implements OnInit { ...@@ -99,7 +111,7 @@ export class AssignmentComponent implements OnInit {
(response) => { }, (response) => { },
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
this._toaster.success("Exam schedule is deleted successfully", 'ok'); this._toaster.success("Exam schedule is deleted successfully", 'Ok');
this._getAssignments(); this._getAssignments();
}, },
(error) => { (error) => {
......
...@@ -12,14 +12,15 @@ export interface Assignment { ...@@ -12,14 +12,15 @@ export interface Assignment {
id: string; id: string;
session?: LocalizedField; session?: LocalizedField;
subject: LocalizedField; subject: LocalizedField;
school: 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;
session_session_name?: LocalizedField; session_session_name?: LocalizedField;
section_details?: LocalizedField; section_details?: LocalizedField;
subject_subject_name?: LocalizedField; subject_subject_name?: LocalizedField;
class_subject_subject_txt?: LocalizedField; class_subject_subject_txt?: LocalizedField;
assigned_by_teacher: LocalizedField;
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<div class="date_picker mat_input"> <div class="date_picker mat_input">
<mat-form-field class="full_width" > <mat-form-field class="full_width" >
<mat-label>Choose a date</mat-label> <mat-label>Submission Date</mat-label>
<input matInput [matDatepicker]="picker" formControlName="lastDate" /> <input matInput [matDatepicker]="picker" formControlName="lastDate" />
<mat-hint>MM/DD/YYYY</mat-hint> <mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle> <mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
......
...@@ -165,7 +165,7 @@ export class ManageComponent { ...@@ -165,7 +165,7 @@ export class ManageComponent {
TransmissionMapperService.GET_TRANSMISSION_URL + TransmissionMapperService.GET_TRANSMISSION_URL +
this._urlConfig.generateDatasourceConfigUrl({ this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld:false, aggregationOnUniqueFld:false,
datasourceId: DataSourceService.SUBJECT_DATA_SOURCE_ID, datasourceId: DataSourceService.CLASS_SECTION_SUBJECT_DATA_SOURCE_ID,
dontIncludeForeignKey:false, dontIncludeForeignKey:false,
expand:false, expand:false,
isUniqueValueRequiredForFieldToDisplay:false, isUniqueValueRequiredForFieldToDisplay:false,
...@@ -173,6 +173,9 @@ export class ManageComponent { ...@@ -173,6 +173,9 @@ export class ManageComponent {
limit:100, limit:100,
orderBy:"ASC", orderBy:"ASC",
page:1, page:1,
fieldName: "subject_teacher",
operators: "eq",
fieldValues: this._auth.localStorageGetItemByKey("user_id")
}), }),
() => { }, () => { },
(response) => { }, (response) => { },
...@@ -180,8 +183,8 @@ export class ManageComponent { ...@@ -180,8 +183,8 @@ export class ManageComponent {
this.subjectDropDownData = response['data']["themeDataSourceFields"].map( this.subjectDropDownData = response['data']["themeDataSourceFields"].map(
(sSubject: subject) => { (sSubject: subject) => {
return { return {
["name"]: sSubject.subject_name["en"], name: sSubject.subject_subject_name['en'],
["value"]: sSubject.id, value: sSubject.id,
}; };
} }
); );
...@@ -206,7 +209,9 @@ export class ManageComponent { ...@@ -206,7 +209,9 @@ export class ManageComponent {
limit: 100, limit: 100,
orderBy: "ASC", orderBy: "ASC",
page: 1, page: 1,
roleBasedFiltering: true, fieldName: "teacher",
operators: "eq",
fieldValues: this._auth.localStorageGetItemByKey("user_id")
}), }),
() => { }, () => { },
(response) => { }, (response) => { },
...@@ -214,7 +219,7 @@ export class ManageComponent { ...@@ -214,7 +219,7 @@ export class ManageComponent {
this.sectionDropDownData = response['data']["themeDataSourceFields"].map( this.sectionDropDownData = response['data']["themeDataSourceFields"].map(
(sSection: StudentSection) => { (sSection: StudentSection) => {
return { return {
["name"]: sSection.section["en"], ["name"]: sSection.details['en'],
["value"]: sSection.id, ["value"]: sSection.id,
}; };
} }
...@@ -238,15 +243,10 @@ export class ManageComponent { ...@@ -238,15 +243,10 @@ export class ManageComponent {
beng: `${this.assignmentForm.value.section}`, beng: `${this.assignmentForm.value.section}`,
hindi: `${this.assignmentForm.value.section}`, hindi: `${this.assignmentForm.value.section}`,
}, },
class_subject: {
en: ``,
beng: ``,
hindi: ``,
},
assigned_on: { assigned_on: {
en: "", en: `${this._datePipe.transform(new Date(),'yyyy-MM-dd')}`,
beng: "", beng: `${this._datePipe.transform(new Date(),'yyyy-MM-dd')}`,
hindi: "", hindi: `${this._datePipe.transform(new Date(),'yyyy-MM-dd')}`,
}, },
last_submission_date: { last_submission_date: {
en: `${this._datePipe.transform(this.assignmentForm.value.lastDate,'yyyy-MM-dd')}`, en: `${this._datePipe.transform(this.assignmentForm.value.lastDate,'yyyy-MM-dd')}`,
...@@ -263,6 +263,21 @@ export class ManageComponent { ...@@ -263,6 +263,21 @@ export class ManageComponent {
beng: `${this.assignmentForm.value.subject}`, beng: `${this.assignmentForm.value.subject}`,
hindi: `${this.assignmentForm.value.subject}`, hindi: `${this.assignmentForm.value.subject}`,
}, },
assigned_by_teacher: {
en: `${this._auth.localStorageGetItemByKey('user_id')}`,
beng: `${this._auth.localStorageGetItemByKey('user_id')}`,
hindi: `${this._auth.localStorageGetItemByKey('user_id')}`,
},
session: {
en: '86af4d6b5675a82df4581f00c67f0c7f',
beng:'86af4d6b5675a82df4581f00c67f0c7f',
hindi: '86af4d6b5675a82df4581f00c67f0c7f',
},
school: {
en: `${localStorage.getItem('school_id')}`,
beng:`${localStorage.getItem('school_id')}`,
hindi: `${localStorage.getItem('school_id')}`,
},
}, },
], ],
dataSourceName: DataSourceService.ASSIGNMENT_DATA_SOURCE_NAME, dataSourceName: DataSourceService.ASSIGNMENT_DATA_SOURCE_NAME,
...@@ -279,15 +294,10 @@ export class ManageComponent { ...@@ -279,15 +294,10 @@ export class ManageComponent {
beng: `${this.assignmentForm.value.section}`, beng: `${this.assignmentForm.value.section}`,
hindi: `${this.assignmentForm.value.section}`, hindi: `${this.assignmentForm.value.section}`,
}, },
class_subject: {
en: ``,
beng: ``,
hindi: ``,
},
assigned_on: { assigned_on: {
en: "", en: `${this._datePipe.transform(new Date(),'yyyy-MM-dd')}`,
beng: "", beng: `${this._datePipe.transform(new Date(),'yyyy-MM-dd')}`,
hindi: "", hindi: `${this._datePipe.transform(new Date(),'yyyy-MM-dd')}`,
}, },
last_submission_date: { last_submission_date: {
en: `${this._datePipe.transform(this.assignmentForm.value.lastDate,'yyyy-MM-dd')}`, en: `${this._datePipe.transform(this.assignmentForm.value.lastDate,'yyyy-MM-dd')}`,
...@@ -304,10 +314,23 @@ export class ManageComponent { ...@@ -304,10 +314,23 @@ export class ManageComponent {
beng: `${this.assignmentForm.value.subject}`, beng: `${this.assignmentForm.value.subject}`,
hindi: `${this.assignmentForm.value.subject}`, hindi: `${this.assignmentForm.value.subject}`,
}, },
assigned_by_teacher: {
en: `${this._auth.localStorageGetItemByKey('user_id')}`,
beng: `${this._auth.localStorageGetItemByKey('user_id')}`,
hindi: `${this._auth.localStorageGetItemByKey('user_id')}`,
},
session: {
en: '86af4d6b5675a82df4581f00c67f0c7f',
beng:'86af4d6b5675a82df4581f00c67f0c7f',
hindi: '86af4d6b5675a82df4581f00c67f0c7f',
},
school: {
en: `${localStorage.getItem('school_id')}`,
beng:`${localStorage.getItem('school_id')}`,
hindi: `${localStorage.getItem('school_id')}`,
},
}, },
], ],
count: 0,
favourite: true
}; };
} }
......
...@@ -10,6 +10,13 @@ export interface Subjects extends Data { ...@@ -10,6 +10,13 @@ export interface Subjects extends Data {
// ThemeDataSourceField Interface // ThemeDataSourceField Interface
export interface subject { export interface subject {
id: string; id: string;
subject_name: LocalizedField; class: LocalizedField;
class_details: LocalizedField;
section: LocalizedField;
section_details: LocalizedField;
subject: LocalizedField;
subject_subject_name: LocalizedField;
subject_teacher: LocalizedField;
subject_txt: LocalizedField;
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
/> />
</div> </div>
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'"> <div class="add_btn" *ngIf="authService.getUserRole() !== 'Parent'">
<app-square-button <app-square-button
[buttonIcon]="'add'" [buttonIcon]="'add'"
(emitSquareButtonClick)="addExam()" (emitSquareButtonClick)="addExam()"
......
import { Data } from "../../data-source/interface/data";
import { LocalizedField } from "../../data-source/interface/localizedField";
// ThemeDataSourceField Interface
export interface Students extends Data {
themeDataSourceFields: Student[];
}
// ThemeDataSourceField Interface
export interface Student {
id: string;
name: LocalizedField;
parent_user: LocalizedField;
class: LocalizedField;
section: LocalizedField;
email: LocalizedField;
phone: LocalizedField;
address: LocalizedField;
user_type: LocalizedField;
school: LocalizedField;
school_school_Name: LocalizedField;
class_details: LocalizedField;
section_details: LocalizedField;
}
<div class="portal_dashboard_container"> <div class="portal_dashboard_container">
<div class="portal_dashboard_inner"> <div class="portal_dashboard_inner">
<div class="portal_card_container"> <div class="portal_card_container">
@if (authService.getUserRole() === 'Parent') {
<div class="student_dropdown">
<mat-form-field class="full_width">
<mat-label >Select Student</mat-label>
<mat-select [(value)]="selectedStudent" (selectionChange)="onStudentChange()" >
@for (student of studentDropdown; track student) {
<mat-option [value]="student.value" > {{student.name}} </mat-option>
}
</mat-select>
</mat-form-field>
</div>
}
<app-colored-card <app-colored-card
[cardTextOneHeading]="'Assignment'" [cardTextOneHeading]="'Assignment'"
[cardTextOne]="''" [cardTextOne]="''"
......
import { Component, OnInit } from '@angular/core'; import { Component, inject, OnInit } from '@angular/core';
import { ColoredCardComponent } from '../../component-library/colored-card/colored-card.component'; import { ColoredCardComponent } from '../../component-library/colored-card/colored-card.component';
import { RequestMapperService } from '../../mappers/request-mapper.service'; import { RequestMapperService } from '../../mappers/request-mapper.service';
import { CommonModule } from '@angular/common';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { AuthService } from '../../auth/service/auth.service';
import { StudentTransmissionService } from '../../raintree/transmission/student-transmission.service';
import { RaintreeResponse } from '../../raintree/interface/raintree-response';
import { TransmissionMapperService } from '../../mappers/transmission-mapper.service';
import { UrlConfigService } from '../service/url-config.service';
import { DataSourceService } from '../service/data-source.service';
import { DropDown } from '../../component-library/dropdown/interface/drop-down';
import { Student } from './interface/students';
import { Dropdown } from '../../component-library/dropdown/interface/dropdown';
import { TeacherTransmissionService } from '../../raintree/transmission/teacher-transmission.service';
@Component({ @Component({
selector: 'app-portal-dashboard', selector: 'app-portal-dashboard',
imports: [ColoredCardComponent], imports: [
ColoredCardComponent,
CommonModule,
MatInputModule,
MatSelectModule
],
standalone: true,
templateUrl: './portal-dashboard.component.html', templateUrl: './portal-dashboard.component.html',
styleUrl: './portal-dashboard.component.scss' styleUrl: './portal-dashboard.component.scss'
}) })
export class PortalDashboardComponent implements OnInit { export class PortalDashboardComponent implements OnInit {
constructor() {}
public authService = inject(AuthService);
public studentTransmission = inject(StudentTransmissionService);
public teacherTransmission = inject(TeacherTransmissionService);
private _urlConfig = inject(UrlConfigService);
public assignmentUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ASSIGNMENT_URL}`; public assignmentUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ASSIGNMENT_URL}`;
public routineUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ROUTINE_URL}`; public routineUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.ROUTINE_URL}`;
public examUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.EXAM_URL}`; public examUrl = `/${RequestMapperService.PORTAL_URL}/${RequestMapperService.EXAM_URL}`;
public selectedStudent: string = '';
public studentDropdown: Dropdown[] = [];
public students: Student[] = [];
public ngOnInit(): void { public ngOnInit(): void {
(this.authService.getUserRole() === 'Parent') && this._getStudentByParentId();
(this.authService.getUserRole() === 'Teacher') && this._getTeacherDetails();
} }
showLoader(): void {} public onStudentChange(): void {
const selectedStudentInfo = this.students.find((stu: Student) => stu.id === this.selectedStudent);
this._setSetStudentInfoInLocalStorage(selectedStudentInfo as Student);
}
// FOR PARENT LOGIN
private _getStudentByParentId() {
this.studentTransmission.getStudents(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: DataSourceService.STUDENT_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 100,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true,
fieldName: "parent_user",
operators: "eq",
fieldValues: this.authService.localStorageGetItemByKey("user_id")
}),
() => { },
(response) => { },
(response: RaintreeResponse) => {
this.students = response['data'].themeDataSourceFields;
this.selectedStudent = this.students[0].id;
this._setSetStudentInfoInLocalStorage(this.students[0]);
this.studentDropdown = response['data'].themeDataSourceFields.map((student: Student, index: number) => {
return {
"name": student.name.en,
"value": student.id
}
})
},
(error) => {
console.log(error);
},
() => { }
)
}
private _setSetStudentInfoInLocalStorage(stuInfo: Student) {
// console.log(stuInfo);
localStorage.setItem('student_school_id', stuInfo.school.en);
localStorage.setItem('student_class_id', stuInfo.class.en);
localStorage.setItem('student_section_id', stuInfo.section.en);
}
// FOR TEACHER LOGIN
private _getTeacherDetails(): void {
// https://magicoweb.com/webomagic/getWebDataSourceByWebsiteDataSourceForFilter?
// aggregationOnUniqueFld=false&datasourceId=3205&dontIncludeForeignKey=false
// &expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1&
this.teacherTransmission.getTeacher(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: DataSourceService.TEACHER_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 100,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true,
fieldName: "user",
operators: "eq",
fieldValues: this.authService.localStorageGetItemByKey("user_id")
}),
() => { },
(response) => { },
(response: RaintreeResponse) => {
localStorage.setItem('school_id', response['data'].themeDataSourceFields[0].school.en)
},
(error) => {
console.log(error);
},
() => { }
)
}
hideLoader(): void {}
} }
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
/> />
</div> </div>
<div class="add_btn" *ngIf="authService.getUserRole() !== 'Student'"> <div class="add_btn" *ngIf="authService.getUserRole() !== 'Parent'">
<app-square-button <app-square-button
[buttonIcon]="'add'" [buttonIcon]="'add'"
(emitSquareButtonClick)="addRoutine()" (emitSquareButtonClick)="addRoutine()"
......
...@@ -6,6 +6,13 @@ import { Injectable } from '@angular/core'; ...@@ -6,6 +6,13 @@ import { Injectable } from '@angular/core';
export class DataSourceService { export class DataSourceService {
constructor() { } constructor() { }
// FOR STUDENT:
public static readonly STUDENT_DATA_SOURCE_ID: number = 3033;
// FOR TEACHER
public static readonly TEACHER_DATA_SOURCE_ID: number = 3205;
// FOR ASSIGNMENT: // 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_NAME: string = 'Assignment';
...@@ -25,5 +32,5 @@ export class DataSourceService { ...@@ -25,5 +32,5 @@ export class DataSourceService {
public static readonly SECTION_DATA_SOURCE_ID: number = 3013; public static readonly SECTION_DATA_SOURCE_ID: number = 3013;
public static readonly SUBJECT_DATA_SOURCE_ID: number = 3014; public static readonly CLASS_SECTION_SUBJECT_DATA_SOURCE_ID: number = 3016;
} }
import { Injectable } from '@angular/core'; import { inject, Injectable } from '@angular/core';
import { AuthService } from '../../auth/service/auth.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class UrlConfigService { export class UrlConfigService {
public authService = inject(AuthService);
public generateDatasourceConfigUrl(obj: any): string { public generateDatasourceConfigUrl(obj: any): string {
return Object.entries(obj) return Object.entries(obj)
.map(([key, value]) => `${key}=${encodeURIComponent(value as string | number | boolean)}`) .map(([key, value]) => `${key}=${encodeURIComponent(value as string | number | boolean)}`)
.join('&'); .join('&');
} }
public getFiledNameFilter(type: string): string {
let fieldName = '';
// let fieldValues = '';
// let fieldOperator = ''
if (type === 'assignment') {
if (this.authService.getUserRole() === 'Teacher') {
fieldName = "assigned_by_teacher";
} else if (this.authService.getUserRole() === 'Parent') {
fieldName = "school,section_class,section";
}
}
return fieldName;
}
public getFieldOperatorFilter(type: string): string {
let fieldOperator = ''
if (type === 'assignment') {
if (this.authService.getUserRole() === 'Teacher') {
fieldOperator = 'eq';
} else if (this.authService.getUserRole() === 'Parent') {
fieldOperator = 'eq,eq,eq';
}
}
return fieldOperator;
}
public getFieldValuesFilter(type: string): string {
let fieldValues = '';
if (type === 'assignment') {
if (this.authService.getUserRole() === 'Teacher') {
fieldValues = `${this.authService.localStorageGetItemByKey('user_id')}`;
} else if (this.authService.getUserRole() === 'Parent') {
fieldValues = `${localStorage.getItem('student_school_id')},${localStorage.getItem('student_class_id')},${localStorage.getItem('student_section_id')}`;
}
}
return fieldValues;
}
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { LogoutService } from '../portal/navigation/service/logout.service'; import { LogoutService } from '../portal/navigation/service/logout.service';
import { ToasterService } from '../component-library/toaster/toaster.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -7,13 +8,15 @@ import { LogoutService } from '../portal/navigation/service/logout.service'; ...@@ -7,13 +8,15 @@ import { LogoutService } from '../portal/navigation/service/logout.service';
export class ErrorHandlerService { export class ErrorHandlerService {
constructor( constructor(
private _logoutService: LogoutService private _logoutService: LogoutService,
private _toaster:ToasterService
) { } ) { }
public handle(error: number): void { public handle(error: number): void {
if(error === 401 || error === 400) this._handle401Error(error); if(error === 401 || error === 400) this._handle401Error(error);
else if (error === 422) this._handle422Error(error); else if (error === 422) this._handle422Error(error);
else if (error === 403) this._handle403Error(error);
} }
private _handle401Error(error: number): void { private _handle401Error(error: number): void {
...@@ -23,6 +26,11 @@ export class ErrorHandlerService { ...@@ -23,6 +26,11 @@ export class ErrorHandlerService {
private _handle422Error(error: number): void { private _handle422Error(error: number): void {
this._logoutService.logout(); this._logoutService.logout();
} }
private _handle403Error(error: number): void {
this._toaster.error('Invalid credentials', 'Ok');
}
} }
import { TestBed } from '@angular/core/testing';
import { StudentTransmissionService } from './student-transmission.service';
describe('StudentTransmissionService', () => {
let service: StudentTransmissionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(StudentTransmissionService);
});
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 StudentTransmissionService extends TransmissionService {
public getStudents(
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
);
}
}
import { TestBed } from '@angular/core/testing';
import { TeacherTransmissionService } from './teacher-transmission.service';
describe('TeacherTransmissionService', () => {
let service: TeacherTransmissionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TeacherTransmissionService);
});
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 TeacherTransmissionService extends TransmissionService {
public getTeacher(
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
);
}
}
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