This repository was archived by the owner on Apr 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathdashboard.js
63 lines (57 loc) · 1.72 KB
/
dashboard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { optionalChain } from '../../../../utils/object.utils.js';
import { SimplePieChart } from '../../../shared/components/charts/simple-pie-chart/simple-pie-chart.js';
import { dashboardService } from '../../services/dashboard.service.js';
const _DashboardDef = async () => {
const tpl = await RawCMS.loadComponentTpl(
'/modules/core/components/dashboard/dashboard.tpl.html'
);
return {
components: {
PieChart: SimplePieChart,
},
computed: {
totalRecordsNum: function() {
const quotasObj = optionalChain(() => this.info.recordQuotas);
if (quotasObj === undefined) {
return undefined;
}
return Object.keys(quotasObj)
.map(x => quotasObj[x])
.reduce((acc, v) => acc + v, 0);
},
recordQuotasChartData: function() {
const quotasObj = optionalChain(() => this.info.recordQuotas, { fallbackValue: {} });
const labels = [];
const data = [];
Object.keys(quotasObj).forEach(x => {
labels.push(x);
data.push(quotasObj[x]);
});
return { data, labels };
},
},
created: async function() {
this.info = await this.dashboardService.getDashboardInfo();
this.isLoading = false;
},
data: function() {
return {
chartOptions: {
lowerIsBetter: true,
},
dashboardService: dashboardService,
isLoading: true,
info: undefined,
optionalChain: optionalChain,
};
},
template: tpl,
};
};
const _Dashboard = async (res, rej) => {
const cmpDef = await _DashboardDef();
res(cmpDef);
};
export const DashboardDef = _DashboardDef;
export const Dashboard = _Dashboard;
export default _Dashboard;