diff --git a/angular.json b/angular.json index 0715f12b..bb83b8fc 100644 --- a/angular.json +++ b/angular.json @@ -1753,6 +1753,39 @@ } } } + }, + "ucap-webmessenger-api-prompt": { + "projectType": "library", + "root": "projects/ucap-webmessenger-api-prompt", + "sourceRoot": "projects/ucap-webmessenger-api-prompt/src", + "prefix": "ucap-api-prompt", + "architect": { + "build": { + "builder": "@angular-devkit/build-ng-packagr:build", + "options": { + "tsConfig": "projects/ucap-webmessenger-api-prompt/tsconfig.lib.json", + "project": "projects/ucap-webmessenger-api-prompt/ng-package.json" + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/ucap-webmessenger-api-prompt/src/test.ts", + "tsConfig": "projects/ucap-webmessenger-api-prompt/tsconfig.spec.json", + "karmaConfig": "projects/ucap-webmessenger-api-prompt/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "projects/ucap-webmessenger-api-prompt/tsconfig.lib.json", + "projects/ucap-webmessenger-api-prompt/tsconfig.spec.json" + ], + "exclude": ["**/node_modules/**"] + } + } + } } }, "defaultProject": "ucap-webmessenger-app" diff --git a/projects/ucap-webmessenger-api-prompt/README.md b/projects/ucap-webmessenger-api-prompt/README.md new file mode 100644 index 00000000..c4f119b8 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/README.md @@ -0,0 +1,24 @@ +# UcapWebmessengerApiPrompt + +This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.11. + +## Code scaffolding + +Run `ng generate component component-name --project ucap-webmessenger-api-prompt` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-api-prompt`. +> Note: Don't forget to add `--project ucap-webmessenger-api-prompt` or else it will be added to the default project in your `angular.json` file. + +## Build + +Run `ng build ucap-webmessenger-api-prompt` to build the project. The build artifacts will be stored in the `dist/` directory. + +## Publishing + +After building your library with `ng build ucap-webmessenger-api-prompt`, go to the dist folder `cd dist/ucap-webmessenger-api-prompt` and run `npm publish`. + +## Running unit tests + +Run `ng test ucap-webmessenger-api-prompt` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/projects/ucap-webmessenger-api-prompt/karma.conf.js b/projects/ucap-webmessenger-api-prompt/karma.conf.js new file mode 100644 index 00000000..d45fd572 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../coverage/ucap-webmessenger-api-prompt'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/projects/ucap-webmessenger-api-prompt/ng-package.json b/projects/ucap-webmessenger-api-prompt/ng-package.json new file mode 100644 index 00000000..7ee695db --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/ucap-webmessenger-api-prompt", + "lib": { + "entryFile": "src/public-api.ts" + } +} \ No newline at end of file diff --git a/projects/ucap-webmessenger-api-prompt/package.json b/projects/ucap-webmessenger-api-prompt/package.json new file mode 100644 index 00000000..85ad642b --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/package.json @@ -0,0 +1,8 @@ +{ + "name": "@ucap-webmessenger-api-prompt", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^8.2.11", + "@angular/core": "^8.2.11" + } +} diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/apis/api-prompt.ts b/projects/ucap-webmessenger-api-prompt/src/lib/apis/api-prompt.ts new file mode 100644 index 00000000..bb5b7593 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/apis/api-prompt.ts @@ -0,0 +1,7 @@ +import { PromptMessageStatusCode } from '../types/prompt-message-status-code.type'; + +export interface PromptAPIResponse { + _id?: string; + responseCode: PromptMessageStatusCode; + responseMsg: string; +} diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/apis/call.ts b/projects/ucap-webmessenger-api-prompt/src/lib/apis/call.ts new file mode 100644 index 00000000..30cf2d15 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/apis/call.ts @@ -0,0 +1,35 @@ +import { + APIRequest, + APIDecoder, + APIEncoder, + ParameterUtil +} from '@ucap-webmessenger/api'; +import { DeviceType } from '@ucap-webmessenger/core'; +import { PromptAPIResponse } from './api-prompt'; + +export interface CallRequest extends APIRequest { + userSeq: number; + deviceType: DeviceType; + tokenKey: string; + calleeNumber: string; +} + +export interface CallResponse extends PromptAPIResponse {} + +const callEncodeMap = { + userSeq: 'userSeq', + deviceType: 'deviceType', + tokenKey: 'tokenKey', + calleeNumber: 'calleeNumber' +}; + +export const encodeCall: APIEncoder = (req: CallRequest) => { + return ParameterUtil.encode(callEncodeMap, req); +}; + +export const decodeCall: APIDecoder = (res: any) => { + return { + responseCode: res.responseCode, + responseMsg: res.responseMsg + } as CallResponse; +}; diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/config/module-config.ts b/projects/ucap-webmessenger-api-prompt/src/lib/config/module-config.ts new file mode 100644 index 00000000..8e49cd75 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/config/module-config.ts @@ -0,0 +1,5 @@ +import { ModuleConfig as CoreModuleConfig } from '@ucap-webmessenger/core'; + +import { Urls } from './urls'; + +export interface ModuleConfig extends CoreModuleConfig {} diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/config/token.ts b/projects/ucap-webmessenger-api-prompt/src/lib/config/token.ts new file mode 100644 index 00000000..81a49675 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/config/token.ts @@ -0,0 +1,5 @@ +import { InjectionToken } from '@angular/core'; + +export const _MODULE_CONFIG = new InjectionToken( + '@ucap-webmessenger/api-prompt config of module' +); diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/config/urls.ts b/projects/ucap-webmessenger-api-prompt/src/lib/config/urls.ts new file mode 100644 index 00000000..9a601549 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/config/urls.ts @@ -0,0 +1,4 @@ +export interface Urls { + /** Click to Call */ + sendCall: string; +} diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/services/call.service.spec.ts b/projects/ucap-webmessenger-api-prompt/src/lib/services/call.service.spec.ts new file mode 100644 index 00000000..a0bdd469 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/services/call.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { CallService } from './call.service'; + +describe('CallService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: CallService = TestBed.get(CallService); + expect(service).toBeTruthy(); + }); +}); diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/services/call.service.ts b/projects/ucap-webmessenger-api-prompt/src/lib/services/call.service.ts new file mode 100644 index 00000000..eb36b9c2 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/services/call.service.ts @@ -0,0 +1,45 @@ +import { Injectable, Inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; + +import { _MODULE_CONFIG } from '../config/token'; +import { ModuleConfig } from '../config/module-config'; +import { Urls } from '../config/urls'; +import { UrlConfig } from '@ucap-webmessenger/core'; +import { + CallRequest, + CallResponse, + encodeCall, + decodeCall +} from '../apis/call'; + +@Injectable({ + providedIn: 'root' +}) +export class CallService { + readonly urls: Urls; + + constructor( + @Inject(_MODULE_CONFIG) private moduleConfig: ModuleConfig, + private httpClient: HttpClient + ) { + this.urls = UrlConfig.getUrls( + this.moduleConfig.hostConfig, + this.moduleConfig.urls + ); + } + + public sendCall(req: CallRequest): Observable { + return this.httpClient + .post( + this.urls.sendCall, + {}, + { + params: encodeCall(req) + } + ) + .pipe(map(res => decodeCall(res))); + } +} diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/types/prompt-message-status-code.type.ts b/projects/ucap-webmessenger-api-prompt/src/lib/types/prompt-message-status-code.type.ts new file mode 100644 index 00000000..d2dcba6a --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/types/prompt-message-status-code.type.ts @@ -0,0 +1,10 @@ +export enum PromptMessageStatusCode { + /** 정상 */ + Success = '200', + /** 사용자 정보 확인 불가 */ + Fail_Auth = '204', + /** Parameter 부족 */ + Fail_Parameter = '412', + /** 서버 에러, Click to Call 실패 */ + Fail = '500' +} diff --git a/projects/ucap-webmessenger-api-prompt/src/lib/ucap-prompt-api.module.ts b/projects/ucap-webmessenger-api-prompt/src/lib/ucap-prompt-api.module.ts new file mode 100644 index 00000000..45058cf9 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/lib/ucap-prompt-api.module.ts @@ -0,0 +1,24 @@ +import { NgModule, ModuleWithProviders } from '@angular/core'; + +import { _MODULE_CONFIG } from './config/token'; +import { ModuleConfig } from './config/module-config'; + +import { CallService } from './services/call.service'; + +const SERVICES = [CallService]; + +@NgModule({ + declarations: [], + imports: [], + exports: [] +}) +export class UCapPromptApiModule { + public static forRoot( + config: ModuleConfig + ): ModuleWithProviders { + return { + ngModule: UCapPromptApiModule, + providers: [{ provide: _MODULE_CONFIG, useValue: config }, ...SERVICES] + }; + } +} diff --git a/projects/ucap-webmessenger-api-prompt/src/public-api.ts b/projects/ucap-webmessenger-api-prompt/src/public-api.ts new file mode 100644 index 00000000..48f324e8 --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/public-api.ts @@ -0,0 +1,17 @@ +/* + * Public API Surface of ucap-webmessenger-api-prompt + */ + +export * from './lib/apis/api-prompt'; +export * from './lib/apis/call'; + +export * from './lib/services/call.service'; + +export * from './lib/types/prompt-message-status-code.type'; + +export * from './lib/types/prompt-message-status-code.type'; + +export * from './lib/ucap-prompt-api.module'; + +export * from './lib/config/urls'; +export * from './lib/config/module-config'; diff --git a/projects/ucap-webmessenger-api-prompt/src/test.ts b/projects/ucap-webmessenger-api-prompt/src/test.ts new file mode 100644 index 00000000..978c64fb --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/src/test.ts @@ -0,0 +1,21 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/zone'; +import 'zone.js/dist/zone-testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: any; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/projects/ucap-webmessenger-api-prompt/tsconfig.lib.json b/projects/ucap-webmessenger-api-prompt/tsconfig.lib.json new file mode 100644 index 00000000..bd23948e --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/tsconfig.lib.json @@ -0,0 +1,26 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/lib", + "target": "es2015", + "declaration": true, + "inlineSources": true, + "types": [], + "lib": [ + "dom", + "es2018" + ] + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true, + "enableResourceInlining": true + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/projects/ucap-webmessenger-api-prompt/tsconfig.spec.json b/projects/ucap-webmessenger-api-prompt/tsconfig.spec.json new file mode 100644 index 00000000..16da33db --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/projects/ucap-webmessenger-api-prompt/tslint.json b/projects/ucap-webmessenger-api-prompt/tslint.json new file mode 100644 index 00000000..510c580e --- /dev/null +++ b/projects/ucap-webmessenger-api-prompt/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tslint.json", + "rules": { + "directive-selector": [true, "attribute", "ucapApiPrompt", "camelCase"], + "component-selector": [true, "element", "ucap-api-prompt", "kebab-case"] + } +} diff --git a/projects/ucap-webmessenger-app/src/app/app.module.ts b/projects/ucap-webmessenger-app/src/app/app.module.ts index 1b3d1573..a3d909bb 100644 --- a/projects/ucap-webmessenger-app/src/app/app.module.ts +++ b/projects/ucap-webmessenger-app/src/app/app.module.ts @@ -18,6 +18,7 @@ import { UCapCommonApiModule } from '@ucap-webmessenger/api-common'; import { UCapExternalApiModule } from '@ucap-webmessenger/api-external'; import { UCapMessageApiModule } from '@ucap-webmessenger/api-message'; import { UCapPublicApiModule } from '@ucap-webmessenger/api-public'; +import { UCapPromptApiModule } from '@ucap-webmessenger/api-prompt'; import { UCapPiModule } from '@ucap-webmessenger/pi'; @@ -66,6 +67,7 @@ import { environment } from '../environments/environment'; UCapPublicApiModule.forRoot(environment.publicApiModuleConfig), UCapExternalApiModule.forRoot(environment.externalApiModuleConfig), UCapMessageApiModule.forRoot(environment.messageApiModuleConfig), + UCapPromptApiModule.forRoot(environment.promptApiModuleConfig), UCapPiModule.forRoot(environment.piModuleConfig), diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html index aca892bc..95753c09 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.html @@ -188,6 +188,7 @@ (checkAllUser)="onCheckAllUser($event)" (checkUser)="onCheckUser($event)" (openProfile)="onClickOpenProfile($event)" + (sendCall)="onClickSendClickToCall($event)" (toggleUser)="onToggleUser($event)" class="organization-side" > diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts index 313a189c..de92a4d2 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts @@ -71,6 +71,8 @@ export class LeftSideComponent implements OnInit, OnDestroy { openProfile = new EventEmitter< UserInfo | UserInfoSS | UserInfoF | UserInfoDN >(); + @Output() + sendCall = new EventEmitter(); @ViewChildren('tabs') tabs: QueryList>; currentTabLable: string; @@ -260,6 +262,9 @@ export class LeftSideComponent implements OnInit, OnDestroy { onClickOpenProfile(userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN) { this.openProfile.emit(userInfo); } + onClickSendClickToCall(calleeNumber: string) { + this.sendCall.emit(calleeNumber); + } onSelectedTabChange(event: MatTabChangeEvent) { this.setFabInitial(event.tab.ariaLabel); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html index 23c168c9..3c70f82d 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.html @@ -232,6 +232,7 @@ > 그룹 쪽지 보내기 + - -