Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BO -Tableau de bord] Problème chargement du tableau de bord #3109

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading