@mwater/visualization 5.0.1 → 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.
- package/lib/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/MWaterAddRelatedFormComponent.d.ts +1 -1
- package/lib/MWaterAddRelatedFormComponent.js +10 -17
- package/lib/MWaterCompleteTableSelectComponent.d.ts +2 -9
- package/lib/MWaterContextComponent.d.ts +31 -9
- package/lib/MWaterContextComponent.js +85 -76
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +14 -4
- package/lib/MWaterLoaderComponent.js +10 -2
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +20 -41
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.js +9 -7
- package/lib/axes/AxisComponent.d.ts +4 -4
- package/lib/axes/RangesComponent.d.ts +12 -6
- package/lib/axes/RangesComponent.js +21 -10
- package/lib/dashboards/DashboardComponent.d.ts +1 -14
- package/lib/dashboards/DashboardComponent.js +18 -56
- package/lib/dashboards/DashboardDesign.d.ts +2 -17
- package/lib/dashboards/DashboardViewComponent.js +3 -4
- package/lib/dashboards/LayoutOptionsComponent.js +4 -3
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -0
- package/lib/dashboards/ServerDashboardDataSource.js +3 -0
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/datagrids/DatagridComponent.d.ts +10 -13
- package/lib/datagrids/DatagridComponent.js +27 -5
- package/lib/datagrids/DatagridDataSource.d.ts +3 -2
- package/lib/datagrids/DatagridDataSource.js +0 -11
- package/lib/datagrids/DatagridDesign.d.ts +2 -0
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +11 -8
- package/lib/datagrids/DatagridViewComponent.js +2 -2
- package/lib/datagrids/DirectDatagridDataSource.d.ts +1 -0
- package/lib/datagrids/DirectDatagridDataSource.js +26 -0
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +2 -1
- package/lib/datagrids/ServerDatagridDataSource.js +16 -3
- package/lib/demo.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -4
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +2 -1
- package/lib/layouts/blocks/BlocksDisplayComponent.js +2 -2
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/layouts/grid/LegoLayoutEngine.d.ts +1 -1
- package/lib/maps/BufferLayer.js +3 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayerDesigner.js +2 -2
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/ClusterLayerDesignerComponent.js +2 -2
- package/lib/maps/DirectMapDataSource.js +1 -2
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +2 -3
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +2 -7
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapDesignerComponent.d.ts +1 -12
- package/lib/maps/MapDesignerComponent.js +5 -12
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayerDesignerComponent.js +2 -2
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -1
- package/lib/maps/PopupFilterJoinsUtils.js +4 -3
- package/lib/maps/RasterMapViewComponent.d.ts +2 -9
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +1 -1
- package/lib/maps/UtfGridLayer.js +1 -1
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +10 -2
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/widgets/IFrameWidgetComponent.d.ts +2 -9
- package/lib/widgets/ImageWidgetComponent.d.ts +6 -24
- package/lib/widgets/ImageWidgetComponent.js +2 -2
- package/lib/widgets/MapWidget.d.ts +2 -7
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/charts/ChartWidget.d.ts +3 -15
- package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +1 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +2 -31
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -2
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +73 -66
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +10 -6
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +3 -22
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/table/TableChartViewComponent.js +21 -7
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprItemEditorComponent.js +2 -2
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextWidgetDesign.d.ts +3 -1
- package/package.json +1 -1
- package/src/GlobalFilter.ts +17 -0
- package/src/MWaterAddRelatedFormComponent.ts +15 -20
- package/src/MWaterContextComponent.tsx +158 -0
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +10 -3
- package/src/{MWaterTableSelectComponent.ts → MWaterTableSelectComponent.tsx} +61 -66
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +10 -9
- package/src/axes/RangesComponent.ts +27 -16
- package/src/dashboards/{DashboardComponent.ts → DashboardComponent.tsx} +39 -80
- package/src/dashboards/DashboardDesign.ts +2 -22
- package/src/dashboards/DashboardViewComponent.ts +4 -5
- package/src/dashboards/LayoutOptionsComponent.tsx +6 -4
- package/src/dashboards/ServerDashboardDataSource.ts +16 -12
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/datagrids/DatagridComponent.ts +45 -14
- package/src/datagrids/DatagridDataSource.ts +10 -8
- package/src/datagrids/DatagridDesign.ts +3 -0
- package/src/datagrids/DatagridDesignerComponent.tsx +31 -19
- package/src/datagrids/DatagridViewComponent.ts +4 -4
- package/src/datagrids/DirectDatagridDataSource.ts +35 -0
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +23 -6
- package/src/demo.ts +1 -1
- package/src/index.ts +1 -2
- package/src/layouts/blocks/BlocksDisplayComponent.ts +2 -2
- package/src/layouts/grid/LegoLayoutEngine.ts +2 -2
- package/src/layouts/grid/WidgetContainerComponent.ts +2 -2
- package/src/maps/BingLayer.ts +2 -2
- package/src/maps/BufferLayer.ts +3 -1
- package/src/maps/BufferLayerDesignerComponent.ts +1 -1
- package/src/maps/ChoroplethLayerDesigner.tsx +1 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/ClusterLayerDesignerComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +1 -2
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +1 -2
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/LegendGroup.ts +1 -1
- package/src/maps/MWaterServerLayer.ts +2 -2
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapDesignerComponent.ts → MapDesignerComponent.tsx} +8 -16
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayerDesignerComponent.ts +1 -1
- package/src/maps/PopupFilterJoinsUtils.ts +4 -4
- package/src/maps/ServerMapDataSource.ts +7 -7
- package/src/maps/SwitchableTileUrlLayerDesigner.tsx +1 -13
- package/src/maps/UtfGridLayer.ts +4 -4
- package/src/maps/VectorMapViewComponent.tsx +0 -1
- package/src/maps/mapboxUtils.ts +2 -2
- package/src/maps/vectorMaps.tsx +10 -1
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/richtext/ExprItemsHtmlConverter.ts +1 -1
- package/src/richtext/FontColorPaletteItem.ts +1 -1
- package/src/richtext/FontSizePaletteItem.ts +1 -1
- package/src/richtext/ItemsHtmlConverter.ts +2 -2
- package/src/widgets/ImageWidgetComponent.ts +1 -1
- package/src/widgets/charts/calendar/CalendarChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +1 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +1 -1
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +1 -1
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +1 -1
- package/src/widgets/charts/table/TableChartViewComponent.ts +21 -7
- package/src/widgets/text/ExprItemEditorComponent.tsx +1 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -1
- package/src/MWaterContextComponent.ts +0 -141
- package/src/TableSelectComponent.ts +0 -60
- package/src/dashboards/SettingsModalComponent.ts +0 -169
|
@@ -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";
|
|
@@ -30,7 +31,7 @@ export interface DatagridComponentProps {
|
|
|
30
31
|
quickfilterLocks?: any[];
|
|
31
32
|
filters?: JsonQLFilter[];
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
interface DatagridComponentState {
|
|
34
35
|
/** is design being edited */
|
|
35
36
|
editingDesign: boolean;
|
|
36
37
|
/** True if cells can be edited directly */
|
|
@@ -39,14 +40,18 @@ export default class DatagridComponent extends React.Component<DatagridComponent
|
|
|
39
40
|
quickfiltersHeight: number | null;
|
|
40
41
|
quickfiltersValues: null | any[];
|
|
41
42
|
refreshKey: number;
|
|
42
|
-
|
|
43
|
+
/** Number of rows */
|
|
44
|
+
numRows?: number;
|
|
45
|
+
}
|
|
46
|
+
export default class DatagridComponent extends React.Component<DatagridComponentProps, DatagridComponentState> {
|
|
43
47
|
datagridView?: DatagridViewComponent | null;
|
|
44
48
|
quickfilters?: HTMLElement | null;
|
|
45
49
|
findReplaceModal: FindReplaceModalComponent | null;
|
|
46
50
|
constructor(props: DatagridComponentProps);
|
|
47
|
-
reload(): void
|
|
51
|
+
reload(): void;
|
|
48
52
|
componentDidMount(): void;
|
|
49
|
-
componentDidUpdate(): void;
|
|
53
|
+
componentDidUpdate(prevProps: DatagridComponentProps, prevState: DatagridComponentState): void;
|
|
54
|
+
loadRowCount(): void;
|
|
50
55
|
handleRefreshData: () => void;
|
|
51
56
|
updateHeight(): void;
|
|
52
57
|
getQuickfilterValues: () => any[];
|
|
@@ -111,14 +116,6 @@ declare class DatagridEditorComponent extends React.Component<DatagridEditorComp
|
|
|
111
116
|
design: DatagridDesign;
|
|
112
117
|
}> {
|
|
113
118
|
constructor(props: DatagridEditorComponentProps);
|
|
114
|
-
render(): React.CElement<
|
|
115
|
-
onAction: () => void;
|
|
116
|
-
onCancel: () => void;
|
|
117
|
-
size: string;
|
|
118
|
-
}, React.Component<{
|
|
119
|
-
onAction: () => void;
|
|
120
|
-
onCancel: () => void;
|
|
121
|
-
size: string;
|
|
122
|
-
}, any, any>>;
|
|
119
|
+
render(): React.CElement<import("@mwater/react-library/lib/ActionCancelModalComponent").ActionCancelModalComponentProps, ActionCancelModalComponent>;
|
|
123
120
|
}
|
|
124
121
|
export {};
|
|
@@ -17,6 +17,7 @@ const DatagridUtils_1 = __importDefault(require("./DatagridUtils"));
|
|
|
17
17
|
const QuickfiltersComponent_1 = __importDefault(require("../quickfilter/QuickfiltersComponent"));
|
|
18
18
|
const QuickfilterCompiler_1 = __importDefault(require("../quickfilter/QuickfilterCompiler"));
|
|
19
19
|
const FindReplaceModalComponent_1 = __importDefault(require("./FindReplaceModalComponent"));
|
|
20
|
+
const d3_format_1 = require("d3-format");
|
|
20
21
|
// Datagrid with decorations
|
|
21
22
|
// See README.md for description of datagrid format
|
|
22
23
|
// Design should be cleaned already before being passed in (see DatagridUtils)
|
|
@@ -35,13 +36,34 @@ class DatagridComponent extends react_1.default.Component {
|
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
reload() {
|
|
38
|
-
|
|
39
|
+
this.datagridView?.reload();
|
|
39
40
|
}
|
|
40
41
|
componentDidMount() {
|
|
41
|
-
|
|
42
|
+
this.loadRowCount();
|
|
43
|
+
this.updateHeight();
|
|
42
44
|
}
|
|
43
|
-
componentDidUpdate() {
|
|
44
|
-
|
|
45
|
+
componentDidUpdate(prevProps, prevState) {
|
|
46
|
+
if (!lodash_1.default.isEqual(prevProps.design, this.props.design) || !lodash_1.default.isEqual(prevState.quickfiltersValues, this.state.quickfiltersValues) || prevState.refreshKey !== this.state.refreshKey) {
|
|
47
|
+
this.loadRowCount();
|
|
48
|
+
}
|
|
49
|
+
this.updateHeight();
|
|
50
|
+
}
|
|
51
|
+
loadRowCount() {
|
|
52
|
+
if (!this.props.design.showNumRows) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let filters = this.props.filters || [];
|
|
56
|
+
// Compile quickfilters
|
|
57
|
+
filters = filters.concat(this.getQuickfilterFilters());
|
|
58
|
+
this.props.datagridDataSource.countRows(this.props.design, filters, (error, numRows) => {
|
|
59
|
+
if (error) {
|
|
60
|
+
console.error(error);
|
|
61
|
+
alert(T("Error loading data"));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
console.log(numRows);
|
|
65
|
+
this.setState({ numRows });
|
|
66
|
+
});
|
|
45
67
|
}
|
|
46
68
|
handleRefreshData = () => {
|
|
47
69
|
this.props.dataSource.clearCache?.();
|
|
@@ -164,7 +186,7 @@ class DatagridComponent extends react_1.default.Component {
|
|
|
164
186
|
}, T("Find/Replace"));
|
|
165
187
|
}
|
|
166
188
|
renderTitleBar() {
|
|
167
|
-
return R("div", { style: { position: "absolute", top: 0, left: 0, right: 0, height: 40, padding: 4 } }, R("div", { style: { float: "right" } }, this.renderFindReplace(), this.renderCellEdit(), this.renderEditButton(), R("a", { key: "refresh", className: "btn btn-link btn-sm", onClick: this.handleRefreshData }, R("span", { className: "fas fa-sync" }), R("span", { className: "hide-600px" }, " Refresh")), this.props.extraTitleButtonsElem), this.props.titleElem);
|
|
189
|
+
return R("div", { style: { position: "absolute", top: 0, left: 0, right: 0, height: 40, padding: 4 } }, R("div", { style: { float: "right" } }, this.props.design.showNumRows && this.state.numRows ? R("small", { className: 'text-muted text-sm' }, `${(0, d3_format_1.format)(',')(this.state.numRows)} rows`) : undefined, this.renderFindReplace(), this.renderCellEdit(), this.renderEditButton(), R("a", { key: "refresh", className: "btn btn-link btn-sm", onClick: this.handleRefreshData }, R("span", { className: "fas fa-sync" }), R("span", { className: "hide-600px" }, " Refresh")), this.props.extraTitleButtonsElem), this.props.titleElem);
|
|
168
190
|
}
|
|
169
191
|
renderQuickfilter() {
|
|
170
192
|
return R("div", {
|
|
@@ -1,9 +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
|
|
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
|
|
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;
|
|
7
8
|
/** Gets the quickfilters data source */
|
|
8
9
|
getQuickfiltersDataSource(): QuickfiltersDataSource;
|
|
9
10
|
}
|
|
@@ -1,13 +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
|
-
/** Gets the quickfilters data source */
|
|
9
|
-
getQuickfiltersDataSource() {
|
|
10
|
-
throw new Error("Not implemented");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.default = DatagridDataSource;
|
|
@@ -23,6 +23,8 @@ export interface DatagridDesign {
|
|
|
23
23
|
showRowNumbers?: boolean;
|
|
24
24
|
/** array of global filters. See below. */
|
|
25
25
|
globalFilters?: DatagridDesignGlobalFilter[];
|
|
26
|
+
/** true to show number of rows */
|
|
27
|
+
showNumRows?: boolean;
|
|
26
28
|
}
|
|
27
29
|
export interface DatagridDesignColumn {
|
|
28
30
|
/** unique id of the column */
|
|
@@ -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
|
|
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;
|
|
@@ -41,15 +40,15 @@ const OrderBysDesignerComponent_1 = __importDefault(require("./OrderBysDesignerC
|
|
|
41
40
|
const ReorderableListComponent_1 = __importDefault(require("@mwater/react-library/lib/reorderable/ReorderableListComponent"));
|
|
42
41
|
const QuickfiltersDesignComponent_1 = __importDefault(require("../quickfilter/QuickfiltersDesignComponent"));
|
|
43
42
|
const LabeledExprGenerator_1 = __importDefault(require("./LabeledExprGenerator"));
|
|
44
|
-
const
|
|
43
|
+
const expressions_ui_3 = require("@mwater/expressions-ui");
|
|
45
44
|
const uuid_1 = __importDefault(require("uuid"));
|
|
46
45
|
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
|
-
}),
|
|
99
|
-
? R("div", { style: { marginTop: 20 } },
|
|
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",
|
|
@@ -140,7 +139,7 @@ class DatagridDesignerComponent extends react_1.default.Component {
|
|
|
140
139
|
});
|
|
141
140
|
}
|
|
142
141
|
render() {
|
|
143
|
-
return R("div", null, R("label", null, T("Data Source:")), R(
|
|
142
|
+
return R("div", null, R("label", null, T("Data Source:")), R(expressions_ui_3.TableSelectComponent, {
|
|
144
143
|
schema: this.props.schema,
|
|
145
144
|
value: this.props.design.table,
|
|
146
145
|
onChange: this.handleTableChange
|
|
@@ -158,6 +157,7 @@ function DatagridOptionsComponent(props) {
|
|
|
158
157
|
}, []);
|
|
159
158
|
return react_1.default.createElement("div", null,
|
|
160
159
|
react_1.default.createElement(ui.Checkbox, { value: props.design.showRowNumbers, onChange: (showRowNumbers) => props.onDesignChange({ ...props.design, showRowNumbers }) }, T("Show row numbers")),
|
|
160
|
+
react_1.default.createElement(ui.Checkbox, { value: props.design.showNumRows, onChange: (showNumRows) => props.onDesignChange({ ...props.design, showNumRows }) }, T("Show number of rows")),
|
|
161
161
|
react_1.default.createElement(ui.FormGroup, { label: T("Language"), hint: T("Preferred language of the datagrid") },
|
|
162
162
|
react_1.default.createElement(react_select_1.default, { value: localeOptions.find(opt => opt.value == (props.design.locale || "en")) || null, options: localeOptions, onChange: (locale) => props.onDesignChange({ ...props.design, locale: locale.value }) })));
|
|
163
163
|
}
|
|
@@ -377,7 +377,10 @@ class ColumnDesignerComponent extends react_1.default.Component {
|
|
|
377
377
|
aggrStatuses: ["literal", "individual", "aggregate"],
|
|
378
378
|
types: allowedTypes,
|
|
379
379
|
onChange: this.handleExprChange
|
|
380
|
-
}), this.renderSplit(), this.renderFormat(), error ?
|
|
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", {
|
|
381
384
|
type: "text",
|
|
382
385
|
className: "form-control",
|
|
383
386
|
placeholder: exprUtils.summarizeExpr(this.props.column.expr),
|
|
@@ -32,7 +32,7 @@ class DatagridViewComponent extends react_1.default.Component {
|
|
|
32
32
|
// If design or filters changed, delete all rows
|
|
33
33
|
// TODO won't this reload on column resize?
|
|
34
34
|
if (!lodash_1.default.isEqual(nextProps.design, this.props.design) || !lodash_1.default.isEqual(nextProps.filters, this.props.filters) || nextProps.refreshKey !== this.props.refreshKey) {
|
|
35
|
-
|
|
35
|
+
this.setState({ rows: [], entirelyLoaded: false });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
// Loads more rows because the placeholder last row has been rendered
|
|
@@ -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]
|
|
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
|
};
|
|
@@ -14,6 +14,7 @@ export default class DirectDatagridDataSource implements DatagridDataSource {
|
|
|
14
14
|
});
|
|
15
15
|
/** Gets the rows specified */
|
|
16
16
|
getRows(design: DatagridDesign, offset: number, limit: number, filters: JsonQLFilter[] | undefined, callback: (error: any, rows: Row[]) => void): void;
|
|
17
|
+
countRows(design: DatagridDesign, filters: JsonQLFilter[] | undefined, callback: (error: any, numRows: number) => void): void;
|
|
17
18
|
getQuickfiltersDataSource(): {
|
|
18
19
|
getValues: (index: any, expr: any, filters: any, offset: any, limit: any, callback: any) => void;
|
|
19
20
|
};
|
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const DatagridQueryBuilder_1 = __importDefault(require("./DatagridQueryBuilder"));
|
|
30
30
|
const QuickfilterUtils = __importStar(require("../quickfilter/QuickfilterUtils"));
|
|
31
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
31
32
|
/** Uses direct DataSource queries */
|
|
32
33
|
class DirectDatagridDataSource {
|
|
33
34
|
options;
|
|
@@ -49,6 +50,31 @@ class DirectDatagridDataSource {
|
|
|
49
50
|
});
|
|
50
51
|
return this.options.dataSource.performQuery(query, callback);
|
|
51
52
|
}
|
|
53
|
+
countRows(design, filters, callback) {
|
|
54
|
+
const queryBuilder = new DatagridQueryBuilder_1.default(this.options.schema);
|
|
55
|
+
// Create query to get the page of rows at the specific offset
|
|
56
|
+
const query = queryBuilder.createQuery(design, {
|
|
57
|
+
extraFilters: filters
|
|
58
|
+
});
|
|
59
|
+
const countQuery = {
|
|
60
|
+
...lodash_1.default.omit(query, 'orderBy'),
|
|
61
|
+
selects: [
|
|
62
|
+
{
|
|
63
|
+
type: 'select',
|
|
64
|
+
expr: {
|
|
65
|
+
type: 'op',
|
|
66
|
+
op: 'count',
|
|
67
|
+
exprs: []
|
|
68
|
+
},
|
|
69
|
+
alias: 'cnt'
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
console.log(countQuery);
|
|
74
|
+
return this.options.dataSource.performQuery(countQuery, (error, rows) => {
|
|
75
|
+
callback(error, rows?.[0]?.cnt);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
52
78
|
// Gets the quickfilters data source
|
|
53
79
|
getQuickfiltersDataSource() {
|
|
54
80
|
return {
|
|
@@ -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<
|
|
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:
|
|
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 = {
|
|
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 =
|
|
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,
|
|
177
|
-
const replaceColumnOptions = lodash_1.default.map(replaceColumns,
|
|
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:
|
|
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:
|
|
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:
|
|
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,10 +14,11 @@ 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
|
|
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>;
|
|
21
|
+
countRows(design: DatagridDesign, filters: any, callback: any): JQuery.jqXHR<any>;
|
|
21
22
|
getQuickfiltersDataSource(): ServerQuickfilterDataSource;
|
|
22
23
|
}
|
|
23
24
|
interface ServerQuickfilterDataSourceOptions {
|
|
@@ -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
|
|
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
|
|
@@ -40,6 +38,21 @@ class ServerDatagridDataSource extends DatagridDataSource_1.default {
|
|
|
40
38
|
return callback(new Error(xhr.responseText));
|
|
41
39
|
});
|
|
42
40
|
}
|
|
41
|
+
countRows(design, filters, callback) {
|
|
42
|
+
const query = {
|
|
43
|
+
client: this.options.client,
|
|
44
|
+
share: this.options.share,
|
|
45
|
+
filters: (0, compressJson_1.default)(filters),
|
|
46
|
+
rev: this.options.rev,
|
|
47
|
+
};
|
|
48
|
+
const url = this.options.apiUrl + `datagrids/${this.options.datagridId}/summary?` + querystring_1.default.stringify(query);
|
|
49
|
+
return jquery_1.default.getJSON(url, (data) => {
|
|
50
|
+
return callback(null, data?.[0]?.cnt);
|
|
51
|
+
}).fail((xhr) => {
|
|
52
|
+
console.log(xhr.responseText);
|
|
53
|
+
return callback(new Error(xhr.responseText));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
43
56
|
getQuickfiltersDataSource() {
|
|
44
57
|
return new ServerQuickfilterDataSource(this.options);
|
|
45
58
|
}
|
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 + "
|
|
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
|
@@ -2,7 +2,6 @@ export { default as LeafletMapComponent, MapBounds, TileLayer, GeoJsonLayer, Map
|
|
|
2
2
|
export { default as DateRangeComponent } from "./DateRangeComponent";
|
|
3
3
|
export { default as RegionSelectComponent } from "./maps/RegionSelectComponent";
|
|
4
4
|
export * from "./datagrids/DatagridDesign";
|
|
5
|
-
export { default as TableSelectComponent } from "./TableSelectComponent";
|
|
6
5
|
export * from "./JsonQLFilter";
|
|
7
6
|
export { default as DashboardComponent } from "./dashboards/DashboardComponent";
|
|
8
7
|
export { default as DashboardDataSource } from "./dashboards/DashboardDataSource";
|
|
@@ -52,6 +51,7 @@ export { default as AxisBuilder } from "./axes/AxisBuilder";
|
|
|
52
51
|
export { default as ColorSchemeFactory } from "./ColorSchemeFactory";
|
|
53
52
|
export { default as DatagridComponent } from "./datagrids/DatagridComponent";
|
|
54
53
|
export { default as DatagridViewComponent } from "./datagrids/DatagridViewComponent";
|
|
54
|
+
export { default as DatagridDataSource } from "./datagrids/DatagridDataSource";
|
|
55
55
|
export { default as ServerDashboardDataSource } from "./dashboards/ServerDashboardDataSource";
|
|
56
56
|
export { default as ServerMapDataSource } from "./maps/ServerMapDataSource";
|
|
57
57
|
export { default as DirectMapDataSource } from "./maps/DirectMapDataSource";
|