Skip to content
Snippets Groups Projects
Commit 2f2a2c1f authored by Lukasz Lopatowski's avatar Lukasz Lopatowski
Browse files

Pull request #2: NMAAS-980 removed edit mode from clusters details component

Merge in NMAAS/nmaas-portal from NMAAS-980-remove-edit-option-from-k8s-admin-panel to develop

* commit 'a03f4100':
  NMAAS-980 removed edit mode from clusters details component
parents e2a47da6 a03f4100
No related branches found
No related tags found
No related merge requests found
<nmaas-clusterdetails class="col-sm-12 col-sm-12 col-md-12" [cluster]="cluster" [error]="error" [mode]="getCurrentMode()" [allowedModes]="[ComponentMode.VIEW, ComponentMode.EDIT, ComponentMode.CREATE]" (onSave)="onSave($event)" (onDelete)="onDelete($event)"></nmaas-clusterdetails> <nmaas-clusterdetails class="col-sm-12 col-sm-12 col-md-12" [cluster]="cluster" [error]="error" [mode]="getCurrentMode()" [allowedModes]="[ComponentMode.VIEW, ComponentMode.CREATE]" (onSave)="onSave($event)" (onDelete)="onDelete($event)"></nmaas-clusterdetails>
...@@ -243,12 +243,8 @@ ...@@ -243,12 +243,8 @@
<p>{{this.error}}</p> <p>{{this.error}}</p>
</div> </div>
<button *ngIf="isInMode(ComponentMode.EDIT)" type="button"
class="btn btn-default" (click)="onModeChange()">{{ 'CLUSTERS.VIEW_BUTTON' | translate }}</button>
<button *ngIf="!isInMode(ComponentMode.VIEW)" [disabled]="!clusterForm.form.valid" type="submit" <button *ngIf="!isInMode(ComponentMode.VIEW)" [disabled]="!clusterForm.form.valid" type="submit"
class="btn btn-primary">{{ 'CLUSTERS.SUBMIT_BUTTON' | translate }}</button> class="btn btn-primary">{{ 'CLUSTERS.SUBMIT_BUTTON' | translate }}</button>
<button *ngIf="isInMode(ComponentMode.VIEW) && isModeAllowed(ComponentMode.EDIT)"
type="button" class="btn btn-default" (click)="onModeChange()">{{ 'CLUSTERS.EDIT_BUTTON' | translate }}</button>
</form> </form>
</div> </div>
</div> </div>
...@@ -7,7 +7,6 @@ import { ...@@ -7,7 +7,6 @@ import {
NamespaceConfigOption NamespaceConfigOption
} from '../../../../model/cluster'; } from '../../../../model/cluster';
import {BaseComponent} from '../../../common/basecomponent/base.component'; import {BaseComponent} from '../../../common/basecomponent/base.component';
import {ComponentMode} from '../../../common/componentmode';
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
...@@ -30,7 +29,7 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit { ...@@ -30,7 +29,7 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit {
public cluster: Cluster = new Cluster(); public cluster: Cluster = new Cluster();
@Input() @Input()
public error:string; public error: string;
@Output() @Output()
public onSave: EventEmitter<Cluster> = new EventEmitter<Cluster>(); public onSave: EventEmitter<Cluster> = new EventEmitter<Cluster>();
...@@ -38,10 +37,10 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit { ...@@ -38,10 +37,10 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit {
@Output() @Output()
public onDelete: EventEmitter<string> = new EventEmitter<string>(); public onDelete: EventEmitter<string> = new EventEmitter<string>();
constructor(private router: Router) { constructor(private router: Router) {
super(); super();
this.initializeMaps(); this.initializeMaps();
} }
ngOnInit() { ngOnInit() {
...@@ -55,26 +54,16 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit { ...@@ -55,26 +54,16 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit {
this.onDelete.emit(clusterName); this.onDelete.emit(clusterName);
} }
public onModeChange(): void {
const newMode: ComponentMode = (this.mode === ComponentMode.VIEW ? ComponentMode.EDIT : ComponentMode.VIEW);
if (this.isModeAllowed(newMode)) {
this.mode = newMode;
if(this.mode === ComponentMode.VIEW){
this.router.navigate(['admin/clusters'])
}
}
}
public removeNetwork(id) { public removeNetwork(id) {
this.cluster.externalNetworks.splice( this.cluster.externalNetworks.splice(
this.cluster.externalNetworks.findIndex( this.cluster.externalNetworks.findIndex(
function(i){ function (i) {
return i.id = id; return i.id = id;
}), 1); }), 1);
} }
public addNetwork() { public addNetwork() {
let newobj: ClusterExtNetwork= new ClusterExtNetwork(); const newobj: ClusterExtNetwork = new ClusterExtNetwork();
this.cluster.externalNetworks.push(newobj); this.cluster.externalNetworks.push(newobj);
} }
...@@ -82,16 +71,16 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit { ...@@ -82,16 +71,16 @@ export class ClusterDetailsComponent extends BaseComponent implements OnInit {
return index; return index;
} }
public getKeys(map){ public getKeys(map) {
return Array.from(map.keys()); return Array.from(map.keys());
} }
private initializeMaps(){ private initializeMaps() {
this.resourceConfigOption.set('Do nothing',IngressResourceConfigOption.NOT_USED); this.resourceConfigOption.set('Do nothing', IngressResourceConfigOption.NOT_USED);
this.resourceConfigOption.set('Deploy new resource from the definition in the application chart', IngressResourceConfigOption.DEPLOY_FROM_CHART); this.resourceConfigOption.set('Deploy new resource from the definition in the application chart', IngressResourceConfigOption.DEPLOY_FROM_CHART);
this.controllerConfigOption.set('Use existing',IngressControllerConfigOption.USE_EXISTING); this.controllerConfigOption.set('Use existing', IngressControllerConfigOption.USE_EXISTING);
this.controllerConfigOption.set('Deploy new controller from chart repository', IngressControllerConfigOption.DEPLOY_NEW_FROM_REPO); this.controllerConfigOption.set('Deploy new controller from chart repository', IngressControllerConfigOption.DEPLOY_NEW_FROM_REPO);
this.controllerConfigOption.set('Deploy new controller from local chart archive',IngressControllerConfigOption.DEPLOY_NEW_FROM_ARCHIVE); this.controllerConfigOption.set('Deploy new controller from local chart archive', IngressControllerConfigOption.DEPLOY_NEW_FROM_ARCHIVE);
this.namespaceConfigOption.set('Use default namespace', NamespaceConfigOption.USE_DEFAULT_NAMESPACE); this.namespaceConfigOption.set('Use default namespace', NamespaceConfigOption.USE_DEFAULT_NAMESPACE);
this.namespaceConfigOption.set('Use domain namespace', NamespaceConfigOption.USE_DOMAIN_NAMESPACE); this.namespaceConfigOption.set('Use domain namespace', NamespaceConfigOption.USE_DOMAIN_NAMESPACE);
this.namespaceConfigOption.set('Create namespace', NamespaceConfigOption.CREATE_NAMESPACE); this.namespaceConfigOption.set('Create namespace', NamespaceConfigOption.CREATE_NAMESPACE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment