check for updates is modified

This commit is contained in:
richard-loafle 2020-01-22 16:10:30 +09:00
parent 85200f420d
commit 4cef55ded8
5 changed files with 42 additions and 37 deletions

View File

@ -309,10 +309,13 @@
</button> </button>
</div> </div>
<mat-divider></mat-divider> <mat-divider></mat-divider>
<div class="setting"> <div
<button mat-menu-item [matMenuTriggerFor]="informationMenu"> class="setting"
{{ 'information.label' | translate }} style="padding: 0 16px;"
</button> [matMenuTriggerFor]="informationMenu"
(click)="onClickCheckForUpdates($event)"
>
{{ 'information.checkForUpdates' | translate }}
</div> </div>
<mat-divider></mat-divider> <mat-divider></mat-divider>
<div class="setting"> <div class="setting">
@ -432,39 +435,32 @@
<mat-menu #informationMenu="matMenu" (closed)="onClosedInformationMenu($event)"> <mat-menu #informationMenu="matMenu" (closed)="onClosedInformationMenu($event)">
<div class="version-info-container" (click)="$event.stopPropagation()"> <div class="version-info-container" (click)="$event.stopPropagation()">
<div style="display: flex;"> <div>
<span>{{ 'information.version' | translate }}: {{ appVersion }}</span>
<span> <span>
<button {{ 'information.installedVersion' | translate }}:{{ appVersion }}
*ngIf="!checkingUpdate" </span>
mat-icon-button </div>
matTooltip="{{ 'information.checkForUpdates' | translate }}" <div *ngIf="checkingUpdate">
(click)="onClickCheckUpdate($event)" <div *ngIf="checkingUpdateIsProcessing" style="display: flex;">
>
<span class="mdi mdi-progress-check"></span>
</button>
<mat-spinner <mat-spinner
*ngIf="checkingUpdate && checkingUpdateIsProcessing" *ngIf="checkingUpdate && checkingUpdateIsProcessing"
diameter="20" diameter="20"
strokeWidth="1" strokeWidth="1"
></mat-spinner> ></mat-spinner>
</span>
</div>
<div *ngIf="checkingUpdate">
<div *ngIf="checkingUpdateIsProcessing">
{{ 'information.checkForUpdatesInProgress' | translate }} {{ 'information.checkForUpdatesInProgress' | translate }}
</div> </div>
<div *ngIf="!checkingUpdateIsProcessing && !!checkingUpdateAppVersion">
{{ <div *ngIf="!checkingUpdateIsProcessing" style="display: flex;">
'information.updateIsExist' <span>
| translate: { version: checkingUpdateAppVersion } {{ 'information.latestVersion' | translate }}:{{
checkingUpdateAppVersion
}} }}
</span>
<span>
<button mat-button (click)="onClickApplyUpdate($event)"> <button mat-button (click)="onClickApplyUpdate($event)">
{{ 'information.applyUpdates' | translate }} {{ 'information.applyUpdates' | translate }}
</button> </button>
</div> </span>
<div *ngIf="!checkingUpdateIsProcessing && !checkingUpdateAppVersion">
{{ 'information.updateIsNotExist' | translate }}
</div> </div>
</div> </div>
</div> </div>

View File

@ -294,5 +294,5 @@
} }
.version-info-container { .version-info-container {
width: 200px; width: 250px;
} }

View File

@ -110,6 +110,7 @@ export class TopBarComponent implements OnInit, OnDestroy {
checkingUpdate = false; checkingUpdate = false;
checkingUpdateIsProcessing = false; checkingUpdateIsProcessing = false;
checkingUpdateAppVersion: string; checkingUpdateAppVersion: string;
checkingUpdateIsExist = false;
readonly awayTimeList = [10, 20, 30]; readonly awayTimeList = [10, 20, 30];
@ -499,13 +500,20 @@ export class TopBarComponent implements OnInit, OnDestroy {
); );
} }
onClickCheckForUpdates(event: Event) {
event.stopPropagation();
this.checkForUpdates();
}
onClosedInformationMenu() { onClosedInformationMenu() {
this.checkingUpdate = false; this.checkingUpdate = false;
this.checkingUpdateIsProcessing = false; this.checkingUpdateIsProcessing = false;
this.checkingUpdateAppVersion = undefined; this.checkingUpdateAppVersion = undefined;
this.checkingUpdateIsExist = false;
} }
onClickCheckUpdate(event: Event) { checkForUpdates() {
this.checkingUpdate = true; this.checkingUpdate = true;
this.checkingUpdateIsProcessing = true; this.checkingUpdateIsProcessing = true;
@ -524,10 +532,11 @@ export class TopBarComponent implements OnInit, OnDestroy {
.pipe(take(1)) .pipe(take(1))
.subscribe( .subscribe(
res => { res => {
if (semver.lt(this.appVersion, res.appVersion)) {
this.checkingUpdateAppVersion = res.appVersion; this.checkingUpdateAppVersion = res.appVersion;
if (semver.lt(this.appVersion, res.appVersion)) {
this.checkingUpdateIsExist = true;
} else { } else {
this.checkingUpdateAppVersion = undefined; this.checkingUpdateIsExist = false;
} }
}, },
error => {}, error => {},

View File

@ -76,10 +76,10 @@
"information": { "information": {
"label": "Information", "label": "Information",
"version": "Version", "version": "Version",
"installedVersion": "Installed version",
"latestVersion": "Latest version",
"checkForUpdates": "Check for updates", "checkForUpdates": "Check for updates",
"checkForUpdatesInProgress": "Checking for updates", "checkForUpdatesInProgress": "Checking for updates",
"updateIsExist": "There is a new version [{{version}}].",
"updateIsNotExist": "The version of the app is up to date.",
"applyUpdates": "Update" "applyUpdates": "Update"
}, },
"settings": { "settings": {

View File

@ -76,10 +76,10 @@
"information": { "information": {
"label": "정보", "label": "정보",
"version": "버전", "version": "버전",
"installedVersion": "설치된 버전",
"latestVersion": "최신 버전",
"checkForUpdates": "업데이트 확인", "checkForUpdates": "업데이트 확인",
"checkForUpdatesInProgress": "업데이트를 확인하고 있습니다.", "checkForUpdatesInProgress": "업데이트를 확인하고 있습니다.",
"updateIsExist": "새로운 버전[{{version}}]이 존재합니다.",
"updateIsNotExist": "최신 버전이 적용되어 있습니다.",
"applyUpdates": "업데이트 설치" "applyUpdates": "업데이트 설치"
}, },
"settings": { "settings": {