This commit is contained in:
leejinho 2020-02-06 14:35:03 +09:00
commit c31fc51644
16 changed files with 243 additions and 427 deletions

View File

@ -3,18 +3,10 @@ import { Component, OnInit, OnDestroy, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { FileEventJson } from '@ucap-webmessenger/protocol-event'; import { FileEventJson } from '@ucap-webmessenger/protocol-event';
import { DeviceType, FileUtil, MimeUtil } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
import { take, map, finalize, tap } from 'rxjs/operators';
import {
SnackBarService,
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui';
import { FileDownloadItem } from '@ucap-webmessenger/api'; import { FileDownloadItem } from '@ucap-webmessenger/api';
import { CommonApiService } from '@ucap-webmessenger/api-common'; import { CommonApiService } from '@ucap-webmessenger/api-common';
import { TranslateService } from '@ngx-translate/core'; import { AppFileService } from '@app/services/file.service';
import { FileProtocolService } from '@ucap-webmessenger/protocol-file';
export interface FileViewerDialogData { export interface FileViewerDialogData {
fileInfo: FileEventJson; fileInfo: FileEventJson;
@ -46,11 +38,8 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
FileViewerDialogResult FileViewerDialogResult
>, >,
@Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData, @Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private translateService: TranslateService,
private snackBarService: SnackBarService,
private commonApiService: CommonApiService, private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService, private appFileService: AppFileService,
private logger: NGXLogger private logger: NGXLogger
) { ) {
this.fileInfo = data.fileInfo; this.fileInfo = data.fileInfo;
@ -75,93 +64,17 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {} ngOnDestroy(): void {}
onDownload(fileDownloadItem: FileDownloadItem): void { onDownload(fileDownloadItem: FileDownloadItem): void {
this.commonApiService this.appFileService.fileTalkDownlod({
.fileTalkDownload( req: {
{ userSeq: this.userSeq,
userSeq: this.userSeq, deviceType: this.deviceType,
deviceType: this.deviceType, token: this.token,
token: this.token, attachmentsSeq: this.fileInfo.attachmentSeq,
attachmentsSeq: this.fileInfo.attachmentSeq, fileDownloadItem
fileDownloadItem },
}, fileName: this.fileInfo.fileName,
this.downloadUrl fileDownloadUrl: this.downloadUrl
) });
.pipe(
take(1),
map(async rawBlob => {
const mimeType = MimeUtil.getMimeFromExtension(this.fileInfo.fileExt);
const blob = rawBlob.slice(0, rawBlob.size, mimeType);
FileUtil.fromBlobToBuffer(blob)
.then(buffer => {
/** download check */
this.fileProtocolService
.downCheck({
seq: this.fileInfo.attachmentSeq
})
.pipe(take(1))
.subscribe();
this.nativeService
.saveFile(buffer, this.fileInfo.fileName, mimeType)
.then(result => {
if (!!result) {
this.snackBarService.open(
this.translateService.instant(
'common.file.results.savedToPath',
{
path: result
}
),
'',
{
duration: 3000,
verticalPosition: 'bottom'
}
);
} else {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
}
})
.catch(reason => {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
});
})
.catch(reason => {
this.logger.error('download', reason);
});
}),
finalize(() => {
setTimeout(() => {
fileDownloadItem.downloadingProgress$ = undefined;
}, 1000);
})
)
.subscribe();
} }
onClosedViewer(): void { onClosedViewer(): void {

View File

@ -8,9 +8,7 @@ import {
EventEmitter, EventEmitter,
Inject, Inject,
ChangeDetectorRef, ChangeDetectorRef,
ChangeDetectionStrategy, ChangeDetectionStrategy
ElementRef,
NgZone
} from '@angular/core'; } from '@angular/core';
import { import {
ucapAnimations, ucapAnimations,
@ -24,20 +22,11 @@ import {
AlertDialogData, AlertDialogData,
AlertDialogResult, AlertDialogResult,
FileUploadQueueComponent, FileUploadQueueComponent,
StringUtil, StringUtil
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui'; } from '@ucap-webmessenger/ui';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { import { Observable, Subscription, forkJoin, of, BehaviorSubject } from 'rxjs';
Observable,
Subscription,
forkJoin,
combineLatest,
of,
BehaviorSubject
} from 'rxjs';
import { import {
Info, Info,
@ -78,7 +67,7 @@ import {
RoomType, RoomType,
UserInfoShort UserInfoShort
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
import { tap, take, map, catchError, finalize } from 'rxjs/operators'; import { take, map, catchError } from 'rxjs/operators';
import { import {
FormComponent as UCapUiChatFormComponent, FormComponent as UCapUiChatFormComponent,
MessagesComponent as UCapUiChatMessagesComponent MessagesComponent as UCapUiChatMessagesComponent
@ -108,7 +97,7 @@ import {
FileViewerDialogData, FileViewerDialogData,
FileViewerDialogResult FileViewerDialogResult
} from '@app/layouts/common/dialogs/file-viewer.dialog.component'; } from '@app/layouts/common/dialogs/file-viewer.dialog.component';
import { FileUtil, StickerFilesInfo, MimeUtil } from '@ucap-webmessenger/core'; import { FileUtil, StickerFilesInfo } from '@ucap-webmessenger/core';
import { StatusCode } from '@ucap-webmessenger/api'; import { StatusCode } from '@ucap-webmessenger/api';
import { import {
@ -131,12 +120,13 @@ import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { TranslatePipe } from 'projects/ucap-webmessenger-ui/src/lib/pipes/translate.pipe'; import { TranslatePipe } from 'projects/ucap-webmessenger-ui/src/lib/pipes/translate.pipe';
import { TranslateService as UiTranslateService } from '@ucap-webmessenger/ui'; import { TranslateService as UiTranslateService } from '@ucap-webmessenger/ui';
import { FileProtocolService } from '@ucap-webmessenger/protocol-file';
import { import {
ClipboardDialogComponent, ClipboardDialogComponent,
ClipboardDialogData, ClipboardDialogData,
ClipboardDialogResult ClipboardDialogResult
} from '../dialogs/chat/clipboard.dialog.component'; } from '../dialogs/chat/clipboard.dialog.component';
import { AppFileService } from '@app/services/file.service';
@Component({ @Component({
selector: 'app-layout-messenger-messages', selector: 'app-layout-messenger-messages',
@ -241,7 +231,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private localStorageService: LocalStorageService, private localStorageService: LocalStorageService,
private commonApiService: CommonApiService, private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
private clipboardService: ClipboardService, private clipboardService: ClipboardService,
private uiTranslateService: UiTranslateService, private uiTranslateService: UiTranslateService,
private translateService: TranslateService, private translateService: TranslateService,
@ -249,7 +238,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
private dialogService: DialogService, private dialogService: DialogService,
private snackBarService: SnackBarService, private snackBarService: SnackBarService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private ngZone: NgZone, private appFileService: AppFileService,
private logger: NGXLogger private logger: NGXLogger
) { ) {
this.sessionVerInfo = this.sessionStorageService.get<VersionInfo2Response>( this.sessionVerInfo = this.sessionStorageService.get<VersionInfo2Response>(
@ -482,7 +471,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
// Chat Formfield Clear.. // Chat Formfield Clear..
if (!!this.chatForm) { if (!!this.chatForm) {
this.chatForm.replyForm.reset(); this.chatForm.replyInput.nativeElement.value = '';
} }
} }
@ -693,7 +682,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
req: { req: {
roomSeq: this.roomInfoSubject.value.roomSeq, roomSeq: this.roomInfoSubject.value.roomSeq,
eventType: EventType.Character, eventType: EventType.Character,
sentMessage: message sentMessage: StringUtil.escapeHtml(message)
} }
}) })
); );
@ -728,7 +717,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
const stickerJson: StickerEventJson = { const stickerJson: StickerEventJson = {
name: '스티커', name: '스티커',
file: this.selectedSticker.index, file: this.selectedSticker.index,
chat: !!message ? message.trim() : '' chat: !!message ? StringUtil.escapeHtml(message.trim()) : ''
}; };
this.store.dispatch( this.store.dispatch(
EventStore.send({ EventStore.send({
@ -761,7 +750,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
/** Send Translation message */ /** Send Translation message */
sendMessageOfTranslate(message: string) { sendMessageOfTranslate(message: string) {
const destLocale = this.destLocale; const destLocale = this.destLocale;
const original = message; const original = StringUtil.escapeHtml(message);
const roomSeq = this.roomInfoSubject.value.roomSeq; const roomSeq = this.roomInfoSubject.value.roomSeq;
if (!!this.isTranslationProcess) { if (!!this.isTranslationProcess) {
@ -1052,103 +1041,17 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
}, },
savePath?: string savePath?: string
) { ) {
this.commonApiService this.appFileService.fileTalkDownlod({
.fileTalkDownload({ req: {
userSeq: this.loginResSubject.value.userSeq, userSeq: this.loginResSubject.value.userSeq,
deviceType: this.environmentsInfo.deviceType, deviceType: this.environmentsInfo.deviceType,
token: this.loginResSubject.value.tokenString, token: this.loginResSubject.value.tokenString,
attachmentsSeq: value.fileInfo.attachmentSeq, attachmentsSeq: value.fileInfo.attachmentSeq,
fileDownloadItem: value.fileDownloadItem fileDownloadItem: value.fileDownloadItem
}) },
.pipe( fileName: value.fileInfo.fileName,
take(1), savePath
map(async rawBlob => { });
const mimeType = MimeUtil.getMimeFromExtension(
FileUtil.getExtension(value.fileInfo.fileName)
);
const blob = rawBlob.slice(0, rawBlob.size, mimeType);
FileUtil.fromBlobToBuffer(blob)
.then(buffer => {
/** download check */
this.fileProtocolService
.downCheck({
seq: value.fileInfo.attachmentSeq
})
.pipe(take(1))
.subscribe();
this.nativeService
.saveFile(buffer, value.fileInfo.fileName, mimeType, savePath)
.then(result => {
if (!!result) {
const snackBarRef = this.snackBarService.open(
this.translateService.instant(
'common.file.results.savedToPath',
{
path: result
}
),
this.translateService.instant('common.file.open'),
{
duration: 3000,
verticalPosition: 'bottom',
horizontalPosition: 'center'
}
);
snackBarRef.onAction().subscribe(() => {
this.ngZone.runOutsideAngular(() => {
this.nativeService
.openTargetItem(result)
.catch(reason => {
this.logger.warn(reason);
});
});
});
} else {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
}
})
.catch(reason => {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
});
})
.catch(reason => {
this.logger.error('download', reason);
});
}),
finalize(() => {
setTimeout(() => {
value.fileDownloadItem.downloadingProgress$ = undefined;
}, 1000);
})
)
.subscribe();
} }
async onFileSelected(fileUploadItems: FileUploadItem[]) { async onFileSelected(fileUploadItems: FileUploadItem[]) {
@ -2028,7 +1931,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
}); });
if (result.selected.text) { if (result.selected.text) {
this.onSendMessage(data.text); this.onSendMessage(data.text.replace(/\t/g, ' '));
} }
if (result.selected.image) { if (result.selected.image) {

View File

@ -9,15 +9,14 @@ import {
import { import {
FileInfo, FileInfo,
FileDownloadInfo, FileDownloadInfo,
FileType, FileType
FileProtocolService
} from '@ucap-webmessenger/protocol-file'; } from '@ucap-webmessenger/protocol-file';
import { Subscription, combineLatest } from 'rxjs'; import { Subscription, combineLatest } from 'rxjs';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store'; import * as AppStore from '@app/store';
import { tap, map, take, finalize } from 'rxjs/operators'; import { tap } from 'rxjs/operators';
import { FileUtil, MimeUtil } from '@ucap-webmessenger/core'; import { FileUtil } from '@ucap-webmessenger/core';
import { CommonApiService } from '@ucap-webmessenger/api-common'; import { CommonApiService } from '@ucap-webmessenger/api-common';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
@ -30,15 +29,10 @@ import {
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native'; import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import {
SnackBarService,
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui';
import { FileDownloadItem } from '@ucap-webmessenger/api'; import { FileDownloadItem } from '@ucap-webmessenger/api';
import { ModuleConfig } from '@ucap-webmessenger/api-common'; import { ModuleConfig } from '@ucap-webmessenger/api-common';
import { _MODULE_CONFIG } from 'projects/ucap-webmessenger-api-common/src/lib/config/token'; import { _MODULE_CONFIG } from 'projects/ucap-webmessenger-api-common/src/lib/config/token';
import { TranslateService } from '@ngx-translate/core'; import { AppFileService } from '@app/services/file.service';
export interface FileInfoTotal { export interface FileInfoTotal {
info: FileInfo; info: FileInfo;
@ -78,10 +72,8 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
private store: Store<any>, private store: Store<any>,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private commonApiService: CommonApiService, private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
private translateService: TranslateService,
private snackBarService: SnackBarService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private appFileService: AppFileService,
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig, @Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
private logger: NGXLogger private logger: NGXLogger
) { ) {
@ -229,92 +221,16 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
} }
onClickDownload(fileInfo: FileInfoTotal) { onClickDownload(fileInfo: FileInfoTotal) {
this.commonApiService this.appFileService.fileTalkDownlod({
.fileTalkDownload({ req: {
userSeq: this.loginRes.userSeq, userSeq: this.loginRes.userSeq,
deviceType: this.environmentsInfo.deviceType, deviceType: this.environmentsInfo.deviceType,
token: this.loginRes.tokenString, token: this.loginRes.tokenString,
attachmentsSeq: fileInfo.info.seq, attachmentsSeq: fileInfo.info.seq,
fileDownloadItem: fileInfo.fileDownloadItem fileDownloadItem: fileInfo.fileDownloadItem
}) },
.pipe( fileName: fileInfo.info.name
take(1), });
map(async rawBlob => {
const mimeType = MimeUtil.getMimeFromExtension(
FileUtil.getExtension(fileInfo.info.name)
);
const blob = rawBlob.slice(0, rawBlob.size, mimeType);
FileUtil.fromBlobToBuffer(blob)
.then(buffer => {
/** download check */
this.fileProtocolService
.downCheck({
seq: fileInfo.info.seq
})
.pipe(take(1))
.subscribe();
this.nativeService
.saveFile(buffer, fileInfo.info.name, mimeType)
.then(result => {
if (!!result) {
this.snackBarService.open(
this.translateService.instant(
'common.file.results.savedToPath',
{
path: result
}
),
'',
{
duration: 3000,
verticalPosition: 'bottom'
}
);
} else {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
}
})
.catch(reason => {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
});
})
.catch(reason => {
this.logger.error('download', reason);
});
}),
finalize(() => {
setTimeout(() => {
fileInfo.fileDownloadItem.downloadingProgress$ = undefined;
}, 1000);
})
)
.subscribe();
} }
onClickDownloadAll(): void { onClickDownloadAll(): void {

View File

@ -3,16 +3,16 @@ import { MatPaginator, MatTableDataSource, MatSort } from '@angular/material';
import { import {
FileInfo, FileInfo,
FileDownloadInfo, FileDownloadInfo,
FileType, FileType
FileProtocolService
} from '@ucap-webmessenger/protocol-file'; } from '@ucap-webmessenger/protocol-file';
import { Subscription, combineLatest } from 'rxjs'; import { Subscription, combineLatest } from 'rxjs';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store'; import * as AppStore from '@app/store';
import * as EventStore from '@app/store/messenger/event'; import * as EventStore from '@app/store/messenger/event';
import { tap, map, take, finalize } from 'rxjs/operators';
import { FileUtil, MimeUtil } from '@ucap-webmessenger/core'; import { tap } from 'rxjs/operators';
import { FileUtil } from '@ucap-webmessenger/core';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
@ -20,16 +20,12 @@ import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { FileDownloadItem } from '@ucap-webmessenger/api'; import { FileDownloadItem } from '@ucap-webmessenger/api';
import { import {
SnackBarService,
DialogService, DialogService,
ConfirmDialogComponent, ConfirmDialogComponent,
ConfirmDialogResult, ConfirmDialogResult,
ConfirmDialogData, ConfirmDialogData,
DateOptions, DateOptions
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui'; } from '@ucap-webmessenger/ui';
import { CommonApiService } from '@ucap-webmessenger/api-common';
import { EventType } from '@ucap-webmessenger/protocol-event'; import { EventType } from '@ucap-webmessenger/protocol-event';
import { import {
CreateChatDialogComponent, CreateChatDialogComponent,
@ -43,6 +39,7 @@ import {
} from '@app/types'; } from '@app/types';
import { RoomInfo } from '@ucap-webmessenger/protocol-room'; import { RoomInfo } from '@ucap-webmessenger/protocol-room';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { AppFileService } from '@app/services/file.service';
export interface FileInfoTotal { export interface FileInfoTotal {
info: FileInfo; info: FileInfo;
@ -78,11 +75,9 @@ export class FileBoxComponent implements OnInit, OnDestroy {
constructor( constructor(
private store: Store<any>, private store: Store<any>,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
private translateService: TranslateService, private translateService: TranslateService,
private snackBarService: SnackBarService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private appFileService: AppFileService,
private dialogService: DialogService, private dialogService: DialogService,
private logger: NGXLogger private logger: NGXLogger
) { ) {
@ -259,92 +254,16 @@ export class FileBoxComponent implements OnInit, OnDestroy {
} }
onClickDownload(fileInfo: FileInfoTotal) { onClickDownload(fileInfo: FileInfoTotal) {
this.commonApiService this.appFileService.fileTalkDownlod({
.fileTalkDownload({ req: {
userSeq: this.loginRes.userSeq, userSeq: this.loginRes.userSeq,
deviceType: this.environmentsInfo.deviceType, deviceType: this.environmentsInfo.deviceType,
token: this.loginRes.tokenString, token: this.loginRes.tokenString,
attachmentsSeq: fileInfo.info.seq, attachmentsSeq: fileInfo.info.seq,
fileDownloadItem: fileInfo.fileDownloadItem fileDownloadItem: fileInfo.fileDownloadItem
}) },
.pipe( fileName: fileInfo.info.name
take(1), });
map(async rawBlob => {
const mimeType = MimeUtil.getMimeFromExtension(
FileUtil.getExtension(fileInfo.info.name)
);
const blob = rawBlob.slice(0, rawBlob.size, mimeType);
FileUtil.fromBlobToBuffer(blob)
.then(buffer => {
/** download check */
this.fileProtocolService
.downCheck({
seq: fileInfo.info.seq
})
.pipe(take(1))
.subscribe();
this.nativeService
.saveFile(buffer, fileInfo.info.name, mimeType)
.then(result => {
if (!!result) {
this.snackBarService.open(
this.translateService.instant(
'common.file.results.savedToPath',
{
path: result
}
),
'',
{
duration: 3000,
verticalPosition: 'bottom'
}
);
} else {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
}
})
.catch(reason => {
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant(
'common.file.errors.failToSave'
),
buttonText: this.translateService.instant(
'common.file.errors.label'
)
}
});
});
})
.catch(reason => {
this.logger.error('download', reason);
});
}),
finalize(() => {
setTimeout(() => {
fileInfo.fileDownloadItem.downloadingProgress$ = undefined;
}, 1000);
})
)
.subscribe();
} }
onClickDownloadAll(): void { onClickDownloadAll(): void {

View File

@ -4,7 +4,7 @@
cdkDrag cdkDrag
cdkDragRootElement=".cdk-overlay-pane" cdkDragRootElement=".cdk-overlay-pane"
cdkDragHandle cdkDragHandle
>{{ 'settings.label' | translate }}</mat-card-title >{{ 'chat.sendFromClipboard' | translate }}</mat-card-title
> >
<button class="icon-button btn-dialog-close" (click)="onClickChoice(false)"> <button class="icon-button btn-dialog-close" (click)="onClickChoice(false)">
<i class="mdi mdi-window-close"></i> <i class="mdi mdi-window-close"></i>
@ -21,7 +21,7 @@
}}</span> }}</span>
</ng-template> </ng-template>
<perfect-scrollbar> <perfect-scrollbar>
<div>{{ data.content.text }}</div> <div style="white-space: pre-wrap;">{{ data.content.text }}</div>
</perfect-scrollbar> </perfect-scrollbar>
</mat-tab> </mat-tab>
<!-- <mat-tab *ngIf="data.content.rtf"> <!-- <mat-tab *ngIf="data.content.rtf">
@ -73,10 +73,10 @@
(click)="onClickChoice(false)" (click)="onClickChoice(false)"
class="mat-primary" class="mat-primary"
> >
{{ 'common.messages.no' | translate }} {{ 'common.messages.cancel' | translate }}
</button> </button>
<button mat-flat-button (click)="onClickChoice(true)" class="mat-primary"> <button mat-flat-button (click)="onClickChoice(true)" class="mat-primary">
{{ 'common.messages.yes' | translate }} {{ 'chat.send' | translate }}
</button> </button>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>

View File

@ -146,7 +146,7 @@ export class LoginPageComponent implements OnInit, OnDestroy {
data: { data: {
title: '', title: '',
html: this.translateService.instant( html: this.translateService.instant(
'accounts.errors.loginFail' 'accounts.errors.loginFailedIdPw'
) )
} }
}); });

View File

@ -41,7 +41,6 @@ import {
LoginResponse LoginResponse
} from '@ucap-webmessenger/protocol-authentication'; } from '@ucap-webmessenger/protocol-authentication';
import * as AuthenticationStore from '@app/store/account/authentication';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { import {
QueryProtocolService, QueryProtocolService,
@ -52,6 +51,7 @@ import { OptionProtocolService } from '@ucap-webmessenger/protocol-option';
import { TranslateService as UCapTranslateService } from '@ucap-webmessenger/ui'; import { TranslateService as UCapTranslateService } from '@ucap-webmessenger/ui';
import * as AppStore from '@app/store'; import * as AppStore from '@app/store';
import * as AuthenticationStore from '@app/store/account/authentication';
import * as CompanyStore from '@app/store/setting/company'; import * as CompanyStore from '@app/store/setting/company';
import * as VersionInfoStore from '@app/store/setting/version-info'; import * as VersionInfoStore from '@app/store/setting/version-info';
import * as OptionStore from '@app/store/messenger/option'; import * as OptionStore from '@app/store/messenger/option';
@ -72,6 +72,7 @@ import {
import { StatusCode } from '@ucap-webmessenger/api'; import { StatusCode } from '@ucap-webmessenger/api';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native'; import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type'; import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type';
import { TranslateService } from '@ngx-translate/core';
@Injectable() @Injectable()
export class AppMessengerResolver implements Resolve<void> { export class AppMessengerResolver implements Resolve<void> {
@ -89,6 +90,7 @@ export class AppMessengerResolver implements Resolve<void> {
private innerProtocolService: InnerProtocolService, private innerProtocolService: InnerProtocolService,
private appNativeService: AppNativeService, private appNativeService: AppNativeService,
private snackBarService: SnackBarService, private snackBarService: SnackBarService,
private translateService: TranslateService,
private logger: NGXLogger private logger: NGXLogger
) {} ) {}
@ -185,6 +187,7 @@ export class AppMessengerResolver implements Resolve<void> {
}) })
.pipe( .pipe(
catchError(err => { catchError(err => {
this.logger.error('ServerErrorCode', err);
switch (err as ServerErrorCode) { switch (err as ServerErrorCode) {
case ServerErrorCode.ERRCD_IDPW: case ServerErrorCode.ERRCD_IDPW:
break; break;
@ -285,6 +288,17 @@ export class AppMessengerResolver implements Resolve<void> {
resolve(); resolve();
}, },
err => { err => {
this.snackBarService.open(
this.translateService.instant('accounts.errors.loginFailed'),
'',
{
duration: 3000,
verticalPosition: 'bottom',
horizontalPosition: 'center'
}
);
this.store.dispatch(AuthenticationStore.loginRedirect());
reject(err); reject(err);
} }
); );

View File

@ -9,7 +9,9 @@ import { TranslateService as UCapTranslateService } from '@ucap-webmessenger/ui'
import { DateService as UCapDateService } from '@ucap-webmessenger/ui'; import { DateService as UCapDateService } from '@ucap-webmessenger/ui';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { EnviromentsService } from '@ucap-webmessenger/enviroments'; import { EnviromentsService } from '@ucap-webmessenger/enviroments';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger, NgxLoggerLevel } from 'ngx-logger';
import { environment } from '../../environments/environment';
@Injectable() @Injectable()
export class AppService { export class AppService {
@ -33,6 +35,10 @@ export class AppService {
this.ucapDateService.setDefaultTimezone('Asia/Seoul'); this.ucapDateService.setDefaultTimezone('Asia/Seoul');
this.ucapDateService.use('Asia/Seoul'); this.ucapDateService.use('Asia/Seoul');
this.ucapDateService.setLocale(this.translateService.currentLang); this.ucapDateService.setLocale(this.translateService.currentLang);
this.logger.updateConfig({
level: environment.production ? NgxLoggerLevel.WARN : NgxLoggerLevel.DEBUG
});
} }
public postInit(): Promise<any> { public postInit(): Promise<any> {

View File

@ -0,0 +1,129 @@
import { Injectable, Inject, NgZone } from '@angular/core';
import {
FileTalkDownloadRequest,
CommonApiService
} from '@ucap-webmessenger/api-common';
import { map, take, finalize, catchError } from 'rxjs/operators';
import { MimeUtil, FileUtil } from '@ucap-webmessenger/core';
import { FileProtocolService } from '@ucap-webmessenger/protocol-file';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
import {
SnackBarService,
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui';
import { TranslateService } from '@ngx-translate/core';
import { NGXLogger } from 'ngx-logger';
import { of } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AppFileService {
constructor(
private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private snackBarService: SnackBarService,
private translateService: TranslateService,
private ngZone: NgZone,
private logger: NGXLogger
) {}
fileTalkDownlod(param: {
req: FileTalkDownloadRequest;
fileName: string;
fileDownloadUrl?: string;
savePath?: string;
}) {
const req = param.req;
const fileName = param.fileName;
const fileDownloadItem = req.fileDownloadItem;
const fileDownloadUrl = param.fileDownloadUrl;
const savePath = param.savePath;
const fileTalkDownloadError = (reason: any) => {
this.logger.warn(reason);
this.snackBarService.openFromComponent<
AlertSnackbarComponent,
AlertSnackbarData
>(AlertSnackbarComponent, {
data: {
html: this.translateService.instant('common.file.errors.failToSave'),
buttonText: this.translateService.instant('common.file.errors.label')
}
});
};
this.commonApiService
.fileTalkDownload(req, fileDownloadUrl)
.pipe(
take(1),
map(rawBlob => {
const mimeType = MimeUtil.getMimeFromExtension(
FileUtil.getExtension(fileName)
);
const blob = rawBlob.slice(0, rawBlob.size, mimeType);
FileUtil.fromBlobToBuffer(blob)
.then(buffer => {
/** download check */
this.fileProtocolService
.downCheck({
seq: req.attachmentsSeq
})
.pipe(take(1))
.subscribe();
this.nativeService
.saveFile(buffer, fileName, mimeType, savePath)
.then(filePath => {
if (!!filePath) {
const snackBarRef = this.snackBarService.open(
this.translateService.instant(
'common.file.results.savedToPath',
{
path: filePath
}
),
this.translateService.instant('common.file.open'),
{
duration: 3000,
verticalPosition: 'bottom',
horizontalPosition: 'center'
}
);
snackBarRef.onAction().subscribe(() => {
snackBarRef.dismiss();
this.ngZone.runOutsideAngular(() => {
this.nativeService
.openTargetItem(filePath)
.catch(reason => {
this.logger.warn(reason);
});
});
});
} else {
fileTalkDownloadError('fail');
}
})
.catch(reason => {
fileTalkDownloadError(reason);
});
})
.catch(reason => {
fileTalkDownloadError(reason);
});
}),
finalize(() => {
if (!!fileDownloadItem) {
setTimeout(() => {
fileDownloadItem.downloadingProgress$ = undefined;
}, 1000);
}
}),
catchError(error => of(error))
)
.subscribe();
}
}

View File

@ -3,11 +3,13 @@ import { AppAuthenticationService } from './authentication.service';
import { AppLoaderService } from './loader.service'; import { AppLoaderService } from './loader.service';
import { AppNotificationService } from './notification.service'; import { AppNotificationService } from './notification.service';
import { AppNativeService } from './native.service'; import { AppNativeService } from './native.service';
import { AppFileService } from './file.service';
export const SERVICES = [ export const SERVICES = [
AppService, AppService,
AppAuthenticationService, AppAuthenticationService,
AppLoaderService, AppLoaderService,
AppNotificationService, AppNotificationService,
AppNativeService AppNativeService,
AppFileService
]; ];

View File

@ -1,10 +1,16 @@
import { createAction, props } from '@ngrx/store'; import { createAction, props } from '@ngrx/store';
import { Info, EventJson } from '@ucap-webmessenger/protocol-event'; import {
Info,
EventJson,
FileEventJson
} from '@ucap-webmessenger/protocol-event';
import { import {
MassTalkDownloadRequest, MassTalkDownloadRequest,
MassTalkDownloadResponse MassTalkDownloadResponse,
FileTalkDownloadRequest
} from '@ucap-webmessenger/api-common'; } from '@ucap-webmessenger/api-common';
import { RightDrawer } from '@app/types'; import { RightDrawer } from '@app/types';
import { FileDownloadItem } from '@ucap-webmessenger/api';
export const selectedRoom = createAction( export const selectedRoom = createAction(
'[Messenger::Chat] selectedRoom', '[Messenger::Chat] selectedRoom',

View File

@ -43,7 +43,8 @@
"notSatisfiedCombineForPassword": "Combination of two or more kinds of letters, numbers and special characters.", "notSatisfiedCombineForPassword": "Combination of two or more kinds of letters, numbers and special characters.",
"minLengthCombineForPassword": "Password must be {{lengthOfPassword}} characters if {{countOfCombine}} combination.", "minLengthCombineForPassword": "Password must be {{lengthOfPassword}} characters if {{countOfCombine}} combination.",
"failToChangePassword": "Failed to change password.", "failToChangePassword": "Failed to change password.",
"loginFail": "Username or password do not match.", "loginFailed": "Failed to login",
"loginFailedIdPw": "Username or password do not match.",
"loginFailOverTry": "Password error count exceeded. <br/> Check your password <br/> Please try again later." "loginFailOverTry": "Password error count exceeded. <br/> Check your password <br/> Please try again later."
} }
}, },
@ -183,6 +184,7 @@
"label": "Chat", "label": "Chat",
"room": "Chat room", "room": "Chat room",
"send": "Send", "send": "Send",
"sendFromClipboard": "Send from clipboard",
"searchRoomByName": "Search by room name", "searchRoomByName": "Search by room name",
"searchEventByText": "Search by chat", "searchEventByText": "Search by chat",
"searchEventByTextEnd": "Complate Search by chat", "searchEventByTextEnd": "Complate Search by chat",

View File

@ -43,7 +43,8 @@
"notSatisfiedCombineForPassword": "문자, 숫자, 특수문자 중 2종류 이상 조합을 해야 합니다", "notSatisfiedCombineForPassword": "문자, 숫자, 특수문자 중 2종류 이상 조합을 해야 합니다",
"minLengthCombineForPassword": "비밀번호는 {{countOfCombine}}가지가 조합된 경우 {{lengthOfPassword}}자를 넘어야 합니다", "minLengthCombineForPassword": "비밀번호는 {{countOfCombine}}가지가 조합된 경우 {{lengthOfPassword}}자를 넘어야 합니다",
"failToChangePassword": "비밀번호 변경에 실패하였습니다.", "failToChangePassword": "비밀번호 변경에 실패하였습니다.",
"loginFail": "아이디 또는 패스워드가<br/>일치하지 않습니다.", "loginFailed": "로그인에 실패하였습니다.",
"loginFailedIdPw": "아이디 또는 패스워드가<br/>일치하지 않습니다.",
"loginFailOverTry": "비밀번호 오류 횟수 초과입니다.<br/>비밀번호를 확인하신 후<br/>잠시 후 다시 시작해 주세요." "loginFailOverTry": "비밀번호 오류 횟수 초과입니다.<br/>비밀번호를 확인하신 후<br/>잠시 후 다시 시작해 주세요."
} }
}, },
@ -183,6 +184,7 @@
"label": "대화", "label": "대화",
"room": "대화방", "room": "대화방",
"send": "보내기", "send": "보내기",
"sendFromClipboard": "클립보드 전송",
"searchRoomByName": "대화방 이름 검색", "searchRoomByName": "대화방 이름 검색",
"searchEventByText": "대화 내용 검색", "searchEventByText": "대화 내용 검색",
"searchEventByTextEnd": "대화 검색을 마쳤습니다.", "searchEventByTextEnd": "대화 검색을 마쳤습니다.",

View File

@ -87,7 +87,6 @@
</div> </div>
<form <form
#replyForm="ngForm"
(ngSubmit)="onSend($event)" (ngSubmit)="onSend($event)"
(keydown.enter)="onSend($event)" (keydown.enter)="onSend($event)"
fxFlex fxFlex

View File

@ -37,9 +37,6 @@ export class FormComponent implements OnInit {
@Output() @Output()
clipboardPaste = new EventEmitter<ClipboardEvent>(); clipboardPaste = new EventEmitter<ClipboardEvent>();
@ViewChild('replyForm', { static: false })
replyForm: NgForm;
@ViewChild('replyInput', { static: false }) @ViewChild('replyInput', { static: false })
replyInput: ElementRef<HTMLTextAreaElement>; replyInput: ElementRef<HTMLTextAreaElement>;
@ -57,8 +54,8 @@ export class FormComponent implements OnInit {
onSend(event: Event) { onSend(event: Event) {
event.preventDefault(); event.preventDefault();
this.send.emit(this.replyForm.form.value.message); this.send.emit(this.replyInput.nativeElement.value);
this.replyForm.reset(); this.replyInput.nativeElement.value = '';
} }
onClickFileInput() { onClickFileInput() {

View File

@ -4,8 +4,8 @@ import {
Input, Input,
Output, Output,
EventEmitter, EventEmitter,
ElementRef, ChangeDetectorRef,
ViewChild ChangeDetectionStrategy
} from '@angular/core'; } from '@angular/core';
import { ucapAnimations } from '../../animations'; import { ucapAnimations } from '../../animations';
import { FileEventJson } from '@ucap-webmessenger/protocol-event'; import { FileEventJson } from '@ucap-webmessenger/protocol-event';
@ -15,7 +15,8 @@ import { FileDownloadItem } from '@ucap-webmessenger/api';
selector: 'ucap-image-viewer', selector: 'ucap-image-viewer',
templateUrl: './image-viewer.component.html', templateUrl: './image-viewer.component.html',
styleUrls: ['./image-viewer.component.scss'], styleUrls: ['./image-viewer.component.scss'],
animations: ucapAnimations animations: ucapAnimations,
changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class ImageViewerComponent implements OnInit { export class ImageViewerComponent implements OnInit {
@Input() @Input()
@ -37,7 +38,7 @@ export class ImageViewerComponent implements OnInit {
zoomRatio = 100; zoomRatio = 100;
constructor() {} constructor(private changeDetectorRef: ChangeDetectorRef) {}
ngOnInit() { ngOnInit() {
this.naturalWidth = this.fileInfo.imageWidth; this.naturalWidth = this.fileInfo.imageWidth;
@ -54,9 +55,10 @@ export class ImageViewerComponent implements OnInit {
} }
onLoadFileDownloadUrl(img: HTMLImageElement) { onLoadFileDownloadUrl(img: HTMLImageElement) {
console.log('onLoadFileDownloadUrl', img.naturalWidth, img.naturalHeight);
this.naturalWidth = img.naturalWidth; this.naturalWidth = img.naturalWidth;
this.naturalHeight = img.naturalHeight; this.naturalHeight = img.naturalHeight;
this.changeDetectorRef.detectChanges();
} }
onClickZoomOut() { onClickZoomOut() {
@ -64,14 +66,20 @@ export class ImageViewerComponent implements OnInit {
return; return;
} }
this.zoomRatio -= 10; this.zoomRatio -= 10;
this.changeDetectorRef.detectChanges();
} }
onClickZoomIn() { onClickZoomIn() {
if (180 <= this.zoomRatio) { if (180 <= this.zoomRatio) {
return; return;
} }
this.zoomRatio += 10; this.zoomRatio += 10;
this.changeDetectorRef.detectChanges();
} }
onClickZoomReset() { onClickZoomReset() {
this.zoomRatio = 100; this.zoomRatio = 100;
this.changeDetectorRef.detectChanges();
} }
} }