From d2032c462540c6ed6ffdbf7bcec581d2760e3330 Mon Sep 17 00:00:00 2001 From: leejinho Date: Wed, 29 Jan 2020 09:58:40 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=201=EC=B0=A8=20=EC=BB=A4=EB=B0=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/layouts/messenger/dialogs/index.ts | 2 + .../layouts/messenger/dialogs/search/index.ts | 3 + .../integrated-search.dialog.component.html | 11 + .../integrated-search.dialog.component.scss | 0 ...integrated-search.dialog.component.spec.ts | 25 ++ .../integrated-search.dialog.component.ts | 152 ++++++++++++ .../native/components/top-bar.component.html | 4 +- .../native/components/top-bar.component.ts | 17 ++ .../src/assets/i18n/en.json | 14 ++ .../src/assets/i18n/ko.json | 14 ++ .../integrated-search-form.component.html | 12 + .../integrated-search-form.component.scss | 3 + .../integrated-search-form.component.spec.ts | 27 +++ .../integrated-search-form.component.ts | 31 +++ .../integrated-search.component.html | 221 ++++++++++++++++++ .../integrated-search.component.scss | 106 +++++++++ .../integrated-search.component.spec.ts | 27 +++ .../components/integrated-search.component.ts | 108 +++++++++ .../src/lib/ucap-ui.module.ts | 13 +- 19 files changed, 788 insertions(+), 2 deletions(-) create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/index.ts create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.html create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.scss create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.spec.ts create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.ts create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search-form.component.html create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search-form.component.scss create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search-form.component.spec.ts create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search-form.component.ts create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search.component.html create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search.component.scss create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search.component.spec.ts create mode 100644 projects/ucap-webmessenger-ui/src/lib/components/integrated-search.component.ts diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts index 6f4430e9..1165cf8f 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts @@ -5,6 +5,7 @@ import { DIALOGS as MESSAGE_DIALOGS } from './message'; import { DIALOGS as NOTICE_DIALOGS } from './notice'; import { DIALOGS as ORGANIZATION_DIALOGS } from './organization'; import { DIALOGS as PROFILE_DIALOGS } from './profile'; +import { DIALOGS as SEARCH_DIALOGS } from './search'; import { DIALOGS as SETTINGS_DIALOGS } from './settings'; export const DIALOGS = [ @@ -15,5 +16,6 @@ export const DIALOGS = [ ...NOTICE_DIALOGS, ...ORGANIZATION_DIALOGS, ...PROFILE_DIALOGS, + ...SEARCH_DIALOGS, ...SETTINGS_DIALOGS ]; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/index.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/index.ts new file mode 100644 index 00000000..102349a0 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/index.ts @@ -0,0 +1,3 @@ +import { IntegratedSearchDialogComponent } from './integrated-search.dialog.component'; + +export const DIALOGS = [IntegratedSearchDialogComponent]; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.html new file mode 100644 index 00000000..a2bf3c67 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.html @@ -0,0 +1,11 @@ + + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.spec.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.spec.ts new file mode 100644 index 00000000..93935f51 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.spec.ts @@ -0,0 +1,25 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { IntegratedSearchDialogComponent } from './integrated-search.dialog.component'; + +describe('IntegratedSearchDialogComponent', () => { + let component: IntegratedSearchDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [IntegratedSearchDialogComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(IntegratedSearchDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.ts new file mode 100644 index 00000000..fe1553b5 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/search/integrated-search.dialog.component.ts @@ -0,0 +1,152 @@ +import { Component, OnInit, Inject, OnDestroy } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA, PageEvent } from '@angular/material'; +import { KEY_LOGIN_RES_INFO } from '@app/types'; +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; + +import { Store } from '@ngrx/store'; +import * as StatusStore from '@app/store/messenger/status'; +import { + UserInfoSS, + QueryProtocolService, + DeptSearchType, + SSVC_TYPE_QUERY_DEPT_USER_DATA, + DeptUserData, + SSVC_TYPE_QUERY_DEPT_USER_RES, + DeptUserResponse +} from '@ucap-webmessenger/protocol-query'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; +import { map, catchError } from 'rxjs/operators'; +import { Subscription, of } from 'rxjs'; +import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types'; +import { NGXLogger } from 'ngx-logger'; +import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native'; +import { environment } from '../../../../../environments/environment'; +import { TranslateService } from '@ngx-translate/core'; + +export interface IntegratedSearchDialogData { + keyword: string; +} + +export interface IntegratedSearchDialogResult {} + +@Component({ + selector: 'app-integrated-search.dialog', + templateUrl: './integrated-search.dialog.component.html', + styleUrls: ['./integrated-search.dialog.component.scss'] +}) +export class IntegratedSearchDialogComponent implements OnInit, OnDestroy { + loginRes: LoginResponse; + environmentsInfo: EnvironmentsInfo; + + searchSubscription: Subscription; + searchUserInfos: UserInfoSS[] = []; + searchingProcessing = false; + + currentSearchWord: string; + totalCount = 0; + pageCurrent = 1; + pageListCount = 20; + + constructor( + public dialogRef: MatDialogRef< + IntegratedSearchDialogData, + IntegratedSearchDialogResult + >, + @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, + @Inject(MAT_DIALOG_DATA) public data: IntegratedSearchDialogData, + private queryProtocolService: QueryProtocolService, + private sessionStorageService: SessionStorageService, + private store: Store, + private logger: NGXLogger + ) { + this.loginRes = this.sessionStorageService.get( + KEY_LOGIN_RES_INFO + ); + this.environmentsInfo = this.sessionStorageService.get( + KEY_ENVIRONMENTS_INFO + ); + } + + ngOnInit() { + this.onSearch(this.data.keyword); + } + + onSearch(searchWord: string) { + this.currentSearchWord = this.data.keyword; + + if (searchWord.trim().length > 0) { + this.searchingProcessing = true; + const searchUserInfos: UserInfoSS[] = []; + + this.searchSubscription = this.queryProtocolService + .deptUser({ + divCd: 'INT_SRCH', + companyCode: this.loginRes.companyCode, + searchRange: DeptSearchType.All, + search: searchWord.trim(), + senderCompanyCode: this.loginRes.companyCode, + senderEmployeeType: this.loginRes.userInfo.employeeType, + pageCurrent: this.pageCurrent, + pageListCount: this.pageListCount + }) + .pipe( + map(res => { + switch (res.SSVC_TYPE) { + case SSVC_TYPE_QUERY_DEPT_USER_DATA: + const userInfos = (res as DeptUserData).userInfos; + searchUserInfos.push(...userInfos); + break; + case SSVC_TYPE_QUERY_DEPT_USER_RES: + { + const response = res as DeptUserResponse; + + // 검색 결과 처리. + this.searchUserInfos = searchUserInfos; + + this.totalCount = response.pageTotalCount; + this.pageCurrent = response.pageCurrent; + this.pageListCount = response.pageListCount; + this.searchingProcessing = false; + + // 검색 결과에 따른 프레즌스 조회. + const userSeqList: number[] = []; + if (userSeqList.length > 0) { + this.store.dispatch( + StatusStore.bulkInfo({ + divCd: 'INT_SRCH', + userSeqs: this.searchUserInfos.map(user => user.seq) + }) + ); + } + + console.log(this.searchUserInfos); + } + break; + } + }), + catchError(error => { + this.searchingProcessing = false; + return of(this.logger.error(error)); + }) + ) + .subscribe(); + } else { + // clear list. + this.searchingProcessing = false; + this.searchUserInfos = []; + } + } + + ngOnDestroy(): void { + if (!!this.searchSubscription) { + this.searchSubscription.unsubscribe(); + } + } + + onChangePage(event: PageEvent) { + this.pageCurrent = event.pageIndex + 1; + this.pageListCount = event.pageSize; + + this.onSearch(this.currentSearchWord); + } +} 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 e67132ad..00d49b63 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 @@ -8,6 +8,9 @@ *ngIf="!!loginRes && !!weblink" class="app-layout-native-title-bar-link" > + + +