diff --git a/src/app/appmarket/admin/configuration/details/configurationdetails.component.html b/src/app/appmarket/admin/configuration/details/configurationdetails.component.html index 92aafcd35ac0b0fe8ffbd4b30836afee1c5b256e..de8a5d141eabd06407384500438ac27cf15ed1a3 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 9db43b162748d4d171cd0e9addd7551fb3dd02de..06d42a13307598d26cd863a2d5d086d6b4284510 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 39bf0017a2ac359859860765b6093afa4fc2a81f..4883a6bb95b8301576a8479a0d1aac8524bd0cb3 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() } @@ -192,8 +203,7 @@ export class BulkListComponent implements OnDestroy { public ngOnDestroy() { - if (this.refresh !== undefined) { - this.refresh.unsubscribe(); + if (this.refreshQueue !== undefined) { this.refreshQueue.unsubscribe(); } } 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 5f19180821e1b231c7cd80f3f62106706579d817..4b0c59f9115bcae87a18f76b5ea7c109e3c5f9c9 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 aea400e0a3ccf6885624238b496fcbd5186d9e2e..2fe88c217381e865b5ed27e7a814578d5c59aa32 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 3bffd6e8f90421fa78c8e722ece5d6de9b8aeb2d..5bdb54fdace5d822fef1526fbfe092aa13117288 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 9a247125cd18b4bd8f7cb2bb0e74e19cc9e62d10..9d93b4018f6ead3cfc3eb71c3db60417323b71bd 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); } }