dtable-statistic 4.1.7 → 4.1.9

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.
@@ -25,7 +25,8 @@ var NewTableDialog = /*#__PURE__*/function (_React$Component) {
25
25
  return;
26
26
  }
27
27
  _this.setState({
28
- tableName: value
28
+ tableName: value,
29
+ errMessage: ''
29
30
  });
30
31
  };
31
32
  _this.toggle = function () {
@@ -58,12 +59,22 @@ var NewTableDialog = /*#__PURE__*/function (_React$Component) {
58
59
  });
59
60
  return;
60
61
  }
62
+ var isExist = _this.tables.find(function (item) {
63
+ return item.name === tableName;
64
+ });
65
+ if (isExist) {
66
+ _this.setState({
67
+ errMessage: 'Table_xxx_exist'
68
+ });
69
+ return;
70
+ }
61
71
  _this.props.onNewTableConfirm(tableName);
62
72
  };
63
73
  _this.state = {
64
74
  tableName: props.tableName,
65
75
  errMessage: ''
66
76
  };
77
+ _this.tables = props.getTables();
67
78
  return _this;
68
79
  }
69
80
  _createClass(NewTableDialog, [{
@@ -79,7 +90,8 @@ var NewTableDialog = /*#__PURE__*/function (_React$Component) {
79
90
  }, {
80
91
  key: "render",
81
92
  value: function render() {
82
- var _this2 = this;
93
+ var _this2 = this,
94
+ _this$state$tableName;
83
95
  return /*#__PURE__*/React.createElement(Modal, {
84
96
  isOpen: true,
85
97
  toggle: this.toggle,
@@ -99,7 +111,9 @@ var NewTableDialog = /*#__PURE__*/function (_React$Component) {
99
111
  }))), this.state.errMessage && /*#__PURE__*/React.createElement(Alert, {
100
112
  color: "danger",
101
113
  className: "mt-2"
102
- }, intl.get(this.state.errMessage))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
114
+ }, intl.get(this.state.errMessage, {
115
+ name: (_this$state$tableName = this.state.tableName) === null || _this$state$tableName === void 0 ? void 0 : _this$state$tableName.trim()
116
+ }))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
103
117
  color: "secondary",
104
118
  onClick: this.toggle
105
119
  }, intl.get('Cancel')), /*#__PURE__*/React.createElement(Button, {
@@ -12,6 +12,9 @@ var de = {
12
12
  'Submit': 'Einreichen',
13
13
  'Cancel': 'Abbrechen',
14
14
  'Name_is_required': 'Der Name ist erforderlich.',
15
+ 'Name_cannot_contain_backtick': 'Name cannot contain backtick.',
16
+ 'Name_cannot_contain_slash': 'Der Name darf keinen Schrägstrich ( / ) enthalten.',
17
+ 'Name_cannot_contain_backslash': 'Der Name darf keinen Backslash ( \\ ) enthalten.',
15
18
  'Rename_dashboard': 'Dashboard umbenennen',
16
19
  'Rename': 'Umbenennen',
17
20
  'Delete': 'Löschen',
@@ -237,9 +240,11 @@ var de = {
237
240
  'Add_new_stack': 'Neuen Stapel hinzufügen',
238
241
  'Chart_type': 'Diagrammtyp',
239
242
  'Edit_type': 'Typ ändern',
240
- 'New_table': 'New table',
243
+ 'New_table': 'Neue Tabelle',
241
244
  'Select_table': 'Tabelle auswählen',
242
245
  'Update_to_a_table': 'Aktualisierung in eine Tabelle',
243
- 'Export_to_a_new_table': 'In neue Tabelle exportieren'
246
+ 'Export_to_a_new_table': 'In neue Tabelle exportieren',
247
+ 'Move_to': 'Move to...',
248
+ 'Table_xxx_exist': 'Table {name} exist'
244
249
  };
245
250
  export default de;
@@ -12,6 +12,9 @@ var en = {
12
12
  'Submit': 'Submit',
13
13
  'Cancel': 'Cancel',
14
14
  'Name_is_required': 'Name is required',
15
+ 'Name_cannot_contain_backtick': 'Name cannot contain backtick.',
16
+ 'Name_cannot_contain_slash': 'Name cannot contain slash',
17
+ 'Name_cannot_contain_backslash': 'Name cannot contain backslash',
15
18
  'Rename_dashboard': 'Rename dashboard',
16
19
  'Rename': 'Rename',
17
20
  'Delete': 'Delete',
@@ -241,6 +244,7 @@ var en = {
241
244
  'Select_table': 'Select table',
242
245
  'Update_to_a_table': 'Update to a table',
243
246
  'Export_to_a_new_table': 'Export to a new table',
244
- "Move_to": "Move to..."
247
+ 'Move_to': 'Move to...',
248
+ 'Table_xxx_exist': 'Table {name} exist'
245
249
  };
246
250
  export default en;
@@ -12,6 +12,9 @@ var fr = {
12
12
  'Submit': 'Soumettre',
13
13
  'Cancel': 'Annuler',
14
14
  'Name_is_required': 'Le nom est nécessaire.',
15
+ 'Name_cannot_contain_backtick': 'Name cannot contain backtick.',
16
+ 'Name_cannot_contain_slash': 'Le nom ne doit pas contenir de barre oblique ( / ).',
17
+ 'Name_cannot_contain_backslash': 'Le nom ne doit pas contenir de barre oblique inverse ( \\ ).',
15
18
  'Rename_dashboard': 'Renommer le tableau de bord',
16
19
  'Rename': 'Renommer',
17
20
  'Delete': 'Supprimer',
@@ -25,7 +28,7 @@ var fr = {
25
28
  'Grouped_histogram': 'Histogramme groupé',
26
29
  'Stacked_histogram': 'Histogramme empilé',
27
30
  'Time_comparison_histogram': 'Histogramme comparaison de temps',
28
- 'Custom_histogram': 'Historgramme personnalisé',
31
+ 'Custom_histogram': 'Histogramme personnalisé',
29
32
  'Bar_chart': 'Graphique à barres',
30
33
  'Basic_bar_chart': 'Graphique à barres simple',
31
34
  'Grouped_bar_chart': 'Graphique à barres groupé',
@@ -237,9 +240,11 @@ var fr = {
237
240
  'Add_new_stack': 'Ajouter une nouvelle pile',
238
241
  'Chart_type': 'Type de diagramme',
239
242
  'Edit_type': 'Modifier le type',
240
- 'New_table': 'New table',
243
+ 'New_table': 'Nouveau tableau',
241
244
  'Select_table': 'Sélectionner un tableau',
242
245
  'Update_to_a_table': 'Mettre à jour vers un tableau',
243
- 'Export_to_a_new_table': 'Exporter dans un nouveau tableau'
246
+ 'Export_to_a_new_table': 'Exporter dans un nouveau tableau',
247
+ 'Move_to': 'Move to...',
248
+ 'Table_xxx_exist': 'Table {name} exist'
244
249
  };
245
250
  export default fr;
@@ -12,6 +12,9 @@ var zh_CN = {
12
12
  'Submit': '提交',
13
13
  'Cancel': '取消',
14
14
  'Name_is_required': '名称为必填项',
15
+ 'Name_cannot_contain_backtick': '名称不能包含反引号。',
16
+ 'Name_cannot_contain_slash': '名称不能包含斜杠',
17
+ 'Name_cannot_contain_backslash': '名称不能包含反斜杠',
15
18
  'Rename_dashboard': '重命名仪表盘',
16
19
  'Rename': '重命名',
17
20
  'Delete': '删除',
@@ -241,6 +244,7 @@ var zh_CN = {
241
244
  'Select_table': '选择子表',
242
245
  'Update_to_a_table': '更新到子表',
243
246
  'Export_to_a_new_table': '导出到新的子表',
244
- "Move_to": "移动到..."
247
+ 'Move_to': '移动到...',
248
+ 'Table_xxx_exist': '子表 { name } 已存在'
245
249
  };
246
250
  export default zh_CN;
@@ -34,6 +34,8 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
34
34
  var id = statItem._id;
35
35
  var originalElement = document.querySelector("#stat-item-".concat(id, " .statistic-chart-container > div"));
36
36
  if (originalElement) {
37
+ originalElement.style.width = "".concat(window.innerWidth, "px");
38
+ originalElement.style.height = "".concat(window.innerHeight, "px");
37
39
  var containerWidth = originalElement.scrollWidth + 15 * 2;
38
40
  var containerHeight = originalElement.scrollHeight + 15 * 2;
39
41
  exportContainer.setAttribute('style', "width: ".concat(containerWidth, "px; height: ").concat(containerHeight, "px;"));
@@ -52,6 +54,10 @@ var ChartPreview = /*#__PURE__*/function (_Component) {
52
54
  eleA.download = "".concat(statItem.name || 'image', ".png");
53
55
  eleA.click();
54
56
  document.body.removeChild(exportContainer);
57
+ if (originalElement) {
58
+ originalElement.style.width = 'unset';
59
+ originalElement.style.height = 'unset';
60
+ }
55
61
  });
56
62
  }, 1000);
57
63
  };
@@ -4,9 +4,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
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 ReactDOM from 'react-dom';
8
7
  import GridLayout, { WidthProvider } from 'react-grid-layout';
9
- import html2canvas from 'html2canvas';
10
8
  import intl from 'react-intl-universal';
11
9
  import ChartPreview from './chart-preview';
12
10
  import { NewTableDialog, toaster } from '../components';
@@ -39,36 +37,6 @@ var StatList = /*#__PURE__*/function (_Component) {
39
37
  _this.onLayoutChange = function (layout) {
40
38
  _this.props.modifyDashboardLayout(layout);
41
39
  };
42
- _this.onExportChart = function (statItem) {
43
- var exportContainerID = 'exported-statistic-chart-container';
44
- var exportContainer = document.createElement('div');
45
- exportContainer.setAttribute('id', exportContainerID);
46
-
47
- // for charts rendered with `<canvas>`
48
- var id = statItem._id;
49
- var originalElement = document.querySelector("#stat-item-".concat(id, " .statistic-chart-container > div"));
50
- if (originalElement) {
51
- var containerWidth = originalElement.scrollWidth + 15 * 2;
52
- var containerHeight = originalElement.scrollHeight + 15 * 2;
53
- exportContainer.setAttribute('style', "width: ".concat(containerWidth, "px; height: ").concat(containerHeight, "px;"));
54
- }
55
- document.body.appendChild(exportContainer);
56
- ReactDOM.render(_this.renderView(statItem), exportContainer);
57
- setTimeout(function () {
58
- var ele = document.querySelector("#".concat(exportContainerID, " .statistic-chart-container"));
59
- if (!ele) return;
60
- html2canvas(ele, {
61
- windowWidth: ele.scrollWidth,
62
- windowHeight: ele.scrollHeight
63
- }).then(function (canvas) {
64
- var eleA = document.createElement('a');
65
- eleA.href = canvas.toDataURL('image/png');
66
- eleA.download = "".concat(statItem.name || 'image', ".png");
67
- eleA.click();
68
- document.body.removeChild(exportContainer);
69
- });
70
- }, 1000);
71
- };
72
40
  _this.enlargeChart = function (chartIndex) {
73
41
  _this.setState({
74
42
  enlargedChartIndex: chartIndex
@@ -268,6 +236,7 @@ var StatList = /*#__PURE__*/function (_Component) {
268
236
  onToggleShowEnlarged: this.closeEnlargedChart,
269
237
  toggleStatisticRecordsDialog: this.props.toggleStatisticRecordsDialog
270
238
  }), chartExport2Table && /*#__PURE__*/React.createElement(NewTableDialog, {
239
+ getTables: this.props.getTables,
271
240
  tableName: chartExport2Table.name,
272
241
  onNewTableConfirm: function onNewTableConfirm(tableName) {
273
242
  return _this2.exportChart2Table(tableName, chartExport2Table);
@@ -299,7 +299,7 @@ var TreemapChart = /*#__PURE__*/function (_BaseChart) {
299
299
  ref: function ref(_ref3) {
300
300
  return _this2.container = _ref3;
301
301
  },
302
- className: "statistic-chart-loading-container ".concat(chartStyles['statistic-treemap-chart-container'])
302
+ className: "statistic-chart-container ".concat(chartStyles['statistic-treemap-chart-container'])
303
303
  }));
304
304
  }
305
305
  }]);
@@ -1,4 +1,4 @@
1
- import { CellType, isDateColumn, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES, Views } from 'dtable-store';
1
+ import { CellType, isDateColumn, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES } from 'dtable-store';
2
2
  import { MIRROR_COLUMN_LIST } from '../constants';
3
3
  export function getColorFromSingleSelectColumn(column, target) {
4
4
  var columnType = column.type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.1.7",
3
+ "version": "4.1.9",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",