-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Custom image show the correct os when using windows images (#1481)
- Loading branch information
1 parent
66418f6
commit f74d391
Showing
16 changed files
with
235 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./pool-os-icon.component"; |
138 changes: 138 additions & 0 deletions
138
app/components/pool/base/pool-os-icon/pool-os-icon.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { Component, DebugElement } from "@angular/core"; | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
import { MatTooltip, MatTooltipModule } from "@angular/material"; | ||
import { By } from "@angular/platform-browser"; | ||
import { Pool } from "app/models"; | ||
import { PoolOsIconComponent } from "./pool-os-icon.component"; | ||
|
||
const ubuntuPool = new Pool({ | ||
id: "ubuntu-pool", | ||
virtualMachineConfiguration: { | ||
imageReference: { | ||
offer: "UbuntuServer", | ||
publisher: "Canonical", | ||
sku: "16.04-LTS", | ||
version: "latest", | ||
}, | ||
nodeAgentSKUId: "batch.node.ubuntu 16.04", | ||
}, | ||
}); | ||
|
||
const windowsServerPool = new Pool({ | ||
id: "windows-server-pool", | ||
virtualMachineConfiguration: { | ||
imageReference: { | ||
offer: "WindowsServer", | ||
publisher: "MicrosoftWindowsServer", | ||
sku: "2016-Datacenter", | ||
version: "latest", | ||
}, | ||
nodeAgentSKUId: "batch.node.windows amd64", | ||
}, | ||
}); | ||
|
||
const windowsCustomImage = new Pool({ | ||
id: "windows-server-pool", | ||
virtualMachineConfiguration: { | ||
imageReference: { | ||
virtualMachineImageId: "some-windows-image-id", | ||
}, | ||
nodeAgentSKUId: "batch.node.windows amd64", | ||
}, | ||
}); | ||
|
||
const linuxCustomImage = new Pool({ | ||
id: "windows-server-pool", | ||
virtualMachineConfiguration: { | ||
imageReference: { | ||
virtualMachineImageId: "some-windows-image-id", | ||
}, | ||
nodeAgentSKUId: "batch.node.centos 7", | ||
}, | ||
}); | ||
|
||
@Component({ | ||
template: `<bl-pool-os-icon [pool]="pool"></bl-pool-os-icon>`, | ||
}) | ||
class TestComponent { | ||
public pool: Pool = ubuntuPool; | ||
} | ||
|
||
describe("PoolOsIconComponent", () => { | ||
let fixture: ComponentFixture<TestComponent>; | ||
let testComponent: TestComponent; | ||
let de: DebugElement; | ||
let iconEl: DebugElement; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MatTooltipModule], | ||
declarations: [PoolOsIconComponent, TestComponent], | ||
}); | ||
fixture = TestBed.createComponent(TestComponent); | ||
testComponent = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css("bl-pool-os-icon")); | ||
fixture.detectChanges(); | ||
iconEl = de.query(By.css(".fa")); | ||
}); | ||
|
||
describe("when pool is ubuntu", () => { | ||
beforeEach(() => { | ||
testComponent.pool = ubuntuPool; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("shows linux icon", () => { | ||
expect(iconEl.nativeElement.classList).toContain("fa-linux"); | ||
}); | ||
|
||
it("shows os in tooltip", () => { | ||
expect(iconEl.injector.get(MatTooltip).message).toEqual("UbuntuServer 16.04-LTS"); | ||
}); | ||
}); | ||
|
||
describe("when pool is windows server", () => { | ||
beforeEach(() => { | ||
testComponent.pool = windowsServerPool; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("shows windows icon", () => { | ||
expect(iconEl.nativeElement.classList).toContain("fa-windows"); | ||
}); | ||
|
||
it("shows os in tooltip", () => { | ||
expect(iconEl.injector.get(MatTooltip).message).toEqual("Windows Server 2016-Datacenter"); | ||
}); | ||
}); | ||
|
||
describe("when pool is custom image(Linux)", () => { | ||
beforeEach(() => { | ||
testComponent.pool = linuxCustomImage; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("shows linux icon", () => { | ||
expect(iconEl.nativeElement.classList).toContain("fa-linux"); | ||
}); | ||
|
||
it("shows os in tooltip", () => { | ||
expect(iconEl.injector.get(MatTooltip).message).toEqual("Custom image (linux)"); | ||
}); | ||
}); | ||
|
||
describe("when pool is custom image(Windows)", () => { | ||
beforeEach(() => { | ||
testComponent.pool = windowsCustomImage; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("shows windows icon", () => { | ||
expect(iconEl.nativeElement.classList).toContain("fa-windows"); | ||
}); | ||
|
||
it("shows os in tooltip", () => { | ||
expect(iconEl.injector.get(MatTooltip).message).toEqual("Custom image (windows)"); | ||
}); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
app/components/pool/base/pool-os-icon/pool-os-icon.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ChangeDetectionStrategy, Component, Input, OnChanges } from "@angular/core"; | ||
import { OSType, Pool } from "app/models"; | ||
|
||
import "./pool-os-icon.scss"; | ||
|
||
@Component({ | ||
selector: "bl-pool-os-icon", | ||
templateUrl: "pool-os-icon.html", | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class PoolOsIconComponent implements OnChanges { | ||
@Input() public pool: Pool; | ||
@Input() public tooltipPosition: string = "right"; | ||
|
||
public icon: string; | ||
|
||
public ngOnChanges(inputs) { | ||
if (inputs.pool) { | ||
this.icon = this._computeIcon(); | ||
} | ||
} | ||
|
||
private _computeIcon() { | ||
if (this.pool.osType === OSType.Windows) { | ||
return "fa-windows"; | ||
} else if (this.pool.osType === OSType.Linux) { | ||
return "fa-linux"; | ||
} else { | ||
return "fa-cloud"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<i class="fa {{icon}}" [matTooltip]="pool.osName" [matTooltipPosition]="tooltipPosition"></i> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bl-pool-list { | ||
bl-pool-os-icon { | ||
margin-right: 4px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.