@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
|
@@ -24,6 +24,8 @@ export interface ChartViewComponentProps {
|
|
|
24
24
|
/** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
|
|
25
25
|
onScopeChange?: (scope: WidgetScope | null) => void;
|
|
26
26
|
onRowClick?: (tableId: string, rowId: any) => void;
|
|
27
|
+
/** A key that changes when the widget should be refreshed */
|
|
28
|
+
refreshKey?: any;
|
|
27
29
|
}
|
|
28
30
|
interface ChartViewComponentState {
|
|
29
31
|
cacheExpiry?: any;
|
|
@@ -40,6 +42,8 @@ interface ChartViewComponentState {
|
|
|
40
42
|
export default class ChartViewComponent extends React.Component<ChartViewComponentProps, ChartViewComponentState> {
|
|
41
43
|
/** Ordinal of update (0, 1, 2...) to ensure using latest */
|
|
42
44
|
updateSeq: number;
|
|
45
|
+
/** Abort controller for the current data load */
|
|
46
|
+
abortController: AbortController | undefined;
|
|
43
47
|
constructor(props: ChartViewComponentProps);
|
|
44
48
|
componentDidMount(): void;
|
|
45
49
|
componentDidUpdate(prevProps: ChartViewComponentProps): void;
|
|
@@ -13,6 +13,8 @@ const R = react_1.default.createElement;
|
|
|
13
13
|
class ChartViewComponent extends react_1.default.Component {
|
|
14
14
|
/** Ordinal of update (0, 1, 2...) to ensure using latest */
|
|
15
15
|
updateSeq;
|
|
16
|
+
/** Abort controller for the current data load */
|
|
17
|
+
abortController;
|
|
16
18
|
constructor(props) {
|
|
17
19
|
super(props);
|
|
18
20
|
this.updateSeq = 0;
|
|
@@ -31,7 +33,8 @@ class ChartViewComponent extends react_1.default.Component {
|
|
|
31
33
|
componentDidUpdate(prevProps) {
|
|
32
34
|
if (!lodash_1.default.isEqual(prevProps.design, this.props.design) ||
|
|
33
35
|
!lodash_1.default.isEqual(prevProps.filters, this.props.filters) ||
|
|
34
|
-
this.props.dataSource.getCacheExpiry() !== this.state.cacheExpiry
|
|
36
|
+
this.props.dataSource.getCacheExpiry() !== this.state.cacheExpiry ||
|
|
37
|
+
prevProps.refreshKey !== this.props.refreshKey) {
|
|
35
38
|
// Save new cache expiry
|
|
36
39
|
this.setState({ cacheExpiry: this.props.dataSource.getCacheExpiry() });
|
|
37
40
|
this.updateData();
|
|
@@ -46,20 +49,25 @@ class ChartViewComponent extends react_1.default.Component {
|
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
51
|
this.updateSeq += 1;
|
|
52
|
+
if (this.abortController) {
|
|
53
|
+
this.abortController.abort("Aborting previous data load");
|
|
54
|
+
}
|
|
49
55
|
// Set loading data after interval to prevent unnecessary refresh
|
|
50
56
|
const dataLoadingTimeout = setTimeout(() => {
|
|
51
57
|
this.setState({ dataLoading: true });
|
|
52
58
|
}, 100);
|
|
53
59
|
// Store updateSeq to check if latest
|
|
54
60
|
const loadingUpdateSeq = this.updateSeq;
|
|
55
|
-
this.props.widgetDataSource.getData(design, this.props.filters || [], (error, data) => {
|
|
61
|
+
this.abortController = this.props.widgetDataSource.getData(design, this.props.filters || [], (error, data) => {
|
|
56
62
|
// Prevent setting data loading if ready
|
|
57
63
|
clearTimeout(dataLoadingTimeout);
|
|
58
64
|
// Only update if latest
|
|
59
65
|
if (loadingUpdateSeq == this.updateSeq) {
|
|
66
|
+
// Clear the abort controller
|
|
67
|
+
this.abortController = undefined;
|
|
60
68
|
this.setState({ dataLoading: false, dataError: error, data, validDesign: design });
|
|
61
69
|
}
|
|
62
|
-
});
|
|
70
|
+
}) ?? undefined;
|
|
63
71
|
}
|
|
64
72
|
renderSpinner() {
|
|
65
73
|
return R("div", { style: { position: "absolute", bottom: "50%", left: 0, right: 0, textAlign: "center", fontSize: 20 } }, R("i", { className: "fa fa-spinner fa-spin" }));
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import Widget, { CreateViewElementOptions } from "./../Widget";
|
|
4
|
-
import ChartViewComponent from "./ChartViewComponent";
|
|
5
3
|
import { DataSource, Schema } from "@mwater/expressions";
|
|
6
|
-
import { WidgetDataSource } from "../WidgetDataSource";
|
|
7
4
|
import Chart from "./Chart";
|
|
8
|
-
import {
|
|
5
|
+
import { ChartWidgetComponent } from "./ChartWidgetComponent";
|
|
9
6
|
/** A widget which is a chart */
|
|
10
7
|
export default class ChartWidget extends Widget {
|
|
11
8
|
chart: Chart;
|
|
@@ -15,73 +12,3 @@ export default class ChartWidget extends Widget {
|
|
|
15
12
|
getFilterableTables(design: any, schema: Schema): string[];
|
|
16
13
|
isAutoHeight(): boolean;
|
|
17
14
|
}
|
|
18
|
-
interface ChartWidgetComponentProps {
|
|
19
|
-
/** schema to use */
|
|
20
|
-
schema: Schema;
|
|
21
|
-
/** data source to use */
|
|
22
|
-
dataSource: DataSource;
|
|
23
|
-
widgetDataSource: WidgetDataSource;
|
|
24
|
-
/** Chart object to use */
|
|
25
|
-
chart: Chart;
|
|
26
|
-
/** Design of chart */
|
|
27
|
-
design: any;
|
|
28
|
-
/** null/undefined for readonly */
|
|
29
|
-
onDesignChange?: any;
|
|
30
|
-
/** Width in pixels */
|
|
31
|
-
width: number;
|
|
32
|
-
/** Height, if a fixed height widget, or one that uses aspect ratio */
|
|
33
|
-
height?: number;
|
|
34
|
-
/** scope of the widget (when the widget self-selects a particular scope) */
|
|
35
|
-
scope?: any;
|
|
36
|
-
/** array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct */
|
|
37
|
-
filters: JsonQLFilter[];
|
|
38
|
-
/** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
|
|
39
|
-
onScopeChange?: any;
|
|
40
|
-
/** Called with (tableId, rowId) when item is clicked */
|
|
41
|
-
onRowClick?: any;
|
|
42
|
-
/** Connects move handle for dragging (see WidgetContainerComponent) TODO REMOVE */
|
|
43
|
-
connectMoveHandle?: any;
|
|
44
|
-
/** Connects resize handle for dragging (see WidgetContainerComponent) TODO REMOVE */
|
|
45
|
-
connectResizeHandle?: any;
|
|
46
|
-
}
|
|
47
|
-
declare class ChartWidgetComponent extends React.PureComponent<ChartWidgetComponentProps, {
|
|
48
|
-
editDesign: any;
|
|
49
|
-
}> {
|
|
50
|
-
static contextTypes: {
|
|
51
|
-
locale: PropTypes.Requireable<string>;
|
|
52
|
-
};
|
|
53
|
-
constructor(props: any);
|
|
54
|
-
handleSaveCsvFile: () => void;
|
|
55
|
-
handleStartEditing: () => void;
|
|
56
|
-
handleEndEditing: () => void;
|
|
57
|
-
handleCancelEditing: () => void;
|
|
58
|
-
handleEditDesignChange: (design: any) => void;
|
|
59
|
-
renderChart(design: any, onDesignChange: any, width: any, height: any): React.CElement<import("./ChartViewComponent").ChartViewComponentProps, ChartViewComponent>;
|
|
60
|
-
renderEditor(): React.CElement<{
|
|
61
|
-
isOpen: boolean;
|
|
62
|
-
onRequestClose: () => void;
|
|
63
|
-
}, React.Component<{
|
|
64
|
-
isOpen: boolean;
|
|
65
|
-
onRequestClose: () => void;
|
|
66
|
-
}, any, any>> | React.CElement<{
|
|
67
|
-
size: string;
|
|
68
|
-
onCancel: () => void;
|
|
69
|
-
onAction: () => void;
|
|
70
|
-
}, React.Component<{
|
|
71
|
-
size: string;
|
|
72
|
-
onCancel: () => void;
|
|
73
|
-
onAction: () => void;
|
|
74
|
-
}, any, any>> | null;
|
|
75
|
-
renderEditLink(): React.DetailedReactHTMLElement<{
|
|
76
|
-
className: string;
|
|
77
|
-
onClick: () => void;
|
|
78
|
-
}, HTMLElement>;
|
|
79
|
-
render(): React.DetailedReactHTMLElement<{
|
|
80
|
-
onDoubleClick: (() => void) | undefined;
|
|
81
|
-
style: {
|
|
82
|
-
position: "relative";
|
|
83
|
-
width: number;
|
|
84
|
-
};
|
|
85
|
-
}, HTMLElement>;
|
|
86
|
-
}
|
|
87
|
-
export {};
|
|
@@ -1,41 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const prop_types_1 = __importDefault(require("prop-types"));
|
|
30
6
|
const react_1 = __importDefault(require("react"));
|
|
31
7
|
const R = react_1.default.createElement;
|
|
32
8
|
const Widget_1 = __importDefault(require("./../Widget"));
|
|
33
|
-
const
|
|
34
|
-
const CsvBuilder_1 = __importDefault(require("./../../CsvBuilder"));
|
|
35
|
-
const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
|
|
36
|
-
const ChartViewComponent_1 = __importDefault(require("./ChartViewComponent"));
|
|
37
|
-
const ModalWindowComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalWindowComponent"));
|
|
38
|
-
const ui = __importStar(require("@mwater/react-library/lib/bootstrap"));
|
|
9
|
+
const ChartWidgetComponent_1 = require("./ChartWidgetComponent");
|
|
39
10
|
/** A widget which is a chart */
|
|
40
11
|
class ChartWidget extends Widget_1.default {
|
|
41
12
|
chart;
|
|
@@ -57,7 +28,7 @@ class ChartWidget extends Widget_1.default {
|
|
|
57
28
|
// height: height in pixels on screen
|
|
58
29
|
// onRowClick: Called with (tableId, rowId) when item is clicked
|
|
59
30
|
createViewElement(options) {
|
|
60
|
-
return R(ChartWidgetComponent, {
|
|
31
|
+
return R(ChartWidgetComponent_1.ChartWidgetComponent, {
|
|
61
32
|
chart: this.chart,
|
|
62
33
|
design: options.design,
|
|
63
34
|
schema: options.schema,
|
|
@@ -69,7 +40,8 @@ class ChartWidget extends Widget_1.default {
|
|
|
69
40
|
onDesignChange: options.onDesignChange,
|
|
70
41
|
width: options.width,
|
|
71
42
|
height: options.height,
|
|
72
|
-
onRowClick: options.onRowClick
|
|
43
|
+
onRowClick: options.onRowClick,
|
|
44
|
+
refreshKey: options.refreshKey
|
|
73
45
|
});
|
|
74
46
|
}
|
|
75
47
|
// Get the data that the widget needs. This will be called on the server, typically.
|
|
@@ -95,154 +67,3 @@ class ChartWidget extends Widget_1.default {
|
|
|
95
67
|
}
|
|
96
68
|
}
|
|
97
69
|
exports.default = ChartWidget;
|
|
98
|
-
// Complete chart widget
|
|
99
|
-
class ChartWidgetComponent extends react_1.default.PureComponent {
|
|
100
|
-
static contextTypes = { locale: prop_types_1.default.string };
|
|
101
|
-
constructor(props) {
|
|
102
|
-
super(props);
|
|
103
|
-
this.state = {
|
|
104
|
-
// Design that is being edited. Change is propagated on closing window
|
|
105
|
-
editDesign: null
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
// Saves a csv file to disk
|
|
109
|
-
handleSaveCsvFile = () => {
|
|
110
|
-
// Get the data
|
|
111
|
-
return this.props.widgetDataSource.getData(this.props.design, this.props.filters, (err, data) => {
|
|
112
|
-
if (err) {
|
|
113
|
-
return alert("Failed to get data: " + err.message);
|
|
114
|
-
}
|
|
115
|
-
// Create data table
|
|
116
|
-
const table = this.props.chart.createDataTable(this.props.design, this.props.schema, this.props.dataSource, data, this.context.locale);
|
|
117
|
-
if (!table) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
// Convert to csv
|
|
121
|
-
let csv = new CsvBuilder_1.default().build(table);
|
|
122
|
-
// Add BOM
|
|
123
|
-
csv = "\uFEFF" + csv;
|
|
124
|
-
// Make a blob and save
|
|
125
|
-
const blob = new Blob([csv], { type: "text/csv" });
|
|
126
|
-
// Require at use as causes server problems
|
|
127
|
-
const FileSaver = require("file-saver");
|
|
128
|
-
return FileSaver.saveAs(blob, "Exported Data.csv");
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
handleStartEditing = () => {
|
|
132
|
-
// Can't edit if already editing
|
|
133
|
-
if (this.state.editDesign) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this.setState({ editDesign: this.props.design });
|
|
137
|
-
};
|
|
138
|
-
handleEndEditing = () => {
|
|
139
|
-
this.props.onDesignChange(this.state.editDesign);
|
|
140
|
-
this.setState({ editDesign: null });
|
|
141
|
-
};
|
|
142
|
-
handleCancelEditing = () => {
|
|
143
|
-
this.setState({ editDesign: null });
|
|
144
|
-
};
|
|
145
|
-
handleEditDesignChange = (design) => {
|
|
146
|
-
this.setState({ editDesign: design });
|
|
147
|
-
};
|
|
148
|
-
renderChart(design, onDesignChange, width, height) {
|
|
149
|
-
return R(ChartViewComponent_1.default, {
|
|
150
|
-
chart: this.props.chart,
|
|
151
|
-
design,
|
|
152
|
-
onDesignChange,
|
|
153
|
-
schema: this.props.schema,
|
|
154
|
-
dataSource: this.props.dataSource,
|
|
155
|
-
widgetDataSource: this.props.widgetDataSource,
|
|
156
|
-
scope: this.props.scope,
|
|
157
|
-
filters: this.props.filters,
|
|
158
|
-
width,
|
|
159
|
-
height,
|
|
160
|
-
onScopeChange: this.props.onScopeChange,
|
|
161
|
-
onRowClick: this.props.onRowClick
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
renderEditor() {
|
|
165
|
-
if (!this.state.editDesign) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
// Create editor
|
|
169
|
-
const editor = this.props.chart.createDesignerElement({
|
|
170
|
-
schema: this.props.schema,
|
|
171
|
-
filters: this.props.filters,
|
|
172
|
-
dataSource: this.props.dataSource,
|
|
173
|
-
design: this.state.editDesign,
|
|
174
|
-
onDesignChange: this.handleEditDesignChange
|
|
175
|
-
});
|
|
176
|
-
if (this.props.chart.hasDesignerPreview()) {
|
|
177
|
-
// Create chart (maxing out at half of width of screen)
|
|
178
|
-
const chartWidth = Math.min(document.body.clientWidth / 2, this.props.width);
|
|
179
|
-
const chartHeight = this.props.height != null ? this.props.height * (chartWidth / this.props.width) : undefined;
|
|
180
|
-
const chart = this.renderChart(this.state.editDesign, (design) => this.setState({ editDesign: design }), chartWidth, chartHeight);
|
|
181
|
-
const content = R("div", { style: { height: "100%", width: "100%" } }, R("div", {
|
|
182
|
-
style: {
|
|
183
|
-
position: "absolute",
|
|
184
|
-
left: 0,
|
|
185
|
-
top: 0,
|
|
186
|
-
border: "solid 2px #EEE",
|
|
187
|
-
borderRadius: 8,
|
|
188
|
-
padding: 10,
|
|
189
|
-
width: chartWidth + 20,
|
|
190
|
-
height: chartHeight != null ? chartHeight + 20 : undefined,
|
|
191
|
-
overflow: "hidden"
|
|
192
|
-
}
|
|
193
|
-
}, chart), R("div", { style: { width: "100%", height: "100%", paddingLeft: chartWidth + 40 } }, R("div", {
|
|
194
|
-
style: {
|
|
195
|
-
width: "100%",
|
|
196
|
-
height: "100%",
|
|
197
|
-
overflowY: "auto",
|
|
198
|
-
paddingLeft: 20,
|
|
199
|
-
paddingRight: 20,
|
|
200
|
-
borderLeft: "solid 3px #AAA"
|
|
201
|
-
}
|
|
202
|
-
}, editor)));
|
|
203
|
-
return R(ModalWindowComponent_1.default, {
|
|
204
|
-
isOpen: true,
|
|
205
|
-
onRequestClose: this.handleEndEditing
|
|
206
|
-
}, content);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
return R(ActionCancelModalComponent_1.default, {
|
|
210
|
-
size: "large",
|
|
211
|
-
onCancel: this.handleCancelEditing,
|
|
212
|
-
onAction: this.handleEndEditing
|
|
213
|
-
}, editor);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// Render a link to start editing
|
|
217
|
-
renderEditLink() {
|
|
218
|
-
return R("div", { className: "mwater-visualization-widget-placeholder", onClick: this.handleStartEditing }, R(ui.Icon, { id: this.props.chart.getPlaceholderIcon() }));
|
|
219
|
-
}
|
|
220
|
-
render() {
|
|
221
|
-
const design = this.props.chart.cleanDesign(this.props.design, this.props.schema);
|
|
222
|
-
// Determine if valid design
|
|
223
|
-
const validDesign = !this.props.chart.validateDesign(design, this.props.schema);
|
|
224
|
-
// Determine if empty
|
|
225
|
-
const emptyDesign = this.props.chart.isEmpty(design);
|
|
226
|
-
// Create dropdown items
|
|
227
|
-
const dropdownItems = this.props.chart.createDropdownItems(design, this.props.schema, this.props.widgetDataSource, this.props.filters);
|
|
228
|
-
if (validDesign) {
|
|
229
|
-
dropdownItems.push({ label: "Export Data", icon: "save-file", onClick: this.handleSaveCsvFile });
|
|
230
|
-
}
|
|
231
|
-
if (this.props.onDesignChange != null) {
|
|
232
|
-
dropdownItems.unshift({
|
|
233
|
-
label: this.props.chart.getEditLabel(),
|
|
234
|
-
icon: "pencil",
|
|
235
|
-
onClick: this.handleStartEditing
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
// Wrap in a simple widget
|
|
239
|
-
return R("div", {
|
|
240
|
-
onDoubleClick: this.props.onDesignChange != null ? this.handleStartEditing : undefined,
|
|
241
|
-
style: { position: "relative", width: this.props.width }
|
|
242
|
-
}, this.props.onDesignChange != null ? this.renderEditor() : undefined, react_1.default.createElement(DropdownWidgetComponent_1.default, {
|
|
243
|
-
width: this.props.width,
|
|
244
|
-
height: this.props.height,
|
|
245
|
-
dropdownItems
|
|
246
|
-
}, this.renderChart(design, this.props.onDesignChange, this.props.width, this.props.height)), (emptyDesign || !validDesign) && this.props.onDesignChange != null ? this.renderEditLink() : undefined);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DataSource, Schema } from "@mwater/expressions";
|
|
3
|
+
import { WidgetDataSource } from "../WidgetDataSource";
|
|
4
|
+
import Chart from "./Chart";
|
|
5
|
+
import { JsonQLFilter } from "../../JsonQLFilter";
|
|
6
|
+
export interface ChartWidgetComponentProps {
|
|
7
|
+
/** schema to use */
|
|
8
|
+
schema: Schema;
|
|
9
|
+
/** data source to use */
|
|
10
|
+
dataSource: DataSource;
|
|
11
|
+
widgetDataSource: WidgetDataSource;
|
|
12
|
+
/** Chart object to use */
|
|
13
|
+
chart: Chart;
|
|
14
|
+
/** Design of chart */
|
|
15
|
+
design: any;
|
|
16
|
+
/** null/undefined for readonly */
|
|
17
|
+
onDesignChange?: any;
|
|
18
|
+
/** Width in pixels */
|
|
19
|
+
width: number;
|
|
20
|
+
/** Height, if a fixed height widget, or one that uses aspect ratio */
|
|
21
|
+
height?: number;
|
|
22
|
+
/** scope of the widget (when the widget self-selects a particular scope) */
|
|
23
|
+
scope?: any;
|
|
24
|
+
/** array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct */
|
|
25
|
+
filters: JsonQLFilter[];
|
|
26
|
+
/** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
|
|
27
|
+
onScopeChange?: any;
|
|
28
|
+
/** Called with (tableId, rowId) when item is clicked */
|
|
29
|
+
onRowClick?: any;
|
|
30
|
+
/** Connects move handle for dragging (see WidgetContainerComponent) TODO REMOVE */
|
|
31
|
+
connectMoveHandle?: any;
|
|
32
|
+
/** Connects resize handle for dragging (see WidgetContainerComponent) TODO REMOVE */
|
|
33
|
+
connectResizeHandle?: any;
|
|
34
|
+
/** A key that changes when the widget should be refreshed */
|
|
35
|
+
refreshKey?: any;
|
|
36
|
+
}
|
|
37
|
+
export declare class ChartWidgetComponent extends React.PureComponent<ChartWidgetComponentProps, {
|
|
38
|
+
editDesign: any;
|
|
39
|
+
}> {
|
|
40
|
+
static contextType: React.Context<string>;
|
|
41
|
+
constructor(props: any);
|
|
42
|
+
handleSaveCsvFile: () => void | AbortController | undefined;
|
|
43
|
+
handleStartEditing: () => void;
|
|
44
|
+
handleEndEditing: () => void;
|
|
45
|
+
handleCancelEditing: () => void;
|
|
46
|
+
handleEditDesignChange: (design: any) => void;
|
|
47
|
+
renderChart(design: any, onDesignChange: any, width: any, height: any): React.JSX.Element;
|
|
48
|
+
renderEditor(): React.JSX.Element | null;
|
|
49
|
+
renderEditLink(message: string): React.JSX.Element;
|
|
50
|
+
render(): React.JSX.Element;
|
|
51
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ChartWidgetComponent = void 0;
|
|
30
|
+
const react_1 = __importDefault(require("react"));
|
|
31
|
+
const DropdownWidgetComponent_1 = __importDefault(require("../DropdownWidgetComponent"));
|
|
32
|
+
const CsvBuilder_1 = __importDefault(require("../../CsvBuilder"));
|
|
33
|
+
const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
|
|
34
|
+
const ChartViewComponent_1 = __importDefault(require("./ChartViewComponent"));
|
|
35
|
+
const ModalWindowComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalWindowComponent"));
|
|
36
|
+
const ui = __importStar(require("@mwater/react-library/lib/bootstrap"));
|
|
37
|
+
const contexts_1 = require("@mwater/expressions-ui/lib/contexts");
|
|
38
|
+
const layoutOptions_1 = require("../../dashboards/layoutOptions");
|
|
39
|
+
// Complete chart widget
|
|
40
|
+
class ChartWidgetComponent extends react_1.default.PureComponent {
|
|
41
|
+
static contextType = contexts_1.LocaleContext;
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
this.state = {
|
|
45
|
+
// Design that is being edited. Change is propagated on closing window
|
|
46
|
+
editDesign: null
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Saves a csv file to disk
|
|
50
|
+
handleSaveCsvFile = () => {
|
|
51
|
+
// Get the data
|
|
52
|
+
return this.props.widgetDataSource.getData(this.props.design, this.props.filters, (err, data) => {
|
|
53
|
+
if (err) {
|
|
54
|
+
return alert("Failed to get data: " + err.message);
|
|
55
|
+
}
|
|
56
|
+
// Create data table
|
|
57
|
+
const table = this.props.chart.createDataTable(this.props.design, this.props.schema, this.props.dataSource, data, this.context);
|
|
58
|
+
if (!table) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Convert to csv
|
|
62
|
+
let csv = new CsvBuilder_1.default().build(table);
|
|
63
|
+
// Add BOM
|
|
64
|
+
csv = "\uFEFF" + csv;
|
|
65
|
+
// Make a blob and save
|
|
66
|
+
const blob = new Blob([csv], { type: "text/csv" });
|
|
67
|
+
// Require at use as causes server problems
|
|
68
|
+
const FileSaver = require("file-saver");
|
|
69
|
+
return FileSaver.saveAs(blob, "Exported Data.csv");
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
handleStartEditing = () => {
|
|
73
|
+
// Can't edit if already editing
|
|
74
|
+
if (this.state.editDesign) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.setState({ editDesign: this.props.design });
|
|
78
|
+
};
|
|
79
|
+
handleEndEditing = () => {
|
|
80
|
+
this.props.onDesignChange(this.state.editDesign);
|
|
81
|
+
this.setState({ editDesign: null });
|
|
82
|
+
};
|
|
83
|
+
handleCancelEditing = () => {
|
|
84
|
+
this.setState({ editDesign: null });
|
|
85
|
+
};
|
|
86
|
+
handleEditDesignChange = (design) => {
|
|
87
|
+
this.setState({ editDesign: design });
|
|
88
|
+
};
|
|
89
|
+
renderChart(design, onDesignChange, width, height) {
|
|
90
|
+
return react_1.default.createElement(ChartViewComponent_1.default, { chart: this.props.chart, design: design, onDesignChange: onDesignChange, schema: this.props.schema, dataSource: this.props.dataSource, widgetDataSource: this.props.widgetDataSource, scope: this.props.scope, filters: this.props.filters, width: width, height: height, onScopeChange: this.props.onScopeChange, onRowClick: this.props.onRowClick, refreshKey: this.props.refreshKey });
|
|
91
|
+
}
|
|
92
|
+
renderEditor() {
|
|
93
|
+
if (!this.state.editDesign) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
// Create editor
|
|
97
|
+
const editor = this.props.chart.createDesignerElement({
|
|
98
|
+
schema: this.props.schema,
|
|
99
|
+
filters: this.props.filters,
|
|
100
|
+
dataSource: this.props.dataSource,
|
|
101
|
+
design: this.state.editDesign,
|
|
102
|
+
onDesignChange: this.handleEditDesignChange
|
|
103
|
+
});
|
|
104
|
+
if (this.props.chart.hasDesignerPreview()) {
|
|
105
|
+
// Create chart (maxing out at half of width of screen)
|
|
106
|
+
const chartWidth = Math.min(document.body.clientWidth / 2, this.props.width);
|
|
107
|
+
const chartHeight = this.props.height != null ? this.props.height * (chartWidth / this.props.width) : undefined;
|
|
108
|
+
let chart = this.renderChart(this.state.editDesign, (design) => this.setState({ editDesign: design }), chartWidth, chartHeight);
|
|
109
|
+
const content = (react_1.default.createElement("div", { style: { height: "100%", width: "100%" } },
|
|
110
|
+
react_1.default.createElement(layoutOptions_1.BlocksLayoutOptionsContext.Consumer, null, blocksLayoutOptions => (react_1.default.createElement("style", { dangerouslySetInnerHTML: { __html: (0, layoutOptions_1.createDashboardStyles)("#chart-editor", blocksLayoutOptions || (0, layoutOptions_1.getDefaultLayoutOptions)()) } }))),
|
|
111
|
+
react_1.default.createElement("div", { style: {
|
|
112
|
+
position: "absolute",
|
|
113
|
+
left: 0,
|
|
114
|
+
top: 0,
|
|
115
|
+
border: "solid 2px #EEE",
|
|
116
|
+
borderRadius: 8,
|
|
117
|
+
padding: 10,
|
|
118
|
+
width: chartWidth + 20,
|
|
119
|
+
height: chartHeight != null ? chartHeight + 20 : undefined,
|
|
120
|
+
overflow: "hidden"
|
|
121
|
+
}, id: "chart-editor" }, chart),
|
|
122
|
+
react_1.default.createElement("div", { style: { width: "100%", height: "100%", paddingLeft: chartWidth + 40 } },
|
|
123
|
+
react_1.default.createElement("div", { style: {
|
|
124
|
+
width: "100%",
|
|
125
|
+
height: "100%",
|
|
126
|
+
overflowY: "auto",
|
|
127
|
+
paddingLeft: 20,
|
|
128
|
+
paddingRight: 20,
|
|
129
|
+
borderLeft: "solid 3px #AAA"
|
|
130
|
+
} }, editor))));
|
|
131
|
+
return (react_1.default.createElement(ModalWindowComponent_1.default, { isOpen: true, onRequestClose: this.handleEndEditing }, content));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return (react_1.default.createElement(ActionCancelModalComponent_1.default, { size: "large", onCancel: this.handleCancelEditing, onAction: this.handleEndEditing }, editor));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Render a link to start editing
|
|
138
|
+
renderEditLink(message) {
|
|
139
|
+
return (react_1.default.createElement("div", { className: "mwater-visualization-widget-placeholder", onClick: this.handleStartEditing },
|
|
140
|
+
react_1.default.createElement(ui.Icon, { id: this.props.chart.getPlaceholderIcon() }),
|
|
141
|
+
react_1.default.createElement("div", { className: "mwater-visualization-widget-placeholder-message" }, message)));
|
|
142
|
+
}
|
|
143
|
+
render() {
|
|
144
|
+
const design = this.props.chart.cleanDesign(this.props.design, this.props.schema);
|
|
145
|
+
// Determine if valid design
|
|
146
|
+
const designError = this.props.chart.validateDesign(design, this.props.schema);
|
|
147
|
+
// Determine if empty
|
|
148
|
+
const emptyDesign = this.props.chart.isEmpty(design);
|
|
149
|
+
// Create dropdown items
|
|
150
|
+
const dropdownItems = this.props.chart.createDropdownItems(design, this.props.schema, this.props.widgetDataSource, this.props.filters);
|
|
151
|
+
if (!designError) {
|
|
152
|
+
dropdownItems.push({ label: "Export Data", icon: "save-file", onClick: this.handleSaveCsvFile });
|
|
153
|
+
}
|
|
154
|
+
if (this.props.onDesignChange != null) {
|
|
155
|
+
dropdownItems.unshift({
|
|
156
|
+
label: this.props.chart.getEditLabel(),
|
|
157
|
+
onClick: this.handleStartEditing
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// Wrap in a simple widget
|
|
161
|
+
return (react_1.default.createElement("div", { onDoubleClick: this.props.onDesignChange != null ? this.handleStartEditing : undefined, style: { position: "relative", width: this.props.width } },
|
|
162
|
+
this.props.onDesignChange != null ? this.renderEditor() : undefined,
|
|
163
|
+
react_1.default.createElement(DropdownWidgetComponent_1.default, { width: this.props.width, height: this.props.height, dropdownItems: dropdownItems }, this.renderChart(design, this.props.onDesignChange, this.props.width, this.props.height)),
|
|
164
|
+
(emptyDesign || designError) && this.props.onDesignChange != null ? this.renderEditLink(designError || "") : undefined));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.ChartWidgetComponent = ChartWidgetComponent;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import AxisBuilder from "../../../axes/AxisBuilder";
|
|
4
3
|
import { Schema } from "@mwater/expressions";
|
|
@@ -30,9 +29,7 @@ export default class CalendarChartViewComponent extends React.Component<Calendar
|
|
|
30
29
|
monthsStrokeWidth: number;
|
|
31
30
|
highlightCellFillColor: string;
|
|
32
31
|
};
|
|
33
|
-
static
|
|
34
|
-
locale: PropTypes.Requireable<string>;
|
|
35
|
-
};
|
|
32
|
+
static contextType: React.Context<string>;
|
|
36
33
|
axisBuilder: AxisBuilder;
|
|
37
34
|
reloading: boolean;
|
|
38
35
|
chart_container: any;
|
|
@@ -27,13 +27,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const jquery_1 = __importDefault(require("jquery"));
|
|
30
|
-
const prop_types_1 = __importDefault(require("prop-types"));
|
|
31
30
|
const lodash_1 = __importDefault(require("lodash"));
|
|
32
31
|
const react_1 = __importDefault(require("react"));
|
|
33
32
|
const R = react_1.default.createElement;
|
|
34
33
|
const moment_1 = __importDefault(require("moment"));
|
|
35
34
|
const AxisBuilder_1 = __importDefault(require("../../../axes/AxisBuilder"));
|
|
36
35
|
const d3 = __importStar(require("d3"));
|
|
36
|
+
const contexts_1 = require("@mwater/expressions-ui/lib/contexts");
|
|
37
37
|
// Require d3-tip to use it
|
|
38
38
|
const d3_tip_1 = __importDefault(require("d3-tip"));
|
|
39
39
|
// creates a d3 calendar visualization
|
|
@@ -43,7 +43,7 @@ class CalendarChartViewComponent extends react_1.default.Component {
|
|
|
43
43
|
monthsStrokeWidth: 1,
|
|
44
44
|
highlightCellFillColor: "#000000"
|
|
45
45
|
};
|
|
46
|
-
static
|
|
46
|
+
static contextType = contexts_1.LocaleContext;
|
|
47
47
|
axisBuilder;
|
|
48
48
|
reloading;
|
|
49
49
|
chart_container;
|
|
@@ -91,9 +91,9 @@ class CalendarChartViewComponent extends react_1.default.Component {
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
const scopeData = {
|
|
94
|
-
name: this.axisBuilder.summarizeAxis(this.props.design.dateAxis, this.context
|
|
94
|
+
name: this.axisBuilder.summarizeAxis(this.props.design.dateAxis, this.context) +
|
|
95
95
|
" is " +
|
|
96
|
-
this.axisBuilder.formatValue(this.props.design.dateAxis, data, this.context
|
|
96
|
+
this.axisBuilder.formatValue(this.props.design.dateAxis, data, this.context),
|
|
97
97
|
filter: {
|
|
98
98
|
jsonql: this.axisBuilder.createValueFilter(this.props.design.dateAxis, data),
|
|
99
99
|
table: this.props.design.table
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import ModalWindowComponent from "@mwater/react-library/lib/ModalWindowComponent";
|
|
2
3
|
export interface ImagePopupComponentProps {
|
|
3
4
|
imageManager: any;
|
|
4
5
|
}
|
|
@@ -9,12 +10,6 @@ interface ImagePopupComponentState {
|
|
|
9
10
|
export default class ImagePopupComponent extends React.Component<ImagePopupComponentProps, ImagePopupComponentState> {
|
|
10
11
|
constructor(props: any);
|
|
11
12
|
show(image: any): any;
|
|
12
|
-
render(): React.CElement<
|
|
13
|
-
isOpen: boolean;
|
|
14
|
-
onRequestClose: () => void;
|
|
15
|
-
}, React.Component<{
|
|
16
|
-
isOpen: boolean;
|
|
17
|
-
onRequestClose: () => void;
|
|
18
|
-
}, any, any>> | null;
|
|
13
|
+
render(): React.CElement<import("@mwater/react-library/lib/ModalWindowComponent").ModalWindowComponentProps, ModalWindowComponent> | null;
|
|
19
14
|
}
|
|
20
15
|
export {};
|