diff --git a/wowup-electron/src/app/components/common/client-selector/client-selector.component.html b/wowup-electron/src/app/components/common/client-selector/client-selector.component.html new file mode 100644 index 00000000..3b94b6aa --- /dev/null +++ b/wowup-electron/src/app/components/common/client-selector/client-selector.component.html @@ -0,0 +1,38 @@ +
+ + +
+
PAGES.MY_ADDONS.CLIENT_TYPE_SELECT_LABEL
+
+ PAGES.MY_ADDONS.CLIENT_TYPE_SELECT_BADGE +
+
+
+ + + {{ selectedWowInstallationLabel$ | async }} + + +
+
{{ installation.label }}
+
+
+ {{ installation.availableUpdateCount }} +
+
+
+
+
+
+
diff --git a/wowup-electron/src/app/components/common/client-selector/client-selector.component.scss b/wowup-electron/src/app/components/common/client-selector/client-selector.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/wowup-electron/src/app/components/common/client-selector/client-selector.component.spec.ts b/wowup-electron/src/app/components/common/client-selector/client-selector.component.spec.ts new file mode 100644 index 00000000..877050a4 --- /dev/null +++ b/wowup-electron/src/app/components/common/client-selector/client-selector.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ClientSelectorComponent } from './client-selector.component'; + +describe('ClientSelectorComponent', () => { + let component: ClientSelectorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ClientSelectorComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ClientSelectorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/wowup-electron/src/app/components/common/client-selector/client-selector.component.ts b/wowup-electron/src/app/components/common/client-selector/client-selector.component.ts new file mode 100644 index 00000000..185864f8 --- /dev/null +++ b/wowup-electron/src/app/components/common/client-selector/client-selector.component.ts @@ -0,0 +1,57 @@ +import { Component, Input, OnInit } from "@angular/core"; +import { BehaviorSubject, combineLatest, Observable } from "rxjs"; +import { map } from "rxjs/operators"; +import { WowInstallation } from "../../../../common/warcraft/wow-installation"; +import { AddonService } from "../../../services/addons/addon.service"; +import { SessionService } from "../../../services/session/session.service"; +import { WarcraftInstallationService } from "../../../services/warcraft/warcraft-installation.service"; + +@Component({ + selector: "app-client-selector", + templateUrl: "./client-selector.component.html", + styleUrls: ["./client-selector.component.scss"], +}) +export class ClientSelectorComponent implements OnInit { + @Input() updates: boolean = false; + + public readonly totalAvailableUpdateCt$ = new BehaviorSubject(0); + + public readonly enableControls$ = new BehaviorSubject(true); + + public readonly selectedWowInstallationId$ = this._sessionService.selectedWowInstallation$.pipe( + map((wowInstall) => wowInstall?.id) + ); + + public readonly selectedWowInstallationLabel$ = this._sessionService.selectedWowInstallation$.pipe( + map((wowInstall) => wowInstall?.label ?? "") + ); + + public wowInstallations$: Observable = combineLatest([ + this._warcraftInstallationService.wowInstallations$, + this._addonService.anyUpdatesAvailable$, + ]).pipe( + map(([installations]) => { + let total = 0; + installations.forEach((inst) => { + inst.availableUpdateCount = this._addonService.getAllAddonsAvailableForUpdate(inst).length; + total += inst.availableUpdateCount; + }); + + this.totalAvailableUpdateCt$.next(total); + return installations; + }) + ); + + constructor( + private _addonService: AddonService, + private _sessionService: SessionService, + private _warcraftInstallationService: WarcraftInstallationService + ) {} + + ngOnInit(): void {} + + public onClientChange(evt: any): void { + const val: string = evt.value.toString(); + this._sessionService.setSelectedWowInstallation(val); + } +} diff --git a/wowup-electron/src/app/modules/common-ui.module.ts b/wowup-electron/src/app/modules/common-ui.module.ts index 9a7fce12..e107a5c3 100644 --- a/wowup-electron/src/app/modules/common-ui.module.ts +++ b/wowup-electron/src/app/modules/common-ui.module.ts @@ -6,6 +6,7 @@ import { AlertDialogComponent } from "../components/common/alert-dialog/alert-di import { AnimatedLogoComponent } from "../components/common/animated-logo/animated-logo.component"; import { CellWrapTextComponent } from "../components/common/cell-wrap-text/cell-wrap-text.component"; import { CenteredSnackbarComponent } from "../components/common/centered-snackbar/centered-snackbar.component"; +import { ClientSelectorComponent } from "../components/common/client-selector/client-selector.component"; import { ConfirmDialogComponent } from "../components/common/confirm-dialog/confirm-dialog.component"; import { ExternalUrlConfirmationDialogComponent } from "../components/common/external-url-confirmation-dialog/external-url-confirmation-dialog.component"; import { PatchNotesDialogComponent } from "../components/common/patch-notes-dialog/patch-notes-dialog.component"; @@ -28,6 +29,7 @@ import { PipesModule } from "./pipes.module"; TelemetryDialogComponent, CellWrapTextComponent, CenteredSnackbarComponent, + ClientSelectorComponent, ], imports: [CommonModule, FormsModule, TranslateModule, MatModule, PipesModule], exports: [ @@ -42,6 +44,7 @@ import { PipesModule } from "./pipes.module"; TelemetryDialogComponent, CellWrapTextComponent, CenteredSnackbarComponent, + ClientSelectorComponent, ], }) export class CommonUiModule {} diff --git a/wowup-electron/src/app/pages/get-addons/get-addons.component.html b/wowup-electron/src/app/pages/get-addons/get-addons.component.html index 4ff1b605..64afb5e9 100644 --- a/wowup-electron/src/app/pages/get-addons/get-addons.component.html +++ b/wowup-electron/src/app/pages/get-addons/get-addons.component.html @@ -5,15 +5,7 @@ }" (click)="onTableBlur($event)">
- - {{ "PAGES.GET_ADDONS.CLIENT_TYPE_SELECT_LABEL" | translate }} - - - {{ installation.label }} - - - +

diff --git a/wowup-electron/src/app/pages/my-addons/my-addons.component.html b/wowup-electron/src/app/pages/my-addons/my-addons.component.html index c2cd3111..8d37d370 100644 --- a/wowup-electron/src/app/pages/my-addons/my-addons.component.html +++ b/wowup-electron/src/app/pages/my-addons/my-addons.component.html @@ -9,42 +9,7 @@ >
- - -
-
{{ "PAGES.MY_ADDONS.CLIENT_TYPE_SELECT_LABEL" | translate }}
-
- PAGES.MY_ADDONS.CLIENT_TYPE_SELECT_BADGE -
-
-
- - - {{ selectedWowInstallationLabel$ | async }} - - -
-
{{ installation.label }}
-
-
- {{ installation.availableUpdateCount }} -
-
-
-
-
-
+