dtable-statistic 5.0.37 → 5.0.38-alpha.1
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/index.js +1 -89
- package/es/service/dashboard-service.js +87 -0
- package/es/utils/export-table-utils.js +7 -0
- package/package.json +2 -2
package/es/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _dtableStore = require("dtable-store");
|
|
6
|
-
var _seaChart = require("sea-chart");
|
|
7
6
|
var _dashboard = _interopRequireDefault(require("./dashboard"));
|
|
8
|
-
var _converStatItem = require("./model/conver-statItem");
|
|
9
7
|
class Statistic {
|
|
10
8
|
static getInitProps() {
|
|
11
9
|
if (!window || !window.app) {
|
|
@@ -24,9 +22,8 @@ class Statistic {
|
|
|
24
22
|
const collaboratorsCacheList = Object.values(collaboratorsCache) || [];
|
|
25
23
|
if (!value.collaborators) value.collaborators = [];
|
|
26
24
|
value.collaborators = value.collaborators.concat(collaboratorsCacheList);
|
|
27
|
-
const convertedValue = this.convertStatistics(value);
|
|
28
25
|
return {
|
|
29
|
-
value
|
|
26
|
+
value,
|
|
30
27
|
eventBus: dtableStore.eventBus,
|
|
31
28
|
activeTableIdx: selectedTableIdx,
|
|
32
29
|
activeViewId: selectedViewId,
|
|
@@ -36,91 +33,6 @@ class Statistic {
|
|
|
36
33
|
deletePluginSettings: this.deletePluginSettings.bind(this, dtableStore)
|
|
37
34
|
};
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
// Compatible with old statistics
|
|
41
|
-
static convertStatistics(value) {
|
|
42
|
-
value.statistics.forEach(dashboard => {
|
|
43
|
-
const new_stat_items = dashboard.stat_items.map(item => {
|
|
44
|
-
var _item$config, _item$config2, _item$config3;
|
|
45
|
-
if (!item.config) {
|
|
46
|
-
const newItem = {
|
|
47
|
-
config: {
|
|
48
|
-
...item,
|
|
49
|
-
...(0, _converStatItem.convertByType)(item)
|
|
50
|
-
},
|
|
51
|
-
layout: item.layout,
|
|
52
|
-
style_config: {
|
|
53
|
-
border: {},
|
|
54
|
-
title: {
|
|
55
|
-
text: item.name
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
return newItem;
|
|
60
|
-
}
|
|
61
|
-
const {
|
|
62
|
-
summary_columns
|
|
63
|
-
} = item.config || {};
|
|
64
|
-
if ((item === null || item === void 0 ? void 0 : (_item$config = item.config) === null || _item$config === void 0 ? void 0 : _item$config.type) === _seaChart.CHART_TYPE.TABLE && Array.isArray(summary_columns) && (summary_columns === null || summary_columns === void 0 ? void 0 : summary_columns.length) !== 0) {
|
|
65
|
-
const new_summary_columns = [];
|
|
66
|
-
summary_columns.forEach(item => {
|
|
67
|
-
if (Object.keys(item).length !== 0) {
|
|
68
|
-
new_summary_columns.push({
|
|
69
|
-
column_key: (item === null || item === void 0 ? void 0 : item.column_key) || (item === null || item === void 0 ? void 0 : item.key),
|
|
70
|
-
summary_method: (item === null || item === void 0 ? void 0 : item.summary_method) || (item === null || item === void 0 ? void 0 : item.method)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
item.config.summary_columns = [...new_summary_columns];
|
|
75
|
-
}
|
|
76
|
-
if ((item === null || item === void 0 ? void 0 : (_item$config2 = item.config) === null || _item$config2 === void 0 ? void 0 : _item$config2.type) === _seaChart.CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
77
|
-
const {
|
|
78
|
-
font_size,
|
|
79
|
-
font_weight,
|
|
80
|
-
font_color,
|
|
81
|
-
text_align,
|
|
82
|
-
card_label_font_size,
|
|
83
|
-
label_font_color,
|
|
84
|
-
label_font_weight,
|
|
85
|
-
label_text_align
|
|
86
|
-
} = item.config || {};
|
|
87
|
-
if (!font_size && !font_weight && !font_color && !text_align && !card_label_font_size && !label_font_color && !label_font_weight && !label_text_align) {
|
|
88
|
-
item.config = {
|
|
89
|
-
...item.config,
|
|
90
|
-
font_size: 34,
|
|
91
|
-
font_weight: 700,
|
|
92
|
-
card_label_font_size: 14,
|
|
93
|
-
label_font_weight: 400
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if ((item === null || item === void 0 ? void 0 : (_item$config3 = item.config) === null || _item$config3 === void 0 ? void 0 : _item$config3.type) === _seaChart.CHART_TYPE.TREND) {
|
|
98
|
-
const {
|
|
99
|
-
num_font_size,
|
|
100
|
-
num_font_weight,
|
|
101
|
-
num_font_color,
|
|
102
|
-
num_text_align,
|
|
103
|
-
card_label_font_size,
|
|
104
|
-
label_font_color,
|
|
105
|
-
label_font_weight,
|
|
106
|
-
label_text_align
|
|
107
|
-
} = item.config || {};
|
|
108
|
-
if (!num_font_size && !num_font_weight && !num_font_color && !num_text_align && !card_label_font_size && !label_font_color && !label_font_weight && !label_text_align) {
|
|
109
|
-
item.config = {
|
|
110
|
-
...item.config,
|
|
111
|
-
num_font_size: 34,
|
|
112
|
-
num_font_weight: 700,
|
|
113
|
-
card_label_font_size: 14,
|
|
114
|
-
label_font_weight: 400
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return item;
|
|
119
|
-
});
|
|
120
|
-
dashboard.stat_items = new_stat_items;
|
|
121
|
-
});
|
|
122
|
-
return value;
|
|
123
|
-
}
|
|
124
36
|
static getViewRows(view, table) {
|
|
125
37
|
const dtableStore = window.app.dtableStore || {};
|
|
126
38
|
const {
|
|
@@ -9,6 +9,7 @@ var _seaChart = require("sea-chart");
|
|
|
9
9
|
var _statisticDashboard = _interopRequireDefault(require("../model/statistic-dashboard"));
|
|
10
10
|
var _utils = require("../utils");
|
|
11
11
|
var _commonUtils = require("../utils/common-utils");
|
|
12
|
+
var _converStatItem = require("../model/conver-statItem");
|
|
12
13
|
var _constants = require("../constants");
|
|
13
14
|
const ADVANCED_STATISTICS_NAME = 'advanced-statistics';
|
|
14
15
|
class DashBoardService {
|
|
@@ -52,6 +53,9 @@ class DashBoardService {
|
|
|
52
53
|
if (hasAdvancedStatistics) {
|
|
53
54
|
this.mergeAdvancedStatistics(advancedStatistics, deletePluginSettings);
|
|
54
55
|
}
|
|
56
|
+
|
|
57
|
+
// convert to sea-chart
|
|
58
|
+
this.convertSeaChart();
|
|
55
59
|
if (this.needSave) {
|
|
56
60
|
this.needSave = false;
|
|
57
61
|
updateStatistics(this.statistics);
|
|
@@ -94,6 +98,89 @@ class DashBoardService {
|
|
|
94
98
|
name: this.defaultDashboardName
|
|
95
99
|
})];
|
|
96
100
|
}
|
|
101
|
+
convertSeaChart() {
|
|
102
|
+
this.statistics.forEach(dashboard => {
|
|
103
|
+
var _dashboard$stat_items;
|
|
104
|
+
const new_stat_items = dashboard === null || dashboard === void 0 ? void 0 : (_dashboard$stat_items = dashboard.stat_items) === null || _dashboard$stat_items === void 0 ? void 0 : _dashboard$stat_items.map(item => {
|
|
105
|
+
var _item$config, _item$config2, _item$config3;
|
|
106
|
+
if (!item.config) {
|
|
107
|
+
const newItem = {
|
|
108
|
+
config: {
|
|
109
|
+
...item,
|
|
110
|
+
...(0, _converStatItem.convertByType)(item)
|
|
111
|
+
},
|
|
112
|
+
layout: item.layout,
|
|
113
|
+
style_config: {
|
|
114
|
+
border: {},
|
|
115
|
+
title: {
|
|
116
|
+
text: item.name
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return newItem;
|
|
121
|
+
}
|
|
122
|
+
const {
|
|
123
|
+
summary_columns
|
|
124
|
+
} = item.config || {};
|
|
125
|
+
if ((item === null || item === void 0 ? void 0 : (_item$config = item.config) === null || _item$config === void 0 ? void 0 : _item$config.type) === _seaChart.CHART_TYPE.TABLE && Array.isArray(summary_columns) && (summary_columns === null || summary_columns === void 0 ? void 0 : summary_columns.length) !== 0) {
|
|
126
|
+
const new_summary_columns = [];
|
|
127
|
+
summary_columns.forEach(item => {
|
|
128
|
+
if (Object.keys(item).length !== 0) {
|
|
129
|
+
new_summary_columns.push({
|
|
130
|
+
column_key: (item === null || item === void 0 ? void 0 : item.column_key) || (item === null || item === void 0 ? void 0 : item.key),
|
|
131
|
+
summary_method: (item === null || item === void 0 ? void 0 : item.summary_method) || (item === null || item === void 0 ? void 0 : item.method)
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
item.config.summary_columns = [...new_summary_columns];
|
|
136
|
+
}
|
|
137
|
+
if ((item === null || item === void 0 ? void 0 : (_item$config2 = item.config) === null || _item$config2 === void 0 ? void 0 : _item$config2.type) === _seaChart.CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
138
|
+
const {
|
|
139
|
+
font_size,
|
|
140
|
+
font_weight,
|
|
141
|
+
font_color,
|
|
142
|
+
text_align,
|
|
143
|
+
card_label_font_size,
|
|
144
|
+
label_font_color,
|
|
145
|
+
label_font_weight,
|
|
146
|
+
label_text_align
|
|
147
|
+
} = item.config || {};
|
|
148
|
+
if (!font_size && !font_weight && !font_color && !text_align && !card_label_font_size && !label_font_color && !label_font_weight && !label_text_align) {
|
|
149
|
+
item.config = {
|
|
150
|
+
...item.config,
|
|
151
|
+
font_size: 34,
|
|
152
|
+
font_weight: 700,
|
|
153
|
+
card_label_font_size: 14,
|
|
154
|
+
label_font_weight: 400
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if ((item === null || item === void 0 ? void 0 : (_item$config3 = item.config) === null || _item$config3 === void 0 ? void 0 : _item$config3.type) === _seaChart.CHART_TYPE.TREND) {
|
|
159
|
+
const {
|
|
160
|
+
num_font_size,
|
|
161
|
+
num_font_weight,
|
|
162
|
+
num_font_color,
|
|
163
|
+
num_text_align,
|
|
164
|
+
card_label_font_size,
|
|
165
|
+
label_font_color,
|
|
166
|
+
label_font_weight,
|
|
167
|
+
label_text_align
|
|
168
|
+
} = item.config || {};
|
|
169
|
+
if (!num_font_size && !num_font_weight && !num_font_color && !num_text_align && !card_label_font_size && !label_font_color && !label_font_weight && !label_text_align) {
|
|
170
|
+
item.config = {
|
|
171
|
+
...item.config,
|
|
172
|
+
num_font_size: 34,
|
|
173
|
+
num_font_weight: 700,
|
|
174
|
+
card_label_font_size: 14,
|
|
175
|
+
label_font_weight: 400
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return item;
|
|
180
|
+
});
|
|
181
|
+
dashboard.stat_items = [...new_stat_items];
|
|
182
|
+
});
|
|
183
|
+
}
|
|
97
184
|
convertPivotTable(chart) {
|
|
98
185
|
const {
|
|
99
186
|
summary_type,
|
|
@@ -606,6 +606,7 @@ const updateTwoDimensionToTable = _ref6 => {
|
|
|
606
606
|
updateTable,
|
|
607
607
|
statisticalResult
|
|
608
608
|
} = _ref6;
|
|
609
|
+
console.log('updateTwoDimensionToTable');
|
|
609
610
|
const {
|
|
610
611
|
pivotResult,
|
|
611
612
|
groupbyColumn
|
|
@@ -660,16 +661,20 @@ const updateTwoDimensionToTable = _ref6 => {
|
|
|
660
661
|
const totalColumn = columnMap['total'];
|
|
661
662
|
if (row) {
|
|
662
663
|
// update old row
|
|
664
|
+
console.log(11);
|
|
663
665
|
const rowId = row._id;
|
|
664
666
|
let updatedRow = {};
|
|
665
667
|
let oldRow = {}; // op used
|
|
666
668
|
const validTotalCellValue = getValidValueForColumn(totalColumn, total);
|
|
669
|
+
console.log('22validTotalCellValue', validTotalCellValue);
|
|
667
670
|
if (totalColumn && (0, _cellValue.isCellValueChanged)(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
|
|
671
|
+
console.log('33', validTotalCellValue);
|
|
668
672
|
updatedRow[totalColumn.key] = validTotalCellValue;
|
|
669
673
|
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
670
674
|
}
|
|
671
675
|
const keys = Object.keys(cells);
|
|
672
676
|
if (keys.length === 0) {
|
|
677
|
+
console.log('44', updateColumns);
|
|
673
678
|
updateColumns.forEach(column => {
|
|
674
679
|
const {
|
|
675
680
|
key,
|
|
@@ -682,6 +687,7 @@ const updateTwoDimensionToTable = _ref6 => {
|
|
|
682
687
|
}
|
|
683
688
|
});
|
|
684
689
|
} else {
|
|
690
|
+
console.log('55', cells);
|
|
685
691
|
keys.forEach(key => {
|
|
686
692
|
const columnName = isEmptyName(key) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : key;
|
|
687
693
|
const column = columnMap[columnName];
|
|
@@ -728,6 +734,7 @@ const updateTwoDimensionWithSummaryColumnsToTable = _ref7 => {
|
|
|
728
734
|
updateTable,
|
|
729
735
|
statisticalResult
|
|
730
736
|
} = _ref7;
|
|
737
|
+
console.log('updateTwoDimensionWithSummaryColumnsToTable');
|
|
731
738
|
const {
|
|
732
739
|
groupbyColumn
|
|
733
740
|
} = statisticalResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.38-alpha.1",
|
|
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.
|
|
21
|
+
"sea-chart": "~0.0.84"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"dtable-ui-component": "~5.0.*",
|