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

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 _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
  }
@@ -58,17 +58,5 @@ class ChartService {
58
58
  newStatItem.layout = null;
59
59
  return newStatItem;
60
60
  }
61
- getConvertedChart(_ref4) {
62
- let {
63
- originalStatistic,
64
- targetStatisticType,
65
- activeTable
66
- } = _ref4;
67
- if (targetStatisticType === originalStatistic.type) return originalStatistic;
68
- return this.generatorChart({
69
- ...originalStatistic,
70
- type: targetStatisticType
71
- }, activeTable);
72
- }
73
61
  }
74
62
  var _default = exports.default = ChartService;
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.14",
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.45-alpha.0"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "dtable-ui-component": "~4.4.*",
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.FILTER_TYPE_2_CELL_TYPE = exports.EMPTY_PREDICATE = exports.DISPLAY_COLOR_RULE_FILTER_TYPE = exports.COLOR_RULE_FILTER_TYPE_MAP = void 0;
7
- var _dtableUtils = require("dtable-utils");
8
- const COLOR_RULE_FILTER_TYPE_MAP = exports.COLOR_RULE_FILTER_TYPE_MAP = {
9
- NUMERIC_VALUE: 'numeric_value'
10
- };
11
- const DISPLAY_COLOR_RULE_FILTER_TYPE = exports.DISPLAY_COLOR_RULE_FILTER_TYPE = {
12
- [COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE]: 'Numeric_value'
13
- };
14
- const FILTER_TYPE_2_CELL_TYPE = exports.FILTER_TYPE_2_CELL_TYPE = {
15
- [COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE]: _dtableUtils.CellType.NUMBER
16
- };
17
- const EMPTY_PREDICATE = exports.EMPTY_PREDICATE = [_dtableUtils.FILTER_PREDICATE_TYPE.EMPTY, _dtableUtils.FILTER_PREDICATE_TYPE.NOT_EMPTY];
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MUNICIPALITIES = exports.MAP_LEVEL = void 0;
7
- const MAP_LEVEL = exports.MAP_LEVEL = {
8
- WORLD: 'world',
9
- COUNTRY: 'country',
10
- PROVINCE: 'province',
11
- CITY: 'city'
12
- };
13
- const MUNICIPALITIES = exports.MUNICIPALITIES = ['北京市', '天津市', '上海市', '重庆市'];
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Y_SUMMARY_TYPE_KEYS = exports.Y_SUMMARY_METHOD_KEYS = exports.Y_SUMMARY_BY_KEYS = exports.Y_SHOW_AXIS_LABEL_KEYS = exports.Y_LABEL_POSITION_KEYS = exports.Y_LABEL_COLOR_RULES_KEYS = exports.Y_LABEL_COLOR_KEYS = exports.Y_AUTO_RANGE_MIN_KEYS = exports.Y_AUTO_RANGE_MAX_KEYS = exports.Y_AUTO_RANGE_KEYS = exports.X_SHOW_AXIS_LABEL = exports.X_LABEL_POSITION_KEYS = exports.X_INCLUDE_EMPTY_KEYS = exports.X_GROUPBY_KEYS = exports.X_GEO_GRANULARITY_KEYS = exports.X_DATE_GRANULARITY_KEYS = exports.LABEL_FRONT_SIZE_KEYS = exports.COLUMN_GROUPBY_KEYS = exports.COLUMN_GEO_GRANULARITY_KEYS = exports.COLUMN_DATE_GRANULARITY_KEYS = void 0;
7
- const X_GROUPBY_KEYS = exports.X_GROUPBY_KEYS = ['x_axis_column_key', 'groupby_column_key', 'vertical_axis_column_key', 'date_column', 'time_column', 'column', 'geo_column', 'x_axis_column', 'numeric_column', 'name_column'];
8
- const X_GEO_GRANULARITY_KEYS = exports.X_GEO_GRANULARITY_KEYS = ['x_axis_geolocation_granularity', 'groupby_geolocation_granularity', 'vertical_geolocation_granularity', 'geolocation_granularity'];
9
- const X_DATE_GRANULARITY_KEYS = exports.X_DATE_GRANULARITY_KEYS = ['x_axis_date_granularity', 'groupby_date_granularity', 'vertical_date_granularity', 'date_granularity'];
10
- const X_INCLUDE_EMPTY_KEYS = exports.X_INCLUDE_EMPTY_KEYS = ['x_axis_include_empty', 'groupby_include_empty_cells', 'vertical_axis_include_empty'];
11
- const X_SHOW_AXIS_LABEL = exports.X_SHOW_AXIS_LABEL = ['show_x_axis_label', 'show_vertical_axis_label'];
12
- const X_LABEL_POSITION_KEYS = exports.X_LABEL_POSITION_KEYS = ['x_axis_label_position', 'vertical_axis_label_position'];
13
- const Y_SUMMARY_BY_KEYS = exports.Y_SUMMARY_BY_KEYS = ['y_axis_column_key', 'y_axis_column', 'y_axis_summary_column', 'summary_column_key', 'horizontal_axis_column_key'];
14
- const Y_SUMMARY_METHOD_KEYS = exports.Y_SUMMARY_METHOD_KEYS = ['y_axis_summary_method', 'horizontal_axis_summary_method', 'summary_method'];
15
- const Y_SUMMARY_TYPE_KEYS = exports.Y_SUMMARY_TYPE_KEYS = ['y_axis_summary_type', 'horizontal_axis_summary_type', 'summary_type'];
16
- const Y_LABEL_COLOR_KEYS = exports.Y_LABEL_COLOR_KEYS = ['y_axis_label_color', 'horizontal_axis_label_color'];
17
- const Y_LABEL_COLOR_RULES_KEYS = exports.Y_LABEL_COLOR_RULES_KEYS = ['y_axis_label_color_rules', 'horizontal_axis_label_color_rules'];
18
- const Y_SHOW_AXIS_LABEL_KEYS = exports.Y_SHOW_AXIS_LABEL_KEYS = ['show_y_axis_label', 'show_horizontal_axis_label'];
19
- const Y_LABEL_POSITION_KEYS = exports.Y_LABEL_POSITION_KEYS = ['y_axis_label_position', 'horizontal_axis_label_position'];
20
- const Y_AUTO_RANGE_KEYS = exports.Y_AUTO_RANGE_KEYS = ['y_axis_auto_range', 'h_axis_auto_range'];
21
- const Y_AUTO_RANGE_MIN_KEYS = exports.Y_AUTO_RANGE_MIN_KEYS = ['y_axis_min', 'h_axis_min'];
22
- const Y_AUTO_RANGE_MAX_KEYS = exports.Y_AUTO_RANGE_MAX_KEYS = ['y_axis_max', 'h_axis_max'];
23
- const COLUMN_GROUPBY_KEYS = exports.COLUMN_GROUPBY_KEYS = ['column_groupby_column_key', 'group_column'];
24
- const COLUMN_DATE_GRANULARITY_KEYS = exports.COLUMN_DATE_GRANULARITY_KEYS = ['column_groupby_date_granularity', 'date_granularity'];
25
- const COLUMN_GEO_GRANULARITY_KEYS = exports.COLUMN_GEO_GRANULARITY_KEYS = ['column_groupby_geolocation_granularity', 'geolocation_granularity'];
26
- const LABEL_FRONT_SIZE_KEYS = exports.LABEL_FRONT_SIZE_KEYS = ['label_font_size', 'annotation_font_size'];