@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,498 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import React, { CSSProperties, ReactElement } from "react"
|
|
3
|
+
import uuid from "uuid"
|
|
4
|
+
import DraggableBlockComponent from "./DraggableBlockComponent"
|
|
5
|
+
import DecoratedBlockComponent from "../DecoratedBlockComponent"
|
|
6
|
+
import PaletteItemComponent from "./PaletteItemComponent"
|
|
7
|
+
import ClipboardPaletteItemComponent from "./ClipboardPaletteItemComponent"
|
|
8
|
+
import * as blockUtils from "./blockUtils"
|
|
9
|
+
import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent"
|
|
10
|
+
import HorizontalBlockComponent from "./HorizontalBlockComponent"
|
|
11
|
+
import { DashboardStyleWrapper, DashboardTheme, getDefaultLayoutOptions } from "../../dashboards/layoutOptions"
|
|
12
|
+
import { LayoutBlock } from "./blockUtils"
|
|
13
|
+
import { RenderWidgetOptions } from "../LayoutManager"
|
|
14
|
+
|
|
15
|
+
export interface BlocksDisplayComponentProps {
|
|
16
|
+
items: LayoutBlock
|
|
17
|
+
onItemsChange?: (items: LayoutBlock) => void
|
|
18
|
+
|
|
19
|
+
/** Stylesheet to use. null for default */
|
|
20
|
+
style?: DashboardTheme
|
|
21
|
+
|
|
22
|
+
/** layout options to use */
|
|
23
|
+
layoutOptions?: any
|
|
24
|
+
|
|
25
|
+
/** Renders a widget. Passed (options) */
|
|
26
|
+
renderWidget: (options: RenderWidgetOptions) => ReactElement
|
|
27
|
+
|
|
28
|
+
/** True to prevent maps */
|
|
29
|
+
disableMaps?: boolean
|
|
30
|
+
|
|
31
|
+
/** clipboard contents */
|
|
32
|
+
clipboard?: any
|
|
33
|
+
|
|
34
|
+
/** Including onClipboardChange adds a clipboard palette item that can be used to copy and paste widgets */
|
|
35
|
+
onClipboardChange?: (clipboard: any) => void
|
|
36
|
+
|
|
37
|
+
/** message to display if clipboard can't be pasted into current dashboard */
|
|
38
|
+
cantPasteMessage?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
Renders the complete layout of the blocks and also optionally a palette to the left
|
|
43
|
+
that can be used to drag new items into the layout. Palette is only displayed if onItemsChange is not null
|
|
44
|
+
*/
|
|
45
|
+
class BlocksDisplayComponent extends React.Component<BlocksDisplayComponentProps> {
|
|
46
|
+
handleBlockDrop = (sourceBlock: LayoutBlock, targetBlock: LayoutBlock, side: "top" | "left" | "right" | "bottom") => {
|
|
47
|
+
// Remove source from items
|
|
48
|
+
let items = blockUtils.removeBlock(this.props.items, sourceBlock)!
|
|
49
|
+
|
|
50
|
+
// Remove source from target also
|
|
51
|
+
targetBlock = blockUtils.removeBlock(targetBlock, sourceBlock)!
|
|
52
|
+
|
|
53
|
+
items = blockUtils.dropBlock(items, sourceBlock, targetBlock, side)
|
|
54
|
+
items = blockUtils.cleanBlock(items)
|
|
55
|
+
return this.props.onItemsChange!(items)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
handleBlockRemove = (block: LayoutBlock) => {
|
|
59
|
+
let items = blockUtils.removeBlock(this.props.items, block)!
|
|
60
|
+
items = blockUtils.cleanBlock(items)
|
|
61
|
+
return this.props.onItemsChange!(items)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
handleBlockUpdate = (block: LayoutBlock) => {
|
|
65
|
+
let items = blockUtils.updateBlock(this.props.items, block)!
|
|
66
|
+
items = blockUtils.cleanBlock(items)
|
|
67
|
+
return this.props.onItemsChange!(items)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Render a single block (and its children)
|
|
72
|
+
* @param block Block to render
|
|
73
|
+
* @param collapseColumns True to collapse columns
|
|
74
|
+
* @param priority Priority of widget. Higher priority widgets are rendered first
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
renderBlock = (block: LayoutBlock, collapseColumns: boolean, priority: number): ReactElement => {
|
|
78
|
+
let elem: ReactElement | null = null;
|
|
79
|
+
|
|
80
|
+
switch (block.type) {
|
|
81
|
+
case "root":
|
|
82
|
+
return <RootBlockComponent
|
|
83
|
+
key={block.id}
|
|
84
|
+
block={block}
|
|
85
|
+
collapseColumns={collapseColumns}
|
|
86
|
+
renderBlock={this.renderBlock}
|
|
87
|
+
onBlockDrop={this.props.onItemsChange != null ? this.handleBlockDrop : undefined}
|
|
88
|
+
onBlockRemove={this.props.onItemsChange != null ? this.handleBlockRemove : undefined}
|
|
89
|
+
priority={priority}
|
|
90
|
+
/>;
|
|
91
|
+
|
|
92
|
+
case "vertical":
|
|
93
|
+
return <VerticalBlockComponent
|
|
94
|
+
key={block.id}
|
|
95
|
+
block={block}
|
|
96
|
+
collapseColumns={collapseColumns}
|
|
97
|
+
renderBlock={this.renderBlock}
|
|
98
|
+
onBlockDrop={this.props.onItemsChange != null ? this.handleBlockDrop : undefined}
|
|
99
|
+
onBlockRemove={this.props.onItemsChange != null ? this.handleBlockRemove : undefined}
|
|
100
|
+
priority={priority}
|
|
101
|
+
/>;
|
|
102
|
+
|
|
103
|
+
case "horizontal":
|
|
104
|
+
return <HorizontalBlockComponent
|
|
105
|
+
key={block.id}
|
|
106
|
+
block={block}
|
|
107
|
+
collapseColumns={collapseColumns}
|
|
108
|
+
renderBlock={this.renderBlock}
|
|
109
|
+
onBlockDrop={this.props.onItemsChange != null ? this.handleBlockDrop : undefined}
|
|
110
|
+
onBlockRemove={this.props.onItemsChange != null ? this.handleBlockRemove : undefined}
|
|
111
|
+
priority={priority}
|
|
112
|
+
onBlockUpdate={this.props.onItemsChange != null ? this.handleBlockUpdate : undefined}
|
|
113
|
+
/>;
|
|
114
|
+
|
|
115
|
+
case "spacer":
|
|
116
|
+
elem = <AutoSizeComponent injectWidth={true} key={block.id}>
|
|
117
|
+
{(size: any) => (
|
|
118
|
+
<div
|
|
119
|
+
id={block.id}
|
|
120
|
+
style={{
|
|
121
|
+
width: size.width,
|
|
122
|
+
height: block.aspectRatio != null ? size.width / block.aspectRatio : undefined
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
)}
|
|
126
|
+
</AutoSizeComponent>;
|
|
127
|
+
|
|
128
|
+
if (this.props.onItemsChange) {
|
|
129
|
+
elem = (
|
|
130
|
+
<DraggableBlockComponent
|
|
131
|
+
key={block.id}
|
|
132
|
+
block={block}
|
|
133
|
+
onBlockDrop={this.handleBlockDrop}
|
|
134
|
+
>
|
|
135
|
+
<DecoratedBlockComponent
|
|
136
|
+
key={block.id}
|
|
137
|
+
isDragging={false}
|
|
138
|
+
aspectRatio={block.aspectRatio}
|
|
139
|
+
onAspectRatioChange={
|
|
140
|
+
block.aspectRatio != null
|
|
141
|
+
? (aspectRatio: any) =>
|
|
142
|
+
this.props.onItemsChange!(
|
|
143
|
+
blockUtils.updateBlock(this.props.items, _.extend({}, block, { aspectRatio }))
|
|
144
|
+
)
|
|
145
|
+
: undefined
|
|
146
|
+
}
|
|
147
|
+
onBlockRemove={this.props.onItemsChange != null ? this.handleBlockDrop.bind(null, block) : undefined}
|
|
148
|
+
>
|
|
149
|
+
{elem}
|
|
150
|
+
</DecoratedBlockComponent>
|
|
151
|
+
</DraggableBlockComponent>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
|
|
156
|
+
case "widget":
|
|
157
|
+
elem = <AutoSizeComponent injectWidth={true} key={block.id}>
|
|
158
|
+
{(size: any) =>
|
|
159
|
+
this.props.renderWidget({
|
|
160
|
+
id: block.id,
|
|
161
|
+
type: block.widgetType!,
|
|
162
|
+
design: block.design,
|
|
163
|
+
onDesignChange: this.props.onItemsChange
|
|
164
|
+
? (design: any) =>
|
|
165
|
+
this.props.onItemsChange!(blockUtils.updateBlock(this.props.items, _.extend({}, block, { design })))
|
|
166
|
+
: undefined,
|
|
167
|
+
width: size.width,
|
|
168
|
+
height: block.aspectRatio != null ? size.width / block.aspectRatio : undefined,
|
|
169
|
+
priority
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
</AutoSizeComponent>;
|
|
173
|
+
|
|
174
|
+
if (this.props.onItemsChange) {
|
|
175
|
+
elem = (
|
|
176
|
+
<DraggableBlockComponent
|
|
177
|
+
key={block.id}
|
|
178
|
+
block={block}
|
|
179
|
+
onBlockDrop={this.handleBlockDrop}
|
|
180
|
+
>
|
|
181
|
+
<DecoratedBlockComponent
|
|
182
|
+
key={block.id}
|
|
183
|
+
isDragging={false}
|
|
184
|
+
aspectRatio={block.aspectRatio}
|
|
185
|
+
onAspectRatioChange={
|
|
186
|
+
block.aspectRatio != null
|
|
187
|
+
? (aspectRatio: any) =>
|
|
188
|
+
this.props.onItemsChange!(
|
|
189
|
+
blockUtils.updateBlock(this.props.items, _.extend({}, block, { aspectRatio }))
|
|
190
|
+
)
|
|
191
|
+
: undefined
|
|
192
|
+
}
|
|
193
|
+
onBlockRemove={this.props.onItemsChange != null ? this.handleBlockDrop.bind(null, block) : undefined}
|
|
194
|
+
>
|
|
195
|
+
{elem}
|
|
196
|
+
</DecoratedBlockComponent>
|
|
197
|
+
</DraggableBlockComponent>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
default:
|
|
202
|
+
throw new Error(`Unknown block type ${block.type}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Wrap block in padding
|
|
206
|
+
return (
|
|
207
|
+
<div key={block.id} className={`mwater-visualization-block mwater-visualization-block-${block.type}`}>
|
|
208
|
+
{elem}
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
createBlockItem(block: any) {
|
|
214
|
+
// Add unique id
|
|
215
|
+
return () => ({
|
|
216
|
+
block: _.extend({}, block, { id: uuid() })
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
renderPalette() {
|
|
221
|
+
return (
|
|
222
|
+
<div key="palette" style={{ width: 141, height: "100%", position: "absolute", top: 0, left: 0 }}>
|
|
223
|
+
<div className="mwater-visualization-palette" style={{ height: "100%" }}>
|
|
224
|
+
<PaletteItemComponent
|
|
225
|
+
createItem={this.createBlockItem({ type: "widget", widgetType: "Text", design: { style: "title" } })}
|
|
226
|
+
title={<i className="fa fa-font" />}
|
|
227
|
+
subtitle="Title"
|
|
228
|
+
/>
|
|
229
|
+
<PaletteItemComponent
|
|
230
|
+
createItem={this.createBlockItem({ type: "widget", widgetType: "Text", design: {} })}
|
|
231
|
+
title={<i className="fa fa-align-left" />}
|
|
232
|
+
subtitle="Text"
|
|
233
|
+
/>
|
|
234
|
+
<PaletteItemComponent
|
|
235
|
+
createItem={this.createBlockItem({ type: "widget", aspectRatio: 1.4, widgetType: "Image", design: {} })}
|
|
236
|
+
title={<i className="fa fa-picture-o" />}
|
|
237
|
+
subtitle="Image"
|
|
238
|
+
/>
|
|
239
|
+
<PaletteItemComponent
|
|
240
|
+
createItem={this.createBlockItem({
|
|
241
|
+
type: "widget",
|
|
242
|
+
aspectRatio: 1.4,
|
|
243
|
+
widgetType: "LayeredChart",
|
|
244
|
+
design: {}
|
|
245
|
+
})}
|
|
246
|
+
title={<i className="fa fa-bar-chart" />}
|
|
247
|
+
subtitle="Chart"
|
|
248
|
+
/>
|
|
249
|
+
{!this.props.disableMaps && (
|
|
250
|
+
<PaletteItemComponent
|
|
251
|
+
createItem={this.createBlockItem({
|
|
252
|
+
type: "widget",
|
|
253
|
+
aspectRatio: 2,
|
|
254
|
+
widgetType: "Map",
|
|
255
|
+
design: {
|
|
256
|
+
baseLayer: "bing_road",
|
|
257
|
+
layerViews: [],
|
|
258
|
+
filters: {},
|
|
259
|
+
bounds: { w: -40, n: 25, e: 40, s: -25 }
|
|
260
|
+
}
|
|
261
|
+
})}
|
|
262
|
+
title={<i className="fa fa-map-o" />}
|
|
263
|
+
subtitle="Map"
|
|
264
|
+
/>
|
|
265
|
+
)}
|
|
266
|
+
<PaletteItemComponent
|
|
267
|
+
createItem={this.createBlockItem({ type: "widget", aspectRatio: 1.4, widgetType: "TableChart", design: {} })}
|
|
268
|
+
title={<i className="fa fa-table" />}
|
|
269
|
+
subtitle="Table"
|
|
270
|
+
/>
|
|
271
|
+
<PaletteItemComponent
|
|
272
|
+
createItem={this.createBlockItem({ type: "widget", widgetType: "PivotChart", design: {} })}
|
|
273
|
+
title={<img
|
|
274
|
+
width={24}
|
|
275
|
+
height={24}
|
|
276
|
+
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAb0lEQVRIx91VQQrAIAwzo/7/ydllG0MQS21EzMW2ICFtoyBZlLDn/LOgySPAG1xFDDmBtZI6efoMvODozkyL2IlTCOisfS2KrqG0RXus6fkEVBIw08khE62aQY0ogMdEswqwYouwvQ8s+4M576m4Ae/tET/u1taEAAAAAElFTkSuQmCC"
|
|
277
|
+
/>}
|
|
278
|
+
subtitle="Pivot"
|
|
279
|
+
/>
|
|
280
|
+
<PaletteItemComponent
|
|
281
|
+
createItem={this.createBlockItem({
|
|
282
|
+
type: "widget",
|
|
283
|
+
aspectRatio: 1.4,
|
|
284
|
+
widgetType: "CalendarChart",
|
|
285
|
+
design: {}
|
|
286
|
+
})}
|
|
287
|
+
title={<i className="fa fa-calendar" />}
|
|
288
|
+
subtitle="Calendar"
|
|
289
|
+
/>
|
|
290
|
+
<PaletteItemComponent
|
|
291
|
+
createItem={this.createBlockItem({
|
|
292
|
+
type: "widget",
|
|
293
|
+
aspectRatio: 1.4,
|
|
294
|
+
widgetType: "ImageMosaicChart",
|
|
295
|
+
design: {}
|
|
296
|
+
})}
|
|
297
|
+
title={<i className="fa fa-th" />}
|
|
298
|
+
subtitle="Mosaic"
|
|
299
|
+
/>
|
|
300
|
+
<PaletteItemComponent
|
|
301
|
+
createItem={this.createBlockItem({ type: "spacer", aspectRatio: 2 })}
|
|
302
|
+
title={<i className="fa fa-square-o" />}
|
|
303
|
+
subtitle="Spacer"
|
|
304
|
+
/>
|
|
305
|
+
<PaletteItemComponent
|
|
306
|
+
createItem={this.createBlockItem({
|
|
307
|
+
type: "widget",
|
|
308
|
+
aspectRatio: 16.0 / 9.0,
|
|
309
|
+
widgetType: "IFrame",
|
|
310
|
+
design: {}
|
|
311
|
+
})}
|
|
312
|
+
title={<i className="fa fa-youtube-play" />}
|
|
313
|
+
subtitle="Video"
|
|
314
|
+
/>
|
|
315
|
+
<PaletteItemComponent
|
|
316
|
+
createItem={this.createBlockItem({
|
|
317
|
+
type: "widget",
|
|
318
|
+
widgetType: "TOC",
|
|
319
|
+
design: { numbering: false, borderWeight: 2, header: "Contents" }
|
|
320
|
+
})}
|
|
321
|
+
title={<i className="fa fa-list-ol" />}
|
|
322
|
+
subtitle="TOC"
|
|
323
|
+
/>
|
|
324
|
+
{this.props.onClipboardChange && (
|
|
325
|
+
<ClipboardPaletteItemComponent
|
|
326
|
+
clipboard={this.props.clipboard}
|
|
327
|
+
onClipboardChange={this.props.onClipboardChange}
|
|
328
|
+
cantPasteMessage={this.props.cantPasteMessage}
|
|
329
|
+
/>
|
|
330
|
+
)}
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
render() {
|
|
337
|
+
let innerParentStyle: CSSProperties
|
|
338
|
+
const layoutOptions = this.props.layoutOptions || getDefaultLayoutOptions()
|
|
339
|
+
if (this.props.onItemsChange) {
|
|
340
|
+
innerParentStyle = {}
|
|
341
|
+
innerParentStyle.maxWidth = layoutOptions.maximumWidth || undefined
|
|
342
|
+
|
|
343
|
+
return (
|
|
344
|
+
<DashboardStyleWrapper
|
|
345
|
+
style={{ width: "100%", height: "100%", overflow: "hidden", position: "relative" }}
|
|
346
|
+
layoutOptions={layoutOptions}
|
|
347
|
+
>
|
|
348
|
+
{this.renderPalette()}
|
|
349
|
+
<div
|
|
350
|
+
style={{
|
|
351
|
+
position: "absolute",
|
|
352
|
+
left: 141,
|
|
353
|
+
top: 0,
|
|
354
|
+
bottom: 0,
|
|
355
|
+
right: 0,
|
|
356
|
+
overflowX: "auto",
|
|
357
|
+
overflowY: "scroll"
|
|
358
|
+
}}
|
|
359
|
+
className={`mwater-visualization-block-parent-outer mwater-visualization-block-editing`}
|
|
360
|
+
>
|
|
361
|
+
<div
|
|
362
|
+
key="inner"
|
|
363
|
+
className={`mwater-visualization-block-parent-inner mwater-visualization-block-parent-inner-${this.props.style || "default"
|
|
364
|
+
}`}
|
|
365
|
+
style={innerParentStyle}
|
|
366
|
+
>
|
|
367
|
+
{this.renderBlock(this.props.items, false, 0)}
|
|
368
|
+
</div>
|
|
369
|
+
</div>
|
|
370
|
+
</DashboardStyleWrapper>
|
|
371
|
+
)
|
|
372
|
+
} else {
|
|
373
|
+
return (
|
|
374
|
+
<AutoSizeComponent injectWidth injectHeight>
|
|
375
|
+
{(size: any) => {
|
|
376
|
+
const outerParentStyle: CSSProperties = {
|
|
377
|
+
width: "100%",
|
|
378
|
+
height: "100%",
|
|
379
|
+
overflowX: "auto",
|
|
380
|
+
overflowY: "scroll"
|
|
381
|
+
}
|
|
382
|
+
innerParentStyle = {}
|
|
383
|
+
|
|
384
|
+
// Remove padding if small
|
|
385
|
+
if (size.width < 600) {
|
|
386
|
+
innerParentStyle.padding = "0px"
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Scroll/scale
|
|
390
|
+
innerParentStyle.maxWidth = layoutOptions.maximumWidth || undefined
|
|
391
|
+
|
|
392
|
+
if (layoutOptions.belowMinimumWidth === "scroll") {
|
|
393
|
+
innerParentStyle.minWidth = layoutOptions.minimumWidth || undefined
|
|
394
|
+
} else {
|
|
395
|
+
if (layoutOptions.minimumWidth != null && size.width < layoutOptions.minimumWidth) {
|
|
396
|
+
const scale = size.width / layoutOptions.minimumWidth
|
|
397
|
+
outerParentStyle.transform = `scale(${scale})`
|
|
398
|
+
outerParentStyle.width = size.width / scale
|
|
399
|
+
outerParentStyle.height = size.height / scale
|
|
400
|
+
outerParentStyle.transformOrigin = "top left"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return (
|
|
405
|
+
<DashboardStyleWrapper
|
|
406
|
+
style={{ width: "100%", height: "100%" }}
|
|
407
|
+
layoutOptions={layoutOptions}
|
|
408
|
+
>
|
|
409
|
+
<div
|
|
410
|
+
style={outerParentStyle}
|
|
411
|
+
className={`mwater-visualization-block-parent-outer mwater-visualization-block-parent-outer-${this.props.style || "default"
|
|
412
|
+
} mwater-visualization-block-viewing`}
|
|
413
|
+
>
|
|
414
|
+
<div
|
|
415
|
+
key="inner"
|
|
416
|
+
className={`mwater-visualization-block-parent-inner mwater-visualization-block-parent-inner-${this.props.style || "default"
|
|
417
|
+
}`}
|
|
418
|
+
style={innerParentStyle}
|
|
419
|
+
>
|
|
420
|
+
{this.renderBlock(
|
|
421
|
+
this.props.items,
|
|
422
|
+
layoutOptions.collapseColumnsWidth != null && size.width <= layoutOptions.collapseColumnsWidth,
|
|
423
|
+
0
|
|
424
|
+
)}
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
</DashboardStyleWrapper>
|
|
428
|
+
)
|
|
429
|
+
}}
|
|
430
|
+
</AutoSizeComponent>
|
|
431
|
+
)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
export default BlocksDisplayComponent
|
|
436
|
+
|
|
437
|
+
interface RootBlockComponentProps {
|
|
438
|
+
block: LayoutBlock
|
|
439
|
+
collapseColumns: boolean
|
|
440
|
+
priority: number
|
|
441
|
+
renderBlock: (block: LayoutBlock, collapseColumns: boolean, priority: number) => ReactElement
|
|
442
|
+
/** Called with (sourceBlock, targetBlock, side) when block is dropped on it. side is top, left, bottom, right */
|
|
443
|
+
onBlockDrop?: any
|
|
444
|
+
onBlockRemove?: any
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
class RootBlockComponent extends React.Component<RootBlockComponentProps> {
|
|
448
|
+
render() {
|
|
449
|
+
const elem = (
|
|
450
|
+
// Flex to prevent margin collapse
|
|
451
|
+
<div key="root" style={{ display: "flex", flexDirection: "column" }}>
|
|
452
|
+
{_.map(this.props.block.blocks!, (block, index) => {
|
|
453
|
+
// Render with negative priority so that the first block is rendered first
|
|
454
|
+
return this.props.renderBlock(block, this.props.collapseColumns, this.props.priority - index)
|
|
455
|
+
})}
|
|
456
|
+
</div>
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
// If draggable
|
|
460
|
+
if (this.props.onBlockDrop != null) {
|
|
461
|
+
return (
|
|
462
|
+
<DraggableBlockComponent
|
|
463
|
+
block={this.props.block}
|
|
464
|
+
onBlockDrop={this.props.onBlockDrop}
|
|
465
|
+
style={{ height: "100%" }}
|
|
466
|
+
onlyBottom
|
|
467
|
+
>
|
|
468
|
+
{elem}
|
|
469
|
+
</DraggableBlockComponent>
|
|
470
|
+
)
|
|
471
|
+
} else {
|
|
472
|
+
return elem
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
interface VerticalBlockComponentProps {
|
|
478
|
+
block: LayoutBlock
|
|
479
|
+
collapseColumns: boolean
|
|
480
|
+
priority: number
|
|
481
|
+
renderBlock: (block: LayoutBlock, collapseColumns: boolean, priority: number) => ReactElement
|
|
482
|
+
/** Called with (sourceBlock, targetBlock, side) when block is dropped on it. side is top, left, bottom, right */
|
|
483
|
+
onBlockDrop?: any
|
|
484
|
+
onBlockRemove?: any
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
class VerticalBlockComponent extends React.Component<VerticalBlockComponentProps> {
|
|
488
|
+
render() {
|
|
489
|
+
return (
|
|
490
|
+
// Flex to prevent margin collapse
|
|
491
|
+
<div style={{ display: "flex", flexDirection: "column" }}>
|
|
492
|
+
{_.map(this.props.block.blocks!, block => {
|
|
493
|
+
return this.props.renderBlock(block, this.props.collapseColumns, this.props.priority)
|
|
494
|
+
})}
|
|
495
|
+
</div>
|
|
496
|
+
)
|
|
497
|
+
}
|
|
498
|
+
}
|
|
@@ -2,26 +2,17 @@ import _ from "lodash"
|
|
|
2
2
|
import React from "react"
|
|
3
3
|
const R = React.createElement
|
|
4
4
|
import uuid from "uuid"
|
|
5
|
-
import LayoutManager from "../LayoutManager"
|
|
5
|
+
import LayoutManager, { RenderLayoutOptions } from "../LayoutManager"
|
|
6
|
+
import BlocksDisplayComponent from "./BlocksDisplayComponent"
|
|
6
7
|
|
|
7
8
|
export default class BlocksLayoutManager extends LayoutManager {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// renderWidget: called with ({ id:, type:, design:, onDesignChange:, width:, height: })
|
|
13
|
-
// style: style to use for layout. null for default
|
|
14
|
-
// layoutOptions: layout options to use
|
|
15
|
-
// disableMaps: true to disable maps
|
|
16
|
-
// clipboard: clipboard contents
|
|
17
|
-
// onClipboardChange: called when clipboard is changed
|
|
18
|
-
// cantPasteMesssage: message to display if clipboard can't be pasted into current dashboard
|
|
19
|
-
renderLayout(options: any) {
|
|
20
|
-
const BlocksDisplayComponent = require("./BlocksDisplayComponent").default
|
|
9
|
+
/**
|
|
10
|
+
* Renders the layout as a react element
|
|
11
|
+
*/
|
|
12
|
+
renderLayout(options: RenderLayoutOptions) {
|
|
21
13
|
return R(BlocksDisplayComponent, {
|
|
22
14
|
items: options.items || { id: "root", type: "root", blocks: [] },
|
|
23
15
|
onItemsChange: options.onItemsChange,
|
|
24
|
-
style: options.style,
|
|
25
16
|
layoutOptions: options.layoutOptions,
|
|
26
17
|
renderWidget: options.renderWidget,
|
|
27
18
|
disableMaps: options.disableMaps,
|
|
@@ -7,8 +7,9 @@ import DraggableBlockComponent from "./DraggableBlockComponent"
|
|
|
7
7
|
|
|
8
8
|
export interface HorizontalBlockComponentProps {
|
|
9
9
|
block: LayoutBlock
|
|
10
|
-
collapseColumns
|
|
11
|
-
|
|
10
|
+
collapseColumns: boolean
|
|
11
|
+
priority: number
|
|
12
|
+
renderBlock: (block: LayoutBlock, collapseColumns: boolean, priority: number) => ReactElement
|
|
12
13
|
/** Called with (sourceBlock, targetBlock, side) when block is dropped on it. side is top, left, bottom, right */
|
|
13
14
|
onBlockDrop?: any
|
|
14
15
|
/** Called with (block) when block is removed */
|
|
@@ -30,7 +31,7 @@ export default class HorizontalBlockComponent extends React.Component<
|
|
|
30
31
|
> {
|
|
31
32
|
blockRefs: { [blockId: string]: HTMLElement | null }
|
|
32
33
|
|
|
33
|
-
constructor(props:
|
|
34
|
+
constructor(props: HorizontalBlockComponentProps) {
|
|
34
35
|
super(props)
|
|
35
36
|
|
|
36
37
|
this.state = {
|
|
@@ -47,7 +48,7 @@ export default class HorizontalBlockComponent extends React.Component<
|
|
|
47
48
|
componentWillUnmount() {
|
|
48
49
|
// Remove listeners
|
|
49
50
|
document.removeEventListener("mousemove", this.handleMouseMove)
|
|
50
|
-
|
|
51
|
+
document.removeEventListener("mouseup", this.handleMouseUp)
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
handleMouseDown = (index: any, ev: any) => {
|
|
@@ -62,7 +63,7 @@ export default class HorizontalBlockComponent extends React.Component<
|
|
|
62
63
|
})
|
|
63
64
|
|
|
64
65
|
document.addEventListener("mousemove", this.handleMouseMove)
|
|
65
|
-
|
|
66
|
+
document.addEventListener("mouseup", this.handleMouseUp)
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
handleMouseMove = (ev: any) => {
|
|
@@ -118,7 +119,7 @@ export default class HorizontalBlockComponent extends React.Component<
|
|
|
118
119
|
return R(
|
|
119
120
|
"div",
|
|
120
121
|
null,
|
|
121
|
-
_.map(this.props.block.blocks!, (block
|
|
122
|
+
_.map(this.props.block.blocks!, (block) => this.props.renderBlock(block, true, this.props.priority))
|
|
122
123
|
)
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -177,7 +178,7 @@ export default class HorizontalBlockComponent extends React.Component<
|
|
|
177
178
|
return (this.blockRefs[`block${index}`] = c)
|
|
178
179
|
}
|
|
179
180
|
},
|
|
180
|
-
this.props.renderBlock(block)
|
|
181
|
+
this.props.renderBlock(block, false, this.props.priority)
|
|
181
182
|
)
|
|
182
183
|
]
|
|
183
184
|
})
|
|
@@ -213,7 +214,7 @@ export default class HorizontalBlockComponent extends React.Component<
|
|
|
213
214
|
},
|
|
214
215
|
className: "mwater-visualization-horizontal-block-item"
|
|
215
216
|
},
|
|
216
|
-
this.props.renderBlock(block)
|
|
217
|
+
this.props.renderBlock(block, false, this.props.priority)
|
|
217
218
|
)
|
|
218
219
|
]
|
|
219
220
|
})
|
package/src/mWaterLoader.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface MWaterLoaderOptions {
|
|
|
19
19
|
localCaching?: boolean
|
|
20
20
|
/** Locales of the schema to load. Default is all. */
|
|
21
21
|
locales?: string[]
|
|
22
|
+
/** Origin of usage. e.g. "dashboards:43445364..." */
|
|
23
|
+
origin?: string
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/** Loads a schema and data source that is specific to mWater server */
|
|
@@ -69,7 +71,8 @@ export default function mWaterLoader(
|
|
|
69
71
|
const schema = new Schema(schemaJson)
|
|
70
72
|
const dataSource = new MWaterDataSource(options.apiUrl, options.client, {
|
|
71
73
|
serverCaching: false,
|
|
72
|
-
localCaching: options.localCaching != null ? options.localCaching : true
|
|
74
|
+
localCaching: options.localCaching != null ? options.localCaching : true,
|
|
75
|
+
origin: options.origin
|
|
73
76
|
})
|
|
74
77
|
|
|
75
78
|
return callback(null, {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PropTypes from "prop-types"
|
|
2
1
|
import _ from "lodash"
|
|
3
2
|
import React from "react"
|
|
4
3
|
const R = React.createElement
|
|
@@ -6,15 +5,16 @@ const R = React.createElement
|
|
|
6
5
|
import uuid from "uuid"
|
|
7
6
|
import LayerFactory from "./LayerFactory"
|
|
8
7
|
import { DataSource, Schema } from "@mwater/expressions"
|
|
9
|
-
import { MapLayerView } from ".."
|
|
8
|
+
import { MapDesign, MapLayerView } from ".."
|
|
9
|
+
import { AddLayerElementFactoryContext } from "../MWaterContextComponent"
|
|
10
10
|
|
|
11
11
|
export interface AddLayerComponentProps {
|
|
12
12
|
/** Number of layers that already exist */
|
|
13
13
|
layerNumber: number
|
|
14
14
|
/** See Map Design.md */
|
|
15
|
-
design:
|
|
15
|
+
design: MapDesign
|
|
16
16
|
/** Called with new design */
|
|
17
|
-
onDesignChange:
|
|
17
|
+
onDesignChange: (design: MapDesign) => void
|
|
18
18
|
/** Schema to use */
|
|
19
19
|
schema: Schema
|
|
20
20
|
dataSource: DataSource
|
|
@@ -23,7 +23,7 @@ export interface AddLayerComponentProps {
|
|
|
23
23
|
// Dropdown to add a new layer.
|
|
24
24
|
// Can be overridden by context of addLayerElementFactory which is called with all props
|
|
25
25
|
export default class AddLayerComponent extends React.Component<AddLayerComponentProps> {
|
|
26
|
-
static
|
|
26
|
+
static contextType = AddLayerElementFactoryContext
|
|
27
27
|
|
|
28
28
|
handleAddLayer = (newLayer: any) => {
|
|
29
29
|
const layerView: MapLayerView = {
|
|
@@ -48,13 +48,13 @@ export default class AddLayerComponent extends React.Component<AddLayerComponent
|
|
|
48
48
|
const layerViews = this.props.design.layerViews.slice()
|
|
49
49
|
layerViews.push(layerView)
|
|
50
50
|
|
|
51
|
-
const design =
|
|
52
|
-
|
|
51
|
+
const design = { ...this.props.design, layerViews }
|
|
52
|
+
this.props.onDesignChange(design)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
render() {
|
|
56
|
-
if (this.context
|
|
57
|
-
return this.context
|
|
56
|
+
if (this.context) {
|
|
57
|
+
return this.context(this.props)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const newLayers = [
|