|
5 | 5 | <div class="resource-header">
|
6 | 6 | <div class="resource-header-name-state">
|
7 | 7 | <span class="resource-header-name">
|
8 |
| - <RouterLink to="../">{{ t('imageScanner.registries.title') }}:</RouterLink> |
| 8 | + <RouterLink :to="`/c/${this.$route.params.cluster}/${ this.PRODUCT_NAME }/${ this.RESOURCE.REGISTRY }/`">{{ t('imageScanner.registries.title') }}:</RouterLink> |
9 | 9 | {{ $route.params.id }}
|
10 | 10 | </span>
|
11 | 11 | <RegisterStatusBadge :status="registryStatus" />
|
|
41 | 41 |
|
42 | 42 | <script>
|
43 | 43 | import { BadgeState } from '@rancher/components';
|
44 |
| - import { RESOURCE } from '@sbombastic-image-vulnerability-scanner/types'; |
| 44 | + import { PRODUCT_NAME, RESOURCE } from '@sbombastic-image-vulnerability-scanner/types'; |
45 | 45 | import ResourceTable from "@shell/components/ResourceTable";
|
46 | 46 | import RancherMeta from './common/RancherMeta.vue';
|
47 | 47 | import RegisterStatusBadge from './common/RegisterStatusBadge.vue';
|
|
57 | 57 | },
|
58 | 58 | data() {
|
59 | 59 | return {
|
| 60 | + PRODUCT_NAME, |
| 61 | + RESOURCE, |
60 | 62 | registryStatus: null,
|
61 | 63 | registryMetadata: [],
|
62 | 64 | scanHistory: [],
|
63 | 65 | headers: REGISTRY_SCAN_HISTORY_TABLE
|
64 | 66 | }
|
65 | 67 | },
|
66 | 68 | async fetch() {
|
67 |
| - await this.$store.dispatch('cluster/find', { type: RESOURCE.SCAN_JOB, id: `${this.$route.params.ns}/${this.$route.params.id}` }); |
68 |
| - let scanJob = this.$store.getters['cluster/byId'](RESOURCE.SCAN_JOB, `${this.$route.params.ns}/${this.$route.params.id}`); |
69 | 69 |
|
70 |
| - await this.$store.dispatch('cluster/find', { type: RESOURCE.REGISTRY, id: `${this.$route.params.ns}/${scanJob.spec.registry}` }); |
71 |
| - let registry = this.$store.getters['cluster/byId'](RESOURCE.REGISTRY, `${this.$route.params.ns}/${scanJob.spec.registry}`); |
| 70 | + await this.$store.dispatch('cluster/find', { type: RESOURCE.REGISTRY, id: `${this.$route.params.ns}/${this.$route.params.id}` }); |
| 71 | + let registry = this.$store.getters['cluster/byId'](RESOURCE.REGISTRY, `${this.$route.params.ns}/${this.$route.params.id}`); |
72 | 72 |
|
73 |
| - this.registryStatus = (registry.status.conditions[0].type.toLowerCase() === "discovering" ? "InProgress" : registry.status.conditions[0].type).toLowerCase(); |
| 73 | +
|
| 74 | + await this.$store.dispatch('cluster/findAll', { type: RESOURCE.SCAN_JOB }); |
| 75 | + let scanJobs = this.$store.getters['cluster/all'](RESOURCE.SCAN_JOB); |
| 76 | + |
| 77 | + // filter scan jobs for the current registry |
| 78 | + scanJobs = scanJobs.filter((job) => { |
| 79 | + return job.spec.registry === registry.metadata.name; |
| 80 | + }); |
| 81 | +
|
| 82 | + this.registryStatus = this.getRegistryStatus(registry); |
74 | 83 | this.registryMetadata = [
|
75 | 84 | {
|
76 | 85 | type: 'text',
|
|
100 | 109 | value: registry.metadata.schedule || '',
|
101 | 110 | }
|
102 | 111 | ];
|
103 |
| - |
104 |
| - this.scanHistory = scanJob.status.conditions.map((rec) => { |
105 |
| - return { |
106 |
| - status: rec.type.toLowerCase(), |
107 |
| - timestamp: rec.lastUpdateTime, |
108 |
| - progress: rec.progress || 0, |
109 |
| - imagesScanned: rec.imagesScanned || 0, |
110 |
| - imagesFound: rec.imagesFound || 0, |
111 |
| - errors: rec.errors || [] |
| 112 | +
|
| 113 | + this.scanHistory = scanJobs.map((rec) => { |
| 114 | + rec.status.statusResult = rec.status.conditions.filter(condition => { |
| 115 | + return condition.status === "True"; |
| 116 | + })[0] || { |
| 117 | + type: "Pending", |
| 118 | + lastTransitionTime: null, |
112 | 119 | };
|
| 120 | + rec.status['scannedImagesCount'] = this.$route.params.id === 'kw-controller' ? 1000 : 500; |
| 121 | + rec.status['imagesCount'] = 2000; |
| 122 | + return rec; |
113 | 123 | });
|
| 124 | +
|
| 125 | + console.log("Scan history:", this.scanHistory); |
| 126 | + }, |
| 127 | + methods: { |
| 128 | + getRegistryStatus(registry) { |
| 129 | + if (!registry || !registry.status || !registry.status.conditions || !registry.status.conditions.length) { |
| 130 | + return null; |
| 131 | + } |
| 132 | + let status = registry.status.conditions[0].type.toLowerCase() === "discovering" ? "InProgress" : registry.status.conditions[0].type; |
| 133 | + return status.toLowerCase(); |
| 134 | + }, |
114 | 135 | },
|
115 | 136 | }
|
116 | 137 | </script>
|
|
0 commit comments