refactoring

This commit is contained in:
병준 박 2019-09-26 11:11:22 +09:00
parent 465a3124d3
commit 8d73524de6
50 changed files with 141 additions and 154 deletions

16
package-lock.json generated
View File

@ -9975,6 +9975,16 @@
"deep-freeze-strict": "^1.1.1" "deep-freeze-strict": "^1.1.1"
} }
}, },
"ngx-logger": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/ngx-logger/-/ngx-logger-4.0.5.tgz",
"integrity": "sha512-RUvu6TeDga+nUFGMwGiUn+GTCwpshfF4rsfS02i8euGXE9Lq9PPPzHg10sgonPCYBYj4GAx+bdPRv8BQpRyldQ==",
"dev": true,
"requires": {
"tslib": "^1.9.0",
"vlq": "^1.0.0"
}
},
"ngx-perfect-scrollbar": { "ngx-perfect-scrollbar": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/ngx-perfect-scrollbar/-/ngx-perfect-scrollbar-8.0.0.tgz", "resolved": "https://registry.npmjs.org/ngx-perfect-scrollbar/-/ngx-perfect-scrollbar-8.0.0.tgz",
@ -14377,6 +14387,12 @@
"extsprintf": "^1.2.0" "extsprintf": "^1.2.0"
} }
}, },
"vlq": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/vlq/-/vlq-1.0.1.tgz",
"integrity": "sha512-gQpnTgkubC6hQgdIcRdYGDSDc+SaujOdyesZQMv6JlfQee/9Mp0Qhnys6WxDWvQnL5WZdT7o2Ul187aSt0Rq+w==",
"dev": true
},
"vm-browserify": { "vm-browserify": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz",

View File

@ -84,6 +84,7 @@
"moment": "^2.24.0", "moment": "^2.24.0",
"ng-packagr": "^5.4.0", "ng-packagr": "^5.4.0",
"ngrx-store-freeze": "^0.2.4", "ngrx-store-freeze": "^0.2.4",
"ngx-logger": "^4.0.5",
"ngx-perfect-scrollbar": "^8.0.0", "ngx-perfect-scrollbar": "^8.0.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"parallel-webpack": "^2.4.0", "parallel-webpack": "^2.4.0",

View File

@ -21,7 +21,7 @@ const routes: Routes = [
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forRoot(routes, { enableTracing: true })], imports: [RouterModule.forRoot(routes, { enableTracing: false })],
exports: [RouterModule] exports: [RouterModule]
}) })
export class AppRoutingModule {} export class AppRoutingModule {}

View File

@ -0,0 +1,4 @@
:host {
width: 100%;
height: auto !important;
}

View File

@ -24,6 +24,8 @@ import { UCapWebStorageModule } from '@ucap-webmessenger/web-storage';
import { UCapUtilModule } from '@ucap-webmessenger/util'; import { UCapUtilModule } from '@ucap-webmessenger/util';
import { LoggerModule, NgxLoggerLevel } from 'ngx-logger';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
import { AppProviderModule } from './app-provider.module'; import { AppProviderModule } from './app-provider.module';
@ -77,7 +79,11 @@ import { GUARDS } from './guards';
AppProviderModule, AppProviderModule,
AppRoutingModule, AppRoutingModule,
AppStoreModule, AppStoreModule,
AppTranslateModule AppTranslateModule,
LoggerModule.forRoot({
level: NgxLoggerLevel.DEBUG
})
], ],
providers: [...GUARDS], providers: [...GUARDS],
declarations: [AppComponent], declarations: [AppComponent],

View File

@ -1,14 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { ucapAnimations } from '@ucap-webmessenger/ui';
@Component({
selector: 'app-layout-chat-left-sidenav',
templateUrl: './left-sidenav.component.html',
styleUrls: ['./left-sidenav.component.scss'],
animations: ucapAnimations
})
export class LeftSidenavComponent implements OnInit {
constructor() {}
ngOnInit() {}
}

View File

@ -1,14 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { ucapAnimations } from '@ucap-webmessenger/ui';
@Component({
selector: 'app-layout-chat-right-sidenav',
templateUrl: './right-sidenav.component.html',
styleUrls: ['./right-sidenav.component.scss'],
animations: ucapAnimations
})
export class RightSidenavComponent implements OnInit {
constructor() {}
ngOnInit() {}
}

View File

@ -1,15 +1,15 @@
import { IntroComponent } from './intro.component'; import { IntroComponent } from './intro.component';
import { LeftSidenavComponent } from './left-sidenav.component'; import { LeftSideComponent } from './left-side.component';
import { MessagesComponent } from './messages.component'; import { MessagesComponent } from './messages.component';
import { RightSidenavComponent } from './right-sidenav.component'; import { RightSideComponent } from './right-side.component';
import { LEFT_SIDENAV_COMPONENTS } from './left-sidenav'; import { LEFT_SIDENAV_COMPONENTS } from './left-sidenav';
export const COMPONENTS = [ export const COMPONENTS = [
IntroComponent, IntroComponent,
LeftSidenavComponent, LeftSideComponent,
MessagesComponent, MessagesComponent,
RightSidenavComponent, RightSideComponent,
...LEFT_SIDENAV_COMPONENTS ...LEFT_SIDENAV_COMPONENTS
]; ];

View File

@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IntroComponent } from './intro.component'; import { IntroComponent } from './intro.component';
describe('Chat::IntroComponent', () => { describe('App::Layout::Messenger::IntroComponent', () => {
let component: IntroComponent; let component: IntroComponent;
let fixture: ComponentFixture<IntroComponent>; let fixture: ComponentFixture<IntroComponent>;

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ucapAnimations } from '@ucap-webmessenger/ui'; import { ucapAnimations } from '@ucap-webmessenger/ui';
@Component({ @Component({
selector: 'app-layout-chat-intro', selector: 'app-layout-messenger-intro',
templateUrl: './intro.component.html', templateUrl: './intro.component.html',
styleUrls: ['./intro.component.scss'], styleUrls: ['./intro.component.scss'],
animations: ucapAnimations animations: ucapAnimations

View File

@ -1,4 +1,4 @@
<mat-tab-group md-stretch-tabs> <mat-tab-group mat-stretch-tabs>
<mat-tab> <mat-tab>
<ng-template mat-tab-label> <ng-template mat-tab-label>
<mat-icon>group</mat-icon> <mat-icon>group</mat-icon>

View File

@ -1,19 +1,19 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LeftSidenavComponent } from './left-sidenav.component'; import { LeftSideComponent } from './left-side.component';
describe('Chat::LeftSidenavComponent', () => { describe('App::Layout::Messenger::LeftSideComponent', () => {
let component: LeftSidenavComponent; let component: LeftSideComponent;
let fixture: ComponentFixture<LeftSidenavComponent>; let fixture: ComponentFixture<LeftSideComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [LeftSidenavComponent] declarations: [LeftSideComponent]
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(LeftSidenavComponent); fixture = TestBed.createComponent(LeftSideComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -0,0 +1,14 @@
import { Component, OnInit } from '@angular/core';
import { ucapAnimations } from '@ucap-webmessenger/ui';
@Component({
selector: 'app-layout-messenger-left-side',
templateUrl: './left-side.component.html',
styleUrls: ['./left-side.component.scss'],
animations: ucapAnimations
})
export class LeftSideComponent implements OnInit {
constructor() {}
ngOnInit() {}
}

View File

@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MessagesComponent } from './messages.component'; import { MessagesComponent } from './messages.component';
describe('Chat::MessagesComponent', () => { describe('App::Layout::Messenger::MessagesComponent', () => {
let component: MessagesComponent; let component: MessagesComponent;
let fixture: ComponentFixture<MessagesComponent>; let fixture: ComponentFixture<MessagesComponent>;

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { ucapAnimations } from '@ucap-webmessenger/ui'; import { ucapAnimations } from '@ucap-webmessenger/ui';
@Component({ @Component({
selector: 'app-layout-chat-messages', selector: 'app-layout-messenger-messages',
templateUrl: './messages.component.html', templateUrl: './messages.component.html',
styleUrls: ['./messages.component.scss'], styleUrls: ['./messages.component.scss'],
animations: ucapAnimations animations: ucapAnimations

View File

@ -1,19 +1,19 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RightSidenavComponent } from './right-sidenav.component'; import { RightSideComponent } from './right-side.component';
describe('Chat::RightSidenavComponent', () => { describe('App::Layout::Messenger::RightSideComponent', () => {
let component: RightSidenavComponent; let component: RightSideComponent;
let fixture: ComponentFixture<RightSidenavComponent>; let fixture: ComponentFixture<RightSideComponent>;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [RightSidenavComponent] declarations: [RightSideComponent]
}).compileComponents(); }).compileComponents();
})); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(RightSidenavComponent); fixture = TestBed.createComponent(RightSideComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@ -0,0 +1,14 @@
import { Component, OnInit } from '@angular/core';
import { ucapAnimations } from '@ucap-webmessenger/ui';
@Component({
selector: 'app-layout-messenger-right-side',
templateUrl: './right-side.component.html',
styleUrls: ['./right-side.component.scss'],
animations: ucapAnimations
})
export class RightSideComponent implements OnInit {
constructor() {}
ngOnInit() {}
}

View File

@ -27,4 +27,4 @@ import { COMPONENTS } from './components';
declarations: [...COMPONENTS], declarations: [...COMPONENTS],
entryComponents: [] entryComponents: []
}) })
export class AppChatLayoutModule {} export class AppMessengerLayoutModule {}

View File

@ -1,43 +1,26 @@
<div id="messenger" class="page-layout carded fullwidth inner-scroll"> <div class="container">
<!-- TOP BACKGROUND --> <!-- TOP BACKGROUND -->
<div class="top-bg accent"></div> <div></div>
<!-- / TOP BACKGROUND --> <!-- / TOP BACKGROUND -->
<!-- CENTER --> <!-- CENTER -->
<div class="center"> <div>
<!-- CONTENT CARD --> <!-- CONTENT CARD -->
<div class="content-card"> <div>
<mat-sidenav-container> <div class="left-side">
<!-- LEFT SIDENAV --> <app-layout-messenger-left-side></app-layout-messenger-left-side>
<mat-sidenav </div>
class="sidenav left-sidenav" <div>
position="start" <app-layout-messenger-intro
opened="true" *ngIf="!selectedChat"
mode="side" ></app-layout-messenger-intro>
matIsLockedOpen="gt-md" <app-layout-messenger-messages
>
<app-layout-chat-left-sidenav></app-layout-chat-left-sidenav>
</mat-sidenav>
<!-- / LEFT SIDENAV -->
<!-- CONTENT -->
<app-layout-chat-intro *ngIf="!selectedChat"></app-layout-chat-intro>
<app-layout-chat-messages
*ngIf="selectedChat" *ngIf="selectedChat"
></app-layout-chat-messages> ></app-layout-messenger-messages>
<!-- / CONTENT --> </div>
<!-- RIGHT SIDENAV --> <div class="right-side">
<mat-sidenav <app-layout-messenger-right-side></app-layout-messenger-right-side>
class="sidenav right-sidenav" </div>
position="end"
opened="true"
mode="side"
>
<app-layout-chat-right-sidenav></app-layout-chat-right-sidenav>
</mat-sidenav>
<!-- / RIGHT SIDENAV -->
</mat-sidenav-container>
</div> </div>
<!-- / CONTENT CARD --> <!-- / CONTENT CARD -->
</div> </div>

View File

@ -1,55 +1,12 @@
#messenger { .container {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
height: auto !important;
.center {
max-width: 1400px;
margin: 0 auto;
.content-card {
position: relative;
display: flex;
flex: 1;
border-radius: 8px;
.mat-sidenav-container {
display: flex;
flex: 1;
width: 100%; width: 100%;
height: auto !important;
}
.left-sidenav { .left-side {
width: 300px; width: 300px;
} }
.right-sidenav { .right-side {
width: 70px; width: 70px;
} }
> .mat-sidenav-content,
> .mat-drawer-content {
display: flex;
flex: 1 1 auto;
min-height: 100%;
width: auto;
height: auto;
}
> .mat-drawer-content {
max-width: 100%;
}
mat-sidenav {
display: flex;
flex-direction: column;
width: 400px;
max-width: 90%;
overflow: hidden;
}
}
}
}
}

View File

@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
import { MatSidenavModule } from '@angular/material/sidenav'; import { MatSidenavModule } from '@angular/material/sidenav';
import { AppChatLayoutModule } from '@app/layouts/chat/chat.layout.module'; import { AppMessengerLayoutModule } from '@app/layouts/messenger/messenger.layout.module';
import { AppMessengerRoutingPageModule } from './messenger-routing.page.module'; import { AppMessengerRoutingPageModule } from './messenger-routing.page.module';
@ -13,7 +13,7 @@ import { COMPONENTS } from './components';
imports: [ imports: [
CommonModule, CommonModule,
MatSidenavModule, MatSidenavModule,
AppChatLayoutModule, AppMessengerLayoutModule,
AppMessengerRoutingPageModule AppMessengerRoutingPageModule
], ],
declarations: [...COMPONENTS], declarations: [...COMPONENTS],

View File

@ -14,12 +14,14 @@ import {
} from '@ucap-webmessenger/protocol-authentication'; } from '@ucap-webmessenger/protocol-authentication';
import * as AuthenticationStore from '../store/account/authentication'; import * as AuthenticationStore from '../store/account/authentication';
import { NGXLogger } from 'ngx-logger';
@Injectable() @Injectable()
export class AppNotificationService { export class AppNotificationService {
constructor( constructor(
private protocolService: ProtocolService, private protocolService: ProtocolService,
private store: Store<any> private store: Store<any>,
private logger: NGXLogger
) {} ) {}
public subscribe(): void { public subscribe(): void {
@ -32,7 +34,7 @@ export class AppNotificationService {
), ),
tap(message => { tap(message => {
const logoutRes = decodeLogout(message); const logoutRes = decodeLogout(message);
console.log('logoutRes', logoutRes); this.logger.debug('logoutRes', logoutRes);
this.store.dispatch(AuthenticationStore.logout()); this.store.dispatch(AuthenticationStore.logout());
}) })
) )

View File

@ -7,6 +7,8 @@ import { catchError, exhaustMap, map, withLatestFrom } from 'rxjs/operators';
import { Store, select } from '@ngrx/store'; import { Store, select } from '@ngrx/store';
import { NGXLogger } from 'ngx-logger';
import { import {
buddy2, buddy2,
buddy2Success, buddy2Success,
@ -38,7 +40,7 @@ export class Effects {
withLatestFrom( withLatestFrom(
this.store.pipe( this.store.pipe(
select(state => { select(state => {
console.log('state', state); this.logger.debug('state', state);
return state.messenger.sync.buddy2SyncDate as string; return state.messenger.sync.buddy2SyncDate as string;
}) })
) )
@ -72,7 +74,7 @@ export class Effects {
withLatestFrom( withLatestFrom(
this.store.pipe( this.store.pipe(
select(state => { select(state => {
console.log('state', state); this.logger.debug('state', state);
return state.messenger.sync.group2SyncDate as string; return state.messenger.sync.group2SyncDate as string;
}) })
) )
@ -104,6 +106,7 @@ export class Effects {
private actions$: Actions, private actions$: Actions,
private store: Store<any>, private store: Store<any>,
private syncProtocolService: SyncProtocolService, private syncProtocolService: SyncProtocolService,
private sessionStorageService: SessionStorageService private sessionStorageService: SessionStorageService,
private logger: NGXLogger
) {} ) {}
} }

View File

@ -10,6 +10,8 @@ import { PublicApiService } from '@ucap-webmessenger/api-public';
import { StatusCode } from '@ucap-webmessenger/api'; import { StatusCode } from '@ucap-webmessenger/api';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { NGXLogger } from 'ngx-logger';
import { fetch, fetchSuccess, fetchFailure } from './actions'; import { fetch, fetchSuccess, fetchFailure } from './actions';
@Injectable() @Injectable()
@ -22,7 +24,7 @@ export class Effects {
this.publicApiService.versionInfo2(req).pipe( this.publicApiService.versionInfo2(req).pipe(
map(res => { map(res => {
if (res.statusCode === StatusCode.Success) { if (res.statusCode === StatusCode.Success) {
console.log('fetchSuccess', res); this.logger.debug('fetchSuccess', res);
return fetchSuccess(res); return fetchSuccess(res);
} else { } else {
return fetchFailure({ error: 'Failed' }); return fetchFailure({ error: 'Failed' });
@ -47,6 +49,7 @@ export class Effects {
private actions$: Actions, private actions$: Actions,
private publicApiService: PublicApiService, private publicApiService: PublicApiService,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private router: Router private router: Router,
private logger: NGXLogger
) {} ) {}
} }

View File

@ -22,6 +22,8 @@ import { PacketBodyValue } from '../types/packet-body-value.type';
import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service'; import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service';
import { ProtocolMessage } from '../models/protocol'; import { ProtocolMessage } from '../models/protocol';
import { NGXLogger } from 'ngx-logger';
interface RequestState { interface RequestState {
subject: Subject<ProtocolMessage>; subject: Subject<ProtocolMessage>;
request: { request: {
@ -45,7 +47,10 @@ export class ProtocolService {
private serverMessageSubject: Subject<ProtocolMessage> | null = null; private serverMessageSubject: Subject<ProtocolMessage> | null = null;
private serverMessage$: Observable<ProtocolMessage> | null = null; private serverMessage$: Observable<ProtocolMessage> | null = null;
constructor(@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig) { constructor(
@Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig,
private logger: NGXLogger
) {
this.pendingRequests = new Map(); this.pendingRequests = new Map();
this.input$ = new QueueingSubject<string>(); this.input$ = new QueueingSubject<string>();
this.serverMessageSubject = new Subject(); this.serverMessageSubject = new Subject();
@ -106,16 +111,23 @@ export class ProtocolService {
(error: Error) => { (error: Error) => {
const { message } = error; const { message } = error;
if (message === NormalClosureMessage) { if (message === NormalClosureMessage) {
console.log('server closed the websocket connection normally'); this.logger.info(
'server closed the websocket connection normally'
);
} else { } else {
console.log('socket was disconnected due to error:', message); this.logger.error(
'socket was disconnected due to error:',
message
);
} }
}, },
() => { () => {
// The clean termination only happens in response to the last // The clean termination only happens in response to the last
// subscription to the observable being unsubscribed, any // subscription to the observable being unsubscribed, any
// other closure is considered an error. // other closure is considered an error.
console.log('the connection was closed in response to the user'); this.logger.info(
'the connection was closed in response to the user'
);
} }
); );
} catch (error) { } catch (error) {
@ -170,7 +182,7 @@ export class ProtocolService {
if (this.pendingRequests.has(requestId)) { if (this.pendingRequests.has(requestId)) {
this.pendingRequests.delete(requestId); this.pendingRequests.delete(requestId);
} }
console.log( this.logger.debug(
'ProtocolService::pendingRequests.size', 'ProtocolService::pendingRequests.size',
this.pendingRequests.size this.pendingRequests.size
); );

View File

@ -2,7 +2,7 @@
<mat-expansion-panel *ngFor="let group of groupList"> <mat-expansion-panel *ngFor="let group of groupList">
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> {{ group.name }} </mat-panel-title> <mat-panel-title> {{ group.name }} </mat-panel-title>
<mat-panel-description>{{ group.name }} </mat-panel-description> <mat-panel-description> </mat-panel-description>
</mat-expansion-panel-header> </mat-expansion-panel-header>
</mat-expansion-panel> </mat-expansion-panel>
</mat-accordion> </mat-accordion>