diff --git a/src/app/appmarket/appinstance/appinstance/appinstance.component.html b/src/app/appmarket/appinstance/appinstance/appinstance.component.html index 9ad4da9d993d742d8c3d061ce577ee84d3739b34..b4cf434b6262d0692426bbd38d98f8afeb192a9d 100644 --- a/src/app/appmarket/appinstance/appinstance/appinstance.component.html +++ b/src/app/appmarket/appinstance/appinstance/appinstance.component.html @@ -81,6 +81,16 @@ {{'APP_INSTANCE.INSTANCE_ACTIONS' | translate}} <span class="caret"></span> </button> <ul class="dropdown-menu"> + <li *ngIf="getStateAsEnum(appInstanceStatus?.state) !== AppInstanceState.SCALED_DOWN"> + <a role="button" (click)="scaleDown()"> + {{'APP_INSTANCE.SCALED_DOWN' | translate}} + </a> + </li> + <li *ngIf="getStateAsEnum(appInstanceStatus?.state) == AppInstanceState.SCALED_DOWN"> + <a role="button" (click)="scaleUp()"> + {{'APP_INSTANCE.SCALED_UP' | translate}} + </a> + </li> <ng-container *ngIf="getStateAsEnum(appInstanceStatus?.state) === AppInstanceState.RUNNING"> <li> <a role="button" (click)="openAccessMethodsModal()"> diff --git a/src/app/appmarket/appinstance/appinstance/appinstance.component.ts b/src/app/appmarket/appinstance/appinstance/appinstance.component.ts index 543a563ff26a4089231b8e225fbcc4512120f17c..61bde4e33d35fd17b5bfd3d30c585458bcb96bdd 100644 --- a/src/app/appmarket/appinstance/appinstance/appinstance.component.ts +++ b/src/app/appmarket/appinstance/appinstance/appinstance.component.ts @@ -279,16 +279,18 @@ export class AppInstanceComponent implements OnInit, OnDestroy { } return apps } + showHistory() { this.updateAppInstanceHistory() this.intervalCheckerStateHistory = interval(5000).subscribe(() => { - if (this.showAppInstanceHistory) { - this.updateAppInstanceHistory() - } else { - this.intervalCheckerStateHistory.unsubscribe(); - } + if (this.showAppInstanceHistory) { + this.updateAppInstanceHistory() + } else { + this.intervalCheckerStateHistory.unsubscribe(); + } }); } + private updateAppInstanceHistory() { this.appInstanceService.getAppInstanceHistory(this.appInstanceId).subscribe(history => { this.appInstanceStateHistory = [...history].reverse(); @@ -607,24 +609,24 @@ export class AppInstanceComponent implements OnInit, OnDestroy { } public openVersionUpdateModal() { - this.appsService.getApplicationVersions(this.appInstance.application.applicationBase.id).subscribe( versions => { - this.appVersions = versions.filter(val => val.state.toString() === 'ACTIVE' && val.version !== this.appInstance.applicationVersion ) + this.appsService.getApplicationVersions(this.appInstance.application.applicationBase.id).subscribe(versions => { + this.appVersions = versions.filter(val => val.state.toString() === 'ACTIVE' && val.version !== this.appInstance.applicationVersion) this.appVersions.sort(this.appVersionCompare) }) this.manualUpdateModal.show(); } public manualUpdateVersion() { - this.appInstanceService.manualUpdateVersion(this.appInstanceId, this.selectedVersion).subscribe( next => { - this.manualUpdateModal.hide(); - this.updateAppInstance() - }) + this.appInstanceService.manualUpdateVersion(this.appInstanceId, this.selectedVersion).subscribe(next => { + this.manualUpdateModal.hide(); + this.updateAppInstance() + }) } public openShowConfigModal() { - console.warn("Sumbission", this.submission) - this.appInstanceService.getConfiguration(this.appInstanceId).subscribe( config => { + console.warn('Sumbission', this.submission) + this.appInstanceService.getConfiguration(this.appInstanceId).subscribe(config => { this.submission['data']['configuration'] = config; this.deployParameters$.subscribe(additionalParams => { this.submission['data']['additionalParameters'] = additionalParams @@ -632,7 +634,7 @@ export class AppInstanceComponent implements OnInit, OnDestroy { property: 'submission', value: this.submission }); - console.log("updated", this.submission) + console.log('updated', this.submission) }) }) this.showConfigurationModal.show() @@ -647,9 +649,35 @@ export class AppInstanceComponent implements OnInit, OnDestroy { this.appInstanceService.getDeploymentParameters(this.appInstanceId).subscribe( deployParams => { this.deployParametersSubject.next(deployParams) - this.accessMethodsModal.show() ; - }) - + this.accessMethodsModal.show(); + }) + + } + + public scaleDown(): void { + this.appInstanceService.scaleDown(this.appInstanceId).subscribe( + { + next: () => { + console.log('Scaled down'); + }, + error: (err) => { + console.error('Failed to scale down', err); + } + } + ) } + public scaleUp(): void { + this.appInstanceService.scaleUp(this.appInstanceId).subscribe( + { + next: () => { + console.log('Scaled up'); + }, + error: (err) => { + console.error('Failed to scale up', err); + } + } + ) + + } } diff --git a/src/app/model/app-instance-status.ts b/src/app/model/app-instance-status.ts index 8122a6a875f1cece760a0ab4580d82269f50863d..9c8e4617600e5c7a846d6408930a4b7d992878a8 100644 --- a/src/app/model/app-instance-status.ts +++ b/src/app/model/app-instance-status.ts @@ -10,7 +10,8 @@ export enum AppInstanceState { DONE, FAILURE, UNKNOWN, - REMOVED + REMOVED, + SCALED_DOWN } export class AppInstanceStatus { diff --git a/src/app/service/appinstance.service.ts b/src/app/service/appinstance.service.ts index 5588249ba88a6251e19d2753e074d627f884c5a4..ee989d3176e6a1f2bd509b91e4d3b1a1731c68cb 100644 --- a/src/app/service/appinstance.service.ts +++ b/src/app/service/appinstance.service.ts @@ -153,6 +153,12 @@ export class AppInstanceService extends GenericDataService { return this.http.get<Map<string, string>>(this.getUrl() + `${appInstanceId}/parameters`); } + public scaleDown(appInstanceId: number): Observable<any> { + return this.http.put(this.getUrl() + `${appInstanceId}/scale-down`, null) + } + public scaleUp(appInstanceId: number): Observable<any> { + return this.http.put(this.getUrl() + `${appInstanceId}/scale-up`, null) + } } export class CustomerSearchCriteria {