@mwater/visualization 5.1.0 → 5.3.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/lib/ColorComponent.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +19 -9
- package/lib/MWaterContextComponent.js +38 -22
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +15 -3
- package/lib/MWaterLoaderComponent.js +11 -2
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +12 -8
- package/lib/axes/AxisComponent.d.ts +6 -9
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -17
- package/lib/dashboards/DashboardComponent.js +20 -67
- package/lib/dashboards/DashboardDesign.d.ts +5 -20
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +112 -136
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +209 -39
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridComponent.d.ts +2 -9
- package/lib/datagrids/DatagridDataSource.d.ts +3 -3
- package/lib/datagrids/DatagridDataSource.js +0 -14
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +8 -6
- package/lib/datagrids/DatagridViewComponent.js +1 -1
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
- package/lib/datagrids/ServerDatagridDataSource.js +88 -36
- package/lib/demo.js +4 -4
- package/lib/index.css +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +5 -2
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +0 -1
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +3 -11
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +3 -13
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +3 -4
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +70 -56
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
- package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
- package/lib/widgets/MapWidget.d.ts +4 -7
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -74
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +8 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/GlobalFilter.ts +17 -0
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +42 -33
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +14 -4
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +16 -13
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +73 -147
- package/src/dashboards/DashboardDesign.ts +5 -25
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDataSource.ts +6 -12
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
- package/src/datagrids/DatagridViewComponent.ts +3 -3
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +107 -45
- package/src/demo.ts +4 -4
- package/src/index.css +5 -0
- package/src/index.ts +2 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +5 -2
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +0 -1
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +8 -8
- package/src/maps/VectorMapViewComponent.tsx +2 -2
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +88 -74
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +26 -2
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -304
- package/src/dashboards/SettingsModalComponent.ts +0 -169
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- package/src/widgets/text/TextWidgetComponent.ts +0 -120
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import React from "react"
|
|
3
|
+
const R = React.createElement
|
|
4
|
+
import update from "update-object"
|
|
5
|
+
import { languages } from "../languages"
|
|
6
|
+
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
7
|
+
import { default as ReactSelect } from "react-select"
|
|
8
|
+
import * as DashboardUtils from "./DashboardUtils"
|
|
9
|
+
import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelModalComponent"
|
|
10
|
+
import QuickfiltersDesignComponent from "../quickfilter/QuickfiltersDesignComponent"
|
|
11
|
+
import FiltersDesignerComponent from "../FiltersDesignerComponent"
|
|
12
|
+
import { DataSource, Schema } from "@mwater/expressions"
|
|
13
|
+
import { DashboardDesign } from "./DashboardDesign"
|
|
14
|
+
import { GlobalFiltersElementFactoryContext } from "../MWaterContextComponent"
|
|
15
|
+
|
|
16
|
+
export interface SettingsModalComponentProps {
|
|
17
|
+
onDesignChange: any
|
|
18
|
+
schema: Schema
|
|
19
|
+
dataSource: DataSource
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface SettingsModalComponentState {
|
|
23
|
+
design: DashboardDesign | null
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Popup with settings for dashboard
|
|
27
|
+
export default class SettingsModalComponent extends React.Component<
|
|
28
|
+
SettingsModalComponentProps,
|
|
29
|
+
SettingsModalComponentState
|
|
30
|
+
> {
|
|
31
|
+
constructor(props: SettingsModalComponentProps) {
|
|
32
|
+
super(props)
|
|
33
|
+
this.state = {
|
|
34
|
+
design: null // Set when being edited
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
show(design: any) {
|
|
39
|
+
return this.setState({ design })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
handleSave = () => {
|
|
43
|
+
this.props.onDesignChange(this.state.design)
|
|
44
|
+
return this.setState({ design: null })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
handleCancel = () => {
|
|
48
|
+
return this.setState({ design: null })
|
|
49
|
+
}
|
|
50
|
+
handleDesignChange = (design: any) => {
|
|
51
|
+
return this.setState({ design })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
handleFiltersChange = (filters: any) => {
|
|
55
|
+
const design = _.extend({}, this.state.design, { filters })
|
|
56
|
+
return this.handleDesignChange(design)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
handleGlobalFiltersChange = (globalFilters: any) => {
|
|
60
|
+
const design = _.extend({}, this.state.design, { globalFilters })
|
|
61
|
+
return this.handleDesignChange(design)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
render() {
|
|
65
|
+
// Don't show if not editing
|
|
66
|
+
if (!this.state.design) {
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Get filterable tables
|
|
71
|
+
const filterableTables = DashboardUtils.getFilterableTables(this.state.design, this.props.schema)
|
|
72
|
+
|
|
73
|
+
const localeOptions = _.map(languages, (language) => {
|
|
74
|
+
return {
|
|
75
|
+
value: language.code,
|
|
76
|
+
label: language.en + " (" + language.name + ")"
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<ActionCancelModalComponent
|
|
82
|
+
size="large"
|
|
83
|
+
onCancel={this.handleCancel}
|
|
84
|
+
onAction={this.handleSave}
|
|
85
|
+
>
|
|
86
|
+
<div style={{ paddingBottom: 200 }}>
|
|
87
|
+
<h4>Quick Filters</h4>
|
|
88
|
+
<div className="text-muted">
|
|
89
|
+
Quick filters are shown to the user as a dropdown at the top of the dashboard and can be used to filter data of widgets.
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
{filterableTables.length > 0 ? (
|
|
93
|
+
<QuickfiltersDesignComponent
|
|
94
|
+
design={this.state.design.quickfilters || []}
|
|
95
|
+
onDesignChange={(design: any) =>
|
|
96
|
+
this.handleDesignChange(update(this.state.design, { quickfilters: { $set: design } }))
|
|
97
|
+
}
|
|
98
|
+
schema={this.props.schema}
|
|
99
|
+
dataSource={this.props.dataSource}
|
|
100
|
+
tables={filterableTables}
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
"Nothing to quickfilter. Add widgets to the dashboard"
|
|
104
|
+
)}
|
|
105
|
+
|
|
106
|
+
<h4 style={{ paddingTop: 10 }}>Filters</h4>
|
|
107
|
+
<div className="text-muted">
|
|
108
|
+
Filters are built in to the dashboard and cannot be changed by viewers of the dashboard.
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
{filterableTables.length > 0 ? (
|
|
112
|
+
<FiltersDesignerComponent
|
|
113
|
+
schema={this.props.schema}
|
|
114
|
+
dataSource={this.props.dataSource}
|
|
115
|
+
filters={this.state.design.filters}
|
|
116
|
+
onFiltersChange={this.handleFiltersChange}
|
|
117
|
+
filterableTables={filterableTables}
|
|
118
|
+
/>
|
|
119
|
+
) : (
|
|
120
|
+
"Nothing to filter. Add widgets to the dashboard"
|
|
121
|
+
)}
|
|
122
|
+
|
|
123
|
+
<GlobalFiltersElementFactoryContext.Consumer>
|
|
124
|
+
{globalFiltersElementFactory =>
|
|
125
|
+
globalFiltersElementFactory ? (
|
|
126
|
+
<div>
|
|
127
|
+
<h4 style={{ paddingTop: 10 }}>Global Filters</h4>
|
|
128
|
+
{globalFiltersElementFactory({
|
|
129
|
+
schema: this.props.schema,
|
|
130
|
+
dataSource: this.props.dataSource,
|
|
131
|
+
filterableTables,
|
|
132
|
+
globalFilters: this.state.design!.globalFilters || [],
|
|
133
|
+
onChange: this.handleGlobalFiltersChange
|
|
134
|
+
})}
|
|
135
|
+
</div>
|
|
136
|
+
) : undefined
|
|
137
|
+
}
|
|
138
|
+
</GlobalFiltersElementFactoryContext.Consumer>
|
|
139
|
+
|
|
140
|
+
<h4 style={{ paddingTop: 10 }}>Language</h4>
|
|
141
|
+
<div className="text-muted">
|
|
142
|
+
Controls the preferred language of widgets and uses specified language when available
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<ReactSelect
|
|
146
|
+
value={_.findWhere(localeOptions, { value: this.state.design.locale || "en" }) || null}
|
|
147
|
+
options={localeOptions}
|
|
148
|
+
onChange={(locale: any) =>
|
|
149
|
+
this.handleDesignChange(update(this.state.design, { locale: { $set: locale.value } }))
|
|
150
|
+
}
|
|
151
|
+
/>
|
|
152
|
+
|
|
153
|
+
{this.state.design.implicitFiltersEnabled && (
|
|
154
|
+
<>
|
|
155
|
+
<h4 style={{ paddingTop: 10 }}>Advanced</h4>
|
|
156
|
+
<ui.Checkbox
|
|
157
|
+
value={this.state.design.implicitFiltersEnabled != null ? this.state.design.implicitFiltersEnabled : true}
|
|
158
|
+
onChange={(value: boolean) =>
|
|
159
|
+
this.handleDesignChange(update(this.state.design, { implicitFiltersEnabled: { $set: value } }))
|
|
160
|
+
}
|
|
161
|
+
>
|
|
162
|
+
Enable Implicit Filtering (leave unchecked for new dashboards)
|
|
163
|
+
</ui.Checkbox>
|
|
164
|
+
</>
|
|
165
|
+
)}
|
|
166
|
+
</div>
|
|
167
|
+
</ActionCancelModalComponent>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -4,6 +4,7 @@ import { JsonQLFilter } from "../JsonQLFilter"
|
|
|
4
4
|
import WidgetFactory from "../widgets/WidgetFactory"
|
|
5
5
|
import { WidgetScope } from "../WidgetScope"
|
|
6
6
|
import DashboardDataSource from "./DashboardDataSource"
|
|
7
|
+
import { WidgetDataSource } from "../widgets/WidgetDataSource"
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Component which renders a widget and ensures that props do not change
|
|
@@ -21,8 +22,8 @@ export function WidgetComponent(props: {
|
|
|
21
22
|
/** Called with new widget design. null/undefined for readonly **/
|
|
22
23
|
onDesignChange?: { (design: object): void } | null
|
|
23
24
|
|
|
24
|
-
/** Data source for
|
|
25
|
-
|
|
25
|
+
/** Data source for widget */
|
|
26
|
+
widgetDataSource: WidgetDataSource
|
|
26
27
|
|
|
27
28
|
/** schema to use **/
|
|
28
29
|
schema: Schema
|
|
@@ -66,14 +67,6 @@ export function WidgetComponent(props: {
|
|
|
66
67
|
/** Change to force a refresh */
|
|
67
68
|
refreshKey?: any
|
|
68
69
|
}) {
|
|
69
|
-
// Get and stabilize widget data source
|
|
70
|
-
// TODO!!! There is a global problem with DashboardDataSources being re-created on each render.
|
|
71
|
-
// TODO!!! This now only uses the type of the dashboard data source. They should be more stable in the future.
|
|
72
|
-
const widgetDataSource = useMemo(
|
|
73
|
-
() => props.dashboardDataSource.getWidgetDataSource(props.type, props.id),
|
|
74
|
-
[props.dashboardDataSource.constructor, props.type, props.id, props.schema, props.dataSource, props.refreshKey]
|
|
75
|
-
)
|
|
76
|
-
|
|
77
70
|
const widget = WidgetFactory.createWidget(props.type)
|
|
78
71
|
|
|
79
72
|
// Stabilize functions
|
|
@@ -89,7 +82,7 @@ export function WidgetComponent(props: {
|
|
|
89
82
|
return widget.createViewElement({
|
|
90
83
|
schema: props.schema,
|
|
91
84
|
dataSource: props.dataSource,
|
|
92
|
-
widgetDataSource,
|
|
85
|
+
widgetDataSource: props.widgetDataSource,
|
|
93
86
|
design: props.design,
|
|
94
87
|
scope,
|
|
95
88
|
filters,
|
|
@@ -102,7 +95,8 @@ export function WidgetComponent(props: {
|
|
|
102
95
|
namedStrings: props.namedStrings,
|
|
103
96
|
tocEntries: props.tocEntries,
|
|
104
97
|
onScrollToTOCEntry: props.onScrollToTOCEntry,
|
|
105
|
-
widgetRef
|
|
98
|
+
widgetRef,
|
|
99
|
+
refreshKey: props.refreshKey
|
|
106
100
|
})
|
|
107
101
|
}
|
|
108
102
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import PQueue from 'p-queue'
|
|
2
|
+
import DashboardDataSource from './DashboardDataSource'
|
|
3
|
+
import { WidgetDataSource } from '../widgets/WidgetDataSource'
|
|
4
|
+
import { JsonQLFilter } from '../JsonQLFilter'
|
|
5
|
+
import { MapDesign } from '../maps/MapDesign'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A class that prioritizes widget data sources based on the priority of the data source
|
|
9
|
+
* and ensures that only N requests is made at a time for a given widget data source.
|
|
10
|
+
*/
|
|
11
|
+
export class WidgetDataSourcePrioritizer {
|
|
12
|
+
private queue: PQueue
|
|
13
|
+
private dashboardDataSource: DashboardDataSource
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Key is widget type + ":" + widget id + ":" + priority
|
|
17
|
+
*/
|
|
18
|
+
widgetDataSources: { [key: string]: WidgetDataSource }
|
|
19
|
+
|
|
20
|
+
constructor(dashboardDataSource: DashboardDataSource, concurrency: number) {
|
|
21
|
+
this.dashboardDataSource = dashboardDataSource
|
|
22
|
+
this.queue = new PQueue({ concurrency: concurrency })
|
|
23
|
+
this.widgetDataSources = {}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Get a widget data source with the given priority */
|
|
27
|
+
getWidgetDataSource(widgetType: string, widgetId: string, priority: number) {
|
|
28
|
+
let widgetDataSource = this.widgetDataSources[widgetType + ":" + widgetId + ":" + priority]
|
|
29
|
+
if (!widgetDataSource) {
|
|
30
|
+
const innerWidgetDataSource = this.dashboardDataSource.getWidgetDataSource(widgetType, widgetId)
|
|
31
|
+
|
|
32
|
+
widgetDataSource = {
|
|
33
|
+
getData: (design: any, filters: JsonQLFilter[], callback: (error: any, data?: any) => void): AbortController => {
|
|
34
|
+
const task = () => new Promise((resolve, reject) => {
|
|
35
|
+
innerWidgetDataSource.getData(design, filters, (error, data) => {
|
|
36
|
+
if (error) {
|
|
37
|
+
callback(error)
|
|
38
|
+
reject(error)
|
|
39
|
+
} else {
|
|
40
|
+
callback(null, data)
|
|
41
|
+
resolve(data)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Create an abort controller for this task
|
|
47
|
+
const taskAbortController = new AbortController()
|
|
48
|
+
|
|
49
|
+
// Queue the task and handle errors
|
|
50
|
+
this.queue.add(task, { priority: priority, signal: taskAbortController.signal }).catch((e: any) => {
|
|
51
|
+
console.log("Task failed", e)
|
|
52
|
+
callback(e)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return taskAbortController
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
/** Get the url to download an image (by id from an image or imagelist column)
|
|
59
|
+
* Height, if specified, is minimum height needed. May return larger image */
|
|
60
|
+
getImageUrl: (imageId: string, height?: number): string => {
|
|
61
|
+
return innerWidgetDataSource.getImageUrl(imageId, height)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (innerWidgetDataSource.getMapDataSource) {
|
|
66
|
+
widgetDataSource.getMapDataSource = (design: MapDesign) => {
|
|
67
|
+
return innerWidgetDataSource.getMapDataSource!(design)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.widgetDataSources[widgetType + ":" + widgetId + ":" + priority] = widgetDataSource
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return widgetDataSource
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
cancel() {
|
|
78
|
+
// Clear the queue
|
|
79
|
+
this.queue.clear()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|