diff --git a/src/custom/ecospheres/components/indicators/IndicatorSourcesList.vue b/src/custom/ecospheres/components/indicators/IndicatorSourcesList.vue
new file mode 100644
index 000000000..7bef06e51
--- /dev/null
+++ b/src/custom/ecospheres/components/indicators/IndicatorSourcesList.vue
@@ -0,0 +1,43 @@
+
+
+
+
+ {{ source.nom }}
+
+
+
+
+
+
+ {{ source.url }}
+
+
+
+
+ {{ formatDate(source.plage_temporelle.start, true) }} -
+ {{ formatDate(source.plage_temporelle.end, true) }}
+
+
+
+
diff --git a/src/custom/ecospheres/components/indicators/IndicatorTags.vue b/src/custom/ecospheres/components/indicators/IndicatorTags.vue
new file mode 100644
index 000000000..a8463d129
--- /dev/null
+++ b/src/custom/ecospheres/components/indicators/IndicatorTags.vue
@@ -0,0 +1,34 @@
+
+
+
+
+ -
+
+ {{ t.value }}
+
+
+
+ {{ UNFILLED_LABEL }}
+
diff --git a/src/custom/ecospheres/components/indicators/SelectSpatialGranularity.vue b/src/custom/ecospheres/components/indicators/SelectSpatialGranularity.vue
new file mode 100644
index 000000000..eb515ce62
--- /dev/null
+++ b/src/custom/ecospheres/components/indicators/SelectSpatialGranularity.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
diff --git a/src/custom/ecospheres/components/indicators/informations/InformationPanelItem.vue b/src/custom/ecospheres/components/indicators/informations/InformationPanelItem.vue
new file mode 100644
index 000000000..a0a8c8064
--- /dev/null
+++ b/src/custom/ecospheres/components/indicators/informations/InformationPanelItem.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
+
{{ title }}
+
+
+
{{ value }}
+
+
+
+
diff --git a/src/custom/ecospheres/components/indicators/informations/InformationPanelSection.vue b/src/custom/ecospheres/components/indicators/informations/InformationPanelSection.vue
new file mode 100644
index 000000000..12d6aae3d
--- /dev/null
+++ b/src/custom/ecospheres/components/indicators/informations/InformationPanelSection.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
diff --git a/src/custom/ecospheres/model/indicator.ts b/src/custom/ecospheres/model/indicator.ts
index ef3a39956..4c5233075 100644
--- a/src/custom/ecospheres/model/indicator.ts
+++ b/src/custom/ecospheres/model/indicator.ts
@@ -1,14 +1,61 @@
import type { DatasetV2 } from '@datagouv/components'
-export type Indicator = DatasetV2
+export interface IndicatorExtrasCalcul {
+ responsable: string
+ methode: string
+}
+
+export interface IndicatorExtrasSource {
+ nom: string
+ url: string
+ description: string
+ producteur: string
+ distributeur: string
+ plage_temporelle: {
+ start: string
+ end: string
+ }
+}
+
+export interface IndicatorsExtrasApi {
+ id: string
+ description: string
+ noms_cubes: string[]
+}
+
+export type IndicatorExtras = DatasetV2['extras'] & {
+ unite: string
+ mailles_geographiques: string[]
+ axes: {
+ [key: string]: string[]
+ }
+ calcul: IndicatorExtrasCalcul
+ api: IndicatorsExtrasApi
+ sources: IndicatorExtrasSource[]
+}
+
+export type Indicator = DatasetV2 & {
+ extras: IndicatorExtras
+}
// repeating keys is necessary, type becomes too complex to be usable if we don't
// we're keeping values and type in the same place to facilitate maintenance
-export const FILTER_KEYS = ['theme', 'enjeu'] as const
+export const FILTER_KEYS = [
+ 'theme',
+ 'enjeu',
+ 'secteur',
+ 'levier',
+ 'producteur',
+ 'usage'
+] as const
export type IndicatorFilters = {
theme: string | null
enjeu: string | null
+ secteur: string | null
+ levier: string | null
+ producteur: string | null
+ usage: string | null
}
export interface IndicatorTag {
diff --git a/src/custom/ecospheres/routes.ts b/src/custom/ecospheres/routes.ts
index 07396e2c4..1b3cdded1 100644
--- a/src/custom/ecospheres/routes.ts
+++ b/src/custom/ecospheres/routes.ts
@@ -12,27 +12,39 @@ export const routes = [
},
{
path: '/indicators',
- name: 'indicators',
- meta: {
- title: 'Indicateurs'
- },
- props: (route: RouteLocationNormalizedLoaded) => {
- const filterProps = FILTER_KEYS.reduce(
- (acc, key) => ({
- ...acc,
- [key]: route.query[key] || null
- }),
- {}
- )
- return {
- query: route.query.q,
- geozone: route.query.geozone || null,
- page: route.query.page || null,
- sort: route.query.sort || null,
- ...filterProps
+ children: [
+ {
+ path: '',
+ name: 'indicators',
+ meta: {
+ title: 'Indicateurs'
+ },
+ component: async () =>
+ await import('./views/indicators/IndicatorsListView.vue'),
+ props: (route: RouteLocationNormalizedLoaded) => {
+ const filterProps = FILTER_KEYS.reduce(
+ (acc, key) => ({
+ ...acc,
+ [key]: route.query[key] || null
+ }),
+ {}
+ )
+ return {
+ query: route.query.q,
+ geozone: route.query.geozone || null,
+ granularity: route.query.granularity || null,
+ page: route.query.page || null,
+ sort: route.query.sort || null,
+ ...filterProps
+ }
+ }
+ },
+ {
+ path: ':iid',
+ name: 'indicator_detail',
+ component: async () =>
+ await import('./views/indicators/IndicatorDetailView.vue')
}
- },
- component: async () =>
- await import('./views/indicators/IndicatorsListView.vue')
+ ]
}
]
diff --git a/src/custom/ecospheres/store/IndicatorStore.ts b/src/custom/ecospheres/store/IndicatorStore.ts
index 0dd738315..59a462600 100644
--- a/src/custom/ecospheres/store/IndicatorStore.ts
+++ b/src/custom/ecospheres/store/IndicatorStore.ts
@@ -33,7 +33,7 @@ export const useIndicatorStore = defineStore('indicator', {
tag,
...extraArgs
})
- this.indicators = results.data
+ this.indicators = results.data as Indicator[]
this.total = results.total
}
},
diff --git a/src/custom/ecospheres/utils/indicator.ts b/src/custom/ecospheres/utils/indicator.ts
index 40e25fc29..e0d06285c 100644
--- a/src/custom/ecospheres/utils/indicator.ts
+++ b/src/custom/ecospheres/utils/indicator.ts
@@ -1,9 +1,14 @@
import config from '@/config'
+import { useSpatialStore } from '@/store/SpatialStore'
import type { ComputedRef } from 'vue'
import type { IndicatorsConf } from '../model/config'
import type {
Indicator,
+ IndicatorExtras,
+ IndicatorExtrasCalcul,
+ IndicatorExtrasSource,
IndicatorFilters,
+ IndicatorsExtrasApi,
IndicatorTag
} from '../model/indicator'
@@ -11,6 +16,8 @@ const indicatorsConf = config.indicators as IndicatorsConf
const tagPrefix = indicatorsConf.global_tag_prefix
const filters = indicatorsConf.filters
+export const UNFILLED_LABEL = 'Non renseigné'
+
interface QueryArgs extends IndicatorFilters {
[key: string]: string | null
}
@@ -37,29 +44,77 @@ export const useTagsQuery = (
/**
* Extract and denormalize tags from an indicator
*/
-export const useTags = (indicator: Indicator): ComputedRef
=> {
+export const useTags = (
+ indicator?: Indicator,
+ type?: string,
+ exclude?: string[]
+): ComputedRef => {
return computed(() => {
- return (
- indicator.tags
- ?.map((tag) => {
- if (tag.startsWith(tagPrefix)) {
- for (const filter of filters) {
- const filterPrefix = `${tagPrefix}-${filter.id}-`
- if (tag.startsWith(filterPrefix)) {
- const value = tag.replace(filterPrefix, '')
- const filterValue = filter.values.find((v) => v.id === value)
- if (filterValue) {
- return {
- color: filter.color,
- value: filterValue.name,
- type: filter.id
- }
- }
- }
- }
- }
- })
- .filter((v) => !!v) || []
- )
+ const tags: IndicatorTag[] = []
+
+ for (const tag of indicator?.tags || []) {
+ if (!tag.startsWith(tagPrefix)) continue
+
+ for (const filter of filters) {
+ if (type && type !== filter.id) continue
+ if (exclude?.includes(filter.id)) continue
+
+ const filterPrefix = `${tagPrefix}-${filter.id}-`
+ if (!tag.startsWith(filterPrefix)) continue
+
+ const value = tag.replace(filterPrefix, '')
+ const matchingValue = filter.values.find((v) => v.id === value)
+
+ if (matchingValue) {
+ tags.push({
+ color: filter.color,
+ value: matchingValue.name,
+ type: filter.id
+ })
+ }
+ }
+ }
+
+ return tags
})
}
+
+export const useIndicatorExtras = (indicator: Ref) => {
+ const unite: Ref = ref()
+ const mailles: Ref = ref([])
+ const axes: Ref> = ref({})
+ const calcul: Ref = ref()
+ const sources: Ref = ref([])
+ const api: Ref = ref()
+
+ const store = useSpatialStore()
+ store.loadLevels()
+
+ watch(
+ indicator,
+ () => {
+ const extras: IndicatorExtras =
+ indicator.value?.extras?.['ecospheres-indicateurs']
+ if (extras) {
+ unite.value = extras.unite
+ mailles.value = (extras.mailles_geographiques || [])
+ .map((m: string) => store.getLevelById(m)?.name)
+ .filter((v) => v !== undefined)
+ axes.value = extras.axes
+ calcul.value = extras.calcul
+ api.value = extras.api
+ sources.value = extras.sources
+ }
+ },
+ { immediate: true }
+ )
+
+ return {
+ unite,
+ mailles,
+ axes,
+ calcul,
+ api,
+ sources
+ }
+}
diff --git a/src/custom/ecospheres/views/HomeView.vue b/src/custom/ecospheres/views/HomeView.vue
index 7d29b86d8..e5284dcc2 100644
--- a/src/custom/ecospheres/views/HomeView.vue
+++ b/src/custom/ecospheres/views/HomeView.vue
@@ -63,7 +63,7 @@ const dropdown = config.website.header_search.dropdown
data.gouv.fr ou le renseignement d’un URL.