Commit b18b2f83 authored by achinta's avatar achinta

feat: routine and fix user_id

parent daddc8c2
......@@ -7,20 +7,20 @@ import { RoleMapperService } from './mappers/role-mapper.service';
export const routes: Routes = [
{
path: RequestMapperService.STYLE_GUIDE,
loadComponent: () =>
import('./style-guide/style-guide/style-guide.component').then((m) => m.StyleGuideComponent),
data: { roles: [] },
children: [
{
path: RequestMapperService.BASE_RELATIVE_URL,
loadChildren: () =>
import('./style-guide/style-guide.routes')
.then(r => r.STYLE_GUIDE_ROTES)
},
]
},
// {
// path: RequestMapperService.STYLE_GUIDE,
// loadComponent: () =>
// import('./style-guide/style-guide/style-guide.component').then((m) => m.StyleGuideComponent),
// data: { roles: [] },
// children: [
// {
// path: RequestMapperService.BASE_RELATIVE_URL,
// loadChildren: () =>
// import('./style-guide/style-guide.routes')
// .then(r => r.STYLE_GUIDE_ROTES)
// },
// ]
// },
{
path: RequestMapperService.LOGIN_URL,
loadComponent: () =>
......
......@@ -22,14 +22,13 @@ export class AuthService {
}
public prepareLoginProcess(userProfileData: UserProfile): void {
console.log(userProfileData);
this._setProfileInformationInLocalStorage(userProfileData);
if (this.isBrowser) {
localStorage.setItem('isLoggedIn', 'true');
localStorage.setItem('role', userProfileData.role_name);
// localStorage.setItem('role','FO,accountant'); //TODO: for testing
this._router.navigate([RequestMapperService.PORTAL_URL]);
}
}
......@@ -38,4 +37,13 @@ export class AuthService {
// console.log(jwtToken);
localStorage.setItem('userProfile', JSON.stringify(userProfileData));
}
public localStorageGetItemByKey(key: string): string{
const localStorageItem = JSON.parse(localStorage.getItem('userProfile')!);
return localStorageItem[key];
}
}
// @media only screen and (max-width: 999px) and (min-width: 300px) {
// .mat-mdc-header-row{
// }
// }
\ No newline at end of file
......@@ -23,5 +23,4 @@ export class RequestMapperService {
public static readonly EXAM_URL: string = 'exam';
public static readonly ROUTINE_URL: string = 'routine';
}
......@@ -17,7 +17,7 @@ export class TransmissionMapperService {
public static readonly USER_PROFILE_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/user/get-profile';
public static readonly ASSIGNMENT_TRANSMISSION_URL: string =
public static readonly GET_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/getWebDataSourceByWebsiteDataSourceForFilter?';
// aggregationOnUniqueFld=false&datasourceId=3188&dontIncludeForeignKey=false&expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1&user_id=206&roleBasedFiltering=true
......
......@@ -9,13 +9,14 @@ import { TransmissionMapperService } from '../../../mappers/transmission-mapper.
import { UrlConfigService } from '../../service/url-config.service';
import { Assignment } from '../interface/assignment';
import { PrepareAssignmentTableDataService } from '../service/prepare-assignment-table-data.service';
import { DataSourceService } from '../../service/data-source.service';
@Component({
selector: 'app-assignment',
imports: [
CustomTableComponent,
SquareButtonComponent
],
],
templateUrl: './assignment.component.html',
styleUrl: './assignment.component.scss'
})
......@@ -23,10 +24,10 @@ import { PrepareAssignmentTableDataService } from '../service/prepare-assignment
export class AssignmentComponent {
constructor(
private _dialog: MatDialog,
private _assignmentTransmissionService: AssignmentTransmissionService,
private _urlConfigService: UrlConfigService,
private _assignmentTransmission: AssignmentTransmissionService,
private _urlConfig: UrlConfigService,
private _prepareAssignmentTableData: PrepareAssignmentTableDataService
){}
) { }
public columns = [
{ key: 'class_subject_subject_txt', label: 'Class' },
......@@ -35,156 +36,55 @@ export class AssignmentComponent {
{ key: 'action', label: 'Action' },
];
public data:any[] = [];
public data: any[] = [];
private _temp:Assignment[] = [
{
"session": {
"default": "86af4d6b5675a82df4581f00c67f0c7f",
"beng": "86af4d6b5675a82df4581f00c67f0c7f",
"hindi": "86af4d6b5675a82df4581f00c67f0c7f",
"en": "86af4d6b5675a82df4581f00c67f0c7f"
},
"subject": {
"default": "",
"beng": "",
"hindi": "",
"en": "46486ae5e9470245652c77dbe9329136"
},
"assigned_on": {
"default": "2025-03-21",
"beng": "2025-03-21",
"hindi": "2025-03-21",
"en": "2025-03-21"
},
"last_submission_date": {
"default": "2025-03-21",
"beng": "2025-03-21",
"hindi": "2025-03-21",
"en": "2025-03-21"
},
"section": {
"default": "1628f1d3368d31b75447ca348c1add5e",
"beng": "1628f1d3368d31b75447ca348c1add5e",
"hindi": "1628f1d3368d31b75447ca348c1add5e",
"en": "1628f1d3368d31b75447ca348c1add5e"
},
"docs": {
"default": "",
"beng": "",
"hindi": "",
"en": ""
},
"class_subject": {
"default": "7f8aa0e3b9fb526fbc77cb4e190b0965",
"beng": "7f8aa0e3b9fb526fbc77cb4e190b0965",
"hindi": "7f8aa0e3b9fb526fbc77cb4e190b0965",
"en": "7f8aa0e3b9fb526fbc77cb4e190b0965"
},
"session_session_name": {
"default": "2024-2025",
"beng": "2024-2025",
"hindi": "2024-2025",
"en": "2024-2025 session"
},
"section_details": {
"default": "test 12 b",
"beng": "test 12 b",
"hindi": "test 12 b",
"en": "test 12 b"
},
"id": "893121387a9b65a4474402f09046c724",
"subject_subject_name": {
"default": "Physics",
"beng": "Physics",
"hindi": "Physics",
"en": "Physics"
},
"class_subject_subject_txt": {
"default": "Math",
"beng": "Math",
"hindi": "Math",
"en": "Math"
}
}
]
ngOnInit(): void {
this.columns = this._prepareAssignmentTableData.prepareMatTableColumn();
ngOnInit(): void{
this._getAssignment();
this._getAssignments();
}
private _getAssignment() : void{
private _getAssignments(): void {
this.data = this._prepareAssignmentTableData.prepareMatTableData(
this._temp
);
this.columns = this._prepareAssignmentTableData.prepareMatTableColumn(
this._temp
);
this._assignmentTransmissionService.getAssignment(
TransmissionMapperService.ASSIGNMENT_TRANSMISSION_URL + this._urlConfigService.generateDatasourceConfigUrl({
this._assignmentTransmission.getAssignment(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: 3188,
datasourceId: DataSourceService.ASSIGNMENT_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit:10,
orderBy:"ASC",
page:1,
roleBasedFiltering:true
limit: 100,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true
}),
() => { },
(response) => { },
(response: AssignmentsResponse) => {
// this.data = response.data.themeDataSourceFields
// response['data']['themeDataSourceFields'].map((assignment:Assignment) => {
// return{
// assignment.
// }
// })
// this.data = this._prepareAssignmentTableData.prepareMatTableData(
// response.data.themeDataSourceFields
// );
// this.columns = this._prepareAssignmentTableData.prepareMatTableData(
// response.data.themeDataSourceFields
// );
// this.data = [
// { id: 1, name: 'John Doe', age: 30 },
// { id: 2, name: 'Jane Doe', age: 28 },
// { id: 3, name: 'Alice', age: 25 }
// ];
// this.columns = [
// { key: 'id', label: 'ID' },
// { key: 'name', label: 'Name' },
// { key: 'age', label: 'Age' }
// ];
console.log(this.data);
this.data = this._prepareAssignmentTableData.prepareMatTableData(
response.data.themeDataSourceFields
);
},
(error) => {
console.log(error);
}, () => { }
},
() => { }
)
}
public emitViewFromTable(clickedData: string){
public emitViewFromTable(clickedData: string) {
alert("Have to view the doc in another page");
}
public emitEditFromTable(clickedData: string): void {
public emitEditFromTable(emitData: string): void {
// rate ? rate.is_edit_enable = true : '';
console.log(clickedData);
let dialogRef = this._dialog.open(ManageComponent, {
data: clickedData,
data: emitData,
width: '98vw',
height: 'auto',
maxWidth: '70vw',
......@@ -197,9 +97,14 @@ export class AssignmentComponent {
// });
}
public addAssignment(){
alert("Add assignment");
public addAssignment(): void {
let dialogRef = this._dialog.open(ManageComponent, {
data: '',
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
}
}
......@@ -9,7 +9,6 @@ export class PrepareAssignmentTableDataService {
constructor() { }
public prepareMatTableData(data: Assignment[]): any {
debugger
let dataArray = data.map((assignment: Assignment) => {
......@@ -27,7 +26,7 @@ export class PrepareAssignmentTableDataService {
// return [];
}
public prepareMatTableColumn(data: Assignment[]): any[] {
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'subject', label: 'Subject' },
......@@ -35,6 +34,7 @@ export class PrepareAssignmentTableDataService {
{ key: 'session_name', label: 'Session Name' },
{ key: 'action', label: 'Action' },
];
console.log(columnArray);
return columnArray;
}
......
import { Data } from "../../data-source/interface/data";
import { LocalizedField } from "../../data-source/interface/localizedField";
// ThemeDataSourceField Interface
export interface Routines extends Data {
themeDataSourceFields: Routine[];
}
// ThemeDataSourceField Interface
export interface Routine {
id: string;
class: LocalizedField;
section: LocalizedField;
schedule: LocalizedField;
details: LocalizedField;
session: LocalizedField;
document: LocalizedField;
routine_type: LocalizedField;
session_session_name: LocalizedField;
class_details: LocalizedField;
section_details: LocalizedField;
}
<p>manage works!</p>
<pre> {{data | json}} </pre>
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@Component({
selector: 'app-manage',
imports: [],
imports: [
CommonModule
],
templateUrl: './manage.component.html',
styleUrl: './manage.component.scss'
})
export class ManageComponent {
constructor(
@Inject(MAT_DIALOG_DATA) public data: any,
) { }
}
<p>routine works!</p>
<div class="custom_table">
<app-custom-table
[columns]="columns"
[data]="data"
(emitEdit)="emitEditFromTable($event)"
(emitView)="emitViewFromTable($event)"
/>
</div>
<div class="add_btn">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addRoutine()"
/>
</div>
\ No newline at end of file
.add_btn{
position: fixed;
bottom: 20px;
right: 0;
padding: 0px 20px;
margin: auto;
}
\ No newline at end of file
import { Component } from '@angular/core';
import { RoutineTransmissionService } from '../../../raintree/transmission/routine-transmission.service';
import { TransmissionMapperService } from '../../../mappers/transmission-mapper.service';
import { DataSourceService } from '../../service/data-source.service';
import { RoutineResponse } from '../../../raintree/interface/routine-respons';
import { UrlConfigService } from '../../service/url-config.service';
import { CustomTableComponent } from '../../../component-library/custom-table/custom-table.component';
import { SquareButtonComponent } from '../../../component-library/square-button/square-button.component';
import { MatDialog } from '@angular/material/dialog';
import { ManageComponent } from '../manage/manage.component';
import { PrepareRoutineTableDataService } from '../service/prepare-routine-table-data.service';
@Component({
selector: 'app-routine',
imports: [],
standalone: true,
imports: [
CustomTableComponent,
SquareButtonComponent
],
templateUrl: './routine.component.html',
styleUrl: './routine.component.scss'
})
export class RoutineComponent {
constructor(
private _routineTransmission: RoutineTransmissionService,
private _urlConfig: UrlConfigService,
private _dialog: MatDialog,
private _prepareRoutineTableData: PrepareRoutineTableDataService
) { }
public columns: any[] = [];
public data: any[] = [];
ngOnInit(): void {
this.columns = this._prepareRoutineTableData.prepareMatTableColumn();
this._getRoutines();
}
public addRoutine(): void {
let dialogRef = this._dialog.open(ManageComponent, {
data: '',
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
}
public emitViewFromTable(clickedData: string) {
alert("Have to view the doc in another page");
}
public emitEditFromTable(emitData: string): void {
let dialogRef = this._dialog.open(ManageComponent, {
data: emitData,
width: '98vw',
height: 'auto',
maxWidth: '70vw',
maxHeight: '70vh',
});
}
private _getRoutines(): void {
this._routineTransmission.getRoutine(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false,
datasourceId: DataSourceService.ROUTINE_DATA_SOURCE_ID,
dontIncludeForeignKey: false,
expand: false,
isUniqueValueRequiredForFieldToDisplay: false,
language: "en",
limit: 10,
orderBy: "ASC",
page: 1,
roleBasedFiltering: true
}),
() => { },
(response) => { },
(response: RoutineResponse) => {
this.data = this._prepareRoutineTableData.prepareMatTableData(response.data.themeDataSourceFields);
},
(error) => {
console.log(error);
},
() => { }
)
}
}
import { TestBed } from '@angular/core/testing';
import { PrepareRoutineTableDataService } from './prepare-routine-table-data.service';
describe('PrepareRoutineTableDataService', () => {
let service: PrepareRoutineTableDataService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PrepareRoutineTableDataService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { Routine } from '../interface/routine';
@Injectable({
providedIn: 'root'
})
export class PrepareRoutineTableDataService {
constructor() { }
public prepareMatTableData(data: Routine[]): any {
let dataArray = data.map((routine: Routine) => {
return {
['id']: routine.id,
['session_session_name']: routine.session_session_name['en'],
['class_details']: routine.class_details['en'],
['section_details']:routine.section_details['en'],
['action']: ['view', 'edit']
}
})
return dataArray;
}
public prepareMatTableColumn(): any[] {
let columnArray = [
{ key: 'session_session_name', label: 'Session' },
{ key: 'class_details', label: 'Class' },
{ key: 'section_details', label: 'Section' },
{ key: 'action', label: 'Action' },
];
return columnArray;
}
}
import { TestBed } from '@angular/core/testing';
import { DataSourceService } from './data-source.service';
describe('DataSourceService', () => {
let service: DataSourceService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DataSourceService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DataSourceService {
constructor() { }
public static readonly ASSIGNMENT_DATA_SOURCE_ID: number = 3188;
public static readonly ROUTINE_DATA_SOURCE_ID: number = 3021;
}
export interface RaintreeResponse {
[index: string]: any;
status_code: number;
message: string;
[index: string]: any;
}
import { Routines } from "../../portal/routine/interface/routine";
import { RaintreeResponse } from "./raintree-response";
export interface RoutineResponse extends RaintreeResponse{
data: Routines
}
\ No newline at end of file
import { Injectable } from '@angular/core';
import { TransmissionService } from './transmission.service';
import { HttpClient } from '@angular/common/http';
import { HttpErrorHandlerService } from '../http-error-handler.service';
import { JWTService } from './jwt.service';
import { ErrorHandlerService } from '../error-handler.service';
import { RaintreeResponse } from '../interface/raintree-response';
import { AssignmentsResponse } from '../interface/assignment-respons';
@Injectable({
providedIn: 'root'
})
export class AssignmentTransmissionService extends TransmissionService {
// constructor(
// _http: HttpClient,
// _httpErrorHandler: HttpErrorHandlerService,
// _jwt: JWTService,
// _errorHandler: ErrorHandlerService
// ) {
// super(_http, _httpErrorHandler, _jwt, _errorHandler);
// }
public getAssignment(
url: string,
onPreExecute: () => void,
......@@ -27,7 +16,7 @@ export class AssignmentTransmissionService extends TransmissionService {
onFailure: (error: string) => void,
onComplete: () => void
): void {
this.executePostPayload<any>(
this.executePostPayload(
url,
{},
onPreExecute,
......
import { HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AuthService } from '../../auth/service/auth.service';
@Injectable({
providedIn: 'root',
})
export class JWTService {
constructor() {}
constructor(
private _auth:AuthService
) {}
private _jwtToken: string | null = null;
private _expirationDate: Date | null = null;
......@@ -17,7 +20,7 @@ export class JWTService {
// TODO: check if token exist in Local storage and handle accordingly
return new HttpHeaders({
"user-id":'206',
"user-id": this._auth.localStorageGetItemByKey('user_id'),
"apikey": authorizationToken,
'Content-Type': 'application/json',
});
......
import { TestBed } from '@angular/core/testing';
import { RoutineTransmissionService } from './routine-transmission.service';
describe('RoutineTransmissionService', () => {
let service: RoutineTransmissionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(RoutineTransmissionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { TransmissionService } from './transmission.service';
@Injectable({
providedIn: 'root'
})
export class RoutineTransmissionService extends TransmissionService{
public getRoutine(
url: string,
onPreExecute: () => void,
onPostExecute: (response: any) => void,
onSuccess: (response: any) => void,
onFailure: (error: string) => void,
onComplete: () => void
): void {
this.executePostPayload(
url,
{},
onPreExecute,
onPostExecute,
onSuccess,
onFailure,
onComplete,
true
);
}
}
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