dtable-statistic 4.4.24-alpha.12 → 4.4.24-alpha.13

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/es/dashboard.js CHANGED
@@ -453,6 +453,8 @@ class DashBoard extends _react.Component {
453
453
  labelColorConfigs: this.labelColorConfigs,
454
454
  eventBus: eventBus,
455
455
  onCloseDashboard: this.props.onCloseStatistic,
456
+ getViewRows: this.props.getViewRows,
457
+ getTableFormulaResults: this.props.getTableFormulaResults,
456
458
  selectDashboard: this.selectDashboard,
457
459
  addDashboard: this.addDashboard,
458
460
  renameDashboard: this.renameDashboard,
@@ -471,6 +473,8 @@ class DashBoard extends _react.Component {
471
473
  getActiveTable: this.getActiveTable,
472
474
  getActiveView: this.getActiveView,
473
475
  onCloseDashboard: this.props.onCloseStatistic,
476
+ getViewRows: this.props.getViewRows,
477
+ getTableFormulaResults: this.props.getTableFormulaResults,
474
478
  selectDashboard: this.selectDashboard,
475
479
  modifyColorTheme: this.modifyColorTheme,
476
480
  addDashboard: this.addDashboard,
@@ -10,7 +10,6 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _reactstrap = require("reactstrap");
12
12
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
13
- var _dtableStore = require("dtable-store");
14
13
  var _seaChart = require("sea-chart");
15
14
  var _tabs = _interopRequireDefault(require("./tabs"));
16
15
  var _statList = _interopRequireDefault(require("./stat-list"));
@@ -156,37 +155,14 @@ class DesktopDashboard extends _react.Component {
156
155
  };
157
156
  this.api = {
158
157
  sqlQuery: this.sqlQuery,
159
- getViewRows: this.getViewRows,
160
- getTableFormulaResults: this.getTableFormulaResults,
158
+ getViewRows: this.props.getViewRows,
159
+ getTableFormulaResults: this.props.getTableFormulaResults,
161
160
  queryUsers: window.app.queryUsers || (() => {})
162
161
  };
163
162
  }
164
163
  async sqlQuery(sql) {
165
164
  return _dtableDbApi.default.sqlQuery(sql);
166
165
  }
167
- async getViewRows(view, table) {
168
- console.log('getViewRows');
169
- const {
170
- username = null,
171
- userId = null,
172
- userDepartmentIdsMap = null
173
- } = this.dtableStore.dtableSettings;
174
- return _dtableStore.Views.getViewRows(view, table, this.dtableStore.value, username, userId, userDepartmentIdsMap);
175
- }
176
- async getTableFormulaResults(table, rows) {
177
- console.log('getTableFormulaResults');
178
- const {
179
- username = null,
180
- userId = null,
181
- userDepartmentIdsMap = null
182
- } = this.dtableStore.dtableSettings;
183
- const formulaColumns = _dtableStore.Views.getFormulaColumnsContainLinks(table);
184
- return _dtableStore.Views.getTableFormulaResults(table, rows, this.dtableStore.value, formulaColumns, {
185
- username,
186
- userId,
187
- userDepartmentIdsMap
188
- });
189
- }
190
166
  render() {
191
167
  const {
192
168
  getTableById,
package/es/index.js CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  var _react = _interopRequireDefault(require("react"));
5
+ var _dtableStore = require("dtable-store");
5
6
  var _dashboard = _interopRequireDefault(require("./dashboard"));
7
+ var _converStatItem = require("./model/conver-statItem");
6
8
  class Statistic {
7
9
  static getInitProps() {
8
10
  if (!window || !window.app) {
@@ -17,15 +19,68 @@ class Statistic {
17
19
  selectedTableIdx,
18
20
  selectedViewId
19
21
  } = state;
22
+ const convertedValue = this.convertStatistics(value);
20
23
  return {
21
- value,
24
+ value: convertedValue,
22
25
  eventBus: dtableStore.eventBus,
23
26
  activeTableIdx: selectedTableIdx,
24
27
  activeViewId: selectedViewId,
28
+ getViewRows: this.getViewRows,
29
+ getTableFormulaResults: this.getTableFormulaResults,
25
30
  updateStatistics: this.updateStatistics.bind(this, dtableStore),
26
31
  deletePluginSettings: this.deletePluginSettings.bind(this, dtableStore)
27
32
  };
28
33
  }
34
+
35
+ // Compatible with old statistics
36
+ static convertStatistics(value) {
37
+ value.statistics.forEach(dashboard => {
38
+ const new_stat_items = dashboard.stat_items.map(item => {
39
+ if (!item.config) {
40
+ const newItem = {
41
+ config: {
42
+ ...item,
43
+ ...(0, _converStatItem.convertByType)(item)
44
+ },
45
+ layout: item.layout,
46
+ style_config: {
47
+ border: {},
48
+ title: {
49
+ text: item.name
50
+ }
51
+ }
52
+ };
53
+ return newItem;
54
+ }
55
+ return item;
56
+ });
57
+ dashboard.stat_items = new_stat_items;
58
+ });
59
+ return value;
60
+ }
61
+ static getViewRows(view, table) {
62
+ const dtableStore = window.app.dtableStore || {};
63
+ const {
64
+ username = null,
65
+ userId = null,
66
+ userDepartmentIdsMap = null
67
+ } = dtableStore.dtableSettings;
68
+ return _dtableStore.Views.getViewRows(view, table, dtableStore.value, username, userId, userDepartmentIdsMap);
69
+ }
70
+ static getTableFormulaResults(table, rows) {
71
+ const dtableStore = window.app.dtableStore || {};
72
+ const {
73
+ username = null,
74
+ userId = null,
75
+ userDepartmentIdsMap = null
76
+ } = dtableStore.dtableSettings;
77
+ const formulaColumns = _dtableStore.Views.getFormulaColumnsContainLinks(table);
78
+ return _dtableStore.Views.getTableFormulaResults(table, rows, dtableStore.value, formulaColumns, {
79
+ username,
80
+ userId,
81
+ userDepartmentIdsMap
82
+ });
83
+ }
29
84
  static updateStatistics(dtableStore, statistics) {
30
85
  dtableStore.updateStatisticsList(statistics);
31
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.4.24-alpha.12",
3
+ "version": "4.4.24-alpha.13",
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.42-alpha.7"
21
+ "sea-chart": "0.0.43-alpha.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "dtable-ui-component": "~4.4.*",