This repository has been archived by the owner on Jan 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
6387e00
commit 8aacc7b
Showing
13 changed files
with
223 additions
and
6 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
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
10 changes: 10 additions & 0 deletions
10
app/frontend/src/app/settings/settings-page/settings-page.component.html
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,10 @@ | ||
<div class="text-white flex flex-col"> | ||
<div class="p-2"> | ||
<h3 class="text-xl">Updates</h3> | ||
</div> | ||
<div class="p-2 flex flex-col"> | ||
<h3 class="text-xl">About</h3> | ||
<p>Version 0.1.0</p> | ||
<p>License MIT</p> | ||
</div> | ||
</div> |
Empty file.
15 changes: 15 additions & 0 deletions
15
app/frontend/src/app/settings/settings-page/settings-page.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,15 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-settings-page', | ||
templateUrl: './settings-page.component.html', | ||
styleUrls: ['./settings-page.component.scss'] | ||
}) | ||
export class SettingsPageComponent implements OnInit { | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
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,17 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { SettingsPageComponent } from './settings-page/settings-page.component'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { WorkspaceModule } from '../workspace/workspace.module'; | ||
|
||
@NgModule({ | ||
declarations: [SettingsPageComponent], | ||
exports: [SettingsPageComponent], | ||
entryComponents: [SettingsPageComponent], | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
WorkspaceModule | ||
] | ||
}) | ||
export class SettingsModule { } |
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,10 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
@NgModule({ | ||
declarations: [], | ||
imports: [ | ||
CommonModule | ||
] | ||
}) | ||
export class UpdaterModule { } |
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,66 @@ | ||
import { Injectable, EventEmitter } from '@angular/core'; | ||
import { Observable, BehaviorSubject } from 'rxjs'; | ||
import { CalledOnce } from '../helpers/called-once.decorator'; | ||
import { ElectronService } from '../messaging/electron.service'; | ||
import { UpdaterEvent, UpdaterCommand } from '../../../../updater/messages'; | ||
|
||
@Injectable() | ||
export class UpdaterService { | ||
|
||
updateVersion: Observable<string> = new Observable<string>(); | ||
updaterStatus: Observable<UpdaterStatus> = new Observable<UpdaterStatus>(); | ||
updateDownloadProgress: EventEmitter<number> = new EventEmitter<number>(); | ||
|
||
private statusSubject: BehaviorSubject<UpdaterStatus> = new BehaviorSubject<UpdaterStatus>(UpdaterStatus.NoUpdateAvailable); | ||
private versionSubject: BehaviorSubject<string> = new BehaviorSubject<string>(''); | ||
constructor( | ||
private electron: ElectronService, | ||
) { | ||
this.updaterStatus = this.statusSubject.asObservable(); | ||
this.updateVersion = this.versionSubject.asObservable(); | ||
} | ||
@CalledOnce | ||
init() { | ||
this.electron.Receive('UpdaterEvent', (evt: UpdaterEvent) => { | ||
if (evt.Event === 'update-available' && | ||
(this.statusSubject.getValue() === UpdaterStatus.NoUpdateAvailable || this.statusSubject.getValue() === UpdaterStatus.CheckingUpdate)) { | ||
this.versionSubject.next(evt.Arg.version); | ||
this.statusSubject.next(UpdaterStatus.UpdateAvailable); | ||
} else if (evt.Event === 'update-not-available') { | ||
this.statusSubject.next(UpdaterStatus.NoUpdateAvailable); | ||
} else if (evt.Event === 'downloading-update') { | ||
if (this.statusSubject.getValue() !== UpdaterStatus.DownloadingUpdate) { | ||
this.statusSubject.next(UpdaterStatus.DownloadingUpdate); | ||
} | ||
this.updateDownloadProgress.emit(Math.floor(evt.Arg.percentage)); | ||
} else if (evt.Event === 'download-complete') { | ||
this.statusSubject.next(UpdaterStatus.InstallingUpdate); | ||
let that = this; | ||
setTimeout(() => { | ||
that.electron.Send(new UpdaterCommand('commence-install-update')); | ||
}, 7 * 1000); | ||
} else if (evt.Event === 'checking') { | ||
if (evt.Arg.inProgress) { | ||
this.statusSubject.next(UpdaterStatus.CheckingUpdate); | ||
} | ||
} | ||
}); | ||
} | ||
checkUpdate() { | ||
this.electron.Send(new UpdaterCommand('check-for-update')); | ||
} | ||
installUpdate() { | ||
this.statusSubject.next(UpdaterStatus.DownloadingUpdate); | ||
this.electron.Send(new UpdaterCommand('commence-download')); | ||
} | ||
|
||
} | ||
|
||
|
||
export enum UpdaterStatus { | ||
NoUpdateAvailable, | ||
CheckingUpdate, | ||
UpdateAvailable, | ||
DownloadingUpdate, | ||
InstallingUpdate, | ||
} |
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,21 @@ | ||
import { IMessage } from "../messaging/i-message"; | ||
|
||
// tslint:disable:max-classes-per-file | ||
|
||
export class UpdaterCommand implements IMessage { | ||
public ID = 'UpdaterCommand' ; | ||
public Command: string; | ||
public constructor(command: string) { | ||
this.Command = command; | ||
} | ||
} | ||
|
||
export class UpdaterEvent implements IMessage { | ||
public ID = 'UpdaterEvent' ; | ||
public Event: string; | ||
public Arg: any; | ||
public constructor(evt: string, arg?: any) { | ||
this.Event = evt; | ||
this.Arg = arg; | ||
} | ||
} |
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,61 @@ | ||
import { BrowserWindow, app } from "electron"; | ||
import { autoUpdater } from "electron-updater"; | ||
import * as electronLog from "electron-log"; | ||
import { IMessenger } from "../messaging/i-messenger"; | ||
import { UpdaterCommand, UpdaterEvent } from "./messages"; | ||
|
||
autoUpdater.autoDownload = false; | ||
autoUpdater.logger = electronLog; | ||
|
||
// beta channel for testing | ||
autoUpdater.channel = 'beta'; | ||
|
||
export class UpdaterService { | ||
private messenger: IMessenger; | ||
|
||
constructor(messenger: IMessenger) { | ||
this.messenger = messenger; | ||
this.messenger.Receive('UpdaterCommand', (arg: UpdaterCommand) => { | ||
if (arg.Command === 'commence-install-update') { | ||
setImmediate(() => { | ||
app.removeAllListeners("window-all-closed"); | ||
let browserWindows = BrowserWindow.getAllWindows(); | ||
browserWindows.forEach((browserWindow) => { | ||
browserWindow.close(); | ||
}); | ||
autoUpdater.quitAndInstall(); | ||
}); | ||
} else if (arg.Command === 'commence-download') { | ||
autoUpdater.downloadUpdate(); | ||
} else if (arg.Command === 'check-for-update') { | ||
this.checkUpdate(); | ||
} | ||
}); | ||
autoUpdater.on('update-available', (info) => { | ||
this.messenger.Send(new UpdaterEvent('checking', false)); | ||
this.messenger.Send(new UpdaterEvent('update-available', { version: info.version })); | ||
}); | ||
autoUpdater.on('update-not-available', () => { | ||
this.messenger.Send(new UpdaterEvent('checking', false)); | ||
this.messenger.Send(new UpdaterEvent('update-not-available')); | ||
}); | ||
autoUpdater.on('download-progress', (progress) => { | ||
this.messenger.Send(new UpdaterEvent('downloading-update', { percentage: progress.percent })); | ||
}); | ||
autoUpdater.on('update-downloaded', () => { | ||
this.messenger.Send(new UpdaterEvent('download-complete')); | ||
}); | ||
autoUpdater.on('checking-for-update', () => { | ||
this.messenger.Send(new UpdaterEvent('checking', true)); | ||
}); | ||
setInterval(() => { | ||
this.checkUpdate(); | ||
}, 15 * 60 * 1000); | ||
setTimeout(() => { | ||
this.checkUpdate(); | ||
}, 10 * 1000); | ||
} | ||
public checkUpdate() { | ||
autoUpdater.checkForUpdates(); | ||
} | ||
} |