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
65 lines (59 loc) · 2.05 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
64
65
import { optionalChain } from "/app/utils/object.utils.js";
import { SimplePieChart } from "/app/common/shared/components/charts/simple-pie-chart/simple-pie-chart.js";
import { dashboardService } from "/app/modules/core/services/dashboard.service.js";
const _DashboardDef = async () => {
const tpl = await RawCMS.loadComponentTpl(
"/app/modules/core/components/dashboard/dashboard.tpl.html"
);
return {
components: {
PieChart: SimplePieChart
},
computed: {
totalRecordsNum: function () {
const quotasObj = optionalChain(() => this.info.recordQuotas);
if (quotasObj === undefined) {
return 0;
}
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 = [];
for (const index in quotasObj) {
labels.push(index);
data.push(quotasObj[index]);
}
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;