dtable-statistic 4.4.24-alpha.9 → 5.0.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/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/dashboard.css +0 -1
- package/es/assets/css/dialog.css +0 -30
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/calculator/base-calculator.js +80 -0
- package/es/calculator/basic-chart-calculator.js +349 -0
- package/es/calculator/combination-calculator.js +246 -0
- package/es/calculator/compare-bar-calculator.js +197 -0
- package/es/calculator/completeness-calculator.js +215 -0
- package/es/calculator/copy-value.js +53 -0
- package/es/calculator/dashboard-calculator.js +70 -0
- package/es/calculator/heat-map-calculator.js +148 -0
- package/es/calculator/horizontal-bar-calculator.js +67 -0
- package/es/calculator/index.js +81 -0
- package/es/calculator/map-calculator.js +103 -0
- package/es/calculator/mirror-calculator.js +146 -0
- package/es/calculator/number-card-calculator.js +60 -0
- package/es/calculator/pivot-table-calculator.js +821 -0
- package/es/calculator/scatter-calculator.js +75 -0
- package/es/calculator/thread-manager.js +57 -0
- package/es/calculator/trend-calculator.js +113 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +495 -0
- package/es/calculator/workers/calculator.worker.js +44 -0
- package/es/calculator/workers/card-calculator-worker.js +40 -0
- package/es/calculator/workers/combination-calculator-worker.js +276 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +150 -0
- package/es/calculator/workers/completeness-calculator-worker.js +208 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +68 -0
- package/es/calculator/workers/mirror-calculator-worker.js +152 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +718 -0
- package/es/calculator/workers/scatter-calculator-worker.js +80 -0
- package/es/calculator/workers/trend-calculator-worker.js +108 -0
- package/es/calculator/world-map-calculator.js +124 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +90 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +259 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +83 -0
- package/es/components/dialog/enlarged-chart-dialog.js +13 -8
- package/es/components/dialog/statistic-record-dialog/index.js +34 -25
- package/es/components/dialog/statistic-types-dialog/index.css +14 -0
- package/es/components/dialog/statistic-types-dialog/index.js +62 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +2 -2
- package/es/components/popover/color-rules/color-rule.js +183 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +221 -0
- package/es/components/popover/color-rules/rule-filters/index.css +210 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +78 -0
- package/es/components/popover/color-rules-popover.js +218 -0
- package/es/components/popover/color-selector-popover.js +83 -0
- package/es/constants/index.js +2 -1
- package/es/custom-g2.js +644 -0
- package/es/dashboard.js +31 -9
- package/es/desktop-dashboard.js +32 -51
- package/es/mobile-dashboard.js +16 -8
- package/es/model/bar-group.js +58 -0
- package/es/model/bar.js +47 -0
- package/es/model/base-model.js +18 -0
- package/es/model/basic-number-card.js +25 -0
- package/es/model/combination.js +48 -0
- package/es/model/compare-bar.js +56 -0
- package/es/model/completeness-group.js +31 -0
- package/es/model/completeness.js +25 -0
- package/es/model/custom-bar.js +25 -0
- package/es/model/dashboard.js +20 -0
- package/es/model/generic-model.js +222 -0
- package/es/model/heat-map.js +33 -0
- package/es/model/horizontal-bar-group.js +55 -0
- package/es/model/horizontal-bar.js +47 -0
- package/es/model/index.js +187 -0
- package/es/model/map.js +38 -0
- package/es/model/mirror.js +33 -0
- package/es/model/pie.js +38 -0
- package/es/model/ring.js +40 -0
- package/es/model/scatter.js +22 -0
- package/es/model/table.js +32 -0
- package/es/model/trend.js +32 -0
- package/es/model/world-map.js +34 -0
- package/es/service/chart-service.js +15 -8
- package/es/service/dashboard-service.js +29 -25
- package/es/stat-editor/chart-name-editor.js +68 -0
- package/es/stat-editor/index.js +75 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +153 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +422 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +203 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +23 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +104 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +334 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +119 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +240 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +331 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +143 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +144 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +214 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +121 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +172 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +366 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +142 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +473 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +182 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +564 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +112 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +87 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +187 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +300 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +113 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +289 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +58 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +359 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +48 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +121 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +143 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +269 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +104 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +366 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +55 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +130 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +374 -0
- package/es/stat-editor/stat-settings/map/map-level.js +72 -0
- package/es/stat-editor/stat-settings/map/map-province-city.js +151 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +108 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +154 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +125 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +24 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +62 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +61 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +35 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +123 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +33 -0
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.css +29 -0
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +82 -0
- package/es/stat-list/chart-preview.js +20 -19
- package/es/stat-list/index.js +21 -15
- package/es/stat-view/area-chart.js +551 -0
- package/es/stat-view/bar-chart.js +582 -0
- package/es/stat-view/base-chart.js +132 -0
- package/es/stat-view/basic-number-card.js +201 -0
- package/es/stat-view/combination-chart.js +546 -0
- package/es/stat-view/compare-chart.js +483 -0
- package/es/stat-view/completeness-chart.js +390 -0
- package/es/stat-view/custom-bar.js +418 -0
- package/es/stat-view/dashboard-chart.js +266 -0
- package/es/stat-view/heat-map.js +463 -0
- package/es/stat-view/horizontal-bar-chart.js +562 -0
- package/es/stat-view/index.js +156 -47
- package/es/stat-view/line-chart.js +518 -0
- package/es/stat-view/map.js +448 -0
- package/es/stat-view/mirror.js +275 -0
- package/es/stat-view/pie-chart.js +290 -0
- package/es/stat-view/pivot-table/index.js +196 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +156 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +176 -0
- package/es/stat-view/pivot-table/pivot-table-display-name.js +215 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +384 -0
- package/es/stat-view/ring-chart.js +392 -0
- package/es/stat-view/scatter-chart.js +306 -0
- package/es/stat-view/treemap-chart.js +253 -0
- package/es/stat-view/trend-chart.js +249 -0
- package/es/stat-view/world-map.js +431 -0
- package/es/tabs/tab.js +2 -2
- package/es/utils/basic-chart-utils.js +29 -0
- package/es/utils/cell-format.js +115 -0
- package/es/utils/collaborator.js +50 -0
- package/es/utils/color-utils.js +134 -0
- package/es/utils/column-utils.js +110 -0
- package/es/utils/column.js +20 -0
- package/es/utils/common-utils.js +352 -2
- package/es/utils/date-format.js +71 -0
- package/es/utils/export-table-utils.js +69 -0
- package/es/utils/index.js +89 -12
- package/es/utils/map.js +114 -0
- package/es/utils/model.js +19 -0
- package/es/utils/row-utils.js +134 -0
- package/es/utils/search.js +73 -0
- package/es/utils/sql-utils.js +359 -0
- package/es/utils/stat-utils.js +351 -0
- package/es/utils/trend-utils.js +135 -0
- package/package.json +8 -6
- package/es/components/dialog/chart-edit-dialog.js +0 -93
- package/es/components/dtable-popover.js +0 -97
- package/es/components/dtable-search-input.js +0 -135
- package/es/components/index.js +0 -41
- package/es/components/loading.js +0 -15
- package/es/components/modal-portal.js +0 -26
- package/es/model/conver-statItem.js +0 -124
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getValidColorRules = exports.getLabelColorFromSpecificColor = exports.getLabelColorFromColorRules = exports.getLabelColor = exports.getConvertedColorRules = void 0;
|
|
7
|
+
var _dtableUtils = require("dtable-utils");
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
var _colorRules = require("../constants/color-rules");
|
|
10
|
+
const getValidColorRules = colorRules => {
|
|
11
|
+
if (!Array.isArray(colorRules) || colorRules.length === 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const columns = [];
|
|
15
|
+
const keyExistColumnMap = {};
|
|
16
|
+
colorRules.forEach(colorRule => {
|
|
17
|
+
colorRule.filters.forEach(filter => {
|
|
18
|
+
const filterType = filter.filter_type;
|
|
19
|
+
if (keyExistColumnMap[filterType]) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
columns.push({
|
|
23
|
+
key: _colorRules.COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE,
|
|
24
|
+
type: _colorRules.FILTER_TYPE_2_CELL_TYPE[filterType]
|
|
25
|
+
});
|
|
26
|
+
keyExistColumnMap[filterType] = true;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return colorRules.map(colorRule => {
|
|
30
|
+
const {
|
|
31
|
+
filters
|
|
32
|
+
} = colorRule;
|
|
33
|
+
const convertedFilters = filters.map(filter => {
|
|
34
|
+
return {
|
|
35
|
+
...filter,
|
|
36
|
+
column_key: filter.filter_type
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
const validFilters = (0, _dtableUtils.getValidFilters)(convertedFilters, columns);
|
|
40
|
+
if (validFilters.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...colorRule,
|
|
45
|
+
filters: validFilters
|
|
46
|
+
};
|
|
47
|
+
}).filter(Boolean);
|
|
48
|
+
};
|
|
49
|
+
exports.getValidColorRules = getValidColorRules;
|
|
50
|
+
const getConvertedColorRules = colorRules => {
|
|
51
|
+
const validColorRules = getValidColorRules(colorRules);
|
|
52
|
+
return validColorRules.map(colorRule => {
|
|
53
|
+
const convertedFilters = colorRule.filters.map(filter => {
|
|
54
|
+
const {
|
|
55
|
+
filter_type
|
|
56
|
+
} = filter;
|
|
57
|
+
return {
|
|
58
|
+
...filter,
|
|
59
|
+
column_key: filter_type,
|
|
60
|
+
column: {
|
|
61
|
+
key: filter_type,
|
|
62
|
+
type: _colorRules.FILTER_TYPE_2_CELL_TYPE[filter_type]
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
...colorRule,
|
|
68
|
+
filters: convertedFilters
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
exports.getConvertedColorRules = getConvertedColorRules;
|
|
73
|
+
const getLabelColorFromSpecificColor = chart => {
|
|
74
|
+
switch (chart.type) {
|
|
75
|
+
case _constants.STAT_TYPE.BAR:
|
|
76
|
+
{
|
|
77
|
+
return chart.y_axis_label_color;
|
|
78
|
+
}
|
|
79
|
+
case _constants.STAT_TYPE.HORIZONTAL_BAR:
|
|
80
|
+
{
|
|
81
|
+
return chart.horizontal_axis_label_color;
|
|
82
|
+
}
|
|
83
|
+
default:
|
|
84
|
+
{
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
exports.getLabelColorFromSpecificColor = getLabelColorFromSpecificColor;
|
|
90
|
+
const getLabelColorFromColorRules = (colorRules, value) => {
|
|
91
|
+
if (!colorRules) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const row = {
|
|
95
|
+
'numeric_value': value
|
|
96
|
+
};
|
|
97
|
+
let matchedRuleColor = null;
|
|
98
|
+
for (let i = 0, colorRulesLen = colorRules.length; i < colorRulesLen; i++) {
|
|
99
|
+
const colorRule = colorRules[i];
|
|
100
|
+
const {
|
|
101
|
+
color,
|
|
102
|
+
filter_conjunction,
|
|
103
|
+
filters
|
|
104
|
+
} = colorRule;
|
|
105
|
+
if ((0, _dtableUtils.filterRow)(row, filter_conjunction, filters)) {
|
|
106
|
+
matchedRuleColor = color;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return matchedRuleColor;
|
|
111
|
+
};
|
|
112
|
+
exports.getLabelColorFromColorRules = getLabelColorFromColorRules;
|
|
113
|
+
const getLabelColor = _ref => {
|
|
114
|
+
let {
|
|
115
|
+
chart,
|
|
116
|
+
colorRules,
|
|
117
|
+
value
|
|
118
|
+
} = _ref;
|
|
119
|
+
switch (chart.color_option) {
|
|
120
|
+
case _constants.TYPE_COLOR_USING.USE_SPECIFIC_COLORS:
|
|
121
|
+
{
|
|
122
|
+
return getLabelColorFromSpecificColor(chart);
|
|
123
|
+
}
|
|
124
|
+
case _constants.TYPE_COLOR_USING.USE_RULES:
|
|
125
|
+
{
|
|
126
|
+
return getLabelColorFromColorRules(colorRules, value);
|
|
127
|
+
}
|
|
128
|
+
default:
|
|
129
|
+
{
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
exports.getLabelColor = getLabelColor;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getColorFromSingleSelectColumn = getColorFromSingleSelectColumn;
|
|
7
|
+
exports.isWorldMapColumn = exports.isStatisticDateColumn = exports.isMirrorColumn = exports.isMapColumn = void 0;
|
|
8
|
+
var _dtableUtils = require("dtable-utils");
|
|
9
|
+
var _constants = require("../constants");
|
|
10
|
+
function getColorFromSingleSelectColumn(column, target) {
|
|
11
|
+
let {
|
|
12
|
+
type: columnType,
|
|
13
|
+
data: columnData
|
|
14
|
+
} = column;
|
|
15
|
+
if (columnType !== _dtableUtils.CellType.SINGLE_SELECT) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const options = columnData ? columnData.options : [];
|
|
19
|
+
const selectedOption = options.find(option => {
|
|
20
|
+
let id = target;
|
|
21
|
+
if (Array.isArray(target)) {
|
|
22
|
+
id = target[0];
|
|
23
|
+
}
|
|
24
|
+
return option.id === id;
|
|
25
|
+
});
|
|
26
|
+
const color = selectedOption && selectedOption.color;
|
|
27
|
+
return color || null;
|
|
28
|
+
}
|
|
29
|
+
const isStatisticDateColumn = column => {
|
|
30
|
+
if (!column) return false;
|
|
31
|
+
return (0, _dtableUtils.isDateColumn)(column);
|
|
32
|
+
};
|
|
33
|
+
exports.isStatisticDateColumn = isStatisticDateColumn;
|
|
34
|
+
const isMapColumn = column => {
|
|
35
|
+
if (!column) return false;
|
|
36
|
+
const {
|
|
37
|
+
type,
|
|
38
|
+
data
|
|
39
|
+
} = column;
|
|
40
|
+
if (type === _dtableUtils.CellType.GEOLOCATION) {
|
|
41
|
+
const {
|
|
42
|
+
geo_format
|
|
43
|
+
} = data || {};
|
|
44
|
+
if (geo_format === 'lng_lat' || geo_format === 'country_region') {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
50
|
+
const {
|
|
51
|
+
result_type,
|
|
52
|
+
array_type,
|
|
53
|
+
array_data
|
|
54
|
+
} = data || {};
|
|
55
|
+
if (result_type !== _dtableUtils.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableUtils.CellType.GEOLOCATION) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const {
|
|
59
|
+
geo_format
|
|
60
|
+
} = array_data || {};
|
|
61
|
+
if (geo_format === 'lng_lat' || geo_format === 'country_region') {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
exports.isMapColumn = isMapColumn;
|
|
69
|
+
const isMirrorColumn = column => {
|
|
70
|
+
if (!column) return false;
|
|
71
|
+
return _constants.MIRROR_COLUMN_LIST.includes(column.type);
|
|
72
|
+
};
|
|
73
|
+
exports.isMirrorColumn = isMirrorColumn;
|
|
74
|
+
const isWorldMapColumn = column => {
|
|
75
|
+
if (!column) return false;
|
|
76
|
+
const {
|
|
77
|
+
type,
|
|
78
|
+
data
|
|
79
|
+
} = column;
|
|
80
|
+
if (type === _dtableUtils.CellType.TEXT) return true;
|
|
81
|
+
if (type === _dtableUtils.CellType.GEOLOCATION) {
|
|
82
|
+
const {
|
|
83
|
+
geo_format
|
|
84
|
+
} = data || {};
|
|
85
|
+
if (geo_format === 'country_region') {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
90
|
+
const {
|
|
91
|
+
data
|
|
92
|
+
} = column;
|
|
93
|
+
const {
|
|
94
|
+
result_type,
|
|
95
|
+
array_type,
|
|
96
|
+
array_data
|
|
97
|
+
} = data || {};
|
|
98
|
+
if (result_type !== _dtableUtils.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableUtils.CellType.GEOLOCATION) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const {
|
|
102
|
+
geo_format
|
|
103
|
+
} = array_data || {};
|
|
104
|
+
if (geo_format === 'country_region') {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
};
|
|
110
|
+
exports.isWorldMapColumn = isWorldMapColumn;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDateColumnFormat = getDateColumnFormat;
|
|
7
|
+
exports.getSelectColumnOptions = getSelectColumnOptions;
|
|
8
|
+
var _dtableUtils = require("dtable-utils");
|
|
9
|
+
function getSelectColumnOptions(column) {
|
|
10
|
+
if (!column || !column.data || !Array.isArray(column.data.options)) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
return column.data.options;
|
|
14
|
+
}
|
|
15
|
+
function getDateColumnFormat(column) {
|
|
16
|
+
let format = column && column.data && column.data.format ? column.data.format : _dtableUtils.DEFAULT_DATE_FORMAT;
|
|
17
|
+
// Old Europe format is D/M/YYYY new format is DD/MM/YYYY
|
|
18
|
+
format = format.replace(/D\/M\/YYYY/, 'DD/MM/YYYY');
|
|
19
|
+
return format;
|
|
20
|
+
}
|
package/es/utils/common-utils.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.
|
|
7
|
+
exports.arraysEqual = arraysEqual;
|
|
8
|
+
exports.formatNumericValue = void 0;
|
|
9
|
+
exports.formatPieChartData = formatPieChartData;
|
|
10
|
+
exports.isShapeEqual = exports.isBoolean = exports.isArrayCellValue = exports.getSummaryResult = exports.getSummaryColumnMethod = exports.getLabelFontSize = exports.getImageUrl = exports.getCurrentTheme = exports.generatorUniqueId = void 0;
|
|
11
|
+
exports.isStatItemEqual = isStatItemEqual;
|
|
12
|
+
exports.shallowEqual = shallowEqual;
|
|
13
|
+
exports.sortDataByGroupSum = exports.shouldCalculateStatItem = void 0;
|
|
7
14
|
var _dtableUtils = require("dtable-utils");
|
|
15
|
+
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
16
|
+
var _constants = require("../constants");
|
|
17
|
+
var _statUtils = _interopRequireDefault(require("./stat-utils"));
|
|
8
18
|
const generatorUniqueId = list => {
|
|
9
19
|
let uniqueId;
|
|
10
20
|
let isUnique = false;
|
|
@@ -24,4 +34,344 @@ const generatorUniqueId = list => {
|
|
|
24
34
|
}
|
|
25
35
|
return uniqueId;
|
|
26
36
|
};
|
|
27
|
-
exports.generatorUniqueId = generatorUniqueId;
|
|
37
|
+
exports.generatorUniqueId = generatorUniqueId;
|
|
38
|
+
const getImageUrl = imageName => {
|
|
39
|
+
const {
|
|
40
|
+
mediaUrl
|
|
41
|
+
} = window.dtable;
|
|
42
|
+
return "".concat(mediaUrl, "dtable-statistic/img/").concat(imageName);
|
|
43
|
+
};
|
|
44
|
+
exports.getImageUrl = getImageUrl;
|
|
45
|
+
const isShapeEqual = (position1, position2) => {
|
|
46
|
+
if (position1 && position2) {
|
|
47
|
+
return position1.w === position2.w && position1.h === position2.h;
|
|
48
|
+
}
|
|
49
|
+
if (!position1 && !position2) return true;
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
52
|
+
exports.isShapeEqual = isShapeEqual;
|
|
53
|
+
function isStatItemEqual(prevStatItem, chart) {
|
|
54
|
+
let statItemType = prevStatItem.type;
|
|
55
|
+
if (statItemType !== chart.type) return false;
|
|
56
|
+
return shallowEqual(prevStatItem, chart);
|
|
57
|
+
}
|
|
58
|
+
function shallowEqual(objA, objB) {
|
|
59
|
+
if (objA === objB) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const keysA = Object.keys(objA);
|
|
66
|
+
const keysB = Object.keys(objB);
|
|
67
|
+
if (keysA.length !== keysB.length) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
71
|
+
let key = keysA[i];
|
|
72
|
+
let valueA = objA[key];
|
|
73
|
+
let valueB = objB[key];
|
|
74
|
+
if (key === 'layout') continue;
|
|
75
|
+
// line | chart-bar | chart-bar-stack | chart-bar-group
|
|
76
|
+
if (key === 'show_x_axis_label') continue;
|
|
77
|
+
if (key === 'show_y_axis_label') continue;
|
|
78
|
+
if (key === 'x_axis_label_position') continue;
|
|
79
|
+
if (key === 'y_axis_label_position') continue;
|
|
80
|
+
|
|
81
|
+
// horizontal bar | horizontal group bar
|
|
82
|
+
if (key === 'show_vertical_axis_label') continue;
|
|
83
|
+
if (key === 'show_horizontal_axis_label') continue;
|
|
84
|
+
if (key === 'vertical_axis_label_position') continue;
|
|
85
|
+
if (key === 'horizontal_axis_label_position') continue;
|
|
86
|
+
|
|
87
|
+
// combination chart
|
|
88
|
+
if (key === 'show_y_axis_left_label') continue;
|
|
89
|
+
if (key === 'show_y_axis_right_label') continue;
|
|
90
|
+
if (key === 'y_axis_left_label_position') continue;
|
|
91
|
+
if (key === 'y_axis_right_label_position') continue;
|
|
92
|
+
if (objA.type !== 'basic_number_card' && objA.type !== _constants.STAT_TYPE.DASHBOARD && key === 'name') continue;
|
|
93
|
+
if (Object.prototype.hasOwnProperty.call(objB, key)) {
|
|
94
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
95
|
+
let isArrayEqual = arraysEqual(valueA, valueB);
|
|
96
|
+
if (!isArrayEqual) return false;
|
|
97
|
+
} else if (valueA !== valueB) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!isShapeEqual(objA.layout, objB.layout)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
const IGNORE_STAT_KEYS = ['layout', 'name', 'show_y_axis_label', 'show_x_axis_label', 'show_vertical_axis_label', 'show_horizontal_axis_label', 'vertical_axis_label_position', 'horizontal_axis_label_position', 'horizontal_axis_label_color', 'y_axis_label_color', 'data_color', 'display_data', 'show_y_axis_left_label', 'show_y_axis_right_label', 'x_axis_label_position', 'y_axis_label_position', 'y_axis_left_color', 'y_axis_right_color', 'y_axis_left_label_position', 'y_axis_right_label_position', 'minimum_slice_percent', 'bubble_color', 'map_type', 'legend_direction', 'legend_size', 'completed_color', 'uncompleted_color', 'display_percentage', 'label_font_size'];
|
|
110
|
+
const shouldCalculateStatItem = (prevStatItem, chart) => {
|
|
111
|
+
let statItemType = prevStatItem.type;
|
|
112
|
+
if (statItemType !== chart.type) return true;
|
|
113
|
+
if (prevStatItem === chart) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (typeof prevStatItem !== 'object' || !prevStatItem || typeof chart !== 'object' || !chart) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const keysA = Object.keys(prevStatItem);
|
|
120
|
+
const keysB = Object.keys(chart);
|
|
121
|
+
if (keysA.length !== keysB.length) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
125
|
+
let key = keysA[i];
|
|
126
|
+
let valueA = prevStatItem[key];
|
|
127
|
+
let valueB = chart[key];
|
|
128
|
+
if (IGNORE_STAT_KEYS.includes(key)) continue;
|
|
129
|
+
if (Object.prototype.hasOwnProperty.call(chart, key)) {
|
|
130
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
131
|
+
let isArrayEqual = arraysEqual(valueA, valueB);
|
|
132
|
+
if (!isArrayEqual) return true;
|
|
133
|
+
} else if (valueA !== valueB) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
};
|
|
142
|
+
exports.shouldCalculateStatItem = shouldCalculateStatItem;
|
|
143
|
+
function arraysEqual(arrayA, arrayB) {
|
|
144
|
+
if (arrayA === null || arrayB === null) return false;
|
|
145
|
+
if (arrayA.length !== arrayB.length) return false;
|
|
146
|
+
for (let i = 0; i < arrayA.length; i++) {
|
|
147
|
+
if (!shallowEqual(arrayA[i], arrayB[i])) return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
const isArrayCellValue = column => {
|
|
152
|
+
if (!column) return false;
|
|
153
|
+
const {
|
|
154
|
+
type,
|
|
155
|
+
data
|
|
156
|
+
} = column;
|
|
157
|
+
return _constants.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[type] || _dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] && data && data.result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY && _dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(data.array_type) // the collaborator lookup is not formatted
|
|
158
|
+
;
|
|
159
|
+
};
|
|
160
|
+
exports.isArrayCellValue = isArrayCellValue;
|
|
161
|
+
const getSummaryResult = function (results, summaryMethod) {
|
|
162
|
+
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
163
|
+
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => (0, _dtableUtils.isNumber)(res)) : [];
|
|
164
|
+
switch (summaryMethod) {
|
|
165
|
+
case _constants.SUMMARY_METHOD_MAP.Max:
|
|
166
|
+
{
|
|
167
|
+
return getMax(numericResults);
|
|
168
|
+
}
|
|
169
|
+
case _constants.SUMMARY_METHOD_MAP.Min:
|
|
170
|
+
{
|
|
171
|
+
return getMin(numericResults);
|
|
172
|
+
}
|
|
173
|
+
case _constants.SUMMARY_METHOD_MAP.Sum:
|
|
174
|
+
{
|
|
175
|
+
return getSum(numericResults, precision);
|
|
176
|
+
}
|
|
177
|
+
case _constants.SUMMARY_METHOD_MAP.Mean:
|
|
178
|
+
{
|
|
179
|
+
return getMean(numericResults, precision);
|
|
180
|
+
}
|
|
181
|
+
case _constants.SUMMARY_METHOD_MAP.Distinct_values:
|
|
182
|
+
{
|
|
183
|
+
let count = 0;
|
|
184
|
+
let existMap = {};
|
|
185
|
+
Array.isArray(results) && results.forEach(resNum => {
|
|
186
|
+
let num = resNum;
|
|
187
|
+
if (!num) {
|
|
188
|
+
if (num === 0) {
|
|
189
|
+
num = '0';
|
|
190
|
+
} else {
|
|
191
|
+
num = !!num;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!existMap[num]) {
|
|
195
|
+
existMap[num] = true;
|
|
196
|
+
count++;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return count;
|
|
200
|
+
}
|
|
201
|
+
default:
|
|
202
|
+
{
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
exports.getSummaryResult = getSummaryResult;
|
|
208
|
+
const getMax = list => {
|
|
209
|
+
if (list.length === 0) return 0;
|
|
210
|
+
return Number.parseFloat(Math.max.apply(null, list));
|
|
211
|
+
};
|
|
212
|
+
const getMin = list => {
|
|
213
|
+
if (list.length === 0) return 0;
|
|
214
|
+
return Number.parseFloat(Math.min.apply(null, list).toFixed(8));
|
|
215
|
+
};
|
|
216
|
+
const getSum = function (list) {
|
|
217
|
+
let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
|
218
|
+
if (list.length === 0) return 0;
|
|
219
|
+
const sum = list.reduce((a, b) => {
|
|
220
|
+
return a + b;
|
|
221
|
+
}, 0);
|
|
222
|
+
return Number.parseFloat(Number(sum).toFixed(8));
|
|
223
|
+
};
|
|
224
|
+
const getMean = function (list) {
|
|
225
|
+
let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 8;
|
|
226
|
+
if (list.length === 0) return 0;
|
|
227
|
+
const sum = getSum(list);
|
|
228
|
+
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
229
|
+
};
|
|
230
|
+
const getPieColor = (color_option, column, index, data, currentTheme) => {
|
|
231
|
+
let {
|
|
232
|
+
type: columnType,
|
|
233
|
+
data: columnData
|
|
234
|
+
} = column;
|
|
235
|
+
const {
|
|
236
|
+
colors
|
|
237
|
+
} = currentTheme;
|
|
238
|
+
if (color_option === _constants.PIE_COLOR_OPTIONS[1] && (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT)) {
|
|
239
|
+
if (columnData && columnData.options) {
|
|
240
|
+
const selectedItem = columnData.options.find(item => item.name === data.name) || {};
|
|
241
|
+
return selectedItem.color || '#dbdbdb';
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
const sIndex = String(index);
|
|
245
|
+
const colorIndex = sIndex.charAt(sIndex.length - 1);
|
|
246
|
+
return colors[colorIndex];
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
function formatPieChartData(data, statItem, table, currentTheme) {
|
|
250
|
+
const {
|
|
251
|
+
groupby_column_key,
|
|
252
|
+
color_option,
|
|
253
|
+
summary_column_key,
|
|
254
|
+
summary_method: summaryMethod,
|
|
255
|
+
summary_type
|
|
256
|
+
} = statItem;
|
|
257
|
+
const isAdvanced = summary_type === 'advanced';
|
|
258
|
+
const column = (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
|
|
259
|
+
let sum = data.reduce((total, currentValue) => {
|
|
260
|
+
return total += currentValue.value;
|
|
261
|
+
}, 0);
|
|
262
|
+
const minimumSlicePercentage = typeof statItem.minimum_slice_percent === 'number' ? statItem.minimum_slice_percent : 1.5;
|
|
263
|
+
const threshold = sum * (minimumSlicePercentage / 100 || 0);
|
|
264
|
+
const filteredItems = [];
|
|
265
|
+
const colorSet = [];
|
|
266
|
+
const filteredData = [];
|
|
267
|
+
let stepIndex = 0;
|
|
268
|
+
data.forEach((item, index) => {
|
|
269
|
+
const value = item.value;
|
|
270
|
+
if (value >= threshold) {
|
|
271
|
+
const colorIndex = index - stepIndex;
|
|
272
|
+
item.percent = String(Number.parseFloat(value / sum * 100).toFixed(1)) + '%';
|
|
273
|
+
const color = getPieColor(color_option, column, colorIndex, item, currentTheme);
|
|
274
|
+
item.color = color;
|
|
275
|
+
colorSet.push(color);
|
|
276
|
+
filteredData.push(item);
|
|
277
|
+
} else {
|
|
278
|
+
stepIndex += 1;
|
|
279
|
+
filteredItems.push(item);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
data = filteredData;
|
|
283
|
+
if (filteredItems.length > 0) {
|
|
284
|
+
const filteredSum = filteredItems.reduce((total, currentValue) => {
|
|
285
|
+
return total += currentValue.value;
|
|
286
|
+
}, 0);
|
|
287
|
+
let formattedValueSum = filteredSum;
|
|
288
|
+
if (isAdvanced) {
|
|
289
|
+
const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
|
|
290
|
+
formattedValueSum = _statUtils.default.getFormattedValue(filteredSum, summaryColumn, summaryMethod);
|
|
291
|
+
}
|
|
292
|
+
let original_name_list = [];
|
|
293
|
+
let name_list = [];
|
|
294
|
+
let rows = [];
|
|
295
|
+
filteredItems.forEach(item => {
|
|
296
|
+
if (item.original_name) {
|
|
297
|
+
original_name_list.push(item.original_name);
|
|
298
|
+
}
|
|
299
|
+
if (item.name) {
|
|
300
|
+
name_list.push(item.name);
|
|
301
|
+
}
|
|
302
|
+
if (item.rows) {
|
|
303
|
+
rows.push(...item.rows);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
data.push({
|
|
307
|
+
rows,
|
|
308
|
+
name_list,
|
|
309
|
+
original_name_list,
|
|
310
|
+
name: _reactIntlUniversal.default.get('Others'),
|
|
311
|
+
value: filteredSum,
|
|
312
|
+
formatted_value: formattedValueSum,
|
|
313
|
+
color: '#dbdbdb',
|
|
314
|
+
original_name: 'Others',
|
|
315
|
+
percent: String(Number.parseFloat(filteredSum / sum * 100).toFixed(1)) + '%'
|
|
316
|
+
});
|
|
317
|
+
colorSet.push('#dbdbdb');
|
|
318
|
+
}
|
|
319
|
+
data.total = sum;
|
|
320
|
+
data.colorSet = colorSet;
|
|
321
|
+
return data;
|
|
322
|
+
}
|
|
323
|
+
const formatNumericValue = function (value) {
|
|
324
|
+
let column = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
325
|
+
const data = column.data || {};
|
|
326
|
+
let {
|
|
327
|
+
precision = 8
|
|
328
|
+
} = data;
|
|
329
|
+
value = value || 0;
|
|
330
|
+
return parseFloat(value.toFixed(precision));
|
|
331
|
+
};
|
|
332
|
+
exports.formatNumericValue = formatNumericValue;
|
|
333
|
+
const getLabelFontSize = label_font_size => {
|
|
334
|
+
return (0, _dtableUtils.isNumber)(label_font_size) ? label_font_size : _constants.DEFAULT_LABEL_FONT_SIZE;
|
|
335
|
+
};
|
|
336
|
+
exports.getLabelFontSize = getLabelFontSize;
|
|
337
|
+
const getSummaryColumnMethod = function (method, summaryColumnName) {
|
|
338
|
+
let useSingleQuote = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
339
|
+
if (method === 'Distinct_values') {
|
|
340
|
+
return "COUNT(DISTINCT ".concat(summaryColumnName, ")");
|
|
341
|
+
}
|
|
342
|
+
return "".concat(method, "(").concat(useSingleQuote ? '`' : '').concat(summaryColumnName).concat(useSingleQuote ? '`' : '', ")");
|
|
343
|
+
};
|
|
344
|
+
exports.getSummaryColumnMethod = getSummaryColumnMethod;
|
|
345
|
+
const getCurrentTheme = colorThemeName => {
|
|
346
|
+
if (colorThemeName) {
|
|
347
|
+
const currentColorTheme = _constants.CHART_STYLE_COLORS.find(item => item.name === colorThemeName);
|
|
348
|
+
return currentColorTheme || _constants.CHART_STYLE_COLORS[0];
|
|
349
|
+
}
|
|
350
|
+
return _constants.CHART_STYLE_COLORS[0];
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// for stacked bar, stacked horizontal bar
|
|
354
|
+
exports.getCurrentTheme = getCurrentTheme;
|
|
355
|
+
const sortDataByGroupSum = (data, sortType) => {
|
|
356
|
+
const nameSumMap = [];
|
|
357
|
+
data.forEach(item => {
|
|
358
|
+
if (nameSumMap.filter(filteredItem => filteredItem.name === item.name).length === 0) {
|
|
359
|
+
const items = data.filter(originItem => originItem.name === item.name);
|
|
360
|
+
const valueSum = items.reduce((accumulator, currentItem) => accumulator + currentItem.value, 0);
|
|
361
|
+
nameSumMap.push({
|
|
362
|
+
name: item.name,
|
|
363
|
+
items,
|
|
364
|
+
valueSum
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// sort group
|
|
370
|
+
_statUtils.default.sortDataByKey(nameSumMap, 'valueSum', sortType);
|
|
371
|
+
return nameSumMap.reduce((accumulator, currentItem) => accumulator.concat(currentItem.items), []);
|
|
372
|
+
};
|
|
373
|
+
exports.sortDataByGroupSum = sortDataByGroupSum;
|
|
374
|
+
const isBoolean = val => {
|
|
375
|
+
return typeof val === 'boolean';
|
|
376
|
+
};
|
|
377
|
+
exports.isBoolean = isBoolean;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTodayDate = getTodayDate;
|
|
7
|
+
exports.translateCalendar = translateCalendar;
|
|
8
|
+
const zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
9
|
+
const zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
10
|
+
const enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
11
|
+
const frFR = require('@seafile/seafile-calendar/lib/locale/fr_FR');
|
|
12
|
+
const deDE = require('@seafile/seafile-calendar/lib/locale/de_DE');
|
|
13
|
+
const esES = require('@seafile/seafile-calendar/lib/locale/es_ES');
|
|
14
|
+
const plPL = require('@seafile/seafile-calendar/lib/locale/pl_PL');
|
|
15
|
+
const csCZ = require('@seafile/seafile-calendar/lib/locale/cs_CZ');
|
|
16
|
+
const ruRU = require('@seafile/seafile-calendar/lib/locale/ru_RU');
|
|
17
|
+
function translateCalendar() {
|
|
18
|
+
const locale = window.dtable ? window.dtable.lang : 'en';
|
|
19
|
+
let language;
|
|
20
|
+
switch (locale) {
|
|
21
|
+
case 'zh-cn':
|
|
22
|
+
language = zhCN;
|
|
23
|
+
break;
|
|
24
|
+
case 'zh-tw':
|
|
25
|
+
language = zhTW;
|
|
26
|
+
break;
|
|
27
|
+
case 'en':
|
|
28
|
+
language = enUS;
|
|
29
|
+
break;
|
|
30
|
+
case 'fr':
|
|
31
|
+
language = frFR;
|
|
32
|
+
break;
|
|
33
|
+
case 'de':
|
|
34
|
+
language = deDE;
|
|
35
|
+
break;
|
|
36
|
+
case 'es':
|
|
37
|
+
language = esES;
|
|
38
|
+
break;
|
|
39
|
+
case 'es-ar':
|
|
40
|
+
language = esES;
|
|
41
|
+
break;
|
|
42
|
+
case 'es-mx':
|
|
43
|
+
language = esES;
|
|
44
|
+
break;
|
|
45
|
+
case 'pl':
|
|
46
|
+
language = plPL;
|
|
47
|
+
break;
|
|
48
|
+
case 'cs':
|
|
49
|
+
language = csCZ;
|
|
50
|
+
break;
|
|
51
|
+
case 'ru':
|
|
52
|
+
language = ruRU;
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
language = enUS;
|
|
56
|
+
}
|
|
57
|
+
return language;
|
|
58
|
+
}
|
|
59
|
+
function getTodayDate() {
|
|
60
|
+
let todayDate = new Date();
|
|
61
|
+
let year = todayDate.getFullYear();
|
|
62
|
+
let month = todayDate.getMonth() + 1;
|
|
63
|
+
let date = todayDate.getDate();
|
|
64
|
+
let hour = todayDate.getHours();
|
|
65
|
+
let minute = todayDate.getMinutes();
|
|
66
|
+
month = month > 9 ? month : "0".concat(month);
|
|
67
|
+
date = date > 9 ? date : "0".concat(date);
|
|
68
|
+
hour = hour > 9 ? hour : "0".concat(hour);
|
|
69
|
+
minute = minute > 9 ? minute : "0".concat(minute);
|
|
70
|
+
return "".concat(year, "-").concat(month, "-").concat(date, " ").concat(hour, ":").concat(minute);
|
|
71
|
+
}
|