@cdc/dashboard 4.23.11 → 4.24.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 +109007 -98738
- package/examples/DEV-6574.json +2224 -0
- package/examples/filters/Alabama.json +72 -0
- package/examples/filters/Alaska.json +1737 -0
- package/examples/filters/Arkansas.json +4713 -0
- package/examples/filters/California.json +212 -0
- package/examples/filters/Colorado.json +1500 -0
- package/examples/filters/Connecticut.json +559 -0
- package/examples/filters/Delaware.json +63 -0
- package/examples/filters/DistrictofColumbia.json +63 -0
- package/examples/filters/Florida.json +4217 -0
- package/examples/filters/States.json +146 -0
- package/examples/test.json +752 -0
- package/examples/zika.json +2274 -0
- package/index.html +5 -3
- package/package.json +9 -9
- package/src/CdcDashboard.tsx +124 -963
- package/src/CdcDashboardComponent.tsx +903 -0
- package/src/_stories/Dashboard.stories.tsx +2 -2
- package/src/components/Column.tsx +15 -12
- package/src/components/Header/Header.tsx +694 -0
- package/src/components/Header/index.tsx +1 -676
- package/src/components/MultiConfigTabs/MultiConfigTabs.tsx +106 -0
- package/src/components/MultiConfigTabs/MultiTabs.tsx +30 -0
- package/src/components/MultiConfigTabs/index.tsx +8 -0
- package/src/components/MultiConfigTabs/multiconfigtabs.styles.css +32 -0
- package/src/components/Widget.tsx +25 -9
- package/src/helpers/filterData.ts +73 -73
- package/src/helpers/generateValuesForFilter.ts +25 -29
- package/src/helpers/getUpdateConfig.ts +6 -2
- package/src/helpers/processData.ts +13 -0
- package/src/helpers/processDataLegacy.ts +14 -0
- package/src/{index.jsx → index.tsx} +2 -2
- package/src/scss/editor-panel.scss +14 -11
- package/src/scss/grid.scss +4 -6
- package/src/scss/main.scss +2 -8
- package/src/store/dashboard.actions.ts +10 -4
- package/src/store/dashboard.reducer.ts +74 -3
- package/src/types/ConfigRow.ts +6 -0
- package/src/types/Dashboard.ts +11 -0
- package/src/types/DashboardConfig.ts +23 -0
- package/src/types/InitialState.ts +10 -0
- package/src/types/MultiDashboard.ts +11 -0
- package/src/types/SharedFilter.ts +31 -20
- package/src/types/Config.ts +0 -27
|
@@ -1,17 +1,40 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
1
2
|
import { getUpdateConfig } from '../helpers/getUpdateConfig'
|
|
2
|
-
import {
|
|
3
|
+
import { MultiDashboardConfig } from '../types/MultiDashboard'
|
|
3
4
|
import DashboardActions from './dashboard.actions'
|
|
5
|
+
import { devToolsWrapper } from '@cdc/core/helpers/withDevTools'
|
|
6
|
+
|
|
7
|
+
const createBlankDashboard = () => ({
|
|
8
|
+
dashboard: {
|
|
9
|
+
theme: 'theme-blue'
|
|
10
|
+
},
|
|
11
|
+
rows: [[{ width: 12 }, {}, {}]],
|
|
12
|
+
visualizations: {},
|
|
13
|
+
table: {
|
|
14
|
+
label: 'Data Table',
|
|
15
|
+
show: true,
|
|
16
|
+
showDownloadUrl: false,
|
|
17
|
+
showVertical: true
|
|
18
|
+
}
|
|
19
|
+
})
|
|
4
20
|
|
|
5
21
|
export type DashboardState = {
|
|
6
|
-
config
|
|
22
|
+
config: MultiDashboardConfig
|
|
7
23
|
data: Object
|
|
8
24
|
filteredData: Object
|
|
9
25
|
loading: boolean
|
|
10
26
|
preview: boolean
|
|
11
27
|
tabSelected: number
|
|
12
28
|
}
|
|
29
|
+
|
|
13
30
|
const reducer = (state: DashboardState, action: DashboardActions): DashboardState => {
|
|
14
31
|
switch (action.type) {
|
|
32
|
+
case 'ADD_NEW_DASHBOARD': {
|
|
33
|
+
const currentMultiDashboards = state.config.multiDashboards
|
|
34
|
+
const label = 'New Dashboard ' + (currentMultiDashboards.length + 1)
|
|
35
|
+
const newMultiDashboards = [...currentMultiDashboards, { ...createBlankDashboard(), label }]
|
|
36
|
+
return applyMultiDashboards(state, newMultiDashboards)
|
|
37
|
+
}
|
|
15
38
|
case 'UPDATE_CONFIG': {
|
|
16
39
|
const [config, filteredData] = getUpdateConfig(state)(...action.payload)
|
|
17
40
|
return { ...state, config, filteredData }
|
|
@@ -34,9 +57,57 @@ const reducer = (state: DashboardState, action: DashboardActions): DashboardStat
|
|
|
34
57
|
case 'SET_TAB_SELECTED': {
|
|
35
58
|
return { ...state, tabSelected: action.payload }
|
|
36
59
|
}
|
|
60
|
+
case 'REMOVE_MULTIDASHBOARD_AT_INDEX': {
|
|
61
|
+
const newMultiDashboards = [...state.config.multiDashboards]
|
|
62
|
+
_.remove(newMultiDashboards, (_, index) => {
|
|
63
|
+
return index === action.payload
|
|
64
|
+
})
|
|
65
|
+
if (newMultiDashboards.length === 0) return { ...state, config: _.omit(state.config, 'multiDashboards') }
|
|
66
|
+
return applyMultiDashboards(state, newMultiDashboards)
|
|
67
|
+
}
|
|
68
|
+
case 'RENAME_DASHBOARD_TAB': {
|
|
69
|
+
const newMultiDashboards = state.config.multiDashboards.map(dashboard => {
|
|
70
|
+
if (dashboard.label === action.payload.current) {
|
|
71
|
+
dashboard.label = action.payload.new
|
|
72
|
+
}
|
|
73
|
+
return dashboard
|
|
74
|
+
})
|
|
75
|
+
const newConfig = { ...state.config, label: action.payload.new } // make sure active label is updated
|
|
76
|
+
return applyMultiDashboards({ ...state, newConfig }, newMultiDashboards)
|
|
77
|
+
}
|
|
78
|
+
case 'REORDER_MULTIDASHBOARDS': {
|
|
79
|
+
const { newIndex, currentIndex } = action.payload
|
|
80
|
+
const newMultiDashboards = [...state.config.multiDashboards]
|
|
81
|
+
newMultiDashboards.splice(newIndex, 0, newMultiDashboards.splice(currentIndex, 1)[0])
|
|
82
|
+
// set activeDashboard to newIndex
|
|
83
|
+
const config = { ...state.config, activeDashboard: newIndex }
|
|
84
|
+
return applyMultiDashboards({ ...state, config }, newMultiDashboards)
|
|
85
|
+
}
|
|
86
|
+
case 'SAVE_CURRENT_CHANGES': {
|
|
87
|
+
const saveSlot = state.config.activeDashboard
|
|
88
|
+
const newMultiDashboards = [...state.config.multiDashboards]
|
|
89
|
+
const label = newMultiDashboards[saveSlot].label
|
|
90
|
+
const toSave = _.pick(state.config, ['dashboard', 'visualizations', 'rows'])
|
|
91
|
+
newMultiDashboards[saveSlot] = { ...toSave, label }
|
|
92
|
+
return applyMultiDashboards(state, newMultiDashboards)
|
|
93
|
+
}
|
|
94
|
+
case 'INITIALIZE_MULTIDASHBOARDS': {
|
|
95
|
+
const label = 'New Dashboard 1'
|
|
96
|
+
const toSave = _.pick(state.config, ['dashboard', 'visualizations', 'rows'])
|
|
97
|
+
const newMultiDashboards = [{ ...toSave, label }]
|
|
98
|
+
const config = { ...state.config, activeDashboard: 0 }
|
|
99
|
+
return applyMultiDashboards({ ...state, config }, newMultiDashboards)
|
|
100
|
+
}
|
|
101
|
+
case 'SWITCH_CONFIG': {
|
|
102
|
+
const slot = action.payload
|
|
103
|
+
const newConfigFields = state.config.multiDashboards[slot]
|
|
104
|
+
return { ...state, config: { ...state.config, ...newConfigFields, activeDashboard: slot } }
|
|
105
|
+
}
|
|
37
106
|
default:
|
|
38
107
|
return state
|
|
39
108
|
}
|
|
40
109
|
}
|
|
41
110
|
|
|
42
|
-
|
|
111
|
+
const applyMultiDashboards = (state, newMultiDashboards) => ({ ...state, config: { ...state.config, multiDashboards: newMultiDashboards } })
|
|
112
|
+
|
|
113
|
+
export default devToolsWrapper<DashboardState, DashboardActions>(reducer)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Series } from '@cdc/core/types/Series'
|
|
2
|
+
import { Runtime } from '@cdc/core/types/Runtime'
|
|
3
|
+
import { DataSet } from './DataSet'
|
|
4
|
+
import { ConfigRow } from './ConfigRow'
|
|
5
|
+
import { Visualization } from '@cdc/core/types/Visualization'
|
|
6
|
+
import { Table } from '@cdc/core/types/Table'
|
|
7
|
+
import { FilterBehavior } from '@cdc/core/types/FilterBehavior'
|
|
8
|
+
import { Dashboard } from './Dashboard'
|
|
9
|
+
|
|
10
|
+
export type DashboardConfig = DataSet & {
|
|
11
|
+
dashboard: Dashboard
|
|
12
|
+
confidenceKeys: Record<string, any>
|
|
13
|
+
visualizations: Record<string, Visualization>
|
|
14
|
+
series: Series
|
|
15
|
+
datasets: Record<string, DataSet>
|
|
16
|
+
dataFileName: string
|
|
17
|
+
table: Table
|
|
18
|
+
rows: ConfigRow[]
|
|
19
|
+
filterBehavior: FilterBehavior
|
|
20
|
+
runtime: Runtime
|
|
21
|
+
downloadImageButton: boolean
|
|
22
|
+
downloadPdfButton: boolean
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Visualization } from '@cdc/core/types/Visualization'
|
|
2
|
+
import { Dashboard } from './Dashboard'
|
|
3
|
+
import { DashboardConfig } from './DashboardConfig'
|
|
4
|
+
import { ConfigRow } from './ConfigRow'
|
|
5
|
+
|
|
6
|
+
export type MultiDashboard = { dashboard: Dashboard; rows: ConfigRow[]; visualizations: Record<string, Visualization>; label: string }
|
|
7
|
+
|
|
8
|
+
export type MultiDashboardConfig = DashboardConfig & {
|
|
9
|
+
multiDashboards?: MultiDashboard[]
|
|
10
|
+
activeDashboard?: number // index of the active MultiDashboard
|
|
11
|
+
}
|
|
@@ -1,20 +1,31 @@
|
|
|
1
|
-
import { APIFilter } from './APIFilter'
|
|
2
|
-
export type SharedFilter = {
|
|
3
|
-
type?: 'urlfilter' | 'datafilter' | ''
|
|
4
|
-
fileName: string
|
|
5
|
-
filterBy?: 'Query String' | 'File Name'
|
|
6
|
-
queryParameter?: string
|
|
7
|
-
active?: string
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { APIFilter } from './APIFilter'
|
|
2
|
+
export type SharedFilter = {
|
|
3
|
+
type?: 'urlfilter' | 'datafilter' | ''
|
|
4
|
+
fileName: string
|
|
5
|
+
filterBy?: 'Query String' | 'File Name'
|
|
6
|
+
queryParameter?: string
|
|
7
|
+
active?: string
|
|
8
|
+
queuedActive?: string
|
|
9
|
+
usedBy?: string[]
|
|
10
|
+
parents?: string[]
|
|
11
|
+
setBy?: string
|
|
12
|
+
columnName?: string
|
|
13
|
+
resetLabel?: string
|
|
14
|
+
showDropdown?: boolean
|
|
15
|
+
labels?: Record<string, any>
|
|
16
|
+
key: string
|
|
17
|
+
values?: string[]
|
|
18
|
+
apiFilter?: APIFilter
|
|
19
|
+
datasetKey?: string
|
|
20
|
+
tier?: number
|
|
21
|
+
/**
|
|
22
|
+
* How to format the end file name when filter.filterBy is set to "File Name"
|
|
23
|
+
*
|
|
24
|
+
* @example * United States
|
|
25
|
+
*
|
|
26
|
+
* Keep Spaces: United%20States.json
|
|
27
|
+
* Remove Spaces: UnitedStates.json
|
|
28
|
+
* Replace With Underscore: United_States.json
|
|
29
|
+
**/
|
|
30
|
+
whitespaceReplacement?: 'Keep Spaces' | 'Remove Spaces' | 'Replace With Underscore'
|
|
31
|
+
}
|
package/src/types/Config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Series } from '@cdc/core/types/Series'
|
|
2
|
-
import { Runtime } from '@cdc/core/types/Runtime'
|
|
3
|
-
import { DataSet } from './DataSet'
|
|
4
|
-
import { SharedFilter } from './SharedFilter'
|
|
5
|
-
import { Visualization } from '@cdc/core/types/Visualization'
|
|
6
|
-
|
|
7
|
-
export type Config = DataSet & {
|
|
8
|
-
dashboard: {
|
|
9
|
-
sharedFilters: SharedFilter[]
|
|
10
|
-
datasets: Record<string, DataSet>
|
|
11
|
-
description: any
|
|
12
|
-
title: any
|
|
13
|
-
theme: any
|
|
14
|
-
filters: any
|
|
15
|
-
}
|
|
16
|
-
confidenceKeys: Record<string, any>
|
|
17
|
-
visualizations: {
|
|
18
|
-
[vizKey: string]: Visualization
|
|
19
|
-
}
|
|
20
|
-
series: Series
|
|
21
|
-
datasets: Record<string, DataSet>
|
|
22
|
-
dataFileName: string
|
|
23
|
-
table: any
|
|
24
|
-
rows: any[]
|
|
25
|
-
filterBehavior: string
|
|
26
|
-
runtime: Runtime
|
|
27
|
-
}
|