dtable-statistic 4.2.0 → 4.2.2

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.
@@ -4,6 +4,36 @@
4
4
  height: calc(100% - 56px);
5
5
  }
6
6
 
7
+ .statistic-enlarge-dialog .header-close-list {
8
+ display: flex;
9
+ }
10
+
11
+ .statistic-enlarge-dialog .op-item-icon-wrapper {
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ width: 24px;
16
+ height: 24px;
17
+ margin-right: 4px;
18
+ cursor: pointer;
19
+ }
20
+
21
+ .statistic-enlarge-dialog .op-item-icon-wrapper.header-btn-close {
22
+ margin-right: 0;
23
+ }
24
+
25
+ .statistic-enlarge-dialog .op-item-icon-wrapper .item-icon {
26
+ color: rgba(0, 0, 0, .5);
27
+ }
28
+
29
+ .statistic-enlarge-dialog .header-btn-close .item-icon {
30
+ font-weight: 700;
31
+ }
32
+
33
+ .statistic-enlarge-dialog .op-item-icon-wrapper:hover .item-icon {
34
+ color: #404040;
35
+ }
36
+
7
37
  .statistic-chart-addition-dialog .modal-content {
8
38
  height: 100%;
9
39
  }
@@ -297,7 +327,8 @@
297
327
  overflow: auto;
298
328
  }
299
329
 
300
- .statistic-enlarge-dialog .view-wrapper {
330
+ .statistic-enlarge-dialog .view-wrapper,
331
+ #exported-chart-container .view-wrapper {
301
332
  height: 100%;
302
333
  width: calc(100% - 20px);
303
334
  padding: 0 30px;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import intl from 'react-intl-universal';
3
+ import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
4
+ function DeleteConfirmationDialog(props) {
5
+ var header = props.header,
6
+ name = props.name,
7
+ onDelete = props.onDelete,
8
+ onToggle = props.onToggle;
9
+ return /*#__PURE__*/React.createElement(Modal, {
10
+ isOpen: true,
11
+ toggle: onToggle
12
+ }, /*#__PURE__*/React.createElement(ModalHeader, {
13
+ toggle: onToggle
14
+ }, header), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement("div", {
15
+ className: "pb-6"
16
+ }, intl.get('Delete_xxx_tip', {
17
+ name: name
18
+ }))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
19
+ color: "secondary",
20
+ onClick: onToggle
21
+ }, intl.get('Cancel')), /*#__PURE__*/React.createElement(Button, {
22
+ color: "primary",
23
+ onClick: onDelete
24
+ }, intl.get('Delete'))));
25
+ }
26
+ export default DeleteConfirmationDialog;
@@ -3,6 +3,8 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React, { Component } from 'react';
6
+ import ReactDOM from 'react-dom';
7
+ import html2canvas from 'html2canvas';
6
8
  import { Modal, ModalHeader, ModalBody } from 'reactstrap';
7
9
  import StatView from '../../stat-view';
8
10
  import { STAT_TYPE } from '../../constants';
@@ -50,6 +52,35 @@ var EnlargeChartDialog = /*#__PURE__*/function (_Component) {
50
52
  draggable: false
51
53
  }, /*#__PURE__*/React.createElement(StatView, viewProps));
52
54
  };
55
+ _this.onExportChart = function () {
56
+ var exportContainerID = 'exported-chart-container';
57
+ var exportContainer = document.createElement('div');
58
+ exportContainer.setAttribute('id', exportContainerID);
59
+
60
+ // for charts rendered with `<canvas>`
61
+ var originalElement = document.querySelector('.statistic-enlarge-modal .statistic-chart-container > div');
62
+ if (originalElement) {
63
+ var containerWidth = originalElement.scrollWidth + 15 * 2;
64
+ var containerHeight = originalElement.scrollHeight + 15 * 2;
65
+ exportContainer.setAttribute('style', "width: ".concat(containerWidth, "px; height: ").concat(containerHeight, "px;"));
66
+ }
67
+ document.body.appendChild(exportContainer);
68
+ ReactDOM.render(_this.renderStatisticView(), exportContainer);
69
+ setTimeout(function () {
70
+ var ele = document.querySelector("#".concat(exportContainerID, " .statistic-chart-container"));
71
+ if (!ele) return;
72
+ html2canvas(ele, {
73
+ windowWidth: ele.scrollWidth,
74
+ windowHeight: ele.scrollHeight
75
+ }).then(function (canvas) {
76
+ var eleA = document.createElement('a');
77
+ eleA.href = canvas.toDataURL('image/png');
78
+ eleA.download = "".concat(_this.props.statItem.name || 'image', ".png");
79
+ eleA.click();
80
+ document.body.removeChild(exportContainer);
81
+ });
82
+ }, 1000);
83
+ };
53
84
  return _this;
54
85
  }
55
86
  _createClass(EnlargeChartDialog, [{
@@ -63,7 +94,20 @@ var EnlargeChartDialog = /*#__PURE__*/function (_Component) {
63
94
  modalClassName: "statistic-enlarge-dialog",
64
95
  zIndex: 1048
65
96
  }, /*#__PURE__*/React.createElement(ModalHeader, {
66
- toggle: this.toggle
97
+ toggle: this.toggle,
98
+ close: /*#__PURE__*/React.createElement("div", {
99
+ className: "header-close-list"
100
+ }, /*#__PURE__*/React.createElement("div", {
101
+ className: "op-item op-item-icon-wrapper",
102
+ onClick: this.onExportChart
103
+ }, /*#__PURE__*/React.createElement("i", {
104
+ className: "item-icon dtable-font dtable-icon-download"
105
+ })), /*#__PURE__*/React.createElement("div", {
106
+ className: "op-item op-item-icon-wrapper header-btn-close",
107
+ onClick: this.toggle
108
+ }, /*#__PURE__*/React.createElement("i", {
109
+ className: "item-icon dtable-font dtable-icon-x"
110
+ })))
67
111
  }, /*#__PURE__*/React.createElement("span", null, statItem.type === STAT_TYPE.BASIC_NUMBER_CARD ? '' : statItem.name)), /*#__PURE__*/React.createElement(ModalBody, {
68
112
  className: 'statistic-body-container statistic-microscope-content'
69
113
  }, this.renderStatisticView()));
package/es/dashboard.js CHANGED
@@ -15,7 +15,7 @@ import DesktopDashboard from './desktop-dashboard';
15
15
  import MobileDashboard from './mobile-dashboard';
16
16
  import ThreadManager from './calculator/thread-manager';
17
17
  import ChartCalculator from './calculator';
18
- import { isMobile } from './utils';
18
+ import { hasOwnProperty, isMobile } from './utils';
19
19
  import { generatorUniqueId } from './utils/common-utils';
20
20
  import { CommonEventTypes, DASHBOARD_ACTION_TYPE, KEY_SELECTED_DASHBOARD, LABEL_COLORS } from './constants';
21
21
  import './locale';
@@ -94,12 +94,13 @@ var DashBoard = /*#__PURE__*/function (_Component) {
94
94
  });
95
95
  _this.initLabelColorConfigs();
96
96
  var statistics = _this.dashboardService.getStatistics();
97
+ var validStatistics = _this.dashboardService.getValidStatistics(statistics);
97
98
  var selectedDashboardIdx = _this.getSelectedDashboardIdxFromLocal(KEY_SELECTED_DASHBOARD) || 0;
98
99
  if (!statistics[selectedDashboardIdx]) {
99
100
  selectedDashboardIdx = 0;
100
101
  }
101
102
  return {
102
- statistics: statistics,
103
+ statistics: validStatistics,
103
104
  selectedDashboardIdx: selectedDashboardIdx
104
105
  };
105
106
  };
@@ -364,7 +365,11 @@ var DashBoard = /*#__PURE__*/function (_Component) {
364
365
  _this.updateStatistics = function (updates, callback) {
365
366
  var statistics = updates.statistics;
366
367
  _this.updatingLocalStatistics = true;
367
- _this.setState(updates, function () {
368
+ var validUpdates = _objectSpread({}, updates);
369
+ if (hasOwnProperty(updates, 'statistics')) {
370
+ validUpdates.statistics = _this.dashboardService.getValidStatistics(statistics);
371
+ }
372
+ _this.setState(validUpdates, function () {
368
373
  callback && callback();
369
374
  _this.props.updateStatistics(statistics);
370
375
  });
@@ -8,11 +8,12 @@ var de = {
8
8
  'Cancel_full_screen': 'Vollbildmodus beenden',
9
9
  'Default_dashboard': 'Dashboard',
10
10
  'New_dashboard': 'Neues Dashboard',
11
+ 'Delete_dashboard': 'Delete dashboard',
11
12
  'Name': 'Name',
12
13
  'Submit': 'Einreichen',
13
14
  'Cancel': 'Abbrechen',
14
15
  'Name_is_required': 'Der Name ist erforderlich.',
15
- 'Name_cannot_contain_backtick': 'Name cannot contain backtick.',
16
+ 'Name_cannot_contain_backtick': 'Der Name darf kein rückwärts geneigtes Hochkomma ( ` ) enthalten.',
16
17
  'Name_cannot_contain_slash': 'Der Name darf keinen Schrägstrich ( / ) enthalten.',
17
18
  'Name_cannot_contain_backslash': 'Der Name darf keinen Backslash ( \\ ) enthalten.',
18
19
  'Rename_dashboard': 'Dashboard umbenennen',
@@ -204,6 +205,7 @@ var de = {
204
205
  'Add_rule': 'Regel hinzufügen',
205
206
  'Added_1_rule': '1 Regel wurde hinzugefügt.',
206
207
  'Added_xxx_rules': '{rules_count} Regeln wurden hinzugefügt.',
208
+ 'Delete_xxx_tip': 'Are you sure you want to delete {name}?',
207
209
  'Define_rule': 'Regel definieren',
208
210
  'Or': 'Oder',
209
211
  'And': 'Und',
@@ -244,7 +246,7 @@ var de = {
244
246
  'Select_table': 'Tabelle auswählen',
245
247
  'Update_to_a_table': 'Aktualisierung in eine Tabelle',
246
248
  'Export_to_a_new_table': 'In neue Tabelle exportieren',
247
- 'Move_to': 'Move to...',
248
- 'Table_xxx_exist': 'Table {name} exist'
249
+ 'Move_to': 'Verschieben nach',
250
+ 'Table_xxx_exist': 'Die Tabelle {name} existiert.'
249
251
  };
250
252
  export default de;
@@ -8,6 +8,7 @@ var en = {
8
8
  'Cancel_full_screen': 'Cancel full screen',
9
9
  'Default_dashboard': 'Default dashboard',
10
10
  'New_dashboard': 'New dashboard',
11
+ 'Delete_dashboard': 'Delete dashboard',
11
12
  'Name': 'Name',
12
13
  'Submit': 'Submit',
13
14
  'Cancel': 'Cancel',
@@ -204,6 +205,7 @@ var en = {
204
205
  'Add_rule': 'Add rule',
205
206
  'Added_1_rule': 'Added 1 rule',
206
207
  'Added_xxx_rules': 'Added {rules_count} rules',
208
+ 'Delete_xxx_tip': 'Are you sure you want to delete {name}?',
207
209
  'Define_rule': 'Define rule',
208
210
  'Or': 'Or',
209
211
  'And': 'And',
@@ -8,11 +8,12 @@ var fr = {
8
8
  'Cancel_full_screen': 'Quitter mode plein écran',
9
9
  'Default_dashboard': 'Tableau de bord standard',
10
10
  'New_dashboard': 'Nouveau tableau de bord',
11
+ 'Delete_dashboard': 'Delete dashboard',
11
12
  'Name': 'Nom',
12
13
  'Submit': 'Soumettre',
13
14
  'Cancel': 'Annuler',
14
15
  'Name_is_required': 'Le nom est nécessaire.',
15
- 'Name_cannot_contain_backtick': 'Name cannot contain backtick.',
16
+ 'Name_cannot_contain_backtick': 'Le nom ne doit pas contenir d\'accent grave ( ` ).',
16
17
  'Name_cannot_contain_slash': 'Le nom ne doit pas contenir de barre oblique ( / ).',
17
18
  'Name_cannot_contain_backslash': 'Le nom ne doit pas contenir de barre oblique inverse ( \\ ).',
18
19
  'Rename_dashboard': 'Renommer le tableau de bord',
@@ -204,6 +205,7 @@ var fr = {
204
205
  'Add_rule': 'Ajouter une règle',
205
206
  'Added_1_rule': '1 règle a été ajoutée.',
206
207
  'Added_xxx_rules': '{rules_count} règles ont été ajoutées.',
208
+ 'Delete_xxx_tip': 'Are you sure you want to delete {name}?',
207
209
  'Define_rule': 'Définir une règle',
208
210
  'Or': 'Ou',
209
211
  'And': 'Et',
@@ -244,7 +246,7 @@ var fr = {
244
246
  'Select_table': 'Sélectionner un tableau',
245
247
  'Update_to_a_table': 'Mettre à jour vers un tableau',
246
248
  'Export_to_a_new_table': 'Exporter dans un nouveau tableau',
247
- 'Move_to': 'Move to...',
248
- 'Table_xxx_exist': 'Table {name} exist'
249
+ 'Move_to': 'Déplacer vers',
250
+ 'Table_xxx_exist': 'Le tableau {name} existe.'
249
251
  };
250
252
  export default fr;
@@ -8,6 +8,7 @@ var zh_CN = {
8
8
  'Cancel_full_screen': '取消全屏',
9
9
  'Default_dashboard': '默认仪表盘',
10
10
  'New_dashboard': '新建仪表盘',
11
+ 'Delete_dashboard': '删除仪表盘',
11
12
  'Name': '名称',
12
13
  'Submit': '提交',
13
14
  'Cancel': '取消',
@@ -204,6 +205,7 @@ var zh_CN = {
204
205
  'Add_rule': '新增规则',
205
206
  'Added_1_rule': '已添加 1 个规则',
206
207
  'Added_xxx_rules': '已添加 {rules_count} 个规则',
208
+ 'Delete_xxx_tip': '你确定要删除 {name} 吗?',
207
209
  'Define_rule': '定义规则',
208
210
  'Or': '或者',
209
211
  'And': '并且',
@@ -51,7 +51,6 @@ var DashBoardService = /*#__PURE__*/function () {
51
51
  if (hasAdvancedStatistics) {
52
52
  this.mergeAdvancedStatistics(advancedStatistics, deletePluginSettings);
53
53
  }
54
- this.filterInvalidCharts();
55
54
  if (this.needSave) {
56
55
  this.needSave = false;
57
56
  updateStatistics(this.statistics);
@@ -201,10 +200,10 @@ var DashBoardService = /*#__PURE__*/function () {
201
200
  deletePluginSettings(ADVANCED_STATISTICS_NAME);
202
201
  }
203
202
  }, {
204
- key: "filterInvalidCharts",
205
- value: function filterInvalidCharts() {
203
+ key: "getValidStatistics",
204
+ value: function getValidStatistics(statistics) {
206
205
  var _this2 = this;
207
- this.statistics = this.statistics.map(function (dashboard) {
206
+ return statistics.map(function (dashboard) {
208
207
  var charts = dashboard.stat_items || dashboard.statItems;
209
208
  if (!Array.isArray(charts) || charts.length === 0) {
210
209
  return dashboard;
@@ -29,12 +29,17 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
29
29
  var exportContainerID = 'exported-chart-container';
30
30
  var exportContainer = document.createElement('div');
31
31
  exportContainer.setAttribute('id', exportContainerID);
32
- exportContainer.setAttribute('style', "width: ".concat(window.innerWidth, "px; height: ").concat(window.innerHeight, "px;"));
32
+
33
+ // for charts rendered with `<canvas>`
34
+ var id = statItem._id;
35
+ var originalElement = document.querySelector("#stat-item-".concat(id, " .statistic-chart-container > div"));
36
+ if (originalElement) {
37
+ var containerWidth = originalElement.scrollWidth + 15 * 2;
38
+ var containerHeight = originalElement.scrollHeight + 15 * 2;
39
+ exportContainer.setAttribute('style', "width: ".concat(containerWidth, "px; height: ").concat(containerHeight, "px;"));
40
+ }
33
41
  document.body.appendChild(exportContainer);
34
- ReactDOM.render(_this.renderChart(statItem, {
35
- isPreview: false,
36
- isEnlarge: true
37
- }), exportContainer);
42
+ ReactDOM.render(_this.renderChart(statItem), exportContainer);
38
43
  setTimeout(function () {
39
44
  var ele = document.querySelector("#".concat(exportContainerID, " .statistic-chart-container"));
40
45
  if (!ele) return;
@@ -62,11 +67,7 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
62
67
  statisticalResult: statisticalResult
63
68
  });
64
69
  };
65
- _this.renderChart = function (statItem, _ref) {
66
- var _ref$isPreview = _ref.isPreview,
67
- isPreview = _ref$isPreview === void 0 ? true : _ref$isPreview,
68
- _ref$isEnlarge = _ref.isEnlarge,
69
- isEnlarge = _ref$isEnlarge === void 0 ? false : _ref$isEnlarge;
70
+ _this.renderChart = function (statItem) {
70
71
  var _this$props = _this.props,
71
72
  dtableChangedTime = _this$props.dtableChangedTime,
72
73
  chartCalculator = _this$props.chartCalculator,
@@ -74,11 +75,11 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
74
75
  colorThemeName = _this$props.colorThemeName,
75
76
  eventBus = _this$props.eventBus;
76
77
  return /*#__PURE__*/React.createElement(StatView, {
77
- ref: function ref(_ref2) {
78
- return _this.chartView = _ref2;
78
+ ref: function ref(_ref) {
79
+ return _this.chartView = _ref;
79
80
  },
80
- isPreview: isPreview,
81
- isEnlarge: isEnlarge,
81
+ isPreview: true,
82
+ isEnlarge: false,
82
83
  dtableChangedTime: dtableChangedTime,
83
84
  theme: theme,
84
85
  colorThemeName: colorThemeName,
@@ -134,10 +135,7 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
134
135
  }))), /*#__PURE__*/React.createElement("div", {
135
136
  id: "stat-item-".concat(statItem._id),
136
137
  className: "statistic-chart-preview-container"
137
- }, this.renderChart(statItem, {
138
- isPreview: true,
139
- isEnlarge: false
140
- })), /*#__PURE__*/React.createElement("div", {
138
+ }, this.renderChart(statItem)), /*#__PURE__*/React.createElement("div", {
141
139
  className: "statistic-chart-preview-container-resize"
142
140
  }));
143
141
  }
package/es/tabs/index.js CHANGED
@@ -4,8 +4,10 @@ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitial
4
4
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
6
  import React, { Component } from 'react';
7
+ import intl from 'react-intl-universal';
7
8
  import NewViewDialog from '../components/dialog/new-view-dialog';
8
9
  import RenameViewDialog from '../components/dialog/rename-view-dialog';
10
+ import DeleteConfirmationDialog from '../components/dialog/delete-confirmation-dialog';
9
11
  import Tab from './tab';
10
12
  import styles from './statistic-tabs.module.css';
11
13
  var SCROLL_TYPE = {
@@ -134,6 +136,19 @@ var DashboardTabs = /*#__PURE__*/function (_Component) {
134
136
  isShowRenameViewDialog: !_this.state.isShowRenameViewDialog
135
137
  });
136
138
  };
139
+ _this.onToggleDeleteView = function () {
140
+ if (_this.props.isMobile) return;
141
+ _this.setState({
142
+ isShowDeleteViewDialog: !_this.state.isShowDeleteViewDialog
143
+ });
144
+ };
145
+ _this.onDeleteDashBoard = function () {
146
+ var selectedDashboardIdx = _this.props.selectedDashboardIdx;
147
+ _this.props.deleteDashboard(selectedDashboardIdx);
148
+ _this.setState({
149
+ isShowDeleteViewDialog: false
150
+ });
151
+ };
137
152
  _this.hideRenameViewDialog = function () {
138
153
  _this.setState({
139
154
  isShowRenameViewDialog: false
@@ -167,7 +182,7 @@ var DashboardTabs = /*#__PURE__*/function (_Component) {
167
182
  },
168
183
  onSelectDashboard: _this.selectDashboard.bind(_assertThisInitialized(_this), index),
169
184
  onToggleRenameView: _this.onToggleRenameView,
170
- onDeleteDashboard: _this.props.deleteDashboard.bind(_assertThisInitialized(_this), index),
185
+ onDeleteDashboard: _this.onToggleDeleteView,
171
186
  onMoveDashboard: _this.props.moveDashboard
172
187
  });
173
188
  });
@@ -175,6 +190,7 @@ var DashboardTabs = /*#__PURE__*/function (_Component) {
175
190
  _this.state = {
176
191
  isShowNewViewDialog: false,
177
192
  isShowRenameViewDialog: false,
193
+ isShowDeleteViewDialog: false,
178
194
  canScrollPrev: false,
179
195
  canScrollNext: false,
180
196
  canViewsScroll: true
@@ -202,6 +218,7 @@ var DashboardTabs = /*#__PURE__*/function (_Component) {
202
218
  var _this$state2 = this.state,
203
219
  isShowNewViewDialog = _this$state2.isShowNewViewDialog,
204
220
  isShowRenameViewDialog = _this$state2.isShowRenameViewDialog,
221
+ isShowDeleteViewDialog = _this$state2.isShowDeleteViewDialog,
205
222
  canScrollPrev = _this$state2.canScrollPrev,
206
223
  canScrollNext = _this$state2.canScrollNext;
207
224
  var _this$props2 = this.props,
@@ -241,6 +258,11 @@ var DashboardTabs = /*#__PURE__*/function (_Component) {
241
258
  viewName: statistics[selectedDashboardIdx].name,
242
259
  onRenameDashboard: this.props.renameDashboard,
243
260
  hideRenameViewDialog: this.hideRenameViewDialog
261
+ }), isShowDeleteViewDialog && /*#__PURE__*/React.createElement(DeleteConfirmationDialog, {
262
+ header: intl.get('Delete_dashboard'),
263
+ name: statistics[selectedDashboardIdx].name,
264
+ onToggle: this.onToggleDeleteView,
265
+ onDelete: this.onDeleteDashBoard
244
266
  }));
245
267
  }
246
268
  }]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",