From 8e8d6721a0404d525d792a6540d45b1afd31798d Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Thu, 25 May 2017 22:54:40 +0200 Subject: [PATCH 1/8] Started moving updater dialogs inside the app itself --- client/package.json | 1 + client/src/app/app.component.ts | 6 ++-- client/src/app/app.module.ts | 6 ++++ client/src/app/updater.service.ts | 36 +++++++++++++++++++++++ client/src/index.html | 1 + electron/updater.js | 48 ++++++++++++++++++------------- 6 files changed, 75 insertions(+), 23 deletions(-) create mode 100644 client/src/app/updater.service.ts diff --git a/client/package.json b/client/package.json index 11c10e5..651ffe1 100644 --- a/client/package.json +++ b/client/package.json @@ -25,6 +25,7 @@ "@swimlane/ngx-datatable": "^9.1.0", "core-js": "^2.4.1", "nedb": "^1.8.0", + "ngx-electron": "0.0.11", "rxjs": "^5.4.0", "typescript": "^2.3.2", "zone.js": "^0.8.10" diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 1246ff3..9b41ede 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -1,10 +1,10 @@ import { Component } from '@angular/core'; - +import { UpdaterService } from './updater.service'; @Component({ selector: 'pokemon-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) -export class AppComponent { - +export class AppComponent { + constructor(private updaterService: UpdaterService) { } } diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index f272682..501f5ab 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -13,8 +13,12 @@ import { CardService } from './card.service'; import { CollectionService } from './collection.service'; import { MenuItemComponent } from './menu-item/menu-item.component'; +import { UpdaterService } from './updater.service'; + import { NgxDatatableModule } from '@swimlane/ngx-datatable'; +import { NgxElectronModule } from 'ngx-electron'; + @NgModule({ declarations: [ AppComponent, @@ -22,6 +26,7 @@ import { NgxDatatableModule } from '@swimlane/ngx-datatable'; MenuItemComponent ], imports: [ + NgxElectronModule, BrowserModule, HttpModule, BrowserAnimationsModule, @@ -29,6 +34,7 @@ import { NgxDatatableModule } from '@swimlane/ngx-datatable'; NgxDatatableModule ], providers: [ + UpdaterService, SetService, CardService, CollectionService diff --git a/client/src/app/updater.service.ts b/client/src/app/updater.service.ts new file mode 100644 index 0000000..94c7bd5 --- /dev/null +++ b/client/src/app/updater.service.ts @@ -0,0 +1,36 @@ +import { Injectable } from '@angular/core'; +import { MdlSnackbarService } from '@angular-mdl/core'; + +import * as Datastore from 'nedb'; + +import { Observable } from 'rxjs'; + +import { ElectronService } from 'ngx-electron'; + +@Injectable() +export class UpdaterService { + constructor( + private electronService: ElectronService, + private mdlSnackbarService: MdlSnackbarService + ) { + this.setupUpToDateHandler(); + this.setupNewVersionHandler(); + + electronService.ipcRenderer.send("check-update"); + } + + private setupNewVersionHandler(): void { + this.electronService.ipcRenderer.on("update-available", (ev, info) => { + this.mdlSnackbarService.showSnackbar({ + message: `New version avialable: ${info.version}`, + + }); + }); + } + + private setupUpToDateHandler(): void { + this.electronService.ipcRenderer.on("up-to-date", (event) => { + this.mdlSnackbarService.showToast('Hooray, you\'re using the latest version!'); + }); + } +} \ No newline at end of file diff --git a/client/src/index.html b/client/src/index.html index 986a44d..56106b2 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -10,5 +10,6 @@ Loading... + diff --git a/electron/updater.js b/electron/updater.js index 5f69f2e..a1d3fc1 100644 --- a/electron/updater.js +++ b/electron/updater.js @@ -1,21 +1,17 @@ const { autoUpdater } = require("electron-updater"); -const { dialog } = require('electron'); +const { dialog, BrowserWindow, ipcMain } = require('electron'); autoUpdater.autoDownload = false; + /** * Autoupdater events */ -autoUpdater.on('update-available', () => { - dialog.showMessageBox({ - type: 'info', - title: 'Found Updates', - message: 'Found updates, do you want update now?', - buttons: ['Yes', 'No'] - }, (buttonIndex) => { - if (buttonIndex === 0) { - autoUpdater.downloadUpdate() - } - }) +autoUpdater.on('update-available', (info) => { + notify("update-available", info); +}); + +autoUpdater.on('update-not-available', () => { + notify("up-to-date"); }); autoUpdater.on('update-downloaded', (event, info) => { @@ -27,16 +23,28 @@ autoUpdater.on('update-downloaded', (event, info) => { }); }); -/* -autoUpdater.on('update-not-available', () => { - dialog.showMessageBox({ - title: 'No Updates', - message: 'Current version is up-to-date.' - }) -})*/ + autoUpdater.on('error', (event, error) => { dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString()) }) -autoUpdater.checkForUpdates(); \ No newline at end of file + +/** + * IPC events + */ +ipcMain.on("check-update", () => { + autoUpdater.checkForUpdates(); + + notify("check-update-started"); +}); + +ipcMain.on('download-update', () => { + autoUpdater.downloadUpdate(); +}); + +function notify(title, message) { + let windows = BrowserWindow.getAllWindows(); + + windows[0].webContents.send(title, message); +} \ No newline at end of file From ee7d90a6ceb748069306744780b544e6689d2bf8 Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Thu, 25 May 2017 23:49:21 +0200 Subject: [PATCH 2/8] Attempt to get value in dialog --- client/src/app/app.module.ts | 5 ++++- client/src/app/dialog.component.html | 11 +++++++++++ client/src/app/dialog.component.ts | 13 +++++++++++++ client/src/app/updater.service.ts | 25 +++++++++++++++++++++++-- 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 client/src/app/dialog.component.html create mode 100644 client/src/app/dialog.component.ts diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 501f5ab..8cb9383 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -19,11 +19,14 @@ import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { NgxElectronModule } from 'ngx-electron'; +import { DialogComponent } from './dialog.component'; + @NgModule({ declarations: [ AppComponent, HomeComponent, - MenuItemComponent + MenuItemComponent, + DialogComponent ], imports: [ NgxElectronModule, diff --git a/client/src/app/dialog.component.html b/client/src/app/dialog.component.html new file mode 100644 index 0000000..c526655 --- /dev/null +++ b/client/src/app/dialog.component.html @@ -0,0 +1,11 @@ +
+

App Login

+
+ +
+ +
+
+ +
+
diff --git a/client/src/app/dialog.component.ts b/client/src/app/dialog.component.ts new file mode 100644 index 0000000..238c7b8 --- /dev/null +++ b/client/src/app/dialog.component.ts @@ -0,0 +1,13 @@ +import { Component, Inject } from '@angular/core'; + +import { NOTES } from './updater.service'; + +@Component({ + selector: 'dialog-component', + templateUrl: './dialog.component.html' +}) +export class DialogComponent { + constructor(@Inject(NOTES) notes: string) { + console.log(notes); + } +} \ No newline at end of file diff --git a/client/src/app/updater.service.ts b/client/src/app/updater.service.ts index 94c7bd5..264fc7b 100644 --- a/client/src/app/updater.service.ts +++ b/client/src/app/updater.service.ts @@ -1,22 +1,43 @@ import { Injectable } from '@angular/core'; -import { MdlSnackbarService } from '@angular-mdl/core'; +import { MdlSnackbarService, MdlDialogService } from '@angular-mdl/core'; + +import { InjectionToken } from '@angular/core'; + +export let NOTES = new InjectionToken("NOTE"); import * as Datastore from 'nedb'; import { Observable } from 'rxjs'; import { ElectronService } from 'ngx-electron'; +import { DialogComponent } from './dialog.component'; @Injectable() export class UpdaterService { constructor( private electronService: ElectronService, - private mdlSnackbarService: MdlSnackbarService + private mdlSnackbarService: MdlSnackbarService, + private mdlDialogService: MdlDialogService ) { this.setupUpToDateHandler(); this.setupNewVersionHandler(); electronService.ipcRenderer.send("check-update"); + + this.mdlDialogService.showCustomDialog({ + component: DialogComponent, + providers: [ + { + provide: NOTES, + useValue: 'Note' + } + ], + isModal: true, + styles: {'width': '350px'}, + clickOutsideToClose: true, + enterTransitionDuration: 400, + leaveTransitionDuration: 400 + }) } private setupNewVersionHandler(): void { From 469e718fe50a888e6ea5336b7b09e50466ab7b33 Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Thu, 25 May 2017 23:59:28 +0200 Subject: [PATCH 3/8] Attempted to get dialog up and running --- client/src/app/app.module.ts | 5 ++++- client/src/app/dialog.component.html | 6 ++---- client/src/app/dialog.component.ts | 2 +- client/src/app/notes.class.ts | 3 +++ client/src/app/updater.service.ts | 6 ++---- 5 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 client/src/app/notes.class.ts diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 8cb9383..d091765 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -42,6 +42,9 @@ import { DialogComponent } from './dialog.component'; CardService, CollectionService ], - bootstrap: [AppComponent] + bootstrap: [AppComponent], + entryComponents: [ + DialogComponent + ] }) export class AppModule { } diff --git a/client/src/app/dialog.component.html b/client/src/app/dialog.component.html index c526655..10dcf2d 100644 --- a/client/src/app/dialog.component.html +++ b/client/src/app/dialog.component.html @@ -1,11 +1,9 @@

App Login

- -
- + Content
- + Button
diff --git a/client/src/app/dialog.component.ts b/client/src/app/dialog.component.ts index 238c7b8..a568d3e 100644 --- a/client/src/app/dialog.component.ts +++ b/client/src/app/dialog.component.ts @@ -1,6 +1,6 @@ import { Component, Inject } from '@angular/core'; -import { NOTES } from './updater.service'; +import { NOTES } from './notes.class'; @Component({ selector: 'dialog-component', diff --git a/client/src/app/notes.class.ts b/client/src/app/notes.class.ts new file mode 100644 index 0000000..9f54b78 --- /dev/null +++ b/client/src/app/notes.class.ts @@ -0,0 +1,3 @@ +import { InjectionToken } from '@angular/core'; + +export let NOTES = new InjectionToken('release.notes'); \ No newline at end of file diff --git a/client/src/app/updater.service.ts b/client/src/app/updater.service.ts index 264fc7b..ce6395f 100644 --- a/client/src/app/updater.service.ts +++ b/client/src/app/updater.service.ts @@ -1,10 +1,6 @@ import { Injectable } from '@angular/core'; import { MdlSnackbarService, MdlDialogService } from '@angular-mdl/core'; -import { InjectionToken } from '@angular/core'; - -export let NOTES = new InjectionToken("NOTE"); - import * as Datastore from 'nedb'; import { Observable } from 'rxjs'; @@ -12,6 +8,8 @@ import { Observable } from 'rxjs'; import { ElectronService } from 'ngx-electron'; import { DialogComponent } from './dialog.component'; +import { NOTES } from './notes.class'; + @Injectable() export class UpdaterService { constructor( From e83bd07b31d02a8d37e8bb5cc5fd6afacae0b440 Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Fri, 26 May 2017 18:03:07 +0200 Subject: [PATCH 4/8] Use ngZone to trigger dialog correctly --- client/package.json | 14 ++-- client/src/app/app.module.ts | 2 +- client/src/app/dialog.component.html | 9 --- client/src/app/dialog.component.ts | 13 ---- client/src/app/dialog/dialog.component.css | 3 + client/src/app/dialog/dialog.component.html | 12 ++++ client/src/app/dialog/dialog.component.ts | 28 ++++++++ .../src/app/models/update-info.interface.ts | 4 ++ client/src/app/models/update-info.token.ts | 4 ++ client/src/app/notes.class.ts | 3 - client/src/app/updater.service.ts | 65 +++++++++++-------- package.json | 5 +- 12 files changed, 100 insertions(+), 62 deletions(-) delete mode 100644 client/src/app/dialog.component.html delete mode 100644 client/src/app/dialog.component.ts create mode 100644 client/src/app/dialog/dialog.component.css create mode 100644 client/src/app/dialog/dialog.component.html create mode 100644 client/src/app/dialog/dialog.component.ts create mode 100644 client/src/app/models/update-info.interface.ts create mode 100644 client/src/app/models/update-info.token.ts delete mode 100644 client/src/app/notes.class.ts diff --git a/client/package.json b/client/package.json index 651ffe1..85806ec 100644 --- a/client/package.json +++ b/client/package.json @@ -12,7 +12,7 @@ }, "private": true, "dependencies": { - "@angular-mdl/core": "^4.0.3", + "@angular-mdl/core": "^4.0.5", "@angular/animations": "^4.1.3", "@angular/common": "^4.1.3", "@angular/compiler": "^4.1.3", @@ -22,22 +22,22 @@ "@angular/platform-browser": "^4.1.3", "@angular/platform-browser-dynamic": "^4.1.3", "@angular/router": "^4.1.3", - "@swimlane/ngx-datatable": "^9.1.0", + "@swimlane/ngx-datatable": "^9.2.0", "core-js": "^2.4.1", "nedb": "^1.8.0", "ngx-electron": "0.0.11", "rxjs": "^5.4.0", - "typescript": "^2.3.2", - "zone.js": "^0.8.10" + "typescript": "^2.3.3", + "zone.js": "^0.8.11" }, "devDependencies": { - "@angular/cli": "^1.0.3", + "@angular/cli": "^1.0.6", "@angular/compiler-cli": "^4.1.3", "@types/nedb": "^1.8.3", - "@types/node": "~7.0.18", + "@types/node": "~7.0.22", "codelyzer": "~3.0.1", "concurrently": "^3.4.0", "ts-node": "~3.0.4", - "tslint": "~5.2.0" + "tslint": "~5.3.2" } } diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index d091765..19e859e 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -19,7 +19,7 @@ import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { NgxElectronModule } from 'ngx-electron'; -import { DialogComponent } from './dialog.component'; +import { DialogComponent } from './dialog/dialog.component'; @NgModule({ declarations: [ diff --git a/client/src/app/dialog.component.html b/client/src/app/dialog.component.html deleted file mode 100644 index 10dcf2d..0000000 --- a/client/src/app/dialog.component.html +++ /dev/null @@ -1,9 +0,0 @@ -
-

App Login

-
- Content -
-
- Button -
-
diff --git a/client/src/app/dialog.component.ts b/client/src/app/dialog.component.ts deleted file mode 100644 index a568d3e..0000000 --- a/client/src/app/dialog.component.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Component, Inject } from '@angular/core'; - -import { NOTES } from './notes.class'; - -@Component({ - selector: 'dialog-component', - templateUrl: './dialog.component.html' -}) -export class DialogComponent { - constructor(@Inject(NOTES) notes: string) { - console.log(notes); - } -} \ No newline at end of file diff --git a/client/src/app/dialog/dialog.component.css b/client/src/app/dialog/dialog.component.css new file mode 100644 index 0000000..bb78556 --- /dev/null +++ b/client/src/app/dialog/dialog.component.css @@ -0,0 +1,3 @@ +h4 { + margin-top: 0; +} \ No newline at end of file diff --git a/client/src/app/dialog/dialog.component.html b/client/src/app/dialog/dialog.component.html new file mode 100644 index 0000000..285b64a --- /dev/null +++ b/client/src/app/dialog/dialog.component.html @@ -0,0 +1,12 @@ +
+

Version {{ updateInfo.version }} is now available

+
+

Release notes:

+

+
+
+ + + +
+
diff --git a/client/src/app/dialog/dialog.component.ts b/client/src/app/dialog/dialog.component.ts new file mode 100644 index 0000000..85cf7cf --- /dev/null +++ b/client/src/app/dialog/dialog.component.ts @@ -0,0 +1,28 @@ +import { Component, Inject } from '@angular/core'; +import { MdlDialogReference } from '@angular-mdl/core'; + +import { UpdateInfo } from '../models/update-info.interface'; +import { UPDATE_INFO } from '../models/update-info.token'; + +@Component({ + selector: 'dialog-component', + templateUrl: './dialog.component.html', + styleUrls: ['./dialog.component.css'] +}) +export class DialogComponent { + public updateInfo: UpdateInfo; + + constructor( + @Inject(UPDATE_INFO) updateInfo: UpdateInfo, + private dialog: MdlDialogReference) { + this.updateInfo = updateInfo; + } + + public dismissUpdate(): void { + this.dialog.hide(false); + } + + public doUpdate(): void { + this.dialog.hide(true); + } +} \ No newline at end of file diff --git a/client/src/app/models/update-info.interface.ts b/client/src/app/models/update-info.interface.ts new file mode 100644 index 0000000..18d1aff --- /dev/null +++ b/client/src/app/models/update-info.interface.ts @@ -0,0 +1,4 @@ +export interface UpdateInfo { + releaseNotes: string; + version: string; +} \ No newline at end of file diff --git a/client/src/app/models/update-info.token.ts b/client/src/app/models/update-info.token.ts new file mode 100644 index 0000000..34c67c6 --- /dev/null +++ b/client/src/app/models/update-info.token.ts @@ -0,0 +1,4 @@ +import { InjectionToken } from '@angular/core'; +import { UpdateInfo } from './update-info.interface'; + +export let UPDATE_INFO = new InjectionToken('release.info'); \ No newline at end of file diff --git a/client/src/app/notes.class.ts b/client/src/app/notes.class.ts deleted file mode 100644 index 9f54b78..0000000 --- a/client/src/app/notes.class.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { InjectionToken } from '@angular/core'; - -export let NOTES = new InjectionToken('release.notes'); \ No newline at end of file diff --git a/client/src/app/updater.service.ts b/client/src/app/updater.service.ts index ce6395f..b4147c9 100644 --- a/client/src/app/updater.service.ts +++ b/client/src/app/updater.service.ts @@ -1,55 +1,66 @@ -import { Injectable } from '@angular/core'; -import { MdlSnackbarService, MdlDialogService } from '@angular-mdl/core'; +import { Injectable, NgZone } from '@angular/core'; +import { MdlSnackbarService, MdlDialogService, MdlDialogReference } from '@angular-mdl/core'; import * as Datastore from 'nedb'; -import { Observable } from 'rxjs'; +import { Subject, Observable } from 'rxjs'; import { ElectronService } from 'ngx-electron'; -import { DialogComponent } from './dialog.component'; +import { DialogComponent } from './dialog/dialog.component'; -import { NOTES } from './notes.class'; +import { UpdateInfo } from './models/update-info.interface'; +import { UPDATE_INFO } from './models/update-info.token'; @Injectable() export class UpdaterService { + private dialogObservable: Subject; + constructor( private electronService: ElectronService, private mdlSnackbarService: MdlSnackbarService, - private mdlDialogService: MdlDialogService + private mdlDialogService: MdlDialogService, + private ngZone: NgZone ) { this.setupUpToDateHandler(); this.setupNewVersionHandler(); electronService.ipcRenderer.send("check-update"); - - this.mdlDialogService.showCustomDialog({ - component: DialogComponent, - providers: [ - { - provide: NOTES, - useValue: 'Note' - } - ], - isModal: true, - styles: {'width': '350px'}, - clickOutsideToClose: true, - enterTransitionDuration: 400, - leaveTransitionDuration: 400 - }) } - private setupNewVersionHandler(): void { - this.electronService.ipcRenderer.on("update-available", (ev, info) => { - this.mdlSnackbarService.showSnackbar({ - message: `New version avialable: ${info.version}`, - + private setupNewVersionHandler(): void { + this.electronService.ipcRenderer.on("update-available", (ev, info: UpdateInfo) => { + this.ngZone.run(() => { + let updaterDialog: Observable = this.mdlDialogService.showCustomDialog({ + component: DialogComponent, + providers: [ + { + provide: UPDATE_INFO, + useValue: info + } + ], + isModal: true, + styles: { 'width': '650px' }, + clickOutsideToClose: false, + enterTransitionDuration: 400, + leaveTransitionDuration: 400 + }); + + updaterDialog.subscribe((dialogRef: MdlDialogReference) => { + dialogRef.onHide().subscribe((data) => { + if (data) { + this.electronService.ipcRenderer.send("download-update"); + } + }); + }); }); }); } private setupUpToDateHandler(): void { this.electronService.ipcRenderer.on("up-to-date", (event) => { - this.mdlSnackbarService.showToast('Hooray, you\'re using the latest version!'); + this.ngZone.run(() => { + this.mdlSnackbarService.showToast('Hooray, you\'re using the latest version!'); + }); }); } } \ No newline at end of file diff --git a/package.json b/package.json index 82302b8..5d0091b 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "start": "concurrently \"electron .\" \"cd client && ng serve\" ", "build": "ng build", "compile": "cd client && ng build --base-href . --prod -op ../build_client", + "test-release": "npm run compile && npm run dist:win", "release": "npm run compile && build --publish onTagOrDraft" }, "repository": { @@ -28,9 +29,9 @@ "js-yaml": "^3.8.4" }, "devDependencies": { - "electron": "^1.6.8", + "electron": "^1.6.10", "concurrently": "^3.4.0", - "electron-builder": "^17.8.0" + "electron-builder": "^18.0.1" }, "build": { "appId": "pokemon.tcg.tracker", From 9c5873aed1b7eef930ce52896df842e00ea73ae0 Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Fri, 26 May 2017 19:14:23 +0200 Subject: [PATCH 5/8] Finished updater --- client/src/app/app.module.ts | 6 ++-- ... => update-available-dialog.component.css} | 0 ...=> update-available-dialog.component.html} | 0 ...s => update-available-dialog.component.ts} | 8 ++--- client/src/app/updater.service.ts | 36 ++++++++++++++++--- electron/updater.js | 19 ++++++---- 6 files changed, 52 insertions(+), 17 deletions(-) rename client/src/app/dialog/{dialog.component.css => update-available-dialog.component.css} (100%) rename client/src/app/dialog/{dialog.component.html => update-available-dialog.component.html} (100%) rename client/src/app/dialog/{dialog.component.ts => update-available-dialog.component.ts} (72%) diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 19e859e..7d8196c 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -19,14 +19,14 @@ import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { NgxElectronModule } from 'ngx-electron'; -import { DialogComponent } from './dialog/dialog.component'; +import { UpdateAvailableDialogComponent } from './dialog/update-available-dialog.component'; @NgModule({ declarations: [ AppComponent, HomeComponent, MenuItemComponent, - DialogComponent + UpdateAvailableDialogComponent ], imports: [ NgxElectronModule, @@ -44,7 +44,7 @@ import { DialogComponent } from './dialog/dialog.component'; ], bootstrap: [AppComponent], entryComponents: [ - DialogComponent + UpdateAvailableDialogComponent ] }) export class AppModule { } diff --git a/client/src/app/dialog/dialog.component.css b/client/src/app/dialog/update-available-dialog.component.css similarity index 100% rename from client/src/app/dialog/dialog.component.css rename to client/src/app/dialog/update-available-dialog.component.css diff --git a/client/src/app/dialog/dialog.component.html b/client/src/app/dialog/update-available-dialog.component.html similarity index 100% rename from client/src/app/dialog/dialog.component.html rename to client/src/app/dialog/update-available-dialog.component.html diff --git a/client/src/app/dialog/dialog.component.ts b/client/src/app/dialog/update-available-dialog.component.ts similarity index 72% rename from client/src/app/dialog/dialog.component.ts rename to client/src/app/dialog/update-available-dialog.component.ts index 85cf7cf..3c05f6d 100644 --- a/client/src/app/dialog/dialog.component.ts +++ b/client/src/app/dialog/update-available-dialog.component.ts @@ -5,11 +5,11 @@ import { UpdateInfo } from '../models/update-info.interface'; import { UPDATE_INFO } from '../models/update-info.token'; @Component({ - selector: 'dialog-component', - templateUrl: './dialog.component.html', - styleUrls: ['./dialog.component.css'] + selector: 'update-available-dialog-component', + templateUrl: './update-available-dialog.component.html', + styleUrls: ['./update-available-dialog.component.css'] }) -export class DialogComponent { +export class UpdateAvailableDialogComponent { public updateInfo: UpdateInfo; constructor( diff --git a/client/src/app/updater.service.ts b/client/src/app/updater.service.ts index b4147c9..89c7357 100644 --- a/client/src/app/updater.service.ts +++ b/client/src/app/updater.service.ts @@ -6,7 +6,7 @@ import * as Datastore from 'nedb'; import { Subject, Observable } from 'rxjs'; import { ElectronService } from 'ngx-electron'; -import { DialogComponent } from './dialog/dialog.component'; +import { UpdateAvailableDialogComponent } from './dialog/update-available-dialog.component'; import { UpdateInfo } from './models/update-info.interface'; import { UPDATE_INFO } from './models/update-info.token'; @@ -23,6 +23,9 @@ export class UpdaterService { ) { this.setupUpToDateHandler(); this.setupNewVersionHandler(); + this.setupDownloadStartedHandler(); + this.setupDownloadFinishedHandler(); + //this.setupDownloadProgressHandler(); electronService.ipcRenderer.send("check-update"); } @@ -30,8 +33,8 @@ export class UpdaterService { private setupNewVersionHandler(): void { this.electronService.ipcRenderer.on("update-available", (ev, info: UpdateInfo) => { this.ngZone.run(() => { - let updaterDialog: Observable = this.mdlDialogService.showCustomDialog({ - component: DialogComponent, + let updateAvailableDialog: Observable = this.mdlDialogService.showCustomDialog({ + component: UpdateAvailableDialogComponent, providers: [ { provide: UPDATE_INFO, @@ -45,7 +48,7 @@ export class UpdaterService { leaveTransitionDuration: 400 }); - updaterDialog.subscribe((dialogRef: MdlDialogReference) => { + updateAvailableDialog.subscribe((dialogRef: MdlDialogReference) => { dialogRef.onHide().subscribe((data) => { if (data) { this.electronService.ipcRenderer.send("download-update"); @@ -63,4 +66,29 @@ export class UpdaterService { }); }); } + + private setupDownloadStartedHandler(): void { + this.electronService.ipcRenderer.on("update-download-started", () => { + this.ngZone.run(() => { + this.mdlSnackbarService.showToast("Started downloading update, please wait"); + }); + }); + } + + private setupDownloadFinishedHandler(): void { + this.electronService.ipcRenderer.on("update-download-finished", () => { + this.ngZone.run(() => { + let updateDownloadedDialog: Observable = this.mdlDialogService.alert("Update downloaded, application will close to install now", "Ok", "Update downloaded"); + updateDownloadedDialog.subscribe(() => { + this.electronService.ipcRenderer.send("install-update"); + }); + }); + }); + } + + private setupDownloadProgressHandler(): void { + this.electronService.ipcRenderer.on("update-download-progress", (event, progress) => { + console.log(progress); + }); + } } \ No newline at end of file diff --git a/electron/updater.js b/electron/updater.js index a1d3fc1..8428f43 100644 --- a/electron/updater.js +++ b/electron/updater.js @@ -14,13 +14,12 @@ autoUpdater.on('update-not-available', () => { notify("up-to-date"); }); +autoUpdater.on("download-progress", (progress) => { + notify("update-download-progress", progress); +}); + autoUpdater.on('update-downloaded', (event, info) => { - dialog.showMessageBox({ - title: 'Update downloaded', - message: 'New version downloaded, installing now' - }, (buttonIndex) => { - autoUpdater.quitAndInstall(); - }); + notify("update-download-finished"); }); @@ -41,6 +40,14 @@ ipcMain.on("check-update", () => { ipcMain.on('download-update', () => { autoUpdater.downloadUpdate(); + + notify("update-download-started"); +}); + +ipcMain.on("install-update", () => { + autoUpdater.quitAndInstall(); + + notify("install-update-starting"); }); function notify(title, message) { From 534c1344f8ee1478842a344264127616a2f9e00f Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Fri, 26 May 2017 20:02:59 +0200 Subject: [PATCH 6/8] Improved text a bit --- client/src/app/updater.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/app/updater.service.ts b/client/src/app/updater.service.ts index 89c7357..2ba2316 100644 --- a/client/src/app/updater.service.ts +++ b/client/src/app/updater.service.ts @@ -30,7 +30,7 @@ export class UpdaterService { electronService.ipcRenderer.send("check-update"); } - private setupNewVersionHandler(): void { + private setupNewVersionHandler(): void { this.electronService.ipcRenderer.on("update-available", (ev, info: UpdateInfo) => { this.ngZone.run(() => { let updateAvailableDialog: Observable = this.mdlDialogService.showCustomDialog({ @@ -63,14 +63,14 @@ export class UpdaterService { this.electronService.ipcRenderer.on("up-to-date", (event) => { this.ngZone.run(() => { this.mdlSnackbarService.showToast('Hooray, you\'re using the latest version!'); - }); + }); }); } private setupDownloadStartedHandler(): void { this.electronService.ipcRenderer.on("update-download-started", () => { this.ngZone.run(() => { - this.mdlSnackbarService.showToast("Started downloading update, please wait"); + this.mdlSnackbarService.showToast("Update downloading, you will be prompted when this is finished"); }); }); } @@ -87,7 +87,7 @@ export class UpdaterService { } private setupDownloadProgressHandler(): void { - this.electronService.ipcRenderer.on("update-download-progress", (event, progress) => { + this.electronService.ipcRenderer.on("update-download-progress", (event, progress) => { console.log(progress); }); } From 83b75530a1140f96ad462d05128df4aec4e7f5f1 Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Fri, 26 May 2017 20:22:57 +0200 Subject: [PATCH 7/8] Ran code through linter --- client/src/app/app.component.ts | 2 +- client/src/app/card.service.ts | 8 ++--- client/src/app/collection.service.ts | 6 ++-- client/src/app/database/card.store.ts | 12 ++++---- client/src/app/database/collection.store.ts | 19 ++++++------ client/src/app/database/set.store.ts | 7 +++-- .../update-available-dialog.component.html | 12 ++++---- .../update-available-dialog.component.ts | 4 +-- client/src/app/home/home.component.html | 30 +++++++++---------- client/src/app/home/home.component.ts | 16 +++++----- .../src/app/menu-item/menu-item.component.css | 4 +-- .../app/menu-item/menu-item.component.html | 10 +++---- .../src/app/menu-item/menu-item.component.ts | 10 +++---- client/src/app/models/card.interface.ts | 2 +- client/src/app/models/collection.interface.ts | 2 +- client/src/app/models/set.interface.ts | 10 +++---- .../src/app/models/update-info.interface.ts | 2 +- client/src/app/models/update-info.token.ts | 2 +- client/src/app/set.service.ts | 20 ++++++------- client/src/app/updater.service.ts | 30 ++++++++++--------- client/src/index.html | 7 ++--- electron/updater.js | 24 +++++++-------- main.js | 2 +- 23 files changed, 123 insertions(+), 118 deletions(-) diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 9b41ede..b716930 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -5,6 +5,6 @@ import { UpdaterService } from './updater.service'; templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) -export class AppComponent { +export class AppComponent { constructor(private updaterService: UpdaterService) { } } diff --git a/client/src/app/card.service.ts b/client/src/app/card.service.ts index c18b245..a6b19e0 100644 --- a/client/src/app/card.service.ts +++ b/client/src/app/card.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; -import { Observable } from 'rxjs'; +import { Observable } from 'rxjs/observable'; import * as Datastore from 'nedb'; import { Card } from './models/card.interface'; @@ -11,14 +11,14 @@ import { CardStore } from './database/card.store'; @Injectable() export class CardService { - private cardStore: CardStore; + private cardStore: CardStore; constructor(private http: Http) { - let db = new Datastore({ filename: 'cards.db', autoload: true }); + const db: Datastore = new Datastore({ filename: 'cards.db', autoload: true }); this.cardStore = new CardStore(db, http); } public get(set: Set): Observable { return this.cardStore.getCards(set); } -} \ No newline at end of file +} diff --git a/client/src/app/collection.service.ts b/client/src/app/collection.service.ts index 23430bb..7626d6f 100644 --- a/client/src/app/collection.service.ts +++ b/client/src/app/collection.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; +import { Observable } from 'rxjs/observable'; import * as Datastore from 'nedb'; import { Collection } from './models/collection.interface'; @@ -13,7 +13,7 @@ export class CollectionService { private collectionStore: CollectionStore; constructor() { - let db = new Datastore({ filename: 'collection.db', autoload: true }); + const db: Datastore = new Datastore({ filename: 'collection.db', autoload: true }); this.collectionStore = new CollectionStore(db); } @@ -28,4 +28,4 @@ export class CollectionService { public countCollected(setCode: string): Observable { return this.collectionStore.countCollectedSet(setCode); } -} \ No newline at end of file +} diff --git a/client/src/app/database/card.store.ts b/client/src/app/database/card.store.ts index bce5825..cb014fa 100644 --- a/client/src/app/database/card.store.ts +++ b/client/src/app/database/card.store.ts @@ -2,9 +2,11 @@ import { Card } from '../models/card.interface'; import { Set } from '../models/set.interface'; import { Http, Response, URLSearchParams } from '@angular/http'; -import { Observable, Subject } from 'rxjs'; +import { Observable } from 'rxjs/Observable'; +import { Subject } from 'rxjs/Subject'; import * as Datastore from 'nedb'; + /** * Performs CRUD on the NEDB data store that is passed to it in the constructor. */ @@ -20,8 +22,8 @@ export class CardStore { */ public getCards(set: Set): Observable { this.db.find({ setCode: set.code }).exec((err, dbcards) => { - if (dbcards.length === 0 || dbcards.length != set.totalCards) { - let params = new URLSearchParams(); + if (dbcards.length === 0 || dbcards.length !== set.totalCards) { + const params: URLSearchParams = new URLSearchParams(); params.append('setCode', set.code); params.append('pageSize', String(set.totalCards)); this.http.get('https://api.pokemontcg.io/v1/cards', { search: params }) @@ -34,7 +36,7 @@ export class CardStore { this.cardListSubject.next(dbcards); } }); - + return this.cardListSubject; } -} \ No newline at end of file +} diff --git a/client/src/app/database/collection.store.ts b/client/src/app/database/collection.store.ts index 1c0ec5a..2294c91 100644 --- a/client/src/app/database/collection.store.ts +++ b/client/src/app/database/collection.store.ts @@ -1,8 +1,8 @@ -import { Observable } from 'rxjs'; - import { Collection } from '../models/collection.interface'; -import { Subject, BehaviorSubject } from 'rxjs'; +import { Observable } from 'rxjs/Observable'; +import { Subject } from 'rxjs/subject'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import * as Datastore from 'nedb'; @@ -10,7 +10,7 @@ import * as Datastore from 'nedb'; * Performs CRUD on the NEDB data store that is passed to it in the constructor. */ export class CollectionStore { - private countCollectedSubject: codeToObservable = {}; + private countCollectedSubject: CodeToObservable = {}; constructor( private db: Datastore) { } @@ -24,7 +24,7 @@ export class CollectionStore { } public getCollection(setCode): Observable { - let collectionSubject = new Subject(); + const collectionSubject: Subject = new Subject(); this.db.find({ setCode: setCode }).exec((err, collection) => { collectionSubject.next(collection); @@ -34,9 +34,10 @@ export class CollectionStore { } public collectCard(card): Observable { - let cardCollectedSubject = new Subject(); + const cardCollectedSubject: Subject = new Subject(); + this.db.insert(new Collection(card.id, card.setCode), (err, collection) => { - cardCollectedSubject.next(Collection); + cardCollectedSubject.next(collection); this.countSetCollection(card.setCode); }); @@ -51,6 +52,6 @@ export class CollectionStore { } } -interface codeToObservable { +interface CodeToObservable { [setCode: string]: BehaviorSubject; -} \ No newline at end of file +} diff --git a/client/src/app/database/set.store.ts b/client/src/app/database/set.store.ts index 13ad4c6..bef72f2 100644 --- a/client/src/app/database/set.store.ts +++ b/client/src/app/database/set.store.ts @@ -1,7 +1,8 @@ import { Set } from '../models/set.interface'; import { Http, Response } from '@angular/http'; -import { Observable, Subject } from 'rxjs'; +import { Observable } from 'rxjs/Observable'; +import { Subject } from 'rxjs/Subject'; import * as Datastore from 'nedb'; /** @@ -30,7 +31,7 @@ export class SetStore { this.setListSubject.next(dbsets); } }); - + return this.setListSubject; } -} \ No newline at end of file +} diff --git a/client/src/app/dialog/update-available-dialog.component.html b/client/src/app/dialog/update-available-dialog.component.html index 285b64a..84b67ce 100644 --- a/client/src/app/dialog/update-available-dialog.component.html +++ b/client/src/app/dialog/update-available-dialog.component.html @@ -1,12 +1,12 @@
-

Version {{ updateInfo.version }} is now available

-
+

Version {{ updateInfo.version }} is now available

+

Release notes:

-

+

-
- +
+ - +
diff --git a/client/src/app/dialog/update-available-dialog.component.ts b/client/src/app/dialog/update-available-dialog.component.ts index 3c05f6d..65db395 100644 --- a/client/src/app/dialog/update-available-dialog.component.ts +++ b/client/src/app/dialog/update-available-dialog.component.ts @@ -5,7 +5,7 @@ import { UpdateInfo } from '../models/update-info.interface'; import { UPDATE_INFO } from '../models/update-info.token'; @Component({ - selector: 'update-available-dialog-component', + selector: 'pokemon-update-available-dialog-component', templateUrl: './update-available-dialog.component.html', styleUrls: ['./update-available-dialog.component.css'] }) @@ -25,4 +25,4 @@ export class UpdateAvailableDialogComponent { public doUpdate(): void { this.dialog.hide(true); } -} \ No newline at end of file +} diff --git a/client/src/app/home/home.component.html b/client/src/app/home/home.component.html index 94ab27a..4082f2d 100644 --- a/client/src/app/home/home.component.html +++ b/client/src/app/home/home.component.html @@ -8,30 +8,30 @@ Sets - - + + class='material' + [columnMode]=''force'' + [rowHeight]=''auto'' + [rows]='cards' + [columns]='columns' + [rowClass]='getRowClass' + [messages]='{ emptyMessage: 'No set selected' }'> - - -
{{ value | date : 'mediumDate' }}
+
{{ value | date : 'mediumDate' }}
diff --git a/client/src/app/home/home.component.ts b/client/src/app/home/home.component.ts index 402ee1f..03958f1 100644 --- a/client/src/app/home/home.component.ts +++ b/client/src/app/home/home.component.ts @@ -6,7 +6,7 @@ import { SetService } from '../set.service'; import { CardService } from '../card.service'; import { CollectionService } from '../collection.service'; -import { Observable } from 'rxjs'; +import { Observable } from 'rxjs/observable'; import { Set } from '../models/set.interface'; import { Card } from '../models/card.interface'; import { Collection } from '../models/collection.interface'; @@ -51,8 +51,8 @@ export class HomeComponent implements OnInit { } dateComparator(dateA: Date, dateB: Date) { - if (dateB < dateA) return 1; - else if (dateB > dateA) return -1; + if (dateB < dateA) { return 1; } + if (dateB > dateA) { return -1; } return 0; } @@ -60,8 +60,8 @@ export class HomeComponent implements OnInit { this.sets = this.setService.getSetList() .map((sets: Set[]) => { return sets.sort((a: Set, b: Set) => { - if (new Date(b.releaseDate) < new Date(a.releaseDate)) return 1; - else if (new Date(b.releaseDate) > new Date(a.releaseDate)) return -1; + if (new Date(b.releaseDate) < new Date(a.releaseDate)) { return 1; } + if (new Date(b.releaseDate) > new Date(a.releaseDate)) { return -1; } return 0; }); }); @@ -96,12 +96,12 @@ export class HomeComponent implements OnInit { .subscribe(([cards, collection]) => { this.cards = cards; collection.forEach(collectedEntry => { - var foundCard = cards.find(function (card) { - return card.id == collectedEntry.card; + const foundCard: Card = cards.find(function (card) { + return card.id === collectedEntry.card; }); foundCard.collected = collectedEntry.collected; }); }); } -} \ No newline at end of file +} diff --git a/client/src/app/menu-item/menu-item.component.css b/client/src/app/menu-item/menu-item.component.css index 328d455..d74b40f 100644 --- a/client/src/app/menu-item/menu-item.component.css +++ b/client/src/app/menu-item/menu-item.component.css @@ -1,7 +1,7 @@ .set.active { - background-color: lightgray; + background-color: lightgray; } .set:hover { - background-color: lightslategray; + background-color: lightslategray; } \ No newline at end of file diff --git a/client/src/app/menu-item/menu-item.component.html b/client/src/app/menu-item/menu-item.component.html index 1b137bd..df8a9a5 100644 --- a/client/src/app/menu-item/menu-item.component.html +++ b/client/src/app/menu-item/menu-item.component.html @@ -1,7 +1,7 @@ - - {{ set.name }} - {{ set.releaseDate }} - - {{ count / set.totalCards | percent:'1.0-2' }} + + {{ set.name }} + {{ set.releaseDate }} + + {{ count / set.totalCards | percent:'1.0-2' }} \ No newline at end of file diff --git a/client/src/app/menu-item/menu-item.component.ts b/client/src/app/menu-item/menu-item.component.ts index 284cd10..f38ace3 100644 --- a/client/src/app/menu-item/menu-item.component.ts +++ b/client/src/app/menu-item/menu-item.component.ts @@ -14,18 +14,18 @@ export class MenuItemComponent implements AfterViewInit { @Input() selectedSet: string; @Output() selectSet = new EventEmitter(); - public count: number = 0; + public count = 0; constructor(private collectionService: CollectionService) { } ngAfterViewInit(): void { - this.collectionService.countCollected(this.set.code) + this.collectionService.countCollected(this.set.code) .subscribe(count => { - this.count = count; - }); + this.count = count; + }); } select() { this.selectSet.emit(this.set); } -} \ No newline at end of file +} diff --git a/client/src/app/models/card.interface.ts b/client/src/app/models/card.interface.ts index d3d8aee..67781d1 100644 --- a/client/src/app/models/card.interface.ts +++ b/client/src/app/models/card.interface.ts @@ -6,4 +6,4 @@ export interface Card { series: string; setCode: string; collected: Date; -} \ No newline at end of file +} diff --git a/client/src/app/models/collection.interface.ts b/client/src/app/models/collection.interface.ts index 1b8ae47..6363cd1 100644 --- a/client/src/app/models/collection.interface.ts +++ b/client/src/app/models/collection.interface.ts @@ -8,4 +8,4 @@ export class Collection { this.setCode = set; this.collected = new Date(); } -} \ No newline at end of file +} diff --git a/client/src/app/models/set.interface.ts b/client/src/app/models/set.interface.ts index cf8fda7..765cb16 100644 --- a/client/src/app/models/set.interface.ts +++ b/client/src/app/models/set.interface.ts @@ -1,8 +1,8 @@ export interface Set { - name: string; - series: string; - totalCards: number; - code: string; + name: string; + series: string; + totalCards: number; + code: string; releaseDate: string; collectedCount: number; -} \ No newline at end of file +} diff --git a/client/src/app/models/update-info.interface.ts b/client/src/app/models/update-info.interface.ts index 18d1aff..e7ed9ce 100644 --- a/client/src/app/models/update-info.interface.ts +++ b/client/src/app/models/update-info.interface.ts @@ -1,4 +1,4 @@ export interface UpdateInfo { releaseNotes: string; version: string; -} \ No newline at end of file +} diff --git a/client/src/app/models/update-info.token.ts b/client/src/app/models/update-info.token.ts index 34c67c6..0ebc6ed 100644 --- a/client/src/app/models/update-info.token.ts +++ b/client/src/app/models/update-info.token.ts @@ -1,4 +1,4 @@ import { InjectionToken } from '@angular/core'; import { UpdateInfo } from './update-info.interface'; -export let UPDATE_INFO = new InjectionToken('release.info'); \ No newline at end of file +export let UPDATE_INFO = new InjectionToken('release.info'); diff --git a/client/src/app/set.service.ts b/client/src/app/set.service.ts index 116335a..6da7458 100644 --- a/client/src/app/set.service.ts +++ b/client/src/app/set.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; -import { Observable } from 'rxjs'; +import { Observable } from 'rxjs/Observable'; import * as Datastore from 'nedb'; import { Set } from './models/set.interface'; @@ -10,14 +10,14 @@ import { SetStore } from './database/set.store'; @Injectable() export class SetService { - private setStore: SetStore; + private setStore: SetStore; - constructor(private http: Http) { - let db = new Datastore({ filename: 'sets.db', autoload: true }); - this.setStore = new SetStore(db, http); - } + constructor(private http: Http) { + const db: Datastore = new Datastore({ filename: 'sets.db', autoload: true }); + this.setStore = new SetStore(db, http); + } - public getSetList(): Observable { - return this.setStore.getSets(); - } -} \ No newline at end of file + public getSetList(): Observable { + return this.setStore.getSets(); + } +} diff --git a/client/src/app/updater.service.ts b/client/src/app/updater.service.ts index 2ba2316..e77da12 100644 --- a/client/src/app/updater.service.ts +++ b/client/src/app/updater.service.ts @@ -3,7 +3,8 @@ import { MdlSnackbarService, MdlDialogService, MdlDialogReference } from '@angul import * as Datastore from 'nedb'; -import { Subject, Observable } from 'rxjs'; +import { Observable } from 'rxjs/Observable'; +import { Subject } from 'rxjs/Subject'; import { ElectronService } from 'ngx-electron'; import { UpdateAvailableDialogComponent } from './dialog/update-available-dialog.component'; @@ -25,15 +26,15 @@ export class UpdaterService { this.setupNewVersionHandler(); this.setupDownloadStartedHandler(); this.setupDownloadFinishedHandler(); - //this.setupDownloadProgressHandler(); + // this.setupDownloadProgressHandler(); - electronService.ipcRenderer.send("check-update"); + electronService.ipcRenderer.send('check-update'); } private setupNewVersionHandler(): void { - this.electronService.ipcRenderer.on("update-available", (ev, info: UpdateInfo) => { + this.electronService.ipcRenderer.on('update-available', (ev, info: UpdateInfo) => { this.ngZone.run(() => { - let updateAvailableDialog: Observable = this.mdlDialogService.showCustomDialog({ + const updateAvailableDialog: Observable = this.mdlDialogService.showCustomDialog({ component: UpdateAvailableDialogComponent, providers: [ { @@ -51,7 +52,7 @@ export class UpdaterService { updateAvailableDialog.subscribe((dialogRef: MdlDialogReference) => { dialogRef.onHide().subscribe((data) => { if (data) { - this.electronService.ipcRenderer.send("download-update"); + this.electronService.ipcRenderer.send('download-update'); } }); }); @@ -60,7 +61,7 @@ export class UpdaterService { } private setupUpToDateHandler(): void { - this.electronService.ipcRenderer.on("up-to-date", (event) => { + this.electronService.ipcRenderer.on('up-to-date', (event) => { this.ngZone.run(() => { this.mdlSnackbarService.showToast('Hooray, you\'re using the latest version!'); }); @@ -68,27 +69,28 @@ export class UpdaterService { } private setupDownloadStartedHandler(): void { - this.electronService.ipcRenderer.on("update-download-started", () => { + this.electronService.ipcRenderer.on('update-download-started', () => { this.ngZone.run(() => { - this.mdlSnackbarService.showToast("Update downloading, you will be prompted when this is finished"); + this.mdlSnackbarService.showToast('Update downloading, you will be prompted when this is finished'); }); }); } private setupDownloadFinishedHandler(): void { - this.electronService.ipcRenderer.on("update-download-finished", () => { + this.electronService.ipcRenderer.on('update-download-finished', () => { this.ngZone.run(() => { - let updateDownloadedDialog: Observable = this.mdlDialogService.alert("Update downloaded, application will close to install now", "Ok", "Update downloaded"); + const updateDownloadedDialog: Observable = + this.mdlDialogService.alert('Update downloaded, application will close to install now', 'Ok', 'Update downloaded'); updateDownloadedDialog.subscribe(() => { - this.electronService.ipcRenderer.send("install-update"); + this.electronService.ipcRenderer.send('install-update'); }); }); }); } private setupDownloadProgressHandler(): void { - this.electronService.ipcRenderer.on("update-download-progress", (event, progress) => { + this.electronService.ipcRenderer.on('update-download-progress', (event, progress) => { console.log(progress); }); } -} \ No newline at end of file +} diff --git a/client/src/index.html b/client/src/index.html index 56106b2..1368dd0 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -1,12 +1,11 @@ - + Pokemon TCG Tracker - + - - + Loading... diff --git a/electron/updater.js b/electron/updater.js index 8428f43..ee7b2c8 100644 --- a/electron/updater.js +++ b/electron/updater.js @@ -1,4 +1,4 @@ -const { autoUpdater } = require("electron-updater"); +const { autoUpdater } = require('electron-updater'); const { dialog, BrowserWindow, ipcMain } = require('electron'); autoUpdater.autoDownload = false; @@ -7,47 +7,47 @@ autoUpdater.autoDownload = false; * Autoupdater events */ autoUpdater.on('update-available', (info) => { - notify("update-available", info); + notify('update-available', info); }); autoUpdater.on('update-not-available', () => { - notify("up-to-date"); + notify('up-to-date'); }); -autoUpdater.on("download-progress", (progress) => { - notify("update-download-progress", progress); +autoUpdater.on('download-progress', (progress) => { + notify('update-download-progress', progress); }); autoUpdater.on('update-downloaded', (event, info) => { - notify("update-download-finished"); + notify('update-download-finished'); }); autoUpdater.on('error', (event, error) => { - dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString()) + dialog.showErrorBox('Error: ', error == null ? 'unknown' : (error.stack || error).toString()) }) /** * IPC events */ -ipcMain.on("check-update", () => { +ipcMain.on('check-update', () => { autoUpdater.checkForUpdates(); - notify("check-update-started"); + notify('check-update-started'); }); ipcMain.on('download-update', () => { autoUpdater.downloadUpdate(); - notify("update-download-started"); + notify('update-download-started'); }); -ipcMain.on("install-update", () => { +ipcMain.on('install-update', () => { autoUpdater.quitAndInstall(); - notify("install-update-starting"); + notify('install-update-starting'); }); function notify(title, message) { diff --git a/main.js b/main.js index 8686f47..3832dbb 100644 --- a/main.js +++ b/main.js @@ -14,7 +14,7 @@ function createWindow () { // Make sure content is always shown on big screen, never collapsed together // Windows adds the scrollbar inside of the window - width = (process.platform === "darwin" ? 1025 : 1041); + width = (process.platform === 'darwin' ? 1025 : 1041); mainWindow = new BrowserWindow({ width: width, minWidth: width, From 5addd9f208af9a5dbda37bff4e317012e21b3e1b Mon Sep 17 00:00:00 2001 From: Tom Matheussen Date: Fri, 26 May 2017 20:42:20 +0200 Subject: [PATCH 8/8] Minor fixes --- client/src/app/database/collection.store.ts | 2 +- client/src/app/home/home.component.html | 8 ++++---- client/src/app/home/home.component.ts | 4 +++- client/src/index.html | 2 +- electron/updater.js | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client/src/app/database/collection.store.ts b/client/src/app/database/collection.store.ts index 2294c91..cb9db9b 100644 --- a/client/src/app/database/collection.store.ts +++ b/client/src/app/database/collection.store.ts @@ -1,7 +1,7 @@ import { Collection } from '../models/collection.interface'; import { Observable } from 'rxjs/Observable'; -import { Subject } from 'rxjs/subject'; +import { Subject } from 'rxjs/Subject'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import * as Datastore from 'nedb'; diff --git a/client/src/app/home/home.component.html b/client/src/app/home/home.component.html index 4082f2d..19a6a25 100644 --- a/client/src/app/home/home.component.html +++ b/client/src/app/home/home.component.html @@ -19,12 +19,12 @@ + [messages]='{ emptyMessage: "No set selected" }'> @@ -33,5 +33,5 @@ -
{{ value | date : 'mediumDate' }}
+
{{ value | date : 'mediumDate' }}
diff --git a/client/src/app/home/home.component.ts b/client/src/app/home/home.component.ts index 03958f1..ca78f37 100644 --- a/client/src/app/home/home.component.ts +++ b/client/src/app/home/home.component.ts @@ -6,7 +6,9 @@ import { SetService } from '../set.service'; import { CardService } from '../card.service'; import { CollectionService } from '../collection.service'; -import { Observable } from 'rxjs/observable'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/observable/zip'; import { Set } from '../models/set.interface'; import { Card } from '../models/card.interface'; import { Collection } from '../models/collection.interface'; diff --git a/client/src/index.html b/client/src/index.html index 1368dd0..d9d15af 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -3,7 +3,7 @@ Pokemon TCG Tracker - + diff --git a/electron/updater.js b/electron/updater.js index ee7b2c8..c917b51 100644 --- a/electron/updater.js +++ b/electron/updater.js @@ -45,9 +45,9 @@ ipcMain.on('download-update', () => { }); ipcMain.on('install-update', () => { - autoUpdater.quitAndInstall(); - notify('install-update-starting'); + + autoUpdater.quitAndInstall(); }); function notify(title, message) {