This commit is contained in:
병준 박 2019-11-25 16:48:13 +09:00
commit 664a92781f
12 changed files with 235 additions and 83 deletions

View File

@ -148,10 +148,34 @@ export const decodeRetrieveReservation: APIDecoder<RetrieveResponse> = (
export const decodeRetrieveSearch: APIDecoder<RetrieveResponse> = ( export const decodeRetrieveSearch: APIDecoder<RetrieveResponse> = (
res: any res: any
) => { ) => {
const messageList: MessageList[] = [];
if (!!res.msgList && res.msgList.length > 0) {
for (const msgList of res.msgList) {
messageList.push({
...msgList,
userCount:
!msgList.userCount || msgList.userCount === null
? 0
: msgList.userCount,
userReadCount:
!msgList.userReadCount || msgList.userReadCount === null
? 0
: msgList.userReadCount,
titleYn: msgList.titleYn === 'Y' ? true : false,
attachmentYn: msgList.attachmentYn === 'Y' ? true : false
} as MessageList);
}
}
return { return {
responseCode: res.responseCode, responseCode: res.responseCode,
responseMsg: res.responseMsg, responseMsg: res.responseMsg,
pageCount: res.pageCount,
pageSize: res.pageSize,
totalCount: res.totalCount, totalCount: res.totalCount,
messageList: []
messageList
} as RetrieveResponse; } as RetrieveResponse;
}; };

View File

@ -0,0 +1,5 @@
export enum MessageSearchType {
Title = 'T',
Name = 'N',
Contents = 'C'
}

View File

@ -1,5 +1,6 @@
export enum MessageType { export enum MessageType {
Send = 'S', Send = 'S',
Receive = 'R', Receive = 'R',
Reservation = 'B' Reservation = 'B',
All = 'A'
} }

View File

@ -17,6 +17,7 @@ export * from './lib/models/message-list';
export * from './lib/types/category.type'; export * from './lib/types/category.type';
export * from './lib/types/content.type'; export * from './lib/types/content.type';
export * from './lib/types/message.search.type';
export * from './lib/types/message.type'; export * from './lib/types/message.type';
export * from './lib/config/urls'; export * from './lib/config/urls';

View File

@ -37,7 +37,7 @@
</form> </form>
</div> </div>
</div> </div>
<div> <div *ngIf="!isSearch">
<mat-tab-group <mat-tab-group
#tabs #tabs
mat-stretch-tabs mat-stretch-tabs
@ -143,4 +143,56 @@
</mat-tab> </mat-tab>
</mat-tab-group> </mat-tab-group>
</div> </div>
<div *ngIf="isSearch">
<div class="search-sub">
<form [formGroup]="fgSearchType" class="w-100-p">
<mat-form-field>
<mat-select formControlName="searchMessageType" (selectionChange)="onChangeSelection($event)">
<mat-option [value]="MessageType.All">전체</mat-option>
<mat-option [value]="MessageType.Receive">수신</mat-option>
<mat-option [value]="MessageType.Send">발신</mat-option>
<mat-option [value]="MessageType.Reservation">예약</mat-option>
</mat-select>
</mat-form-field>
<mat-radio-group
formControlName="searchMessageSearchType"
aria-label="Select an searchType"
(change)="onChangeSearchType($event)"
>
<mat-radio-button [value]="MessageSearchType.Name" [checked]="true"
>이름</mat-radio-button
>
<mat-radio-button [value]="MessageSearchType.Title"
>제목</mat-radio-button
>
<mat-radio-button [value]="MessageSearchType.Contents"
>내용</mat-radio-button
>
</mat-radio-group>
</form>
</div>
<div *ngFor="let message of messageList">
<dl>
<dt>
<mat-icon
*ngIf="!!message.resType && message.resType === ContentType.Image"
>image</mat-icon
>
<mat-icon
*ngIf="
!!message.resType && message.resType === ContentType.AttachFile
"
>attach_file</mat-icon
>
<ul>
<li>{{ message.userName }}</li>
<li>{{ message.title }}</li>
</ul>
</dt>
<dd>
{{ message.regDate | dateToStringFormat: 'MM:DD' }}
</dd>
</dl>
</div>
</div>
</div> </div>

View File

@ -25,13 +25,19 @@ import {
MessageApiService, MessageApiService,
MessageType, MessageType,
RetrieveRequest, RetrieveRequest,
MessageList MessageList,
RetrieveSearchRequest,
MessageSearchType
} from '@ucap-webmessenger/api-message'; } from '@ucap-webmessenger/api-message';
import { DeviceType } from '@ucap-webmessenger/core'; import { DeviceType } from '@ucap-webmessenger/core';
import { MessageStatusCode } from '@ucap-webmessenger/api'; import { MessageStatusCode } from '@ucap-webmessenger/api';
import { ContentType } from '@ucap-webmessenger/api-message'; import { ContentType } from '@ucap-webmessenger/api-message';
import { FormGroup, FormBuilder } from '@angular/forms'; import { FormGroup, FormBuilder } from '@angular/forms';
import { MatTabGroup } from '@angular/material'; import {
MatTabGroup,
MatSelectChange,
MatRadioChange
} from '@angular/material';
@Component({ @Component({
selector: 'app-layout-chat-left-sidenav-message', selector: 'app-layout-chat-left-sidenav-message',
@ -47,9 +53,7 @@ export class MessageBoxComponent
isInitTabs = false; isInitTabs = false;
fgSearch: FormGroup; fgSearch: FormGroup;
fgSearchType: FormGroup;
userInfoList: UserInfo[];
userInfoListSubscription: Subscription;
loginRes: LoginResponse; loginRes: LoginResponse;
sessionVerinfo: VersionInfo2Response; sessionVerinfo: VersionInfo2Response;
@ -72,6 +76,9 @@ export class MessageBoxComponent
ContentType = ContentType; ContentType = ContentType;
MessageType = MessageType; MessageType = MessageType;
MessageSearchType = MessageSearchType;
isSearch = false;
constructor( constructor(
private store: Store<any>, private store: Store<any>,
@ -92,15 +99,10 @@ export class MessageBoxComponent
this.fgSearch = this.formBuilder.group({ this.fgSearch = this.formBuilder.group({
searchInput: null searchInput: null
}); });
this.fgSearchType = this.formBuilder.group({
this.userInfoListSubscription = this.store searchMessageType: [MessageType.All],
.pipe( searchMessageSearchType: [MessageSearchType.Name]
select(AppStore.MessengerSelector.RoomSelector.selectUserinfolist), });
tap(userInfoList => {
this.userInfoList = userInfoList;
})
)
.subscribe();
// 초기 검색은 수신함. // 초기 검색은 수신함.
this.getRetrieveMessage(MessageType.Receive, this.recieveCurrentPage); this.getRetrieveMessage(MessageType.Receive, this.recieveCurrentPage);
@ -118,9 +120,6 @@ export class MessageBoxComponent
} }
ngOnDestroy(): void { ngOnDestroy(): void {
if (!!this.userInfoListSubscription) {
this.userInfoListSubscription.unsubscribe();
}
if (!!this.messageRecieveListSubscription) { if (!!this.messageRecieveListSubscription) {
this.messageRecieveListSubscription.unsubscribe(); this.messageRecieveListSubscription.unsubscribe();
} }
@ -161,12 +160,74 @@ export class MessageBoxComponent
} }
} }
onChangeSelection(event: MatSelectChange) {
this.searchCurrentPage = 0;
this.getSearchMessage(
event.value,
this.fgSearchType.get('searchMessageSearchType').value,
this.fgSearch.get('searchInput').value
);
}
onChangeSearchType(event: MatRadioChange) {
this.searchCurrentPage = 0;
this.getSearchMessage(
this.fgSearchType.get('searchMessageType').value,
event.value,
this.fgSearch.get('searchInput').value
);
}
onKeyDownEnter(event: KeyboardEvent, search: string) { onKeyDownEnter(event: KeyboardEvent, search: string) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
this.searchCurrentPage = 0;
this.getSearchMessage(
MessageType.All,
MessageSearchType.Name,
search.trim()
);
}
getSearchMessage(
messageType: MessageType,
searchType: MessageSearchType,
searchStr: string
) {
this.isSearch = true;
this.messageSendListSubscription = this.messageApiService
.retrieveSearchMessage({
userSeq: this.loginRes.userSeq,
deviceType: DeviceType.PC,
tokenKey: this.loginRes.tokenString,
type: messageType,
pageSize: this.defaultPageSize,
pageCount: this.searchCurrentPage,
searchTitle: searchType === MessageSearchType.Title ? searchStr : '',
searchName: searchType === MessageSearchType.Name ? searchStr : '',
searchContent:
searchType === MessageSearchType.Contents ? searchStr : ''
} as RetrieveSearchRequest)
.pipe(
map(res => {
console.log(res);
if (res.responseCode === MessageStatusCode.Success) {
this.currentTotalCount = res.totalCount;
this.currentPage = res.pageCount;
this.searchCurrentPage = res.pageCount;
this.messageList = res.messageList;
} else {
}
}),
catchError(error => of(console.log(error)))
)
.subscribe();
} }
onClickSearchCancel() {} onClickSearchCancel() {
this.isSearch = false;
this.getRetrieveMessage(MessageType.Receive, this.recieveCurrentPage);
}
getRetrieveMessage(type: MessageType, trgtPageIndex: number) { getRetrieveMessage(type: MessageType, trgtPageIndex: number) {
switch (type) { switch (type) {

View File

@ -43,12 +43,16 @@ import * as ChatStore from '@app/store/messenger/chat';
import * as RoomStore from '@app/store/messenger/room'; import * as RoomStore from '@app/store/messenger/room';
import * as SyncStore from '@app/store/messenger/sync'; import * as SyncStore from '@app/store/messenger/sync';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import {
SessionStorageService,
LocalStorageService
} from '@ucap-webmessenger/web-storage';
import { import {
EnvironmentsInfo, EnvironmentsInfo,
KEY_ENVIRONMENTS_INFO, KEY_ENVIRONMENTS_INFO,
UserSelectDialogType, UserSelectDialogType,
RightDrawer RightDrawer,
KEY_STICKER_HISTORY
} from '@app/types'; } from '@app/types';
import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room'; import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room';
import { tap, take, map, catchError } from 'rxjs/operators'; import { tap, take, map, catchError } from 'rxjs/operators';
@ -83,7 +87,9 @@ import {
CONST, CONST,
FileUtil, FileUtil,
StickerFilesInfo, StickerFilesInfo,
StickerUtil StickerUtil,
StickerInfo,
StickerMap
} from '@ucap-webmessenger/core'; } from '@ucap-webmessenger/core';
import { PerfectScrollbarComponent } from 'ngx-perfect-scrollbar'; import { PerfectScrollbarComponent } from 'ngx-perfect-scrollbar';
import { StatusCode } from '@ucap-webmessenger/api'; import { StatusCode } from '@ucap-webmessenger/api';
@ -162,6 +168,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
constructor( constructor(
private store: Store<any>, private store: Store<any>,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private localStorageService: LocalStorageService,
private commonApiService: CommonApiService, private commonApiService: CommonApiService,
private clipboardService: ClipboardService, private clipboardService: ClipboardService,
private dialogService: DialogService, private dialogService: DialogService,
@ -198,7 +205,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
select(AppStore.MessengerSelector.RoomSelector.roomInfo), select(AppStore.MessengerSelector.RoomSelector.roomInfo),
tap(roomInfo => { tap(roomInfo => {
this.roomInfo = roomInfo; this.roomInfo = roomInfo;
this.clearView();
this.setEventMoreInit(); this.setEventMoreInit();
}) })
) )
@ -535,7 +542,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
}) })
); );
this.isShowStickerSelector = false; this.isShowStickerSelector = false;
StickerUtil.setStickerHistory(this.selectedSticker); this.setStickerHistory(this.selectedSticker);
} else if (message.trim().length > CONST.MASSTEXT_LEN) { } else if (message.trim().length > CONST.MASSTEXT_LEN) {
// MASS TEXT // MASS TEXT
this.store.dispatch( this.store.dispatch(
@ -1091,4 +1098,24 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
onSelectedSticker(stickerInfo: StickerFilesInfo) { onSelectedSticker(stickerInfo: StickerFilesInfo) {
this.selectedSticker = stickerInfo; this.selectedSticker = stickerInfo;
} }
setStickerHistory(sticker: StickerFilesInfo) {
const history = this.localStorageService.get<string[]>(KEY_STICKER_HISTORY);
if (!!history && history.length > 0) {
const stickers: string[] = [];
[sticker.index, ...history.filter(hist => hist !== sticker.index)].map(
(s, i) => {
if (i < 10) {
stickers.push(s);
}
}
);
this.localStorageService.set<string[]>(KEY_STICKER_HISTORY, stickers);
} else {
this.localStorageService.set<string[]>(KEY_STICKER_HISTORY, [
sticker.index
]);
}
}
} }

View File

@ -2,3 +2,4 @@ export * from './environment.type';
export * from './login-info.type'; export * from './login-info.type';
export * from './userselect.dialog.type'; export * from './userselect.dialog.type';
export * from './right-drawer.type'; export * from './right-drawer.type';
export * from './sticker-info.type';

View File

@ -0,0 +1 @@
export const KEY_STICKER_HISTORY = 'ucap::Sticker_History';

View File

@ -1,5 +1,3 @@
import { LocalStorageService } from '@ucap-webmessenger/web-storage';
export interface StickerInfo { export interface StickerInfo {
index: string; index: string;
title: string; title: string;
@ -12,7 +10,7 @@ export interface StickerFilesInfo {
index: string; index: string;
path: string; path: string;
} }
const StickerMap: StickerInfo[] = [ export const StickerMap: StickerInfo[] = [
{ {
index: '00', index: '00',
title: 'History', title: 'History',
@ -152,11 +150,6 @@ export class StickerUtil {
); );
if (!!stickerInfos && stickerInfos.length > 0) { if (!!stickerInfos && stickerInfos.length > 0) {
if (idx === '00') {
// history.
stickerInfos[0].fileInfos = this.getStickerHistory();
}
rtnStickerList.push(stickerInfos[0]); rtnStickerList.push(stickerInfos[0]);
} }
}); });
@ -176,50 +169,4 @@ export class StickerUtil {
return stickerFilesList; return stickerFilesList;
} }
static setStickerHistory(sticker: StickerFilesInfo) {
const localStorageService = new LocalStorageService();
const history = localStorageService.get<string[]>('ucap::Sticker_History');
if (!!history && history.length > 0) {
const stickers: string[] = [];
[sticker.index, ...history.filter(hist => hist !== sticker.index)].map(
(s, i) => {
if (i < 10) {
stickers.push(s);
}
}
);
localStorageService.set<string[]>('ucap::Sticker_History', stickers);
} else {
localStorageService.set<string[]>('ucap::Sticker_History', [
sticker.index
]);
}
}
static getStickerHistory(): StickerFilesInfo[] {
const rtnArray: StickerFilesInfo[] = [];
const localStorageService = new LocalStorageService();
const history = localStorageService.get<string[]>('ucap::Sticker_History');
if (!!history && history.length > 0) {
history.forEach(sticker => {
const arr: string[] = sticker.split('_');
if (arr.length === 2) {
const sInfo: StickerInfo[] = StickerMap.filter(
stickerInfo => stickerInfo.index === arr[0]
);
if (!!sInfo && sInfo.length > 0) {
rtnArray.push(
...sInfo[0].fileInfos.filter(
fileInfo => fileInfo.index === sticker
)
);
}
}
});
}
return rtnArray;
}
} }

View File

@ -27,7 +27,7 @@
</ng-template> </ng-template>
<div fxFlex fxLayout="row" fxLayoutGap="10px"> <div fxFlex fxLayout="row" fxLayoutGap="10px">
<div <div
*ngFor="let sticker of stickerInfo.fileInfos" *ngFor="let sticker of getStickerInfos(stickerInfo)"
(click)="onClickSelectSticker(sticker)" (click)="onClickSelectSticker(sticker)"
class="sticker-item" class="sticker-item"
> >

View File

@ -2,8 +2,11 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { import {
StickerInfo, StickerInfo,
StickerFilesInfo, StickerFilesInfo,
StickerUtil StickerUtil,
StickerMap
} from '@ucap-webmessenger/core'; } from '@ucap-webmessenger/core';
import { LocalStorageService } from '@ucap-webmessenger/web-storage';
import { KEY_STICKER_HISTORY } from '@app/types';
@Component({ @Component({
selector: 'ucap-sticker-selector', selector: 'ucap-sticker-selector',
@ -21,7 +24,7 @@ export class StickerSelectorComponent implements OnInit {
currentTabIndex: number; currentTabIndex: number;
constructor() {} constructor(private localStorageService: LocalStorageService) {}
ngOnInit() { ngOnInit() {
this.stickerInfoList = StickerUtil.getStickerInfoList(); this.stickerInfoList = StickerUtil.getStickerInfoList();
@ -48,6 +51,35 @@ export class StickerSelectorComponent implements OnInit {
} }
} }
getStickerInfos(stickerInfo: StickerInfo) {
if (stickerInfo.index === '00') {
const rtnArray: StickerFilesInfo[] = [];
const history = this.localStorageService.get<string[]>(
KEY_STICKER_HISTORY
);
if (!!history && history.length > 0) {
history.forEach(sticker => {
const arr: string[] = sticker.split('_');
if (arr.length === 2) {
const sInfo: StickerInfo[] = StickerMap.filter(
s => s.index === arr[0]
);
if (!!sInfo && sInfo.length > 0) {
rtnArray.push(
...sInfo[0].fileInfos.filter(
fileInfo => fileInfo.index === sticker
)
);
}
}
});
}
return rtnArray;
} else {
return stickerInfo.fileInfos;
}
}
getStickerContentsImage(sticker: StickerFilesInfo) { getStickerContentsImage(sticker: StickerFilesInfo) {
return this.stickerBasePath + sticker.path; return this.stickerBasePath + sticker.path;
} }