From 3a11f238d2d03f5b9b8f7d83ad3c3b231e0fac03 Mon Sep 17 00:00:00 2001 From: kbeyro <121854496+kbeyro@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:15:44 +0100 Subject: [PATCH 1/2] update configuration and bulks --- .../configurationdetails.component.html | 11 ++++++++ .../bulk-list/bulk-list.component.html | 2 +- .../bulk-list/bulk-list.component.ts | 21 +++++++++++---- .../bulk-view/bulk-view.component.ts | 27 +++++++++++++++---- src/app/auth/auth.guard.ts | 3 ++- src/app/model/configuration.ts | 1 + src/app/service/configuration.service.ts | 2 +- 7 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/app/appmarket/admin/configuration/details/configurationdetails.component.html b/src/app/appmarket/admin/configuration/details/configurationdetails.component.html index 92aafcd3..de8a5d14 100644 --- a/src/app/appmarket/admin/configuration/details/configurationdetails.component.html +++ b/src/app/appmarket/admin/configuration/details/configurationdetails.component.html @@ -131,6 +131,17 @@ </div> </div> + <div class="form-group"> + <label for="bulkDeploymentQueueRefresh" + class="col-sm-3 control-label">{{'PORTAL_CONFIGURATION.BULK_DEPLOYMENT_QUEUE_REFRESH' | translate}}</label> + <div class="col-sm-9 pd-top-7"> + <div class="input-width"> + <input class="form-control" type="number" id="bulkDeploymentQueueRefresh" name="bulkDeploymentQueueRefresh" + [(ngModel)]="this.configuration.bulkDeploymentQueueRefresh"> + </div> + + </div> + </div> <div class="flex justify-content-end"> <button class="btn btn-primary" type="submit">{{ 'PORTAL_CONFIGURATION.SUBMIT_BUTTON' | translate }}</button> diff --git a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html index 9db43b16..06d42a13 100644 --- a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html +++ b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.html @@ -9,7 +9,7 @@ </div> <div class="flex"> - <div *roles="['ROLE_SYSTEM_ADMIN', 'ROLE_VL_MANAGER']" class="flex align-items-center mr-6 pt-2"> + <div *roles="['ROLE_SYSTEM_ADMIN', 'ROLE_VL_MANAGER']" class="flex align-items-center mr-6"> <p-button type="button" diff --git a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts index 39bf0017..45925ffb 100644 --- a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts +++ b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, Input, OnDestroy, Output, QueryList, ViewChild, ViewChildren} from '@angular/core'; +import {Component, EventEmitter, Input, OnDestroy, OnInit, Output, QueryList, ViewChild, ViewChildren} from '@angular/core'; import {BulkDeployment} from '../../../model/bulk-deployment'; import {BulkType} from '../../../model/bulk-response'; import {SortableHeaderDirective} from '../../../service/sort-domain.directive'; @@ -7,13 +7,14 @@ import {AppdeploymentService} from '../appdeployment.service'; import {DomSanitizer} from '@angular/platform-browser'; import { BulkQueueDetails } from '../../../model/bulk-queue-details'; import { map, timer } from 'rxjs'; +import { ConfigurationService } from '../../../service'; @Component({ selector: 'app-bulk-list', templateUrl: './bulk-list.component.html', styleUrls: ['./bulk-list.component.css'] }) -export class BulkListComponent implements OnDestroy { +export class BulkListComponent implements OnDestroy, OnInit { public static BULK_ENTRY_DETAIL_KEY_APP_INSTANCE_NO = 'appInstanceNo'; public static BULK_ENTRY_DETAIL_KEY_APP_INSTANCE_NAME = 'appName'; @@ -55,9 +56,19 @@ export class BulkListComponent implements OnDestroy { public refreshQueue = undefined; public sidebarVisible4 = false; + public configRefresh = 60; + + constructor(private appDeploy: AppdeploymentService, - private sanitizer: DomSanitizer) { - this.update(); + private sanitizer: DomSanitizer, + private configService: ConfigurationService) { + } + + public ngOnInit(): void { + this.configService.getConfiguration().subscribe(conf => { + this.configRefresh = conf.bulkDeploymentQueueRefresh; + this.update(); + }) } public getApplicationName(details: Map<string, string>) { @@ -181,7 +192,7 @@ export class BulkListComponent implements OnDestroy { } public update() { - this.refreshQueue = timer(0, 60000).pipe(map(() => { + this.refreshQueue = timer(0, this.refreshQueue * 1000).pipe(map(() => { this.getQueueDetails(); })).subscribe() } diff --git a/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts b/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts index 5f191808..4b0c59f9 100644 --- a/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts +++ b/src/app/appmarket/bulkDeployment/bulk-view/bulk-view.component.ts @@ -5,7 +5,7 @@ import {ActivatedRoute, Router} from '@angular/router'; import {BulkResponse, BulkType} from '../../../model/bulk-response'; import {timer} from 'rxjs'; import {map} from 'rxjs/operators'; -import {AppImagesService} from '../../../service'; +import {AppImagesService, ConfigurationService} from '../../../service'; import { BulkQueueDetails } from '../../../model/bulk-queue-details'; import { DatePipe } from '@angular/common'; @@ -30,22 +30,29 @@ export class BulkViewComponent implements OnInit, OnDestroy { public jobDone = false; public completionDate = ""; + public configRefresh = 60; + constructor(public deployService: AppdeploymentService, private route: ActivatedRoute, private router: Router, public appImagesService: AppImagesService, - private datePipe: DatePipe + private datePipe: DatePipe, + private configService: ConfigurationService ) { } ngOnInit(): void { - + this.configService.getConfiguration().subscribe(conf => { + this.configRefresh = conf.bulkDeploymentQueueRefresh; + }) + this.route.params.subscribe(params => { if (params['id'] !== undefined) { this.bulkId = +params['id']; this.deployService.getBulkDeployment(this.bulkId).subscribe( (bulk) => { this.bulk = bulk; + this.sortByInstanceId(); this.bulkType = bulk.type; this.getQueueDetails(); this.setCompletionDate(bulk); @@ -102,9 +109,10 @@ export class BulkViewComponent implements OnInit, OnDestroy { } public update() { - this.refresh = timer(0, 20000).pipe(map(() => { + this.refresh = timer(0, this.configRefresh * 1000).pipe(map(() => { this.deployService.getBulkDeployment(this.bulk.id).subscribe(bulk => { this.bulk = bulk; + this.sortByInstanceId(); this.setCompletionDate(bulk); if(bulk.state === 'REMOVED') this.refresh.unsubscribe(); if(bulk.state === 'PROCESSING' && this.queueDetails.jobInProcessId === bulk.id) { @@ -146,6 +154,7 @@ export class BulkViewComponent implements OnInit, OnDestroy { public refreshStates() { this.deployService.refreshStatesInBulkDeployment(this.bulkId).subscribe( deply => { this.bulk = deply; + this.sortByInstanceId(); this.setCompletionDate(deply); this.getQueueDetails(); }) @@ -169,11 +178,19 @@ export class BulkViewComponent implements OnInit, OnDestroy { if(queue.jobDone === this.bulk.entries.length) { this.progressBarValue = 100; this.jobDone = true; - } else { + this.progressBarMode = "determinate" + } else if(queue.jobDone === 0) { + this.progressBarMode = "indeterminate" + }else { + this.progressBarMode = "determinate" this.progressBarValue = queue.jobDone * 100 / this.bulk.entries.length; this.jobDone = false; } }) } + + public sortByInstanceId() { + this.bulk.entries.sort((a,b) => this.getAppInstanceId(a) < this.getAppInstanceId(b) ? 1 : -1); + } } diff --git a/src/app/auth/auth.guard.ts b/src/app/auth/auth.guard.ts index aea400e0..2fe88c21 100644 --- a/src/app/auth/auth.guard.ts +++ b/src/app/auth/auth.guard.ts @@ -2,6 +2,7 @@ import {Injectable} from '@angular/core'; import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router'; import {AuthService} from './auth.service'; import {ConfigurationService} from '../service'; +import { debounceTime } from 'rxjs'; @Injectable() export class AuthGuard { @@ -11,7 +12,7 @@ export class AuthGuard { public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { if (this.auth.isLogged()) { - this.maintenanceService.getConfiguration().subscribe(value => { + this.maintenanceService.getConfiguration().pipe(debounceTime(500)).subscribe(value => { if (!this.auth.hasRole('ROLE_SYSTEM_ADMIN') && value.maintenance) { this.auth.logout(); this.router.navigate(['/welcome/login']); diff --git a/src/app/model/configuration.ts b/src/app/model/configuration.ts index 3bffd6e8..5bdb54fd 100644 --- a/src/app/model/configuration.ts +++ b/src/app/model/configuration.ts @@ -11,4 +11,5 @@ export class Configuration { public appInstanceFailureEmailList: string[] = []; public bulkDeploymentJobCron: string; public parallelDeploymentsLimit: number; + public bulkDeploymentQueueRefresh: number; } diff --git a/src/app/service/configuration.service.ts b/src/app/service/configuration.service.ts index 9a247125..9d93b401 100644 --- a/src/app/service/configuration.service.ts +++ b/src/app/service/configuration.service.ts @@ -22,7 +22,7 @@ export class ConfigurationService extends GenericDataService{ } public updateConfiguration(configuration: Configuration): Observable<any>{ - return this.put(this.uri + configuration.id, configuration); + return this.put(this.uri + "/"+ configuration.id, configuration); } } -- GitLab From 96058ce09bb462fa0c5dbc3f1db2957c529fae0b Mon Sep 17 00:00:00 2001 From: kbeyro <121854496+kbeyro@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:23:15 +0100 Subject: [PATCH 2/2] update ngOnDestroy --- .../appmarket/bulkDeployment/bulk-list/bulk-list.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts index 45925ffb..4883a6bb 100644 --- a/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts +++ b/src/app/appmarket/bulkDeployment/bulk-list/bulk-list.component.ts @@ -203,8 +203,7 @@ export class BulkListComponent implements OnDestroy, OnInit { public ngOnDestroy() { - if (this.refresh !== undefined) { - this.refresh.unsubscribe(); + if (this.refreshQueue !== undefined) { this.refreshQueue.unsubscribe(); } } -- GitLab