@geo2france/api-dashboard 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Charts/ChartComparison.d.ts +2 -2
- package/dist/components/Charts/ChartEvolution.d.ts +30 -0
- package/dist/components/Charts/ChartEvolution.js +71 -0
- package/dist/components/Charts/Datatable.d.ts +14 -0
- package/dist/components/Charts/Datatable.js +22 -0
- package/dist/components/Charts/Pie.d.ts +2 -2
- package/dist/components/Charts/Statistics.d.ts +3 -3
- package/dist/components/Charts/YearSerie.d.ts +2 -2
- package/dist/components/Control/Control.d.ts +5 -4
- package/dist/components/Control/Control.js +2 -5
- package/dist/components/Control/Select.d.ts +16 -6
- package/dist/components/Control/Select.js +3 -0
- package/dist/components/DashboardPage/Page.d.ts +9 -2
- package/dist/components/DashboardPage/Page.js +9 -4
- package/dist/components/DashboardPage/Section.d.ts +9 -4
- package/dist/components/DashboardPage/Section.js +3 -4
- package/dist/components/Dataset/Dataset.d.ts +15 -3
- package/dist/components/Dataset/Dataset.js +8 -6
- package/dist/components/Dataset/Filter.d.ts +0 -1
- package/dist/components/Dataset/hooks.d.ts +2 -2
- package/dist/dsl/index.d.ts +3 -1
- package/dist/dsl/index.js +3 -1
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EChartsOption } from "echarts";
|
|
2
|
-
import {
|
|
2
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
3
3
|
type labelType = "percent" | "value" | "category" | "none";
|
|
4
4
|
export interface ChartComparisonProps {
|
|
5
5
|
/** Identifiant du dataset */
|
|
6
|
-
dataset?:
|
|
6
|
+
dataset?: datasetInput;
|
|
7
7
|
/** Nom de la colonne qui contient les valeurs numériques */
|
|
8
8
|
valueKey: string;
|
|
9
9
|
/** Nom de la colonne qui contient les catégories */
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EChartsOption } from "echarts";
|
|
2
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
3
|
+
export interface ChartEvolutionProps {
|
|
4
|
+
/** Identifiant du dataset */
|
|
5
|
+
dataset?: datasetInput;
|
|
6
|
+
/** Nom de la colonne qui contient les valeurs numériques */
|
|
7
|
+
valueKey: string;
|
|
8
|
+
/** Nom de la colonne qui contient les catégories */
|
|
9
|
+
nameKey?: string;
|
|
10
|
+
/** Colonne qui contient la date ou année */
|
|
11
|
+
timeKey: string;
|
|
12
|
+
/** Type de graphique */
|
|
13
|
+
chartType?: 'bar' | 'line' | 'area';
|
|
14
|
+
/** Unité à afficher */
|
|
15
|
+
unit?: string;
|
|
16
|
+
/** Titre du graphique */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Empiler les valeurs ? */
|
|
19
|
+
stack?: boolean;
|
|
20
|
+
/** Afficher un marquer sur la ligne de temps */
|
|
21
|
+
timeMarker?: number | string;
|
|
22
|
+
/** Options suplémentaires passées à Echarts
|
|
23
|
+
* https://echarts.apache.org/en/option.html
|
|
24
|
+
*/
|
|
25
|
+
option?: EChartsOption;
|
|
26
|
+
}
|
|
27
|
+
/** Composant de visualisation permettant de montrer l'évolution d'une valeur au cours du temps.
|
|
28
|
+
* La valeur peut-être décomposée en plusieurs catégories
|
|
29
|
+
*/
|
|
30
|
+
export declare const ChartEvolution: React.FC<ChartEvolutionProps>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { from, op } from "arquero";
|
|
3
|
+
import deepMerge from "../../utils/deepmerge";
|
|
4
|
+
import { useBlockConfig } from "../DashboardPage/Block";
|
|
5
|
+
import { ChartEcharts, useDataset } from "../../dsl";
|
|
6
|
+
/** Composant de visualisation permettant de montrer l'évolution d'une valeur au cours du temps.
|
|
7
|
+
* La valeur peut-être décomposée en plusieurs catégories
|
|
8
|
+
*/
|
|
9
|
+
export const ChartEvolution = ({ dataset: dataset_id, title, nameKey, timeKey, valueKey, chartType = 'bar', stack: stack_in, timeMarker, unit, option: custom_option = {} }) => {
|
|
10
|
+
const dataset = useDataset(dataset_id);
|
|
11
|
+
const data = dataset?.data;
|
|
12
|
+
useBlockConfig({
|
|
13
|
+
title: title,
|
|
14
|
+
dataExport: data
|
|
15
|
+
});
|
|
16
|
+
// Devnote : ajouter une propriété "timePrecision" ? (year, month, day, etc..)
|
|
17
|
+
// Ceci pourrait permettre aussi d'aggréger les données selon la précision souhaité
|
|
18
|
+
const first_time = data?.[0]?.[timeKey];
|
|
19
|
+
const yearMode = (typeof first_time === 'number' || isNaN(Number(first_time)) == false);
|
|
20
|
+
const stack = stack_in ?? (chartType !== 'line');
|
|
21
|
+
const chart_data1 = data && data.length > 0
|
|
22
|
+
? from(data.filter(e => e[valueKey]))
|
|
23
|
+
.groupby(nameKey ? [nameKey, timeKey] : timeKey)
|
|
24
|
+
.rollup({ value: op.sum(valueKey) })
|
|
25
|
+
.orderby(timeKey)
|
|
26
|
+
.objects()
|
|
27
|
+
.map((d) => ([
|
|
28
|
+
String(d[timeKey]),
|
|
29
|
+
d.value,
|
|
30
|
+
nameKey ? d[nameKey] : valueKey // Si pas de dimension "cat", on utilise le nom la colonne de valeur
|
|
31
|
+
]))
|
|
32
|
+
: [];
|
|
33
|
+
const cat = nameKey ?
|
|
34
|
+
data?.length ? from(data).select(nameKey).dedupe().array(nameKey) : undefined
|
|
35
|
+
: [valueKey]; // Nom de la série unique
|
|
36
|
+
const series = cat?.map((c, idx) => ({
|
|
37
|
+
type: chartType === "area" ? 'line' : chartType,
|
|
38
|
+
name: c,
|
|
39
|
+
data: chart_data1.filter(row => row[2] == c),
|
|
40
|
+
stack: stack ? 'total' : undefined,
|
|
41
|
+
connectNulls: true,
|
|
42
|
+
areaStyle: chartType === 'area' ? {} : undefined,
|
|
43
|
+
symbolSize: chartType === 'area' ? 2 : chartType === 'line' ? 4 : undefined,
|
|
44
|
+
markLine: idx === 0 && timeMarker ? {
|
|
45
|
+
symbol: 'none',
|
|
46
|
+
animation: false,
|
|
47
|
+
silent: true,
|
|
48
|
+
data: [
|
|
49
|
+
{ xAxis: String(timeMarker) }
|
|
50
|
+
]
|
|
51
|
+
} : undefined,
|
|
52
|
+
})) || [];
|
|
53
|
+
const option = {
|
|
54
|
+
legend: {
|
|
55
|
+
show: true,
|
|
56
|
+
},
|
|
57
|
+
tooltip: {
|
|
58
|
+
show: true,
|
|
59
|
+
trigger: 'axis',
|
|
60
|
+
axisPointer: {
|
|
61
|
+
// N'afficher que l'année (au lieu de la date du 1er janvier)
|
|
62
|
+
label: { formatter: yearMode ? (p) => String(new Date(p.value).getUTCFullYear()) ?? `` : undefined }
|
|
63
|
+
},
|
|
64
|
+
valueFormatter: (v) => `${v?.toLocaleString(undefined, { maximumFractionDigits: 0 })} ${unit ?? ''}`
|
|
65
|
+
},
|
|
66
|
+
yAxis: { show: true, type: 'value' },
|
|
67
|
+
xAxis: { show: true, type: 'time' },
|
|
68
|
+
series: series,
|
|
69
|
+
};
|
|
70
|
+
return _jsx(ChartEcharts, { notMerge: true, option: deepMerge(option, custom_option) });
|
|
71
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
2
|
+
export interface DataTableProps {
|
|
3
|
+
/** Jeu de données */
|
|
4
|
+
dataset: datasetInput;
|
|
5
|
+
/** Titre du composant */
|
|
6
|
+
title?: string;
|
|
7
|
+
/** Nombre d'éléments par page */
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
/** Style CSS du tableau */
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}
|
|
12
|
+
/** Afficher un dataset sous forme de tableau
|
|
13
|
+
*/
|
|
14
|
+
export declare const DataTable: React.FC<DataTableProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Table } from "antd";
|
|
3
|
+
import { useDataset } from "../Dataset/hooks";
|
|
4
|
+
import { useBlockConfig } from "../DashboardPage/Block";
|
|
5
|
+
/** Afficher un dataset sous forme de tableau
|
|
6
|
+
*/
|
|
7
|
+
export const DataTable = ({ dataset: dataset_id, title, pageSize = 5, style }) => {
|
|
8
|
+
const dataset = useDataset(dataset_id); //Récupérer le jeu de données
|
|
9
|
+
const data = dataset?.data;
|
|
10
|
+
useBlockConfig({
|
|
11
|
+
title: title,
|
|
12
|
+
dataExport: data
|
|
13
|
+
});
|
|
14
|
+
const cols = Object.keys(data?.[0] || {})?.map((k) => ({
|
|
15
|
+
dataIndex: k,
|
|
16
|
+
title: k,
|
|
17
|
+
ellipsis: true,
|
|
18
|
+
key: k,
|
|
19
|
+
render: (v) => typeof v === 'number' ? isNaN(v) ? '' : v.toLocaleString() : v,
|
|
20
|
+
}));
|
|
21
|
+
return _jsx(Table, { columns: cols, style: style, className: "data-table", dataSource: Array.isArray(data) ? data?.map((r, idx) => ({ ...r, key: idx })) : [], pagination: { pageSize: pageSize } });
|
|
22
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
2
2
|
import { EChartsOption, LabelFormatterCallback } from "echarts";
|
|
3
3
|
import type { CallbackDataParams } from 'echarts/types/dist/shared';
|
|
4
4
|
export interface IChartPieProps {
|
|
5
5
|
/** Identifiant du dataset */
|
|
6
|
-
dataset?:
|
|
6
|
+
dataset?: datasetInput;
|
|
7
7
|
/** Nom de la colonne qui contient les valeurs numériques */
|
|
8
8
|
dataKey: string;
|
|
9
9
|
/** Nom de la colonne qui contient les catégories */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
3
3
|
import { SimpleRecord } from "../../types";
|
|
4
4
|
type comparwithType = "first" | "previous";
|
|
5
5
|
type aggregateType = "last" | "first" | "sum" | "lastNotNull" | "min" | "max" | "count" | "mean" | "countDistinct" | "countMissing";
|
|
@@ -15,7 +15,7 @@ interface ICallbackParams {
|
|
|
15
15
|
}
|
|
16
16
|
export interface StatisticsProps {
|
|
17
17
|
/** Identifiant du jeu de données ou tableau de valeurs */
|
|
18
|
-
dataset:
|
|
18
|
+
dataset: datasetInput;
|
|
19
19
|
/** Nom de la colonne qui contient les valeurs */
|
|
20
20
|
dataKey: string;
|
|
21
21
|
/** Texte à afficher après l'évolution */
|
|
@@ -31,7 +31,7 @@ export interface StatisticsProps {
|
|
|
31
31
|
/** Inverser les couleurs (rouge/vert) de l'évolution */
|
|
32
32
|
invertColor?: boolean;
|
|
33
33
|
/** Icône. Composant ou nom de l'icône sur https://icon-sets.iconify.design/ */
|
|
34
|
-
icon?:
|
|
34
|
+
icon?: React.ReactNode | string;
|
|
35
35
|
/** Texte à afficher dans le tooltip d'aide */
|
|
36
36
|
help?: string;
|
|
37
37
|
/** Comparer la valeur avec la précédente ou la première du jeu de données */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Graphique standard pour afficher des données annuelles
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { datasetInput } from "../Dataset/hooks";
|
|
5
5
|
import { EChartsOption, SeriesOption } from "echarts";
|
|
6
6
|
export interface IYearSerieProps {
|
|
7
|
-
dataset:
|
|
7
|
+
dataset: datasetInput;
|
|
8
8
|
title?: string;
|
|
9
9
|
yearKey: string;
|
|
10
10
|
valueKey: string;
|
|
@@ -7,13 +7,14 @@ declare const Control: React.FC<IControlProps>;
|
|
|
7
7
|
export default Control;
|
|
8
8
|
export declare const useControl: (name: string) => string | undefined;
|
|
9
9
|
export declare const useAllControls: () => Record<string, any>;
|
|
10
|
-
export declare const list_to_options: (input?: string[] | {
|
|
10
|
+
export declare const list_to_options: (input?: string[] | number[] | {
|
|
11
11
|
label: string;
|
|
12
|
-
value: string;
|
|
13
|
-
}[]) => {
|
|
12
|
+
value: string | number;
|
|
13
|
+
}[]) => ({
|
|
14
14
|
label: string;
|
|
15
15
|
value: string;
|
|
16
|
-
}[];
|
|
16
|
+
}[]);
|
|
17
|
+
export type ListToOptionsInput = Parameters<typeof list_to_options>[0];
|
|
17
18
|
interface IControlProps {
|
|
18
19
|
children: ReactElement | ReactElement[];
|
|
19
20
|
}
|
|
@@ -44,14 +44,11 @@ export const useAllControls = () => {
|
|
|
44
44
|
};
|
|
45
45
|
/* Convenient function to return Options from list or Options */
|
|
46
46
|
export const list_to_options = (input = []) => {
|
|
47
|
-
if (input === undefined) {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
47
|
return input.map((o) => {
|
|
51
|
-
if (typeof o == "string") {
|
|
48
|
+
if (typeof o == "string" || typeof o == "number") {
|
|
52
49
|
return { label: String(o), value: String(o) };
|
|
53
50
|
}
|
|
54
|
-
return o;
|
|
51
|
+
return { label: String(o.label), value: String(o.value) };
|
|
55
52
|
});
|
|
56
53
|
};
|
|
57
54
|
export const DSL_Control = ({ children }) => {
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import type { SelectProps } from 'antd';
|
|
2
|
+
import { ListToOptionsInput } from './Control';
|
|
2
3
|
type ExtendedSelectProps = Omit<SelectProps<any>, 'options'> & {
|
|
4
|
+
/** Nom technique du controle */
|
|
5
|
+
name?: string;
|
|
6
|
+
/** Nom à afficher */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Jeu de données contenant les choix (à la place de options) */
|
|
3
9
|
dataset?: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}[] | string[];
|
|
10
|
+
/** Choix possibles */
|
|
11
|
+
options?: ListToOptionsInput;
|
|
12
|
+
/** Valeur intiale sélectionnée */
|
|
8
13
|
initial_value?: string;
|
|
14
|
+
/** Colonne à utiliser pour le libellé (si dataset utilisé) */
|
|
9
15
|
labelField?: string;
|
|
16
|
+
/** Colonne à utiliser pour la valeur (si dataset utilisé) */
|
|
10
17
|
valueField?: string;
|
|
11
|
-
|
|
12
|
-
label?: string;
|
|
18
|
+
/** Affichage des flèches Suivant/Précédent */
|
|
13
19
|
arrows?: boolean;
|
|
20
|
+
/** Inverser le sens des flêches */
|
|
14
21
|
reverse?: boolean;
|
|
15
22
|
};
|
|
23
|
+
/** Composant de controle permettant de choisir une valeur parmis une liste de choix.
|
|
24
|
+
* Adapté pour les choix de territoires ou d'années
|
|
25
|
+
*/
|
|
16
26
|
export declare const Select: React.FC<ExtendedSelectProps>;
|
|
17
27
|
export {};
|
|
@@ -5,6 +5,9 @@ import NextPrevSelect from '../NextPrevSelect/NextPrevSelect';
|
|
|
5
5
|
import { list_to_options } from './Control';
|
|
6
6
|
// TODO : a fusionner avec NextPrevSelect pour n'avoir qu'un seul composant
|
|
7
7
|
// Actuellement, Select apporte seulement le fait de choisir les valeurs depuis un
|
|
8
|
+
/** Composant de controle permettant de choisir une valeur parmis une liste de choix.
|
|
9
|
+
* Adapté pour les choix de territoires ou d'années
|
|
10
|
+
*/
|
|
8
11
|
export const Select = ({ name, dataset: datasetSource, options: input_options = [], labelField = 'label', valueField = 'value', arrows = false, reverse = false, label, initial_value: initial_value_in, ...rest }) => {
|
|
9
12
|
const options = list_to_options(input_options);
|
|
10
13
|
const data = useDataset(datasetSource)?.data;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RowProps } from "antd";
|
|
2
2
|
import DashboardElement from "../DashboardElement/DashboardElement";
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { ReactNode } from "react";
|
|
4
4
|
import { Section } from "./Section";
|
|
5
5
|
type Section = {
|
|
6
6
|
key: string;
|
|
@@ -18,9 +18,16 @@ interface IDashboardPageProps {
|
|
|
18
18
|
declare const DashboardPage: React.FC<IDashboardPageProps>;
|
|
19
19
|
export default DashboardPage;
|
|
20
20
|
interface IDSLDashboardPageProps {
|
|
21
|
-
|
|
21
|
+
/** Composants visibles (dataviz, carto) ou logiques (dataset, palette) */
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/** Nom de la page (titre). */
|
|
22
24
|
name?: string;
|
|
25
|
+
/** Nombre de colonnes. */
|
|
23
26
|
columns?: number;
|
|
27
|
+
/** Mode debug. Affiche un bouton permettant d'accéder aux informations développeur. */
|
|
24
28
|
debug?: boolean;
|
|
25
29
|
}
|
|
30
|
+
/** Une page de tableau de bord.
|
|
31
|
+
* Cette page peut contenir plusieurs `Section` ou directement le contenu.
|
|
32
|
+
*/
|
|
26
33
|
export declare const DSL_DashboardPage: React.FC<IDSLDashboardPageProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Col, Dropdown, Flex, Grid, Layout, Radio, Row, Tabs, theme } from "antd";
|
|
2
|
+
import { Button, Col, Dropdown, Empty, Flex, Grid, Layout, Radio, Row, Tabs, theme } from "antd";
|
|
3
3
|
import React, { isValidElement, useState, useEffect, useContext } from "react";
|
|
4
4
|
import { Helmet } from "react-helmet-async";
|
|
5
5
|
import { useSearchParamsState } from "../../utils/useSearchParamsState";
|
|
@@ -41,6 +41,9 @@ const DashboardPage = ({ children: children_input, control, row_gutter = [8, 8],
|
|
|
41
41
|
})), value: activeTab, onChange: (e) => setActiveTab(e.target.value) }), control] }) }), _jsx(Row, { gutter: row_gutter, style: { margin: 16 }, children: children.map((child, idx) => ({ child, idx })).filter(({ child }) => (getSection(child) ?? 'Autres') == activeTab).map(({ child, idx }) => _jsx(Col, { xl: 12, xs: 24, children: child }, idx)) })] }));
|
|
42
42
|
};
|
|
43
43
|
export default DashboardPage;
|
|
44
|
+
/** Une page de tableau de bord.
|
|
45
|
+
* Cette page peut contenir plusieurs `Section` ou directement le contenu.
|
|
46
|
+
*/
|
|
44
47
|
export const DSL_DashboardPage = ({ name = 'Tableau de bord', columns = 2, children, debug = false }) => {
|
|
45
48
|
const { token } = useToken();
|
|
46
49
|
const [palette, setPalette] = useState(DEFAULT_PALETTE);
|
|
@@ -91,7 +94,7 @@ export const DSL_DashboardPage = ({ name = 'Tableau de bord', columns = 2, child
|
|
|
91
94
|
items.push({
|
|
92
95
|
key: "99 - Autres",
|
|
93
96
|
label: '-',
|
|
94
|
-
children: _jsx(Section, { title: 'Autres', children: visible_components })
|
|
97
|
+
children: _jsx(Section, { title: 'Autres', columns: columns, children: visible_components })
|
|
95
98
|
});
|
|
96
99
|
}
|
|
97
100
|
return (_jsxs(_Fragment, { children: [_jsx(Helmet, { children: _jsx("title", { children: name }) }), _jsxs(PaletteContext.Provider, { value: { palette, setPalette }, children: [control_components.length > 0 && _jsx(Header, { style: {
|
|
@@ -108,6 +111,8 @@ export const DSL_DashboardPage = ({ name = 'Tableau de bord', columns = 2, child
|
|
|
108
111
|
background: token.colorBgContainer,
|
|
109
112
|
borderRadius: token.borderRadiusLG }, style: { margin: 4 } })
|
|
110
113
|
:
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
items.length == 1 ?
|
|
115
|
+
_jsxs("div", { style: { margin: 4 }, children: [" ", items?.[0].children, " "] }) //Show content without tabs if only one
|
|
116
|
+
: //no visible content
|
|
117
|
+
_jsx(Flex, { align: "center", justify: "center", style: { height: "100%" }, children: _jsx(Empty, { description: "Ce tableau de bord est vide pour le moment.", image: _jsx(Icon, { icon: "solar:sleeping-circle-bold", height: 55, color: token.colorIcon }) }) }), logic_components, intro_component] })] }));
|
|
113
118
|
};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
2
|
export interface SectionProps {
|
|
3
|
+
/** Titre de la section, doit être unique */
|
|
3
4
|
title: string;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/** Composants visibles (dataviz, carto) ou logiques (dataset, palette) */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** Icone de la section. Composant ou nom (iconify) de l'icon */
|
|
8
|
+
icon?: ReactNode | string;
|
|
9
|
+
/** Nombre de colonnes. */
|
|
10
|
+
columns?: number;
|
|
6
11
|
}
|
|
7
|
-
export declare const Section:
|
|
12
|
+
export declare const Section: FC<SectionProps>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Col, Row } from "antd";
|
|
3
|
-
import
|
|
3
|
+
import { Children, isValidElement } from "react";
|
|
4
4
|
import { DSL_ChartBlock } from "./Block";
|
|
5
|
-
export const Section = ({ children }) => {
|
|
6
|
-
const
|
|
7
|
-
const childrenArray = React.Children.toArray(children).filter(isValidElement);
|
|
5
|
+
export const Section = ({ children, columns = 2 }) => {
|
|
6
|
+
const childrenArray = Children.toArray(children).filter(isValidElement);
|
|
8
7
|
return (_jsx(Row, { gutter: [8, 8], style: { margin: 0 }, children: childrenArray.map((component, idx) => (_jsx(Col, { xl: 24 / columns, xs: 24, children: _jsx(DSL_ChartBlock, { children: component }) }, idx))) }));
|
|
9
8
|
};
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { SimpleRecord } from "../..";
|
|
3
|
-
import { CrudFilters
|
|
3
|
+
import { CrudFilters } from "../../data_providers/types";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import { ProviderType } from "./Provider";
|
|
6
6
|
interface IDatasetProps {
|
|
7
|
+
/**Identifiant interne unique du jeu de données*/
|
|
7
8
|
id: string;
|
|
8
|
-
|
|
9
|
+
/** Url du fournisseur */
|
|
9
10
|
url?: string;
|
|
10
|
-
|
|
11
|
+
/** Type de fournisseur */
|
|
12
|
+
type: ProviderType;
|
|
13
|
+
/** Nom de la ressource côté fournisseur
|
|
14
|
+
* (couche, dataset, fichier, etc.)
|
|
15
|
+
*/
|
|
11
16
|
resource: string;
|
|
17
|
+
/**
|
|
18
|
+
* ⚠️ deprecated
|
|
19
|
+
*/
|
|
12
20
|
filters?: CrudFilters;
|
|
13
21
|
children?: ReactNode;
|
|
14
22
|
pageSize?: number;
|
|
23
|
+
/** Paramètres additionnels à passer au fournisseur */
|
|
15
24
|
meta?: any;
|
|
16
25
|
}
|
|
17
26
|
export type dataset = {
|
|
@@ -24,5 +33,8 @@ export type dataset = {
|
|
|
24
33
|
geojson?: any;
|
|
25
34
|
dataHash?: number;
|
|
26
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* Composant **logique** permettant de récupérer des données.
|
|
38
|
+
*/
|
|
27
39
|
export declare const DSL_Dataset: React.FC<IDatasetProps>;
|
|
28
40
|
export {};
|
|
@@ -3,14 +3,17 @@ import { useContext, useEffect } from "react";
|
|
|
3
3
|
import { useApi } from "../..";
|
|
4
4
|
import { Producer } from "./Producer";
|
|
5
5
|
import React from "react";
|
|
6
|
-
import { Filter, Transform,
|
|
6
|
+
import { Filter, Transform, useAllDatasets, useDatasets } from "../../dsl";
|
|
7
7
|
import alasql from "alasql";
|
|
8
8
|
import { DataProviderContext, getProviderFromType } from "./Provider";
|
|
9
9
|
import { Join } from "./Join";
|
|
10
10
|
import { from } from "arquero";
|
|
11
11
|
import hashCode from "../../utils/hash_data";
|
|
12
12
|
import { DatasetRegistryContext } from "./context";
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Composant **logique** permettant de récupérer des données.
|
|
15
|
+
*/
|
|
16
|
+
export const DSL_Dataset = ({ children, id, type: providerType, url: providerUrl, resource, pageSize, meta }) => {
|
|
14
17
|
const getTransformerFn = (component) => {
|
|
15
18
|
/*
|
|
16
19
|
* Génére une fonction transformer soit
|
|
@@ -57,18 +60,17 @@ export const DSL_Dataset = ({ children, id, provider: provider_input, type: prov
|
|
|
57
60
|
};
|
|
58
61
|
const datasetRegistryContext = useContext(DatasetRegistryContext);
|
|
59
62
|
const allDatasets = useAllDatasets();
|
|
60
|
-
const controls = useAllControls();
|
|
61
63
|
const providerContext = useContext(DataProviderContext);
|
|
62
|
-
const provider = (providerUrl && getProviderFromType(providerType)(providerUrl)) || providerContext
|
|
64
|
+
const provider = (providerUrl && getProviderFromType(providerType)(providerUrl)) || providerContext;
|
|
63
65
|
if (provider === undefined) {
|
|
64
|
-
throw new Error("Error : No dataProvider, please use
|
|
66
|
+
throw new Error("Error : No dataProvider, please use providerUrl/providerType properties");
|
|
65
67
|
}
|
|
66
68
|
/* Récupérer les props des filtres depuis les composants enfant Filter */
|
|
67
69
|
const filters = [];
|
|
68
70
|
React.Children.toArray(children)
|
|
69
71
|
.filter((c) => React.isValidElement(c))
|
|
70
72
|
.filter((c) => typeof c.type != 'string' && c.type.name == Filter.name).forEach((c) => {
|
|
71
|
-
const value = (typeof c.props.children === "string" ? c.props.children.trim() : c.props.children)
|
|
73
|
+
const value = (typeof c.props.children === "string" ? c.props.children.trim() : c.props.children);
|
|
72
74
|
filters.push({
|
|
73
75
|
operator: c.props.operator || 'eq',
|
|
74
76
|
value: value,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dataset } from "./Dataset";
|
|
2
2
|
import { SimpleRecord } from "../..";
|
|
3
|
-
export type
|
|
4
|
-
export declare const useDataset: (dataset_id?:
|
|
3
|
+
export type datasetInput = string | SimpleRecord[];
|
|
4
|
+
export declare const useDataset: (dataset_id?: datasetInput) => dataset | undefined;
|
|
5
5
|
export declare const useAllDatasets: () => dataset[];
|
|
6
6
|
export declare const useDatasets: (dataset_ids?: string[]) => dataset[];
|
|
7
7
|
/**
|
package/dist/dsl/index.d.ts
CHANGED
|
@@ -23,4 +23,6 @@ import { Section } from "../components/DashboardPage/Section";
|
|
|
23
23
|
import { LegendControl } from "../components/MapLegend/MapLegend";
|
|
24
24
|
import { Intro } from "../components/DashboardPage/Intro";
|
|
25
25
|
import { ChartComparison } from "../components/Charts/ChartComparison";
|
|
26
|
-
|
|
26
|
+
import { DataTable } from "../components/Charts/Datatable";
|
|
27
|
+
import { ChartEvolution } from "../components/Charts/ChartEvolution";
|
|
28
|
+
export { Dashboard, Dataset, Provider, Transform, Join, Filter, Section, Intro, DataPreview, ChartEcharts, ChartPie, ChartYearSerie, ChartComparison, ChartEvolution, DataTable, Statistics, StatisticsCollection, useDataset, useDatasets, useAllDatasets, useBlockConfig, Producer, Control, useControl, useAllControls, Radio, Select, Input, Palette, usePalette, usePaletteLabels, PalettePreview, Debug, Map, MapLayer, LegendControl };
|
package/dist/dsl/index.js
CHANGED
|
@@ -23,4 +23,6 @@ import { Section } from "../components/DashboardPage/Section";
|
|
|
23
23
|
import { LegendControl } from "../components/MapLegend/MapLegend";
|
|
24
24
|
import { Intro } from "../components/DashboardPage/Intro";
|
|
25
25
|
import { ChartComparison } from "../components/Charts/ChartComparison";
|
|
26
|
-
|
|
26
|
+
import { DataTable } from "../components/Charts/Datatable";
|
|
27
|
+
import { ChartEvolution } from "../components/Charts/ChartEvolution";
|
|
28
|
+
export { Dashboard, Dataset, Provider, Transform, Join, Filter, Section, Intro, DataPreview, ChartEcharts, ChartPie, ChartYearSerie, ChartComparison, ChartEvolution, DataTable, Statistics, StatisticsCollection, useDataset, useDatasets, useAllDatasets, useBlockConfig, Producer, Control, useControl, useAllControls, Radio, Select, Input, Palette, usePalette, usePaletteLabels, PalettePreview, Debug, Map, MapLayer, LegendControl };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,5 +28,6 @@ export { WfsProvider, DatafairProvider, FileProvider };
|
|
|
28
28
|
export type { SimpleRecord, Partner, RouteConfig } from "./types";
|
|
29
29
|
export type { LegendItem } from "./components/MapLegend/MapLegend";
|
|
30
30
|
export type { DashboardConfig } from "./components/Layout/DashboardApp";
|
|
31
|
+
export type { datasetInput } from "./components/Dataset/hooks";
|
|
31
32
|
import * as DSL from './dsl';
|
|
32
33
|
export { DSL };
|