Skip to content
Snippets Groups Projects
Commit 56f8f4af authored by kbeyro's avatar kbeyro
Browse files

webhook updead, add cluster selection

parent b6d5165d
No related branches found
No related tags found
1 merge request!189webhook updead, add cluster selection
......@@ -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"
......
......@@ -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>
......
......@@ -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);
}
......
......@@ -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">
......
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment