checking updates is added

This commit is contained in:
Richard Park 2020-01-22 14:16:32 +09:00
parent b0742c475d
commit e46522734a
6 changed files with 109 additions and 7 deletions

View File

@ -361,7 +361,6 @@
maxlength="5" maxlength="5"
[value]="loginRes?.statusMessage1" [value]="loginRes?.statusMessage1"
(click)="$event.stopPropagation()" (click)="$event.stopPropagation()"
/></span> /></span>
</ucap-inline-edit-input> </ucap-inline-edit-input>
</button> </button>
@ -432,7 +431,41 @@
</mat-menu> </mat-menu>
<mat-menu #informationMenu="matMenu"> <mat-menu #informationMenu="matMenu">
<div mat-menu-item> <div class="version-info-container" (click)="$event.stopPropagation()">
{{ 'information.version' | translate }}: {{ appVersion }} <div style="display: flex;">
<span>{{ 'information.version' | translate }}: {{ appVersion }}</span>
<span>
<button
*ngIf="!checkingUpdate"
mat-icon-button
matTooltip="{{ 'information.checkForUpdates' | translate }}"
(click)="onClickCheckUpdate($event)"
>
<span class="mdi mdi-progress-check"></span>
</button>
<mat-spinner
*ngIf="checkingUpdate && checkingUpdateIsProcessing"
diameter="20"
strokeWidth="1"
></mat-spinner>
</span>
</div>
<div *ngIf="checkingUpdate">
<div *ngIf="checkingUpdateIsProcessing">
{{ 'information.checkForUpdatesInProgress' | translate }}
</div>
<div *ngIf="!checkingUpdateIsProcessing && !!checkingUpdateAppVersion">
{{
'information.updateIsExist'
| translate: { version: checkingUpdateAppVersion }
}}
<button mat-button (click)="onClickApplyUpdate($event)">
{{ 'information.applyUpdates' | translate }}
</button>
</div>
<div *ngIf="!checkingUpdateIsProcessing && !checkingUpdateAppVersion">
{{ 'information.updateIsNotExist' | translate }}
</div>
</div>
</div> </div>
</mat-menu> </mat-menu>

View File

@ -292,3 +292,7 @@
} }
} }
} }
.version-info-container {
width: 200px;
}

View File

@ -15,6 +15,8 @@ import {
import { Observable, Subscription, of } from 'rxjs'; import { Observable, Subscription, of } from 'rxjs';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import semver from 'semver';
import * as AppStore from '@app/store'; import * as AppStore from '@app/store';
import * as ChatStore from '@app/store/messenger/chat'; import * as ChatStore from '@app/store/messenger/chat';
import * as AuthenticationStore from '@app/store/account/authentication'; import * as AuthenticationStore from '@app/store/account/authentication';
@ -30,7 +32,9 @@ import {
KEY_URL_INFO, KEY_URL_INFO,
LoginInfo, LoginInfo,
KEY_LOGIN_INFO, KEY_LOGIN_INFO,
KEY_VER_INFO KEY_VER_INFO,
EnvironmentsInfo,
KEY_ENVIRONMENTS_INFO
} from '@app/types'; } from '@app/types';
import { import {
WebLink, WebLink,
@ -48,7 +52,10 @@ import {
WebLinkType WebLinkType
} from '@ucap-webmessenger/daesang'; } from '@ucap-webmessenger/daesang';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import {
VersionInfo2Response,
PublicApiService
} from '@ucap-webmessenger/api-public';
import { import {
ProfileDialogComponent, ProfileDialogComponent,
ProfileDialogResult, ProfileDialogResult,
@ -100,6 +107,10 @@ export class TopBarComponent implements OnInit, OnDestroy {
WebLinkType = WebLinkType; WebLinkType = WebLinkType;
StatusCode = StatusCode; StatusCode = StatusCode;
checkingUpdate = false;
checkingUpdateIsProcessing = false;
checkingUpdateAppVersion: string;
readonly awayTimeList = [10, 20, 30]; readonly awayTimeList = [10, 20, 30];
@ViewChild('profileMenu', { static: true }) @ViewChild('profileMenu', { static: true })
@ -108,9 +119,11 @@ export class TopBarComponent implements OnInit, OnDestroy {
constructor( constructor(
private store: Store<any>, private store: Store<any>,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private changeDetectorRef: ChangeDetectorRef,
private dialogService: DialogService, private dialogService: DialogService,
private localStorageService: LocalStorageService, private localStorageService: LocalStorageService,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private publicApiService: PublicApiService,
private daesangApiService: DaesangApiService, private daesangApiService: DaesangApiService,
private daesangProtocolService: DaesangProtocolService, private daesangProtocolService: DaesangProtocolService,
@Inject(DOCUMENT) private document: Document, @Inject(DOCUMENT) private document: Document,
@ -485,4 +498,42 @@ export class TopBarComponent implements OnInit, OnDestroy {
StatusStore.changeMyIdleCheckTime({ checkTime: Number(event.value) }) StatusStore.changeMyIdleCheckTime({ checkTime: Number(event.value) })
); );
} }
onClickCheckUpdate(event: Event) {
this.checkingUpdate = true;
this.checkingUpdateIsProcessing = true;
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
const environmentsInfo = this.sessionStorageService.get<EnvironmentsInfo>(
KEY_ENVIRONMENTS_INFO
);
this.publicApiService
.versionInfo2({
deviceType: environmentsInfo.deviceType,
companyGroupType: loginInfo.companyGroupType,
companyCode: loginInfo.companyCode,
loginId: loginInfo.loginId
})
.pipe(take(1))
.subscribe(
res => {
if (semver.lt(this.appVersion, res.appVersion)) {
this.checkingUpdateAppVersion = res.appVersion;
} else {
this.checkingUpdateAppVersion = undefined;
}
},
error => {},
() => {
this.checkingUpdateIsProcessing = false;
}
);
}
onClickApplyUpdate(event: Event) {
this.nativeService
.checkForUpdates(this.checkingUpdateAppVersion)
.then(e => {});
}
} }

View File

@ -3,11 +3,13 @@ import { CommonModule } from '@angular/common';
import { FlexLayoutModule } from '@angular/flex-layout'; import { FlexLayoutModule } from '@angular/flex-layout';
import { MatButtonModule } from '@angular/material/button';
import { MatDividerModule } from '@angular/material/divider'; import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu';
import { MatRadioModule } from '@angular/material/radio'; import { MatRadioModule } from '@angular/material/radio';
import { MatToolbarModule } from '@angular/material/toolbar'; import { MatToolbarModule } from '@angular/material/toolbar';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@ -21,6 +23,7 @@ import { MatTooltipModule, MatBadgeModule } from '@angular/material';
imports: [ imports: [
CommonModule, CommonModule,
FlexLayoutModule, FlexLayoutModule,
MatButtonModule,
MatDividerModule, MatDividerModule,
MatIconModule, MatIconModule,
MatToolbarModule, MatToolbarModule,
@ -28,6 +31,7 @@ import { MatTooltipModule, MatBadgeModule } from '@angular/material';
MatMenuModule, MatMenuModule,
MatRadioModule, MatRadioModule,
MatBadgeModule, MatBadgeModule,
MatProgressSpinnerModule,
TranslateModule, TranslateModule,

View File

@ -75,7 +75,12 @@
}, },
"information": { "information": {
"label": "Information", "label": "Information",
"version": "Version" "version": "Version",
"checkForUpdates": "Check 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"
}, },
"settings": { "settings": {
"label": "Settings", "label": "Settings",

View File

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