@mwater/visualization 5.1.0 → 5.2.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.
Files changed (101) hide show
  1. package/lib/GlobalFilter.d.ts +13 -0
  2. package/lib/GlobalFilter.js +2 -0
  3. package/lib/MWaterCompleteTableSelectComponent.d.ts +2 -9
  4. package/lib/MWaterContextComponent.d.ts +15 -3
  5. package/lib/MWaterContextComponent.js +38 -13
  6. package/lib/MWaterCustomTablesetListComponent.js +9 -3
  7. package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
  8. package/lib/MWaterGlobalFiltersComponent.js +4 -4
  9. package/lib/MWaterLoaderComponent.d.ts +12 -2
  10. package/lib/MWaterLoaderComponent.js +9 -1
  11. package/lib/axes/Axis.d.ts +20 -25
  12. package/lib/axes/AxisBuilder.js +9 -7
  13. package/lib/axes/AxisComponent.d.ts +4 -4
  14. package/lib/dashboards/DashboardComponent.d.ts +0 -5
  15. package/lib/dashboards/DashboardComponent.js +2 -29
  16. package/lib/dashboards/DashboardDesign.d.ts +2 -17
  17. package/lib/dashboards/DashboardViewComponent.js +3 -4
  18. package/lib/dashboards/LayoutOptionsComponent.js +4 -3
  19. package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
  20. package/lib/dashboards/SettingsModalComponent.js +24 -38
  21. package/lib/datagrids/DatagridComponent.d.ts +2 -9
  22. package/lib/datagrids/DatagridDataSource.d.ts +3 -3
  23. package/lib/datagrids/DatagridDataSource.js +0 -14
  24. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
  25. package/lib/datagrids/DatagridDesignerComponent.js +8 -6
  26. package/lib/datagrids/DatagridViewComponent.js +1 -1
  27. package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
  28. package/lib/datagrids/FindReplaceModalComponent.js +27 -13
  29. package/lib/datagrids/ServerDatagridDataSource.d.ts +1 -1
  30. package/lib/datagrids/ServerDatagridDataSource.js +1 -3
  31. package/lib/demo.js +1 -1
  32. package/lib/index.d.ts +1 -0
  33. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +2 -1
  34. package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
  35. package/lib/maps/BufferLayer.js +3 -1
  36. package/lib/maps/ClusterLayer.js +3 -1
  37. package/lib/maps/GridLayer.js +5 -3
  38. package/lib/maps/GridLayerDesigner.js +0 -1
  39. package/lib/maps/LayerSwitcherComponent.js +1 -1
  40. package/lib/maps/MapComponent.d.ts +2 -7
  41. package/lib/maps/MapDesign.d.ts +2 -13
  42. package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
  43. package/lib/maps/MapFiltersDesignerComponent.js +4 -5
  44. package/lib/maps/RasterMapViewComponent.d.ts +2 -9
  45. package/lib/maps/RegionSelectComponent.d.ts +2 -1
  46. package/lib/maps/ServerMapDataSource.d.ts +1 -1
  47. package/lib/maps/vectorMaps.d.ts +1 -0
  48. package/lib/maps/vectorMaps.js +10 -2
  49. package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
  50. package/lib/widgets/IFrameWidgetComponent.d.ts +2 -9
  51. package/lib/widgets/ImageWidgetComponent.d.ts +6 -24
  52. package/lib/widgets/MapWidget.d.ts +2 -7
  53. package/lib/widgets/MarkdownWidget.d.ts +2 -7
  54. package/lib/widgets/TOCWidget.d.ts +2 -9
  55. package/lib/widgets/charts/ChartWidget.d.ts +3 -15
  56. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
  57. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +2 -31
  58. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +2 -7
  59. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +73 -66
  60. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +10 -6
  61. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +3 -22
  62. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
  63. package/lib/widgets/charts/table/TableChartViewComponent.js +21 -7
  64. package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
  65. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
  66. package/lib/widgets/text/TextWidgetDesign.d.ts +3 -1
  67. package/package.json +1 -1
  68. package/src/GlobalFilter.ts +17 -0
  69. package/src/MWaterContextComponent.tsx +37 -19
  70. package/src/MWaterCustomTablesetListComponent.tsx +21 -3
  71. package/src/MWaterGlobalFiltersComponent.ts +8 -8
  72. package/src/MWaterLoaderComponent.ts +8 -1
  73. package/src/axes/Axis.ts +24 -25
  74. package/src/axes/AxisBuilder.ts +9 -8
  75. package/src/dashboards/DashboardComponent.tsx +2 -40
  76. package/src/dashboards/DashboardDesign.ts +2 -22
  77. package/src/dashboards/DashboardViewComponent.ts +4 -5
  78. package/src/dashboards/LayoutOptionsComponent.tsx +6 -4
  79. package/src/dashboards/SettingsModalComponent.tsx +170 -0
  80. package/src/datagrids/DatagridDataSource.ts +6 -12
  81. package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
  82. package/src/datagrids/DatagridViewComponent.ts +3 -3
  83. package/src/datagrids/ExprCellComponent.ts +0 -1
  84. package/src/datagrids/FindReplaceModalComponent.ts +39 -22
  85. package/src/datagrids/ServerDatagridDataSource.ts +1 -2
  86. package/src/demo.ts +1 -1
  87. package/src/index.ts +1 -0
  88. package/src/maps/BufferLayer.ts +3 -1
  89. package/src/maps/ClusterLayer.ts +3 -1
  90. package/src/maps/GridLayer.ts +5 -3
  91. package/src/maps/GridLayerDesigner.tsx +0 -1
  92. package/src/maps/LayerSwitcherComponent.tsx +1 -1
  93. package/src/maps/MapDesign.ts +2 -17
  94. package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
  95. package/src/maps/ServerMapDataSource.ts +1 -1
  96. package/src/maps/VectorMapViewComponent.tsx +0 -1
  97. package/src/maps/vectorMaps.tsx +10 -1
  98. package/src/quickfilter/QuickfilterCompiler.ts +1 -1
  99. package/src/widgets/charts/table/TableChartViewComponent.ts +21 -7
  100. package/src/widgets/text/TextWidgetDesign.ts +4 -1
  101. package/src/dashboards/SettingsModalComponent.ts +0 -169
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const prop_types_1 = __importDefault(require("prop-types"));
30
29
  const lodash_1 = __importDefault(require("lodash"));
31
30
  const react_1 = __importDefault(require("react"));
32
31
  const R = react_1.default.createElement;
@@ -38,9 +37,9 @@ const DashboardUtils = __importStar(require("./DashboardUtils"));
38
37
  const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
39
38
  const QuickfiltersDesignComponent_1 = __importDefault(require("../quickfilter/QuickfiltersDesignComponent"));
40
39
  const FiltersDesignerComponent_1 = __importDefault(require("../FiltersDesignerComponent"));
40
+ const MWaterContextComponent_1 = require("../MWaterContextComponent");
41
41
  // Popup with settings for dashboard
42
42
  class SettingsModalComponent extends react_1.default.Component {
43
- static contextTypes = { globalFiltersElementFactory: prop_types_1.default.func };
44
43
  constructor(props) {
45
44
  super(props);
46
45
  this.state = {
@@ -81,42 +80,29 @@ class SettingsModalComponent extends react_1.default.Component {
81
80
  label: language.en + " (" + language.name + ")"
82
81
  };
83
82
  });
84
- return R(ActionCancelModalComponent_1.default, {
85
- size: "large",
86
- onCancel: this.handleCancel,
87
- onAction: this.handleSave
88
- }, R("div", { style: { paddingBottom: 200 } }, R("h4", null, "Quick Filters"), R("div", { className: "text-muted" }, "Quick filters are shown to the user as a dropdown at the top of the dashboard and can be used to filter data of widgets."), filterableTables.length > 0
89
- ? R(QuickfiltersDesignComponent_1.default, {
90
- design: this.state.design.quickfilters || [],
91
- onDesignChange: (design) => this.handleDesignChange((0, update_object_1.default)(this.state.design, { quickfilters: { $set: design } })),
92
- schema: this.props.schema,
93
- dataSource: this.props.dataSource,
94
- tables: filterableTables
95
- })
96
- : "Nothing to quickfilter. Add widgets to the dashboard", R("h4", { style: { paddingTop: 10 } }, "Filters"), R("div", { className: "text-muted" }, "Filters are built in to the dashboard and cannot be changed by viewers of the dashboard."), filterableTables.length > 0
97
- ? R(FiltersDesignerComponent_1.default, {
98
- schema: this.props.schema,
99
- dataSource: this.props.dataSource,
100
- filters: this.state.design.filters,
101
- onFiltersChange: this.handleFiltersChange,
102
- filterableTables
103
- })
104
- : "Nothing to filter. Add widgets to the dashboard", this.context.globalFiltersElementFactory
105
- ? R("div", null, R("h4", { style: { paddingTop: 10 } }, "Global Filters"), this.context.globalFiltersElementFactory({
106
- schema: this.props.schema,
107
- dataSource: this.props.dataSource,
108
- filterableTables,
109
- globalFilters: this.state.design.globalFilters || [],
110
- onChange: this.handleGlobalFiltersChange
111
- }))
112
- : undefined, R("h4", { style: { paddingTop: 10 } }, "Language"), R("div", { className: "text-muted" }, "Controls the preferred language of widgets and uses specified language when available"), R(react_select_1.default, {
113
- value: lodash_1.default.findWhere(localeOptions, { value: this.state.design.locale || "en" }) || null,
114
- options: localeOptions,
115
- onChange: (locale) => this.handleDesignChange((0, update_object_1.default)(this.state.design, { locale: { $set: locale.value } }))
116
- }), R("h4", { style: { paddingTop: 10 } }, "Advanced"), R(ui.Checkbox, {
117
- value: this.state.design.implicitFiltersEnabled != null ? this.state.design.implicitFiltersEnabled : true,
118
- onChange: (value) => this.handleDesignChange((0, update_object_1.default)(this.state.design, { implicitFiltersEnabled: { $set: value } }))
119
- }, "Enable Implicit Filtering (leave unchecked for new dashboards)")));
83
+ return (react_1.default.createElement(ActionCancelModalComponent_1.default, { size: "large", onCancel: this.handleCancel, onAction: this.handleSave },
84
+ react_1.default.createElement("div", { style: { paddingBottom: 200 } },
85
+ react_1.default.createElement("h4", null, "Quick Filters"),
86
+ react_1.default.createElement("div", { className: "text-muted" }, "Quick filters are shown to the user as a dropdown at the top of the dashboard and can be used to filter data of widgets."),
87
+ filterableTables.length > 0 ? (react_1.default.createElement(QuickfiltersDesignComponent_1.default, { design: this.state.design.quickfilters || [], onDesignChange: (design) => this.handleDesignChange((0, update_object_1.default)(this.state.design, { quickfilters: { $set: design } })), schema: this.props.schema, dataSource: this.props.dataSource, tables: filterableTables })) : ("Nothing to quickfilter. Add widgets to the dashboard"),
88
+ react_1.default.createElement("h4", { style: { paddingTop: 10 } }, "Filters"),
89
+ react_1.default.createElement("div", { className: "text-muted" }, "Filters are built in to the dashboard and cannot be changed by viewers of the dashboard."),
90
+ filterableTables.length > 0 ? (react_1.default.createElement(FiltersDesignerComponent_1.default, { schema: this.props.schema, dataSource: this.props.dataSource, filters: this.state.design.filters, onFiltersChange: this.handleFiltersChange, filterableTables: filterableTables })) : ("Nothing to filter. Add widgets to the dashboard"),
91
+ react_1.default.createElement(MWaterContextComponent_1.GlobalFiltersElementFactoryContext.Consumer, null, globalFiltersElementFactory => globalFiltersElementFactory ? (react_1.default.createElement("div", null,
92
+ react_1.default.createElement("h4", { style: { paddingTop: 10 } }, "Global Filters"),
93
+ globalFiltersElementFactory({
94
+ schema: this.props.schema,
95
+ dataSource: this.props.dataSource,
96
+ filterableTables,
97
+ globalFilters: this.state.design.globalFilters || [],
98
+ onChange: this.handleGlobalFiltersChange
99
+ }))) : undefined),
100
+ react_1.default.createElement("h4", { style: { paddingTop: 10 } }, "Language"),
101
+ react_1.default.createElement("div", { className: "text-muted" }, "Controls the preferred language of widgets and uses specified language when available"),
102
+ react_1.default.createElement(react_select_1.default, { value: lodash_1.default.findWhere(localeOptions, { value: this.state.design.locale || "en" }) || null, options: localeOptions, onChange: (locale) => this.handleDesignChange((0, update_object_1.default)(this.state.design, { locale: { $set: locale.value } })) }),
103
+ this.state.design.implicitFiltersEnabled && (react_1.default.createElement(react_1.default.Fragment, null,
104
+ react_1.default.createElement("h4", { style: { paddingTop: 10 } }, "Advanced"),
105
+ react_1.default.createElement(ui.Checkbox, { value: this.state.design.implicitFiltersEnabled != null ? this.state.design.implicitFiltersEnabled : true, onChange: (value) => this.handleDesignChange((0, update_object_1.default)(this.state.design, { implicitFiltersEnabled: { $set: value } })) }, "Enable Implicit Filtering (leave unchecked for new dashboards)"))))));
120
106
  }
121
107
  }
122
108
  exports.default = SettingsModalComponent;
@@ -1,4 +1,5 @@
1
1
  import React, { ReactNode } from "react";
2
+ import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelModalComponent";
2
3
  import { DataSource, Expr, Schema } from "@mwater/expressions";
3
4
  import DatagridViewComponent, { RowUpdate } from "./DatagridViewComponent";
4
5
  import FindReplaceModalComponent from "./FindReplaceModalComponent";
@@ -115,14 +116,6 @@ declare class DatagridEditorComponent extends React.Component<DatagridEditorComp
115
116
  design: DatagridDesign;
116
117
  }> {
117
118
  constructor(props: DatagridEditorComponentProps);
118
- render(): React.CElement<{
119
- onAction: () => void;
120
- onCancel: () => void;
121
- size: string;
122
- }, React.Component<{
123
- onAction: () => void;
124
- onCancel: () => void;
125
- size: string;
126
- }, any, any>>;
119
+ render(): React.CElement<import("@mwater/react-library/lib/ActionCancelModalComponent").ActionCancelModalComponentProps, ActionCancelModalComponent>;
127
120
  }
128
121
  export {};
@@ -1,10 +1,10 @@
1
1
  import { Row } from "@mwater/expressions";
2
2
  import { DatagridDesign, JsonQLFilter } from "..";
3
3
  import { QuickfiltersDataSource } from "../quickfilter/QuickfiltersDataSource";
4
- export default class DatagridDataSource {
4
+ export default interface DatagridDataSource {
5
5
  /** Gets the rows specified */
6
- getRows(design: DatagridDesign, offset: number, limit: number, filters: JsonQLFilter[] | undefined, callback: (error: any, rows: Row[]) => void): void;
7
- countRows(design: DatagridDesign, filters: JsonQLFilter[] | undefined, callback: (error: any, numRows: number) => void): void;
6
+ getRows(design: DatagridDesign, offset: number, limit: number, filters: JsonQLFilter[] | undefined, callback: (error: any, rows?: Row[]) => void): void;
7
+ countRows(design: DatagridDesign, filters: JsonQLFilter[] | undefined, callback: (error: any, numRows?: number) => void): void;
8
8
  /** Gets the quickfilters data source */
9
9
  getQuickfiltersDataSource(): QuickfiltersDataSource;
10
10
  }
@@ -1,16 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- class DatagridDataSource {
4
- /** Gets the rows specified */
5
- getRows(design, offset, limit, filters, callback) {
6
- throw new Error("Not implemented");
7
- }
8
- countRows(design, filters, callback) {
9
- throw new Error("Not implemented");
10
- }
11
- /** Gets the quickfilters data source */
12
- getQuickfiltersDataSource() {
13
- throw new Error("Not implemented");
14
- }
15
- }
16
- exports.default = DatagridDataSource;
@@ -1,7 +1,6 @@
1
- import PropTypes from "prop-types";
2
1
  import React from "react";
3
2
  import { DataSource, Schema } from "@mwater/expressions";
4
- import { DatagridDesignColumn } from "./DatagridDesign";
3
+ import TabbedComponent from "@mwater/react-library/lib/TabbedComponent";
5
4
  import { DatagridDesign } from "..";
6
5
  export interface DatagridDesignerComponentProps {
7
6
  /** schema to use */
@@ -14,101 +13,11 @@ export interface DatagridDesignerComponentProps {
14
13
  onDesignChange: (design: DatagridDesign) => void;
15
14
  }
16
15
  export default class DatagridDesignerComponent extends React.Component<DatagridDesignerComponentProps> {
17
- static contextTypes: {
18
- globalFiltersElementFactory: PropTypes.Requireable<(...args: any[]) => any>;
19
- };
20
16
  handleTableChange: (table: any) => void;
21
17
  handleColumnsChange: (columns: any) => void;
22
18
  handleFilterChange: (filter: any) => void;
23
19
  handleGlobalFiltersChange: (globalFilters: any) => void;
24
20
  handleOrderBysChange: (orderBys: any) => void;
25
- renderTabs(): React.CElement<{
26
- initialTabId: string;
27
- tabs: ({
28
- id: string;
29
- label: string;
30
- elem: React.CElement<ColumnsDesignerComponentProps, ColumnsDesignerComponent>;
31
- } | {
32
- id: string;
33
- label: string;
34
- elem: React.DetailedReactHTMLElement<{
35
- style: {
36
- marginBottom: number;
37
- };
38
- }, HTMLElement>;
39
- })[];
40
- }, React.Component<{
41
- initialTabId: string;
42
- tabs: ({
43
- id: string;
44
- label: string;
45
- elem: React.CElement<ColumnsDesignerComponentProps, ColumnsDesignerComponent>;
46
- } | {
47
- id: string;
48
- label: string;
49
- elem: React.DetailedReactHTMLElement<{
50
- style: {
51
- marginBottom: number;
52
- };
53
- }, HTMLElement>;
54
- })[];
55
- }, any, any>>;
21
+ renderTabs(): React.CElement<any, TabbedComponent>;
56
22
  render(): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
57
23
  }
58
- interface ColumnsDesignerComponentProps {
59
- /** schema to use */
60
- schema: Schema;
61
- /** dataSource to use */
62
- dataSource: DataSource;
63
- table: string;
64
- /** Columns list See README.md of this folder */
65
- columns: any;
66
- onColumnsChange: any;
67
- }
68
- declare class ColumnsDesignerComponent extends React.Component<ColumnsDesignerComponentProps> {
69
- handleColumnChange: (columnIndex: any, column: any) => any;
70
- handleAddColumn: () => any;
71
- handleAddIdColumn: () => any;
72
- handleAddDefaultColumns: () => any;
73
- handleRemoveAllColumns: () => any;
74
- renderColumn: (column: DatagridDesignColumn, columnIndex: any, connectDragSource: any, connectDragPreview: any, connectDropTarget: any) => React.CElement<ColumnDesignerComponentProps, ColumnDesignerComponent>;
75
- render(): React.DetailedReactHTMLElement<{
76
- style: {
77
- height: string;
78
- overflowY: "auto";
79
- overflowX: "hidden";
80
- };
81
- }, HTMLElement>;
82
- }
83
- interface ColumnDesignerComponentProps {
84
- /** schema to use */
85
- schema: Schema;
86
- /** dataSource to use */
87
- dataSource: DataSource;
88
- table: string;
89
- /** Column See README.md of this folder */
90
- column: DatagridDesignColumn;
91
- /** Called when column changes. Null to remove. Array to replace with multiple entries */
92
- onColumnChange: (column: DatagridDesignColumn | null | DatagridDesignColumn[]) => void;
93
- /** Connect drag source (handle) here */
94
- connectDragSource: any;
95
- /** Connect drag preview here */
96
- connectDragPreview: any;
97
- connectDropTarget: any;
98
- }
99
- declare class ColumnDesignerComponent extends React.Component<ColumnDesignerComponentProps> {
100
- handleExprChange: (expr: any) => void;
101
- handleLabelChange: (label: any) => void;
102
- handleFormatChange: (ev: any) => void;
103
- handleSplitEnumset: () => void;
104
- handleSplitGeometry: () => void;
105
- renderSplit(): React.DetailedReactHTMLElement<{
106
- className: string;
107
- onClick: () => void;
108
- }, HTMLElement> | null;
109
- renderFormat(): React.DetailedReactHTMLElement<{
110
- className: string;
111
- }, HTMLElement> | null;
112
- render: () => any;
113
- }
114
- export {};
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const prop_types_1 = __importDefault(require("prop-types"));
30
29
  const lodash_1 = __importDefault(require("lodash"));
31
30
  const react_1 = __importStar(require("react"));
32
31
  const R = react_1.default.createElement;
@@ -47,9 +46,9 @@ const update_object_1 = __importDefault(require("update-object"));
47
46
  const ui = __importStar(require("@mwater/react-library/lib/bootstrap"));
48
47
  const valueFormatter_1 = require("../valueFormatter");
49
48
  const valueFormatter_2 = require("../valueFormatter");
49
+ const MWaterContextComponent_1 = require("../MWaterContextComponent");
50
50
  // Designer for the datagrid. Currenly allows only single-table designs (no subtable rows)
51
51
  class DatagridDesignerComponent extends react_1.default.Component {
52
- static contextTypes = { globalFiltersElementFactory: prop_types_1.default.func };
53
52
  handleTableChange = (table) => {
54
53
  const design = {
55
54
  table,
@@ -95,8 +94,8 @@ class DatagridDesignerComponent extends react_1.default.Component {
95
94
  table: this.props.design.table,
96
95
  value: this.props.design.filter,
97
96
  onChange: this.handleFilterChange
98
- }), this.context.globalFiltersElementFactory
99
- ? R("div", { style: { marginTop: 20 } }, this.context.globalFiltersElementFactory({
97
+ }), react_1.default.createElement(MWaterContextComponent_1.GlobalFiltersElementFactoryContext.Consumer, null, (globalFiltersElementFactory) => globalFiltersElementFactory
98
+ ? R("div", { style: { marginTop: 20 } }, globalFiltersElementFactory({
100
99
  schema: this.props.schema,
101
100
  dataSource: this.props.dataSource,
102
101
  filterableTables: [this.props.design.table],
@@ -104,7 +103,7 @@ class DatagridDesignerComponent extends react_1.default.Component {
104
103
  onChange: this.handleGlobalFiltersChange,
105
104
  nullIfIrrelevant: true
106
105
  }))
107
- : undefined)
106
+ : undefined))
108
107
  },
109
108
  {
110
109
  id: "order",
@@ -378,7 +377,10 @@ class ColumnDesignerComponent extends react_1.default.Component {
378
377
  aggrStatuses: ["literal", "individual", "aggregate"],
379
378
  types: allowedTypes,
380
379
  onChange: this.handleExprChange
381
- }), this.renderSplit(), this.renderFormat(), error ? R("i", { className: "fa fa-exclamation-circle text-danger" }) : undefined), R("div", { className: "col-4" }, R("input", {
380
+ }), this.renderSplit(), this.renderFormat(), error ? react_1.default.createElement("span", { className: "text-danger" },
381
+ react_1.default.createElement("i", { className: "fa fa-exclamation-circle" }),
382
+ " ",
383
+ error) : undefined), R("div", { className: "col-4" }, R("input", {
382
384
  type: "text",
383
385
  className: "form-control",
384
386
  placeholder: exprUtils.summarizeExpr(this.props.column.expr),
@@ -202,7 +202,7 @@ class DatagridViewComponent extends react_1.default.Component {
202
202
  this.editCellComp = comp;
203
203
  };
204
204
  handleRowDoubleClick = (ev, rowIndex) => {
205
- if (this.props.onRowDoubleClick != null && this.state.rows[rowIndex].id) {
205
+ if (this.props.onRowDoubleClick != null && this.state.rows[rowIndex]?.id) {
206
206
  this.props.onRowDoubleClick(this.props.design.table, this.state.rows[rowIndex].id, rowIndex);
207
207
  }
208
208
  };
@@ -1,5 +1,7 @@
1
1
  import React from "react";
2
+ import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent";
2
3
  import { RowUpdate } from "./DatagridViewComponent";
4
+ import ModalPopupComponent from "@mwater/react-library/lib/ModalPopupComponent";
3
5
  import { DataSource, Expr, Schema } from "@mwater/expressions";
4
6
  import { DatagridDesign, JsonQLFilter } from "..";
5
7
  export interface FindReplaceModalComponentProps {
@@ -27,26 +29,8 @@ export default class FindReplaceModalComponent extends React.Component<FindRepla
27
29
  constructor(props: any);
28
30
  show(): void;
29
31
  performReplace(): Promise<void>;
30
- renderPreview(): React.CElement<any, React.Component<any, any, any>>;
32
+ renderPreview(): React.CElement<import("@mwater/react-library/lib/AutoSizeComponent").AutoSizeComponentProps, AutoSizeComponent>;
31
33
  renderContents(): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
32
- render(): React.CElement<{
33
- size: string;
34
- header: string;
35
- footer: React.DetailedReactHTMLElement<{
36
- key: string;
37
- type: string;
38
- onClick: () => void;
39
- className: string;
40
- }, HTMLElement>[];
41
- }, React.Component<{
42
- size: string;
43
- header: string;
44
- footer: React.DetailedReactHTMLElement<{
45
- key: string;
46
- type: string;
47
- onClick: () => void;
48
- className: string;
49
- }, HTMLElement>[];
50
- }, any, any>> | null;
34
+ render(): React.CElement<import("@mwater/react-library/lib/ModalPopupComponent").ModalPopupComponentProps, ModalPopupComponent> | null;
51
35
  }
52
36
  export {};
@@ -38,6 +38,17 @@ class FindReplaceModalComponent extends react_1.default.Component {
38
38
  const design = this.props.design;
39
39
  // Get expr of replace column
40
40
  const replaceExpr = lodash_1.default.findWhere(this.props.design.columns, { id: this.state.replaceColumn }).expr;
41
+ const exprType = exprUtils.getExprType(this.state.withExpr);
42
+ let compiledWithExpr = exprCompiler.compileExpr({ expr: this.state.withExpr, tableAlias: "main" });
43
+ if (exprType === "geometry") {
44
+ compiledWithExpr = {
45
+ type: "op",
46
+ op: "ST_AsGeoJSON",
47
+ exprs: [
48
+ { type: "op", op: "ST_Transform", exprs: [{ type: "op", op: "::geometry", exprs: [compiledWithExpr] }, 4326] }
49
+ ]
50
+ };
51
+ }
41
52
  // Get ids and with value, filtered by filters, design.filter and conditionExpr (if present)
42
53
  const query = {
43
54
  type: "query",
@@ -53,7 +64,7 @@ class FindReplaceModalComponent extends react_1.default.Component {
53
64
  },
54
65
  {
55
66
  type: "select",
56
- expr: exprCompiler.compileExpr({ expr: this.state.withExpr, tableAlias: "main" }),
67
+ expr: compiledWithExpr,
57
68
  alias: "withValue"
58
69
  }
59
70
  ],
@@ -80,7 +91,12 @@ class FindReplaceModalComponent extends react_1.default.Component {
80
91
  continue;
81
92
  }
82
93
  // Create expr
83
- let expr = { type: "op", op: filter.op, table: design.table, exprs: [columnExpr].concat(filter.exprs) };
94
+ let expr = {
95
+ type: "op",
96
+ op: filter.op,
97
+ table: design.table,
98
+ exprs: [columnExpr].concat(filter.exprs)
99
+ };
84
100
  // Clean expr
85
101
  expr = exprCleaner.cleanExpr(expr, { table: design.table });
86
102
  wheres.push(exprCompiler.compileExpr({ expr, tableAlias: "main" }));
@@ -103,7 +119,7 @@ class FindReplaceModalComponent extends react_1.default.Component {
103
119
  await this.props.updateExprValues(this.props.design.table, rows.map(row => ({
104
120
  primaryKey: row.id,
105
121
  expr: replaceExpr,
106
- value: row.withValue
122
+ value: exprType === "geometry" ? JSON.parse(row.withValue) : row.withValue
107
123
  })));
108
124
  alert(T("Successfully replaced {0} values", rows.length));
109
125
  this.setState({ open: false });
@@ -134,7 +150,8 @@ class FindReplaceModalComponent extends react_1.default.Component {
134
150
  // Unchanged
135
151
  else: replaceColumn.expr
136
152
  };
137
- replaceColumn.label = replaceColumn.label || exprUtils.summarizeExpr(replaceColumn.expr, this.props.design.locale);
153
+ replaceColumn.label =
154
+ replaceColumn.label || exprUtils.summarizeExpr(replaceColumn.expr, this.props.design.locale);
138
155
  }
139
156
  // Add filter
140
157
  if (this.state.conditionExpr) {
@@ -143,10 +160,7 @@ class FindReplaceModalComponent extends react_1.default.Component {
143
160
  type: "op",
144
161
  op: "and",
145
162
  table: this.props.design.table,
146
- exprs: [
147
- draft.filter,
148
- this.state.conditionExpr
149
- ]
163
+ exprs: [draft.filter, this.state.conditionExpr]
150
164
  };
151
165
  }
152
166
  else {
@@ -173,8 +187,8 @@ class FindReplaceModalComponent extends react_1.default.Component {
173
187
  let value;
174
188
  const exprUtils = new expressions_1.ExprUtils(this.props.schema);
175
189
  // Determine which columns are replace-able. Excludes subtables and aggregates
176
- const replaceColumns = lodash_1.default.filter(this.props.design.columns, (column) => !column.subtable && exprUtils.getExprAggrStatus(column.expr) === "individual");
177
- const replaceColumnOptions = lodash_1.default.map(replaceColumns, (column) => ({
190
+ const replaceColumns = lodash_1.default.filter(this.props.design.columns, column => !column.subtable && exprUtils.getExprAggrStatus(column.expr) === "individual");
191
+ const replaceColumnOptions = lodash_1.default.map(replaceColumns, column => ({
178
192
  value: column.id,
179
193
  label: column.label || exprUtils.summarizeExpr(column.expr, this.props.design.locale)
180
194
  }));
@@ -189,7 +203,7 @@ class FindReplaceModalComponent extends react_1.default.Component {
189
203
  placeholder: T("Select Column..."),
190
204
  styles: {
191
205
  // Keep menu above fixed data table headers
192
- menu: (style) => lodash_1.default.extend({}, style, { zIndex: 2 })
206
+ menu: style => lodash_1.default.extend({}, style, { zIndex: 2 })
193
207
  }
194
208
  })), (() => {
195
209
  if (this.state.replaceColumn) {
@@ -200,7 +214,7 @@ class FindReplaceModalComponent extends react_1.default.Component {
200
214
  dataSource: this.props.dataSource,
201
215
  table: this.props.design.table,
202
216
  value: this.state.withExpr,
203
- onChange: (value) => this.setState({ withExpr: value }),
217
+ onChange: value => this.setState({ withExpr: value }),
204
218
  types: [exprUtils.getExprType(replaceExpr)],
205
219
  enumValues: exprUtils.getExprEnumValues(replaceExpr) || undefined,
206
220
  idTable: exprUtils.getExprIdTable(replaceExpr) || undefined,
@@ -215,7 +229,7 @@ class FindReplaceModalComponent extends react_1.default.Component {
215
229
  dataSource: this.props.dataSource,
216
230
  table: this.props.design.table,
217
231
  value: this.state.conditionExpr,
218
- onChange: (value) => this.setState({ conditionExpr: value }),
232
+ onChange: value => this.setState({ conditionExpr: value }),
219
233
  types: ["boolean"],
220
234
  placeholder: T("All Rows")
221
235
  })), R("div", { key: "preview" }, R("h4", null, T("Preview")), this.renderPreview()));
@@ -14,7 +14,7 @@ export interface ServerDatagridDataSourceOptions {
14
14
  rev?: number;
15
15
  }
16
16
  /** Uses mWater server to get datagrid data to allow sharing with unprivileged users */
17
- export default class ServerDatagridDataSource extends DatagridDataSource {
17
+ export default class ServerDatagridDataSource implements DatagridDataSource {
18
18
  options: ServerDatagridDataSourceOptions;
19
19
  constructor(options: ServerDatagridDataSourceOptions);
20
20
  getRows(design: DatagridDesign, offset: any, limit: any, filters: any, callback: any): JQuery.jqXHR<any>;
@@ -5,10 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jquery_1 = __importDefault(require("jquery"));
7
7
  const querystring_1 = __importDefault(require("querystring"));
8
- const DatagridDataSource_1 = __importDefault(require("./DatagridDataSource"));
9
8
  const compressJson_1 = __importDefault(require("../compressJson"));
10
9
  /** Uses mWater server to get datagrid data to allow sharing with unprivileged users */
11
- class ServerDatagridDataSource extends DatagridDataSource_1.default {
10
+ class ServerDatagridDataSource {
12
11
  options;
13
12
  // options:
14
13
  // apiUrl: API url to use for talking to mWater server
@@ -17,7 +16,6 @@ class ServerDatagridDataSource extends DatagridDataSource_1.default {
17
16
  // datagridId: datagrid id to use on server
18
17
  // rev: revision to use to allow caching
19
18
  constructor(options) {
20
- super();
21
19
  this.options = options;
22
20
  }
23
21
  // Get the data that the widget needs. The widget should implement getData method (see above) to get the data from the server
package/lib/demo.js CHANGED
@@ -389,7 +389,7 @@ class WaterOrgDashboardPane extends react_1.default.Component {
389
389
  };
390
390
  }
391
391
  componentWillMount() {
392
- const url = this.props.apiUrl + "jsonql/schema";
392
+ const url = this.props.apiUrl + "schema";
393
393
  return jquery_1.default.getJSON(url, (schemaJson) => {
394
394
  const schema = new expressions_1.Schema(schemaJson);
395
395
  const dataSource = new MWaterDataSource_1.default(this.props.apiUrl, null, { serverCaching: false, localCaching: true });
package/lib/index.d.ts CHANGED
@@ -51,6 +51,7 @@ export { default as AxisBuilder } from "./axes/AxisBuilder";
51
51
  export { default as ColorSchemeFactory } from "./ColorSchemeFactory";
52
52
  export { default as DatagridComponent } from "./datagrids/DatagridComponent";
53
53
  export { default as DatagridViewComponent } from "./datagrids/DatagridViewComponent";
54
+ export { default as DatagridDataSource } from "./datagrids/DatagridDataSource";
54
55
  export { default as ServerDashboardDataSource } from "./dashboards/ServerDashboardDataSource";
55
56
  export { default as ServerMapDataSource } from "./maps/ServerMapDataSource";
56
57
  export { default as DirectMapDataSource } from "./maps/DirectMapDataSource";
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent";
2
3
  import HorizontalBlockComponent from "./HorizontalBlockComponent";
3
4
  import { LayoutBlock } from "./blockUtils";
4
5
  export interface BlocksDisplayComponentProps {
@@ -38,7 +39,7 @@ declare class BlocksDisplayComponent extends React.Component<BlocksDisplayCompon
38
39
  left: number;
39
40
  };
40
41
  }, HTMLElement>;
41
- render(): React.CElement<any, React.Component<any, any, any>> | React.DetailedReactHTMLElement<{
42
+ render(): React.CElement<import("@mwater/react-library/lib/AutoSizeComponent").AutoSizeComponentProps, AutoSizeComponent> | React.DetailedReactHTMLElement<{
42
43
  style: {
43
44
  width: string;
44
45
  height: string;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import LayoutManager from "../LayoutManager";
3
+ import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent";
3
4
  export default class GridLayoutManager extends LayoutManager {
4
5
  renderPalette(width: any): React.DetailedReactHTMLElement<{
5
6
  className: string;
@@ -11,7 +12,7 @@ export default class GridLayoutManager extends LayoutManager {
11
12
  width: number;
12
13
  };
13
14
  }, HTMLElement>;
14
- renderLayout(options: any): React.CElement<any, React.Component<any, any, any>>;
15
+ renderLayout(options: any): React.CElement<import("@mwater/react-library/lib/AutoSizeComponent").AutoSizeComponentProps, AutoSizeComponent>;
15
16
  isEmpty(items: any): boolean;
16
17
  getWidgetTypeAndDesign(items: any, widgetId: any): any;
17
18
  getAllWidgets(items: any): {
@@ -96,7 +96,9 @@ class BufferLayer extends Layer_1.default {
96
96
  sourceLayers: [{ id: "circles", jsonql: jsonql }],
97
97
  ctes: [],
98
98
  mapLayers: mapLayers,
99
- mapLayersHandleClicks: [`${sourceId}:fill`]
99
+ mapLayersHandleClicks: [`${sourceId}:fill`],
100
+ minZoom: this.getMinZoom(design),
101
+ maxZoom: this.getMaxZoom(design)
100
102
  };
101
103
  }
102
104
  createJsonQL(design, schema, filters) {
@@ -90,7 +90,9 @@ class ClusterLayer extends Layer_1.default {
90
90
  sourceLayers: [{ id: "clusters", jsonql: jsonql }],
91
91
  ctes: [],
92
92
  mapLayers: mapLayers,
93
- mapLayersHandleClicks: [`${sourceId}:circles-single`, `${sourceId}:circles-multiple`]
93
+ mapLayersHandleClicks: [`${sourceId}:circles-single`, `${sourceId}:circles-multiple`],
94
+ minZoom: this.getMinZoom(design),
95
+ maxZoom: this.getMaxZoom(design)
94
96
  };
95
97
  }
96
98
  createJsonQL(design, schema, filters) {
@@ -51,7 +51,9 @@ class GridLayer extends Layer_1.default {
51
51
  sourceLayers: [{ id: "grid", jsonql: jsonql }],
52
52
  ctes: [],
53
53
  mapLayers: mapLayers,
54
- mapLayersHandleClicks: [`${sourceId}:fill`]
54
+ mapLayersHandleClicks: [`${sourceId}:fill`],
55
+ minZoom: this.getMinZoom(design),
56
+ maxZoom: this.getMaxZoom(design)
55
57
  };
56
58
  }
57
59
  createJsonQL(design, schema, filters) {
@@ -544,9 +546,9 @@ class GridLayer extends Layer_1.default {
544
546
  // }
545
547
  // Get min and max zoom levels
546
548
  getMinZoom(design) {
547
- // Determine if too zoomed out to safely display (zoom 6 at 20000 is limit)
549
+ // Determine if too zoomed out to safely display (200x200, so size = 4e7/(2^zoom) < 200)
548
550
  if (design.sizeUnits === "meters") {
549
- const minSafeZoom = Math.log2(1280000.0 / (design.size || 20000));
551
+ const minSafeZoom = Math.log2(200000.0 / (design.size || 20000));
550
552
  if (design.minZoom) {
551
553
  return Math.max(design.minZoom, minSafeZoom);
552
554
  }
@@ -79,7 +79,6 @@ class GridLayerDesigner extends react_1.default.Component {
79
79
  this.update((d) => {
80
80
  d.sizeUnits = sizeUnits;
81
81
  d.size = 20000;
82
- d.minZoom = 6;
83
82
  });
84
83
  }
85
84
  };
@@ -72,7 +72,7 @@ function LayerSwitcherComponent(props) {
72
72
  }) },
73
73
  react_1.default.createElement("div", { style: iconStyle, onClick: toggleDropdown },
74
74
  react_1.default.createElement("i", { className: "fas fa-layer-group fa-fw" })),
75
- dropdownOpen ? (react_1.default.createElement("div", { style: { backgroundColor: "white", padding: 5 } }, props.design.layerViews.map(renderLayerView))) : null));
75
+ dropdownOpen ? (react_1.default.createElement("div", { style: { backgroundColor: "white", padding: 5, textAlign: "left" } }, props.design.layerViews.map(renderLayerView))) : null));
76
76
  }
77
77
  exports.LayerSwitcherComponent = LayerSwitcherComponent;
78
78
  /** Hook for click outside catching */
@@ -1,5 +1,6 @@
1
1
  import PropTypes from "prop-types";
2
2
  import React, { ReactNode } from "react";
3
+ import AutoSizeComponent from "@mwater/react-library/lib/AutoSizeComponent";
3
4
  import UndoStack from "../UndoStack";
4
5
  import { DataSource, Schema } from "@mwater/expressions";
5
6
  import { MapDataSource } from "./MapDataSource";
@@ -60,13 +61,7 @@ export default class MapComponent extends React.Component<MapComponentProps, Map
60
61
  getDesign(): MapDesign;
61
62
  handleToggleDesignPanel: () => void;
62
63
  getQuickfilterValues: () => any[];
63
- renderView(): React.CElement<{
64
- injectWidth: boolean;
65
- injectHeight: boolean;
66
- }, React.Component<{
67
- injectWidth: boolean;
68
- injectHeight: boolean;
69
- }, any, any>>;
64
+ renderView(): React.CElement<import("@mwater/react-library/lib/AutoSizeComponent").AutoSizeComponentProps, AutoSizeComponent>;
70
65
  getCompiledFilters(): {
71
66
  table: string;
72
67
  jsonql: import("@mwater/jsonql").JsonQLExpr;