From 5ac76edaddd9abfa48a162e7467cc26ab41d09f6 Mon Sep 17 00:00:00 2001 From: leejinho Date: Tue, 3 Dec 2019 14:32:50 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/lib/apis/notice.ts | 53 +++++++++ .../src/lib/config/urls.ts | 3 + .../src/lib/models/notice-list.ts | 12 ++ .../src/lib/services/message-api.service.ts | 17 +++ .../src/public-api.ts | 1 + .../components/right-drawer.component.html | 2 + .../right-drawer/file-box.component.html | 12 +- .../components/right-drawer/index.ts | 5 +- .../right-drawer/notice.component.html | 54 +++++++++ .../right-drawer/notice.component.scss | 105 ++++++++++++++++ .../right-drawer/notice.component.spec.ts | 24 ++++ .../right-drawer/notice.component.ts | 112 ++++++++++++++++++ .../app/layouts/messenger/dialogs/index.ts | 2 + .../layouts/messenger/dialogs/notice/index.ts | 3 + .../notice-detail.dialog.component.html | 21 ++++ .../notice-detail.dialog.component.scss | 45 +++++++ .../notice-detail.dialog.component.spec.ts | 27 +++++ .../notice/notice-detail.dialog.component.ts | 30 +++++ .../native/components/top-bar.component.html | 22 ++++ .../native/components/top-bar.component.ts | 10 ++ .../src/app/types/right-drawer.type.ts | 5 +- .../src/environments/environment.type.ts | 4 +- 22 files changed, 563 insertions(+), 6 deletions(-) create mode 100644 projects/ucap-webmessenger-api-message/src/lib/apis/notice.ts create mode 100644 projects/ucap-webmessenger-api-message/src/lib/models/notice-list.ts create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.html create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.scss create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.spec.ts create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.ts create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/index.ts create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.html create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.scss create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.spec.ts create mode 100644 projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.ts diff --git a/projects/ucap-webmessenger-api-message/src/lib/apis/notice.ts b/projects/ucap-webmessenger-api-message/src/lib/apis/notice.ts new file mode 100644 index 00000000..f3c3b097 --- /dev/null +++ b/projects/ucap-webmessenger-api-message/src/lib/apis/notice.ts @@ -0,0 +1,53 @@ +import { + APIRequest, + MessageAPIResponse, + APIDecoder, + APIJsonEncoder +} from '@ucap-webmessenger/api'; +import { NoticeList } from '../models/notice-list'; + +export interface RetrieveNoticeRequest extends APIRequest { + userSeq: number; + companyCode: string; + pageSize: number; + pageCount: number; +} + +export interface RetrieveNoticeResponse extends MessageAPIResponse { + pageSize: number; + pageCount: number; + totalCount: number; + + noticeList: NoticeList[]; +} + +export const encodeRetrieveNotice: APIJsonEncoder = ( + req: RetrieveNoticeRequest +) => { + return JSON.stringify(req); +}; + +export const decodeRetrieveNotice: APIDecoder = ( + res: any +) => { + const noticeList: NoticeList[] = []; + if (!!res.noticeList && res.noticeList.length > 0) { + for (const notice of res.noticeList) { + noticeList.push({ + ...notice, + topYn: notice.topYn === 'Y' ? true : false + } as NoticeList); + } + } + + return { + responseCode: res.responseCode, + responseMsg: res.responseMsg, + + pageCount: res.pageCount, + pageSize: res.pageSize, + totalCount: res.totalCount, + + noticeList + } as RetrieveNoticeResponse; +}; diff --git a/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts b/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts index e01d9548..10773f4d 100644 --- a/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts +++ b/projects/ucap-webmessenger-api-message/src/lib/config/urls.ts @@ -44,4 +44,7 @@ export interface Urls { /** 읽지 않은 메시지 개수 조회 */ retrieveUnreadCount: string; + + /** 공지 조회 */ + retrieveNoticeList: string; } diff --git a/projects/ucap-webmessenger-api-message/src/lib/models/notice-list.ts b/projects/ucap-webmessenger-api-message/src/lib/models/notice-list.ts new file mode 100644 index 00000000..43f23bf1 --- /dev/null +++ b/projects/ucap-webmessenger-api-message/src/lib/models/notice-list.ts @@ -0,0 +1,12 @@ +export interface NoticeList { + /** 공지 번호 */ + noticeSeq: number; + /** 공지 제목 */ + title: string; + /** 공지 내용 */ + content: string; + /** 상단 표시 여부 */ + topYn: boolean; + /** 공지 등록일자 */ + regDate: string; +} 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 deaecc71..6ce77efa 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 @@ -91,6 +91,12 @@ import { encodeUnreadCount, decodeUnreadCount } from '../apis/unread-count'; +import { + RetrieveNoticeRequest, + RetrieveNoticeResponse, + encodeRetrieveNotice, + decodeRetrieveNotice +} from '../apis/notice'; @Injectable({ providedIn: 'root' @@ -309,4 +315,15 @@ export class MessageApiService { }) .pipe(map(res => decodeUnreadCount(res))); } + + /** NoticeList */ + public retrieveNotice( + req: RetrieveNoticeRequest + ): Observable { + return this.httpClient + .post(this.urls.retrieveNoticeList, encodeRetrieveNotice(req), { + headers: this.headers + }) + .pipe(map(res => decodeRetrieveNotice(res))); + } } diff --git a/projects/ucap-webmessenger-api-message/src/public-api.ts b/projects/ucap-webmessenger-api-message/src/public-api.ts index 13789a8a..ac110c3d 100644 --- a/projects/ucap-webmessenger-api-message/src/public-api.ts +++ b/projects/ucap-webmessenger-api-message/src/public-api.ts @@ -16,6 +16,7 @@ export * from './lib/ucap-message-api.module'; export * from './lib/models/detail-receiver'; export * from './lib/models/detail-content'; export * from './lib/models/message-list'; +export * from './lib/models/notice-list'; export * from './lib/types/category.type'; export * from './lib/types/content.type'; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer.component.html index f317f3cf..c445d6fe 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer.component.html @@ -28,5 +28,7 @@ + + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html index 2be9561a..0f7dab5b 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.html @@ -40,7 +40,10 @@
  • {{ selectedFile.info.name }}
  • -
  • size : {{ selectedFile.info.size | ucapBytes }}
  • +
  • + size : + {{ selectedFile.info.size | ucapBytes }} +
  • date : {{ selectedFile.info.sendDate | dateToStringFormat: 'YYYY.MM.DD' }} @@ -167,14 +170,17 @@ {{ element.info.size | ucapBytes }} - + - + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.scss new file mode 100644 index 00000000..cfa4652f --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.scss @@ -0,0 +1,105 @@ +@mixin ellipsis($row) { + overflow: hidden; + text-overflow: ellipsis; + @if $row == 1 { + display: block; + white-space: nowrap; + word-wrap: normal; + } @else if $row >= 2 { + display: -webkit-box; + -webkit-line-clamp: $row; + -webkit-box-orient: vertical; + word-wrap: break-word; + } +} + +.rightDrawer-notice { + width: 100%; + height: calc(100% - 60px); + + .table-box { + height: calc(100% - 111.5px); + overflow: auto; + } +} + +.mat-table { + width: 100%; + position: relative; + th.infos { + padding: 10px; + } + tr.mat-row { + height: 70px; + .notice-info { + padding: 16px; + display: grid; + height: 70px; + .title { + font-weight: 600; + margin-bottom: 2px; + width: 50%; + @include ellipsis(1); + + .important { + color: red; + } + } + } + } +} + +.mat-paginator-container { + display: flex; + flex-flow: column; +} + +.mat-row:hover { + background: rgba(0, 0, 0, 0.04); + cursor: pointer; +} + +.footer-fix { + position: absolute; + bottom: 0; + flex-direction: column; + box-sizing: border-box; + display: flex; + border-top: 1px solid #dddddd; + .btn-box { + height: 50px; + padding-bottom: 10px; + width: 100%; + background-color: #ffffff; + button { + margin: 5px; + } + } +} + +.mat-paginator { + .mat-paginator-container { + justify-content: center; + } + .mat-paginator-navigation-first { + order: 1; + } + .mat-paginator-navigation-previous { + order: 2; + } + // override material paginator page switch + .mat-paginator-range-label { + order: 3; + } + .mat-paginator-navigation-next { + order: 4; + } + .mat-paginator-navigation-last { + order: 5; + } +} +.mat-form-field-appearance-legacy { + .mat-form-field-infix { + padding: 6px; + } +} diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.spec.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.spec.ts new file mode 100644 index 00000000..91692a28 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NoticeComponent } from './notice.component'; + +describe('NoticeComponent', () => { + let component: NoticeComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [NoticeComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NoticeComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.ts new file mode 100644 index 00000000..80dacf0a --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/notice.component.ts @@ -0,0 +1,112 @@ +import { + Component, + OnInit, + OnDestroy, + ViewChild, + AfterViewInit +} from '@angular/core'; +import { of, merge, Subscription } from 'rxjs'; +import { Store } from '@ngrx/store'; +import { map, catchError, startWith, switchMap } from 'rxjs/operators'; + +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; +import { DialogService } from '@ucap-webmessenger/ui'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; +import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; +import { MessageApiService, NoticeList } from '@ucap-webmessenger/api-message'; +import { RetrieveNoticeRequest } from 'projects/ucap-webmessenger-api-message/src/lib/apis/notice'; +import { NGXLogger } from 'ngx-logger'; +import { MatPaginator } from '@angular/material'; +import { + NoticeDetailDialogComponent, + NoticeDetailDialogData +} from '../../dialogs/notice/notice-detail.dialog.component'; + +@Component({ + selector: 'app-layout-chat-right-drawer-notice', + templateUrl: './notice.component.html', + styleUrls: ['./notice.component.scss'] +}) +export class NoticeComponent implements OnInit, OnDestroy, AfterViewInit { + loginRes: LoginResponse; + + @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; + displayedColumns: string[] = ['title', 'regDate']; + + isLoadingResults = true; + isRateLimitReached = false; + defaultPageSize = 10; // default + totalCount = 0; + currentPage = 0; + noticelist: NoticeList[] = []; + noticeListSubscription: Subscription; + + constructor( + private store: Store, + private sessionStorageService: SessionStorageService, + private dialogService: DialogService, + private messageApiService: MessageApiService, + private logger: NGXLogger + ) { + this.loginRes = this.sessionStorageService.get( + KEY_LOGIN_RES_INFO + ); + } + + ngOnInit() { + // this.getRetrieveNotice(this.currentPage); + } + + ngOnDestroy(): void { + if (!!this.noticeListSubscription) { + this.noticeListSubscription.unsubscribe(); + } + } + + ngAfterViewInit(): void { + this.noticeListSubscription = merge(this.paginator.page) + .pipe( + startWith({}), + switchMap(() => { + this.isLoadingResults = true; + return this.messageApiService.retrieveNotice({ + userSeq: this.loginRes.userSeq, + companyCode: this.loginRes.companyCode, + pageSize: this.defaultPageSize, + pageCount: this.paginator.pageIndex + } as RetrieveNoticeRequest); + }), + map(data => { + // Flip flag to show that loading has finished. + this.isLoadingResults = false; + this.isRateLimitReached = false; + + this.totalCount = data.totalCount; + this.currentPage = data.pageCount; + this.noticelist = data.noticeList; + + return data.noticeList; + }), + catchError(() => { + this.isLoadingResults = false; + // Catch if the GitHub API has reached its rate limit. Return empty data. + this.isRateLimitReached = true; + return of([]); + }) + ) + .subscribe(data => (this.noticelist = data)); + } + + onClickDetail(notice: NoticeList) { + const result = this.dialogService.open< + NoticeDetailDialogComponent, + NoticeDetailDialogData + >(NoticeDetailDialogComponent, { + disableClose: false, + width: '550px', + data: { + notice + } + }); + } +} 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 f4ae8d86..093e4297 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 @@ -2,6 +2,7 @@ import { DIALOGS as ACCOUNT_DIALOGS } from './account'; import { DIALOGS as CHAT_DIALOGS } from './chat'; import { DIALOGS as GROUP_DIALOGS } from './group'; import { DIALOGS as MESSAGE_DIALOGS } from './message'; +import { DIALOGS as NOTICE_DIALOGS } from './notice'; import { DIALOGS as PROFILE_DIALOGS } from './profile'; import { DIALOGS as SETTINGS_DIALOGS } from './settings'; @@ -10,6 +11,7 @@ export const DIALOGS = [ ...CHAT_DIALOGS, ...GROUP_DIALOGS, ...MESSAGE_DIALOGS, + ...NOTICE_DIALOGS, ...PROFILE_DIALOGS, ...SETTINGS_DIALOGS ]; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/index.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/index.ts new file mode 100644 index 00000000..fb51ced6 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/index.ts @@ -0,0 +1,3 @@ +import { NoticeDetailDialogComponent } from './notice-detail.dialog.component'; + +export const DIALOGS = [NoticeDetailDialogComponent]; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.html new file mode 100644 index 00000000..ba5eaf4f --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.html @@ -0,0 +1,21 @@ + + + + [중요] + {{ data.notice.title }} + + + +
    + {{ data.notice.regDate }} +
    + +

    +
    +
    + + + +
    diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.scss new file mode 100644 index 00000000..fbe0c0ed --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.scss @@ -0,0 +1,45 @@ +@mixin ellipsis($row) { + overflow: hidden; + text-overflow: ellipsis; + @if $row == 1 { + display: block; + white-space: nowrap; + word-wrap: normal; + } @else if $row >= 2 { + display: -webkit-box; + -webkit-line-clamp: $row; + -webkit-box-orient: vertical; + word-wrap: break-word; + } +} + +::ng-deep .mat-card-header-text { + margin: 0; + .title { + width: 480px; + @include ellipsis(1); + } +} +.confirm-card { + min-width: 500px; + .mat-card-header { + margin-bottom: 20px; + .mat-card-header-text { + .mat-card-title { + margin: 0 -16px; + } + } + } + .button-farm { + text-align: right; + .mat-primary { + margin-left: 4px; + } + } +} + +.contnets { + max-height: 500px; + min-height: 400px; + word-break: break-word; +} diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.spec.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.spec.ts new file mode 100644 index 00000000..7a9834fb --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.spec.ts @@ -0,0 +1,27 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; + +import { NoticeDetailDialogComponent } from './notice-detail.dialog.component'; + +describe('ProfileDialogComponent', () => { + let component: NoticeDetailDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [NoticeDetailDialogComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NoticeDetailDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.ts new file mode 100644 index 00000000..79433b77 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/notice/notice-detail.dialog.component.ts @@ -0,0 +1,30 @@ +import { Component, OnInit, Inject, ViewChild, OnDestroy } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { NoticeList } from '@ucap-webmessenger/api-message'; + +export interface NoticeDetailDialogData { + notice: NoticeList; +} + +export interface NoticeDetailDialogResult {} + +@Component({ + selector: 'app-notice-detail.dialog', + templateUrl: './notice-detail.dialog.component.html', + styleUrls: ['./notice-detail.dialog.component.scss'] +}) +export class NoticeDetailDialogComponent implements OnInit { + constructor( + public dialogRef: MatDialogRef< + NoticeDetailDialogData, + NoticeDetailDialogResult + >, + @Inject(MAT_DIALOG_DATA) public data: NoticeDetailDialogData + ) {} + + ngOnInit() {} + + onClickConfirm(): void { + this.dialogRef.close(); + } +} 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 9376dbd8..99283e2b 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,28 @@ +