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" > + + +