@@ -27,6 +27,7 @@ import { MultiClusterGridActionCellComponent } from '@components/multi-cluster-g
27
27
import { finalize , takeWhile } from 'rxjs/operators' ;
28
28
import { interval } from 'rxjs' ;
29
29
import { GlobalConstant } from '@common/constants/global.constant' ;
30
+ import { NotificationService } from '@services/notification.service' ;
30
31
31
32
type Task = {
32
33
index : number ;
@@ -43,7 +44,9 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
43
44
private readonly $win ;
44
45
private _activeTaskNum : number = 0 ;
45
46
private _taskQueue : Task [ ] = [ ] ;
47
+ private _finishedNum : number = 0 ;
46
48
private _getSummarySubscription ;
49
+ private rowData : Cluster [ ] = [ ] ;
47
50
@Input ( ) clusterData ! : ClusterData ;
48
51
@Input ( ) gridHeight : number = 200 ;
49
52
isMasterRole ;
@@ -135,6 +138,11 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
135
138
} ,
136
139
width : 90 ,
137
140
} ,
141
+ {
142
+ headerName : '' ,
143
+ field : 'component_versions' ,
144
+ hide : true ,
145
+ } ,
138
146
] ;
139
147
140
148
statusColumn = [
@@ -165,15 +173,46 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
165
173
filtered : boolean = false ;
166
174
filteredCount : number = 0 ;
167
175
context ;
176
+ hasDiffManager : boolean = false ;
168
177
169
178
get clusterCount ( ) {
170
179
return this . clusterData . clusters ! . length ;
171
180
}
181
+
182
+ get taskQueue ( ) : Task [ ] {
183
+ return this . _taskQueue ;
184
+ }
185
+
186
+ set taskQueue ( value : Task [ ] ) {
187
+ this . _taskQueue = value ;
188
+ }
189
+
190
+ get finishedNum ( ) : number {
191
+ return this . _finishedNum ;
192
+ }
193
+
194
+ set finishedNum ( value : number ) {
195
+ if ( value === this . clusterCount && this . taskQueue . length === 0 ) {
196
+ let componentVersions = this . rowData . map ( data => {
197
+ data . component_versions ;
198
+ } ) ;
199
+ this . hasDiffManager = componentVersions . some ( ( ver ) => ver !== componentVersions [ 0 ] ) ;
200
+ if ( this . hasDiffManager ) {
201
+ this . notificationService . open (
202
+ this . translate . instant ( 'multiCluster.HAS_INCOMPATIBLE_VERSION' ) ,
203
+ GlobalConstant . NOTIFICATION_TYPE . ERROR
204
+ ) ;
205
+ }
206
+ }
207
+ this . _finishedNum = value ;
208
+ }
209
+
172
210
constructor (
173
211
public multiClusterService : MultiClusterService ,
174
212
private translate : TranslateService ,
175
213
private utils : UtilsService ,
176
214
private sanitizer : DomSanitizer ,
215
+ private notificationService : NotificationService ,
177
216
private cd : ChangeDetectorRef
178
217
) {
179
218
this . $win = $ ( GlobalVariable . window ) ;
@@ -213,7 +252,9 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
213
252
this . columnDefs . push ( this . actionColumn ) ;
214
253
}
215
254
216
- this . context = { componentParent : this } ;
255
+ this . context = {
256
+ componentParent : this ,
257
+ } ;
217
258
218
259
this . gridOptions = this . utils . createGridOptions ( this . columnDefs , this . $win ) ;
219
260
@@ -225,6 +266,9 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
225
266
onGridReady : event => this . onGridReady ( event ) ,
226
267
onRowSelected : event => this . onRowSelected ( event ) ,
227
268
} ;
269
+
270
+ this . _activeTaskNum = 0 ;
271
+ this . finishedNum = 0 ;
228
272
}
229
273
230
274
updateSummaryForRow ( rowNode : IRowNode , cluster : Cluster , index : number ) {
@@ -270,6 +314,7 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
270
314
cluster : cluster ,
271
315
} ;
272
316
this . _taskQueue . push ( task ) ;
317
+ this . taskQueue = this . _taskQueue ;
273
318
}
274
319
}
275
320
} ) ;
@@ -279,12 +324,13 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
279
324
this . _getSummarySubscription = interval ( 500 )
280
325
. pipe (
281
326
takeWhile ( ( ) => {
282
- return this . _taskQueue . length > 0 ;
327
+ return this . taskQueue . length > 0 ;
283
328
} )
284
329
)
285
330
. subscribe ( ( ) => {
286
- while ( this . _activeTaskNum < limit && this . _taskQueue . length > 0 ) {
287
- const task = this . _taskQueue . shift ( ) ;
331
+ while ( this . _activeTaskNum < limit && this . taskQueue . length > 0 ) {
332
+ const task = this . taskQueue . shift ( ) ;
333
+ this . taskQueue = this . _taskQueue ;
288
334
if ( task ) {
289
335
this . _activeTaskNum ++ ;
290
336
this . updateSummaryForRow ( task . rowNode , task . cluster , task . index ) ;
@@ -497,6 +543,7 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
497
543
rowNode . data . hosts = summaryDetail . hosts ;
498
544
rowNode . data . running_pods = summaryDetail . running_pods . toString ( ) ;
499
545
rowNode . data . cvedb_version = summaryDetail . cvedb_version ;
546
+ rowNode . data . component_versions = summaryDetail . component_versions ;
500
547
} else {
501
548
rowNode . data . hosts = this . translate . instant (
502
549
'multiCluster.messages.SCORE_UNAVAILIBlE'
@@ -519,8 +566,11 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
519
566
) ;
520
567
}
521
568
569
+ this . rowData . push ( rowNode . data ) ;
570
+
522
571
if ( this . gridOptions && this . gridApi ) {
523
572
this . gridApi ! . redrawRows ( { rowNodes : [ rowNode ] } ) ;
573
+ this . finishedNum ++ ;
524
574
}
525
575
}
526
576
0 commit comments