Commit 25d50dd1 authored by achinta's avatar achinta

fix: fixing some issue due to change database

parent 8010cf7d
...@@ -52,11 +52,11 @@ export class LoginComponent implements OnInit { ...@@ -52,11 +52,11 @@ export class LoginComponent implements OnInit {
public hidePassword: boolean = true; public hidePassword: boolean = true;
public loginForm = new FormGroup({ public loginForm = new FormGroup({
phoneNo: new FormControl('', [ phoneNo: new FormControl('6290861931', [
Validators.required, Validators.required,
Validators.pattern(/^\d{10}$/) Validators.pattern(/^\d{10}$/)
]), ]),
otp: new FormControl('', [ otp: new FormControl('5678', [
Validators.required, Validators.required,
Validators.pattern(/^\d{4}$/) Validators.pattern(/^\d{4}$/)
]), ]),
...@@ -111,14 +111,16 @@ export class LoginComponent implements OnInit { ...@@ -111,14 +111,16 @@ export class LoginComponent implements OnInit {
return; return;
}; };
let userInfoName = userInfo.Name? userInfo.Name.en : userInfo.name.en;
let user_data = { let user_data = {
apiKey: `${response['data'].apiKey}`, apiKey: `${response['data'].apiKey}`,
name: `${userInfo.name['en']}`, name: userInfoName,
project_id: response['data'].project_id, project_id: response['data'].project_id,
role_name: `${this.loginForm.value.role}`, role_name: `${this.loginForm.value.role}`,
user_id: response['data'].user_id, user_id: response['data'].user_id,
user_type: response['data'].user_type, user_type: response['data'].user_type,
username: `${userInfo.name['en']}`, username: userInfoName,
phone:`${userInfo.phone['en']}`, phone:`${userInfo.phone['en']}`,
logged_id: `${userInfo.id}` logged_id: `${userInfo.id}`
} }
...@@ -159,10 +161,12 @@ export class LoginComponent implements OnInit { ...@@ -159,10 +161,12 @@ export class LoginComponent implements OnInit {
// } // }
private _getUserDetails() { private _getUserDetails() {
const userDataSourceId = this._authService.getUserDataSourceId(this.loginForm.value.role as string);
this._authTransmissionService.getUser( this._authTransmissionService.getUser(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({ TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
aggregationOnUniqueFld: false, aggregationOnUniqueFld: false,
datasourceId: `${this.loginForm.get('role')?.value === RoleMapperService.TEACHER_ROLE ? DataSourceService.TEACHER_DATA_SOURCE_ID : DataSourceService.STUDENT_DATA_SOURCE_ID}`, datasourceId: userDataSourceId,
dontIncludeForeignKey: false, dontIncludeForeignKey: false,
expand: true, expand: true,
access: 'PUBLIC', access: 'PUBLIC',
...@@ -181,6 +185,7 @@ export class LoginComponent implements OnInit { ...@@ -181,6 +185,7 @@ export class LoginComponent implements OnInit {
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
let userInfo = response['data'].themeDataSourceFields[0]; let userInfo = response['data'].themeDataSourceFields[0];
console.log(userInfo);
if(!userInfo) { if(!userInfo) {
this._toaster.error('Invalid user','Ok'); this._toaster.error('Invalid user','Ok');
......
...@@ -6,6 +6,7 @@ import { RequestMapperService } from '../../mappers/request-mapper.service'; ...@@ -6,6 +6,7 @@ import { RequestMapperService } from '../../mappers/request-mapper.service';
import { LogoutService } from '../../portal/navigation/service/logout.service'; import { LogoutService } from '../../portal/navigation/service/logout.service';
import { Student } from '../../portal/portal-dashboard/interface/students'; import { Student } from '../../portal/portal-dashboard/interface/students';
import { RoleMapperService } from '../../mappers/role-mapper.service'; import { RoleMapperService } from '../../mappers/role-mapper.service';
import { DataSourceService } from '../../portal/service/data-source.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -48,6 +49,7 @@ export class AuthService { ...@@ -48,6 +49,7 @@ export class AuthService {
private _setProfileInformationInLocalStorage(userProfileData: UserProfile): void { private _setProfileInformationInLocalStorage(userProfileData: UserProfile): void {
// console.log(jwtToken); // console.log(jwtToken);
localStorage.setItem('userProfile', JSON.stringify(userProfileData)); localStorage.setItem('userProfile', JSON.stringify(userProfileData));
localStorage.setItem('school_id', this.getLoggedSchool() === 'boys' ? RequestMapperService.LMB_SCHOOL_ID : RequestMapperService.LMG_SCHOOL_ID);
} }
public localStorageGetItemByKey(key: string): string { public localStorageGetItemByKey(key: string): string {
...@@ -79,6 +81,27 @@ export class AuthService { ...@@ -79,6 +81,27 @@ export class AuthService {
return text; return text;
} }
public getLoggedSchool(): string {
return localStorage.getItem('logged_school') || '';
}
public getUserDataSourceId(role:string): number {
const school = this.getLoggedSchool();
// const role = this.getUserRole();
if (role === RoleMapperService.TEACHER_ROLE) {
if (school === 'boys') {
return DataSourceService.LMB_TEACHER_DATA_SOURCE_ID;
} else if (school === 'girls') {
return DataSourceService.TEACHER_DATA_SOURCE_ID;
}
} else if (role === RoleMapperService.STUDENT_ROLE) {
return DataSourceService.STUDENT_DATA_SOURCE_ID;
}
return 0;
}
public getUserName() { public getUserName() {
return this.localStorageGetItemByKey('phone'); return this.localStorageGetItemByKey('phone');
} }
......
...@@ -3,6 +3,8 @@ import { ToasterService } from '../../component-library/toaster/toaster.service' ...@@ -3,6 +3,8 @@ import { ToasterService } from '../../component-library/toaster/toaster.service'
import { RequestMapperService } from '../../mappers/request-mapper.service'; import { RequestMapperService } from '../../mappers/request-mapper.service';
import { AuthTransmissionService } from '../../raintree/transmission/auth-transmission.service'; import { AuthTransmissionService } from '../../raintree/transmission/auth-transmission.service';
import { RaintreeResponse } from '../../raintree/interface/raintree-response'; import { RaintreeResponse } from '../../raintree/interface/raintree-response';
import { TransmissionMapperService } from '../../mappers/transmission-mapper.service';
import { UrlConfigService } from '../../portal/service/url-config.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -13,21 +15,22 @@ export class SendOtpService { ...@@ -13,21 +15,22 @@ export class SendOtpService {
private _toaster = inject(ToasterService); private _toaster = inject(ToasterService);
private _authTransmissionService = inject(AuthTransmissionService); private _authTransmissionService = inject(AuthTransmissionService);
private _urlConfig = inject(UrlConfigService);
private _otp: number = 0; private _otp: number = 0;
// public isOtpSend: boolean = false;
public sendOtp(phone: number): boolean { public sendOtp(phone: number): boolean {
this._otp = Math.floor(1000 + Math.random() * 9000); this._otp = Math.floor(1000 + Math.random() * 9000);
let otpUrl = RequestMapperService.OTP_URL; let otpUrl = TransmissionMapperService.OTP_URL;
this._otp = 5678; this._otp = 5678;
const makeOtpUrl = otpUrl const makeOtpUrl = otpUrl + this._urlConfig.generateDatasourceConfigUrl({
.replace("[NUMBER]", String(phone)) number: phone,
.replace("[OTP]", String(this._otp)) otp: this._otp
});
// this._prepareToSendOtp(makeOtpUrl); // this._prepareToSendOtp(makeOtpUrl);
// console.log(this.isOtpSend);
this._toaster.success('Otp send successfully', 'Ok')
return true; return true;
...@@ -43,12 +46,15 @@ export class SendOtpService { ...@@ -43,12 +46,15 @@ export class SendOtpService {
() => { }, () => { },
() => { }, () => { },
(response) => { (response) => {
if(response.status_code === 200) {
this._toaster.success('Otp send successfully', 'Ok');
// console.log(response); } else{
this._toaster.error('Invalid Phone Number', 'Ok');
}
}, },
(error) => { (error) => {
// console.log(error); this._toaster.error('Invalid Phone Number', 'Ok');
}, },
() => { } () => { }
......
...@@ -28,9 +28,8 @@ export class RequestMapperService { ...@@ -28,9 +28,8 @@ export class RequestMapperService {
public static readonly PROFILE_URL: string = 'profile'; public static readonly PROFILE_URL: string = 'profile';
public static readonly CHANGE_PASSWORD_URL: string = 'update-password'; public static readonly CHANGE_PASSWORD_URL: string = 'update-password';
// Otp url // School id
public static readonly OTP_URL: string = 'https://103.229.250.200/smpp/sendsms?username=lmccao&password=sms@2023&to=[NUMBER]&from=LMCCAO&text=[OTP]%20is%20the%20OTP%20to%20create%20new%20password.%20For%20any%20assistance,%20please%20call%20033-4040-6607.%0A%0ABursar-cum-Assistant%20Secretary,%0ALa%20Martiniere%20Schools'; public static readonly LMB_SCHOOL_ID: string = '2a867283e1755af3231c5569211395c7';
public static readonly LMG_SCHOOL_ID: string = 'da76ca6e60bcb4203e5a80c8044a6c2e';
} }
...@@ -38,4 +38,9 @@ export class TransmissionMapperService { ...@@ -38,4 +38,9 @@ export class TransmissionMapperService {
public static readonly DELETE_RECORD_TRANSMISSION_URL: string = public static readonly DELETE_RECORD_TRANSMISSION_URL: string =
TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/deleteWebsiteDataSourceFieldsBasedOnDataSourceType?'; TransmissionMapperService.DEV_TRANSMISSION_URL + '/webomagic/deleteWebsiteDataSourceFieldsBasedOnDataSourceType?';
// Otp url
public static readonly OTP_BASE_URL: string = 'http://127.0.0.1';
public static readonly OTP_URL: string = `${TransmissionMapperService.OTP_BASE_URL}/lamarts-otp/api/send-otp?`;
} }
...@@ -19,7 +19,7 @@ export interface Assignment { ...@@ -19,7 +19,7 @@ export interface Assignment {
docs: LocalizedField; docs: LocalizedField;
session_session_name?: LocalizedField; session_session_name?: LocalizedField;
section_details?: LocalizedField; section_details?: LocalizedField;
subject_subject_name?: LocalizedField; subject_Subject?: LocalizedField;
class_subject_subject_txt?: LocalizedField; class_subject_subject_txt?: LocalizedField;
assigned_by: LocalizedField; assigned_by: LocalizedField;
} }
......
...@@ -178,7 +178,7 @@ export class ManageComponent { ...@@ -178,7 +178,7 @@ export class ManageComponent {
limit:100, limit:100,
orderBy:"ASC", orderBy:"ASC",
page:1, page:1,
fieldName: "subject_teacher,section", fieldName: `${this._auth.getLoggedSchool() === 'girls'?'gst':'bst'},section`,
operators: "eq,eq", operators: "eq,eq",
fieldValues: `${this._auth.localStorageGetItemByKey("logged_id")},${sectionId}` fieldValues: `${this._auth.localStorageGetItemByKey("logged_id")},${sectionId}`
}), }),
...@@ -188,11 +188,14 @@ export class ManageComponent { ...@@ -188,11 +188,14 @@ export class ManageComponent {
this.subjectDropDownData = response['data']["themeDataSourceFields"].map( this.subjectDropDownData = response['data']["themeDataSourceFields"].map(
(sSubject: subject) => { (sSubject: subject) => {
return { return {
name: sSubject.subject_subject_name['en'], name: sSubject.subject_Subject['en'],
value: sSubject.subject['en'], value: sSubject.subject['en'],
}; };
} }
); );
console.log(this.subjectDropDownData);
}, },
(error) => { (error) => {
console.log(error); console.log(error);
...@@ -214,7 +217,7 @@ export class ManageComponent { ...@@ -214,7 +217,7 @@ export class ManageComponent {
limit: 100, limit: 100,
orderBy: "ASC", orderBy: "ASC",
page: 1, page: 1,
fieldName: "teacher", fieldName: `${this._auth.getLoggedSchool() === 'girls'?'gt':'bt'}`,
operators: "eq", operators: "eq",
fieldValues: this._auth.localStorageGetItemByKey("logged_id") fieldValues: this._auth.localStorageGetItemByKey("logged_id")
}), }),
......
...@@ -18,7 +18,7 @@ export class PrepareAssignmentTableDataService { ...@@ -18,7 +18,7 @@ export class PrepareAssignmentTableDataService {
return { return {
'id': assignment.id, 'id': assignment.id,
'subject': assignment.subject_subject_name?.en, 'subject': assignment.subject_Subject?.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,
......
...@@ -15,7 +15,7 @@ export interface subject { ...@@ -15,7 +15,7 @@ export interface subject {
section: LocalizedField; section: LocalizedField;
section_details: LocalizedField; section_details: LocalizedField;
subject: LocalizedField; subject: LocalizedField;
subject_subject_name: LocalizedField; subject_Subject: LocalizedField;
subject_teacher: LocalizedField; subject_teacher: LocalizedField;
subject_txt: LocalizedField; subject_txt: LocalizedField;
} }
......
...@@ -56,7 +56,7 @@ export class PortalDashboardComponent implements OnInit { ...@@ -56,7 +56,7 @@ export class PortalDashboardComponent implements OnInit {
public ngOnInit(): void { public ngOnInit(): void {
// (this.authService.getUserRole() === 'Parent') && this._getStudentByParentId(); // (this.authService.getUserRole() === 'Parent') && this._getStudentByParentId();
(this.authService.getUserRole() === RoleMapperService.TEACHER_ROLE) && this._getTeacherDetails(); // (this.authService.getUserRole() === RoleMapperService.TEACHER_ROLE) && this._getTeacherDetails();
(this.authService.getUserRole() === RoleMapperService.STUDENT_ROLE) && this._getStudentByParentId(); (this.authService.getUserRole() === RoleMapperService.STUDENT_ROLE) && this._getStudentByParentId();
...@@ -166,6 +166,9 @@ export class PortalDashboardComponent implements OnInit { ...@@ -166,6 +166,9 @@ export class PortalDashboardComponent implements OnInit {
// https://magicoweb.com/webomagic/getWebDataSourceByWebsiteDataSourceForFilter? // https://magicoweb.com/webomagic/getWebDataSourceByWebsiteDataSourceForFilter?
// aggregationOnUniqueFld=false&datasourceId=3205&dontIncludeForeignKey=false // aggregationOnUniqueFld=false&datasourceId=3205&dontIncludeForeignKey=false
// &expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1& // &expand=false&isUniqueValueRequiredForFieldToDisplay=false&language=en&limit=10&orderBy=ASC&page=1&
// const loggedSchool =this.authService.getLoggedSchool()
// localStorage.setItem('school_id', RequestMapperService.LMG_SCHOOL_ID);
this.teacherTransmission.getTeacher( this.teacherTransmission.getTeacher(
TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({ TransmissionMapperService.GET_TRANSMISSION_URL + this._urlConfig.generateDatasourceConfigUrl({
......
...@@ -186,7 +186,7 @@ export class ManageComponent { ...@@ -186,7 +186,7 @@ export class ManageComponent {
limit: 100, limit: 100,
orderBy: "ASC", orderBy: "ASC",
page: 1, page: 1,
fieldName: "teacher", fieldName: `${this._auth.getLoggedSchool() === 'girls'?'gt':'bt'}`,
operators: "eq", operators: "eq",
fieldValues: this._auth.localStorageGetItemByKey("logged_id") fieldValues: this._auth.localStorageGetItemByKey("logged_id")
}), }),
......
...@@ -10,7 +10,9 @@ export class DataSourceService { ...@@ -10,7 +10,9 @@ export class DataSourceService {
// FOR STUDENT: // FOR STUDENT:
public static readonly STUDENT_DATA_SOURCE_ID: number = 3033; public static readonly STUDENT_DATA_SOURCE_ID: number = 3033;
// FOR TEACHER // FOR TEACHER
public static readonly TEACHER_DATA_SOURCE_ID: number = 3205; public static readonly TEACHER_DATA_SOURCE_ID: number = 3335; //for girls school
// public static readonly TEACHER_DATA_SOURCE_ID: number = 3205;
public static readonly LMB_TEACHER_DATA_SOURCE_ID: number = 3431; //for boys school
// FOR ASSIGNMENT: // FOR ASSIGNMENT:
...@@ -34,9 +36,5 @@ export class DataSourceService { ...@@ -34,9 +36,5 @@ export class DataSourceService {
public static readonly CLASS_SECTION_SUBJECT_DATA_SOURCE_ID: number = 3016; public static readonly CLASS_SECTION_SUBJECT_DATA_SOURCE_ID: number = 3016;
public static readonly SESSION_ID: string = '86af4d6b5675a82df4581f00c67f0c7f'; public static readonly SESSION_ID: string = '86af4d6b5675a82df4581f00c67f0c7f';
} }
...@@ -23,7 +23,7 @@ export class TransmissionService { ...@@ -23,7 +23,7 @@ export class TransmissionService {
url: string, url: string,
onPreExecute: () => void, onPreExecute: () => void,
onPostExecute: (response: string) => void, onPostExecute: (response: string) => void,
onSuccess: (response: string) => void, onSuccess: (response: RaintreeResponse) => void ,
onFailure: (error: string) => void, onFailure: (error: string) => void,
onComplete: () => void, onComplete: () => void,
requiresAuthentication = false requiresAuthentication = false
...@@ -40,7 +40,7 @@ export class TransmissionService { ...@@ -40,7 +40,7 @@ export class TransmissionService {
.subscribe( .subscribe(
(response: RaintreeResponse) => { (response: RaintreeResponse) => {
onPostExecute(response.message); onPostExecute(response.message);
if (response.status_code === 200 || response.status_code === 201) onSuccess(response.message); if (response.status_code === 200 || response.status_code === 201) onSuccess(response);
// else onFailure(MessageService.RESOURCE_VALIDATION_FAILED); // else onFailure(MessageService.RESOURCE_VALIDATION_FAILED);
}, },
(error) => { (error) => {
......
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