From 11639a8cf4f523ede1c27c2c1e623e7079a0a609 Mon Sep 17 00:00:00 2001 From: MadhuMosip Date: Mon, 25 Nov 2024 15:06:42 +0530 Subject: [PATCH 1/3] MOSIP-37782 removed hardcoded language value and displying language dropdown if there is more then one language Signed-off-by: MadhuMosip --- resident-ui/src/app/app-config.service.ts | 140 +++++++++--------- resident-ui/src/app/app.component.ts | 5 +- .../feature/getuin/getuin/getuin.component.ts | 21 +-- .../personalisedcard.component.ts | 2 +- .../feature/verify/verify/verify.component.ts | 2 +- .../app/shared/header/header.component.html | 4 +- .../src/app/shared/header/header.component.ts | 29 ++-- 7 files changed, 91 insertions(+), 112 deletions(-) diff --git a/resident-ui/src/app/app-config.service.ts b/resident-ui/src/app/app-config.service.ts index f99b008f..91538853 100644 --- a/resident-ui/src/app/app-config.service.ts +++ b/resident-ui/src/app/app-config.service.ts @@ -8,76 +8,76 @@ export class AppConfigService { appConfig: any; constructor(public http: HttpClient) { } - async loadAppConfig() { - localStorage.setItem("isDataLoaded", 'false') - this.appConfig = await this.http.get('./assets/config.json').toPromise(); - this.http.get(this.appConfig.baseUrl + '/proxy/config/ui-properties').subscribe( - (response) => { - let responseData = response["response"]; - this.appConfig["supportedLanguages"] = responseData["mosip.mandatory-languages"]+","+responseData["mosip.optional-languages"]; - this.appConfig["mosip.iam.adapter.clientid"] = responseData["mosip.iam.adapter.clientid"]; - this.appConfig["mosip.resident.api.id.otp.request"] = responseData["mosip.resident.api.id.otp.request"]; - this.appConfig["mosip.resident.api.version.otp.request"] = responseData["mosip.resident.api.version.otp.request"]; - this.appConfig["resident.vid.id"] = responseData["resident.vid.id"]; - this.appConfig["resident.vid.version"] = responseData["resident.vid.version"]; - this.appConfig["mosip.resident.request.response.version"] = responseData["mosip.resident.request.response.version"]; - this.appConfig["resident.revokevid.id"] = responseData["resident.revokevid.id"]; - this.appConfig["mosip-prereg-host"] = responseData["mosip-prereg-host"]; - this.appConfig["mosip-prereg-ui-url"] = responseData["mosip-prereg-ui-url"]; - this.appConfig["auth.types.allowed"] = responseData["auth.types.allowed"]; - this.appConfig["resident.view.history.serviceType.filters"] = responseData["resident.view.history.serviceType.filters"]; - this.appConfig["resident.view.history.status.filters"] = responseData["resident.view.history.status.filters"]; - this.appConfig["mosip.resident.grievance.url"] = responseData["mosip.resident.grievance.url"]; - this.appConfig["resident.vid.id.generate"] = responseData["resident.vid.id.generate"]; - this.appConfig["resident.vid.version.new"] = responseData["resident.vid.version.new"]; - this.appConfig["mosip.resident.revokevid.id"] = responseData["mosip.resident.revokevid.id"]; - this.appConfig["resident.revokevid.version.new"] = responseData["resident.revokevid.version.new"]; - this.appConfig["mosip.resident.download.personalized.card.id"] = responseData["mosip.resident.download.personalized.card.id"] - this.appConfig["mosip.resident.download.registration.centre.file.name.convention"] = responseData["mosip.resident.download.registration.centre.file.name.convention"]; - this.appConfig["mosip.resident.download.supporting.document.file.name.convention"] = responseData["mosip.resident.download.supporting.document.file.name.convention"]; - this.appConfig["mosip.resident.download.personalized.card.naming.convention"] = responseData["mosip.resident.download.personalized.card.naming.convention"]; - this.appConfig["mosip.resident.ack.manage_my_vid.name.convention"] = responseData["mosip.resident.ack.manage_my_vid.name.convention"]; - this.appConfig["mosip.resident.ack.secure_my_id.name.convention"] = responseData["mosip.resident.ack.secure_my_id.name.convention"]; - this.appConfig["mosip.resident.ack.personalised_card.name.convention"] = responseData["mosip.resident.ack.personalised_card.name.convention"]; - this.appConfig["mosip.resident.ack.update_my_data.name.convention"] = responseData["mosip.resident.ack.update_my_data.name.convention"]; - this.appConfig["mosip.resident.ack.share_credential.name.convention"] = responseData["mosip.resident.ack.share_credential.name.convention"]; - this.appConfig["mosip.resident.ack.order_physical_card.name.convention"] = responseData["mosip.resident.ack.order_physical_card.name.convention"]; - this.appConfig["mosip.resident.ack.name.convention"] = responseData["mosip.resident.ack.name.convention"]; - this.appConfig["mosip.resident.uin.card.name.convention"] = responseData["mosip.resident.uin.card.name.convention"]; - this.appConfig["mosip.resident.vid.card.name.convention"] = responseData["mosip.resident.vid.card.name.convention"]; - this.appConfig["mosip.resident.download.service.history.file.name.convention"] = responseData["mosip.resident.download.service.history.file.name.convention"]; - this.appConfig["mosip.resident.download.nearest.registration.centre.file.name.convention"] = responseData["mosip.resident.download.nearest.registration.centre.file.name.convention"]; - this.appConfig["resident.nearby.centers.distance.meters"] = responseData["resident.nearby.centers.distance.meters"]; - this.appConfig["mosip.resident.captcha.sitekey"] = responseData["mosip.resident.captcha.sitekey"]; - this.appConfig["mosip.resident.captcha.secretkey"] = responseData["mosip.resident.captcha.secretkey"]; - this.appConfig["mosip.webui.auto.logout.idle"] = responseData["mosip.webui.auto.logout.idle"]; - this.appConfig["mosip.webui.auto.logout.ping"] = responseData["mosip.webui.auto.logout.ping"]; - this.appConfig["mosip.webui.auto.logout.timeout"] = responseData["mosip.webui.auto.logout.timeout"]; - this.appConfig["resident.updateuin.id"] = responseData["resident.updateuin.id"]; - this.appConfig["resident.ui.notification.update.interval.seconds"] = responseData["resident.ui.notification.update.interval.seconds"]; - this.appConfig["mosip.kernel.otp.expiry-time"] = responseData["mosip.kernel.otp.expiry-time"]; - this.appConfig["resident.grievance-redressal.comments.chars.limit"] = responseData["resident.grievance-redressal.comments.chars.limit"]; - this.appConfig["resident.grievance-redressal.alt-email.chars.limit"] = responseData["resident.grievance-redressal.alt-email.chars.limit"]; - this.appConfig["resident.grievance-redressal.alt-phone.chars.limit"] = responseData["resident.grievance-redressal.alt-phone.chars.limit"]; - this.appConfig["resident.validation.event-id.regex"] = responseData["resident.validation.event-id.regex"]; - this.appConfig["resident.purpose.allowed.special.char.regex"] = responseData["resident.purpose.allowed.special.char.regex"]; - this.appConfig["mosip.resident.captcha.enable"] = responseData["mosip.resident.captcha.enable"]; - this.appConfig["mosip.kernel.vid.length"] = responseData["mosip.kernel.vid.length"]; - this.appConfig["mosip.kernel.uin.length"] = responseData["mosip.kernel.uin.length"]; - this.appConfig["mosip.kernel.rid.length"] = responseData["mosip.kernel.rid.length"]; - this.appConfig["mosip.resident.transliteration.transliterate.id"] = responseData["mosip.resident.transliteration.transliterate.id"]; - this.appConfig["resident.contact.details.update.id"] = responseData["resident.contact.details.update.id"]; - this.appConfig["mosip.resident.zoom"] = responseData["mosip.resident.zoom"]; - this.appConfig["mosip.resident.maxZoom"] = responseData["mosip.resident.maxZoom"]; - this.appConfig["mosip.resident.minZoom"] = responseData["mosip.resident.minZoom"]; - this.appConfig["resident.update-uin.machine-zone-code"] = responseData["resident.update-uin.machine-zone-code"]; - this.appConfig["resident-multi-language-enable"] = responseData["resident-multi-language-enable"]; - localStorage.setItem("isDataLoaded", 'true') - }, - (error) => { - console.log(error); - } - ); + async loadAppConfig(): Promise { + try { + // Load local config.json + this.appConfig = await this.http.get('./assets/config.json').toPromise(); + // Load additional config from remote endpoint + const response = await this.http.get(this.appConfig.baseUrl + '/proxy/config/ui-properties').toPromise(); + const responseData = response["response"]; + localStorage.setItem("langCode", responseData["mosip.mandatory-languages"]); + this.appConfig["supportedLanguages"] = responseData["mosip.mandatory-languages"] + ",ara" + ",fra" +","+responseData["mosip.optional-languages"]; + this.appConfig["mosip.iam.adapter.clientid"] = responseData["mosip.iam.adapter.clientid"]; + this.appConfig["mosip.resident.api.id.otp.request"] = responseData["mosip.resident.api.id.otp.request"]; + this.appConfig["mosip.resident.api.version.otp.request"] = responseData["mosip.resident.api.version.otp.request"]; + this.appConfig["resident.vid.id"] = responseData["resident.vid.id"]; + this.appConfig["resident.vid.version"] = responseData["resident.vid.version"]; + this.appConfig["mosip.resident.request.response.version"] = responseData["mosip.resident.request.response.version"]; + this.appConfig["resident.revokevid.id"] = responseData["resident.revokevid.id"]; + this.appConfig["mosip-prereg-host"] = responseData["mosip-prereg-host"]; + this.appConfig["mosip-prereg-ui-url"] = responseData["mosip-prereg-ui-url"]; + this.appConfig["auth.types.allowed"] = responseData["auth.types.allowed"]; + this.appConfig["resident.view.history.serviceType.filters"] = responseData["resident.view.history.serviceType.filters"]; + this.appConfig["resident.view.history.status.filters"] = responseData["resident.view.history.status.filters"]; + this.appConfig["mosip.resident.grievance.url"] = responseData["mosip.resident.grievance.url"]; + this.appConfig["resident.vid.id.generate"] = responseData["resident.vid.id.generate"]; + this.appConfig["resident.vid.version.new"] = responseData["resident.vid.version.new"]; + this.appConfig["mosip.resident.revokevid.id"] = responseData["mosip.resident.revokevid.id"]; + this.appConfig["resident.revokevid.version.new"] = responseData["resident.revokevid.version.new"]; + this.appConfig["mosip.resident.download.personalized.card.id"] = responseData["mosip.resident.download.personalized.card.id"] + this.appConfig["mosip.resident.download.registration.centre.file.name.convention"] = responseData["mosip.resident.download.registration.centre.file.name.convention"]; + this.appConfig["mosip.resident.download.supporting.document.file.name.convention"] = responseData["mosip.resident.download.supporting.document.file.name.convention"]; + this.appConfig["mosip.resident.download.personalized.card.naming.convention"] = responseData["mosip.resident.download.personalized.card.naming.convention"]; + this.appConfig["mosip.resident.ack.manage_my_vid.name.convention"] = responseData["mosip.resident.ack.manage_my_vid.name.convention"]; + this.appConfig["mosip.resident.ack.secure_my_id.name.convention"] = responseData["mosip.resident.ack.secure_my_id.name.convention"]; + this.appConfig["mosip.resident.ack.personalised_card.name.convention"] = responseData["mosip.resident.ack.personalised_card.name.convention"]; + this.appConfig["mosip.resident.ack.update_my_data.name.convention"] = responseData["mosip.resident.ack.update_my_data.name.convention"]; + this.appConfig["mosip.resident.ack.share_credential.name.convention"] = responseData["mosip.resident.ack.share_credential.name.convention"]; + this.appConfig["mosip.resident.ack.order_physical_card.name.convention"] = responseData["mosip.resident.ack.order_physical_card.name.convention"]; + this.appConfig["mosip.resident.ack.name.convention"] = responseData["mosip.resident.ack.name.convention"]; + this.appConfig["mosip.resident.uin.card.name.convention"] = responseData["mosip.resident.uin.card.name.convention"]; + this.appConfig["mosip.resident.vid.card.name.convention"] = responseData["mosip.resident.vid.card.name.convention"]; + this.appConfig["mosip.resident.download.service.history.file.name.convention"] = responseData["mosip.resident.download.service.history.file.name.convention"]; + this.appConfig["mosip.resident.download.nearest.registration.centre.file.name.convention"] = responseData["mosip.resident.download.nearest.registration.centre.file.name.convention"]; + this.appConfig["resident.nearby.centers.distance.meters"] = responseData["resident.nearby.centers.distance.meters"]; + this.appConfig["mosip.resident.captcha.sitekey"] = responseData["mosip.resident.captcha.sitekey"]; + this.appConfig["mosip.resident.captcha.secretkey"] = responseData["mosip.resident.captcha.secretkey"]; + this.appConfig["mosip.webui.auto.logout.idle"] = responseData["mosip.webui.auto.logout.idle"]; + this.appConfig["mosip.webui.auto.logout.ping"] = responseData["mosip.webui.auto.logout.ping"]; + this.appConfig["mosip.webui.auto.logout.timeout"] = responseData["mosip.webui.auto.logout.timeout"]; + this.appConfig["resident.updateuin.id"] = responseData["resident.updateuin.id"]; + this.appConfig["resident.ui.notification.update.interval.seconds"] = responseData["resident.ui.notification.update.interval.seconds"]; + this.appConfig["mosip.kernel.otp.expiry-time"] = responseData["mosip.kernel.otp.expiry-time"]; + this.appConfig["resident.grievance-redressal.comments.chars.limit"] = responseData["resident.grievance-redressal.comments.chars.limit"]; + this.appConfig["resident.grievance-redressal.alt-email.chars.limit"] = responseData["resident.grievance-redressal.alt-email.chars.limit"]; + this.appConfig["resident.grievance-redressal.alt-phone.chars.limit"] = responseData["resident.grievance-redressal.alt-phone.chars.limit"]; + this.appConfig["resident.validation.event-id.regex"] = responseData["resident.validation.event-id.regex"]; + this.appConfig["resident.purpose.allowed.special.char.regex"] = responseData["resident.purpose.allowed.special.char.regex"]; + this.appConfig["mosip.resident.captcha.enable"] = responseData["mosip.resident.captcha.enable"]; + this.appConfig["mosip.kernel.vid.length"] = responseData["mosip.kernel.vid.length"]; + this.appConfig["mosip.kernel.uin.length"] = responseData["mosip.kernel.uin.length"]; + this.appConfig["mosip.kernel.rid.length"] = responseData["mosip.kernel.rid.length"]; + this.appConfig["mosip.resident.transliteration.transliterate.id"] = responseData["mosip.resident.transliteration.transliterate.id"]; + this.appConfig["resident.contact.details.update.id"] = responseData["resident.contact.details.update.id"]; + this.appConfig["mosip.resident.zoom"] = responseData["mosip.resident.zoom"]; + this.appConfig["mosip.resident.maxZoom"] = responseData["mosip.resident.maxZoom"]; + this.appConfig["mosip.resident.minZoom"] = responseData["mosip.resident.minZoom"]; + this.appConfig["resident.update-uin.machine-zone-code"] = responseData["resident.update-uin.machine-zone-code"]; + this.appConfig["mosip.mandatory-languages"] = responseData["mosip.mandatory-languages"]; + } catch (error) { + console.error("Error loading configuration", error); + throw error; + } } getConfig() { diff --git a/resident-ui/src/app/app.component.ts b/resident-ui/src/app/app.component.ts index 40513493..a7b07fab 100644 --- a/resident-ui/src/app/app.component.ts +++ b/resident-ui/src/app/app.component.ts @@ -168,10 +168,7 @@ export class AppComponent { if(window.location.href.includes('error=invalid_transaction')){ this.router.navigate(['error']); } - - if(!localStorage.getItem("langCode")){ - localStorage.setItem("langCode", "eng"); - } + this.subscriptions.push(this.autoLogout.currentMessageAutoLogout.subscribe(() => {})); this.autoLogout.changeMessage({ timerFired: false }); this.routerType(); diff --git a/resident-ui/src/app/feature/getuin/getuin/getuin.component.ts b/resident-ui/src/app/feature/getuin/getuin/getuin.component.ts index bd2e70bb..80450485 100644 --- a/resident-ui/src/app/feature/getuin/getuin/getuin.component.ts +++ b/resident-ui/src/app/feature/getuin/getuin/getuin.component.ts @@ -84,20 +84,13 @@ export class GetuinComponent implements OnInit { } getConfigData(){ - if(localStorage.getItem('isDataLoaded') === 'true'){ - this.siteKey = this.appConfigService.getConfig()["mosip.resident.captcha.sitekey"]; - this.captchaEnable = JSON.parse(this.appConfigService.getConfig()["mosip.resident.captcha.enable"]); - this.vidLength = this.appConfigService.getConfig()["mosip.kernel.vid.length"]; - this.uinLength = this.appConfigService.getConfig()["mosip.kernel.uin.length"]; - this.aidLength = this.appConfigService.getConfig()["mosip.kernel.rid.length"]; - this.getLangData() - this.isLoading = false; - return - }else{ - setTimeout(()=>{ - this.getConfigData() - },500) - } + this.siteKey = this.appConfigService.getConfig()["mosip.resident.captcha.sitekey"]; + this.captchaEnable = JSON.parse(this.appConfigService.getConfig()["mosip.resident.captcha.enable"]); + this.vidLength = this.appConfigService.getConfig()["mosip.kernel.vid.length"]; + this.uinLength = this.appConfigService.getConfig()["mosip.kernel.uin.length"]; + this.aidLength = this.appConfigService.getConfig()["mosip.kernel.rid.length"]; + this.getLangData() + this.isLoading = false; } getLangData(){ diff --git a/resident-ui/src/app/feature/uinservices/personalisedcard/personalisedcard.component.ts b/resident-ui/src/app/feature/uinservices/personalisedcard/personalisedcard.component.ts index 59a0fefd..d1932151 100644 --- a/resident-ui/src/app/feature/uinservices/personalisedcard/personalisedcard.component.ts +++ b/resident-ui/src/app/feature/uinservices/personalisedcard/personalisedcard.component.ts @@ -298,10 +298,10 @@ export class PersonalisedcardComponent implements OnInit, OnDestroy { }) if (type.value === data.attributeName) { - value = this.createDefaultValue(data) data.formatOption[this.langCode].forEach(item => { item.checked = true }) + value = this.createDefaultValue(data); } else { value = this.createCheckedVal(data); this.checkDefaultVal(data, $event); diff --git a/resident-ui/src/app/feature/verify/verify/verify.component.ts b/resident-ui/src/app/feature/verify/verify/verify.component.ts index 0f7909ee..d1ee53d3 100644 --- a/resident-ui/src/app/feature/verify/verify/verify.component.ts +++ b/resident-ui/src/app/feature/verify/verify/verify.component.ts @@ -428,7 +428,7 @@ export class VerifyComponent implements OnInit, OnDestroy { onItemSelected(item: any) { if (item === "home") { this.router.navigate(["dashboard"]); - } else if ("back") { + } else if (item === "back") { this.showOtpPanel = false; this.resetBtnDisable = true; this.submitBtnDisable = true; diff --git a/resident-ui/src/app/shared/header/header.component.html b/resident-ui/src/app/shared/header/header.component.html index 65ee0c92..3a055e04 100644 --- a/resident-ui/src/app/shared/header/header.component.html +++ b/resident-ui/src/app/shared/header/header.component.html @@ -20,13 +20,13 @@ {{item.label}} - + - diff --git a/resident-ui/src/app/shared/header/header.component.ts b/resident-ui/src/app/shared/header/header.component.ts index a2e52b4b..4ad93e34 100644 --- a/resident-ui/src/app/shared/header/header.component.ts +++ b/resident-ui/src/app/shared/header/header.component.ts @@ -78,42 +78,31 @@ export class HeaderComponent implements OnInit, OnDestroy { } getConfigData(){ - if(localStorage.getItem('isDataLoaded') === 'true'){ - let supportedLanguages = this.appConfigService.getConfig()['supportedLanguages'].split(','); - this.showLangDropDown = this.appConfigService.getConfig()['resident-multi-language-enable']; + let allSupportedLanguages = this.appConfigService.getConfig()['supportedLanguages'].split(','); + let uniqueSupportedLanguages = allSupportedLanguages.filter((item, index) => allSupportedLanguages.indexOf(item) === index); + this.showLangDropDown = uniqueSupportedLanguages.length > 1 ? true : false; - if(supportedLanguages.length > 1){ - supportedLanguages.forEach((language) => { + if(uniqueSupportedLanguages.length > 1){ + uniqueSupportedLanguages.forEach((language) => { this.selectLanguagesArr.push({ code: language.trim(), value: defaultJson.languages[language.trim()].nativeName, }); }); } - + this.translateService.use(localStorage.getItem("langCode")); this.textDir = localStorage.getItem("dir"); return - }else{ - setTimeout(()=>{ - this.getConfigData() - },400) - } } - - async ngOnInit() { + async ngOnInit() { + console.log('Header component') this.defaultJsonValue = defaultJson; let self = this; this.getConfigData(); - if(!localStorage.getItem("langCode")){ - localStorage.setItem("langCode", "eng"); - this.selectedLanguage = defaultJson["languages"]['eng'].nativeName; - }else{ - let key = localStorage.getItem("langCode") - this.selectedLanguage = defaultJson["languages"][key].nativeName; - } + this.selectedLanguage = defaultJson["languages"][this.langCode].nativeName; self.getProfileInfo(); await this.translateService From d0261ffce8fc289bf57b5d28eb24565790b44ce7 Mon Sep 17 00:00:00 2001 From: MadhuMosip Date: Mon, 25 Nov 2024 15:20:31 +0530 Subject: [PATCH 2/3] MOSIP-37782 removed log in header component Signed-off-by: MadhuMosip --- resident-ui/src/app/shared/header/header.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/resident-ui/src/app/shared/header/header.component.ts b/resident-ui/src/app/shared/header/header.component.ts index 4ad93e34..d985dfae 100644 --- a/resident-ui/src/app/shared/header/header.component.ts +++ b/resident-ui/src/app/shared/header/header.component.ts @@ -97,7 +97,6 @@ export class HeaderComponent implements OnInit, OnDestroy { } async ngOnInit() { - console.log('Header component') this.defaultJsonValue = defaultJson; let self = this; this.getConfigData(); From ee8dd7b8aff37c57e823e625b0662e5ec57c3c19 Mon Sep 17 00:00:00 2001 From: MadhuMosip Date: Mon, 25 Nov 2024 15:22:18 +0530 Subject: [PATCH 3/3] MOSIP-37782 removed haed coded values Signed-off-by: MadhuMosip --- resident-ui/src/app/app-config.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resident-ui/src/app/app-config.service.ts b/resident-ui/src/app/app-config.service.ts index 91538853..3bad2215 100644 --- a/resident-ui/src/app/app-config.service.ts +++ b/resident-ui/src/app/app-config.service.ts @@ -16,7 +16,7 @@ export class AppConfigService { const response = await this.http.get(this.appConfig.baseUrl + '/proxy/config/ui-properties').toPromise(); const responseData = response["response"]; localStorage.setItem("langCode", responseData["mosip.mandatory-languages"]); - this.appConfig["supportedLanguages"] = responseData["mosip.mandatory-languages"] + ",ara" + ",fra" +","+responseData["mosip.optional-languages"]; + this.appConfig["supportedLanguages"] = responseData["mosip.mandatory-languages"] + ","+ responseData["mosip.optional-languages"]; this.appConfig["mosip.iam.adapter.clientid"] = responseData["mosip.iam.adapter.clientid"]; this.appConfig["mosip.resident.api.id.otp.request"] = responseData["mosip.resident.api.id.otp.request"]; this.appConfig["mosip.resident.api.version.otp.request"] = responseData["mosip.resident.api.version.otp.request"];