sitmun / sitmun-admin-app

Administration application for the SITMUN system.
European Union Public License 1.2
0 stars 1 forks source link

Potential hardcoded codes #131

Open fjlopez opened 2 years ago

fjlopez commented 2 years ago

This is a list of potential hardcoded codes

Related with languages

File Code
app/app.module.ts registerLocaleData(localeEs, 'es-ES');
app/app.module.ts registerLocaleData(localeCa, 'ca-ES');
app/app.module.ts { provide: LOCALE_ID, useValue: 'es-ES' },
app/app.component.ts this.translate.addLangs(['es', 'ca', 'es', 'fr']);
app/app.component.ts if(language.shortname == 'ca') { config.languagesObjects.catalan=language; }
app/app.component.ts if(language.shortname == 'es') { config.languagesObjects.spanish= language }
app/app.component.ts if(language.shortname == 'en') { config.languagesObjects.english= language }
app/app.component.ts if(language.shortname == 'oc-aranes') { config.languagesObjects.aranese= language }
app/app.component.ts if(language.shortname == 'fr') { config.languagesObjects.french= language }
app/services/icons.service.ts id: 'icon_lang_ca',
app/services/icons.service.ts icon: 'flag_ca',
app/services/icons.service.ts id: 'icon_lang_en',
app/services/icons.service.ts icon: 'flag_en',
app/services/icons.service.ts id: 'icon_lang_es',
app/services/icons.service.ts icon: 'flag_es',
app/services/icons.service.ts id: 'icon_lang_oc',
app/services/icons.service.ts icon: 'flag_oc',
app/services/icons.service.ts id: 'icon_lang_fr',
app/services/icons.service.ts icon: 'flag_oc',
Related with the dashboard, as they can be dynamically obtained by the actuator. File Code
app/components/dashboard/dashboard.component.ts this.KPIsTable.push({text: this.utils.getTranslate("dashboard.newUsers"), number: result.total.users})
app/components/dashboard/dashboard.component.ts this.KPIsTable.push({text: this.utils.getTranslate("dashboard.services"), number: result.total.services})
app/components/dashboard/dashboard.component.ts this.KPIsTable.push({text: this.utils.getTranslate("dashboard.tasks"), number: result.total.tasks})
app/components/dashboard/dashboard.component.ts this.KPIsTable.push({text: this.utils.getTranslate("dashboard.territories"), number: result.total.territories})
app/components/dashboard/dashboard.component.ts this.KPIsTable.push({text: this.utils.getTranslate("dashboard.cartographies"), number: result.total.cartographies})
app/components/dashboard/dashboard.component.ts this.KPIsTable.push({text: this.utils.getTranslate("dashboard.applications"), number: result.total.applications})
app/components/dashboard/dashboard.component.ts this.KPIsTable.push({text: this.utils.getTranslate("dashboard.applicationsTerritories"), number: result.total['applications-territories']})

Related with OGC web services

File Code
app/components/trees/trees-form/trees-form.component.ts if (!url.includes('request=GetCapabilities')) {
app/components/trees/trees-form/trees-form.component.ts url += 'request=GetCapabilities%26service=WMS'
app/components/layers/layers-form/layers-form.component.ts if (service.type === 'WFS') { wfsServices.push(service) }
app/components/service/service-form/service-form.component.ts this.tableLoadButtonDisabled=currentType.value == 'WMS'? false:true
app/components/service/service-form/service-form.component.ts if(! url.includes('request=GetCapabilities')){
app/components/service/service-form/service-form.component.ts url += 'request=GetCapabilities%26service=WMS'
app/components/task-form/task-form.component.ts else if(selector=="wfsServices") { this.wfsServicesNeeded = true }
app/components/task-form/task-form.component.ts else if(data=="wfsServices") { return this.wfsServices }

Related to code lists

File Code Obs
app/components/background-layers/background-layers-form/background-layers-form.component.ts if (cartographyGroup.description === 'Background map') { bug, should be cartographyGroup.type === 'F'?
app/components/application/application-form/application-form.component.ts if (element.value !== 'PRINT_TEMPLATE') { newTable.push(element) } why this value of the code list application.type is needed hardcoded?
app/components/application/application-form/application-form.component.ts item.type = 'PRINT_TEMPLATE'; why this value of the code list application.type is needed hardcoded?
app/components/application/application-form/application-form.component.ts let param: HalParam = { key: 'type', value: 'M' } why it must be hardcoded?
app/components/application/application-form/application-form.component.ts if (value === 'E') { why it must be hardcoded?

These constants are related with the tasks types that are dynamically loaded.

File Code
app/components/task-form/task-form.component.ts else if(selector=="fmeServices") { this.fmeServicesNeeded = true }
app/components/task-form/task-form.component.ts else if(selector=="this.locators") { this.locatorsNeeded = true }
app/components/task-form/task-form.component.ts else if(this.taskTypeName == 'Query' this.taskTypeName== 'More info' this.taskTypeName== 'Locator' ){
app/components/task-form/task-form.component.ts else if(this.taskTypeName == 'Extraction (FME)' this.taskTypeName == 'Report' ){
app/components/task-form/task-form.component.ts let key =this.taskTypeName == 'Extraction (FME)'?'layers':'layer'
app/components/task-form/task-form.component.ts else if(data=="fmeServices") { return this.fmeServices }
app/components/task-form/task-form.component.ts else if(data=="this.locators") { return this.locators }
app/services/icons.service.ts id: 'tasksDownload',
app/services/icons.service.ts id: 'tasksDocument',
app/services/icons.service.ts id: 'tasksQuery',
app/services/icons.service.ts id: 'tasksMoreInformation',
app/services/icons.service.ts id: 'tasksLocator',
app/services/icons.service.ts id: 'tasksReport',
app/services/icons.service.ts id: 'tasksEdition',
app/services/icons.service.ts id: 'tasksEditionCartographyTable',
app/services/icons.service.ts translation: 'cartographyTableWFT'
app/services/icons.service.ts id: 'tasksEditionDataTable',
app/services/icons.service.ts translation: 'dataTable',
app/services/icons.service.ts id: 'tasksEditionRelationTable',
app/services/icons.service.ts translation: 'relationTable',
app/services/icons.service.ts id: 'tasksEditionSearchView',
app/services/icons.service.ts translation: 'searchView',
app/services/icons.service.ts id: 'tasksThematic',
app/services/icons.service.ts id: 'tasksExtractionFME',
gon-nexus commented 2 years ago

Elements fixed:

Related with OGC web services

File Code
app/components/trees/trees-form/trees-form.component.ts if (!url.includes('request=GetCapabilities')) {
app/components/trees/trees-form/trees-form.component.ts url += 'request=GetCapabilities%26service=WMS'
app/components/layers/layers-form/layers-form.component.ts if (service.type === 'WFS') { wfsServices.push(service) }
app/components/service/service-form/service-form.component.ts this.tableLoadButtonDisabled=currentType.value == 'WMS'? false:true
app/components/service/service-form/service-form.component.ts if(! url.includes('request=GetCapabilities')){
app/components/service/service-form/service-form.component.ts url += 'request=GetCapabilities%26service=WMS'
app/components/task-form/task-form.component.ts else if(selector=="wfsServices") { this.wfsServicesNeeded = true }
app/components/task-form/task-form.component.ts else if(data=="wfsServices") { return this.wfsServices }

Related to code lists

File Code Obs
app/components/background-layers/background-layers-form/background-layers-form.component.ts if (cartographyGroup.description === 'Background map') { bug, should be cartographyGroup.type === 'F'?
app/components/application/application-form/application-form.component.ts if (element.value !== 'PRINT_TEMPLATE') { newTable.push(element) } why this value of the code list application.type is needed hardcoded?
app/components/application/application-form/application-form.component.ts item.type = 'PRINT_TEMPLATE'; why this value of the code list application.type is needed hardcoded?

These constants are related with the tasks types that are dynamically loaded.

File Code
app/components/task-form/task-form.component.ts else if(selector=="fmeServices") { this.fmeServicesNeeded = true }
app/components/task-form/task-form.component.ts else if(selector=="this.locators") { this.locatorsNeeded = true }
app/components/task-form/task-form.component.ts else if(this.taskTypeName == 'Query' this.taskTypeName== 'More info' this.taskTypeName== 'Locator' ){
app/components/task-form/task-form.component.ts else if(this.taskTypeName == 'Extraction (FME)' this.taskTypeName == 'Report' ){
app/components/task-form/task-form.component.ts let key =this.taskTypeName == 'Extraction (FME)'?'layers':'layer'
app/components/task-form/task-form.component.ts else if(data=="fmeServices") { return this.fmeServices }
app/components/task-form/task-form.component.ts else if(data=="this.locators") { return this.locators }

We think that the other elements don't need to be changed.

fjlopez commented 2 years ago

And languages? For example, imagine if somebody needs a Portuguese version and the backend has the Portuguese translations. Can the current code support it?

gon-nexus commented 2 years ago

You were right! Now we have made a modification so if you want to add a new language you only need to add the flag icon (named flag_'shortname'.svg) and add an i18n file for translations (named 'shortname'.json').

Thanks!