Skip to content

Commit

Permalink
set default in field version (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgroschoff authored Jun 15, 2018
1 parent 1fe6639 commit 1cd9ec5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/app/core/services/api/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export class ApiService {
return this.http.get<DigitaloceanSizes>(url, { headers: this.headers });
}

getClusterUpgrades(cluster: string, dc: string): Observable<any[]> {
getClusterUpgrades(cluster: string, dc: string): Observable<MasterVersion[]> {
const url = `${this.restRootV3}/dc/${dc}/cluster/${cluster}/upgrades`;
return this.http.get<string[]>(url, { headers: this.headers })
return this.http.get<MasterVersion[]>(url, { headers: this.headers })
.catch(error => {
return Observable.of<string[]>([]);
return Observable.of<MasterVersion[]>([]);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/app/shared/entity/ClusterEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@ export class SSHKeyPair {
export class MasterVersion {
version: string;
allowedNodeVersions: string[];
default?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ <h4>Cluster Specifications</h4>
<mat-card-content>
<form [formGroup]="clusterSpecForm">
<mat-form-field>
<mat-select placeholder="Master Version:" formControlName="version">
<mat-select placeholder="Master Version (optional):" formControlName="version">
<mat-option *ngFor="let version of masterVersions" [value]="version.version">
{{ version.version }}
</mat-option>
</mat-select>
<mat-hint>Select the version that should be used for cluster creation. If not specified, the default version will be used.</mat-hint>
<mat-hint>Select the version that should be used for cluster creation. Unless otherwise specified, the default version {{defaultVersion}} will be used.</mat-hint>
</mat-form-field>
</form>
</mat-card-content>
Expand Down
7 changes: 7 additions & 0 deletions src/app/wizard/set-cluster-spec/set-cluster-spec.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class SetClusterSpecComponent implements OnInit, OnDestroy {
@Input() public cluster: ClusterEntity;
public clusterSpecForm: FormGroup;
public masterVersions: MasterVersion[] = [];
public defaultVersion: string;
private subscriptions: Subscription[] = [];

constructor(private nameGenerator: ClusterNameGenerator, private api: ApiService, private wizardService: WizardService) { }
Expand Down Expand Up @@ -50,6 +51,12 @@ export class SetClusterSpecComponent implements OnInit, OnDestroy {
loadMasterVersions() {
this.subscriptions.push(this.api.getMasterVersions().subscribe(versions => {
this.masterVersions = versions;
for (const i in versions) {
if (versions[i].default) {
this.defaultVersion = versions[i].version;
this.clusterSpecForm.controls.version.setValue(versions[i].version);
}
}
}));
}

Expand Down

0 comments on commit 1cd9ec5

Please sign in to comment.