dtable-statistic 4.3.5 → 4.3.7
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/calculator/base-calculator.js +16 -5
- package/es/calculator/basic-chart-calculator.js +17 -31
- package/es/calculator/combination-calculator.js +19 -30
- package/es/calculator/compare-bar-calculator.js +9 -20
- package/es/calculator/completeness-calculator.js +10 -24
- package/es/calculator/dashboard-calculator.js +6 -20
- package/es/calculator/heat-map-calculator.js +6 -20
- package/es/calculator/horizontal-bar-calculator.js +2 -13
- package/es/calculator/index.js +2 -0
- package/es/calculator/map-calculator.js +7 -21
- package/es/calculator/mirror-calculator.js +8 -22
- package/es/calculator/number-card-calculator.js +4 -18
- package/es/calculator/pivot-table-calculator.js +40 -54
- package/es/calculator/scatter-calculator.js +6 -20
- package/es/calculator/trend-calculator.js +6 -20
- package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
- package/es/calculator/workers/calculator.worker.js +5 -2
- package/es/calculator/workers/card-calculator-worker.js +13 -9
- package/es/calculator/workers/combination-calculator-worker.js +20 -16
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
- package/es/calculator/workers/completeness-calculator-worker.js +21 -17
- package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
- package/es/calculator/workers/mirror-calculator-worker.js +14 -10
- package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
- package/es/calculator/workers/scatter-calculator-worker.js +15 -11
- package/es/calculator/workers/trend-calculator-worker.js +14 -10
- package/es/calculator/world-map-calculator.js +6 -20
- package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
- package/es/components/dialog/statistic-record-dialog/index.js +21 -11
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
- package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
- package/es/components/popover/color-rules-popover.js +2 -2
- package/es/components/toast/alert.js +2 -0
- package/es/components/toast/toastManager.js +1 -0
- package/es/constants/color-rules.js +3 -3
- package/es/constants/index.js +9 -9
- package/es/dashboard.js +7 -13
- package/es/desktop-dashboard.js +1 -1
- package/es/locale/lang/de.js +10 -10
- package/es/locale/lang/en.js +8 -8
- package/es/locale/lang/fr.js +10 -10
- package/es/locale/lang/zh_CN.js +8 -8
- package/es/model/basic-number-card.js +3 -3
- package/es/model/compare-bar.js +2 -2
- package/es/model/generic-model.js +11 -11
- package/es/model/heat-map.js +2 -2
- package/es/model/horizontal-bar.js +2 -2
- package/es/model/index.js +3 -2
- package/es/model/map.js +3 -3
- package/es/model/mirror.js +2 -2
- package/es/model/trend.js +2 -2
- package/es/model/world-map.js +3 -3
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +1 -1
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
- package/es/stat-view/area-chart.js +4 -4
- package/es/stat-view/bar-chart.js +4 -4
- package/es/stat-view/base-chart.js +2 -2
- package/es/stat-view/basic-number-card.js +2 -2
- package/es/stat-view/combination-chart.js +9 -9
- package/es/stat-view/compare-chart.js +4 -4
- package/es/stat-view/completeness-chart.js +3 -3
- package/es/stat-view/custom-bar.js +2 -2
- package/es/stat-view/heat-map.js +2 -2
- package/es/stat-view/horizontal-bar-chart.js +4 -4
- package/es/stat-view/line-chart.js +4 -4
- package/es/stat-view/map.js +3 -3
- package/es/stat-view/mirror.js +2 -2
- package/es/stat-view/pivot-table/index.js +6 -6
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
- package/es/stat-view/pivot-table/pivot-table-display-name.js +41 -47
- package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
- package/es/stat-view/ring-chart.js +2 -2
- package/es/stat-view/scatter-chart.js +5 -5
- package/es/stat-view/treemap-chart.js +3 -2
- package/es/stat-view/trend-chart.js +2 -2
- package/es/stat-view/world-map.js +3 -3
- package/es/utils/cell-format.js +14 -15
- package/es/utils/cell-value.js +3 -3
- package/es/utils/color-utils.js +3 -3
- package/es/utils/column-utils.js +10 -10
- package/es/utils/column.js +2 -2
- package/es/utils/common-utils.js +10 -8
- package/es/utils/export-table-utils.js +38 -38
- package/es/utils/pivot-table.js +3 -3
- package/es/utils/row-utils.js +17 -17
- package/es/utils/search.js +14 -14
- package/es/utils/sql-utils.js +23 -20
- package/es/utils/stat-utils.js +55 -59
- package/es/utils/trend-utils.js +1 -0
- package/package.json +3 -2
package/es/utils/row-utils.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getCellValue = getCellValue;
|
|
7
7
|
exports.isValidRow = exports.isEmptyGeolocationCell = exports.getFormattedLabel = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _dtableUtils = require("dtable-utils");
|
|
9
9
|
var _utils = require("../utils");
|
|
10
10
|
const isEmptyGeolocationCell = (cellValue, format) => {
|
|
11
11
|
if (!cellValue) return null;
|
|
@@ -23,15 +23,15 @@ const isValidRow = (row, formulaRow, column, includeEmpty) => {
|
|
|
23
23
|
type: columnType,
|
|
24
24
|
key: columnKey
|
|
25
25
|
} = column;
|
|
26
|
-
if (includeEmpty || columnType ===
|
|
27
|
-
if (columnType ===
|
|
26
|
+
if (includeEmpty || columnType === _dtableUtils.CellType.CHECKBOX) return true;
|
|
27
|
+
if (columnType === _dtableUtils.CellType.GEOLOCATION) {
|
|
28
28
|
const {
|
|
29
29
|
geo_format
|
|
30
30
|
} = column.data;
|
|
31
31
|
return isEmptyGeolocationCell(row[columnKey], geo_format);
|
|
32
32
|
}
|
|
33
33
|
let cellValue = row[columnKey];
|
|
34
|
-
if (
|
|
34
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === _dtableUtils.CellType.LINK) {
|
|
35
35
|
cellValue = formulaRow ? formulaRow[columnKey] : null;
|
|
36
36
|
}
|
|
37
37
|
return cellValue || cellValue === 0;
|
|
@@ -42,7 +42,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
42
42
|
type: columnType,
|
|
43
43
|
data: columnData
|
|
44
44
|
} = column;
|
|
45
|
-
if (columnType ===
|
|
45
|
+
if (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
46
46
|
let options = columnData ? columnData.options : [];
|
|
47
47
|
let selectedOption = options.find(o => {
|
|
48
48
|
let id = name;
|
|
@@ -57,7 +57,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
57
57
|
if (selectedOption) {
|
|
58
58
|
return optionName;
|
|
59
59
|
}
|
|
60
|
-
} else if (columnType ===
|
|
60
|
+
} else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
|
|
61
61
|
let collaborator = collaborators.find(item => {
|
|
62
62
|
let email = name;
|
|
63
63
|
if (Array.isArray(name)) {
|
|
@@ -68,7 +68,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
68
68
|
if (collaborator) {
|
|
69
69
|
return collaborator.name;
|
|
70
70
|
}
|
|
71
|
-
} else if (columnType ===
|
|
71
|
+
} else if (columnType === _dtableUtils.CellType.CREATOR || columnType === _dtableUtils.CellType.LAST_MODIFIER) {
|
|
72
72
|
if (name === 'anonymous') {
|
|
73
73
|
return name;
|
|
74
74
|
} else {
|
|
@@ -77,25 +77,25 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
77
77
|
return collaborator.name;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
} else if (columnType ===
|
|
80
|
+
} else if (columnType === _dtableUtils.CellType.LINK) {
|
|
81
81
|
return (0, _utils.getClientFormulaDisplayString)(Array.isArray(name) ? name : [name], columnData, {
|
|
82
82
|
collaborators
|
|
83
83
|
});
|
|
84
|
-
} else if (columnType ===
|
|
84
|
+
} else if (columnType === _dtableUtils.CellType.CHECKBOX) {
|
|
85
85
|
return name === 'true' ? 'Checked' : 'Unchecked';
|
|
86
|
-
} else if (
|
|
86
|
+
} else if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
87
87
|
const {
|
|
88
88
|
result_type,
|
|
89
89
|
array_type
|
|
90
90
|
} = columnData || {};
|
|
91
|
-
if (!name && !(0,
|
|
92
|
-
if (result_type ===
|
|
91
|
+
if (!name && !(0, _dtableUtils.isNumber)(name)) return '';
|
|
92
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
93
93
|
const valueNumber = parseFloat(name);
|
|
94
|
-
return (0,
|
|
94
|
+
return (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, column.data) : name;
|
|
95
95
|
}
|
|
96
|
-
if (result_type ===
|
|
97
|
-
if (
|
|
98
|
-
if ([
|
|
96
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
97
|
+
if (_dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
98
|
+
if ([_dtableUtils.CellType.CREATOR, _dtableUtils.CellType.LAST_MODIFIER].includes(array_type) && name === 'anonymous') {
|
|
99
99
|
return name;
|
|
100
100
|
}
|
|
101
101
|
const collaborator = collaborators.find(item => {
|
|
@@ -123,7 +123,7 @@ function getCellValue(row, formulaRow, column) {
|
|
|
123
123
|
type,
|
|
124
124
|
key
|
|
125
125
|
} = column;
|
|
126
|
-
if (
|
|
126
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
127
127
|
const cellValue = formulaRow && formulaRow[key];
|
|
128
128
|
if (Array.isArray(cellValue)) {
|
|
129
129
|
return cellValue[0];
|
package/es/utils/search.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.searchRows = void 0;
|
|
8
8
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
var
|
|
9
|
+
var _dtableUtils = require("dtable-utils");
|
|
10
10
|
var _column = require("./column");
|
|
11
|
-
const SUPPORT_SEARCH_COLUMN_TYPES = [
|
|
11
|
+
const SUPPORT_SEARCH_COLUMN_TYPES = [_dtableUtils.CellType.DATE, _dtableUtils.CellType.TEXT, _dtableUtils.CellType.LONG_TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.URL, _dtableUtils.CellType.EMAIL, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.LAST_MODIFIER, _dtableUtils.CellType.CREATOR, _dtableUtils.CellType.COLLABORATOR, _dtableUtils.CellType.LINK, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.AUTO_NUMBER, _dtableUtils.CellType.GEOLOCATION, _dtableUtils.CellType.DURATION];
|
|
12
12
|
const searchRows = (rows, columns, val, processRow) => {
|
|
13
13
|
let dtableCollaborators = window.app.collaboratorsCache || [];
|
|
14
14
|
let collaborators = window.app.state.collaborators;
|
|
@@ -25,20 +25,20 @@ const searchRows = (rows, columns, val, processRow) => {
|
|
|
25
25
|
const cellValue = row[columnKey];
|
|
26
26
|
if (cellValue) {
|
|
27
27
|
let text;
|
|
28
|
-
if (columnType ===
|
|
28
|
+
if (columnType === _dtableUtils.CellType.LONG_TEXT) {
|
|
29
29
|
text = cellValue.text;
|
|
30
|
-
} else if (columnType ===
|
|
31
|
-
text = (0,
|
|
32
|
-
} else if (columnType ===
|
|
30
|
+
} else if (columnType === _dtableUtils.CellType.NUMBER || columnType === _dtableUtils.CellType.DURATION) {
|
|
31
|
+
text = (0, _dtableUtils.getNumberDisplayString)(cellValue, column.data);
|
|
32
|
+
} else if (columnType === _dtableUtils.CellType.SINGLE_SELECT) {
|
|
33
33
|
const options = (0, _column.getSelectColumnOptions)(column);
|
|
34
34
|
const option = options.find(option => option.id === cellValue);
|
|
35
35
|
text = option ? option.name : '';
|
|
36
|
-
} else if (columnType ===
|
|
36
|
+
} else if (columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
37
37
|
const options = (0, _column.getSelectColumnOptions)(column);
|
|
38
|
-
text = (0,
|
|
39
|
-
} else if (columnType ===
|
|
40
|
-
text = (0,
|
|
41
|
-
} else if (columnType ===
|
|
38
|
+
text = (0, _dtableUtils.getMultipleOptionName)(options, cellValue);
|
|
39
|
+
} else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
|
|
40
|
+
text = (0, _dtableUtils.getCollaboratorsName)(collaborators, cellValue);
|
|
41
|
+
} else if (columnType === _dtableUtils.CellType.LAST_MODIFIER || columnType === _dtableUtils.CellType.CREATOR) {
|
|
42
42
|
if (cellValue === 'anonymous') {
|
|
43
43
|
text = cellValue;
|
|
44
44
|
} else {
|
|
@@ -50,9 +50,9 @@ const searchRows = (rows, columns, val, processRow) => {
|
|
|
50
50
|
text = collaborator.name;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
} else if (columnType ===
|
|
54
|
-
text = (0,
|
|
55
|
-
} else if (columnType ===
|
|
53
|
+
} else if (columnType === _dtableUtils.CellType.GEOLOCATION) {
|
|
54
|
+
text = (0, _dtableUtils.getGeolocationDisplayString)(cellValue, column.data);
|
|
55
|
+
} else if (columnType === _dtableUtils.CellType.CTIME || columnType === _dtableUtils.CellType.MTIME) {
|
|
56
56
|
text = (0, _dayjs.default)(cellValue).format('YYYY-MM-DD HH:mm:ss');
|
|
57
57
|
} else {
|
|
58
58
|
text = cellValue;
|
package/es/utils/sql-utils.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getSqlString = exports.getSqlOrder = exports.getSqlGroup = exports.getPieChartSqlGroupName = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
8
|
var _constants = require("../constants");
|
|
9
9
|
const getSqlOrder = (sortType, groupName) => {
|
|
10
10
|
if (!sortType) {
|
|
@@ -33,7 +33,7 @@ const getSqlGroup = (granularity, column) => {
|
|
|
33
33
|
return "CONCATENATE(year(".concat(columnName, "), \"-Q\", quarter(").concat(columnName, "))");
|
|
34
34
|
}
|
|
35
35
|
return "YEAR(".concat(columnName, ")");
|
|
36
|
-
} else if (type ===
|
|
36
|
+
} else if (type === _dtableUtils.CellType.GEOLOCATION) {
|
|
37
37
|
if (granularity === _constants.STATISTICS_COUNT_TYPE.PROVINCE) {
|
|
38
38
|
return "PROVINCE(".concat(columnName, ")");
|
|
39
39
|
}
|
|
@@ -70,7 +70,10 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
70
70
|
isColumn,
|
|
71
71
|
isCurrentView,
|
|
72
72
|
isRow,
|
|
73
|
-
getTableById
|
|
73
|
+
getTableById,
|
|
74
|
+
username,
|
|
75
|
+
userId,
|
|
76
|
+
userDepartmentIdsMap
|
|
74
77
|
} = _ref;
|
|
75
78
|
const {
|
|
76
79
|
table_id,
|
|
@@ -80,7 +83,7 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
80
83
|
type
|
|
81
84
|
} = statItem;
|
|
82
85
|
const selectedTable = getTableById(table_id);
|
|
83
|
-
const selectedView =
|
|
86
|
+
const selectedView = (0, _dtableUtils.getViewById)(selectedTable.views, view_id);
|
|
84
87
|
const {
|
|
85
88
|
groupName,
|
|
86
89
|
selectedColumn,
|
|
@@ -89,7 +92,7 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
|
|
|
89
92
|
} = getDatabaseGroupName(statItem, selectedTable, {
|
|
90
93
|
isCurrentView
|
|
91
94
|
});
|
|
92
|
-
const sqlCondition = (0,
|
|
95
|
+
const sqlCondition = (0, _dtableUtils.filter2SqlCondition)(selectedTable, selectedView, username, userId, userDepartmentIdsMap);
|
|
93
96
|
const isGroup = column_groupby_column_key && !column_groupby_multiple_numeric_column;
|
|
94
97
|
const {
|
|
95
98
|
name,
|
|
@@ -143,7 +146,7 @@ const getSqlGroupName = (name, original_name, column) => {
|
|
|
143
146
|
const {
|
|
144
147
|
type
|
|
145
148
|
} = column || {};
|
|
146
|
-
if (type ===
|
|
149
|
+
if (type === _dtableUtils.CellType.SINGLE_SELECT || type === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
147
150
|
return "'".concat(name, "'");
|
|
148
151
|
}
|
|
149
152
|
const newName = original_name ? original_name : name;
|
|
@@ -161,7 +164,7 @@ const getGroupName = (selectedColumn, _ref2) => {
|
|
|
161
164
|
const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(selectedColumn.type);
|
|
162
165
|
if (isTimeColumn) {
|
|
163
166
|
groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
|
|
164
|
-
} else if (selectedColumn.type ===
|
|
167
|
+
} else if (selectedColumn.type === _dtableUtils.CellType.GEOLOCATION) {
|
|
165
168
|
groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
|
|
166
169
|
}
|
|
167
170
|
return groupName;
|
|
@@ -209,13 +212,13 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
209
212
|
groupby_geolocation_granularity = statItem.x_axis_geolocation_granularity;
|
|
210
213
|
}
|
|
211
214
|
if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
|
|
212
|
-
columnSelectedColumn =
|
|
215
|
+
columnSelectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column_groupby_column_key);
|
|
213
216
|
columnGroupName = getGroupName(columnSelectedColumn, {
|
|
214
217
|
groupby_date_granularity: column_groupby_date_granularity,
|
|
215
218
|
groupby_geolocation_granularity: column_groupby_geolocation_granularity
|
|
216
219
|
});
|
|
217
220
|
}
|
|
218
|
-
selectedColumn =
|
|
221
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, groupby_column_key);
|
|
219
222
|
groupName = getGroupName(selectedColumn, {
|
|
220
223
|
groupby_date_granularity,
|
|
221
224
|
groupby_geolocation_granularity
|
|
@@ -229,7 +232,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
229
232
|
geolocation_granularity,
|
|
230
233
|
geo_column
|
|
231
234
|
} = statItem;
|
|
232
|
-
selectedColumn =
|
|
235
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, geo_column);
|
|
233
236
|
groupName = getSqlGroup(geolocation_granularity, selectedColumn);
|
|
234
237
|
break;
|
|
235
238
|
}
|
|
@@ -240,7 +243,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
240
243
|
const {
|
|
241
244
|
column
|
|
242
245
|
} = statItem;
|
|
243
|
-
selectedColumn =
|
|
246
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column);
|
|
244
247
|
groupName = selectedColumn.name;
|
|
245
248
|
break;
|
|
246
249
|
}
|
|
@@ -249,7 +252,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
249
252
|
const {
|
|
250
253
|
time_column
|
|
251
254
|
} = statItem;
|
|
252
|
-
selectedColumn =
|
|
255
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, time_column);
|
|
253
256
|
groupName = "ISODATE(".concat(selectedColumn.name, ")");
|
|
254
257
|
break;
|
|
255
258
|
}
|
|
@@ -258,7 +261,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
258
261
|
const {
|
|
259
262
|
group_column
|
|
260
263
|
} = statItem;
|
|
261
|
-
selectedColumn =
|
|
264
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, group_column);
|
|
262
265
|
groupName = selectedColumn.name;
|
|
263
266
|
break;
|
|
264
267
|
}
|
|
@@ -273,7 +276,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
273
276
|
x_axis_column_key,
|
|
274
277
|
x_axis_date_granularity
|
|
275
278
|
} = statItem;
|
|
276
|
-
selectedColumn =
|
|
279
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column_key);
|
|
277
280
|
groupName = getSqlGroup(x_axis_date_granularity, selectedColumn);
|
|
278
281
|
break;
|
|
279
282
|
}
|
|
@@ -284,12 +287,12 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
284
287
|
x_axis_date_granularity: groupby_date_granularity,
|
|
285
288
|
x_axis_geolocation_granularity: groupby_geolocation_granularity
|
|
286
289
|
} = statItem;
|
|
287
|
-
selectedColumn =
|
|
290
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column_key);
|
|
288
291
|
if (!selectedColumn) return [];
|
|
289
292
|
groupName = "`".concat(selectedColumn.name, "`");
|
|
290
293
|
if (_constants.TIME_COLUMN_LIST.includes(selectedColumn.type)) {
|
|
291
294
|
groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
|
|
292
|
-
} else if (selectedColumn.type ===
|
|
295
|
+
} else if (selectedColumn.type === _dtableUtils.CellType.GEOLOCATION) {
|
|
293
296
|
groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
|
|
294
297
|
}
|
|
295
298
|
break;
|
|
@@ -300,7 +303,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
300
303
|
date_column,
|
|
301
304
|
date_granularity
|
|
302
305
|
} = statItem;
|
|
303
|
-
selectedColumn =
|
|
306
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, date_column);
|
|
304
307
|
groupName = getSqlGroup(date_granularity, selectedColumn);
|
|
305
308
|
break;
|
|
306
309
|
}
|
|
@@ -310,7 +313,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
310
313
|
const {
|
|
311
314
|
name_column
|
|
312
315
|
} = statItem;
|
|
313
|
-
selectedColumn =
|
|
316
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, name_column);
|
|
314
317
|
groupName = "`".concat(selectedColumn.name, "`");
|
|
315
318
|
break;
|
|
316
319
|
}
|
|
@@ -331,13 +334,13 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
|
|
|
331
334
|
column_groupby_multiple_numeric_column
|
|
332
335
|
} = statItem;
|
|
333
336
|
if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
|
|
334
|
-
columnSelectedColumn =
|
|
337
|
+
columnSelectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column_groupby_column_key);
|
|
335
338
|
columnGroupName = getGroupName(columnSelectedColumn, {
|
|
336
339
|
groupby_date_granularity: column_groupby_date_granularity,
|
|
337
340
|
groupby_geolocation_granularity: column_groupby_geolocation_granularity
|
|
338
341
|
});
|
|
339
342
|
}
|
|
340
|
-
selectedColumn =
|
|
343
|
+
selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, groupby_column_key);
|
|
341
344
|
groupName = getGroupName(selectedColumn, {
|
|
342
345
|
groupby_date_granularity,
|
|
343
346
|
groupby_geolocation_granularity
|
package/es/utils/stat-utils.js
CHANGED
|
@@ -4,16 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
8
|
var _utils = require("../utils");
|
|
9
|
+
var _collaborator = require("./collaborator");
|
|
9
10
|
var _constants = require("../constants");
|
|
10
|
-
const SUPPORT_SORT_COLUMNS = [
|
|
11
|
-
const getValidCollaborators = (collaborators, emails) => {
|
|
12
|
-
if (!Array.isArray(emails)) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
return emails.filter(e => collaborators.findIndex(c => c.email === e) > -1);
|
|
16
|
-
};
|
|
11
|
+
const SUPPORT_SORT_COLUMNS = [_dtableUtils.CellType.TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.DATE, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.RATE];
|
|
17
12
|
class StatUtils {
|
|
18
13
|
static getGroupLabel(cellValue, formulaRow, column, dateGranularity, geoGranularity, value) {
|
|
19
14
|
let {
|
|
@@ -22,20 +17,20 @@ class StatUtils {
|
|
|
22
17
|
data
|
|
23
18
|
} = column;
|
|
24
19
|
switch (type) {
|
|
25
|
-
case
|
|
20
|
+
case _dtableUtils.CellType.TEXT:
|
|
26
21
|
{
|
|
27
22
|
return cellValue || null;
|
|
28
23
|
}
|
|
29
|
-
case
|
|
24
|
+
case _dtableUtils.CellType.NUMBER:
|
|
30
25
|
{
|
|
31
26
|
if (!cellValue && cellValue !== 0) {
|
|
32
27
|
return null;
|
|
33
28
|
}
|
|
34
|
-
const number = (0,
|
|
29
|
+
const number = (0, _dtableUtils.getPrecisionNumber)(cellValue, data);
|
|
35
30
|
let valueNumber = parseFloat(number);
|
|
36
|
-
return (0,
|
|
31
|
+
return (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, column.data) : valueNumber;
|
|
37
32
|
}
|
|
38
|
-
case
|
|
33
|
+
case _dtableUtils.CellType.SINGLE_SELECT:
|
|
39
34
|
{
|
|
40
35
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
41
36
|
if (isInvalidValue) {
|
|
@@ -43,20 +38,20 @@ class StatUtils {
|
|
|
43
38
|
}
|
|
44
39
|
return cellValue;
|
|
45
40
|
}
|
|
46
|
-
case
|
|
47
|
-
case
|
|
48
|
-
case
|
|
41
|
+
case _dtableUtils.CellType.DATE:
|
|
42
|
+
case _dtableUtils.CellType.CTIME:
|
|
43
|
+
case _dtableUtils.CellType.MTIME:
|
|
49
44
|
{
|
|
50
45
|
if (!dateGranularity) {
|
|
51
|
-
return (0,
|
|
46
|
+
return (0, _dtableUtils.getDateDisplayString)(cellValue);
|
|
52
47
|
}
|
|
53
48
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
54
49
|
// TODO: fix the unknown word 'QUARTAR'
|
|
55
|
-
return
|
|
50
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
|
|
56
51
|
}
|
|
57
|
-
return
|
|
52
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity);
|
|
58
53
|
}
|
|
59
|
-
case
|
|
54
|
+
case _dtableUtils.CellType.MULTIPLE_SELECT:
|
|
60
55
|
{
|
|
61
56
|
let options = data && data.options;
|
|
62
57
|
if (!Array.isArray(cellValue)) {
|
|
@@ -64,44 +59,45 @@ class StatUtils {
|
|
|
64
59
|
}
|
|
65
60
|
return cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
66
61
|
}
|
|
67
|
-
case
|
|
62
|
+
case _dtableUtils.CellType.COLLABORATOR:
|
|
68
63
|
{
|
|
69
|
-
|
|
64
|
+
if (!Array.isArray(cellValue)) return [];
|
|
65
|
+
return cellValue.filter(email => (0, _collaborator.isValidCollaboratorEmail)(email));
|
|
70
66
|
}
|
|
71
|
-
case
|
|
72
|
-
case
|
|
67
|
+
case _dtableUtils.CellType.CREATOR:
|
|
68
|
+
case _dtableUtils.CellType.LAST_MODIFIER:
|
|
73
69
|
{
|
|
74
70
|
return cellValue ? cellValue : null;
|
|
75
71
|
}
|
|
76
|
-
case
|
|
77
|
-
case
|
|
72
|
+
case _dtableUtils.CellType.LINK_FORMULA:
|
|
73
|
+
case _dtableUtils.CellType.FORMULA:
|
|
78
74
|
{
|
|
79
75
|
if (!formulaRow) return '';
|
|
80
76
|
let formulaCellValue = formulaRow[key];
|
|
81
77
|
let {
|
|
82
78
|
result_type
|
|
83
79
|
} = data || {};
|
|
84
|
-
if (result_type ===
|
|
85
|
-
return (0,
|
|
80
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
81
|
+
return (0, _dtableUtils.getFormulaDisplayString)(formulaCellValue, data, {
|
|
86
82
|
tables: value.tables
|
|
87
83
|
}) || null;
|
|
88
84
|
}
|
|
89
|
-
if (result_type ===
|
|
90
|
-
return (0,
|
|
85
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
86
|
+
return (0, _dtableUtils.getPrecisionNumber)(formulaCellValue, data);
|
|
91
87
|
}
|
|
92
88
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
93
89
|
}
|
|
94
|
-
case
|
|
90
|
+
case _dtableUtils.CellType.GEOLOCATION:
|
|
95
91
|
{
|
|
96
92
|
const {
|
|
97
93
|
geo_format
|
|
98
94
|
} = data || {};
|
|
99
95
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
100
|
-
return (0,
|
|
96
|
+
return (0, _dtableUtils.getGeolocationDisplayString)(cellValue, data);
|
|
101
97
|
}
|
|
102
98
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
103
99
|
}
|
|
104
|
-
case
|
|
100
|
+
case _dtableUtils.CellType.LINK:
|
|
105
101
|
{
|
|
106
102
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
107
103
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -109,11 +105,11 @@ class StatUtils {
|
|
|
109
105
|
}
|
|
110
106
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
111
107
|
}
|
|
112
|
-
case
|
|
108
|
+
case _dtableUtils.CellType.CHECKBOX:
|
|
113
109
|
{
|
|
114
110
|
return String(!!cellValue);
|
|
115
111
|
}
|
|
116
|
-
case
|
|
112
|
+
case _dtableUtils.CellType.RATE:
|
|
117
113
|
{
|
|
118
114
|
if (!cellValue) return null;
|
|
119
115
|
return cellValue + '';
|
|
@@ -131,7 +127,7 @@ class StatUtils {
|
|
|
131
127
|
} = column;
|
|
132
128
|
let sortType = 'up';
|
|
133
129
|
let option_id_index_map = {};
|
|
134
|
-
if (column_type ===
|
|
130
|
+
if (column_type === _dtableUtils.CellType.SINGLE_SELECT) {
|
|
135
131
|
const {
|
|
136
132
|
options
|
|
137
133
|
} = data || {};
|
|
@@ -154,7 +150,7 @@ class StatUtils {
|
|
|
154
150
|
}
|
|
155
151
|
if (SUPPORT_SORT_COLUMNS.includes(column_type)) {
|
|
156
152
|
switch (column_type) {
|
|
157
|
-
case
|
|
153
|
+
case _dtableUtils.CellType.NUMBER:
|
|
158
154
|
{
|
|
159
155
|
if (current) {
|
|
160
156
|
current = current - 0;
|
|
@@ -162,42 +158,42 @@ class StatUtils {
|
|
|
162
158
|
if (next) {
|
|
163
159
|
next = next - 0;
|
|
164
160
|
}
|
|
165
|
-
return (0,
|
|
161
|
+
return (0, _dtableUtils.sortNumber)(current, next, sortType);
|
|
166
162
|
}
|
|
167
|
-
case
|
|
168
|
-
case
|
|
169
|
-
case
|
|
163
|
+
case _dtableUtils.CellType.DATE:
|
|
164
|
+
case _dtableUtils.CellType.CTIME:
|
|
165
|
+
case _dtableUtils.CellType.MTIME:
|
|
170
166
|
{
|
|
171
|
-
return (0,
|
|
167
|
+
return (0, _dtableUtils.sortDate)(current, next, sortType);
|
|
172
168
|
}
|
|
173
|
-
case
|
|
174
|
-
case
|
|
169
|
+
case _dtableUtils.CellType.SINGLE_SELECT:
|
|
170
|
+
case _dtableUtils.CellType.MULTIPLE_SELECT:
|
|
175
171
|
{
|
|
176
|
-
return (0,
|
|
172
|
+
return (0, _dtableUtils.sortSingleSelect)(current, next, {
|
|
177
173
|
sort_type: sortType,
|
|
178
174
|
option_id_index_map
|
|
179
175
|
});
|
|
180
176
|
}
|
|
181
|
-
case
|
|
182
|
-
case
|
|
177
|
+
case _dtableUtils.CellType.FORMULA:
|
|
178
|
+
case _dtableUtils.CellType.LINK_FORMULA:
|
|
183
179
|
{
|
|
184
180
|
let {
|
|
185
181
|
result_type
|
|
186
182
|
} = data || {};
|
|
187
|
-
if (result_type ===
|
|
183
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
188
184
|
if (current) {
|
|
189
185
|
current = current - 0;
|
|
190
186
|
}
|
|
191
187
|
if (next) {
|
|
192
188
|
next = next - 0;
|
|
193
189
|
}
|
|
194
|
-
return (0,
|
|
190
|
+
return (0, _dtableUtils.sortNumber)(current, next, sortType);
|
|
195
191
|
}
|
|
196
|
-
return (0,
|
|
192
|
+
return (0, _dtableUtils.sortText)(result_type, current, next, sortType);
|
|
197
193
|
}
|
|
198
194
|
default:
|
|
199
195
|
{
|
|
200
|
-
return (0,
|
|
196
|
+
return (0, _dtableUtils.sortText)(current, next, sortType);
|
|
201
197
|
}
|
|
202
198
|
}
|
|
203
199
|
}
|
|
@@ -239,7 +235,7 @@ class StatUtils {
|
|
|
239
235
|
let existMap = {};
|
|
240
236
|
rows.forEach(r => {
|
|
241
237
|
let num;
|
|
242
|
-
if (
|
|
238
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
243
239
|
const formulaRow = formula_rows[r._id] || {};
|
|
244
240
|
num = formulaRow[summary_column_key];
|
|
245
241
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -268,14 +264,14 @@ class StatUtils {
|
|
|
268
264
|
let validNumbersCount = 0;
|
|
269
265
|
rows.forEach(r => {
|
|
270
266
|
let num;
|
|
271
|
-
if (
|
|
267
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
272
268
|
let formulaRow = formula_rows[r._id] || {};
|
|
273
269
|
num = formulaRow[summary_column_key];
|
|
274
270
|
num = Array.isArray(num) ? num[0] : num;
|
|
275
271
|
} else {
|
|
276
272
|
num = r[summary_column_key];
|
|
277
273
|
}
|
|
278
|
-
if ((0,
|
|
274
|
+
if ((0, _dtableUtils.isNumber)(num)) {
|
|
279
275
|
validNumbersCount++;
|
|
280
276
|
sum += num;
|
|
281
277
|
}
|
|
@@ -293,7 +289,7 @@ class StatUtils {
|
|
|
293
289
|
if (rowsLength > 0) {
|
|
294
290
|
let result = rows.reduce((current, next) => {
|
|
295
291
|
let currentValue, nextValue;
|
|
296
|
-
if (
|
|
292
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
297
293
|
let currentFormulaRow = formula_rows[current._id];
|
|
298
294
|
let nextFormulaRow = formula_rows[next._id];
|
|
299
295
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -314,7 +310,7 @@ class StatUtils {
|
|
|
314
310
|
return isNextGreater ? next : current;
|
|
315
311
|
}
|
|
316
312
|
});
|
|
317
|
-
if (
|
|
313
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
318
314
|
let formulaRow = formula_rows[result._id];
|
|
319
315
|
total = formulaRow && formulaRow[summary_column_key];
|
|
320
316
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -343,10 +339,10 @@ class StatUtils {
|
|
|
343
339
|
type,
|
|
344
340
|
data
|
|
345
341
|
} = column;
|
|
346
|
-
if ((0,
|
|
347
|
-
return (0,
|
|
342
|
+
if ((0, _dtableUtils.isNumericColumn)(column)) {
|
|
343
|
+
return (0, _dtableUtils.getNumberDisplayString)(value, data);
|
|
348
344
|
}
|
|
349
|
-
if (
|
|
345
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
350
346
|
return (0, _utils.getClientFormulaDisplayString)(value, data);
|
|
351
347
|
}
|
|
352
348
|
return value;
|
package/es/utils/trend-utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.7",
|
|
4
4
|
"description": "statistics",
|
|
5
5
|
"main": "dist/dtable-statistic.js",
|
|
6
6
|
"author": "seafile",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@seafile/seafile-calendar": "0.0.24",
|
|
13
13
|
"comlink": "^4.3.1",
|
|
14
14
|
"dayjs": "1.10.7",
|
|
15
|
-
"dtable-
|
|
15
|
+
"dtable-utils": "4.3.3",
|
|
16
16
|
"dtable-web-api": "4.3.5",
|
|
17
17
|
"glamor": "^2.20.40",
|
|
18
18
|
"html2canvas": "^1.4.1",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
56
56
|
"dotenv": "^10.0.0",
|
|
57
57
|
"dotenv-expand": "^5.1.0",
|
|
58
|
+
"dtable-store": "4.3.6",
|
|
58
59
|
"eslint": "^8.3.0",
|
|
59
60
|
"eslint-config-react-app": "^7.0.1",
|
|
60
61
|
"eslint-webpack-plugin": "^3.1.1",
|