dtable-statistic 5.0.10-alpha.1 → 5.0.10-alpha.3

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.
@@ -10,7 +10,6 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
11
11
  var _seaChart = require("sea-chart");
12
12
  var _reactstrap = require("reactstrap");
13
- var _constants = require("../../constants");
14
13
  class ChartEditDialog extends _react.Component {
15
14
  constructor(props) {
16
15
  super(props);
@@ -55,8 +54,7 @@ class ChartEditDialog extends _react.Component {
55
54
  const {
56
55
  api,
57
56
  colorThemeName,
58
- theme,
59
- eventBus
57
+ theme
60
58
  } = this.props;
61
59
  const {
62
60
  chart
@@ -82,15 +80,12 @@ class ChartEditDialog extends _react.Component {
82
80
  chart: chart,
83
81
  config: window.dtable,
84
82
  api: api,
85
- dtableStoreValue: this.value,
86
83
  tables: this.value.tables,
87
84
  collaborators: this.value.collaborators,
88
85
  dataSources: "view",
89
86
  theme: theme,
90
87
  chartColorTheme: colorThemeName,
91
88
  isCalculateByView: true,
92
- integratedEventTypes: _constants.CommonEventTypes,
93
- integratedEventBus: eventBus,
94
89
  onChange: this.onSettingChange
95
90
  })))));
96
91
  }
@@ -27,6 +27,7 @@ class EnlargeChartDialog extends _react.Component {
27
27
  colorThemeName,
28
28
  statItem,
29
29
  getTableById,
30
+ toggleStatisticRecordsDialog,
30
31
  api,
31
32
  value
32
33
  } = this.props;
@@ -35,7 +36,8 @@ class EnlargeChartDialog extends _react.Component {
35
36
  statItem,
36
37
  api,
37
38
  value,
38
- getTableById
39
+ getTableById,
40
+ toggleStatisticRecordsDialog
39
41
  };
40
42
  return /*#__PURE__*/_react.default.createElement("div", {
41
43
  className: "view-wrapper",
@@ -0,0 +1,120 @@
1
+ .statistic-records-dialog {
2
+ width: 800px;
3
+ max-width: 800px;
4
+ height: calc(100% - 56px);
5
+ }
6
+
7
+ .statistic-records-dialog .modal-content {
8
+ width: 100%;
9
+ height: 100%;
10
+ }
11
+
12
+ .statistic-records-dialog .search-header {
13
+ height: 46px;
14
+ line-height: 46px;
15
+ display: flex;
16
+ justify-content: space-between;
17
+ border-bottom: 1px solid #e9ecef;
18
+ align-items: center;
19
+ padding: 0 20px;
20
+ font-weight: 500;
21
+ font-size: 16px;
22
+ }
23
+
24
+ .statistic-records-dialog .no-search-result {
25
+ height: 100%;
26
+ width: 100%;
27
+ text-align: center;
28
+ background-position: 50% 140px;
29
+ background-size: 132px 132px;
30
+ line-height: 600px;
31
+ color: #aaa;
32
+ }
33
+
34
+ .statistic-records-dialog .search-input-container .close {
35
+ height: 24px !important;
36
+ width: 24px;
37
+ line-height: 24px;
38
+ position: absolute;
39
+ right: 14px;
40
+ top: 22px;
41
+ padding: 0;
42
+ margin: 0;
43
+ }
44
+
45
+ .statistic-records-dialog .search-input-container {
46
+ margin-top: 10px;
47
+ padding: 0 20px;
48
+ height: 48px;
49
+ position: relative;
50
+ }
51
+
52
+ .statistic-records-dialog .search-input-container .search-tables-input {
53
+ height: 38px;
54
+ line-height: 38px;
55
+ padding-left: 30px;
56
+ border-bottom: 0;
57
+ background: #f5f5f5;
58
+ border-radius: 3px;
59
+ border: 1px solid #dedede;
60
+ }
61
+
62
+ .statistic-records-dialog .search-input-container .search-tables-input:focus {
63
+ outline: none;
64
+ box-shadow: unset;
65
+ }
66
+
67
+ .statistic-records-dialog .search-input-container .header-search-icon {
68
+ line-height: 38px;
69
+ text-align: center;
70
+ color: #aaa;
71
+ margin-left: 11px;
72
+ position: absolute;
73
+ left: unset;
74
+ }
75
+
76
+ .statistic-records-dialog .search-input-container .clear-search-text {
77
+ display: inline-block;
78
+ position: absolute;
79
+ right: 30px;
80
+ top: 10px;
81
+ height: 12px;
82
+ width: 12px;
83
+ line-height: 12px;
84
+ color: #ccc;
85
+ }
86
+
87
+ .statistic-records-dialog .search-input-container .clear-search-text .dtable-font {
88
+ font-size: 12px;
89
+ }
90
+
91
+ .statistic-records-dialog .search-input-container .clear-search-text:hover {
92
+ cursor: pointer;
93
+ }
94
+
95
+ .statistic-records-dialog .statistic-records-container {
96
+ width: 100%;
97
+ height: 100%;
98
+ padding: 0;
99
+ overflow-y: hidden;
100
+ background-color: #f8f8f8;
101
+ border-bottom-left-radius: 3px;
102
+ border-bottom-right-radius: 3px;
103
+ }
104
+
105
+ .statistic-records-dialog.statistic-records-container .records-list {
106
+ height: calc(100% - 47px);
107
+ width: fit-content;
108
+ min-width: 100%;
109
+ padding: 10px 20px;
110
+ overflow-y: auto;
111
+ margin-top: 3px;
112
+ }
113
+
114
+ .statistic-records-dialog .statistic-records-container .records-list .records-container {
115
+ height: auto;
116
+ }
117
+
118
+ .statistic-records-dialog .row-card-item-content .grid-cell-type-button .grid-cell-type-button-inner {
119
+ justify-content: flex-start;
120
+ }
@@ -0,0 +1,344 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _Loading2 = _interopRequireDefault(require("dtable-ui-component/lib/Loading"));
10
+ var _DTableSearchInput2 = _interopRequireDefault(require("dtable-ui-component/lib/DTableSearchInput"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
13
+ var _reactstrap = require("reactstrap");
14
+ var _dtableUtils = require("dtable-utils");
15
+ var _dtableDbApi = _interopRequireDefault(require("../../../api/dtable-db-api"));
16
+ var _constants = require("../../../constants");
17
+ require("./index.css");
18
+ // import { searchRows } from '../../../utils';
19
+ // import { getSqlString } from '../../../utils/sql-utils';
20
+ class StatisticRecordDialog extends _react.default.Component {
21
+ constructor(props) {
22
+ super(props);
23
+ this.init = () => {
24
+ const {
25
+ chartRecordsParams
26
+ } = this.props;
27
+ if (!chartRecordsParams) return;
28
+ const {
29
+ statisticRecord,
30
+ chart,
31
+ isColumn,
32
+ isCurrentView,
33
+ isRow
34
+ } = chartRecordsParams || {};
35
+ const {
36
+ rows: records
37
+ } = statisticRecord;
38
+ const {
39
+ getTableById
40
+ } = this.props;
41
+ const {
42
+ table_id,
43
+ view_id
44
+ } = chart;
45
+ this.table = getTableById(table_id);
46
+ this.view = (0, _dtableUtils.getViewById)(this.table.views, view_id);
47
+ this.isArchiveView = (0, _dtableUtils.isArchiveView)(this.view);
48
+ this.unShowColumnKeyList = this.getUnShowColumnKeyList(this.view);
49
+ this.renderedColumns = this.getRenderedColumns(this.table);
50
+ // if (this.isArchiveView || !records) {
51
+ // const { username, userId, userDepartmentIdsMap } = window.dtable || {};
52
+ // const sqlString = getSqlString(chart, statisticRecord, { isColumn, isCurrentView, isRow, getTableById, username, userId, userDepartmentIdsMap });
53
+ // dtableDbAPI.sqlQuery(sqlString).then(res => {
54
+ // const { results: rows } = res.data;
55
+ // this.processDrilledRows(rows);
56
+ // });
57
+ // return;
58
+ // }
59
+
60
+ this.processDrilledRows(records);
61
+ };
62
+ this.processDrilledRows = drilledRows => {
63
+ const {
64
+ statisticRecord
65
+ } = this.props.chartRecordsParams;
66
+ const {
67
+ name
68
+ } = statisticRecord;
69
+ const searchedRowsIds = this.getSearchedRows(drilledRows);
70
+ let idRowMap = {};
71
+ drilledRows.forEach(row => {
72
+ idRowMap[row._id] = row;
73
+ });
74
+ this.initComputedProperties(drilledRows);
75
+ this.setState({
76
+ loading: false,
77
+ title: name,
78
+ rows: drilledRows,
79
+ idRowMap,
80
+ searchedRowsIds
81
+ });
82
+ };
83
+ this.initComputedProperties = drilledRows => {
84
+ if (this.isArchiveView) {
85
+ const formulaColumns = (0, _dtableUtils.getFormulaColumnsContainLinks)(this.table);
86
+ if (formulaColumns.length === 0) return {};
87
+ let formulaRows = {};
88
+ drilledRows.forEach(row => {
89
+ const rowId = row._id;
90
+ formulaRows[rowId] = {};
91
+ formulaColumns.forEach(column => formulaRows[rowId][column.key] = row[column.key]);
92
+ });
93
+ this.formulaRows = formulaRows;
94
+ return;
95
+ }
96
+ const {
97
+ formulaRows
98
+ } = this.getTableViewFormulaRows();
99
+ this.formulaRows = formulaRows;
100
+ };
101
+ this.onSearch = searchVal => {
102
+ const {
103
+ rows
104
+ } = this.state;
105
+ const searchedRowsIds = this.getSearchedRows(rows, searchVal);
106
+ this.setState({
107
+ searchedRowsIds,
108
+ searchVal
109
+ });
110
+ };
111
+ this.clearTimer = () => {
112
+ if (this.timer) {
113
+ clearTimeout(this.timer);
114
+ this.timer = null;
115
+ }
116
+ };
117
+ this.clearSearch = () => {
118
+ const {
119
+ rows
120
+ } = this.state;
121
+ const searchedRowsIds = this.getSearchedRows(rows);
122
+ this.setState({
123
+ searchedRowsIds,
124
+ searchVal: ''
125
+ });
126
+ };
127
+ this.getSearchedRows = (rows, searchVal) => {
128
+ if (!Array.isArray(rows) || rows.length === 0) return [];
129
+ // if (searchVal) {
130
+ // return searchRows(
131
+ // rows,
132
+ // getViewShownColumns(this.view, this.table.columns),
133
+ // searchVal,
134
+ // (row) => {
135
+ // return row;
136
+ // },
137
+ // ).map((row) => row._id);
138
+ // }
139
+ return rows.map(row => row._id);
140
+ };
141
+ this.getRowsByIds = rowsIds => {
142
+ if (!Array.isArray(rowsIds) || rowsIds.length === 0) {
143
+ return [];
144
+ }
145
+ const {
146
+ idRowMap
147
+ } = this.state;
148
+ return rowsIds.map(rowId => idRowMap[rowId]).filter(Boolean);
149
+ };
150
+ this.toggle = () => {
151
+ if (this.valueChanged) {
152
+ this.props.eventBus.dispatch(_constants.CommonEventTypes.REFRESH_CHARTS);
153
+ }
154
+ this.props.toggleStatisticRecordsDialog();
155
+ };
156
+ this.expandRowUpdated = _ref => {
157
+ let {
158
+ table_id,
159
+ updatedRow
160
+ } = _ref;
161
+ // none-matched
162
+ if (table_id !== this.table._id) return;
163
+ const {
164
+ rows,
165
+ searchedRowsIds,
166
+ idRowMap,
167
+ searchVal
168
+ } = this.state;
169
+ let updatedSearchedRowsIds = searchedRowsIds;
170
+ let updatedRows = [...rows];
171
+ let updatedIdRowMap = idRowMap;
172
+ rows.forEach((row, index) => {
173
+ const rowId = row._id;
174
+ if (rowId === updatedRow._id) {
175
+ updatedRows[index] = updatedRow;
176
+ updatedIdRowMap[rowId] = updatedRow;
177
+ }
178
+ });
179
+ if (searchedRowsIds.length > 0) {
180
+ const searchedRows = this.getRowsByIds(searchedRowsIds);
181
+ updatedSearchedRowsIds = this.getSearchedRows(searchedRows, searchVal);
182
+ }
183
+ this.valueChanged = true;
184
+ this.setState({
185
+ rows: updatedRows,
186
+ idRowMap: updatedIdRowMap,
187
+ searchedRowsIds: updatedSearchedRowsIds
188
+ });
189
+ };
190
+ this.expandRowDeleted = _ref2 => {
191
+ let {
192
+ table_id,
193
+ row_id
194
+ } = _ref2;
195
+ // none-matched
196
+ if (table_id !== this.table._id) return;
197
+ const {
198
+ rows,
199
+ searchedRowsIds,
200
+ idRowMap
201
+ } = this.state;
202
+ let updatedSearchedRowsIds = searchedRowsIds;
203
+ let updatedIdRowMap = idRowMap;
204
+ const updatedRows = rows.filter(row => row._id !== row_id);
205
+ delete updatedIdRowMap[row_id];
206
+ if (searchedRowsIds.length > 0) {
207
+ updatedSearchedRowsIds = searchedRowsIds.filter(rowId => rowId !== row_id);
208
+ }
209
+ this.valueChanged = true;
210
+ this.setState({
211
+ rows: updatedRows,
212
+ idRowMap: updatedIdRowMap,
213
+ searchedRowsIds: updatedSearchedRowsIds
214
+ });
215
+ };
216
+ this.getUnShowColumnKeyList = view => {
217
+ const firstColumnKey = '0000';
218
+ const {
219
+ hidden_columns = []
220
+ } = view;
221
+ return [firstColumnKey, ...hidden_columns];
222
+ };
223
+ this.getRenderedColumns = table => {
224
+ const {
225
+ columns
226
+ } = table;
227
+ return columns.filter(column => !this.unShowColumnKeyList.includes(column.key));
228
+ };
229
+ this.getTableViewFormulaRows = () => {
230
+ const {
231
+ table,
232
+ view
233
+ } = this;
234
+ const value = this.props.getValue();
235
+ if (view.formula_rows && Object.keys(view.formula_rows).length > 0) {
236
+ return {
237
+ formulaRows: view.formula_rows
238
+ };
239
+ }
240
+ if (window.app && window.app.cacheFormulaResults) {
241
+ window.app.cacheFormulaResults(table.rows, {
242
+ targetViewId: view._id,
243
+ table,
244
+ value
245
+ });
246
+ }
247
+ return {
248
+ formulaRows: view.formula_rows
249
+ };
250
+ };
251
+ this.renderRowsCards = () => {
252
+ const {
253
+ searchedRowsIds
254
+ } = this.state;
255
+ const searchedRows = this.getRowsByIds(searchedRowsIds);
256
+ if (searchedRows.length === 0) return null;
257
+ if (!window.app || !window.app.renderRowsCards) return null;
258
+ return window.app.renderRowsCards({
259
+ table: this.table,
260
+ renderedColumns: this.renderedColumns,
261
+ unShowColumnKeyList: this.unShowColumnKeyList,
262
+ isShowRowCardHeader: true,
263
+ formulaRows: this.formulaRows,
264
+ columns: this.renderedColumns,
265
+ rows: searchedRows,
266
+ rowCardType: 'statistic'
267
+ });
268
+ };
269
+ this.state = {
270
+ loading: true,
271
+ title: '',
272
+ rows: [],
273
+ idRowMap: {},
274
+ searchVal: '',
275
+ searchedRowsIds: []
276
+ };
277
+ this.table = null;
278
+ this.view = null;
279
+ this.isArchiveView = false;
280
+ this.valueChanged = false;
281
+ this.renderedColumns = [];
282
+ this.formulaRows = null;
283
+ this.unShowColumnKeyList = null;
284
+ }
285
+ componentDidMount() {
286
+ this.unsubscribeExpandRowUpdated = this.props.eventBus.subscribe(_constants.CommonEventTypes.EXPAND_ROW_UPDATED, this.expandRowUpdated);
287
+ this.unsubscribeExpandRowDeleted = this.props.eventBus.subscribe(_constants.CommonEventTypes.EXPAND_ROW_DELETED, this.expandRowDeleted);
288
+ this.init();
289
+ }
290
+ componentWillUnmount() {
291
+ this.unsubscribeExpandRowUpdated();
292
+ this.unsubscribeExpandRowDeleted();
293
+ }
294
+ render() {
295
+ const {
296
+ loading,
297
+ title
298
+ } = this.state;
299
+ return /*#__PURE__*/_react.default.createElement(_reactstrap.Modal, {
300
+ isOpen: true,
301
+ autoFocus: false,
302
+ toggle: this.toggle,
303
+ className: "statistic-records-dialog",
304
+ zIndex: 1048
305
+ }, /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
306
+ className: "search-header"
307
+ }, /*#__PURE__*/_react.default.createElement("span", null, title), /*#__PURE__*/_react.default.createElement("button", {
308
+ type: "button",
309
+ className: "close",
310
+ "aria-label": "Close",
311
+ onClick: this.toggle
312
+ }, /*#__PURE__*/_react.default.createElement("span", {
313
+ "aria-hidden": "true"
314
+ }, "\xD7"))), /*#__PURE__*/_react.default.createElement("div", {
315
+ className: "search-input-container"
316
+ }, /*#__PURE__*/_react.default.createElement("i", {
317
+ className: "header-search-icon dtable-font dtable-icon-search"
318
+ }), /*#__PURE__*/_react.default.createElement(_DTableSearchInput2.default, {
319
+ autoFocus: true,
320
+ isClearable: true,
321
+ className: "search-tables-input",
322
+ placeholder: _reactIntlUniversal.default.get('Search_records'),
323
+ onChange: this.onSearch,
324
+ clearValue: this.clearSearch,
325
+ components: {
326
+ ClearIndicator: props => {
327
+ return /*#__PURE__*/_react.default.createElement("span", {
328
+ className: "clear-search-text",
329
+ onClick: props.clearValue,
330
+ title: _reactIntlUniversal.default.get('Clear_search_text'),
331
+ "aria-label": _reactIntlUniversal.default.get('Clear_search_text')
332
+ }, /*#__PURE__*/_react.default.createElement("i", {
333
+ className: "dtable-font dtable-icon-x-"
334
+ }));
335
+ }
336
+ }
337
+ })), /*#__PURE__*/_react.default.createElement(_reactstrap.ModalBody, {
338
+ className: "statistic-records-container"
339
+ }, loading ? /*#__PURE__*/_react.default.createElement("div", {
340
+ className: "d-flex py-8"
341
+ }, /*#__PURE__*/_react.default.createElement(_Loading2.default, null)) : this.renderRowsCards())));
342
+ }
343
+ }
344
+ var _default = exports.default = StatisticRecordDialog;
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "KeyCodes", {
12
12
  return _keyCodes.default;
13
13
  }
14
14
  });
15
- exports.THEME_NAME_MAP = exports.SUMMARY_TYPE = exports.SUMMARY_METHOD_MAP = exports.SUMMARY_METHOD = exports.STATISTICS_COUNT_TYPE = void 0;
15
+ exports.THEME_NAME_MAP = exports.SUMMARY_TYPE = exports.SUMMARY_METHOD_MAP = exports.SUMMARY_METHOD = exports.STAT_TYPE = exports.STATISTICS_COUNT_TYPE = void 0;
16
16
  var _keyCodes = _interopRequireDefault(require("./key-codes"));
17
17
  var CommonEventTypes = _interopRequireWildcard(require("./event-types"));
18
18
  exports.CommonEventTypes = CommonEventTypes;
@@ -29,6 +29,37 @@ const DASHBOARD_ACTION_TYPE = exports.DASHBOARD_ACTION_TYPE = {
29
29
  MOVE_CHART_TO_VIEW: 'move_chart_to_view',
30
30
  DELETE_CHART: 'delete_chart'
31
31
  };
32
+ const STAT_TYPE = exports.STAT_TYPE = {
33
+ MAP: 'map',
34
+ MAP_BUBBLE: 'map_bubble',
35
+ HEAT_MAP: 'heat_map',
36
+ WORLD_MAP: 'world_map',
37
+ WORLD_MAP_BUBBLE: 'world_map_bubble',
38
+ MIRROR: 'mirror',
39
+ BAR: 'chart_bar',
40
+ BAR_GROUP: 'chart_bar_group',
41
+ BAR_STACK: 'chart_bar_stack',
42
+ LINE: 'chart_line',
43
+ GROUP_LINE: 'chart_group_line',
44
+ PIE: 'chart_pie',
45
+ RING: 'chart_ring',
46
+ SCATTER: 'scatter_chart',
47
+ BASIC_NUMBER_CARD: 'basic_number_card',
48
+ HORIZONTAL_BAR: 'horizontal_bar',
49
+ HORIZONTAL_GROUP_BAR: 'horizontal_group_bar',
50
+ STACKED_HORIZONTAL_BAR: 'stacked_horizontal_bar',
51
+ COMBINATION_CHART: 'combination_chart',
52
+ TREND_CHART: 'trend_chart',
53
+ AREA_CHART: 'area_chart',
54
+ AREA_GROUP_CHART: 'area_group_chart',
55
+ COMPARE_BAR: 'compare_bar',
56
+ COMPLETENESS_CHART: 'completeness_chart',
57
+ DASHBOARD: 'dashboard',
58
+ GROUP_COMPLETENESS_CHART: 'group_completeness_chart',
59
+ TREEMAP: 'treemap',
60
+ PIVOT_TABLE: 'pivot_table',
61
+ CUSTOM_BAR: 'custom_bar'
62
+ };
32
63
  const SUMMARY_TYPE = exports.SUMMARY_TYPE = {
33
64
  COUNT: 'count',
34
65
  ADVANCED: 'advanced'
package/es/dashboard.js CHANGED
@@ -66,6 +66,11 @@ class DashBoard extends _react.Component {
66
66
  selectedDashboardIdx
67
67
  });
68
68
  };
69
+ this.refreshCharts = () => {
70
+ this.setState({
71
+ dtableChangedTime: Date.now()
72
+ });
73
+ };
69
74
  this.initDashboard = () => {
70
75
  const value = this.value;
71
76
  this.dashboardService = new _dashboardService.default({
@@ -358,7 +363,8 @@ class DashBoard extends _react.Component {
358
363
  } = this.initDashboard();
359
364
  this.state = {
360
365
  statistics: _statistics,
361
- selectedDashboardIdx: _selectedDashboardIdx
366
+ selectedDashboardIdx: _selectedDashboardIdx,
367
+ dtableChangedTime: null
362
368
  };
363
369
  this.isInitDashboard = true;
364
370
  this.updatingLocalStatistics = false;
@@ -371,10 +377,12 @@ class DashBoard extends _react.Component {
371
377
  } = this.props;
372
378
  this.unsubscribeLocalDtableChanged = eventBus.subscribe('local-dtable-changed', this.onLocalDTableChanged);
373
379
  this.unsubscribeRemoteDtableChange = eventBus.subscribe('remote-dtable-changed', this.onServerDTableChanged);
380
+ this.unsubscribeRefreshCharts = eventBus.subscribe(_constants.CommonEventTypes.REFRESH_CHARTS, this.refreshCharts);
374
381
  }
375
382
  componentWillUnmount() {
376
383
  this.unsubscribeLocalDtableChanged();
377
384
  this.unsubscribeRemoteDtableChange();
385
+ this.unsubscribeRefreshCharts();
378
386
  }
379
387
  render() {
380
388
  const {
@@ -382,13 +390,15 @@ class DashBoard extends _react.Component {
382
390
  } = this.props;
383
391
  const {
384
392
  statistics,
385
- selectedDashboardIdx
393
+ selectedDashboardIdx,
394
+ dtableChangedTime
386
395
  } = this.state;
387
396
  const isTableReadOnly = this.isTableReadOnly();
388
397
  const colorThemeName = this.dashboardService.getColorThemeName();
389
398
  return _utils.isMobile ? /*#__PURE__*/_react.default.createElement(_mobileDashboard.default, {
390
399
  isTableReadOnly: isTableReadOnly,
391
400
  colorThemeName: colorThemeName,
401
+ dtableChangedTime: dtableChangedTime,
392
402
  statistics: statistics,
393
403
  selectedDashboardIdx: selectedDashboardIdx,
394
404
  eventBus: eventBus,
@@ -403,6 +413,7 @@ class DashBoard extends _react.Component {
403
413
  }) : /*#__PURE__*/_react.default.createElement(_desktopDashboard.default, {
404
414
  isTableReadOnly: isTableReadOnly,
405
415
  colorThemeName: colorThemeName,
416
+ dtableChangedTime: dtableChangedTime,
406
417
  statistics: statistics,
407
418
  selectedDashboardIdx: selectedDashboardIdx,
408
419
  eventBus: eventBus,
@@ -15,6 +15,7 @@ var _tabs = _interopRequireDefault(require("./tabs"));
15
15
  var _statList = _interopRequireDefault(require("./stat-list"));
16
16
  var _colorThemeDialog = _interopRequireDefault(require("./components/dialog/color-theme-dialog"));
17
17
  var _chartEditDialog = _interopRequireDefault(require("./components/dialog/chart-edit-dialog"));
18
+ var _statisticRecordDialog = _interopRequireDefault(require("./components/dialog/statistic-record-dialog"));
18
19
  var _dtableDbApi = _interopRequireDefault(require("./api/dtable-db-api"));
19
20
  var _chartService = _interopRequireDefault(require("./service/chart-service"));
20
21
  var _constants = require("./constants");
@@ -22,7 +23,9 @@ var _icon = _interopRequireDefault(require("./assets/images/icon.png"));
22
23
  const KEY_LOCAL_THEME_MODE = 'statistics-theme-mode';
23
24
  class DesktopDashboard extends _react.Component {
24
25
  constructor(props) {
26
+ var _this;
25
27
  super(props);
28
+ _this = this;
26
29
  this.onToggleColorThemeDialog = () => {
27
30
  this.setState({
28
31
  isShowColorThemeDialog: !this.state.isShowColorThemeDialog
@@ -92,6 +95,28 @@ class DesktopDashboard extends _react.Component {
92
95
  const uuidThemeModeMap = this.getThemeModeMap();
93
96
  return uuidThemeModeMap[dtableUuid];
94
97
  };
98
+ this.toggleStatisticRecordsDialog = function (statisticRecord, chart) {
99
+ let {
100
+ isColumn = false,
101
+ isCurrentView = false,
102
+ isRow = false
103
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
104
+ if (_this.state.chartRecordsParams) {
105
+ _this.setState({
106
+ chartRecordsParams: null
107
+ });
108
+ } else {
109
+ _this.setState({
110
+ chartRecordsParams: {
111
+ statisticRecord,
112
+ chart,
113
+ isColumn,
114
+ isCurrentView,
115
+ isRow
116
+ }
117
+ });
118
+ }
119
+ };
95
120
  this.generateChart = chartType => {
96
121
  const {
97
122
  statistics,
@@ -125,7 +150,8 @@ class DesktopDashboard extends _react.Component {
125
150
  isShowChartEditDialog: false,
126
151
  isShowChartAddDialog: false,
127
152
  isShowColorThemeDialog: false,
128
- editingChart: null
153
+ editingChart: null,
154
+ chartRecordsParams: null
129
155
  };
130
156
  this.api = {
131
157
  sqlQuery: this.sqlQuery,
@@ -139,8 +165,10 @@ class DesktopDashboard extends _react.Component {
139
165
  }
140
166
  render() {
141
167
  const {
168
+ getTableById,
142
169
  getValue,
143
170
  isTableReadOnly,
171
+ dtableChangedTime,
144
172
  colorThemeName,
145
173
  statistics,
146
174
  selectedDashboardIdx,
@@ -150,6 +178,7 @@ class DesktopDashboard extends _react.Component {
150
178
  theme,
151
179
  isFullScreen,
152
180
  editingChart,
181
+ chartRecordsParams,
153
182
  isShowChartAddDialog
154
183
  } = this.state;
155
184
  const darkMode = theme === _constants.THEME_NAME_MAP.DARK;
@@ -231,6 +260,7 @@ class DesktopDashboard extends _react.Component {
231
260
  className: "statistic-main"
232
261
  }, /*#__PURE__*/_react.default.createElement(_statList.default, {
233
262
  isTableReadOnly: isTableReadOnly,
263
+ dtableChangedTime: dtableChangedTime,
234
264
  theme: theme,
235
265
  colorThemeName: colorThemeName,
236
266
  statItems: statItems,
@@ -245,19 +275,20 @@ class DesktopDashboard extends _react.Component {
245
275
  deleteChart: this.props.deleteChart,
246
276
  modifyDashboardLayout: this.props.modifyDashboardLayout,
247
277
  onToggleEditChart: this.onToggleEditChart,
248
- onCloseDashboard: this.props.onCloseDashboard
278
+ onCloseDashboard: this.props.onCloseDashboard,
279
+ toggleStatisticRecordsDialog: this.toggleStatisticRecordsDialog
249
280
  })), this.state.isShowChartEditDialog && /*#__PURE__*/_react.default.createElement(_chartEditDialog.default, {
250
281
  theme: theme,
251
282
  colorThemeName: colorThemeName,
252
283
  editingChart: editingChart,
253
- eventBus: eventBus,
254
284
  api: this.api,
255
285
  getValue: getValue,
256
286
  statistics: statistics,
257
287
  selectedDashboardIdx: selectedDashboardIdx,
258
288
  addChart: this.props.addChart,
259
289
  modifyChart: this.props.modifyChart,
260
- onToggleEditChart: this.onToggleEditChart
290
+ onToggleEditChart: this.onToggleEditChart,
291
+ toggleStatisticRecordsDialog: this.toggleStatisticRecordsDialog
261
292
  }), isShowChartAddDialog && /*#__PURE__*/_react.default.createElement(_seaChart.TypesDialog, {
262
293
  type: "",
263
294
  onToggle: this.onToggleAddChart,
@@ -266,6 +297,12 @@ class DesktopDashboard extends _react.Component {
266
297
  colorThemeName: colorThemeName,
267
298
  onToggleColorThemeDialog: this.onToggleColorThemeDialog,
268
299
  modifyColorTheme: this.props.modifyColorTheme
300
+ }), !!chartRecordsParams && /*#__PURE__*/_react.default.createElement(_statisticRecordDialog.default, {
301
+ eventBus: this.props.eventBus,
302
+ chartRecordsParams: chartRecordsParams,
303
+ getTableById: getTableById,
304
+ getValue: getValue,
305
+ toggleStatisticRecordsDialog: this.toggleStatisticRecordsDialog
269
306
  }));
270
307
  }
271
308
  }
@@ -65,13 +65,13 @@ class MobileDashboard extends _react.Component {
65
65
  })))), /*#__PURE__*/_react.default.createElement("div", {
66
66
  className: _mobileDashboardModule.default['mobile-statistic-dashboard-wrapper']
67
67
  }, statItems.map(statItem => {
68
+ var _style_config$title, _style_config$title$t;
68
69
  const {
69
70
  _id,
70
- type
71
+ type,
72
+ style_config = {}
71
73
  } = statItem.config;
72
- const {
73
- name
74
- } = statItem.style_config.title.text;
74
+ const name = (style_config === null || style_config === void 0 ? void 0 : (_style_config$title = style_config.title) === null || _style_config$title === void 0 ? void 0 : (_style_config$title$t = _style_config$title.text) === null || _style_config$title$t === void 0 ? void 0 : _style_config$title$t.name) || '';
75
75
  const showStatName = !(type === _seaChart.CHART_TYPE.BASIC_NUMBER_CARD || type === _seaChart.CHART_TYPE.DASHBOARD);
76
76
  return /*#__PURE__*/_react.default.createElement("div", {
77
77
  key: "mobile-statistic-chart-".concat(_id),
@@ -75,8 +75,8 @@ class ChartPreview extends _react.Component {
75
75
  colorThemeName,
76
76
  api,
77
77
  value,
78
- eventBus,
79
- getTableById
78
+ getTableById,
79
+ toggleStatisticRecordsDialog
80
80
  } = this.props;
81
81
  return /*#__PURE__*/_react.default.createElement(_statView.default, {
82
82
  ref: ref => this.chartView = ref,
@@ -85,8 +85,8 @@ class ChartPreview extends _react.Component {
85
85
  statItem: statItem,
86
86
  api: api,
87
87
  value: value,
88
- eventBus: eventBus,
89
- getTableById: getTableById
88
+ getTableById: getTableById,
89
+ toggleStatisticRecordsDialog: toggleStatisticRecordsDialog
90
90
  });
91
91
  };
92
92
  this.moveChartToView = viewId => {
@@ -132,7 +132,7 @@ class StatList extends _react.Component {
132
132
 
133
133
  // refresh charts if has updates
134
134
  if (Array.isArray(rowIds) && rowIds.length > 0 || Array.isArray(newRows) && newRows.length > 0) {
135
- _seaChart.EventBus.dispatch(_constants.CommonEventTypes.REFRESH_CHARTS);
135
+ this.props.eventBus.dispatch(_constants.CommonEventTypes.REFRESH_CHARTS);
136
136
  }
137
137
  }
138
138
  this.statisticalResult4Update = null;
@@ -168,8 +168,7 @@ class StatList extends _react.Component {
168
168
  theme,
169
169
  colorThemeName,
170
170
  statItems,
171
- api,
172
- eventBus
171
+ api
173
172
  } = this.props;
174
173
  const {
175
174
  layout,
@@ -207,7 +206,6 @@ class StatList extends _react.Component {
207
206
  colorThemeName: colorThemeName,
208
207
  statItem: item,
209
208
  api: api,
210
- eventBus: eventBus,
211
209
  value: this.value,
212
210
  getOtherStatistics: this.props.getOtherStatistics,
213
211
  getTableById: this.props.getTableById,
@@ -227,7 +225,8 @@ class StatList extends _react.Component {
227
225
  } = _ref2;
228
226
  return this.showSelectTableDialog(index, statisticalResult);
229
227
  },
230
- onToggleEditChart: this.props.onToggleEditChart
228
+ onToggleEditChart: this.props.onToggleEditChart,
229
+ toggleStatisticRecordsDialog: this.props.toggleStatisticRecordsDialog
231
230
  }));
232
231
  })), enlargedChart && /*#__PURE__*/_react.default.createElement(_enlargedChartDialog.default, {
233
232
  colorThemeName: colorThemeName,
@@ -235,7 +234,8 @@ class StatList extends _react.Component {
235
234
  api: api,
236
235
  value: this.value,
237
236
  getTableById: this.props.getTableById,
238
- onEnlargeToggle: this.closeEnlargedChart
237
+ onEnlargeToggle: this.closeEnlargedChart,
238
+ toggleStatisticRecordsDialog: this.props.toggleStatisticRecordsDialog
239
239
  }), chartExport2Table && /*#__PURE__*/_react.default.createElement(_newTableDialog.default, {
240
240
  getTables: this.props.getTables,
241
241
  tableName: chartExport2Table.name,
@@ -8,7 +8,6 @@ exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _seaChart = require("sea-chart");
10
10
  var _dtableUtils = require("dtable-utils");
11
- var _constants = require("../constants");
12
11
  class StatView extends _react.default.Component {
13
12
  constructor(props) {
14
13
  super(props);
@@ -46,8 +45,7 @@ class StatView extends _react.default.Component {
46
45
  api,
47
46
  value,
48
47
  theme,
49
- colorThemeName,
50
- eventBus
48
+ colorThemeName
51
49
  } = this.props;
52
50
  return /*#__PURE__*/_react.default.createElement("div", {
53
51
  className: "statistic-chart-container"
@@ -55,15 +53,12 @@ class StatView extends _react.default.Component {
55
53
  chart: statItem,
56
54
  api: api,
57
55
  config: window.dtable,
58
- dtableStoreValue: value,
59
56
  tables: value.tables,
60
57
  collaborators: value.collaborators,
61
58
  hideTitle: true,
62
59
  globalTheme: theme,
63
60
  chartColorTheme: colorThemeName,
64
61
  isCalculateByView: true,
65
- integratedEventTypes: _constants.CommonEventTypes,
66
- integratedEventBus: eventBus,
67
62
  onViewRef: this.getViewRef
68
63
  }));
69
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "5.0.10-alpha.1",
3
+ "version": "5.0.10-alpha.3",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",
@@ -18,7 +18,7 @@
18
18
  "react-grid-layout": "^1.2.5",
19
19
  "react-intl-universal": "^2.4.8",
20
20
  "reactstrap": "8.9.0",
21
- "sea-chart": "0.0.56-alpha.0"
21
+ "sea-chart": "^0.0.56"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "dtable-ui-component": "~5.0.*",