diff --git a/projects/ucap-webmessenger-api-message/src/lib/apis/send.ts b/projects/ucap-webmessenger-api-message/src/lib/apis/send.ts index 39d9559f..0518b8b6 100644 --- a/projects/ucap-webmessenger-api-message/src/lib/apis/send.ts +++ b/projects/ucap-webmessenger-api-message/src/lib/apis/send.ts @@ -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 = ( export const decodeSend: APIDecoder = (res: any) => { return { - responseCode: res.responseCode, + responseCode: res.responseCode as MessageStatusCode, responseMsg: res.responseMsg } as SendResponse; }; diff --git a/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts b/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts index 7f0be966..f43d5bc2 100644 --- a/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts +++ b/projects/ucap-webmessenger-api-message/src/lib/services/message-api.service.ts @@ -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(); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts index ff44f3f2..25f3c2e8 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts @@ -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', diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-write.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-write.dialog.component.ts index c388fa50..30642ab0 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-write.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/message/message-write.dialog.component.ts @@ -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( 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 59d313b6..5f5e39a0 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 @@ -4,7 +4,11 @@
DS Talk
- +
- + + {{ inputTitle.value?.length || 0 }}/100