diff --git a/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html b/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html index f2fb671831fa7abf2a18ef727bde77e0c878e631..6508c441faf6d04a075bd21e4de0d841d5868c29 100644 --- a/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html +++ b/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html @@ -28,7 +28,7 @@ </div> <div class="form-group"> - <label for="targetUrl" class="col-sm-2 control-label">{{ 'WEBHOOKS.TARGEt_URL' | translate }}</label> + <label for="targetUrl" class="col-sm-2 control-label">{{ 'WEBHOOKS.TARGET_URL' | translate }}</label> <div class="col-sm-10"> <div class="col-sm-10"> <input type="text" class="form-control" id="targetUrl" name="targetUrl" diff --git a/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html b/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html index 8158c52a0252fe096e268b2f7036dfda7f05a424..8bb2e3293da2157b960e25861a19eb2d388c5e8b 100644 --- a/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html +++ b/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html @@ -78,8 +78,7 @@ <label for="contactEmail">{{'WEBHOOKS.TYPE' | translate}}</label> <select id="domain" #typeSelect class="form-control" (change)="onTypeSelect(typeSelect.value)" > <option *ngFor="let t of type" [value]="t.name" - >{{t.name | translate}} - </option> + >{{('WEBHOOKS.' + t.name ) | translate}}</option> </select> </div> diff --git a/src/app/service/appinstance.service.ts b/src/app/service/appinstance.service.ts index 75dd8f65024fb9940c5deecdeac54aefa931e4e2..5588249ba88a6251e19d2753e074d627f884c5a4 100644 --- a/src/app/service/appinstance.service.ts +++ b/src/app/service/appinstance.service.ts @@ -63,6 +63,11 @@ export class AppInstanceService extends GenericDataService { return this.post<AppInstanceRequest, Id>(this.getUrl() + 'domain/' + domainId, new AppInstanceRequest(appId, name, autoUpgradesEnabled)); } + public createAppInstanceInCluster(domainId: number, appId: number, name: string, autoUpgradesEnabled: boolean, clusterId: number): Observable<Id> { + const params = new HttpParams().set('clusterId', clusterId.toString()); + return this.http.post<Id>(this.getUrl() + 'domain/' + domainId, new AppInstanceRequest(appId, name, autoUpgradesEnabled), { params }); + } + public removeAppInstance(appInstanceId: number): Observable<any> { return this.delete<any>(this.getUrl() + appInstanceId); } diff --git a/src/app/shared/modal/appinstall/appinstallmodal.component.html b/src/app/shared/modal/appinstall/appinstallmodal.component.html index a20f13295c6c956e9c89c730e710bd492875de95..83c1876cfb2ad85ebd587339af208617f9fb02e5 100644 --- a/src/app/shared/modal/appinstall/appinstallmodal.component.html +++ b/src/app/shared/modal/appinstall/appinstallmodal.component.html @@ -26,6 +26,21 @@ <div style="padding-top: 15px"> <p><strong>{{'INSTALL_MODAL.DOMAIN' | translate}}: </strong>{{domainName}}</p> </div> + + <div class="form-group" style="padding-top: 15px"> + <label for="showCluster" style="padding-left: 0px" class="col-sm-10 control-label">{{ 'INSTALL_MODAL.REMOTE_CLUSTER' | translate }}:</label> + <div class="col-sm-2"> + <input type="checkbox" id="showCluster" name="showCluster" + [(ngModel)]="showClusterOptions" [checked]="showClusterOptions == true" (onchange)="onClusterOptionChange($event)"> + </div> + </div> + <div *ngIf="showClusterOptions" style="padding-top: 15px"> + <label for="selectCluster" class="control-label">{{'INSTALL_MODAL.SELECT_CLUSTER' | translate}}</label> + <select class="form-control" name="selectCluster" id="selectCluster" [(ngModel)]="selectedCluster" required> + <option *ngFor="let cluster of domain?.clusters" [value]="cluster.id" >{{cluster.name}}</option> + </select> + </div> + </div> </div> <div class="nmaas-modal-footer"> diff --git a/src/app/shared/modal/appinstall/appinstallmodal.component.ts b/src/app/shared/modal/appinstall/appinstallmodal.component.ts index 95ab5901369c57154a146c512e1b9109f9e33a00..c7b4aa13c263de84a8d8d0079730096d2afcf487 100644 --- a/src/app/shared/modal/appinstall/appinstallmodal.component.ts +++ b/src/app/shared/modal/appinstall/appinstallmodal.component.ts @@ -33,6 +33,11 @@ export class AppInstallModalComponent implements OnInit { autoUpgradesEnabled: boolean; error: string; + public selectedCluster: number; + + isRemoteClusterAvailable: boolean = false; + showClusterOptions: boolean = false; + public clicked = false; constructor(private appInstanceService: AppInstanceService, @@ -54,7 +59,18 @@ export class AppInstallModalComponent implements OnInit { public create(): void { if (this.domainId && this.app && this.app.id && !this.clicked) { this.clicked = true // block another method invocation - this.appInstanceService.createAppInstance(this.domainId, this.selectedAppVersion, this.name, this.autoUpgradesEnabled).subscribe( + if(this.showClusterOptions && this.selectedCluster) { + this.appInstanceService.createAppInstanceInCluster(this.domainId, this.app.id, this.name, this.autoUpgradesEnabled, this.selectedCluster).subscribe( + instanceId => { + this.modal.hide(); + this.router.navigate(['/instances', instanceId.id]); + }, + err => { + this.error = err.message; + this.clicked = false; // in case of error unlock the button + }); + } else { + this.appInstanceService.createAppInstance(this.domainId, this.selectedAppVersion, this.name, this.autoUpgradesEnabled).subscribe( instanceId => { this.modal.hide(); this.router.navigate(['/instances', instanceId.id]); @@ -64,10 +80,18 @@ export class AppInstallModalComponent implements OnInit { this.clicked = false; // in case of error unlock the button }); } + } + } public show(): void { + this.showClusterOptions = false; + this.selectedCluster = null; this.modal.show(); + console.log(this.domain); + if(this.domain.clusters.length >0 ) { + this.isRemoteClusterAvailable = true; + } } public applicationState(state: ApplicationState | string): ApplicationState { @@ -81,4 +105,7 @@ export class AppInstallModalComponent implements OnInit { return typeof state === 'string' && isNaN(Number(state.toString())) ? state : ApplicationState[state]; } + public onClusterOptionChange(event: any) { + console.log(event); + } }