@wazo/euc-plugins-sdk
Advanced tools
Comparing version 0.0.11 to 0.0.13
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HIDE = exports.SHOW = void 0; | ||
/* eslint-disable no-unused-vars */ | ||
/* global window, document */ | ||
const events_1 = __importDefault(require("events")); | ||
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED'; | ||
@@ -47,4 +54,8 @@ const BRIDGE_LOGGED_OUT = 'bridge/LOGGED_OUT'; | ||
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED'; | ||
class Softphone { | ||
// Events | ||
exports.SHOW = 'show'; | ||
exports.HIDE = 'hide'; | ||
class Softphone extends events_1.default { | ||
constructor() { | ||
super(...arguments); | ||
this.url = 'https://softphone.wazo.io'; | ||
@@ -55,2 +66,3 @@ this.width = 500; | ||
this.displayed = false; | ||
this.wrapper = null; | ||
this.iframe = null; | ||
@@ -158,14 +170,14 @@ this.iframeLoaded = false; | ||
makeCall(number) { | ||
this.displaySoftphone(); | ||
this.show(); | ||
this._sendMessage(BRIDGE_ON_CLICK_TO_CALL, { number }); | ||
} | ||
toggleSoftphoneDisplay() { | ||
toggleDisplay() { | ||
if (this.displayed) { | ||
this.hideSoftphone(); | ||
this.hide(); | ||
} | ||
else { | ||
this.displaySoftphone(); | ||
this.show(); | ||
} | ||
} | ||
displaySoftphone() { | ||
show() { | ||
if (!this.iframe) { | ||
@@ -178,4 +190,5 @@ this._createIframe(); | ||
this.displayed = true; | ||
this.emit(exports.SHOW); | ||
} | ||
hideSoftphone() { | ||
hide() { | ||
if (this.iframe) { | ||
@@ -185,8 +198,13 @@ this.iframe.style.display = 'none'; | ||
this.displayed = false; | ||
this.emit(exports.HIDE); | ||
} | ||
removeSoftphone() { | ||
remove() { | ||
if (this.iframe) { | ||
this.iframe.remove(); | ||
} | ||
if (this.wrapper) { | ||
this.wrapper.remove(); | ||
} | ||
this.iframe = null; | ||
this.wrapper = null; | ||
} | ||
@@ -214,20 +232,28 @@ optionsFetched(fieldId, options) { | ||
} | ||
configureServer(server) { | ||
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { server }); | ||
} | ||
updateCss(iframeCss = null) { | ||
if (iframeCss) { | ||
if (this.wrapper) { | ||
Object.keys(iframeCss).forEach(key => { | ||
// @ts-ignore: fix CSS key here | ||
this.wrapper.style[key] = iframeCss[key]; | ||
}); | ||
} | ||
this.iframeCss = iframeCss; | ||
} | ||
} | ||
_createIframe(cb) { | ||
this.wrapper = document.createElement('div'); | ||
this.wrapper.id = 'iframe-wrapper'; | ||
this.wrapper.style.position = 'fixed'; | ||
this.updateCss(this.iframeCss); | ||
this.iframe = document.createElement('iframe'); | ||
// $FlowFixMe | ||
this.iframe.width = String(this.width); | ||
// $FlowFixMe | ||
this.iframe.height = String(this.height); | ||
// $FlowFixMe | ||
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *'; | ||
this.iframe.style.position = 'absolute'; | ||
this.iframe.style.border = '1px solid #aaa'; | ||
this.iframe.style.backgroundColor = 'white'; | ||
this.iframe.style.display = 'none'; | ||
Object.keys(this.iframeCss).forEach(key => { | ||
if (this.iframe) { | ||
// @ts-ignore: fix CSS key here | ||
this.iframe.style[key] = this.iframeCss[key]; | ||
} | ||
}); | ||
this.iframe.src = this.url; | ||
@@ -238,4 +264,4 @@ this.iframe.id = 'wazo-softphone'; | ||
} | ||
// $FlowFixMe | ||
document.body.appendChild(this.iframe); | ||
this.wrapper.appendChild(this.iframe); | ||
document.body.appendChild(this.wrapper); | ||
} | ||
@@ -272,3 +298,2 @@ _getLinks() { | ||
case SDK_AUTHENTICATED: | ||
// $FlowFixMe | ||
this._onAuthenticated(event.data.session); | ||
@@ -275,0 +300,0 @@ this.onAuthenticated(event.data.session); |
@@ -0,4 +1,8 @@ | ||
/// <reference types="node" /> | ||
import EventEmitter from 'events'; | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog, IframeCss } from './types'; | ||
export declare const SHOW = "show"; | ||
export declare const HIDE = "hide"; | ||
type Message = [string, Object]; | ||
declare class Softphone { | ||
declare class Softphone extends EventEmitter { | ||
url: string; | ||
@@ -9,2 +13,3 @@ width: number; | ||
displayed: boolean; | ||
wrapper: HTMLDivElement | null; | ||
iframe: HTMLIFrameElement | null; | ||
@@ -54,6 +59,6 @@ iframeLoaded: boolean; | ||
makeCall(number: string): void; | ||
toggleSoftphoneDisplay(): void; | ||
displaySoftphone(): void; | ||
hideSoftphone(): void; | ||
removeSoftphone(): void; | ||
toggleDisplay(): void; | ||
show(): void; | ||
hide(): void; | ||
remove(): void; | ||
optionsFetched(fieldId: string, options: any[]): void; | ||
@@ -66,2 +71,4 @@ onOptionsResults(fieldId: string, options: any[]): void; | ||
loginWithToken(token: string, refreshToken?: string): void; | ||
configureServer(server: string): void; | ||
updateCss(iframeCss?: IframeCss | null): void; | ||
_createIframe(cb?: ((this: GlobalEventHandlers, ev: Event) => any) | null): void; | ||
@@ -68,0 +75,0 @@ _getLinks(): never[]; |
@@ -0,1 +1,4 @@ | ||
/* eslint-disable no-unused-vars */ | ||
/* global window, document */ | ||
import EventEmitter from 'events'; | ||
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED'; | ||
@@ -45,4 +48,8 @@ const BRIDGE_LOGGED_OUT = 'bridge/LOGGED_OUT'; | ||
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED'; | ||
class Softphone { | ||
// Events | ||
export const SHOW = 'show'; | ||
export const HIDE = 'hide'; | ||
class Softphone extends EventEmitter { | ||
constructor() { | ||
super(...arguments); | ||
this.url = 'https://softphone.wazo.io'; | ||
@@ -53,2 +60,3 @@ this.width = 500; | ||
this.displayed = false; | ||
this.wrapper = null; | ||
this.iframe = null; | ||
@@ -156,14 +164,14 @@ this.iframeLoaded = false; | ||
makeCall(number) { | ||
this.displaySoftphone(); | ||
this.show(); | ||
this._sendMessage(BRIDGE_ON_CLICK_TO_CALL, { number }); | ||
} | ||
toggleSoftphoneDisplay() { | ||
toggleDisplay() { | ||
if (this.displayed) { | ||
this.hideSoftphone(); | ||
this.hide(); | ||
} | ||
else { | ||
this.displaySoftphone(); | ||
this.show(); | ||
} | ||
} | ||
displaySoftphone() { | ||
show() { | ||
if (!this.iframe) { | ||
@@ -176,4 +184,5 @@ this._createIframe(); | ||
this.displayed = true; | ||
this.emit(SHOW); | ||
} | ||
hideSoftphone() { | ||
hide() { | ||
if (this.iframe) { | ||
@@ -183,8 +192,13 @@ this.iframe.style.display = 'none'; | ||
this.displayed = false; | ||
this.emit(HIDE); | ||
} | ||
removeSoftphone() { | ||
remove() { | ||
if (this.iframe) { | ||
this.iframe.remove(); | ||
} | ||
if (this.wrapper) { | ||
this.wrapper.remove(); | ||
} | ||
this.iframe = null; | ||
this.wrapper = null; | ||
} | ||
@@ -212,20 +226,28 @@ optionsFetched(fieldId, options) { | ||
} | ||
configureServer(server) { | ||
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { server }); | ||
} | ||
updateCss(iframeCss = null) { | ||
if (iframeCss) { | ||
if (this.wrapper) { | ||
Object.keys(iframeCss).forEach(key => { | ||
// @ts-ignore: fix CSS key here | ||
this.wrapper.style[key] = iframeCss[key]; | ||
}); | ||
} | ||
this.iframeCss = iframeCss; | ||
} | ||
} | ||
_createIframe(cb) { | ||
this.wrapper = document.createElement('div'); | ||
this.wrapper.id = 'iframe-wrapper'; | ||
this.wrapper.style.position = 'fixed'; | ||
this.updateCss(this.iframeCss); | ||
this.iframe = document.createElement('iframe'); | ||
// $FlowFixMe | ||
this.iframe.width = String(this.width); | ||
// $FlowFixMe | ||
this.iframe.height = String(this.height); | ||
// $FlowFixMe | ||
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *'; | ||
this.iframe.style.position = 'absolute'; | ||
this.iframe.style.border = '1px solid #aaa'; | ||
this.iframe.style.backgroundColor = 'white'; | ||
this.iframe.style.display = 'none'; | ||
Object.keys(this.iframeCss).forEach(key => { | ||
if (this.iframe) { | ||
// @ts-ignore: fix CSS key here | ||
this.iframe.style[key] = this.iframeCss[key]; | ||
} | ||
}); | ||
this.iframe.src = this.url; | ||
@@ -236,4 +258,4 @@ this.iframe.id = 'wazo-softphone'; | ||
} | ||
// $FlowFixMe | ||
document.body.appendChild(this.iframe); | ||
this.wrapper.appendChild(this.iframe); | ||
document.body.appendChild(this.wrapper); | ||
} | ||
@@ -270,3 +292,2 @@ _getLinks() { | ||
case SDK_AUTHENTICATED: | ||
// $FlowFixMe | ||
this._onAuthenticated(event.data.session); | ||
@@ -273,0 +294,0 @@ this.onAuthenticated(event.data.session); |
@@ -0,4 +1,8 @@ | ||
/// <reference types="node" /> | ||
import EventEmitter from 'events'; | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog, IframeCss } from './types'; | ||
export declare const SHOW = "show"; | ||
export declare const HIDE = "hide"; | ||
type Message = [string, Object]; | ||
declare class Softphone { | ||
declare class Softphone extends EventEmitter { | ||
url: string; | ||
@@ -9,2 +13,3 @@ width: number; | ||
displayed: boolean; | ||
wrapper: HTMLDivElement | null; | ||
iframe: HTMLIFrameElement | null; | ||
@@ -54,6 +59,6 @@ iframeLoaded: boolean; | ||
makeCall(number: string): void; | ||
toggleSoftphoneDisplay(): void; | ||
displaySoftphone(): void; | ||
hideSoftphone(): void; | ||
removeSoftphone(): void; | ||
toggleDisplay(): void; | ||
show(): void; | ||
hide(): void; | ||
remove(): void; | ||
optionsFetched(fieldId: string, options: any[]): void; | ||
@@ -66,2 +71,4 @@ onOptionsResults(fieldId: string, options: any[]): void; | ||
loginWithToken(token: string, refreshToken?: string): void; | ||
configureServer(server: string): void; | ||
updateCss(iframeCss?: IframeCss | null): void; | ||
_createIframe(cb?: ((this: GlobalEventHandlers, ev: Event) => any) | null): void; | ||
@@ -68,0 +75,0 @@ _getLinks(): never[]; |
{ | ||
"name": "@wazo/euc-plugins-sdk", | ||
"version": "0.0.11", | ||
"version": "0.0.13", | ||
"description": "Wazo's Unified Enterprise Communication JavaScript Software Development Kit.", | ||
@@ -5,0 +5,0 @@ "author": "Wazo (http://wazo.io)", |
/* eslint-disable no-unused-vars */ | ||
/* global window, document */ | ||
import EventEmitter from 'events'; | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog, IframeCss } from './types'; | ||
@@ -52,2 +54,6 @@ | ||
// Events | ||
export const SHOW = 'show'; | ||
export const HIDE = 'hide'; | ||
interface SoftphoneBridgeConfig { | ||
@@ -65,8 +71,9 @@ server: string; | ||
class Softphone { | ||
class Softphone extends EventEmitter { | ||
url: string = 'https://softphone.wazo.io'; | ||
width: number = 500; | ||
height: number = 600; | ||
iframeCss: IframeCss = { left: 0, bottom : 0 }; | ||
iframeCss: IframeCss = { left: 0, bottom: 0 }; | ||
displayed: boolean = false; | ||
wrapper: HTMLDivElement | null = null; | ||
iframe: HTMLIFrameElement | null = null; | ||
@@ -79,16 +86,16 @@ iframeLoaded: boolean = false; | ||
onLinkEnabled(link: HTMLLinkElement) {} | ||
onIFrameLoaded() {} | ||
onLinkEnabled(link: HTMLLinkElement) { } | ||
onIFrameLoaded() { } | ||
onCallLocallyAnswered(call: Call) {} | ||
onCallEstablished(call: Call) {} | ||
onOutgoingCallMade(call: Call) {} | ||
onCallIncoming(call: Call) {} | ||
onCallRejected(call: Call) {} | ||
onCallEnded(call: Call, card: Card, direction: string, fromExtension: string) {} | ||
onCallLocallyAnswered(call: Call) { } | ||
onCallEstablished(call: Call) { } | ||
onOutgoingCallMade(call: Call) { } | ||
onCallIncoming(call: Call) { } | ||
onCallRejected(call: Call) { } | ||
onCallEnded(call: Call, card: Card, direction: string, fromExtension: string) { } | ||
onCardSaved(card: Card) {} | ||
onCardCanceled() {} | ||
onAuthenticated(session: WDASession) {} | ||
onLoggedOut() {} | ||
onCardSaved(card: Card) { } | ||
onCardCanceled() { } | ||
onAuthenticated(session: WDASession) { } | ||
onLoggedOut() { } | ||
@@ -99,25 +106,25 @@ onSearchOptions(fieldId: string, query: string) { | ||
onDisplayLinkedOption(optionId: string) {} | ||
onWazoContactSearch(query: string) {} | ||
onAgentLoggedIn() {} | ||
onAgentLoggedOut() {} | ||
onAgentPaused() {} | ||
onAgentResumed() {} | ||
onLanguageChanged(language: string) {} | ||
onCallHeld() {} | ||
onCallResumed() {} | ||
onCallMuted() {} | ||
onCallUnMuted() {} | ||
onDtmfSent(tone: string) {} | ||
onDirectTransfer(number: string) {} | ||
onCreateIndirectTransfer(number: string) {} | ||
onCancelIndirectTransfer() {} | ||
onConfirmIndirectTransfer() {} | ||
onIndirectCallMade(call: Call) {} | ||
onIndirectTransferDone(call: Call) {} | ||
onStartRecording() {} | ||
onStopRecording() {} | ||
onCallLogCreated(callLog: CallLog) {} | ||
onWebsocketMessage(message: Object) {} | ||
onUnHandledEvent(event: Object) {} | ||
onDisplayLinkedOption(optionId: string) { } | ||
onWazoContactSearch(query: string) { } | ||
onAgentLoggedIn() { } | ||
onAgentLoggedOut() { } | ||
onAgentPaused() { } | ||
onAgentResumed() { } | ||
onLanguageChanged(language: string) { } | ||
onCallHeld() { } | ||
onCallResumed() { } | ||
onCallMuted() { } | ||
onCallUnMuted() { } | ||
onDtmfSent(tone: string) { } | ||
onDirectTransfer(number: string) { } | ||
onCreateIndirectTransfer(number: string) { } | ||
onCancelIndirectTransfer() { } | ||
onConfirmIndirectTransfer() { } | ||
onIndirectCallMade(call: Call) { } | ||
onIndirectTransferDone(call: Call) { } | ||
onStartRecording() { } | ||
onStopRecording() { } | ||
onCallLogCreated(callLog: CallLog) { } | ||
onWebsocketMessage(message: Object) { } | ||
onUnHandledEvent(event: Object) { } | ||
@@ -208,3 +215,3 @@ init({ | ||
makeCall(number: string) { | ||
this.displaySoftphone(); | ||
this.show(); | ||
@@ -214,11 +221,11 @@ this._sendMessage(BRIDGE_ON_CLICK_TO_CALL, { number }); | ||
toggleSoftphoneDisplay() { | ||
toggleDisplay() { | ||
if (this.displayed) { | ||
this.hideSoftphone(); | ||
this.hide(); | ||
} else { | ||
this.displaySoftphone(); | ||
this.show(); | ||
} | ||
} | ||
displaySoftphone() { | ||
show() { | ||
if (!this.iframe) { | ||
@@ -233,16 +240,23 @@ this._createIframe(); | ||
this.displayed = true; | ||
this.emit(SHOW); | ||
} | ||
hideSoftphone() { | ||
hide() { | ||
if (this.iframe) { | ||
this.iframe.style.display = 'none'; | ||
} | ||
this.displayed = false; | ||
this.emit(HIDE); | ||
} | ||
removeSoftphone() { | ||
remove() { | ||
if (this.iframe) { | ||
this.iframe.remove(); | ||
} | ||
if (this.wrapper) { | ||
this.wrapper.remove(); | ||
} | ||
this.iframe = null; | ||
this.wrapper = null; | ||
} | ||
@@ -278,11 +292,31 @@ | ||
configureServer(server: string) { | ||
this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { server }); | ||
} | ||
updateCss(iframeCss: IframeCss | null = null) { | ||
if (iframeCss) { | ||
if (this.wrapper) { | ||
Object.keys(iframeCss).forEach(key => { | ||
// @ts-ignore: fix CSS key here | ||
this.wrapper.style[key] = iframeCss[key]; | ||
}); | ||
} | ||
this.iframeCss = iframeCss; | ||
} | ||
} | ||
_createIframe(cb?: ((this: GlobalEventHandlers, ev: Event) => any) | null) { | ||
this.wrapper = document.createElement('div'); | ||
this.wrapper.id = 'iframe-wrapper'; | ||
this.wrapper.style.position = 'fixed'; | ||
this.updateCss(this.iframeCss); | ||
this.iframe = document.createElement('iframe'); | ||
// $FlowFixMe | ||
this.iframe.width = String(this.width); | ||
// $FlowFixMe | ||
this.iframe.height = String(this.height); | ||
// $FlowFixMe | ||
this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *'; | ||
this.iframe.style.position = 'absolute'; | ||
@@ -293,9 +327,2 @@ this.iframe.style.border = '1px solid #aaa'; | ||
Object.keys(this.iframeCss).forEach(key => { | ||
if (this.iframe) { | ||
// @ts-ignore: fix CSS key here | ||
this.iframe.style[key] = this.iframeCss[key]; | ||
} | ||
}) | ||
this.iframe.src = this.url; | ||
@@ -308,4 +335,4 @@ this.iframe.id = 'wazo-softphone'; | ||
// $FlowFixMe | ||
document.body.appendChild(this.iframe); | ||
this.wrapper.appendChild(this.iframe); | ||
document.body.appendChild(this.wrapper); | ||
} | ||
@@ -349,3 +376,2 @@ | ||
case SDK_AUTHENTICATED: | ||
// $FlowFixMe | ||
this._onAuthenticated(event.data.session); | ||
@@ -352,0 +378,0 @@ this.onAuthenticated(event.data.session); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
139815
3131