Skip to content

Commit

Permalink
Merge branch 'main' into develop #3103
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinx13 committed Oct 1, 2024
2 parents 5ea3c81 + fb948c9 commit a68ae87
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 21 deletions.
72 changes: 53 additions & 19 deletions assets/scripts/vue/components/dashboard/TheHistoAppDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,21 @@ export default defineComponent({
isLoadingRefresh: false
}
},
created () {
async created () {
if (initElements !== null) {
this.sharedProps.ajaxurlSettings = initElements.dataset.ajaxurlSettings
this.sharedProps.ajaxurlKpi = initElements.dataset.ajaxurlKpi
this.sharedProps.ajaxurlPartners = initElements.dataset.ajaxurlPartners
this.sharedProps.ajaxurlSignalementsNosuivi = initElements.dataset.ajaxurlSignalementsNosuivi
this.sharedProps.ajaxurlSignalementsPerTerritoire = initElements.dataset.ajaxurlSignalementsPerTerritoire
this.sharedProps.ajaxurlConnectionsEsabora = initElements.dataset.ajaxurlConnectionsEsabora
requests.initSettings(this.handleInitSettings)
requests.initKPI(this.handleInitKPI)
try {
await this.initSettingsWithPromise()
await this.initKPIWithPromise()
} catch (error) {
console.error('Error during initialization', error)
this.isErrorInit = true
}
} else {
this.isErrorInit = true
}
Expand Down Expand Up @@ -127,24 +132,25 @@ export default defineComponent({
} else {
this.isLoadingInit = false
this.isLoadingRefresh = false
this.processResponseInit(requestResponse)
if (this.sharedState.user.isAdmin || this.sharedState.user.isResponsableTerritoire) {
this.countTablesToLoad++
requests.initAffectationPartner(this.handleAffectationPartner)
}
if (this.sharedState.user.isResponsableTerritoire) {
this.countTablesToLoad++
requests.initSignalementsNoSuivi(this.handleSignalementsNoSuivi)
}
if (this.sharedState.user.isAdmin) {
this.countTablesToLoad++
requests.initSignalementsPerTerritoire(this.handleSignalementsPerTerritoire)
this.countTablesToLoad++
requests.initEsaboraEvents(this.handleEsaboraEvents)
}
this.processResponseInit(requestResponse, () => {
if (this.sharedState.user.isAdmin || this.sharedState.user.isResponsableTerritoire) {
this.countTablesToLoad++
requests.initAffectationPartner(this.handleAffectationPartner)
}
if (this.sharedState.user.isResponsableTerritoire) {
this.countTablesToLoad++
requests.initSignalementsNoSuivi(this.handleSignalementsNoSuivi)
}
if (this.sharedState.user.isAdmin) {
this.countTablesToLoad++
requests.initSignalementsPerTerritoire(this.handleSignalementsPerTerritoire)
this.countTablesToLoad++
requests.initEsaboraEvents(this.handleEsaboraEvents)
}
})
}
},
processResponseInit (requestResponse: any) {
processResponseInit (requestResponse: any, callback: () => void) {
this.sharedState.signalements.count = requestResponse.data.countSignalement.active
this.sharedState.signalements.percent = requestResponse.data.countSignalement.percentage.active
this.sharedState.closedSignalements.count = requestResponse.data.countSignalement.closed
Expand Down Expand Up @@ -182,6 +188,10 @@ export default defineComponent({
this.sharedState.nonDecenceSignalements.linkActive = dataWidget.cardSignalementsEnCoursNonDecence?.link
this.sharedState.noSuiviAfter3Relances.count = dataWidget.cardNoSuiviAfter3Relances?.count
this.sharedState.noSuiviAfter3Relances.link = dataWidget.cardNoSuiviAfter3Relances?.link
if (callback) {
callback()
}
},
handleAffectationPartner (requestResponse: any) {
this.countTablesLoaded++
Expand Down Expand Up @@ -240,6 +250,30 @@ export default defineComponent({
handleChangeTerritoire () {
this.isLoadingRefresh = true
requests.initKPI(this.handleInitKPI)
},
initSettingsWithPromise (): Promise<void> {
return new Promise((resolve, reject) => {
requests.initSettings((response: any) => {
try {
this.handleInitSettings(response)
resolve()
} catch (error) {
reject(error)
}
})
})
},
initKPIWithPromise (): Promise<void> {
return new Promise((resolve, reject) => {
requests.initKPI((response: any) => {
try {
this.handleInitKPI(response)
resolve()
} catch (error) {
reject(error)
}
})
})
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion assets/scripts/vue/components/dashboard/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/browser'
export const requests = {
doRequest (ajaxUrl: string, functionReturn: Function) {
axios
.get(ajaxUrl, { timeout: 15000 })
.get(ajaxUrl, { timeout: 30000 })
.then(response => {
const responseData = response.data
functionReturn(responseData)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress",
"es-vue-fix": "node_modules/.bin/eslint --config=.eslintrc.js assets/vue --fix"
"es-vue-fix": "node_modules/.bin/eslint --config=.eslintrc.js assets/scripts/vue --fix"
},
"engines": {
"node": "18.14.2"
Expand Down

0 comments on commit a68ae87

Please sign in to comment.