File tree Expand file tree Collapse file tree 5 files changed +207
-102
lines changed
pkg/sbombastic-image-vulnerability-scanner Expand file tree Collapse file tree 5 files changed +207
-102
lines changed Original file line number Diff line number Diff line change 27
27
</div >
28
28
<RancherMeta :properties =" registryMetadata" />
29
29
</div >
30
- <RegistryDetailScanTable :registry =" registry" />
30
+ Recent scans
31
+ <ResourceTable
32
+ :headers =" headers"
33
+ :rows =" scanHistory"
34
+ :namespaced =" false"
35
+ :rowActions =" false"
36
+ :search =" false"
37
+ class =" table"
38
+ />
31
39
</div >
32
40
</template >
33
41
38
46
import RancherMeta from ' ./common/RancherMeta.vue' ;
39
47
import RegisterStatusBadge from ' ./common/RegisterStatusBadge.vue' ;
40
48
import { REGISTRY_SCAN_HISTORY_TABLE } from ' @sbombastic-image-vulnerability-scanner/config/table-headers' ;
41
- import RegistryDetailScanTable from ' ./RegistryDetailScanTable.vue' ;
42
49
43
50
export default {
44
51
name: ' registryDetails' ,
47
54
ResourceTable,
48
55
RancherMeta,
49
56
RegisterStatusBadge,
50
- RegistryDetailScanTable
51
57
},
52
58
data () {
53
59
return {
54
60
PRODUCT_NAME ,
55
61
RESOURCE ,
56
- registry: null ,
57
62
registryStatus: null ,
58
63
registryMetadata: [],
64
+ scanHistory: [],
65
+ headers: REGISTRY_SCAN_HISTORY_TABLE
59
66
}
60
67
},
61
68
async fetch () {
82
89
{
83
90
type: ' text' ,
84
91
label: this .t (' imageScanner.registries.configuration.meta.repositories' ),
85
- value: registry .spec .repositories ? .length || 0
92
+ value: registry .spec .repositories .length
86
93
},
87
94
{
88
95
type: ' text' ,
103
110
}
104
111
];
105
112
106
- this .registry = registry;
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 ,
119
+ };
120
+ rec .status [' scannedImagesCount' ] = this .$route .params .id === ' kw-controller' ? 1000 : 500 ;
121
+ rec .status [' imagesCount' ] = 2000 ;
122
+ return rec;
123
+ });
124
+
125
+ console .log (" Scan history:" , this .scanHistory );
107
126
},
108
127
methods: {
109
128
getRegistryStatus (registry ) {
131
150
gap : 24px ;
132
151
flex : 1 0 0 ;
133
152
align-self : stretch ;
153
+
154
+ .table {
155
+ width : 100% ;
156
+ }
134
157
}
135
158
136
159
.about {
179
202
.resource-header-description {
180
203
/* layout */
181
204
display : flex ;
182
- max - width: 900px ;
205
+ width : 900px ;
183
206
height : 21px ;
184
207
flex-direction : column ;
185
208
justify-content : center ;
Original file line number Diff line number Diff line change 2
2
<div v-if =" registryStatus.registryName" class =" registry-status-record" >
3
3
<RouterLink class =" registry-name" :to =" `/c/${this.$route.params.cluster}/${ this.PRODUCT_NAME }/${ this.PAGE.REGISTRIES }/${ registryStatus.namespace }/${ registryStatus.registryName }`" >{{ registryStatus.registryName }}</RouterLink >
4
4
<div class =" uri" >{{ registryStatus.uri }}</div >
5
- <div class =" prev-status" ><RegisterStatusBadge :status =" registryStatus.prevStatus " /></div >
5
+ <div class =" prev-status" ><RegisterStatusBadge :status =" registryStatus.prevScanStatus " /></div >
6
6
<div class =" arrow" ></div >
7
7
<div class =" curr-status" ><RegisterStatusBadge :status =" registryStatus.currStatus" /></div >
8
- <div class =" update-time" >{{ `${updateTime (registryStatus.lastUpdateTime )}` }}</div >
8
+ <div class =" update-time" >{{ `${statusUpdateTime (registryStatus.lastTransitionTime )}` }}</div >
9
9
</div >
10
10
<div v-else class =" registry-status-record" >
11
11
<div class =" no-data" ></div >
37
37
};
38
38
},
39
39
methods: {
40
- updateTime ( lastUpdateTime ) {
41
- return elapsedTime (Math .ceil (Date .now () / 1000 ) - Math .ceil ((new Date (lastUpdateTime ).getTime () / 1000 ))).label + ' ' + this .t (" imageScanner.general.ago" );
40
+ statusUpdateTime ( lastTransitionTime ) {
41
+ return elapsedTime (Math .ceil (Date .now () / 1000 ) - Math .ceil ((new Date (lastTransitionTime ).getTime () / 1000 ))).label + ' ' + this .t (" imageScanner.general.ago" );
42
42
}
43
43
}
44
44
}
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <button
3
+ class =" btn role-primary"
4
+ :disabled =" !(selectedRegistries && selectedRegistries.length)"
5
+ @click =" startScan()"
6
+ >
7
+ <i class =" icon icon-play" ></i >
8
+ {{ t('imageScanner.registries.button.startScan') || 'Enable' }}
9
+ </button >
10
+ </template >
11
+
12
+ <script >
13
+ import { RESOURCE } from " @sbombastic-image-vulnerability-scanner/types" ;
14
+
15
+ export default {
16
+ name: ' scanButton' ,
17
+ props: {
18
+ // Element object -> { name: string, namespace: string }
19
+ selectedRegistries: {
20
+ type: Array ,
21
+ default : () => []
22
+ },
23
+ reloadFn: {
24
+ type: Function ,
25
+ default : () => {}
26
+ }
27
+ },
28
+ methods: {
29
+ async startScan () {
30
+ if (! this .selectedRegistries || ! this .selectedRegistries .length ) {
31
+ return ;
32
+ }
33
+ this .selectedRegistries .forEach (async (registry ) => {
34
+ const scanjobObj = await this .$store .dispatch (' cluster/create' , {
35
+ type: RESOURCE .SCAN_JOB ,
36
+ metadata: {
37
+ generateName: registry .name ,
38
+ namespace: registry .namespace ,
39
+ },
40
+ spec: {
41
+ registry: registry .name ,
42
+ }
43
+ });
44
+ try {
45
+ await scanjobObj .save ();
46
+ this .$store .dispatch (' growl/success' , {
47
+ title: this .t (' imageScanner.registries.messages.registryScanComplete' ),
48
+ message: this .t (' imageScanner.registries.messages.registryScanComplete' , { name: registry .name }),
49
+ });
50
+ } catch (e) {
51
+ this .$store .dispatch (' growl/error' , {
52
+ title: this .t (' imageScanner.registries.messages.registryScanFailed' ),
53
+ message: e .message ,
54
+ });
55
+ } finally {
56
+ setTimeout (() => {
57
+ this .reloadFn (true );
58
+ }, 1000 );
59
+ }
60
+ });
61
+ },
62
+ },
63
+ }
64
+ </script >
Original file line number Diff line number Diff line change @@ -13,13 +13,13 @@ export default {
13
13
},
14
14
methods: {
15
15
getStatusText (row ) {
16
- return this .t (` imageScanner.enum.status.${ row .prevStatus .toLowerCase ()} ` );
16
+ return this .t (` imageScanner.enum.status.${ row .prevScanStatus .toLowerCase ()} ` );
17
17
},
18
18
getStatusLabelClass (row ) {
19
- return row .prevStatus .toLowerCase ();
19
+ return row .prevScanStatus .toLowerCase ();
20
20
},
21
21
getStatusDotClass (row ) {
22
- return ` dot ${ row .prevStatus .toLowerCase ()} ` ;
22
+ return ` dot ${ row .prevScanStatus .toLowerCase ()} ` ;
23
23
}
24
24
}
25
25
};
You can’t perform that action at this time.
0 commit comments