SMS 연동

This commit is contained in:
leejinho 2019-12-18 09:56:00 +09:00
parent 8e40d81f92
commit 0233ef4117
10 changed files with 144 additions and 16 deletions

View File

@ -189,6 +189,7 @@
(checkUser)="onCheckUser($event)" (checkUser)="onCheckUser($event)"
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(sendCall)="onClickSendClickToCall($event)" (sendCall)="onClickSendClickToCall($event)"
(sendSms)="onClickSendSms($event)"
(toggleUser)="onToggleUser($event)" (toggleUser)="onToggleUser($event)"
class="organization-side" class="organization-side"
></app-layout-chat-left-sidenav-organization> ></app-layout-chat-left-sidenav-organization>

View File

@ -73,6 +73,8 @@ export class LeftSideComponent implements OnInit, OnDestroy {
>(); >();
@Output() @Output()
sendCall = new EventEmitter<string>(); sendCall = new EventEmitter<string>();
@Output()
sendSms = new EventEmitter<string>();
@ViewChildren('tabs') tabs: QueryList<ElementRef<HTMLDivElement>>; @ViewChildren('tabs') tabs: QueryList<ElementRef<HTMLDivElement>>;
currentTabLable: string; currentTabLable: string;
@ -265,6 +267,9 @@ export class LeftSideComponent implements OnInit, OnDestroy {
onClickSendClickToCall(calleeNumber: string) { onClickSendClickToCall(calleeNumber: string) {
this.sendCall.emit(calleeNumber); this.sendCall.emit(calleeNumber);
} }
onClickSendSms(calleeNumber: string) {
this.sendSms.emit(calleeNumber);
}
onSelectedTabChange(event: MatTabChangeEvent) { onSelectedTabChange(event: MatTabChangeEvent) {
this.setFabInitial(event.tab.ariaLabel); this.setFabInitial(event.tab.ariaLabel);

View File

@ -103,6 +103,8 @@ export class OrganizationComponent
>(); >();
@Output() @Output()
sendCall = new EventEmitter<string>(); sendCall = new EventEmitter<string>();
@Output()
sendSms = new EventEmitter<string>();
@ViewChild('cvsvDeptUser', { static: false }) @ViewChild('cvsvDeptUser', { static: false })
cvsvDeptUser: CdkVirtualScrollViewport; cvsvDeptUser: CdkVirtualScrollViewport;
@ -553,6 +555,7 @@ export class OrganizationComponent
break; break;
case 'SEND_SMS': case 'SEND_SMS':
{ {
this.sendSms.emit(userInfo.hpNumber);
} }
break; break;
} }

View File

@ -8,6 +8,7 @@
(openChat)="onClickChat($event)" (openChat)="onClickChat($event)"
(sendMessage)="onClickSendMessage($event)" (sendMessage)="onClickSendMessage($event)"
(sendCall)="onClickSendClickToCall($event)" (sendCall)="onClickSendClickToCall($event)"
(sendSms)="onClickSendSms($event)"
(toggleFavorit)="onClickToggleFavorit($event)" (toggleFavorit)="onClickToggleFavorit($event)"
(toggleBuddy)="onClickToggleBuddy($event)" (toggleBuddy)="onClickToggleBuddy($event)"
(uploadProfileImage)="onUploadProfileImage($event)" (uploadProfileImage)="onUploadProfileImage($event)"

View File

@ -48,6 +48,8 @@ import {
PromptMessageStatusCode PromptMessageStatusCode
} from '@ucap-webmessenger/api-prompt'; } from '@ucap-webmessenger/api-prompt';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { SmsUtils } from '@ucap-webmessenger/daesang';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
export interface ProfileDialogData { export interface ProfileDialogData {
userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN; userInfo: UserInfo | UserInfoSS | UserInfoF | UserInfoDN;
@ -74,6 +76,7 @@ export class ProfileDialogComponent implements OnInit, OnDestroy {
constructor( constructor(
public dialogRef: MatDialogRef<ProfileDialogData, ProfileDialogResult>, public dialogRef: MatDialogRef<ProfileDialogData, ProfileDialogResult>,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
@Inject(MAT_DIALOG_DATA) public data: ProfileDialogData, @Inject(MAT_DIALOG_DATA) public data: ProfileDialogData,
private dialogService: DialogService, private dialogService: DialogService,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
@ -222,6 +225,42 @@ export class ProfileDialogComponent implements OnInit, OnDestroy {
} }
} }
onClickSendSms(calleeNumber: string) {
const smsUtil = new SmsUtils(
this.sessionStorageService,
this.nativeService
);
if (!smsUtil.getAuthSms()) {
this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
data: {
title: '',
html: `SMS 사용 권한이 없습니다.`
}
});
return false;
}
calleeNumber = calleeNumber.replace(/\D/g, '');
if (!!calleeNumber && calleeNumber.length > 0) {
smsUtil.openSendSms(this.loginRes.tokenString, [calleeNumber]);
} else {
// this.dialogService.open<
// AlertDialogComponent,
// AlertDialogData,
// AlertDialogResult
// >(AlertDialogComponent, {
// data: {
// title: '',
// html: `상대방 번호가 없어 전화를 걸 수 없습니다.`
// }
// });
}
}
onClickToggleFavorit(param: { userInfo: UserInfoSS; isFavorit: boolean }) { onClickToggleFavorit(param: { userInfo: UserInfoSS; isFavorit: boolean }) {
this.store.dispatch( this.store.dispatch(
SyncStore.updateBuddy({ SyncStore.updateBuddy({

View File

@ -17,7 +17,8 @@
<div class="left-side"> <div class="left-side">
<app-layout-messenger-left-side <app-layout-messenger-left-side
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(sendCall)="onClickSendClickToCall($event)" (sendCall)="sendClickToCall($event)"
(sendSms)="openSms($event)"
></app-layout-messenger-left-side> ></app-layout-messenger-left-side>
</div> </div>
</as-split-area> </as-split-area>

View File

@ -41,9 +41,13 @@ import {
import { MatDrawer } from '@angular/material'; import { MatDrawer } from '@angular/material';
import { NGXLogger } from 'ngx-logger'; import { NGXLogger } from 'ngx-logger';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { DaesangProtocolService } from '@ucap-webmessenger/daesang'; import { DaesangProtocolService, SmsUtils } from '@ucap-webmessenger/daesang';
import { CallService } from '@ucap-webmessenger/api-prompt'; import { CallService } from '@ucap-webmessenger/api-prompt';
import { EnvironmentsInfo, KEY_ENVIRONMENTS_INFO } from '@app/types'; import {
EnvironmentsInfo,
KEY_ENVIRONMENTS_INFO,
KEY_URL_INFO
} from '@app/types';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { import {
MessageApiService, MessageApiService,
@ -56,6 +60,7 @@ import {
MessageDetailDialogResult, MessageDetailDialogResult,
MessageDetailDialogData MessageDetailDialogData
} from '@app/layouts/messenger/dialogs/message/message-detail.dialog.component'; } from '@app/layouts/messenger/dialogs/message/message-detail.dialog.component';
import { DaesangUrlInfoResponse } from '@ucap-webmessenger/api-external';
@Component({ @Component({
selector: 'app-page-messenger-main', selector: 'app-page-messenger-main',
@ -280,7 +285,7 @@ export class MainPageComponent implements OnInit, OnDestroy {
.subscribe(); .subscribe();
} }
async onClickSendClickToCall(calleeNumber: string) { async sendClickToCall(calleeNumber: string) {
const madn = this.loginRes.madn; const madn = this.loginRes.madn;
if (!madn || madn.trim().length === 0) { if (!madn || madn.trim().length === 0) {
this.dialogService.open< this.dialogService.open<
@ -342,6 +347,29 @@ export class MainPageComponent implements OnInit, OnDestroy {
} }
} }
openSms(calleeNumber: string) {
const smsUtil = new SmsUtils(
this.sessionStorageService,
this.nativeService
);
if (!smsUtil.getAuthSms()) {
this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult
>(AlertDialogComponent, {
data: {
title: '',
html: `SMS 사용 권한이 없습니다.`
}
});
return false;
}
calleeNumber = calleeNumber.replace(/\D/g, '');
smsUtil.openSendSms(this.loginRes.tokenString, [calleeNumber]);
}
onCloseRightDrawer() { onCloseRightDrawer() {
this.rightDrawer.close(); this.rightDrawer.close();
} }

View File

@ -0,0 +1,41 @@
import { DaesangUrlInfoResponse } from '@ucap-webmessenger/api-external';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { KEY_URL_INFO } from '@app/types';
import { NativeService } from '@ucap-webmessenger/native';
export class SmsUtils {
constructor(
private sessionStorageService: SessionStorageService,
private nativeService: NativeService
) {}
url: string;
getAuthSms(): boolean {
const urlInfo: DaesangUrlInfoResponse = this.sessionStorageService.get<
DaesangUrlInfoResponse
>(KEY_URL_INFO);
if (
!!urlInfo &&
!!urlInfo.webLinkAllowedList &&
urlInfo.webLinkAllowedList.indexOf('WebLinkSms') > -1 &&
!!urlInfo.webLink &&
urlInfo.webLink.length > 0 &&
urlInfo.webLink.filter(weblink => weblink.key === 'WebLinkSms').length > 0
) {
this.url = urlInfo.webLink.filter(
weblink => weblink.key === 'WebLinkSms'
)[0].url;
return true;
} else {
return false;
}
}
openSendSms(token: string, calleeNumber?: string[]) {
const url = this.url.replace(/(\(%USER_TOKEN%\))/g, token);
this.nativeService.openDefaultBrowser(url);
}
}

View File

@ -8,6 +8,8 @@ export * from './lib/services/daesang-api.service';
export * from './lib/services/daesang-cipher.service'; export * from './lib/services/daesang-cipher.service';
export * from './lib/services/daesang-protocol.service'; export * from './lib/services/daesang-protocol.service';
export * from './lib/utils/SmsUtils';
export * from './lib/ucap-daesang.module'; export * from './lib/ucap-daesang.module';
export * from './lib/protocols/data-user'; export * from './lib/protocols/data-user';

View File

@ -5,13 +5,17 @@ import {
EventEmitter, EventEmitter,
Output, Output,
ViewChild, ViewChild,
ElementRef ElementRef,
Inject
} from '@angular/core'; } from '@angular/core';
import { UserInfo } from '@ucap-webmessenger/protocol-sync'; import { UserInfo } from '@ucap-webmessenger/protocol-sync';
import { UserInfoF, UserInfoSS } from '@ucap-webmessenger/protocol-query'; import { UserInfoF, UserInfoSS } from '@ucap-webmessenger/protocol-query';
import { FileUploadItem } from '@ucap-webmessenger/api'; import { FileUploadItem } from '@ucap-webmessenger/api';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { SmsUtils } from '@ucap-webmessenger/daesang';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
@Component({ @Component({
selector: 'ucap-profile-profile', selector: 'ucap-profile-profile',
@ -39,6 +43,8 @@ export class ProfileComponent implements OnInit {
@Output() @Output()
sendCall = new EventEmitter<string>(); sendCall = new EventEmitter<string>();
@Output() @Output()
sendSms = new EventEmitter<string>();
@Output()
toggleFavorit = new EventEmitter<{ toggleFavorit = new EventEmitter<{
userInfo: UserInfoSS; userInfo: UserInfoSS;
isFavorit: boolean; isFavorit: boolean;
@ -59,7 +65,10 @@ export class ProfileComponent implements OnInit {
profileImageFileUploadItem: FileUploadItem; profileImageFileUploadItem: FileUploadItem;
constructor() {} constructor(
private sessionStorageService: SessionStorageService,
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService
) {}
ngOnInit() {} ngOnInit() {}
@ -78,7 +87,9 @@ export class ProfileComponent implements OnInit {
this.sendCall.emit(calleeNumber); this.sendCall.emit(calleeNumber);
} }
onClickSMS() {} onClickSMS() {
this.sendSms.emit(this.userInfo.hpNumber);
}
onClickVideoConference() {} onClickVideoConference() {}
@ -169,15 +180,11 @@ export class ProfileComponent implements OnInit {
return true; return true;
} }
} else if (type === 'SMS') { } else if (type === 'SMS') {
if ( const smsUtils = new SmsUtils(
!!this.userInfo && this.sessionStorageService,
!!this.userInfo.hpNumber && this.nativeService
this.userInfo.hpNumber.trim().length > 0 );
) { return !smsUtils.getAuthSms();
return false;
} else {
return true;
}
} }
return true; return true;