@cdc/dashboard 4.25.6 → 4.25.7-2
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/cdcdashboard.js +62631 -41608
- package/package.json +9 -9
- package/src/CdcDashboardComponent.tsx +11 -8
- package/src/components/DashboardFilters/DashboardFiltersEditor/DashboardFiltersEditor.tsx +286 -287
- package/src/components/Header/Header.tsx +2 -2
- package/src/components/VisualizationRow.tsx +324 -324
- package/src/helpers/getVizConfig.ts +12 -26
- package/src/helpers/getVizRowColumnLocator.ts +10 -10
- package/src/helpers/reloadURLHelpers.ts +124 -124
- package/src/store/dashboard.actions.ts +61 -62
- package/src/store/dashboard.reducer.ts +288 -288
- package/src/types/ConfigRow.ts +19 -19
- package/src/types/Dashboard.ts +11 -11
- package/examples/m2.json +0 -32904
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
import _ from 'lodash'
|
|
2
2
|
import { MultiDashboardConfig } from '../types/MultiDashboard'
|
|
3
3
|
import DataTransform from '@cdc/core/helpers/DataTransform'
|
|
4
|
-
import { getApplicableFilters } from './getFilteredData'
|
|
5
4
|
import { filterData } from './filterData'
|
|
6
5
|
import { AnyVisualization } from '@cdc/core/types/Visualization'
|
|
7
6
|
|
|
8
7
|
const transform = new DataTransform()
|
|
9
8
|
|
|
10
|
-
export const getFootnotesVizConfig = (
|
|
11
|
-
|
|
12
|
-
rowNumber: number,
|
|
13
|
-
config: MultiDashboardConfig
|
|
14
|
-
) => {
|
|
15
|
-
if (!visualizationConfig?.footnotes) return visualizationConfig
|
|
16
|
-
const data = _.cloneDeep(config.datasets[visualizationConfig.footnotes.dataKey]?.data)
|
|
17
|
-
const dataColumns = data?.length ? Object.keys(data[0]) : []
|
|
18
|
-
const filters = (getApplicableFilters(config.dashboard, rowNumber) || []).filter(filter =>
|
|
19
|
-
dataColumns.includes(filter.columnName)
|
|
20
|
-
)
|
|
9
|
+
export const getFootnotesVizConfig = (vizConfig: AnyVisualization, config: MultiDashboardConfig) => {
|
|
10
|
+
if (!vizConfig?.footnotes) return vizConfig
|
|
21
11
|
|
|
22
|
-
const
|
|
12
|
+
const data = config.datasets[vizConfig.footnotes.dataKey]?.data ?? []
|
|
23
13
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_.set(newConfig, 'footnotes.data', data)
|
|
28
|
-
}
|
|
14
|
+
const filters = config?.dashboard?.sharedFilters
|
|
15
|
+
if (filters.length === 0) return vizConfig
|
|
16
|
+
vizConfig.footnotes.data = filters.length ? filterData(filters, data) : data
|
|
29
17
|
|
|
30
|
-
return
|
|
18
|
+
return vizConfig
|
|
31
19
|
}
|
|
32
20
|
|
|
33
21
|
export const getVizConfig = (
|
|
@@ -43,7 +31,7 @@ export const getVizConfig = (
|
|
|
43
31
|
const visualizationConfig = _.cloneDeep(config.visualizations[visualizationKey])
|
|
44
32
|
const rowData = config.rows[rowNumber]
|
|
45
33
|
if (visualizationConfig.footnotes?.dataKey) {
|
|
46
|
-
|
|
34
|
+
visualizationConfig.footnotes.data = config.datasets[visualizationConfig.footnotes.dataKey]?.data
|
|
47
35
|
}
|
|
48
36
|
if (rowData?.dataKey) {
|
|
49
37
|
// data configured on the row
|
|
@@ -88,18 +76,16 @@ export const getVizConfig = (
|
|
|
88
76
|
|
|
89
77
|
if (filteredDataOverride) {
|
|
90
78
|
visualizationConfig.data = filteredDataOverride
|
|
91
|
-
|
|
92
|
-
visualizationConfig.formattedData = filteredDataOverride
|
|
93
|
-
}
|
|
79
|
+
visualizationConfig.formattedData = filteredDataOverride
|
|
94
80
|
}
|
|
81
|
+
|
|
95
82
|
if (visualizationConfig.footnotes) {
|
|
96
|
-
const visConfigWithFootnotes = getFootnotesVizConfig(visualizationConfig,
|
|
83
|
+
const visConfigWithFootnotes = getFootnotesVizConfig(visualizationConfig, config)
|
|
97
84
|
if (multiVizColumn && filteredDataOverride) {
|
|
98
85
|
const vizCategory = filteredDataOverride[0][multiVizColumn]
|
|
99
86
|
// the multiViz filtering filtering is applied after the dashboard filters
|
|
100
|
-
|
|
101
87
|
const categoryFootnote = visConfigWithFootnotes.footnotes.data.filter(d => d[multiVizColumn] === vizCategory)
|
|
102
|
-
|
|
88
|
+
visConfigWithFootnotes.footnotes.data = categoryFootnote
|
|
103
89
|
}
|
|
104
90
|
return visConfigWithFootnotes
|
|
105
91
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ConfigRow } from '../types/ConfigRow'
|
|
2
|
-
|
|
3
|
-
// returns a dictionary of widget names and their corresponding row and column index
|
|
4
|
-
export const getVizRowColumnLocator = (rows: ConfigRow[]): Record<string, { row: number; column: number }> =>
|
|
5
|
-
rows.reduce((acc, curr, index) => {
|
|
6
|
-
curr.columns?.forEach((column, columnIndex) => {
|
|
7
|
-
if (column.widget !== undefined) acc[column.widget] = { row: index, column: columnIndex }
|
|
8
|
-
})
|
|
9
|
-
return acc
|
|
10
|
-
}, {})
|
|
1
|
+
import { ConfigRow } from '../types/ConfigRow'
|
|
2
|
+
|
|
3
|
+
// returns a dictionary of widget names and their corresponding row and column index
|
|
4
|
+
export const getVizRowColumnLocator = (rows: ConfigRow[]): Record<string, { row: number; column: number }> =>
|
|
5
|
+
rows.reduce((acc, curr, index) => {
|
|
6
|
+
curr.columns?.forEach((column, columnIndex) => {
|
|
7
|
+
if (column.widget !== undefined) acc[column.widget] = { row: index, column: columnIndex }
|
|
8
|
+
})
|
|
9
|
+
return acc
|
|
10
|
+
}, {})
|
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import { gatherQueryParams } from '@cdc/core/helpers/gatherQueryParams'
|
|
2
|
-
import { SharedFilter } from '../types/SharedFilter'
|
|
3
|
-
import { capitalizeSplitAndJoin } from '@cdc/core/helpers/cove/string'
|
|
4
|
-
import { AnyVisualization, Visualization } from '@cdc/core/types/Visualization'
|
|
5
|
-
import _ from 'lodash'
|
|
6
|
-
import { DashboardConfig } from '../types/DashboardConfig'
|
|
7
|
-
import { ConfigRow } from '../types/ConfigRow'
|
|
8
|
-
import { getVizRowColumnLocator } from './getVizRowColumnLocator'
|
|
9
|
-
|
|
10
|
-
export const isUpdateNeeded = (
|
|
11
|
-
filters: SharedFilter[],
|
|
12
|
-
currentQueryParams: Record<string, string>,
|
|
13
|
-
newQueryParams: Record<string, string>
|
|
14
|
-
): boolean => {
|
|
15
|
-
let needsUpdate = false
|
|
16
|
-
filters.find(filter => {
|
|
17
|
-
if (filter.type === 'urlfilter' && !Array.isArray(filter.active) && filter.filterBy === 'File Name') {
|
|
18
|
-
needsUpdate = true
|
|
19
|
-
return true
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
Object.keys(newQueryParams).forEach(updatedParam => {
|
|
23
|
-
if (decodeURIComponent(newQueryParams[updatedParam]) !== currentQueryParams[updatedParam]) {
|
|
24
|
-
needsUpdate = true
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
return needsUpdate
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type GetDatasetKeysParams = Pick<DashboardConfig, 'visualizations' | 'datasets' | 'rows'>
|
|
31
|
-
export const getDatasetKeys = ({ visualizations, datasets, rows }: GetDatasetKeysParams): string[] => {
|
|
32
|
-
const vizDataKeys = Object.values(visualizations).map(viz => viz.dataKey)
|
|
33
|
-
const rowDataKeys = rows.map(row => row.dataKey)
|
|
34
|
-
const footnoteDataKeys = Object.values(visualizations)
|
|
35
|
-
.map(viz => viz.footnotes?.dataKey)
|
|
36
|
-
.filter(Boolean)
|
|
37
|
-
// ensure to only load datasets for the specific dashboard tab.
|
|
38
|
-
const datasetsUsedByDashboard = _.uniq([...vizDataKeys, ...rowDataKeys, ...footnoteDataKeys])
|
|
39
|
-
return Object.keys(datasets).filter(datasetKey => datasetsUsedByDashboard.includes(datasetKey))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const getDataURL = (updatedQSParams: Record<string, string | string[]>, dataUrl: URL, newFileName: string) => {
|
|
43
|
-
const _params = Object.keys(updatedQSParams).flatMap(key => {
|
|
44
|
-
const value = updatedQSParams[key]
|
|
45
|
-
if (value === undefined) return []
|
|
46
|
-
if (typeof value === 'string' && (value as String).match(/undefined/)) return []
|
|
47
|
-
if (Array.isArray(value)) return value.map(v => ({ key, value: v }))
|
|
48
|
-
return { key, value }
|
|
49
|
-
})
|
|
50
|
-
const baseURL = dataUrl.origin + dataUrl.pathname
|
|
51
|
-
let dataUrlFinal = `${baseURL}${gatherQueryParams(baseURL, _params)}`
|
|
52
|
-
|
|
53
|
-
if (newFileName !== '') {
|
|
54
|
-
const fileExtension = dataUrl.pathname.split('.').pop()
|
|
55
|
-
const pathWithoutFilename = dataUrl.pathname.substring(0, dataUrl.pathname.lastIndexOf('/'))
|
|
56
|
-
dataUrlFinal = `${dataUrl.origin}${pathWithoutFilename}/${newFileName}.${fileExtension}${gatherQueryParams(
|
|
57
|
-
baseURL,
|
|
58
|
-
_params
|
|
59
|
-
)}`
|
|
60
|
-
}
|
|
61
|
-
return dataUrlFinal
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const getNewFileName = (newFileName: string, filter: SharedFilter, datasetKey: string) => {
|
|
65
|
-
const replacements = {
|
|
66
|
-
'Remove Spaces': '',
|
|
67
|
-
'Keep Spaces': ' ',
|
|
68
|
-
'Replace With Underscore': '_'
|
|
69
|
-
}
|
|
70
|
-
let fileName = newFileName
|
|
71
|
-
if (filter.datasetKey === datasetKey) {
|
|
72
|
-
if (filter.fileName) {
|
|
73
|
-
// if a file name is found, ie, state_${query}, use that, ie. state_activeFilter.json
|
|
74
|
-
fileName = capitalizeSplitAndJoin.call(
|
|
75
|
-
String(filter.fileName),
|
|
76
|
-
' ',
|
|
77
|
-
replacements[filter.whitespaceReplacement ?? 'Keep Spaces']
|
|
78
|
-
)
|
|
79
|
-
} else {
|
|
80
|
-
// if no file name is entered use the default active filter. ie. /activeFilter.json
|
|
81
|
-
fileName = filter.active as string
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (fileName?.includes('${query}')) {
|
|
86
|
-
fileName = fileName.replace(
|
|
87
|
-
'${query}',
|
|
88
|
-
capitalizeSplitAndJoin.call(
|
|
89
|
-
String(filter.active),
|
|
90
|
-
' ',
|
|
91
|
-
replacements[filter.whitespaceReplacement ?? 'Keep Spaces']
|
|
92
|
-
)
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return fileName
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export const getVisualizationsWithFormattedData = (visualizations: Record<string, Visualization>, newData: Object) => {
|
|
100
|
-
return Object.keys(visualizations).reduce((acc, vizKey) => {
|
|
101
|
-
const dataKey = visualizations[vizKey].dataKey
|
|
102
|
-
if (newData[dataKey]) {
|
|
103
|
-
acc[vizKey].formattedData = newData[dataKey]
|
|
104
|
-
}
|
|
105
|
-
return acc
|
|
106
|
-
}, _.cloneDeep(visualizations))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export const filterUsedByDataUrl = (
|
|
110
|
-
filter: SharedFilter,
|
|
111
|
-
datasetKey: string,
|
|
112
|
-
visualizations: Record<string, AnyVisualization>,
|
|
113
|
-
rows: ConfigRow[]
|
|
114
|
-
) => {
|
|
115
|
-
if (!filter.usedBy || !filter.usedBy.length) return true
|
|
116
|
-
const vizUsingFilters = filter.usedBy?.map(vizOrRowKey => visualizations[vizOrRowKey] || rows[vizOrRowKey])
|
|
117
|
-
|
|
118
|
-
return vizUsingFilters?.some(viz => {
|
|
119
|
-
const usedByViz = viz?.dataKey === datasetKey
|
|
120
|
-
// datasetKey might be a key to a dynamic footnotes URL
|
|
121
|
-
const usedByVizFootnote = viz?.footnotes?.dataKey === datasetKey
|
|
122
|
-
return usedByViz || usedByVizFootnote
|
|
123
|
-
})
|
|
124
|
-
}
|
|
1
|
+
import { gatherQueryParams } from '@cdc/core/helpers/gatherQueryParams'
|
|
2
|
+
import { SharedFilter } from '../types/SharedFilter'
|
|
3
|
+
import { capitalizeSplitAndJoin } from '@cdc/core/helpers/cove/string'
|
|
4
|
+
import { AnyVisualization, Visualization } from '@cdc/core/types/Visualization'
|
|
5
|
+
import _ from 'lodash'
|
|
6
|
+
import { DashboardConfig } from '../types/DashboardConfig'
|
|
7
|
+
import { ConfigRow } from '../types/ConfigRow'
|
|
8
|
+
import { getVizRowColumnLocator } from './getVizRowColumnLocator'
|
|
9
|
+
|
|
10
|
+
export const isUpdateNeeded = (
|
|
11
|
+
filters: SharedFilter[],
|
|
12
|
+
currentQueryParams: Record<string, string>,
|
|
13
|
+
newQueryParams: Record<string, string>
|
|
14
|
+
): boolean => {
|
|
15
|
+
let needsUpdate = false
|
|
16
|
+
filters.find(filter => {
|
|
17
|
+
if (filter.type === 'urlfilter' && !Array.isArray(filter.active) && filter.filterBy === 'File Name') {
|
|
18
|
+
needsUpdate = true
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
Object.keys(newQueryParams).forEach(updatedParam => {
|
|
23
|
+
if (decodeURIComponent(newQueryParams[updatedParam]) !== currentQueryParams[updatedParam]) {
|
|
24
|
+
needsUpdate = true
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
return needsUpdate
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type GetDatasetKeysParams = Pick<DashboardConfig, 'visualizations' | 'datasets' | 'rows'>
|
|
31
|
+
export const getDatasetKeys = ({ visualizations, datasets, rows }: GetDatasetKeysParams): string[] => {
|
|
32
|
+
const vizDataKeys = Object.values(visualizations).map(viz => viz.dataKey)
|
|
33
|
+
const rowDataKeys = rows.map(row => row.dataKey)
|
|
34
|
+
const footnoteDataKeys = Object.values(visualizations)
|
|
35
|
+
.map(viz => viz.footnotes?.dataKey)
|
|
36
|
+
.filter(Boolean)
|
|
37
|
+
// ensure to only load datasets for the specific dashboard tab.
|
|
38
|
+
const datasetsUsedByDashboard = _.uniq([...vizDataKeys, ...rowDataKeys, ...footnoteDataKeys])
|
|
39
|
+
return Object.keys(datasets).filter(datasetKey => datasetsUsedByDashboard.includes(datasetKey))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const getDataURL = (updatedQSParams: Record<string, string | string[]>, dataUrl: URL, newFileName: string) => {
|
|
43
|
+
const _params = Object.keys(updatedQSParams).flatMap(key => {
|
|
44
|
+
const value = updatedQSParams[key]
|
|
45
|
+
if (value === undefined) return []
|
|
46
|
+
if (typeof value === 'string' && (value as String).match(/undefined/)) return []
|
|
47
|
+
if (Array.isArray(value)) return value.map(v => ({ key, value: v }))
|
|
48
|
+
return { key, value }
|
|
49
|
+
})
|
|
50
|
+
const baseURL = dataUrl.origin + dataUrl.pathname
|
|
51
|
+
let dataUrlFinal = `${baseURL}${gatherQueryParams(baseURL, _params)}`
|
|
52
|
+
|
|
53
|
+
if (newFileName !== '') {
|
|
54
|
+
const fileExtension = dataUrl.pathname.split('.').pop()
|
|
55
|
+
const pathWithoutFilename = dataUrl.pathname.substring(0, dataUrl.pathname.lastIndexOf('/'))
|
|
56
|
+
dataUrlFinal = `${dataUrl.origin}${pathWithoutFilename}/${newFileName}.${fileExtension}${gatherQueryParams(
|
|
57
|
+
baseURL,
|
|
58
|
+
_params
|
|
59
|
+
)}`
|
|
60
|
+
}
|
|
61
|
+
return dataUrlFinal
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const getNewFileName = (newFileName: string, filter: SharedFilter, datasetKey: string) => {
|
|
65
|
+
const replacements = {
|
|
66
|
+
'Remove Spaces': '',
|
|
67
|
+
'Keep Spaces': ' ',
|
|
68
|
+
'Replace With Underscore': '_'
|
|
69
|
+
}
|
|
70
|
+
let fileName = newFileName
|
|
71
|
+
if (filter.datasetKey === datasetKey) {
|
|
72
|
+
if (filter.fileName) {
|
|
73
|
+
// if a file name is found, ie, state_${query}, use that, ie. state_activeFilter.json
|
|
74
|
+
fileName = capitalizeSplitAndJoin.call(
|
|
75
|
+
String(filter.fileName),
|
|
76
|
+
' ',
|
|
77
|
+
replacements[filter.whitespaceReplacement ?? 'Keep Spaces']
|
|
78
|
+
)
|
|
79
|
+
} else {
|
|
80
|
+
// if no file name is entered use the default active filter. ie. /activeFilter.json
|
|
81
|
+
fileName = filter.active as string
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (fileName?.includes('${query}')) {
|
|
86
|
+
fileName = fileName.replace(
|
|
87
|
+
'${query}',
|
|
88
|
+
capitalizeSplitAndJoin.call(
|
|
89
|
+
String(filter.active),
|
|
90
|
+
' ',
|
|
91
|
+
replacements[filter.whitespaceReplacement ?? 'Keep Spaces']
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return fileName
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const getVisualizationsWithFormattedData = (visualizations: Record<string, Visualization>, newData: Object) => {
|
|
100
|
+
return Object.keys(visualizations).reduce((acc, vizKey) => {
|
|
101
|
+
const dataKey = visualizations[vizKey].dataKey
|
|
102
|
+
if (newData[dataKey]) {
|
|
103
|
+
acc[vizKey].formattedData = newData[dataKey]
|
|
104
|
+
}
|
|
105
|
+
return acc
|
|
106
|
+
}, _.cloneDeep(visualizations))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const filterUsedByDataUrl = (
|
|
110
|
+
filter: SharedFilter,
|
|
111
|
+
datasetKey: string,
|
|
112
|
+
visualizations: Record<string, AnyVisualization>,
|
|
113
|
+
rows: ConfigRow[]
|
|
114
|
+
) => {
|
|
115
|
+
if (!filter.usedBy || !filter.usedBy.length) return true
|
|
116
|
+
const vizUsingFilters = filter.usedBy?.map(vizOrRowKey => visualizations[vizOrRowKey] || rows[vizOrRowKey])
|
|
117
|
+
|
|
118
|
+
return vizUsingFilters?.some(viz => {
|
|
119
|
+
const usedByViz = viz?.dataKey === datasetKey
|
|
120
|
+
// datasetKey might be a key to a dynamic footnotes URL
|
|
121
|
+
const usedByVizFootnote = viz?.footnotes?.dataKey === datasetKey
|
|
122
|
+
return usedByViz || usedByVizFootnote
|
|
123
|
+
})
|
|
124
|
+
}
|
|
@@ -1,62 +1,61 @@
|
|
|
1
|
-
import type { DashboardConfig as Config } from '../types/DashboardConfig'
|
|
2
|
-
import { type Action } from '@cdc/core/types/Action'
|
|
3
|
-
import { Tab } from '../types/Tab'
|
|
4
|
-
import { ConfigRow } from '../types/ConfigRow'
|
|
5
|
-
import { AnyVisualization } from '@cdc/core/types/Visualization'
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
type
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
>
|
|
16
|
-
type
|
|
17
|
-
type
|
|
18
|
-
type
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
type
|
|
22
|
-
type
|
|
23
|
-
type
|
|
24
|
-
type
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
type
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
export default DashboardActions
|
|
1
|
+
import type { DashboardConfig as Config } from '../types/DashboardConfig'
|
|
2
|
+
import { type Action } from '@cdc/core/types/Action'
|
|
3
|
+
import { Tab } from '../types/Tab'
|
|
4
|
+
import { ConfigRow } from '../types/ConfigRow'
|
|
5
|
+
import { AnyVisualization } from '@cdc/core/types/Visualization'
|
|
6
|
+
import { SharedFilter } from '../types/SharedFilter'
|
|
7
|
+
|
|
8
|
+
type ADD_VISUALIZATION = Action<'ADD_VISUALIZATION', { rowIdx: number; colIdx: number; newViz: AnyVisualization }>
|
|
9
|
+
type APPLY_CONFIG = Action<'APPLY_CONFIG', [Config, Object?]>
|
|
10
|
+
type DELETE_WIDGET = Action<'DELETE_WIDGET', { uid: string }>
|
|
11
|
+
type MOVE_VISUALIZATION = Action<
|
|
12
|
+
'MOVE_VISUALIZATION',
|
|
13
|
+
{ rowIdx: number; colIdx: number; widget: AnyVisualization & { rowIdx: number; colIdx: number } }
|
|
14
|
+
>
|
|
15
|
+
type SET_CONFIG = Action<'SET_CONFIG', Partial<Config> & { activeDashboard?: number }>
|
|
16
|
+
type UPDATE_CONFIG = Action<'UPDATE_CONFIG', [Config, Object?]>
|
|
17
|
+
type SET_DATA = Action<'SET_DATA', Record<string, any[]>>
|
|
18
|
+
type SET_LOADING = Action<'SET_LOADING', boolean>
|
|
19
|
+
type SET_PREVIEW = Action<'SET_PREVIEW', boolean>
|
|
20
|
+
type SET_FILTERED_DATA = Action<'SET_FILTERED_DATA', Object>
|
|
21
|
+
type SET_SHARED_FILTERS = Action<'SET_SHARED_FILTERS', SharedFilter[]>
|
|
22
|
+
type SET_TAB_SELECTED = Action<'SET_TAB_SELECTED', Tab>
|
|
23
|
+
type RENAME_DASHBOARD_TAB = Action<'RENAME_DASHBOARD_TAB', { current: string; new: string }>
|
|
24
|
+
type INITIALIZE_MULTIDASHBOARDS = Action<'INITIALIZE_MULTIDASHBOARDS', undefined>
|
|
25
|
+
type REMOVE_MULTIDASHBOARD_AT_INDEX = Action<'REMOVE_MULTIDASHBOARD_AT_INDEX', number>
|
|
26
|
+
type REORDER_MULTIDASHBOARDS = Action<'REORDER_MULTIDASHBOARDS', { currentIndex: number; newIndex: number }>
|
|
27
|
+
type ADD_NEW_DASHBOARD = Action<'ADD_NEW_DASHBOARD', undefined>
|
|
28
|
+
type SAVE_CURRENT_CHANGES = Action<'SAVE_CURRENT_CHANGES', undefined>
|
|
29
|
+
type SWITCH_CONFIG = Action<'SWITCH_CONFIG', number>
|
|
30
|
+
type TOGGLE_ROW = Action<'TOGGLE_ROW', { rowIndex: number; colIndex: number }>
|
|
31
|
+
type RESET_VISUALIZATION = Action<'RESET_VISUALIZATION', { vizKey: string }>
|
|
32
|
+
type UPDATE_VISUALIZATION = Action<'UPDATE_VISUALIZATION', { vizKey: string; configureData: Partial<AnyVisualization> }>
|
|
33
|
+
type UPDATE_ROW = Action<'UPDATE_ROW', { rowIndex: number; rowData: Partial<ConfigRow> }>
|
|
34
|
+
type UPDATE_TOGGLE_NAME = Action<'UPDATE_TOGGLE_NAME', { rowIndex: number; columnIndex: number; toggleName: string }>
|
|
35
|
+
|
|
36
|
+
type DashboardActions =
|
|
37
|
+
| ADD_VISUALIZATION
|
|
38
|
+
| APPLY_CONFIG
|
|
39
|
+
| ADD_NEW_DASHBOARD
|
|
40
|
+
| DELETE_WIDGET
|
|
41
|
+
| MOVE_VISUALIZATION
|
|
42
|
+
| SET_CONFIG
|
|
43
|
+
| UPDATE_CONFIG
|
|
44
|
+
| REMOVE_MULTIDASHBOARD_AT_INDEX
|
|
45
|
+
| RENAME_DASHBOARD_TAB
|
|
46
|
+
| REORDER_MULTIDASHBOARDS
|
|
47
|
+
| SAVE_CURRENT_CHANGES
|
|
48
|
+
| SET_DATA
|
|
49
|
+
| SET_LOADING
|
|
50
|
+
| SET_PREVIEW
|
|
51
|
+
| SET_FILTERED_DATA
|
|
52
|
+
| SET_SHARED_FILTERS
|
|
53
|
+
| SET_TAB_SELECTED
|
|
54
|
+
| SWITCH_CONFIG
|
|
55
|
+
| INITIALIZE_MULTIDASHBOARDS
|
|
56
|
+
| TOGGLE_ROW
|
|
57
|
+
| RESET_VISUALIZATION
|
|
58
|
+
| UPDATE_VISUALIZATION
|
|
59
|
+
| UPDATE_ROW
|
|
60
|
+
| UPDATE_TOGGLE_NAME
|
|
61
|
+
export default DashboardActions
|