sea-chart 0.0.1-beta → 0.0.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.
- package/dist/api/index.js +101 -0
- package/dist/components/types-dialog/index.js +2 -1
- package/dist/context.js +69 -19
- package/dist/editor/index.js +5 -0
- package/dist/index.js +4 -1
- package/dist/settings/widgets/data-filter/index.js +2 -1
- package/dist/settings/widgets/time-picker.js +2 -1
- package/dist/utils/chart-data-sql.js +1 -1
- package/dist/utils/chart-utils.js +12 -9
- package/dist/utils/collaborator-manager.js +24 -0
- package/dist/utils/collaborator-utils.js +6 -5
- package/dist/view/index.js +6 -26
- package/dist/view/wrapper/table/pivot-table-display-name.js +5 -4
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
class SeaChartAPI {
|
|
3
|
+
constructor(config) {
|
|
4
|
+
var _this = this;
|
|
5
|
+
this.getDTableAccessToken = () => {
|
|
6
|
+
// dtable-web
|
|
7
|
+
const {
|
|
8
|
+
server,
|
|
9
|
+
APIToken
|
|
10
|
+
} = this.config;
|
|
11
|
+
const url = server + '/api/v2.1/dtable/app-access-token/';
|
|
12
|
+
const headers = {
|
|
13
|
+
'Authorization': 'Token ' + APIToken
|
|
14
|
+
};
|
|
15
|
+
return axios.get(url, {
|
|
16
|
+
headers
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
this.getBaseData = () => {
|
|
20
|
+
const {
|
|
21
|
+
dtableServer,
|
|
22
|
+
dtableUuid,
|
|
23
|
+
accessToken
|
|
24
|
+
} = this;
|
|
25
|
+
const url = dtableServer + 'dtables/' + dtableUuid;
|
|
26
|
+
const headers = {
|
|
27
|
+
'Authorization': 'Token ' + accessToken
|
|
28
|
+
};
|
|
29
|
+
return axios.get(url, {
|
|
30
|
+
headers
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
this.getBaseMetaData = () => {
|
|
34
|
+
const {
|
|
35
|
+
dtableServer,
|
|
36
|
+
dtableUuid,
|
|
37
|
+
accessToken
|
|
38
|
+
} = this;
|
|
39
|
+
const url = dtableServer + 'api/v1/dtables/' + dtableUuid + '/metadata';
|
|
40
|
+
const headers = {
|
|
41
|
+
'Authorization': 'Token ' + accessToken
|
|
42
|
+
};
|
|
43
|
+
return axios.get(url, {
|
|
44
|
+
headers
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
this.sqlQuery = function (sql, parameters) {
|
|
48
|
+
let convert_keys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
49
|
+
// dtable-db
|
|
50
|
+
const {
|
|
51
|
+
dtableDB,
|
|
52
|
+
dtableUuid,
|
|
53
|
+
accessToken
|
|
54
|
+
} = _this;
|
|
55
|
+
const url = dtableDB + 'api/v1/query/' + dtableUuid;
|
|
56
|
+
const data = {
|
|
57
|
+
sql,
|
|
58
|
+
convert_keys,
|
|
59
|
+
...(parameters && {
|
|
60
|
+
parameters: parameters
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
const headers = {
|
|
64
|
+
'Authorization': 'Token ' + accessToken
|
|
65
|
+
};
|
|
66
|
+
return axios.post(url, data, {
|
|
67
|
+
headers
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
this.config = config;
|
|
71
|
+
this.instance = null;
|
|
72
|
+
this.appName = '';
|
|
73
|
+
this.accessToken = '';
|
|
74
|
+
this.dtableUuid = '';
|
|
75
|
+
this.dtableServer = '';
|
|
76
|
+
this.dtableSocket = '';
|
|
77
|
+
}
|
|
78
|
+
static getInstance(config) {
|
|
79
|
+
if (this.instance) return this.instance;
|
|
80
|
+
this.instance = new SeaChartAPI(config);
|
|
81
|
+
return this.instance;
|
|
82
|
+
}
|
|
83
|
+
async init() {
|
|
84
|
+
const accessTokenRes = await this.getDTableAccessToken();
|
|
85
|
+
const {
|
|
86
|
+
app_name,
|
|
87
|
+
access_token,
|
|
88
|
+
dtable_uuid,
|
|
89
|
+
dtable_server,
|
|
90
|
+
dtable_socket,
|
|
91
|
+
dtable_db
|
|
92
|
+
} = accessTokenRes.data;
|
|
93
|
+
this.appName = app_name;
|
|
94
|
+
this.accessToken = access_token;
|
|
95
|
+
this.dtableUuid = dtable_uuid;
|
|
96
|
+
this.dtableServer = dtable_server.replace(/\/+$/, '') + '/';
|
|
97
|
+
this.dtableSocket = dtable_socket.replace(/\/+$/, '') + '/';
|
|
98
|
+
this.dtableDB = dtable_db.replace(/\/+$/, '') + '/';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export default SeaChartAPI;
|
|
@@ -3,6 +3,7 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, UncontrolledTooltip, Button
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { CHART_TYPES, CHART_TYPE_SHOW, ZH_CN_SUPPORT_CHARTS, CHART_TYPE_IMAGE } from '../../constants';
|
|
5
5
|
import { eventStopPropagation } from '../../utils';
|
|
6
|
+
import context from '../../context';
|
|
6
7
|
import intl from '../../intl';
|
|
7
8
|
import Icon from '../icon';
|
|
8
9
|
import './index.css';
|
|
@@ -15,7 +16,7 @@ const TypesDialog = _ref => {
|
|
|
15
16
|
const [currentCatIndex, setCurrentCatIndex] = useState(0);
|
|
16
17
|
const [selectedType, setType] = useState(type);
|
|
17
18
|
const notSupportStatisticTypes = useMemo(() => {
|
|
18
|
-
const lang =
|
|
19
|
+
const lang = context.getSetting('lang');
|
|
19
20
|
return lang !== 'zh-cn' ? ZH_CN_SUPPORT_CHARTS : [];
|
|
20
21
|
}, []);
|
|
21
22
|
const seaChartTypeContainerRef = useRef(null);
|
package/dist/context.js
CHANGED
|
@@ -1,23 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getTableById } from 'dtable-utils';
|
|
2
|
+
import CollaboratorManager from './utils/collaborator-manager';
|
|
3
|
+
import { ChartDataSQL } from './utils';
|
|
2
4
|
class Context {
|
|
3
|
-
constructor(
|
|
4
|
-
this.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
constructor() {
|
|
6
|
+
this.queryResultFromDB = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
chart,
|
|
9
|
+
tables,
|
|
10
|
+
onSuccess,
|
|
11
|
+
onFail
|
|
12
|
+
} = _ref;
|
|
13
|
+
const table = getTableById(tables, chart.config.table_id);
|
|
14
|
+
const chartDataSQL = new ChartDataSQL({
|
|
15
|
+
table,
|
|
16
|
+
chart
|
|
17
|
+
});
|
|
18
|
+
const {
|
|
19
|
+
sql,
|
|
20
|
+
error
|
|
21
|
+
} = chartDataSQL.to_sql();
|
|
22
|
+
if (error) return;
|
|
23
|
+
return this.api.sqlQuery(sql).then(res => {
|
|
24
|
+
onSuccess && onSuccess(res);
|
|
25
|
+
}).catch(error => {
|
|
26
|
+
onFail && onFail(error);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
this.queryUser = (emails, callback) => {
|
|
30
|
+
this.userApi.queryUsers(emails, callback);
|
|
31
|
+
};
|
|
32
|
+
this.api = null;
|
|
33
|
+
this.settings = {};
|
|
34
|
+
this.hasInit = false;
|
|
35
|
+
this.collaborators = [];
|
|
36
|
+
this.collaboratorManager = null;
|
|
10
37
|
}
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
|
|
38
|
+
init(props) {
|
|
39
|
+
const {
|
|
40
|
+
config,
|
|
41
|
+
api,
|
|
42
|
+
usersAPI,
|
|
43
|
+
collaborators,
|
|
44
|
+
collaboratorManager
|
|
45
|
+
} = props;
|
|
46
|
+
if (this.hasInit) return;
|
|
47
|
+
if (!config) {
|
|
48
|
+
throw new Error('Props config is required');
|
|
49
|
+
}
|
|
50
|
+
if (!api) {
|
|
51
|
+
throw new Error('Props api is required');
|
|
52
|
+
}
|
|
53
|
+
if (!usersAPI) {
|
|
54
|
+
throw new Error('Props usersAPI is required');
|
|
55
|
+
}
|
|
56
|
+
this.api = api;
|
|
57
|
+
this.settings = config || {};
|
|
58
|
+
this.hasInit = true;
|
|
59
|
+
this.collaborators = collaborators || [];
|
|
60
|
+
this.collaboratorManager = collaboratorManager ? collaboratorManager : new CollaboratorManager(collaborators);
|
|
21
61
|
}
|
|
22
62
|
setSettings() {
|
|
23
63
|
let settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -29,5 +69,15 @@ class Context {
|
|
|
29
69
|
getSetting(key) {
|
|
30
70
|
return this.settings[key] || this.settings[key] === false ? this.settings[key] : '';
|
|
31
71
|
}
|
|
72
|
+
getCollaboratorFromCache(email) {
|
|
73
|
+
return this.collaboratorManager.getCollaboratorFromCache(email);
|
|
74
|
+
}
|
|
75
|
+
getCollaboratorsFromCache() {
|
|
76
|
+
return this.collaboratorManager.getCollaboratorsFromCache();
|
|
77
|
+
}
|
|
78
|
+
updateCollaboratorsCache(email, collaborator) {
|
|
79
|
+
this.collaboratorManager.updateCollaboratorsCache(email, collaborator);
|
|
80
|
+
}
|
|
32
81
|
}
|
|
33
|
-
|
|
82
|
+
const context = new Context();
|
|
83
|
+
export default context;
|
package/dist/editor/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
+
import context from '../context';
|
|
4
5
|
import View from '../view';
|
|
5
6
|
import Settings from '../settings';
|
|
6
7
|
import './index.css';
|
|
7
8
|
class Editor extends React.PureComponent {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
context.init(props);
|
|
12
|
+
}
|
|
8
13
|
render() {
|
|
9
14
|
const {
|
|
10
15
|
settingsTarget
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import SeaChartAPI from './api';
|
|
2
|
+
import { CHART_TYPES } from './constants/type';
|
|
1
3
|
import View from './view';
|
|
2
4
|
import Editor from './editor';
|
|
3
5
|
import Settings, { StyleSettings } from './settings';
|
|
4
6
|
import { ChartDataSQL } from './utils';
|
|
7
|
+
import Context from './context';
|
|
5
8
|
export default View;
|
|
6
|
-
export { View, Editor, Settings, StyleSettings, ChartDataSQL };
|
|
9
|
+
export { SeaChartAPI, CHART_TYPES, View, Editor, Settings, StyleSettings, Context, ChartDataSQL };
|
|
@@ -4,6 +4,7 @@ import { getTableById } from 'dtable-utils';
|
|
|
4
4
|
import DTableFiltersPopover from "dtable-ui-component/lib/DTableFiltersPopover";
|
|
5
5
|
import { eventStopPropagation, generatorKey } from '../../../utils';
|
|
6
6
|
import intl from '../../../intl';
|
|
7
|
+
import context from '../../../context';
|
|
7
8
|
import './index.css';
|
|
8
9
|
const DataFilter = _ref => {
|
|
9
10
|
let {
|
|
@@ -55,7 +56,7 @@ const DataFilter = _ref => {
|
|
|
55
56
|
} = config;
|
|
56
57
|
return filter_conjunction || 'And';
|
|
57
58
|
}, [chart]);
|
|
58
|
-
const collaborators =
|
|
59
|
+
const collaborators = context.getCollaboratorsFromCache();
|
|
59
60
|
const {
|
|
60
61
|
config
|
|
61
62
|
} = chart;
|
|
@@ -6,6 +6,7 @@ import 'dayjs/locale/zh-cn';
|
|
|
6
6
|
import 'dayjs/locale/en-gb';
|
|
7
7
|
import { translateCalendar } from '../../utils';
|
|
8
8
|
import intl from '../../intl';
|
|
9
|
+
import context from '../../context';
|
|
9
10
|
import '@seafile/seafile-calendar/assets/index.css';
|
|
10
11
|
let now = dayjs();
|
|
11
12
|
const DATE_FORMAT = 'YYYY-MM-DD';
|
|
@@ -80,7 +81,7 @@ class TimePicker extends Component {
|
|
|
80
81
|
const {
|
|
81
82
|
value
|
|
82
83
|
} = this.props;
|
|
83
|
-
const iszhcn =
|
|
84
|
+
const iszhcn = context.getSetting('lang') === 'zh-cn';
|
|
84
85
|
if (iszhcn) {
|
|
85
86
|
now = now.locale('zh-cn');
|
|
86
87
|
} else {
|
|
@@ -16,7 +16,7 @@ class ChartDataSQL {
|
|
|
16
16
|
this._update_filter_sql = (includeEmpty, column) => {
|
|
17
17
|
const columnName = (column === null || column === void 0 ? void 0 : column.name) || '';
|
|
18
18
|
if (!includeEmpty) {
|
|
19
|
-
const notIncludeEmptySQL = "
|
|
19
|
+
const notIncludeEmptySQL = "".concat(columnName, " is not null");
|
|
20
20
|
if (this.filter_sql) {
|
|
21
21
|
this.filter_sql = "WHERE ".concat(notIncludeEmptySQL, " AND ").concat(this.filter_sql);
|
|
22
22
|
} else {
|
|
@@ -9,6 +9,7 @@ import { getKnownCollaboratorByEmail, generateDefaultUser } from './collaborator
|
|
|
9
9
|
import { getDateColumnFormat, getColumnByKey } from './column-utils';
|
|
10
10
|
import ObjectUtils from './object-utils';
|
|
11
11
|
import intl from '../intl';
|
|
12
|
+
import context from '../context';
|
|
12
13
|
class ChartUtils {
|
|
13
14
|
static formatGroupsLabel(results, chart, tables) {
|
|
14
15
|
if (!results) return;
|
|
@@ -71,15 +72,15 @@ class ChartUtils {
|
|
|
71
72
|
email: name,
|
|
72
73
|
name: name
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
+
context.updateCollaboratorsCache(name, collaboratorTemplate);
|
|
75
76
|
if (!collaborator) {
|
|
76
|
-
|
|
77
|
+
context.queryUsers([name], emailUserMap => {
|
|
77
78
|
const collaborator = emailUserMap && emailUserMap[name] || generateDefaultUser(name);
|
|
78
79
|
const loadedCollaborator = {
|
|
79
80
|
...collaborator,
|
|
80
81
|
loaded: true
|
|
81
82
|
};
|
|
82
|
-
|
|
83
|
+
context.updateCollaboratorsCache(name, loadedCollaborator);
|
|
83
84
|
result[nameKey] = name;
|
|
84
85
|
});
|
|
85
86
|
} else {
|
|
@@ -378,7 +379,7 @@ ChartUtils.isValidCombinationChart = (config, table) => {
|
|
|
378
379
|
return true;
|
|
379
380
|
};
|
|
380
381
|
ChartUtils.getGroupLabelFromDB = (cellValue, column, tables) => {
|
|
381
|
-
const collaborators =
|
|
382
|
+
const collaborators = context.getCollaboratorsFromCache();
|
|
382
383
|
const {
|
|
383
384
|
type,
|
|
384
385
|
data
|
|
@@ -1099,15 +1100,15 @@ ChartUtils.updateTableViewListItemNameAndColor = (result, column, nameKey, color
|
|
|
1099
1100
|
email: name,
|
|
1100
1101
|
name: name
|
|
1101
1102
|
};
|
|
1102
|
-
|
|
1103
|
+
context.updateCollaboratorsCache(name, collaboratorTemplate);
|
|
1103
1104
|
if (!collaborator) {
|
|
1104
|
-
|
|
1105
|
+
context.queryUsers([name], emailUserMap => {
|
|
1105
1106
|
const collaborator = emailUserMap && emailUserMap[name] || generateDefaultUser(name);
|
|
1106
1107
|
const loadedCollaborator = {
|
|
1107
1108
|
...collaborator,
|
|
1108
1109
|
loaded: true
|
|
1109
1110
|
};
|
|
1110
|
-
|
|
1111
|
+
context.updateCollaboratorsCache(name, loadedCollaborator);
|
|
1111
1112
|
result[nameKey] = name;
|
|
1112
1113
|
});
|
|
1113
1114
|
} else {
|
|
@@ -1375,7 +1376,7 @@ ChartUtils.convertConfig = config => {
|
|
|
1375
1376
|
ChartUtils.imEmptyChartResult = chartResult => {
|
|
1376
1377
|
return !chartResult || !chartResult.result && chartResult.result !== 0 || Array.isArray(chartResult.result) && chartResult.result.length === 0;
|
|
1377
1378
|
};
|
|
1378
|
-
ChartUtils.calculateChart = (chart,
|
|
1379
|
+
ChartUtils.calculateChart = (chart, tables, callback, isChartData) => {
|
|
1379
1380
|
if (!_class.isValidExistChart(tables, chart)) {
|
|
1380
1381
|
const tip_message = 'Please_complete_the_chart_configuration_first';
|
|
1381
1382
|
return callback && callback('', tip_message, null);
|
|
@@ -1411,7 +1412,9 @@ ChartUtils.calculateChart = (chart, dataAPI, tables, callback, isChartData) => {
|
|
|
1411
1412
|
const error_message = 'There_are_some_problems_with_the_filters';
|
|
1412
1413
|
return callback && callback(error_message, '', null);
|
|
1413
1414
|
}
|
|
1414
|
-
|
|
1415
|
+
context.queryResultFromDB({
|
|
1416
|
+
chart,
|
|
1417
|
+
tables,
|
|
1415
1418
|
onSuccess: res => {
|
|
1416
1419
|
const {
|
|
1417
1420
|
success,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { User } from '../model';
|
|
2
|
+
class CollaboratorManager {
|
|
3
|
+
constructor(collaborators) {
|
|
4
|
+
this.collaborators = collaborators || [];
|
|
5
|
+
this.collaboratorsCache = {};
|
|
6
|
+
if (collaborators && Array.isArray(collaborators)) {
|
|
7
|
+
this.collaboratorsCache = collaborators.reduce((cache, item) => {
|
|
8
|
+
cache[item.email] = item;
|
|
9
|
+
return cache;
|
|
10
|
+
}, {});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
getCollaboratorFromCache(email) {
|
|
14
|
+
return this.collaboratorsCache[email];
|
|
15
|
+
}
|
|
16
|
+
getCollaboratorsFromCache() {
|
|
17
|
+
const collaboratorsCache = this.collaboratorsCache;
|
|
18
|
+
return Object.values(collaboratorsCache).filter(item => item.email !== 'anonymous');
|
|
19
|
+
}
|
|
20
|
+
updateCollaboratorsCache(email, collaborator) {
|
|
21
|
+
this.collaboratorsCache[email] = collaborator instanceof User ? collaborator : new User(collaborator);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export default CollaboratorManager;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isValidEmail } from 'dtable-utils';
|
|
2
2
|
import { User } from '../model';
|
|
3
|
+
import context from '../context';
|
|
3
4
|
export const getKnownCollaboratorByEmail = email => {
|
|
4
5
|
const defaultUser = generateDefaultUser(email);
|
|
5
6
|
if (email === 'anonymous' || email === 'Automation Rule') {
|
|
@@ -7,20 +8,20 @@ export const getKnownCollaboratorByEmail = email => {
|
|
|
7
8
|
...defaultUser,
|
|
8
9
|
loaded: true
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
+
context.updateCollaboratorsCache(email, anonymous);
|
|
11
12
|
return anonymous;
|
|
12
13
|
}
|
|
13
|
-
let creator =
|
|
14
|
+
let creator = context.getCollaboratorFromCache(email);
|
|
14
15
|
if (creator) return creator;
|
|
15
16
|
if (!isValidEmail(email)) {
|
|
16
17
|
creator = new User({
|
|
17
18
|
...defaultUser,
|
|
18
19
|
loaded: true
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
+
context.updateCollaboratorsCache(email, creator);
|
|
21
22
|
return creator;
|
|
22
23
|
}
|
|
23
|
-
creator =
|
|
24
|
+
creator = context.getCollaboratorFromCache(email);
|
|
24
25
|
if (creator) return creator;
|
|
25
26
|
return null;
|
|
26
27
|
};
|
|
@@ -29,7 +30,7 @@ export const getKnownCollaboratorsByEmails = emails => {
|
|
|
29
30
|
return emails.map(email => getKnownCollaboratorByEmail(email));
|
|
30
31
|
};
|
|
31
32
|
export const generateDefaultUser = name => {
|
|
32
|
-
const mediaUrl =
|
|
33
|
+
const mediaUrl = context.getSetting('mediaUrl');
|
|
33
34
|
const defaultAvatarUrl = "".concat(mediaUrl, "avatars/default.png");
|
|
34
35
|
return {
|
|
35
36
|
name,
|
package/dist/view/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import shallowEqual from 'shallowequal';
|
|
4
|
+
import context from '../context';
|
|
4
5
|
import intl from '../intl';
|
|
5
6
|
import { Loading } from '../components';
|
|
6
7
|
import { ChartUtils } from '../utils';
|
|
7
|
-
import Context from '../context';
|
|
8
8
|
import Title from './title';
|
|
9
9
|
import Wrapper from './wrapper';
|
|
10
10
|
import './index.css';
|
|
@@ -53,7 +53,6 @@ class View extends React.PureComponent {
|
|
|
53
53
|
const {
|
|
54
54
|
tables,
|
|
55
55
|
chart,
|
|
56
|
-
dataAPI,
|
|
57
56
|
isStatisticalData
|
|
58
57
|
} = _this.props;
|
|
59
58
|
const {
|
|
@@ -63,7 +62,7 @@ class View extends React.PureComponent {
|
|
|
63
62
|
ChartUtils.calculateStaticChart(tables, chart, data, _this.callback);
|
|
64
63
|
return;
|
|
65
64
|
}
|
|
66
|
-
ChartUtils.calculateChart(chart,
|
|
65
|
+
ChartUtils.calculateChart(chart, tables, _this.callback, isStatisticalData);
|
|
67
66
|
};
|
|
68
67
|
this.state = {
|
|
69
68
|
isCalculated: false,
|
|
@@ -71,31 +70,12 @@ class View extends React.PureComponent {
|
|
|
71
70
|
errorMessage: '',
|
|
72
71
|
tipMessage: ''
|
|
73
72
|
};
|
|
73
|
+
console.log(props);
|
|
74
|
+
context.init(props);
|
|
74
75
|
}
|
|
75
76
|
componentDidMount() {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
usersAPI,
|
|
79
|
-
context,
|
|
80
|
-
config,
|
|
81
|
-
eventBus,
|
|
82
|
-
collaborators
|
|
83
|
-
} = this.props;
|
|
84
|
-
if (!window.seaChart) {
|
|
85
|
-
window.seaChart = {};
|
|
86
|
-
}
|
|
87
|
-
if (!((_window$seaChart = window.seaChart) === null || _window$seaChart === void 0 ? void 0 : _window$seaChart.queryUsers)) {
|
|
88
|
-
window.seaChart.queryUsers = usersAPI;
|
|
89
|
-
}
|
|
90
|
-
if (!((_window$seaChart2 = window.seaChart) === null || _window$seaChart2 === void 0 ? void 0 : _window$seaChart2.context)) {
|
|
91
|
-
const validContext = context || new Context(eventBus, config);
|
|
92
|
-
Array.isArray(collaborators) && collaborators.forEach(collaborator => {
|
|
93
|
-
validContext.onlyUpdateCollaboratorsCache && validContext.onlyUpdateCollaboratorsCache(collaborator.email, collaborator);
|
|
94
|
-
});
|
|
95
|
-
window.seaChart.context = validContext;
|
|
96
|
-
const lang = validContext.getSetting('lang') || 'zh-cn';
|
|
97
|
-
intl.setLang(lang);
|
|
98
|
-
}
|
|
77
|
+
const lang = context.getSetting('lang') || 'zh-cn';
|
|
78
|
+
intl.setLang(lang);
|
|
99
79
|
this.calculateStatistic();
|
|
100
80
|
}
|
|
101
81
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
@@ -5,6 +5,7 @@ import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE, getOption, ge
|
|
|
5
5
|
import { getClientFormulaDisplayString, getKnownCollaboratorByEmail, getColumnOptions, getDateColumnFormat, generateDefaultUser } from '../../../utils';
|
|
6
6
|
import { Collaborator } from '../../../components';
|
|
7
7
|
import intl from '../../../intl';
|
|
8
|
+
import context from '../../../context';
|
|
8
9
|
class PivotTableDisplayName extends React.Component {
|
|
9
10
|
constructor(props) {
|
|
10
11
|
super(props);
|
|
@@ -28,14 +29,14 @@ class PivotTableDisplayName extends React.Component {
|
|
|
28
29
|
email: email,
|
|
29
30
|
name: email
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
context.updateCollaboratorsCache(email, valueTemplate);
|
|
33
|
+
context.queryUsers([email], emailUserMap => {
|
|
33
34
|
creator = emailUserMap && emailUserMap[email] || generateDefaultUser(email);
|
|
34
35
|
const loadedCreator = {
|
|
35
36
|
...creator,
|
|
36
37
|
loaded: true
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
+
context.updateCollaboratorsCache(email, loadedCreator);
|
|
39
40
|
this.setState({
|
|
40
41
|
creator
|
|
41
42
|
});
|
|
@@ -86,7 +87,7 @@ class PivotTableDisplayName extends React.Component {
|
|
|
86
87
|
type,
|
|
87
88
|
data
|
|
88
89
|
} = column;
|
|
89
|
-
const collaborators =
|
|
90
|
+
const collaborators = context.getCollaboratorsFromCache();
|
|
90
91
|
let displayName;
|
|
91
92
|
switch (type) {
|
|
92
93
|
case CellType.SINGLE_SELECT:
|