@wazo/euc-plugins-sdk
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -30,2 +30,13 @@ "use strict"; | ||
const EVENT_WS_MESSAGE = 'wazo/EVENT_WS_MESSAGE'; | ||
const EVENT_PLAY_PROGRESS_SOUND = 'wazo/EVENT_PLAY_PROGRESS_SOUND'; | ||
const EVENT_PLAY_NEW_MESSAGE_SOUND = 'wazo/EVENT_PLAY_NEW_MESSAGE_SOUND'; | ||
const EVENT_PLAY_INCOMING_CALL_SOUND = 'wazo/EVENT_PLAY_INCOMING_CALL_SOUND'; | ||
const EVENT_PLAY_DOUBLE_CALL_SOUND = 'wazo/EVENT_PLAY_DOUBLE_CALL_SOUND'; | ||
const EVENT_PLAY_HANGUP_SOUND = 'wazo/EVENT_PLAY_HANGUP_SOUND'; | ||
const EVENT_STOP_CURRENT_SOUND = 'wazo/EVENT_STOP_CURRENT_SOUND'; | ||
const EVENT_DISPLAY_NOTIFICATION = 'wazo/EVENT_DISPLAY_NOTIFICATION'; | ||
const EVENT_CHANGE_NAVBAR_COLOR = 'wazo/EVENT_CHANGE_NAVBAR_COLOR'; | ||
const EVENT_RESET_NAVBAR_COLOR = 'wazo/EVENT_RESET_NAVBAR_COLOR'; | ||
const EVENT_DISPLAY_MODAL = 'wazo/EVENT_DISPLAY_MODAL'; | ||
const EVENT_REMOVE_MODAL = 'wazo/EVENT_REMOVE_MODAL'; | ||
// Portal | ||
@@ -36,3 +47,3 @@ const EVENT_ON_CONNECTED_TO_STACK = 'wazo/EVENT_ON_CONNECTED_TO_STACK'; | ||
class App { | ||
onUnLoaded() { } | ||
onUnLoaded(e) { } | ||
; | ||
@@ -87,8 +98,15 @@ constructor() { | ||
}; | ||
this.closeLeftPanel = () => { | ||
this._sendMessage(EVENT_CLOSE_LEFT_PANEL); | ||
}; | ||
this.openLeftPanel = () => { | ||
this._sendMessage(EVENT_OPEN_LEFT_PANEL); | ||
}; | ||
this.closeLeftPanel = () => this._sendMessage(EVENT_CLOSE_LEFT_PANEL); | ||
this.openLeftPanel = () => this._sendMessage(EVENT_OPEN_LEFT_PANEL); | ||
this.playProgressSound = () => this._sendMessage(EVENT_PLAY_PROGRESS_SOUND); | ||
this.playNewMessageSound = () => this._sendMessage(EVENT_PLAY_NEW_MESSAGE_SOUND); | ||
this.playIncomingCallSound = () => this._sendMessage(EVENT_PLAY_INCOMING_CALL_SOUND); | ||
this.playDoubleCallSound = () => this._sendMessage(EVENT_PLAY_DOUBLE_CALL_SOUND); | ||
this.playHangupSound = () => this._sendMessage(EVENT_PLAY_HANGUP_SOUND); | ||
this.stopCurrentSound = () => this._sendMessage(EVENT_STOP_CURRENT_SOUND); | ||
this.changeNavBarColor = (color) => this._sendMessage(EVENT_CHANGE_NAVBAR_COLOR, { color }); | ||
this.resetNavBarColor = () => this._sendMessage(EVENT_RESET_NAVBAR_COLOR); | ||
this.displayNotification = (title, text) => this._sendMessage(EVENT_DISPLAY_NOTIFICATION, { title, text }); | ||
this.displayModal = ({ url, title, text, htmlText, height, width }) => this._sendMessage(EVENT_DISPLAY_MODAL, { url, title, text, htmlText, height, width }); | ||
this.removeModal = () => this._sendMessage(EVENT_REMOVE_MODAL); | ||
this._onMessage = (event) => { | ||
@@ -179,5 +197,9 @@ if (!event.data) { | ||
}; | ||
window.onunload = this.onUnLoaded; | ||
// Can't be simplified as `window.onunload = this.onUnLoaded` | ||
// because `this.onUnLoaded` might not have been overridden by the module yet. | ||
window.onunload = (e) => { | ||
this.onUnLoaded(e); | ||
}; | ||
} | ||
} | ||
exports.default = new App(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED'; | ||
const BRIDGE_LOGGED_OUT = 'bridge/LOGGED_OUT'; | ||
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD'; | ||
@@ -46,3 +47,2 @@ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED'; | ||
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED'; | ||
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT'; | ||
class Softphone { | ||
@@ -53,2 +53,3 @@ constructor() { | ||
this.height = 600; | ||
this.iframeCss = { left: 0, bottom: 0 }; | ||
this.displayed = false; | ||
@@ -99,6 +100,7 @@ this.iframe = null; | ||
onUnHandledEvent(event) { } | ||
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true, tenantId, domainName, debug = false, disableAutoLogin = false, }) { | ||
init({ url, width, height, server, port, language, wrapUpDuration, iframeCss, enableAgent = true, tenantId, domainName, debug = false, disableAutoLogin = false, }) { | ||
this.url = url || this.url; | ||
this.width = width || this.width; | ||
this.height = height || this.height; | ||
this.iframeCss = iframeCss || this.iframeCss; | ||
this.displayed = false; | ||
@@ -150,2 +152,8 @@ this.iframeLoaded = false; | ||
} | ||
removeParsedLinksEvent() { | ||
[].slice.call(document.querySelectorAll('a[data-wazo-parsed]'), 0).forEach((link) => { | ||
link.removeAttribute('data-wazo-parsed'); | ||
link.removeEventListener('click', this._onLinkClick.bind(this)); | ||
}); | ||
} | ||
makeCall(number) { | ||
@@ -178,2 +186,8 @@ this.displaySoftphone(); | ||
} | ||
removeSoftphone() { | ||
if (this.iframe) { | ||
this.iframe.remove(); | ||
} | ||
this.iframe = null; | ||
} | ||
optionsFetched(fieldId, options) { | ||
@@ -209,8 +223,12 @@ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options }); | ||
this.iframe.style.position = 'absolute'; | ||
this.iframe.style.left = '0'; | ||
this.iframe.style.bottom = '0'; | ||
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; | ||
this.iframe.style.display = 'none'; | ||
this.iframe.id = 'wazo-softphone'; | ||
@@ -229,3 +247,3 @@ if (cb) { | ||
e.preventDefault(); | ||
const number = e.target.href.split(':')[1]; | ||
const number = e.target.href.split('//')[1]; | ||
this.makeCall(number); | ||
@@ -258,3 +276,3 @@ } | ||
break; | ||
case SDK_LOGGED_OUT: | ||
case BRIDGE_LOGGED_OUT: | ||
this.onLoggedOut(); | ||
@@ -261,0 +279,0 @@ break; |
@@ -1,2 +0,2 @@ | ||
import { Call, Context, Meeting, UserInfo, Extra } from './types'; | ||
import { Call, Context, Meeting, UserInfo, Extra, ModalParameter } from './types'; | ||
declare class App { | ||
@@ -7,3 +7,3 @@ context: Context; | ||
initializeTimeout: ReturnType<typeof setTimeout> | null; | ||
onUnLoaded(): void; | ||
onUnLoaded(e: Event): void; | ||
onLogout: () => void; | ||
@@ -32,4 +32,15 @@ onCallIncoming: (call: Call) => void; | ||
openSettings: () => void; | ||
closeLeftPanel: () => void; | ||
openLeftPanel: () => void; | ||
closeLeftPanel: () => any; | ||
openLeftPanel: () => any; | ||
playProgressSound: () => any; | ||
playNewMessageSound: () => any; | ||
playIncomingCallSound: () => any; | ||
playDoubleCallSound: () => any; | ||
playHangupSound: () => any; | ||
stopCurrentSound: () => any; | ||
changeNavBarColor: (color: string) => any; | ||
resetNavBarColor: () => any; | ||
displayNotification: (title: string, text: string) => any; | ||
displayModal: ({ url, title, text, htmlText, height, width }: ModalParameter) => any; | ||
removeModal: () => any; | ||
_onMessage: (event: MessageEvent) => void; | ||
@@ -36,0 +47,0 @@ _sendMessage: (type: string, payload?: {}) => any; |
@@ -1,2 +0,2 @@ | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog } from './types'; | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog, IframeCss } from './types'; | ||
type Message = [string, Object]; | ||
@@ -7,2 +7,3 @@ declare class Softphone { | ||
height: number; | ||
iframeCss: IframeCss; | ||
displayed: boolean; | ||
@@ -49,4 +50,5 @@ iframe: HTMLIFrameElement | null; | ||
onUnHandledEvent(event: Object): void; | ||
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent, tenantId, domainName, debug, disableAutoLogin, }: SoftphoneInitArguments): void; | ||
init({ url, width, height, server, port, language, wrapUpDuration, iframeCss, enableAgent, tenantId, domainName, debug, disableAutoLogin, }: SoftphoneInitArguments): void; | ||
parseLinks(): void; | ||
removeParsedLinksEvent(): void; | ||
makeCall(number: string): void; | ||
@@ -56,2 +58,3 @@ toggleSoftphoneDisplay(): void; | ||
hideSoftphone(): void; | ||
removeSoftphone(): void; | ||
optionsFetched(fieldId: string, options: any[]): void; | ||
@@ -58,0 +61,0 @@ onOptionsResults(fieldId: string, options: any[]): void; |
@@ -156,2 +156,13 @@ export declare enum HostClientType { | ||
} | ||
export interface ModalParameter { | ||
url?: string; | ||
title?: string; | ||
text?: string; | ||
htmlText?: string; | ||
height?: string | number; | ||
width?: string | number; | ||
} | ||
export interface IframeCss { | ||
[index: string]: string | number; | ||
} | ||
export interface SoftphoneInitArguments { | ||
@@ -170,2 +181,3 @@ url: string; | ||
disableAutoLogin?: boolean; | ||
iframeCss?: IframeCss; | ||
} | ||
@@ -172,0 +184,0 @@ export interface Card { |
@@ -19,2 +19,13 @@ // WDA | ||
const EVENT_WS_MESSAGE = 'wazo/EVENT_WS_MESSAGE'; | ||
const EVENT_PLAY_PROGRESS_SOUND = 'wazo/EVENT_PLAY_PROGRESS_SOUND'; | ||
const EVENT_PLAY_NEW_MESSAGE_SOUND = 'wazo/EVENT_PLAY_NEW_MESSAGE_SOUND'; | ||
const EVENT_PLAY_INCOMING_CALL_SOUND = 'wazo/EVENT_PLAY_INCOMING_CALL_SOUND'; | ||
const EVENT_PLAY_DOUBLE_CALL_SOUND = 'wazo/EVENT_PLAY_DOUBLE_CALL_SOUND'; | ||
const EVENT_PLAY_HANGUP_SOUND = 'wazo/EVENT_PLAY_HANGUP_SOUND'; | ||
const EVENT_STOP_CURRENT_SOUND = 'wazo/EVENT_STOP_CURRENT_SOUND'; | ||
const EVENT_DISPLAY_NOTIFICATION = 'wazo/EVENT_DISPLAY_NOTIFICATION'; | ||
const EVENT_CHANGE_NAVBAR_COLOR = 'wazo/EVENT_CHANGE_NAVBAR_COLOR'; | ||
const EVENT_RESET_NAVBAR_COLOR = 'wazo/EVENT_RESET_NAVBAR_COLOR'; | ||
const EVENT_DISPLAY_MODAL = 'wazo/EVENT_DISPLAY_MODAL'; | ||
const EVENT_REMOVE_MODAL = 'wazo/EVENT_REMOVE_MODAL'; | ||
// Portal | ||
@@ -25,3 +36,3 @@ const EVENT_ON_CONNECTED_TO_STACK = 'wazo/EVENT_ON_CONNECTED_TO_STACK'; | ||
class App { | ||
onUnLoaded() { } | ||
onUnLoaded(e) { } | ||
; | ||
@@ -76,8 +87,15 @@ constructor() { | ||
}; | ||
this.closeLeftPanel = () => { | ||
this._sendMessage(EVENT_CLOSE_LEFT_PANEL); | ||
}; | ||
this.openLeftPanel = () => { | ||
this._sendMessage(EVENT_OPEN_LEFT_PANEL); | ||
}; | ||
this.closeLeftPanel = () => this._sendMessage(EVENT_CLOSE_LEFT_PANEL); | ||
this.openLeftPanel = () => this._sendMessage(EVENT_OPEN_LEFT_PANEL); | ||
this.playProgressSound = () => this._sendMessage(EVENT_PLAY_PROGRESS_SOUND); | ||
this.playNewMessageSound = () => this._sendMessage(EVENT_PLAY_NEW_MESSAGE_SOUND); | ||
this.playIncomingCallSound = () => this._sendMessage(EVENT_PLAY_INCOMING_CALL_SOUND); | ||
this.playDoubleCallSound = () => this._sendMessage(EVENT_PLAY_DOUBLE_CALL_SOUND); | ||
this.playHangupSound = () => this._sendMessage(EVENT_PLAY_HANGUP_SOUND); | ||
this.stopCurrentSound = () => this._sendMessage(EVENT_STOP_CURRENT_SOUND); | ||
this.changeNavBarColor = (color) => this._sendMessage(EVENT_CHANGE_NAVBAR_COLOR, { color }); | ||
this.resetNavBarColor = () => this._sendMessage(EVENT_RESET_NAVBAR_COLOR); | ||
this.displayNotification = (title, text) => this._sendMessage(EVENT_DISPLAY_NOTIFICATION, { title, text }); | ||
this.displayModal = ({ url, title, text, htmlText, height, width }) => this._sendMessage(EVENT_DISPLAY_MODAL, { url, title, text, htmlText, height, width }); | ||
this.removeModal = () => this._sendMessage(EVENT_REMOVE_MODAL); | ||
this._onMessage = (event) => { | ||
@@ -168,5 +186,9 @@ if (!event.data) { | ||
}; | ||
window.onunload = this.onUnLoaded; | ||
// Can't be simplified as `window.onunload = this.onUnLoaded` | ||
// because `this.onUnLoaded` might not have been overridden by the module yet. | ||
window.onunload = (e) => { | ||
this.onUnLoaded(e); | ||
}; | ||
} | ||
} | ||
export default new App(); |
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED'; | ||
const BRIDGE_LOGGED_OUT = 'bridge/LOGGED_OUT'; | ||
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD'; | ||
@@ -44,3 +45,2 @@ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED'; | ||
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED'; | ||
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT'; | ||
class Softphone { | ||
@@ -51,2 +51,3 @@ constructor() { | ||
this.height = 600; | ||
this.iframeCss = { left: 0, bottom: 0 }; | ||
this.displayed = false; | ||
@@ -97,6 +98,7 @@ this.iframe = null; | ||
onUnHandledEvent(event) { } | ||
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true, tenantId, domainName, debug = false, disableAutoLogin = false, }) { | ||
init({ url, width, height, server, port, language, wrapUpDuration, iframeCss, enableAgent = true, tenantId, domainName, debug = false, disableAutoLogin = false, }) { | ||
this.url = url || this.url; | ||
this.width = width || this.width; | ||
this.height = height || this.height; | ||
this.iframeCss = iframeCss || this.iframeCss; | ||
this.displayed = false; | ||
@@ -148,2 +150,8 @@ this.iframeLoaded = false; | ||
} | ||
removeParsedLinksEvent() { | ||
[].slice.call(document.querySelectorAll('a[data-wazo-parsed]'), 0).forEach((link) => { | ||
link.removeAttribute('data-wazo-parsed'); | ||
link.removeEventListener('click', this._onLinkClick.bind(this)); | ||
}); | ||
} | ||
makeCall(number) { | ||
@@ -176,2 +184,8 @@ this.displaySoftphone(); | ||
} | ||
removeSoftphone() { | ||
if (this.iframe) { | ||
this.iframe.remove(); | ||
} | ||
this.iframe = null; | ||
} | ||
optionsFetched(fieldId, options) { | ||
@@ -207,8 +221,12 @@ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options }); | ||
this.iframe.style.position = 'absolute'; | ||
this.iframe.style.left = '0'; | ||
this.iframe.style.bottom = '0'; | ||
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; | ||
this.iframe.style.display = 'none'; | ||
this.iframe.id = 'wazo-softphone'; | ||
@@ -227,3 +245,3 @@ if (cb) { | ||
e.preventDefault(); | ||
const number = e.target.href.split(':')[1]; | ||
const number = e.target.href.split('//')[1]; | ||
this.makeCall(number); | ||
@@ -256,3 +274,3 @@ } | ||
break; | ||
case SDK_LOGGED_OUT: | ||
case BRIDGE_LOGGED_OUT: | ||
this.onLoggedOut(); | ||
@@ -259,0 +277,0 @@ break; |
@@ -1,2 +0,2 @@ | ||
import { Call, Context, Meeting, UserInfo, Extra } from './types'; | ||
import { Call, Context, Meeting, UserInfo, Extra, ModalParameter } from './types'; | ||
declare class App { | ||
@@ -7,3 +7,3 @@ context: Context; | ||
initializeTimeout: ReturnType<typeof setTimeout> | null; | ||
onUnLoaded(): void; | ||
onUnLoaded(e: Event): void; | ||
onLogout: () => void; | ||
@@ -32,4 +32,15 @@ onCallIncoming: (call: Call) => void; | ||
openSettings: () => void; | ||
closeLeftPanel: () => void; | ||
openLeftPanel: () => void; | ||
closeLeftPanel: () => any; | ||
openLeftPanel: () => any; | ||
playProgressSound: () => any; | ||
playNewMessageSound: () => any; | ||
playIncomingCallSound: () => any; | ||
playDoubleCallSound: () => any; | ||
playHangupSound: () => any; | ||
stopCurrentSound: () => any; | ||
changeNavBarColor: (color: string) => any; | ||
resetNavBarColor: () => any; | ||
displayNotification: (title: string, text: string) => any; | ||
displayModal: ({ url, title, text, htmlText, height, width }: ModalParameter) => any; | ||
removeModal: () => any; | ||
_onMessage: (event: MessageEvent) => void; | ||
@@ -36,0 +47,0 @@ _sendMessage: (type: string, payload?: {}) => any; |
@@ -1,2 +0,2 @@ | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog } from './types'; | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog, IframeCss } from './types'; | ||
type Message = [string, Object]; | ||
@@ -7,2 +7,3 @@ declare class Softphone { | ||
height: number; | ||
iframeCss: IframeCss; | ||
displayed: boolean; | ||
@@ -49,4 +50,5 @@ iframe: HTMLIFrameElement | null; | ||
onUnHandledEvent(event: Object): void; | ||
init({ url, width, height, server, port, language, wrapUpDuration, enableAgent, tenantId, domainName, debug, disableAutoLogin, }: SoftphoneInitArguments): void; | ||
init({ url, width, height, server, port, language, wrapUpDuration, iframeCss, enableAgent, tenantId, domainName, debug, disableAutoLogin, }: SoftphoneInitArguments): void; | ||
parseLinks(): void; | ||
removeParsedLinksEvent(): void; | ||
makeCall(number: string): void; | ||
@@ -56,2 +58,3 @@ toggleSoftphoneDisplay(): void; | ||
hideSoftphone(): void; | ||
removeSoftphone(): void; | ||
optionsFetched(fieldId: string, options: any[]): void; | ||
@@ -58,0 +61,0 @@ onOptionsResults(fieldId: string, options: any[]): void; |
@@ -156,2 +156,13 @@ export declare enum HostClientType { | ||
} | ||
export interface ModalParameter { | ||
url?: string; | ||
title?: string; | ||
text?: string; | ||
htmlText?: string; | ||
height?: string | number; | ||
width?: string | number; | ||
} | ||
export interface IframeCss { | ||
[index: string]: string | number; | ||
} | ||
export interface SoftphoneInitArguments { | ||
@@ -170,2 +181,3 @@ url: string; | ||
disableAutoLogin?: boolean; | ||
iframeCss?: IframeCss; | ||
} | ||
@@ -172,0 +184,0 @@ export interface Card { |
{ | ||
"name": "@wazo/euc-plugins-sdk", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Wazo's Unified Enterprise Communication JavaScript Software Development Kit.", | ||
@@ -52,3 +52,3 @@ "author": "Wazo (http://wazo.io)", | ||
"build": "npm run clean && npm run build:esm && npm run build:cjs", | ||
"build:esm": "tsc -p tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs", | ||
"build:esm": "tsc -p tsconfig.esm.json", | ||
"build:cjs": "tsc -p tsconfig.cjs.json", | ||
@@ -55,0 +55,0 @@ "prepack": "npm run build", |
@@ -1,2 +0,2 @@ | ||
import { Call, Context, Meeting, UserInfo, Extra } from './types'; | ||
import { Call, Context, Meeting, UserInfo, Extra, ModalParameter } from './types'; | ||
@@ -21,2 +21,13 @@ // WDA | ||
const EVENT_WS_MESSAGE = 'wazo/EVENT_WS_MESSAGE'; | ||
const EVENT_PLAY_PROGRESS_SOUND = 'wazo/EVENT_PLAY_PROGRESS_SOUND'; | ||
const EVENT_PLAY_NEW_MESSAGE_SOUND = 'wazo/EVENT_PLAY_NEW_MESSAGE_SOUND'; | ||
const EVENT_PLAY_INCOMING_CALL_SOUND = 'wazo/EVENT_PLAY_INCOMING_CALL_SOUND'; | ||
const EVENT_PLAY_DOUBLE_CALL_SOUND = 'wazo/EVENT_PLAY_DOUBLE_CALL_SOUND'; | ||
const EVENT_PLAY_HANGUP_SOUND = 'wazo/EVENT_PLAY_HANGUP_SOUND'; | ||
const EVENT_STOP_CURRENT_SOUND = 'wazo/EVENT_STOP_CURRENT_SOUND'; | ||
const EVENT_DISPLAY_NOTIFICATION = 'wazo/EVENT_DISPLAY_NOTIFICATION'; | ||
const EVENT_CHANGE_NAVBAR_COLOR = 'wazo/EVENT_CHANGE_NAVBAR_COLOR'; | ||
const EVENT_RESET_NAVBAR_COLOR = 'wazo/EVENT_RESET_NAVBAR_COLOR'; | ||
const EVENT_DISPLAY_MODAL = 'wazo/EVENT_DISPLAY_MODAL'; | ||
const EVENT_REMOVE_MODAL = 'wazo/EVENT_REMOVE_MODAL'; | ||
@@ -35,3 +46,3 @@ // Portal | ||
onUnLoaded() {}; | ||
onUnLoaded(e: Event) {}; | ||
@@ -69,3 +80,7 @@ // WDA | ||
window.onunload = this.onUnLoaded; | ||
// Can't be simplified as `window.onunload = this.onUnLoaded` | ||
// because `this.onUnLoaded` might not have been overridden by the module yet. | ||
window.onunload = (e: Event) => { | ||
this.onUnLoaded(e); | ||
} | ||
} | ||
@@ -119,10 +134,29 @@ | ||
closeLeftPanel = () => { | ||
this._sendMessage(EVENT_CLOSE_LEFT_PANEL); | ||
}; | ||
closeLeftPanel = () => this._sendMessage(EVENT_CLOSE_LEFT_PANEL); | ||
openLeftPanel = () => { | ||
this._sendMessage(EVENT_OPEN_LEFT_PANEL); | ||
}; | ||
openLeftPanel = () => this._sendMessage(EVENT_OPEN_LEFT_PANEL); | ||
playProgressSound = () => this._sendMessage(EVENT_PLAY_PROGRESS_SOUND); | ||
playNewMessageSound = () => this._sendMessage(EVENT_PLAY_NEW_MESSAGE_SOUND); | ||
playIncomingCallSound = () => this._sendMessage(EVENT_PLAY_INCOMING_CALL_SOUND); | ||
playDoubleCallSound = () => this._sendMessage(EVENT_PLAY_DOUBLE_CALL_SOUND); | ||
playHangupSound = () => this._sendMessage(EVENT_PLAY_HANGUP_SOUND); | ||
stopCurrentSound = () => this._sendMessage(EVENT_STOP_CURRENT_SOUND); | ||
changeNavBarColor = (color: string) => this._sendMessage(EVENT_CHANGE_NAVBAR_COLOR, { color }); | ||
resetNavBarColor = () => this._sendMessage(EVENT_RESET_NAVBAR_COLOR); | ||
displayNotification = (title: string, text: string) => this._sendMessage(EVENT_DISPLAY_NOTIFICATION, { title, text }); | ||
displayModal = ({ url, title, text, htmlText, height, width }: ModalParameter) => | ||
this._sendMessage(EVENT_DISPLAY_MODAL, { url, title, text, htmlText, height, width }); | ||
removeModal = () => this._sendMessage(EVENT_REMOVE_MODAL); | ||
_onMessage = (event: MessageEvent) => { | ||
@@ -129,0 +163,0 @@ if (!event.data) { |
/* eslint-disable no-unused-vars */ | ||
/* global window, document */ | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog } from './types'; | ||
import { SoftphoneInitArguments, Call, WDASession, Card, CallLog, IframeCss } from './types'; | ||
const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED'; | ||
const BRIDGE_LOGGED_OUT = 'bridge/LOGGED_OUT'; | ||
const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD'; | ||
@@ -50,3 +51,2 @@ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED'; | ||
const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED'; | ||
const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT'; | ||
@@ -69,2 +69,3 @@ interface SoftphoneBridgeConfig { | ||
height: number = 600; | ||
iframeCss: IframeCss = { left: 0, bottom : 0 }; | ||
displayed: boolean = false; | ||
@@ -129,2 +130,3 @@ iframe: HTMLIFrameElement | null = null; | ||
wrapUpDuration, | ||
iframeCss, | ||
enableAgent = true, | ||
@@ -139,2 +141,3 @@ tenantId, | ||
this.height = height || this.height; | ||
this.iframeCss = iframeCss || this.iframeCss; | ||
this.displayed = false; | ||
@@ -197,2 +200,9 @@ this.iframeLoaded = false; | ||
removeParsedLinksEvent() { | ||
[].slice.call(document.querySelectorAll('a[data-wazo-parsed]'), 0).forEach((link: HTMLLinkElement) => { | ||
link.removeAttribute('data-wazo-parsed'); | ||
link.removeEventListener('click', this._onLinkClick.bind(this)); | ||
}); | ||
} | ||
makeCall(number: string) { | ||
@@ -231,2 +241,9 @@ this.displaySoftphone(); | ||
removeSoftphone() { | ||
if (this.iframe) { | ||
this.iframe.remove(); | ||
} | ||
this.iframe = null; | ||
} | ||
optionsFetched(fieldId: string, options: any[]) { | ||
@@ -269,8 +286,15 @@ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options }); | ||
this.iframe.style.position = 'absolute'; | ||
this.iframe.style.left = '0'; | ||
this.iframe.style.bottom = '0'; | ||
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; | ||
this.iframe.style.display = 'none'; | ||
this.iframe.id = 'wazo-softphone'; | ||
@@ -293,3 +317,3 @@ | ||
e.preventDefault(); | ||
const number = (e.target as HTMLLinkElement).href.split(':')[1]; | ||
const number = (e.target as HTMLLinkElement).href.split('//')[1]; | ||
@@ -327,3 +351,3 @@ this.makeCall(number); | ||
break; | ||
case SDK_LOGGED_OUT: | ||
case BRIDGE_LOGGED_OUT: | ||
this.onLoggedOut(); | ||
@@ -330,0 +354,0 @@ break; |
@@ -155,2 +155,13 @@ export enum HostClientType { | ||
export interface ModalParameter { | ||
url?: string; | ||
title?: string; | ||
text?: string; | ||
htmlText?: string; | ||
height?: string|number; | ||
width?: string|number; | ||
} | ||
export interface IframeCss { [index: string]: string|number } | ||
export interface SoftphoneInitArguments { | ||
@@ -169,2 +180,3 @@ url: string; | ||
disableAutoLogin?: boolean; | ||
iframeCss?: IframeCss; | ||
} | ||
@@ -171,0 +183,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
115096
2607