dtable-statistic 4.0.2-test-2
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/README.md +3 -0
- package/es/api/dtable-db-api.js +43 -0
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/color-theme-dialog.css +40 -0
- package/es/assets/css/dashboard.css +562 -0
- package/es/assets/css/dialog.css +415 -0
- package/es/assets/css/mobile-dashboard.module.css +91 -0
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/assets/css/theme.css +61 -0
- package/es/assets/images/icon.png +0 -0
- package/es/calculator/base-calculator.js +111 -0
- package/es/calculator/basic-chart-calculator.js +571 -0
- package/es/calculator/combination-calculator.js +296 -0
- package/es/calculator/compare-bar-calculator.js +291 -0
- package/es/calculator/completeness-calculator.js +307 -0
- package/es/calculator/copy-value.js +47 -0
- package/es/calculator/dashboard-calculator.js +146 -0
- package/es/calculator/heat-map-calculator.js +225 -0
- package/es/calculator/horizontal-bar-calculator.js +100 -0
- package/es/calculator/index.js +88 -0
- package/es/calculator/map-calculator.js +169 -0
- package/es/calculator/mirror-calculator.js +217 -0
- package/es/calculator/number-card-calculator.js +135 -0
- package/es/calculator/pivot-table-calculator.js +810 -0
- package/es/calculator/scatter-calculator.js +150 -0
- package/es/calculator/thread-manager.js +70 -0
- package/es/calculator/trend-calculator.js +204 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
- package/es/calculator/workers/calculator.worker.js +22 -0
- package/es/calculator/workers/card-calculator-worker.js +28 -0
- package/es/calculator/workers/combination-calculator-worker.js +257 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
- package/es/calculator/workers/completeness-calculator-worker.js +153 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
- package/es/calculator/workers/mirror-calculator-worker.js +132 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
- package/es/calculator/workers/scatter-calculator-worker.js +67 -0
- package/es/calculator/workers/trend-calculator-worker.js +93 -0
- package/es/calculator/world-map-calculator.js +193 -0
- package/es/components/common-add-tool.js +19 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
- package/es/components/dialog/color-theme-dialog.js +71 -0
- package/es/components/dialog/enlarged-chart-dialog.js +73 -0
- package/es/components/dialog/new-table-dialog.js +113 -0
- package/es/components/dialog/new-view-dialog.js +87 -0
- package/es/components/dialog/rename-view-dialog.js +87 -0
- package/es/components/dialog/statistic-record-dialog/index.css +114 -0
- package/es/components/dialog/statistic-record-dialog/index.js +174 -0
- package/es/components/dialog/table-select-dialog.js +93 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
- package/es/components/dtable-popover.js +109 -0
- package/es/components/dtable-search-input.js +137 -0
- package/es/components/dtable-select.js +104 -0
- package/es/components/index.js +11 -0
- package/es/components/loading.js +8 -0
- package/es/components/modal-portal.js +36 -0
- package/es/components/popover/color-rules/color-rule.js +179 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
- package/es/components/popover/color-rules/rule-filters/index.css +214 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
- package/es/components/popover/color-rules-popover.js +213 -0
- package/es/components/popover/color-selector-popover.js +85 -0
- package/es/components/seatable-radio/index.css +51 -0
- package/es/components/seatable-radio/index.js +28 -0
- package/es/components/select/index.js +2 -0
- package/es/components/select/option-group.css +104 -0
- package/es/components/select/option-group.js +225 -0
- package/es/components/select/option.js +51 -0
- package/es/components/select/select.css +211 -0
- package/es/components/select/select.js +157 -0
- package/es/components/toast/alert.js +130 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +164 -0
- package/es/components/toast/toastManager.js +150 -0
- package/es/components/toast/toaster.js +64 -0
- package/es/constants/color-rules.js +8 -0
- package/es/constants/dtable-select-style.js +61 -0
- package/es/constants/event-types.js +1 -0
- package/es/constants/index.js +501 -0
- package/es/constants/key-codes.js +102 -0
- package/es/constants/zIndexes.js +1 -0
- package/es/custom-g2.js +614 -0
- package/es/dashboard.js +408 -0
- package/es/desktop-dashboard.js +299 -0
- package/es/index.js +33 -0
- package/es/locale/index.js +17 -0
- package/es/locale/lang/de.js +237 -0
- package/es/locale/lang/en.js +237 -0
- package/es/locale/lang/fr.js +237 -0
- package/es/locale/lang/zh_CN.js +237 -0
- package/es/mobile-dashboard.js +103 -0
- package/es/model/collaborators.js +11 -0
- package/es/model/stat-item.js +340 -0
- package/es/model/statistic-dashboard.js +8 -0
- package/es/service/chart-service.js +192 -0
- package/es/service/dashboard-service.js +415 -0
- package/es/stat-editor/chart-name-editor.js +75 -0
- package/es/stat-editor/index.js +74 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
- package/es/stat-list/chart-preview.js +139 -0
- package/es/stat-list/index.js +275 -0
- package/es/stat-view/area-chart.js +521 -0
- package/es/stat-view/bar-chart.js +568 -0
- package/es/stat-view/base-chart.js +44 -0
- package/es/stat-view/basic-number-card.js +255 -0
- package/es/stat-view/combination-chart.js +558 -0
- package/es/stat-view/compare-chart.js +485 -0
- package/es/stat-view/completeness-chart.js +389 -0
- package/es/stat-view/custom-bar.js +433 -0
- package/es/stat-view/dashboard-chart.js +317 -0
- package/es/stat-view/heat-map.js +501 -0
- package/es/stat-view/horizontal-bar-chart.js +569 -0
- package/es/stat-view/index.js +183 -0
- package/es/stat-view/line-chart.js +505 -0
- package/es/stat-view/map.js +428 -0
- package/es/stat-view/mirror.js +285 -0
- package/es/stat-view/pie-chart.js +326 -0
- package/es/stat-view/pivot-table/index.js +206 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
- package/es/stat-view/ring-chart.js +416 -0
- package/es/stat-view/scatter-chart.js +367 -0
- package/es/stat-view/treemap-chart.js +318 -0
- package/es/stat-view/trend-chart.js +299 -0
- package/es/stat-view/world-map.js +443 -0
- package/es/tabs/index.js +252 -0
- package/es/tabs/statistic-tabs.module.css +154 -0
- package/es/tabs/tab.js +167 -0
- package/es/utils/basic-chart-utils.js +24 -0
- package/es/utils/cell-format.js +110 -0
- package/es/utils/cell-value.js +27 -0
- package/es/utils/collaborator.js +31 -0
- package/es/utils/color-utils.js +112 -0
- package/es/utils/column-utils.js +18 -0
- package/es/utils/column.js +13 -0
- package/es/utils/common-utils.js +303 -0
- package/es/utils/date-format.js +65 -0
- package/es/utils/export-table-utils.js +632 -0
- package/es/utils/index.js +26 -0
- package/es/utils/object.js +26 -0
- package/es/utils/row-utils.js +115 -0
- package/es/utils/search.js +67 -0
- package/es/utils/sql-utils.js +293 -0
- package/es/utils/stat-utils.js +353 -0
- package/es/utils/trend-utils.js +136 -0
- package/index.js +1 -0
- package/package.json +188 -0
package/es/dashboard.js
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import React, { Component } from 'react';
|
|
8
|
+
import intl from 'react-intl-universal';
|
|
9
|
+
import { TableUtils, Views } from 'dtable-store';
|
|
10
|
+
import StatisticDashBoard from './model/statistic-dashboard';
|
|
11
|
+
import StatItem from './model/stat-item';
|
|
12
|
+
import DashBoardService from './service/dashboard-service';
|
|
13
|
+
import DesktopDashboard from './desktop-dashboard';
|
|
14
|
+
import MobileDashboard from './mobile-dashboard';
|
|
15
|
+
import ThreadManager from './calculator/thread-manager';
|
|
16
|
+
import ChartCalculator from './calculator';
|
|
17
|
+
import { isMobile } from './utils';
|
|
18
|
+
import { generatorUniqueId } from './utils/common-utils';
|
|
19
|
+
import { DASHBOARD_ACTION_TYPE, KEY_SELECTED_DASHBOARD, LABEL_COLORS } from './constants';
|
|
20
|
+
import './locale';
|
|
21
|
+
import './assets/css/dashboard.css';
|
|
22
|
+
import './assets/css/theme.css';
|
|
23
|
+
import './assets/css/dialog.css';
|
|
24
|
+
var DashBoard = /*#__PURE__*/function (_Component) {
|
|
25
|
+
_inherits(DashBoard, _Component);
|
|
26
|
+
var _super = _createSuper(DashBoard);
|
|
27
|
+
function DashBoard(props) {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, DashBoard);
|
|
30
|
+
_this = _super.call(this, props);
|
|
31
|
+
_this.onDTableDataChange = function (value) {
|
|
32
|
+
_this.clearCalculations();
|
|
33
|
+
var _this$initDashboard = _this.initDashboard({
|
|
34
|
+
value: value
|
|
35
|
+
}),
|
|
36
|
+
statistics = _this$initDashboard.statistics,
|
|
37
|
+
selectedDashboardIdx = _this$initDashboard.selectedDashboardIdx;
|
|
38
|
+
_this.setState({
|
|
39
|
+
statistics: statistics,
|
|
40
|
+
selectedDashboardIdx: selectedDashboardIdx,
|
|
41
|
+
refresh: true
|
|
42
|
+
}, function () {
|
|
43
|
+
setTimeout(function () {
|
|
44
|
+
_this.setState({
|
|
45
|
+
refresh: false
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
_this.initDashboard = function (_ref) {
|
|
51
|
+
var value = _ref.value;
|
|
52
|
+
var _window$dtable = window.dtable,
|
|
53
|
+
username = _window$dtable.username,
|
|
54
|
+
userId = _window$dtable.userId;
|
|
55
|
+
_this.chartCalculator = new ChartCalculator({
|
|
56
|
+
username: username,
|
|
57
|
+
userId: userId,
|
|
58
|
+
value: value,
|
|
59
|
+
statisticThreadManager: _this.statisticThreadManager
|
|
60
|
+
});
|
|
61
|
+
_this.dashboardService = new DashBoardService({
|
|
62
|
+
value: value,
|
|
63
|
+
defaultDashboardName: _this.defaultDashboardName,
|
|
64
|
+
chartCalculator: _this.chartCalculator,
|
|
65
|
+
updateStatistics: _this.props.updateStatistics,
|
|
66
|
+
deletePluginSettings: _this.props.deletePluginSettings
|
|
67
|
+
});
|
|
68
|
+
_this.initLabelColorConfigs(value);
|
|
69
|
+
var statistics = _this.dashboardService.getStatistics();
|
|
70
|
+
var selectedDashboardIdx = _this.getSelectedDashboardIdxFromLocal(KEY_SELECTED_DASHBOARD) || 0;
|
|
71
|
+
if (!statistics[selectedDashboardIdx]) {
|
|
72
|
+
selectedDashboardIdx = 0;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
statistics: statistics,
|
|
76
|
+
selectedDashboardIdx: selectedDashboardIdx
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
_this.initLabelColorConfigs = function (value) {
|
|
80
|
+
var systemCustomColors = window.dtable.customColors || [];
|
|
81
|
+
var baseSettings = value && value.settings;
|
|
82
|
+
var baseCustomColors = baseSettings && baseSettings.custom_colors || [];
|
|
83
|
+
_this.labelColorConfigs = [].concat(_toConsumableArray(LABEL_COLORS.map(function (color) {
|
|
84
|
+
return {
|
|
85
|
+
color: color.toUpperCase(),
|
|
86
|
+
text_color: '#fff'
|
|
87
|
+
};
|
|
88
|
+
})), _toConsumableArray(systemCustomColors.map(function (customColor) {
|
|
89
|
+
return _objectSpread(_objectSpread({}, customColor), {}, {
|
|
90
|
+
color: customColor.color.toUpperCase()
|
|
91
|
+
});
|
|
92
|
+
})), _toConsumableArray(baseCustomColors.map(function (customColor) {
|
|
93
|
+
return {
|
|
94
|
+
color: customColor.COLOR.toUpperCase(),
|
|
95
|
+
text_color: customColor.TEXT_COLOR,
|
|
96
|
+
border_color: customColor.BORDER_COLOR
|
|
97
|
+
};
|
|
98
|
+
})));
|
|
99
|
+
};
|
|
100
|
+
_this.clearCalculations = function () {
|
|
101
|
+
_this.statisticThreadManager.clearQueue();
|
|
102
|
+
_this.statisticThreadManager.terminateWorkers();
|
|
103
|
+
};
|
|
104
|
+
_this.getSelectedDashboardIdxFromLocal = function (key) {
|
|
105
|
+
var dtableUuid = window.dtable.dtableUuid;
|
|
106
|
+
var selectedViewIdsString = window.localStorage.getItem(key);
|
|
107
|
+
var selectedViewIds = selectedViewIdsString ? JSON.parse(selectedViewIdsString) : {};
|
|
108
|
+
return selectedViewIds[dtableUuid];
|
|
109
|
+
};
|
|
110
|
+
_this.setSelectedDashboardIdx = function (index) {
|
|
111
|
+
var dtableUuid = window.dtable.dtableUuid;
|
|
112
|
+
var selectedViewIdsString = window.localStorage.getItem(KEY_SELECTED_DASHBOARD);
|
|
113
|
+
var selectedViewIds = selectedViewIdsString ? JSON.parse(selectedViewIdsString) : {};
|
|
114
|
+
selectedViewIds[dtableUuid] = index;
|
|
115
|
+
localStorage.setItem(KEY_SELECTED_DASHBOARD, JSON.stringify(selectedViewIds));
|
|
116
|
+
};
|
|
117
|
+
_this.getActiveTable = function () {
|
|
118
|
+
var _this$props = _this.props,
|
|
119
|
+
value = _this$props.value,
|
|
120
|
+
activeTableIdx = _this$props.activeTableIdx;
|
|
121
|
+
return TableUtils.getTableByIndex(value.tables, activeTableIdx);
|
|
122
|
+
};
|
|
123
|
+
_this.getActiveView = function () {
|
|
124
|
+
var activeViewId = _this.props.activeViewId;
|
|
125
|
+
var selectedTable = _this.getActiveTable();
|
|
126
|
+
if (!activeViewId) return selectedTable.views[0];
|
|
127
|
+
return Views.getViewById(selectedTable.views, activeViewId);
|
|
128
|
+
};
|
|
129
|
+
_this.selectDashboard = function (selectedDashboardIdx) {
|
|
130
|
+
_this.isInitDashboard = true;
|
|
131
|
+
_this.setSelectedDashboardIdx(selectedDashboardIdx);
|
|
132
|
+
_this.clearCalculations();
|
|
133
|
+
_this.setState({
|
|
134
|
+
selectedDashboardIdx: selectedDashboardIdx
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
_this.modifyColorTheme = function (colorThemeName) {
|
|
138
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
139
|
+
action: DASHBOARD_ACTION_TYPE.MODIFY_COLOR_THEME,
|
|
140
|
+
payload: {
|
|
141
|
+
colorThemeName: colorThemeName
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
_this.updateStatistics({
|
|
145
|
+
statistics: updatedStatistics
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
_this.addDashboard = function (name, callback) {
|
|
149
|
+
var statistics = _this.state.statistics;
|
|
150
|
+
var dashboard = new StatisticDashBoard({
|
|
151
|
+
_id: generatorUniqueId(statistics),
|
|
152
|
+
stat_items: [],
|
|
153
|
+
name: name
|
|
154
|
+
});
|
|
155
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
156
|
+
action: DASHBOARD_ACTION_TYPE.ADD_DASHBOARD,
|
|
157
|
+
payload: {
|
|
158
|
+
dashboard: dashboard
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
_this.clearCalculations();
|
|
162
|
+
var selectedDashboardIdx = updatedStatistics.length - 1;
|
|
163
|
+
_this.setSelectedDashboardIdx(selectedDashboardIdx);
|
|
164
|
+
_this.updateStatistics({
|
|
165
|
+
statistics: updatedStatistics,
|
|
166
|
+
selectedDashboardIdx: selectedDashboardIdx
|
|
167
|
+
}, function () {
|
|
168
|
+
callback && callback();
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
_this.renameDashboard = function (name) {
|
|
172
|
+
var selectedDashboardIdx = _this.state.selectedDashboardIdx;
|
|
173
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
174
|
+
action: DASHBOARD_ACTION_TYPE.RENAME_DASHBOARD,
|
|
175
|
+
payload: {
|
|
176
|
+
index: selectedDashboardIdx,
|
|
177
|
+
name: name
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
_this.updateStatistics({
|
|
181
|
+
statistics: updatedStatistics
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
_this.deleteDashboard = function (index) {
|
|
185
|
+
var _this$state = _this.state,
|
|
186
|
+
statistics = _this$state.statistics,
|
|
187
|
+
selectedDashboardIdx = _this$state.selectedDashboardIdx;
|
|
188
|
+
var nextSelectedDashboardIdx = selectedDashboardIdx;
|
|
189
|
+
if (index === statistics.length - 1) {
|
|
190
|
+
nextSelectedDashboardIdx--;
|
|
191
|
+
_this.clearCalculations();
|
|
192
|
+
}
|
|
193
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
194
|
+
action: DASHBOARD_ACTION_TYPE.DELETE_DASHBOARD,
|
|
195
|
+
payload: {
|
|
196
|
+
index: index
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
_this.setSelectedDashboardIdx(nextSelectedDashboardIdx);
|
|
200
|
+
_this.updateStatistics({
|
|
201
|
+
statistics: updatedStatistics,
|
|
202
|
+
selectedDashboardIdx: nextSelectedDashboardIdx
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
_this.moveDashboard = function (draggedDashboardId, targetBoardId, relativePosition) {
|
|
206
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
207
|
+
action: DASHBOARD_ACTION_TYPE.MOVE_DASHBOARD,
|
|
208
|
+
payload: {
|
|
209
|
+
draggedDashboardId: draggedDashboardId,
|
|
210
|
+
targetBoardId: targetBoardId,
|
|
211
|
+
relativePosition: relativePosition
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
var selectedDashboardIdx = updatedStatistics.findIndex(function (statistic) {
|
|
215
|
+
return statistic._id === draggedDashboardId;
|
|
216
|
+
});
|
|
217
|
+
_this.setSelectedDashboardIdx(selectedDashboardIdx);
|
|
218
|
+
_this.updateStatistics({
|
|
219
|
+
statistics: updatedStatistics,
|
|
220
|
+
selectedDashboardIdx: selectedDashboardIdx
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
_this.modifyDashboardLayout = function (layout) {
|
|
224
|
+
if (_this.isInitDashboard) {
|
|
225
|
+
_this.isInitDashboard = false;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
229
|
+
action: DASHBOARD_ACTION_TYPE.MODIFY_DASHBOARD_LAYOUT,
|
|
230
|
+
payload: {
|
|
231
|
+
index: _this.state.selectedDashboardIdx,
|
|
232
|
+
layout: layout
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
_this.updateStatistics({
|
|
236
|
+
statistics: updatedStatistics
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
_this.copyChart = function (chartId) {
|
|
240
|
+
var _this$state2 = _this.state,
|
|
241
|
+
statistics = _this$state2.statistics,
|
|
242
|
+
selectedDashboardIdx = _this$state2.selectedDashboardIdx;
|
|
243
|
+
var dashboard = statistics[selectedDashboardIdx];
|
|
244
|
+
var fromChart = dashboard && dashboard.stat_items.find(function (chart) {
|
|
245
|
+
return chart._id === chartId;
|
|
246
|
+
});
|
|
247
|
+
if (!fromChart) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
var newChartId = generatorUniqueId(dashboard.stat_items);
|
|
251
|
+
var newChart = new StatItem(Object.assign({}, fromChart, {
|
|
252
|
+
_id: newChartId,
|
|
253
|
+
name: fromChart.name + '(copy)'
|
|
254
|
+
}));
|
|
255
|
+
_this.addChart(newChart);
|
|
256
|
+
};
|
|
257
|
+
_this.deleteChart = function (chartId) {
|
|
258
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
259
|
+
action: DASHBOARD_ACTION_TYPE.DELETE_CHART,
|
|
260
|
+
payload: {
|
|
261
|
+
index: _this.state.selectedDashboardIdx,
|
|
262
|
+
chart_id: chartId
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
_this.updateStatistics({
|
|
266
|
+
statistics: updatedStatistics
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
_this.addChart = function (chart) {
|
|
270
|
+
if (!_this.chartCalculator.isValidChart(chart)) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
274
|
+
action: DASHBOARD_ACTION_TYPE.ADD_CHART,
|
|
275
|
+
payload: {
|
|
276
|
+
index: _this.state.selectedDashboardIdx,
|
|
277
|
+
chart: chart
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
_this.updateStatistics({
|
|
281
|
+
statistics: updatedStatistics
|
|
282
|
+
}, function () {
|
|
283
|
+
// make the copied stat item display in the view
|
|
284
|
+
document.getElementById(chart._id).scrollIntoView(true);
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
_this.modifyChart = function (chart) {
|
|
288
|
+
var updatedStatistics = _this.dashboardService.update({
|
|
289
|
+
action: DASHBOARD_ACTION_TYPE.MODIFY_CHART,
|
|
290
|
+
payload: {
|
|
291
|
+
index: _this.state.selectedDashboardIdx,
|
|
292
|
+
chart: chart
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
_this.updateStatistics({
|
|
296
|
+
statistics: updatedStatistics
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
_this.updateStatistics = function (updates, callback) {
|
|
300
|
+
var statistics = updates.statistics;
|
|
301
|
+
_this.setState(updates, function () {
|
|
302
|
+
callback && callback();
|
|
303
|
+
_this.props.updateStatistics(statistics);
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
_this.getTableById = function (tableId) {
|
|
307
|
+
return TableUtils.getTableById(_this.props.value.tables, tableId);
|
|
308
|
+
};
|
|
309
|
+
_this.getTables = function () {
|
|
310
|
+
return _this.props.value.tables;
|
|
311
|
+
};
|
|
312
|
+
_this.getViews = function (table) {
|
|
313
|
+
return table.views;
|
|
314
|
+
};
|
|
315
|
+
_this.isTableReadOnly = function () {
|
|
316
|
+
if (window.dtable.modulePermission) {
|
|
317
|
+
return window.dtable.modulePermission.isTableReadOnly;
|
|
318
|
+
}
|
|
319
|
+
var permission = window.dtable.permission || '';
|
|
320
|
+
return permission === 'r' || permission.slice(0, 2) === 'c-';
|
|
321
|
+
};
|
|
322
|
+
var _value = props.value;
|
|
323
|
+
_this.defaultDashboardName = intl.get('Default_dashboard');
|
|
324
|
+
_this.statisticThreadManager = new ThreadManager((navigator.hardwareConcurrency || 4) - 1);
|
|
325
|
+
var _this$initDashboard2 = _this.initDashboard({
|
|
326
|
+
value: _value
|
|
327
|
+
}),
|
|
328
|
+
_statistics = _this$initDashboard2.statistics,
|
|
329
|
+
_selectedDashboardIdx = _this$initDashboard2.selectedDashboardIdx;
|
|
330
|
+
_this.state = {
|
|
331
|
+
statistics: _statistics,
|
|
332
|
+
selectedDashboardIdx: _selectedDashboardIdx,
|
|
333
|
+
refresh: false
|
|
334
|
+
};
|
|
335
|
+
_this.isInitDashboard = true;
|
|
336
|
+
return _this;
|
|
337
|
+
}
|
|
338
|
+
_createClass(DashBoard, [{
|
|
339
|
+
key: "componentDidMount",
|
|
340
|
+
value: function componentDidMount() {
|
|
341
|
+
var eventBus = this.props.eventBus;
|
|
342
|
+
this.unsubscribeRemoteTableDataChange = eventBus.subscribe('remote-dtable-changed', this.onDTableDataChange);
|
|
343
|
+
}
|
|
344
|
+
}, {
|
|
345
|
+
key: "componentWillUnmount",
|
|
346
|
+
value: function componentWillUnmount() {
|
|
347
|
+
this.unsubscribeRemoteTableDataChange();
|
|
348
|
+
this.clearCalculations();
|
|
349
|
+
}
|
|
350
|
+
}, {
|
|
351
|
+
key: "render",
|
|
352
|
+
value: function render() {
|
|
353
|
+
var eventBus = this.props.eventBus;
|
|
354
|
+
var _this$state3 = this.state,
|
|
355
|
+
statistics = _this$state3.statistics,
|
|
356
|
+
selectedDashboardIdx = _this$state3.selectedDashboardIdx,
|
|
357
|
+
editingChart = _this$state3.editingChart,
|
|
358
|
+
refresh = _this$state3.refresh;
|
|
359
|
+
var isTableReadOnly = this.isTableReadOnly();
|
|
360
|
+
var colorThemeName = this.dashboardService.getColorThemeName();
|
|
361
|
+
return isMobile ? /*#__PURE__*/React.createElement(MobileDashboard, {
|
|
362
|
+
isTableReadOnly: isTableReadOnly,
|
|
363
|
+
colorThemeName: colorThemeName,
|
|
364
|
+
refresh: refresh,
|
|
365
|
+
statistics: statistics,
|
|
366
|
+
selectedDashboardIdx: selectedDashboardIdx,
|
|
367
|
+
chartCalculator: this.chartCalculator,
|
|
368
|
+
labelColorConfigs: this.labelColorConfigs,
|
|
369
|
+
eventBus: eventBus,
|
|
370
|
+
onCloseDashboard: this.props.onCloseStatistic,
|
|
371
|
+
selectDashboard: this.selectDashboard,
|
|
372
|
+
addDashboard: this.addDashboard,
|
|
373
|
+
renameDashboard: this.renameDashboard,
|
|
374
|
+
deleteDashboard: this.deleteDashboard,
|
|
375
|
+
getTableById: this.getTableById
|
|
376
|
+
}) : /*#__PURE__*/React.createElement(DesktopDashboard, {
|
|
377
|
+
isTableReadOnly: isTableReadOnly,
|
|
378
|
+
colorThemeName: colorThemeName,
|
|
379
|
+
refresh: refresh,
|
|
380
|
+
statistics: statistics,
|
|
381
|
+
editingChart: editingChart,
|
|
382
|
+
selectedDashboardIdx: selectedDashboardIdx,
|
|
383
|
+
chartCalculator: this.chartCalculator,
|
|
384
|
+
labelColorConfigs: this.labelColorConfigs,
|
|
385
|
+
eventBus: eventBus,
|
|
386
|
+
getActiveTable: this.getActiveTable,
|
|
387
|
+
getActiveView: this.getActiveView,
|
|
388
|
+
onCloseDashboard: this.props.onCloseStatistic,
|
|
389
|
+
selectDashboard: this.selectDashboard,
|
|
390
|
+
modifyColorTheme: this.modifyColorTheme,
|
|
391
|
+
addDashboard: this.addDashboard,
|
|
392
|
+
renameDashboard: this.renameDashboard,
|
|
393
|
+
deleteDashboard: this.deleteDashboard,
|
|
394
|
+
moveDashboard: this.moveDashboard,
|
|
395
|
+
getTableById: this.getTableById,
|
|
396
|
+
getTables: this.getTables,
|
|
397
|
+
getViews: this.getViews,
|
|
398
|
+
copyChart: this.copyChart,
|
|
399
|
+
deleteChart: this.deleteChart,
|
|
400
|
+
modifyDashboardLayout: this.modifyDashboardLayout,
|
|
401
|
+
addChart: this.addChart,
|
|
402
|
+
modifyChart: this.modifyChart
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}]);
|
|
406
|
+
return DashBoard;
|
|
407
|
+
}(Component);
|
|
408
|
+
export default DashBoard;
|