From e46522734ab267d79826dafbd097b3481cedc971 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Wed, 22 Jan 2020 14:16:32 +0900 Subject: [PATCH] checking updates is added --- .../native/components/top-bar.component.html | 39 ++++++++++++- .../native/components/top-bar.component.scss | 4 ++ .../native/components/top-bar.component.ts | 55 ++++++++++++++++++- .../layouts/native/native.layout.module.ts | 4 ++ .../src/assets/i18n/en.json | 7 ++- .../src/assets/i18n/ko.json | 7 ++- 6 files changed, 109 insertions(+), 7 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html index 64a1a0f5..c086cfd4 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html @@ -361,7 +361,6 @@ maxlength="5" [value]="loginRes?.statusMessage1" (click)="$event.stopPropagation()" - /> @@ -432,7 +431,41 @@ -
- {{ 'information.version' | translate }}: {{ appVersion }} +
+
+ {{ 'information.version' | translate }}: {{ appVersion }} + + + + +
+
+
+ {{ 'information.checkForUpdatesInProgress' | translate }} +
+
+ {{ + 'information.updateIsExist' + | translate: { version: checkingUpdateAppVersion } + }} + +
+
+ {{ 'information.updateIsNotExist' | translate }} +
+
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.scss index 6f4af011..2ed72c8b 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.scss +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.scss @@ -292,3 +292,7 @@ } } } + +.version-info-container { + width: 200px; +} diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts index e6c4cce3..cc8686c5 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.ts @@ -15,6 +15,8 @@ import { import { Observable, Subscription, of } from 'rxjs'; import { Store, select } from '@ngrx/store'; +import semver from 'semver'; + import * as AppStore from '@app/store'; import * as ChatStore from '@app/store/messenger/chat'; import * as AuthenticationStore from '@app/store/account/authentication'; @@ -30,7 +32,9 @@ import { KEY_URL_INFO, LoginInfo, KEY_LOGIN_INFO, - KEY_VER_INFO + KEY_VER_INFO, + EnvironmentsInfo, + KEY_ENVIRONMENTS_INFO } from '@app/types'; import { WebLink, @@ -48,7 +52,10 @@ import { WebLinkType } from '@ucap-webmessenger/daesang'; import { NGXLogger } from 'ngx-logger'; -import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; +import { + VersionInfo2Response, + PublicApiService +} from '@ucap-webmessenger/api-public'; import { ProfileDialogComponent, ProfileDialogResult, @@ -100,6 +107,10 @@ export class TopBarComponent implements OnInit, OnDestroy { WebLinkType = WebLinkType; StatusCode = StatusCode; + checkingUpdate = false; + checkingUpdateIsProcessing = false; + checkingUpdateAppVersion: string; + readonly awayTimeList = [10, 20, 30]; @ViewChild('profileMenu', { static: true }) @@ -108,9 +119,11 @@ export class TopBarComponent implements OnInit, OnDestroy { constructor( private store: Store, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, + private changeDetectorRef: ChangeDetectorRef, private dialogService: DialogService, private localStorageService: LocalStorageService, private sessionStorageService: SessionStorageService, + private publicApiService: PublicApiService, private daesangApiService: DaesangApiService, private daesangProtocolService: DaesangProtocolService, @Inject(DOCUMENT) private document: Document, @@ -485,4 +498,42 @@ export class TopBarComponent implements OnInit, OnDestroy { StatusStore.changeMyIdleCheckTime({ checkTime: Number(event.value) }) ); } + + onClickCheckUpdate(event: Event) { + this.checkingUpdate = true; + this.checkingUpdateIsProcessing = true; + + const loginInfo = this.sessionStorageService.get(KEY_LOGIN_INFO); + const environmentsInfo = this.sessionStorageService.get( + 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 => {}); + } } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/native.layout.module.ts b/projects/ucap-webmessenger-app/src/app/layouts/native/native.layout.module.ts index 178d6eac..2722a232 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/native.layout.module.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/native.layout.module.ts @@ -3,11 +3,13 @@ import { CommonModule } from '@angular/common'; import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatButtonModule } from '@angular/material/button'; import { MatDividerModule } from '@angular/material/divider'; import { MatIconModule } from '@angular/material/icon'; import { MatMenuModule } from '@angular/material/menu'; import { MatRadioModule } from '@angular/material/radio'; import { MatToolbarModule } from '@angular/material/toolbar'; +import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { TranslateModule } from '@ngx-translate/core'; @@ -21,6 +23,7 @@ import { MatTooltipModule, MatBadgeModule } from '@angular/material'; imports: [ CommonModule, FlexLayoutModule, + MatButtonModule, MatDividerModule, MatIconModule, MatToolbarModule, @@ -28,6 +31,7 @@ import { MatTooltipModule, MatBadgeModule } from '@angular/material'; MatMenuModule, MatRadioModule, MatBadgeModule, + MatProgressSpinnerModule, TranslateModule, diff --git a/projects/ucap-webmessenger-app/src/assets/i18n/en.json b/projects/ucap-webmessenger-app/src/assets/i18n/en.json index 2e619836..9a21d932 100644 --- a/projects/ucap-webmessenger-app/src/assets/i18n/en.json +++ b/projects/ucap-webmessenger-app/src/assets/i18n/en.json @@ -75,7 +75,12 @@ }, "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": { "label": "Settings", diff --git a/projects/ucap-webmessenger-app/src/assets/i18n/ko.json b/projects/ucap-webmessenger-app/src/assets/i18n/ko.json index 46465313..03a19034 100644 --- a/projects/ucap-webmessenger-app/src/assets/i18n/ko.json +++ b/projects/ucap-webmessenger-app/src/assets/i18n/ko.json @@ -75,7 +75,12 @@ }, "information": { "label": "정보", - "version": "버전" + "version": "버전", + "checkForUpdates": "업데이트 확인", + "checkForUpdatesInProgress": "업데이트를 확인하고 있습니다.", + "updateIsExist": "새로운 버전[{{version}}]이 존재합니다.", + "updateIsNotExist": "최신 버전이 적용되어 있습니다.", + "applyUpdates": "업데이트 설치" }, "settings": { "label": "설정",