-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from "@angular/core/testing"; | ||
|
||
import { EnvironmentService } from "./environment.service"; | ||
|
||
describe("EnvironmentService", () => { | ||
let service: EnvironmentService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(EnvironmentService); | ||
}); | ||
|
||
it("should be created", () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
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,16 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { BehaviorSubject } from "rxjs"; | ||
|
||
@Injectable({ | ||
providedIn: "root" | ||
}) | ||
export class EnvironmentService { | ||
|
||
private environment = new BehaviorSubject<string>(""); | ||
public environment$ = this.environment.asObservable(); | ||
|
||
|
||
setEnvironment(value: string) { | ||
this.environment.next(value); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div ngbDropdown class="d-inline-block" *ngIf="$environments | async; let environments"> | ||
<button type="button" class="btn btn btn-sm jtl-no-glow" id="dropdownBasic1" ngbDropdownToggle> | ||
{{selectedEnvironment || defaultEnvironment}} | ||
</button> | ||
<div ngbDropdownMenu aria-labelledby="dropdownBasic1"> | ||
<button ngbDropdownItem *ngFor="let _ of environments" (click)="filterEnvironment(_)">{{_}}</button> | ||
<button ngbDropdownItem (click)="filterEnvironment(defaultEnvironment)">{{defaultEnvironment}}</button> | ||
</div> | ||
</div> |
34 changes: 34 additions & 0 deletions
34
src/app/scenario/environments/environments.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,34 @@ | ||
import { ComponentFixture, TestBed } from "@angular/core/testing"; | ||
|
||
import { EnvironmentsComponent } from "./environments.component"; | ||
import { HTTP_INTERCEPTORS, HttpClientModule } from "@angular/common/http"; | ||
import { HttpRequestInterceptorMock } from "../../_interceptors/mock-interceptor"; | ||
|
||
describe("EnvironmentsComponent", () => { | ||
let component: EnvironmentsComponent; | ||
let fixture: ComponentFixture<EnvironmentsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [HttpClientModule], | ||
declarations: [EnvironmentsComponent], | ||
providers: [{ | ||
provide: HTTP_INTERCEPTORS, | ||
useClass: HttpRequestInterceptorMock, | ||
multi: true | ||
}] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(EnvironmentsComponent); | ||
component = fixture.componentInstance; | ||
component.params = { projectName: "test-project", scenarioName: "test-scenario" }; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("should create", () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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,46 @@ | ||
import { Component, Input, OnInit } from "@angular/core"; | ||
import { Observable } from "rxjs"; | ||
import { ScenarioService } from "../../scenario.service"; | ||
import { ItemsService } from "../../items.service"; | ||
import { EnvironmentService } from "../../_services/environment.service"; | ||
|
||
@Component({ | ||
selector: "app-environments", | ||
templateUrl: "./environments.component.html", | ||
styleUrls: ["./environments.component.css"] | ||
}) | ||
export class EnvironmentsComponent implements OnInit { | ||
$environments: Observable<Array<string>>; | ||
selectedEnvironment: string; | ||
defaultEnvironment = "All Environments"; | ||
|
||
@Input() params | ||
constructor( | ||
private scenarioService: ScenarioService, | ||
private itemsService: ItemsService, | ||
private environmentService: EnvironmentService, | ||
) { | ||
this.$environments = scenarioService.environments$; | ||
} | ||
|
||
ngOnInit(): void { | ||
this.scenarioService.fetchEnvironments(this.params.projectName, this.params.scenarioName); | ||
this.reloadData("") | ||
|
||
} | ||
// reload data and set new subscription(s) | ||
filterEnvironment(environment: string) { | ||
this.selectedEnvironment = environment | ||
const env = environment === this.defaultEnvironment ? "" : environment; | ||
this.reloadData(env) | ||
|
||
} | ||
|
||
private reloadData(environment) { | ||
this.environmentService.setEnvironment(environment) | ||
this.itemsService.fetchItems(this.params.projectName, this.params.scenarioName, { limit: 15, offset: 0 }); | ||
this.scenarioService.fetchScenarioTrends(this.params.projectName, this.params.scenarioName) | ||
this.itemsService.setProcessingItemsIntervalSubscription(this.params.projectName, this.params.scenarioName); | ||
} | ||
|
||
} |
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.