forked from rancher/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv1-workload-metrics.js
43 lines (35 loc) · 1.2 KB
/
v1-workload-metrics.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
import EmberPage from '@/components/EmberPage';
import { MANAGEMENT } from '@/config/types';
import { haveV1Monitoring } from '@/utils/monitoring';
export default {
components: { EmberPage },
data() {
const { namespace, resource, id } = this.$route.params;
const projects = this.$store.getters['management/all'](MANAGEMENT.PROJECT);
const p = projects.find((p) => {
return !!p.namespaces.find((ns) => {
return ns.metadata.name === namespace;
});
});
let v1MonitoringUrl = null;
let v1MonitoringContainerBaseUrl = null;
if (p && haveV1Monitoring(this.$store.getters)) {
const prjID = p.id.replace('/', ':');
let prefix;
if (resource !== 'pod') {
const r = resource.split('.');
const res = r.length === 2 ? r[1] : r[0];
prefix = `workload-metrics/${ res }:`;
} else {
prefix = `workloads/pod-metrics/`;
v1MonitoringContainerBaseUrl = `/p/${ prjID }/workloads/${ namespace }:${ id }/container-metrics/`;
}
v1MonitoringUrl = `/p/${ prjID }/${ prefix }${ namespace }:${ id }`;
}
return {
project: p ? p.id : null,
v1MonitoringUrl,
v1MonitoringContainerBaseUrl,
};
},
};