This commit is contained in:
richard-loafle 2020-01-30 14:13:00 +09:00
commit 20fa760578
13 changed files with 243 additions and 87 deletions

View File

@ -603,7 +603,10 @@ ipcMain.on(
dialog
.showSaveDialog({ defaultPath: args[0] })
.then(obj => {
event.returnValue = obj.filePath;
event.returnValue = {
canceled: obj.canceled,
filePath: obj.filePath
};
})
.catch(obj => {
event.returnValue = undefined;

View File

@ -4,7 +4,8 @@ import {
APIJsonEncoder,
APIDecoder,
APIFormDataEncoder,
ParameterUtil
ParameterUtil,
MessageStatusCode
} from '@ucap-webmessenger/api';
import { DeviceType } from '@ucap-webmessenger/core';
import { MessageType } from '../types/message.type';
@ -82,7 +83,7 @@ export const encodeSend: APIFormDataEncoder<SendRequest> = (
export const decodeSend: APIDecoder<SendResponse> = (res: any) => {
return {
responseCode: res.responseCode,
responseCode: res.responseCode as MessageStatusCode,
responseMsg: res.responseMsg
} as SendResponse;
};

View File

@ -168,7 +168,7 @@ export class MessageApiService {
'POST',
this.urls.sendNewMessage,
encodeSend(req),
{ reportProgress: true, responseType: 'text' as 'json' }
{ reportProgress: true }
);
const progress = req.fileUploadItem.uploadStart();
@ -196,7 +196,7 @@ export class MessageApiService {
'POST',
this.urls.editReservationMessageEx,
encodeEditReservation(req),
{ reportProgress: true, responseType: 'text' as 'json' }
{ reportProgress: true }
);
const progress = req.fileUploadItem.uploadStart();

View File

@ -1,57 +1,20 @@
import { UserSelectDialogType } from '../../../types/userselect.dialog.type';
import {
Component,
OnInit,
Output,
EventEmitter,
ViewChildren,
QueryList,
ElementRef,
OnDestroy,
ViewChild
} from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui';
import {
CreateChatDialogComponent,
CreateChatDialogData,
CreateChatDialogResult
} from '@app/layouts/messenger/dialogs/chat/create-chat.dialog.component';
import { Subscription, Observable, merge } from 'rxjs';
import { ucapAnimations } from '@ucap-webmessenger/ui';
import { Subscription, Observable, } from 'rxjs';
import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store';
import * as ChatStore from '@app/store/messenger/chat';
import * as MessageStore from '@app/store/messenger/message';
import * as SyncStore from '@app/store/messenger/sync';
import * as SettingsStore from '@app/store/messenger/settings';
import { UserInfo } from '@ucap-webmessenger/protocol-sync';
import {
UserInfoSS,
UserInfoF,
UserInfoDN
} from '@ucap-webmessenger/protocol-query';
import { MatTabChangeEvent } from '@angular/material';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { OpenProfileOptions } from '@ucap-webmessenger/protocol-buddy';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { MessageType } from '@ucap-webmessenger/api-message';
import { tap } from 'rxjs/operators';
import {
MessageWriteDialogComponent,
MessageWriteDialogResult,
MessageWriteDialogData
} from '../dialogs/message/message-write.dialog.component';
import {
EnvironmentsInfo,
KEY_ENVIRONMENTS_INFO,
KEY_VER_INFO,
MainMenu
} from '@app/types';
import { MessageBoxComponent } from './left-sidenav/message.component';
import { environment } from '../../../../environments/environment';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'app-layout-messenger-left-nav',

View File

@ -918,15 +918,19 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
this.nativeService
.selectSaveFilePath(value.fileInfo.fileName)
.then(result => {
if (!!result && result.length > 0) {
this.saveFile(value, result);
if (!!result && result.filePath.length > 0) {
this.saveFile(value, result.filePath);
} else {
this.snackBarService.open(
this.translateService.instant(
'common.file.errors.failToSpecifyPath'
),
this.translateService.instant('common.file.errors.label')
);
if (!!result && result.canceled) {
// ignore..
} else {
this.snackBarService.open(
this.translateService.instant(
'common.file.errors.failToSpecifyPath'
),
this.translateService.instant('common.file.errors.label')
);
}
}
})
.catch(reason => {

View File

@ -1,7 +1,13 @@
import { Component, OnInit, Inject, ViewChild } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { DialogService, SnackBarService } from '@ucap-webmessenger/ui';
import {
DialogService,
SnackBarService,
AlertDialogComponent,
AlertDialogResult,
AlertDialogData
} from '@ucap-webmessenger/ui';
import {
DetailResponse,
@ -32,13 +38,14 @@ import {
EnvironmentsInfo,
KEY_VER_INFO
} from '@app/types';
import { take } from 'rxjs/operators';
import { take, tap } from 'rxjs/operators';
import { UserInfoSS } from '@ucap-webmessenger/protocol-query';
import { TranslateService } from '@ngx-translate/core';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { environment } from '../../../../../environments/environment';
import { EmployeeType } from '@ucap-webmessenger/protocol-room';
import { MessageStatusCode } from '@ucap-webmessenger/api';
export interface MessageWriteDialogData {
loginRes: LoginResponse;
@ -155,23 +162,93 @@ export class MessageWriteDialogComponent implements OnInit {
.pipe(take(1))
.subscribe(
res => {
let msg = '';
if (!!message.reservationTime) {
msg = this.translateService.instant(
'message.results.successForReservation'
);
if (!!res && res.responseCode === MessageStatusCode.Success) {
let msg = '';
if (!!message.reservationTime) {
msg = this.translateService.instant(
'message.results.successForReservation'
);
} else {
msg = this.translateService.instant(
'message.results.successForSending'
);
}
this.snackBarService.open(msg, '', {
duration: 3000,
verticalPosition: 'bottom'
});
this.dialogRef.close({ sendFlag: true, sendType: message.type });
} else {
msg = this.translateService.instant(
'message.results.successForSending'
);
let alertType = 'S';
let errorMsg =
this.translateService.instant('message.errors.failToSending') +
`(${res.responseCode})`;
switch (res.responseCode) {
case MessageStatusCode.Fail_Msg_Reservation_Time_Null:
errorMsg = this.translateService.instant(
'message.errors.failToReservationTimeEmpty'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Msg_Title_length:
errorMsg = this.translateService.instant(
'message.errors.failToTitleLength'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Msg_Reservation_Time_Less:
case MessageStatusCode.Fail_Msg_Edit_Reservation_Time_Less:
errorMsg = this.translateService.instant(
'message.errors.failToReservationTimeLess'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Msg_Edit_Cancel_Reservation_Sended:
errorMsg = this.translateService.instant(
'message.errors.failToReservationSended'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_File_Size:
errorMsg = this.translateService.instant(
'message.errors.failToFileSize'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_File_Ext:
errorMsg = this.translateService.instant(
'message.errors.failToFileExt'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Cancelled_Msg:
errorMsg = this.translateService.instant(
'message.errors.failToCancelled'
);
alertType = 'A';
break;
}
if (alertType === 'S') {
this.snackBarService.open(errorMsg, '', {
duration: 3000,
verticalPosition: 'bottom'
});
} else {
this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
data: {
title: this.translateService.instant('message.errors.label'),
message: errorMsg
}
});
}
}
this.snackBarService.open(msg, '', {
duration: 3000,
verticalPosition: 'bottom'
});
this.dialogRef.close({ sendFlag: true, sendType: message.type });
},
error => {
this.snackBarService.open(
@ -199,18 +276,88 @@ export class MessageWriteDialogComponent implements OnInit {
.pipe(take(1))
.subscribe(
res => {
this.snackBarService.open(
this.translateService.instant(
'message.results.successForModifying'
),
'',
{
duration: 3000,
verticalPosition: 'bottom'
}
);
if (!!res && res.responseCode === MessageStatusCode.Success) {
this.snackBarService.open(
this.translateService.instant(
'message.results.successForModifying'
),
'',
{
duration: 3000,
verticalPosition: 'bottom'
}
);
this.dialogRef.close({ sendFlag: true, sendType: message.type });
this.dialogRef.close({ sendFlag: true, sendType: message.type });
} else {
let alertType = 'S';
let errorMsg =
this.translateService.instant('message.errors.failToSending') +
`(${res.responseCode})`;
switch (res.responseCode) {
case MessageStatusCode.Fail_Msg_Reservation_Time_Null:
errorMsg = this.translateService.instant(
'message.errors.failToReservationTimeEmpty'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Msg_Title_length:
errorMsg = this.translateService.instant(
'message.errors.failToTitleLength'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Msg_Reservation_Time_Less:
case MessageStatusCode.Fail_Msg_Edit_Reservation_Time_Less:
errorMsg = this.translateService.instant(
'message.errors.failToReservationTimeLess'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Msg_Edit_Cancel_Reservation_Sended:
errorMsg = this.translateService.instant(
'message.errors.failToReservationSended'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_File_Size:
errorMsg = this.translateService.instant(
'message.errors.failToFileSize'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_File_Ext:
errorMsg = this.translateService.instant(
'message.errors.failToFileExt'
);
alertType = 'A';
break;
case MessageStatusCode.Fail_Cancelled_Msg:
errorMsg = this.translateService.instant(
'message.errors.failToCancelled'
);
alertType = 'A';
break;
}
if (alertType === 'S') {
this.snackBarService.open(errorMsg, '', {
duration: 3000,
verticalPosition: 'bottom'
});
} else {
this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
data: {
title: this.translateService.instant('message.errors.label'),
message: errorMsg
}
});
}
}
},
error => {
this.snackBarService.open(

View File

@ -149,7 +149,10 @@
</svg>
</button>
</div>
<span *ngIf="(!!weblink && weblink.length > 0) || (updateInfo$ | async)" class="stroke-bar"></span>
<span
*ngIf="(!!weblink && weblink.length > 0) || (updateInfo$ | async)"
class="stroke-bar"
></span>
<ucap-profile-my-profile-widget
[profileImageRoot]="sessionVerinfo.profileRoot"
[profileImageFile]="getMyProfileImageWidget()"

View File

@ -327,6 +327,13 @@
"label": "Message error",
"failToSending": "The message failed to send.",
"failToModify": "The message failed to modify.",
"failToReservationTimeEmpty": "No reservation time is specified.",
"failToTitleLength": "Title is too long",
"failToReservationTimeLess": "Reservation time can not be sent within 10 minutes.",
"failToReservationSended": "You can't edit a message that has already been sent.",
"failToFileSize": "The file you are uploading is larger than the limit.",
"failToFileExt": "The file you uploaded contains restricted files.",
"failToCancelled": "This message has been canceled.",
"minTimeReservation": "It can be set only 30 minutes after the current time.",
"cancelledError": "The message failed to cancel.",
"cancelledMessage": "This message has been cancelled."

View File

@ -327,6 +327,13 @@
"label": "쪽지 에러",
"failToSending": "쪽지를 전송에 실패 하였습니다.",
"failToModify": "쪽지 수정에 실패 하였습니다.",
"failToReservationTimeEmpty": "예약시간이 지정되어 있지 않습니다.",
"failToTitleLength": "제목이 너무 길게 입력되었습니다.",
"failToReservationTimeLess": "예약시간이 현재시간 기준 10분 이내에는 보낼수 없습니다.",
"failToReservationSended": "이미 발송된 메시지는 수정할 수 없습니다.",
"failToFileSize": "업로드 하는 파일의 용량이 제한크기보다 큽니다.",
"failToFileExt": "업로드 하는 파일에 제한된 파일이 포함되었습니다.",
"failToCancelled": "발송 취소된 메시지 입니다.",
"minTimeReservation": "현재 시각으로부터 30분 이후로만 설정 가능합니다.",
"cancelledError": "발송 취소에 실패 하였습니다.",
"cancelledMessage": "발송 취소된 쪽지 입니다."

View File

@ -187,9 +187,18 @@ export class BrowserNativeService extends NativeService {
});
}
selectSaveFilePath(defaultPath?: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
resolve('');
selectSaveFilePath(defaultPath?: string): Promise<{
canceled: boolean,
filePath: string
}> {
return new Promise<{
canceled: boolean,
filePath: string
}>((resolve, reject) => {
resolve({
canceled: false,
filePath: ''
});
});
}

View File

@ -309,8 +309,14 @@ export class ElectronNativeService implements NativeService {
});
}
selectSaveFilePath(defaultPath?: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
selectSaveFilePath(defaultPath?: string): Promise<{
canceled: boolean,
filePath: string
}> {
return new Promise<{
canceled: boolean,
filePath: string
}>((resolve, reject) => {
try {
resolve(
this.ipcRenderer.sendSync(FileChannel.SelectSaveFilePath, defaultPath)

View File

@ -59,7 +59,10 @@ export abstract class NativeService {
abstract openTargetItem(filePath?: string): Promise<boolean>;
abstract getPath(name: NativePathName): Promise<string>;
abstract selectDirectory(): Promise<string>;
abstract selectSaveFilePath(defaultPath?: string): Promise<string>;
abstract selectSaveFilePath(defaultPath?: string): Promise<{
canceled: boolean,
filePath: string
}>;
abstract executeProcess(executableName: string): Promise<number>;

View File

@ -58,9 +58,12 @@
<mat-form-field class="message-title">
<input
matInput
#inputTitle
formControlName="title"
placeholder="{{ 'message.fieldTitle' | translate }}"
maxlength="100"
/>
<mat-hint align="end">{{ inputTitle.value?.length || 0 }}/100</mat-hint>
</mat-form-field>
<div class="message-content">