diff --git a/wowup-electron/src/app/components/footer/footer.component.html b/wowup-electron/src/app/components/footer/footer.component.html index 189ef74a..008c8685 100644 --- a/wowup-electron/src/app/components/footer/footer.component.html +++ b/wowup-electron/src/app/components/footer/footer.component.html @@ -13,9 +13,8 @@

{{sessionService.pageContextText$ | async}}

v{{wowUpService.applicationVersion}}

-
diff --git a/wowup-electron/src/app/components/footer/footer.component.ts b/wowup-electron/src/app/components/footer/footer.component.ts index 05941342..f4af9fc7 100644 --- a/wowup-electron/src/app/components/footer/footer.component.ts +++ b/wowup-electron/src/app/components/footer/footer.component.ts @@ -3,6 +3,10 @@ import { SessionService } from "../../services/session/session.service"; import { WowUpService } from "../../services/wowup/wowup.service"; import { Observable } from "rxjs"; import { filter, map } from "rxjs/operators"; +import { runInNewContext } from "vm"; +import { TranslateService } from "@ngx-translate/core"; +import { MatDialog } from "@angular/material/dialog"; +import { ConfirmDialogComponent } from "../confirm-dialog/confirm-dialog.component"; @Component({ selector: "app-footer", @@ -10,21 +14,34 @@ import { filter, map } from "rxjs/operators"; styleUrls: ["./footer.component.scss"], }) export class FooterComponent implements OnInit { - public hasUpdate$: Observable; - public isUpdatingWowUp = false; + public isWowUpUpdateAvailable = false; + public isWowUpUpdateDownloaded = false; constructor( + private _dialog: MatDialog, + private _translateService: TranslateService, private _zone: NgZone, public wowUpService: WowUpService, public sessionService: SessionService - ) { - this.hasUpdate$ = this.sessionService.wowupUpdateInfo$.pipe( - map((info) => !!info) - ); - } + ) {} ngOnInit(): void { + this.wowUpService.wowupUpdateCheck$.subscribe((updateCheckResult) => { + console.debug("updateCheckResult", updateCheckResult); + this._zone.run(() => { + this.isWowUpUpdateAvailable = true; + }); + }); + + this.wowUpService.wowupUpdateDownloaded$.subscribe((result) => { + console.debug("wowupUpdateDownloaded", result); + this._zone.run(() => { + this.isWowUpUpdateDownloaded = true; + this.onClickUpdateWowup(); + }); + }); + // Force the angular zone to pump for every progress update since its outside the zone this.sessionService.statusText$.subscribe((text) => { this._zone.run(() => {}); @@ -35,13 +52,48 @@ export class FooterComponent implements OnInit { }); } + public getUpdateIconTooltip() { + if (this.isWowUpUpdateDownloaded) { + return "APP.WOWUP_UPDATE_DOWNLOADED_TOOLTIP"; + } + + if (this.isWowUpUpdateAvailable) { + return "APP.WOWUP_UPDATE_TOOLTIP"; + } + + return ""; + } + public async onClickUpdateWowup() { + if (!this.isWowUpUpdateAvailable) { + return; + } + + if (this.isWowUpUpdateDownloaded) { + const dialogRef = this._dialog.open(ConfirmDialogComponent, { + data: { + title: this._translateService.instant( + "APP.WOWUP_UPDATE_INSTALL_TITLE" + ), + message: this._translateService.instant( + "APP.WOWUP_UPDATE_INSTALL_MESSAGE" + ), + }, + }); + + dialogRef.afterClosed().subscribe((result) => { + if (!result) { + return; + } + this.wowUpService.installUpdate(); + }); + + return; + } + this.isUpdatingWowUp = true; try { - const result = await this.wowUpService.downloadUpdate(); - console.debug("onClickUpdateWowup", result); - - await this.wowUpService.installUpdate(); + await this.wowUpService.downloadUpdate(); } catch (e) { console.error("onClickUpdateWowup", e); } finally { diff --git a/wowup-electron/src/app/pages/home/home.component.ts b/wowup-electron/src/app/pages/home/home.component.ts index b511d6d2..aab0e4c9 100644 --- a/wowup-electron/src/app/pages/home/home.component.ts +++ b/wowup-electron/src/app/pages/home/home.component.ts @@ -11,6 +11,7 @@ import { SessionService } from "../../services/session/session.service"; import { WarcraftService } from "../../services/warcraft/warcraft.service"; import { WowUpService } from "../../services/wowup/wowup.service"; import { forkJoin } from "rxjs"; +import { UpdateCheckResult } from "electron-updater"; @Component({ selector: "app-home", @@ -41,7 +42,9 @@ export class HomeComponent implements OnInit, AfterViewInit { }); } - ngOnInit(): void {} + ngOnInit(): void { + this._wowupService.wowupUpdateCheck$.subscribe(this.showUpdateSnackbar); + } ngAfterViewInit(): void { this.checkForAppUpdate(); @@ -52,27 +55,27 @@ export class HomeComponent implements OnInit, AfterViewInit { } private async checkForAppUpdate() { + try { + const appUpdateResponse = await this._wowupService.checkForAppUpdate(); + console.log(appUpdateResponse); + } catch (e) { + console.error(e); + } + } + + private showUpdateSnackbar = async (updateCheckResult: UpdateCheckResult) => { // Have to wait for the localize service to start const [sbtext, sbaction] = await forkJoin([ this._translateService.get("APP.WOWUP_UPDATE_SNACKBAR_TEXT"), this._translateService.get("APP.WOWUP_UPDATE_SNACKBAR_ACTION"), ]).toPromise(); - try { - const appUpdateResponse = await this._wowupService.checkForAppUpdate(); - console.log(appUpdateResponse); + const snackBarRef = this._snackBar.open(sbtext, sbaction, { + duration: 2000, + }); - const snackBarRef = this._snackBar.open(sbtext, sbaction, { - duration: 2000, - }); - - snackBarRef.onAction().subscribe(() => { - console.log("The snack-bar action was triggered!"); - }); - - this._sessionService.wowupUpdateData = appUpdateResponse; - } catch (e) { - console.error(e); - } - } + snackBarRef.onAction().subscribe(() => { + console.log("The snack-bar action was triggered!"); + }); + }; } diff --git a/wowup-electron/src/app/pages/my-addons/my-addons.component.ts b/wowup-electron/src/app/pages/my-addons/my-addons.component.ts index 974c4ca2..27395632 100644 --- a/wowup-electron/src/app/pages/my-addons/my-addons.component.ts +++ b/wowup-electron/src/app/pages/my-addons/my-addons.component.ts @@ -58,11 +58,12 @@ export class MyAddonsComponent implements OnInit, OnDestroy { private subscriptions: Subscription[] = []; private isSelectedTab: boolean = false; - private sortedListItems: AddonViewModel[] = []; + + public sortedListItems: AddonViewModel[] = []; public spinnerMessage = ""; - contextMenuPosition = { x: "0px", y: "0px" }; + public contextMenuPosition = { x: "0px", y: "0px" }; public dataSource = new MatTableDataSource([]); public filter = ""; diff --git a/wowup-electron/src/app/services/session/session.service.ts b/wowup-electron/src/app/services/session/session.service.ts index 56e4e1b8..1db46af1 100644 --- a/wowup-electron/src/app/services/session/session.service.ts +++ b/wowup-electron/src/app/services/session/session.service.ts @@ -16,15 +16,11 @@ export class SessionService { private readonly _pageContextTextSrc = new BehaviorSubject(""); // right side bar text, context to the screen private readonly _statusTextSrc = new BehaviorSubject(""); // left side bar text, context to the app private readonly _selectedHomeTabSrc = new BehaviorSubject(0); - private readonly _wowupUpdateInfoSrc = new BehaviorSubject( - undefined - ); public readonly selectedClientType$ = this._selectedClientTypeSrc.asObservable(); public readonly statusText$ = this._statusTextSrc.asObservable(); public readonly selectedHomeTab$ = this._selectedHomeTabSrc.asObservable(); public readonly pageContextText$ = this._pageContextTextSrc.asObservable(); - public readonly wowupUpdateInfo$ = this._wowupUpdateInfoSrc.asObservable(); constructor( private _warcraftService: WarcraftService, @@ -59,10 +55,6 @@ export class SessionService { return this._selectedClientTypeSrc.value; } - public set wowupUpdateData(updateInfo: UpdateCheckResult) { - this._wowupUpdateInfoSrc.next(updateInfo); - } - private loadInitialClientType() { return this._warcraftService.installedClientTypes$.pipe( filter((clientTypes) => clientTypes !== undefined), diff --git a/wowup-electron/src/app/services/wowup/wowup.service.ts b/wowup-electron/src/app/services/wowup/wowup.service.ts index eb4b5e0b..0a854307 100644 --- a/wowup-electron/src/app/services/wowup/wowup.service.ts +++ b/wowup-electron/src/app/services/wowup/wowup.service.ts @@ -35,25 +35,34 @@ const LATEST_VERSION_CACHE_KEY = "latest-version-response"; }) export class WowUpService { private readonly _preferenceChangeSrc = new Subject(); + private readonly _wowupUpdateDownloadedSrc = new Subject(); + private readonly _wowupUpdateCheckSrc = new Subject(); public readonly updaterName = "WowUpUpdater.exe"; + public readonly applicationFolderPath: string = remote.app.getPath( "userData" ); + public readonly applicationLogsFolderPath: string = remote.app.getPath( "logs" ); + public readonly applicationDownloadsFolderPath: string = join( this.applicationFolderPath, "downloads" ); + public readonly applicationUpdaterPath: string = join( this.applicationFolderPath, this.updaterName ); + public readonly applicationVersion: string; public readonly isBetaBuild: boolean; public readonly preferenceChange$ = this._preferenceChangeSrc.asObservable(); + public readonly wowupUpdateDownloaded$ = this._wowupUpdateDownloadedSrc.asObservable(); + public readonly wowupUpdateCheck$ = this._wowupUpdateCheckSrc.asObservable(); constructor( private _preferenceStorageService: PreferenceStorageService, @@ -182,11 +191,21 @@ export class WowUpService { } public async checkForAppUpdate(): Promise { - return await this._electronService.invoke(APP_UPDATE_CHECK_FOR_UPDATE); + const updateCheckResult = await this._electronService.invoke( + APP_UPDATE_CHECK_FOR_UPDATE + ); + + this._wowupUpdateCheckSrc.next(updateCheckResult); + return updateCheckResult; } public async downloadUpdate() { - return await this._electronService.invoke(APP_UPDATE_START_DOWNLOAD); + const downloadResult = await this._electronService.invoke( + APP_UPDATE_START_DOWNLOAD + ); + + this._wowupUpdateDownloadedSrc.next(downloadResult); + return downloadResult; } public async installUpdate() { diff --git a/wowup-electron/src/assets/changelog.json b/wowup-electron/src/assets/changelog.json index 9203e355..f8838fa8 100644 --- a/wowup-electron/src/assets/changelog.json +++ b/wowup-electron/src/assets/changelog.json @@ -1,5 +1,9 @@ { "ChangeLogs": [ + { + "Version": "2.0.0-alpha.16", + "Description": "" + }, { "Version": "2.0.0-alpha.15", "Description": "Add the ability to translate plurals (Chops)\nAdd the alpha/beta indicator for user's default install channel to the 'Get Addons' tab (Chops)\nAdd new column to show the last updated time of an Addon (Linaori)\nAdd support for installing vir URL from CurseForge\nShow the release date in a more user friendly way (Chops)\nMore text items are now translated with updated locales (Linaori)\nNew placehold thumbnail for Addons\nAddon author list now limited to 3 rows\nSwitch to a new analytics provider.\nFix issue with addon count not changing when deleting an addon.\nSeveral fixes for linux support" diff --git a/wowup-electron/src/assets/i18n/de.json b/wowup-electron/src/assets/i18n/de.json index 05293adc..50d94fb9 100644 --- a/wowup-electron/src/assets/i18n/de.json +++ b/wowup-electron/src/assets/i18n/de.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatisch {count} {count, plural, =1{Addon} other{Addons}} aktualisiert.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Automatische Aktualisierung", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" @@ -159,7 +162,6 @@ "APPLICATION": { "ENABLE_SYSTEM_NOTIFICATIONS_DESCRIPTION": "Aktivieren / Deaktivieren verschiedener Systembenachrichtigungen", "ENABLE_SYSTEM_NOTIFICATIONS_LABEL": "Systembenachrichtigungen aktivieren", - "MINIMIZE_ON_CLOSE_DESCRIPTION_MAC": "When closing the WowUp window, minimize to the menu bar.", "MINIMIZE_ON_CLOSE_DESCRIPTION_MAC": "Beim schließen WowUp in der Menübar minimieren", "MINIMIZE_ON_CLOSE_DESCRIPTION_WINDOWS": "Beim Schließen des WowUp-Fensters auf das Systemabschnitt minimieren.", "MINIMIZE_ON_CLOSE_LABEL": "Minimieren beim Schliessen", @@ -195,4 +197,4 @@ } } } -} \ No newline at end of file +} diff --git a/wowup-electron/src/assets/i18n/en.json b/wowup-electron/src/assets/i18n/en.json index 16c6c42c..18a25243 100644 --- a/wowup-electron/src/assets/i18n/en.json +++ b/wowup-electron/src/assets/i18n/en.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/es.json b/wowup-electron/src/assets/i18n/es.json index f6afb20b..64750257 100644 --- a/wowup-electron/src/assets/i18n/es.json +++ b/wowup-electron/src/assets/i18n/es.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/fr.json b/wowup-electron/src/assets/i18n/fr.json index be25debe..fc2ee686 100644 --- a/wowup-electron/src/assets/i18n/fr.json +++ b/wowup-electron/src/assets/i18n/fr.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/it.json b/wowup-electron/src/assets/i18n/it.json index f72b61c1..7ec3eef8 100644 --- a/wowup-electron/src/assets/i18n/it.json +++ b/wowup-electron/src/assets/i18n/it.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/ko.json b/wowup-electron/src/assets/i18n/ko.json index 780c5ffc..7a799c8c 100644 --- a/wowup-electron/src/assets/i18n/ko.json +++ b/wowup-electron/src/assets/i18n/ko.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/nb.json b/wowup-electron/src/assets/i18n/nb.json index 8bb285dc..5902ca99 100644 --- a/wowup-electron/src/assets/i18n/nb.json +++ b/wowup-electron/src/assets/i18n/nb.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/pt.json b/wowup-electron/src/assets/i18n/pt.json index c38da7e5..eae2d2d2 100644 --- a/wowup-electron/src/assets/i18n/pt.json +++ b/wowup-electron/src/assets/i18n/pt.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/ru.json b/wowup-electron/src/assets/i18n/ru.json index c54699e8..ad79500e 100644 --- a/wowup-electron/src/assets/i18n/ru.json +++ b/wowup-electron/src/assets/i18n/ru.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Автоматически {count, plural, one{обновлена} other{обновлено}} {count} {count, plural, one{модификация} few{модификации} other{модификаций}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Автоматические обновления", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available" diff --git a/wowup-electron/src/assets/i18n/zh.json b/wowup-electron/src/assets/i18n/zh.json index 1f036ae7..f7c9c17a 100644 --- a/wowup-electron/src/assets/i18n/zh.json +++ b/wowup-electron/src/assets/i18n/zh.json @@ -2,6 +2,9 @@ "APP": { "AUTO_UPDATE_NOTIFICATION_BODY": "Automatically updated {count} {count, plural, =1{addon} other{addons}}.", "AUTO_UPDATE_NOTIFICATION_TITLE": "Auto Updates", + "WOWUP_UPDATE_DOWNLOADED_TOOLTIP": "Install WowUp update", + "WOWUP_UPDATE_INSTALL_MESSAGE": "Do you want restart WowUp to install the update?", + "WOWUP_UPDATE_INSTALL_TITLE": "WowUp Update Ready", "WOWUP_UPDATE_SNACKBAR_ACTION": "Update", "WOWUP_UPDATE_SNACKBAR_TEXT": "A new version of WowUp is available", "WOWUP_UPDATE_TOOLTIP": "WowUp update available"