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 { NGXLogger } from 'ngx-logger';
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
import { DeviceType, FileUtil, MimeUtil } 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 { DeviceType } from '@ucap-webmessenger/core';
import { FileDownloadItem } from '@ucap-webmessenger/api';
import { CommonApiService } from '@ucap-webmessenger/api-common';
import { TranslateService } from '@ngx-translate/core';
import { FileProtocolService } from '@ucap-webmessenger/protocol-file';
import { AppFileService } from '@app/services/file.service';
export interface FileViewerDialogData {
fileInfo: FileEventJson;
@ -46,11 +38,8 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
FileViewerDialogResult
>,
@Inject(MAT_DIALOG_DATA) public data: FileViewerDialogData,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private translateService: TranslateService,
private snackBarService: SnackBarService,
private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
private appFileService: AppFileService,
private logger: NGXLogger
) {
this.fileInfo = data.fileInfo;
@ -75,94 +64,18 @@ export class FileViewerDialogComponent implements OnInit, OnDestroy {
ngOnDestroy(): void {}
onDownload(fileDownloadItem: FileDownloadItem): void {
this.commonApiService
.fileTalkDownload(
{
this.appFileService.fileTalkDownlod({
req: {
userSeq: this.userSeq,
deviceType: this.deviceType,
token: this.token,
attachmentsSeq: this.fileInfo.attachmentSeq,
fileDownloadItem
},
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'
)
}
fileName: this.fileInfo.fileName,
fileDownloadUrl: this.downloadUrl
});
}
})
.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 {
this.dialogRef.close();

View File

@ -8,9 +8,7 @@ import {
EventEmitter,
Inject,
ChangeDetectorRef,
ChangeDetectionStrategy,
ElementRef,
NgZone
ChangeDetectionStrategy
} from '@angular/core';
import {
ucapAnimations,
@ -24,20 +22,11 @@ import {
AlertDialogData,
AlertDialogResult,
FileUploadQueueComponent,
StringUtil,
AlertSnackbarComponent,
AlertSnackbarData
StringUtil
} from '@ucap-webmessenger/ui';
import { Store, select } from '@ngrx/store';
import { NGXLogger } from 'ngx-logger';
import {
Observable,
Subscription,
forkJoin,
combineLatest,
of,
BehaviorSubject
} from 'rxjs';
import { Observable, Subscription, forkJoin, of, BehaviorSubject } from 'rxjs';
import {
Info,
@ -78,7 +67,7 @@ import {
RoomType,
UserInfoShort
} from '@ucap-webmessenger/protocol-room';
import { tap, take, map, catchError, finalize } from 'rxjs/operators';
import { take, map, catchError } from 'rxjs/operators';
import {
FormComponent as UCapUiChatFormComponent,
MessagesComponent as UCapUiChatMessagesComponent
@ -108,7 +97,7 @@ import {
FileViewerDialogData,
FileViewerDialogResult
} 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 {
@ -131,12 +120,13 @@ import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
import { TranslateService } from '@ngx-translate/core';
import { TranslatePipe } from 'projects/ucap-webmessenger-ui/src/lib/pipes/translate.pipe';
import { TranslateService as UiTranslateService } from '@ucap-webmessenger/ui';
import { FileProtocolService } from '@ucap-webmessenger/protocol-file';
import {
ClipboardDialogComponent,
ClipboardDialogData,
ClipboardDialogResult
} from '../dialogs/chat/clipboard.dialog.component';
import { AppFileService } from '@app/services/file.service';
@Component({
selector: 'app-layout-messenger-messages',
@ -241,7 +231,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
private sessionStorageService: SessionStorageService,
private localStorageService: LocalStorageService,
private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
private clipboardService: ClipboardService,
private uiTranslateService: UiTranslateService,
private translateService: TranslateService,
@ -249,7 +238,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
private dialogService: DialogService,
private snackBarService: SnackBarService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private ngZone: NgZone,
private appFileService: AppFileService,
private logger: NGXLogger
) {
this.sessionVerInfo = this.sessionStorageService.get<VersionInfo2Response>(
@ -482,7 +471,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
// Chat Formfield Clear..
if (!!this.chatForm) {
this.chatForm.replyForm.reset();
this.chatForm.replyInput.nativeElement.value = '';
}
}
@ -693,7 +682,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
req: {
roomSeq: this.roomInfoSubject.value.roomSeq,
eventType: EventType.Character,
sentMessage: message
sentMessage: StringUtil.escapeHtml(message)
}
})
);
@ -728,7 +717,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
const stickerJson: StickerEventJson = {
name: '스티커',
file: this.selectedSticker.index,
chat: !!message ? message.trim() : ''
chat: !!message ? StringUtil.escapeHtml(message.trim()) : ''
};
this.store.dispatch(
EventStore.send({
@ -761,7 +750,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
/** Send Translation message */
sendMessageOfTranslate(message: string) {
const destLocale = this.destLocale;
const original = message;
const original = StringUtil.escapeHtml(message);
const roomSeq = this.roomInfoSubject.value.roomSeq;
if (!!this.isTranslationProcess) {
@ -1052,103 +1041,17 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
},
savePath?: string
) {
this.commonApiService
.fileTalkDownload({
this.appFileService.fileTalkDownlod({
req: {
userSeq: this.loginResSubject.value.userSeq,
deviceType: this.environmentsInfo.deviceType,
token: this.loginResSubject.value.tokenString,
attachmentsSeq: value.fileInfo.attachmentSeq,
fileDownloadItem: value.fileDownloadItem
})
.pipe(
take(1),
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);
},
fileName: value.fileInfo.fileName,
savePath
});
});
});
} 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[]) {
@ -2028,7 +1931,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
});
if (result.selected.text) {
this.onSendMessage(data.text);
this.onSendMessage(data.text.replace(/\t/g, ' '));
}
if (result.selected.image) {

View File

@ -9,15 +9,14 @@ import {
import {
FileInfo,
FileDownloadInfo,
FileType,
FileProtocolService
FileType
} from '@ucap-webmessenger/protocol-file';
import { Subscription, combineLatest } from 'rxjs';
import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store';
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 { CommonApiService } from '@ucap-webmessenger/api-common';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
@ -30,15 +29,10 @@ import {
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
import { NGXLogger } from 'ngx-logger';
import {
SnackBarService,
AlertSnackbarComponent,
AlertSnackbarData
} from '@ucap-webmessenger/ui';
import { FileDownloadItem } from '@ucap-webmessenger/api';
import { ModuleConfig } from '@ucap-webmessenger/api-common';
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 {
info: FileInfo;
@ -78,10 +72,8 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
private store: Store<any>,
private sessionStorageService: SessionStorageService,
private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
private translateService: TranslateService,
private snackBarService: SnackBarService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private appFileService: AppFileService,
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
private logger: NGXLogger
) {
@ -229,93 +221,17 @@ export class AlbumBoxComponent implements OnInit, OnDestroy {
}
onClickDownload(fileInfo: FileInfoTotal) {
this.commonApiService
.fileTalkDownload({
this.appFileService.fileTalkDownlod({
req: {
userSeq: this.loginRes.userSeq,
deviceType: this.environmentsInfo.deviceType,
token: this.loginRes.tokenString,
attachmentsSeq: fileInfo.info.seq,
fileDownloadItem: fileInfo.fileDownloadItem
})
.pipe(
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'
)
}
},
fileName: fileInfo.info.name
});
}
})
.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 {
this.selectedFileList.forEach(fileInfo => {

View File

@ -3,16 +3,16 @@ import { MatPaginator, MatTableDataSource, MatSort } from '@angular/material';
import {
FileInfo,
FileDownloadInfo,
FileType,
FileProtocolService
FileType
} from '@ucap-webmessenger/protocol-file';
import { Subscription, combineLatest } from 'rxjs';
import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store';
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 { SessionStorageService } from '@ucap-webmessenger/web-storage';
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 { FileDownloadItem } from '@ucap-webmessenger/api';
import {
SnackBarService,
DialogService,
ConfirmDialogComponent,
ConfirmDialogResult,
ConfirmDialogData,
DateOptions,
AlertSnackbarComponent,
AlertSnackbarData
DateOptions
} from '@ucap-webmessenger/ui';
import { CommonApiService } from '@ucap-webmessenger/api-common';
import { EventType } from '@ucap-webmessenger/protocol-event';
import {
CreateChatDialogComponent,
@ -43,6 +39,7 @@ import {
} from '@app/types';
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
import { TranslateService } from '@ngx-translate/core';
import { AppFileService } from '@app/services/file.service';
export interface FileInfoTotal {
info: FileInfo;
@ -78,11 +75,9 @@ export class FileBoxComponent implements OnInit, OnDestroy {
constructor(
private store: Store<any>,
private sessionStorageService: SessionStorageService,
private commonApiService: CommonApiService,
private fileProtocolService: FileProtocolService,
private translateService: TranslateService,
private snackBarService: SnackBarService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private appFileService: AppFileService,
private dialogService: DialogService,
private logger: NGXLogger
) {
@ -259,93 +254,17 @@ export class FileBoxComponent implements OnInit, OnDestroy {
}
onClickDownload(fileInfo: FileInfoTotal) {
this.commonApiService
.fileTalkDownload({
this.appFileService.fileTalkDownlod({
req: {
userSeq: this.loginRes.userSeq,
deviceType: this.environmentsInfo.deviceType,
token: this.loginRes.tokenString,
attachmentsSeq: fileInfo.info.seq,
fileDownloadItem: fileInfo.fileDownloadItem
})
.pipe(
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'
)
}
},
fileName: fileInfo.info.name
});
}
})
.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 {
this.selectedFileList.forEach(fileInfo => {

View File

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

View File

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

View File

@ -41,7 +41,6 @@ import {
LoginResponse
} from '@ucap-webmessenger/protocol-authentication';
import * as AuthenticationStore from '@app/store/account/authentication';
import { NGXLogger } from 'ngx-logger';
import {
QueryProtocolService,
@ -52,6 +51,7 @@ import { OptionProtocolService } from '@ucap-webmessenger/protocol-option';
import { TranslateService as UCapTranslateService } from '@ucap-webmessenger/ui';
import * as AppStore from '@app/store';
import * as AuthenticationStore from '@app/store/account/authentication';
import * as CompanyStore from '@app/store/setting/company';
import * as VersionInfoStore from '@app/store/setting/version-info';
import * as OptionStore from '@app/store/messenger/option';
@ -72,6 +72,7 @@ import {
import { StatusCode } from '@ucap-webmessenger/api';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type';
import { TranslateService } from '@ngx-translate/core';
@Injectable()
export class AppMessengerResolver implements Resolve<void> {
@ -89,6 +90,7 @@ export class AppMessengerResolver implements Resolve<void> {
private innerProtocolService: InnerProtocolService,
private appNativeService: AppNativeService,
private snackBarService: SnackBarService,
private translateService: TranslateService,
private logger: NGXLogger
) {}
@ -185,6 +187,7 @@ export class AppMessengerResolver implements Resolve<void> {
})
.pipe(
catchError(err => {
this.logger.error('ServerErrorCode', err);
switch (err as ServerErrorCode) {
case ServerErrorCode.ERRCD_IDPW:
break;
@ -285,6 +288,17 @@ export class AppMessengerResolver implements Resolve<void> {
resolve();
},
err => {
this.snackBarService.open(
this.translateService.instant('accounts.errors.loginFailed'),
'',
{
duration: 3000,
verticalPosition: 'bottom',
horizontalPosition: 'center'
}
);
this.store.dispatch(AuthenticationStore.loginRedirect());
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 { TranslateService } from '@ngx-translate/core';
import { EnviromentsService } from '@ucap-webmessenger/enviroments';
import { NGXLogger } from 'ngx-logger';
import { NGXLogger, NgxLoggerLevel } from 'ngx-logger';
import { environment } from '../../environments/environment';
@Injectable()
export class AppService {
@ -33,6 +35,10 @@ export class AppService {
this.ucapDateService.setDefaultTimezone('Asia/Seoul');
this.ucapDateService.use('Asia/Seoul');
this.ucapDateService.setLocale(this.translateService.currentLang);
this.logger.updateConfig({
level: environment.production ? NgxLoggerLevel.WARN : NgxLoggerLevel.DEBUG
});
}
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 { AppNotificationService } from './notification.service';
import { AppNativeService } from './native.service';
import { AppFileService } from './file.service';
export const SERVICES = [
AppService,
AppAuthenticationService,
AppLoaderService,
AppNotificationService,
AppNativeService
AppNativeService,
AppFileService
];

View File

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

View File

@ -43,7 +43,8 @@
"notSatisfiedCombineForPassword": "Combination of two or more kinds of letters, numbers and special characters.",
"minLengthCombineForPassword": "Password must be {{lengthOfPassword}} characters if {{countOfCombine}} combination.",
"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."
}
},
@ -183,6 +184,7 @@
"label": "Chat",
"room": "Chat room",
"send": "Send",
"sendFromClipboard": "Send from clipboard",
"searchRoomByName": "Search by room name",
"searchEventByText": "Search by chat",
"searchEventByTextEnd": "Complate Search by chat",

View File

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

View File

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

View File

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

View File

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