dtable-statistic 5.0.36 → 5.0.38-alpha.0
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 +6 -90
- package/es/service/dashboard-service.js +87 -0
- package/es/utils/export-table-utils.js +4 -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) {
|
|
@@ -13,16 +11,19 @@ class Statistic {
|
|
|
13
11
|
}
|
|
14
12
|
const {
|
|
15
13
|
state,
|
|
16
|
-
dtableStore
|
|
14
|
+
dtableStore,
|
|
15
|
+
collaboratorsCache = {}
|
|
17
16
|
} = window.app;
|
|
18
17
|
const {
|
|
19
18
|
value,
|
|
20
19
|
selectedTableIdx,
|
|
21
20
|
selectedViewId
|
|
22
21
|
} = state;
|
|
23
|
-
const
|
|
22
|
+
const collaboratorsCacheList = Object.values(collaboratorsCache) || [];
|
|
23
|
+
if (!value.collaborators) value.collaborators = [];
|
|
24
|
+
value.collaborators = value.collaborators.concat(collaboratorsCacheList);
|
|
24
25
|
return {
|
|
25
|
-
value
|
|
26
|
+
value,
|
|
26
27
|
eventBus: dtableStore.eventBus,
|
|
27
28
|
activeTableIdx: selectedTableIdx,
|
|
28
29
|
activeViewId: selectedViewId,
|
|
@@ -32,91 +33,6 @@ class Statistic {
|
|
|
32
33
|
deletePluginSettings: this.deletePluginSettings.bind(this, dtableStore)
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
// Compatible with old statistics
|
|
37
|
-
static convertStatistics(value) {
|
|
38
|
-
value.statistics.forEach(dashboard => {
|
|
39
|
-
const new_stat_items = dashboard.stat_items.map(item => {
|
|
40
|
-
var _item$config, _item$config2, _item$config3;
|
|
41
|
-
if (!item.config) {
|
|
42
|
-
const newItem = {
|
|
43
|
-
config: {
|
|
44
|
-
...item,
|
|
45
|
-
...(0, _converStatItem.convertByType)(item)
|
|
46
|
-
},
|
|
47
|
-
layout: item.layout,
|
|
48
|
-
style_config: {
|
|
49
|
-
border: {},
|
|
50
|
-
title: {
|
|
51
|
-
text: item.name
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return newItem;
|
|
56
|
-
}
|
|
57
|
-
const {
|
|
58
|
-
summary_columns
|
|
59
|
-
} = item.config || {};
|
|
60
|
-
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) {
|
|
61
|
-
const new_summary_columns = [];
|
|
62
|
-
summary_columns.forEach(item => {
|
|
63
|
-
if (Object.keys(item).length !== 0) {
|
|
64
|
-
new_summary_columns.push({
|
|
65
|
-
column_key: (item === null || item === void 0 ? void 0 : item.column_key) || (item === null || item === void 0 ? void 0 : item.key),
|
|
66
|
-
summary_method: (item === null || item === void 0 ? void 0 : item.summary_method) || (item === null || item === void 0 ? void 0 : item.method)
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
item.config.summary_columns = [...new_summary_columns];
|
|
71
|
-
}
|
|
72
|
-
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) {
|
|
73
|
-
const {
|
|
74
|
-
font_size,
|
|
75
|
-
font_weight,
|
|
76
|
-
font_color,
|
|
77
|
-
text_align,
|
|
78
|
-
card_label_font_size,
|
|
79
|
-
label_font_color,
|
|
80
|
-
label_font_weight,
|
|
81
|
-
label_text_align
|
|
82
|
-
} = item.config || {};
|
|
83
|
-
if (!font_size && !font_weight && !font_color && !text_align && !card_label_font_size && !label_font_color && !label_font_weight && !label_text_align) {
|
|
84
|
-
item.config = {
|
|
85
|
-
...item.config,
|
|
86
|
-
font_size: 34,
|
|
87
|
-
font_weight: 700,
|
|
88
|
-
card_label_font_size: 14,
|
|
89
|
-
label_font_weight: 400
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
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) {
|
|
94
|
-
const {
|
|
95
|
-
num_font_size,
|
|
96
|
-
num_font_weight,
|
|
97
|
-
num_font_color,
|
|
98
|
-
num_text_align,
|
|
99
|
-
card_label_font_size,
|
|
100
|
-
label_font_color,
|
|
101
|
-
label_font_weight,
|
|
102
|
-
label_text_align
|
|
103
|
-
} = item.config || {};
|
|
104
|
-
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) {
|
|
105
|
-
item.config = {
|
|
106
|
-
...item.config,
|
|
107
|
-
num_font_size: 34,
|
|
108
|
-
num_font_weight: 700,
|
|
109
|
-
card_label_font_size: 14,
|
|
110
|
-
label_font_weight: 400
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return item;
|
|
115
|
-
});
|
|
116
|
-
dashboard.stat_items = new_stat_items;
|
|
117
|
-
});
|
|
118
|
-
return value;
|
|
119
|
-
}
|
|
120
36
|
static getViewRows(view, table) {
|
|
121
37
|
const dtableStore = window.app.dtableStore || {};
|
|
122
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,6 +661,7 @@ 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
|
|
@@ -699,6 +701,7 @@ const updateTwoDimensionToTable = _ref6 => {
|
|
|
699
701
|
}
|
|
700
702
|
} else {
|
|
701
703
|
// insert new row
|
|
704
|
+
console.log(22);
|
|
702
705
|
let newRow = {};
|
|
703
706
|
newRow[nameColumnKey] = name;
|
|
704
707
|
if (totalColumn) {
|
|
@@ -728,6 +731,7 @@ const updateTwoDimensionWithSummaryColumnsToTable = _ref7 => {
|
|
|
728
731
|
updateTable,
|
|
729
732
|
statisticalResult
|
|
730
733
|
} = _ref7;
|
|
734
|
+
console.log('updateTwoDimensionWithSummaryColumnsToTable');
|
|
731
735
|
const {
|
|
732
736
|
groupbyColumn
|
|
733
737
|
} = 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.0",
|
|
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.*",
|