Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pricing and fix it being hard coded for linux #465

Merged
merged 2 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DomSanitizer } from "@angular/platform-browser";
import { registerIcons } from "app/config";
import {
AccountService, AdalService, AutoscaleFormulaService, CommandService, NodeService,
PredefinedFormulaService, SSHKeyService, SettingsService, SubscriptionService, VmSizeService,
PredefinedFormulaService, PricingService, SSHKeyService, SettingsService, SubscriptionService, VmSizeService,
} from "app/services";
import { SidebarContentComponent, SidebarManager } from "./components/base/sidebar";

Expand Down Expand Up @@ -45,13 +45,14 @@ export class AppComponent implements AfterViewInit, OnInit {
private nodeService: NodeService,
private sshKeyService: SSHKeyService,
private vmSizeService: VmSizeService,
private pricingService: PricingService,
private predefinedFormulaService: PredefinedFormulaService) {

this.autoscaleFormulaService.init();
this.settingsService.init();
this.sshKeyService.init();
this.commandService.init();
// Init the pricing when good to go.
// this.pricingService.init();
this.pricingService.init();
this.vmSizeService.init();
this.adalService.init(adalConfig);
this.accountService.loadInitialData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { PoolService, VmSizeService } from "app/services";
})
export class PoolCreateBasicDialogComponent extends DynamicForm<Pool, PoolCreateDto> implements OnDestroy {
public osSource: PoolOsSources = PoolOsSources.IaaS;
public osType: "linux" | "windows" = "linux";
public NodeFillType = NodeFillType;

private _osControl: FormControl;
Expand Down Expand Up @@ -52,6 +53,17 @@ export class PoolCreateBasicDialogComponent extends DynamicForm<Pool, PoolCreate

this._sub = this._osControl.valueChanges.subscribe((value) => {
this.osSource = value.source;
if (value.source === PoolOsSources.PaaS) {
this.osType = "windows";
} else {
const config = value.virtualMachineConfiguration;
const agentId: string = config && config.nodeAgentSKUId;
if (agentId && agentId.toLowerCase().indexOf("windows") !== -1) {
this.osType = "windows";
} else {
this.osType = "linux";
}
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<bl-form-section title="Choose a virtual machine size" subtitle="Choose the virtual machine based on CPU, RAM and Disk capacity">
<div class="form-element element-spacer">
<bl-vm-size-picker formControlName="vmSize" [osSource]="osSource"></bl-vm-size-picker>
<bl-vm-size-picker formControlName="vmSize" [osSource]="osSource" [osType]="osType"></bl-vm-size-picker>
<bl-error controlName="vmSize" code="required">You must select a VM size</bl-error>
</div>
</bl-form-section>
Expand Down
10 changes: 9 additions & 1 deletion app/components/pool/action/add/vm-size-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export class VmSizeDecorator {
export class VmSizePickerComponent implements ControlValueAccessor, OnInit, OnChanges, OnDestroy {
@Input()
public osSource: PoolOsSources;

@Input()
public osType: "linux" | "windows";

public pickedSize: string;

public categoryNames: string[];
Expand Down Expand Up @@ -107,6 +111,10 @@ export class VmSizePickerComponent implements ControlValueAccessor, OnInit, OnCh
this._categorizeSizes();
});
}

if (inputs.osType) {
this._loadPrices();
}
}

public ngOnDestroy() {
Expand Down Expand Up @@ -194,7 +202,7 @@ export class VmSizePickerComponent implements ControlValueAccessor, OnInit, OnCh

private _loadPrices() {
this.accountService.currentAccount.flatMap((account) => {
const os = "linux"; // TODO update this.
const os = this.osType || "linux";
return this.pricingService.getPrices(account.location, os);
}).subscribe((prices: List<SpecCost>) => {
const map: StringMap<SpecCost> = {};
Expand Down
16 changes: 8 additions & 8 deletions app/components/pool/action/add/vm-size-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<bl-table [activeItem]="pickedSize" (activeItemChange)="pickSize($event)">
<bl-thead>
<bl-column [sortable]="true">Name</bl-column>
<!--<bl-column [sortable]="true">Price per node(Monthly)</bl-column>-->
<bl-column [sortable]="true">Cores</bl-column>
<bl-column [sortable]="true">RAM</bl-column>
<bl-column [sortable]="true">OS Disk</bl-column>
<bl-column [sortable]="true">Price per node(Monthly)</bl-column>
<bl-column style="width: 60px" [sortable]="true">Cores</bl-column>
<bl-column style="width: 60px" [sortable]="true">RAM</bl-column>
<bl-column style="width: 70px" [sortable]="true">OS Disk</bl-column>
<bl-column [sortable]="true">Resource/Temp Disk</bl-column>
</bl-thead>
<bl-row *ngFor="let size of categories[category]" [key]="size.vmSize.id">
<bl-cell [value]="size.vmSize.name">{{size.title}}</bl-cell>
<!--<bl-cell [value]="size.price">{{size.prettyPrice}}</bl-cell>-->
<bl-cell [value]="size.vmSize.numberOfCores"></bl-cell>
<bl-cell [value]="size.vmSize.memoryInMB">{{size.prettyRAM}}</bl-cell>
<bl-cell [value]="size.vmSize.osDiskSizeInMB">{{size.prettyOSDiskSize}}</bl-cell>
<bl-cell [value]="size.price">{{size.prettyPrice}}</bl-cell>
<bl-cell style="width: 60px" [value]="size.vmSize.numberOfCores"></bl-cell>
<bl-cell style="width: 60px" [value]="size.vmSize.memoryInMB">{{size.prettyRAM}}</bl-cell>
<bl-cell style="width: 70px" [value]="size.vmSize.osDiskSizeInMB">{{size.prettyOSDiskSize}}</bl-cell>
<bl-cell [value]="size.vmSize.resourceDiskSizeInMB">{{size.prettyResourceDiskSize}}</bl-cell>
</bl-row>
</bl-table>
Expand Down