From: Andrea Bianco Date: Sat, 28 Sep 2019 06:05:26 +0000 (+0200) Subject: Built xcally-motion-dialpad from commit 141221b.|1.0.96 X-Git-Tag: 1.0.97 X-Git-Url: http://repos.xcallymotion.com/base/%22https:/wiki.xcallymotion.com/display/XMV//%22?a=commitdiff_plain;p=dialpad.git Built xcally-motion-dialpad from commit 141221b.|1.0.96 --- diff --git a/app.a6d55712.js b/app.93200183.js similarity index 79% rename from app.a6d55712.js rename to app.93200183.js index 0b239ff..7bc304d 100644 --- a/app.a6d55712.js +++ b/app.93200183.js @@ -1 +1 @@ -"use strict";config.$inject=["$locationProvider","$mdThemingProvider"],classicController.$inject=["$scope","$window","$interval","$location","angularLoad","$http"],lightningController.$inject=["$scope","$window","$interval","$location","angularLoad","$http"],deskController.$inject=["$scope","$window","$interval","$location","angularLoad","$http"];var motion=angular.module("motion",["ngMaterial","angularLoad"]);function config(e,n){e.html5Mode(!0),n.theme("default").dark()}function classicController(t,e,n,a,r,i){var o=this,s={},l={},u=null;o.timer="",o.phone="",o.inCall=!1;var c={},d={};o.compose=function(e){o.phone=o.phone.concat(e)},o.remove=function(){o.phone=o.phone.substring(0,o.phone.length-1)},o.hangup=function(){o.phone="",i.get("http://localhost:9888/api/hangup")},o.dial=function(){i.get("http://localhost:9888/api/originate/"+o.phone),i.get("http://localhost:9888/api/answer"),sforce.interaction.runApex("UserInfo","getUserId",null,w)};var m=0;function p(e){e.result?sforce.interaction.cti.onClickToDial(h):console.error("Something went wrong! Errors:",e.errors)}function g(e){var n={};e.result?(n=JSON.parse(e.result),o.host=n["/Motion/Host"],d.createTask=n["/ManageTask/createTask"],d.createTask=d.createTask?d.createTask:"false",d.createOnAnswer=n["/ManageTask/createOnAnswer"],d.createOnAnswer=d.createOnAnswer?d.createOnAnswer:"false",d.updateOnHangup=n["/ManageTask/updateOnHangup"],d.updateOnHangup=d.updateOnHangup?d.updateOnHangup:"false",d.refreshOnHangup=n["/ManageTask/refreshOnHangup"],d.refreshOnHangup=d.refreshOnHangup?d.refreshOnHangup:"false",d.defaultCreateStatus=n["/ManageTask/defaultCreateStatus"],d.defaultCreateStatus=d.defaultCreateStatus?d.defaultCreateStatus:"In Progress",d.defaultUpdateStatus=n["/ManageTask/defaultUpdateStatus"],d.defaultUpdateStatus=d.defaultUpdateStatus?d.defaultUpdateStatus:"Completed",d.uniqueid=n["/FieldMapping/uniqueid"],d.uniqueid=d.uniqueid?d.uniqueid:null,d.agent=n["/FieldMapping/agent"],d.agent=d.agent?d.agent:null,d.callerid=n["/FieldMapping/callerid"],d.callerid=d.callerid?d.callerid:null,d.date=n["/FieldMapping/date"],d.date=d.date?d.date:null,d.time=n["/FieldMapping/time"],d.time=d.time?d.time:null,d.starttime=n["/FieldMapping/starttime"],d.starttime=d.starttime?d.starttime:null,d.endtime=n["/FieldMapping/endtime"],d.endtime=d.endtime?d.endtime:null,d.answertime=n["/FieldMapping/answertime"],d.answertime=d.answertime?d.answertime:null,d.holdtime=n["/FieldMapping/holdtime"],d.holdtime=d.holdtime?d.holdtime:null,d.duration=n["/FieldMapping/duration"],d.duration=d.duration?d.duration:null,d.billsec=n["/FieldMapping/billsec"],d.billsec=d.billsec?d.billsec:null):console.error("Something went wrong! Errors:",e.errors)}function h(e){var n=JSON.parse(e.result);m<1&&o.online&&n.number&&(o.phone=n.number,c.endUserPhone=angular.copy(n.number),c.endUserObjectType=n.object,c.endUserId=n.objectId,c.endUserName=n.objectName,o.dial(),m++)}function f(e){console.log("Display",e),sforce.interaction.screenPop(e.recordId,!0,v)}function w(e){e.result?c.userId=String(e.result):console.error("Something went wrong! Errors:",e.errors)}function b(e){c.activityDate=moment().utc();var n=c.endUserId.substr(0,3),t="";t+="*** Call Info ***\n",t+="Called Number: "+c.endUserPhone+"\n",t+="Member Name: "+e.membername+"\n",t+="UniqueId: "+e.uniqueid+"\n",t+="Date: "+e.starttime+"\n",t+="*** Time Info ***\n",e.answertime&&(t+="Answer Time: "+e.answertime+"\n");var a="Subject=Outbound Call [xCALLY Ticket] "+c.endUserPhone;if(a+="&Activitydate="+c.activityDate,a+="&Phone="+c.endUserPhone,a+="&Description="+t,a+="&OwnerId="+c.userId,a+="003"===n||"00Q"===n?"&whoId="+c.endUserId:"&whatId="+c.endUserId,a+="&Priority=Normal",a+="&Status="+d.defaultCreateStatus,a+="&Type=Call",d.uniqueid&&e.uniqueid&&(a+="&"+d.uniqueid+"="+String(e.uniqueid)),d.agent&&o.fullname&&(a+="&"+d.agent+"="+o.fullname),d.callerid&&e.calleridnum&&(a+="&"+d.callerid+"="+e.calleridnum),d.date&&e.starttime){var r=String(e.starttime).split(" ")[0];a+="&"+d.date+"="+r}if(d.time&&e.starttime){var i=String(e.starttime).split(" ")[1];a+="&"+d.time+"="+i}d.starttime&&e.starttime&&(a+="&"+d.starttime+"="+e.starttime),d.answertime&&e.answertime&&(a+="&"+d.answertime+"="+e.answertime),sforce.interaction.saveLog("Task",encodeURI(a),S),t=""}function S(e){e.result?(c.Id=e.result,m=0,sforce.interaction.screenPop("/"+c.Id,!0,v)):console.error("Something went wrong! Errors:",e.errors)}function v(e){e.result?console.log("API screenPop executed successfully!"):console.error("Something went wrong! Errors:",e.errors)}function C(e){"true"===d.createTask&&"true"===d.updateOnHangup&&"true"===d.refreshOnHangup?e.result?(c={},sforce.interaction.refreshPage(I)):console.error("Something went wrong! Errors:",e.errors):c={}}function I(e){e.result?console.log("API refreshView classic executed successfully! returnValue:",e.result):console.error("Something went wrong! Errors:",e.errors)}angular.element(document.createElement("base")).href=window.location.pathname,r.loadScript(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/js/salesforce/interaction.js").then(function(){console.log("Salesforce Classic"),sforce.interaction.cti.getCallCenterSettings(g),sforce.interaction.cti.enableClickToDial(p)}).catch(function(e){console.error(e)}),n(function(){var e=Date.now();i.get("http://localhost:9888/api/agent").then(s[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;o.id=n.id,o.name=n.name,o.fullname=n.fullname,o.internal=String(n.internal),o.online=!0,u||o.host&&o.id&&((u=io(o.host,{query:{id:o.id},autoConnect:!1,transports:["websocket","polling"]})).on("trigger:salesforce:display",f),u.on("voice_outbound_channel:save",function(e){e.destexten&&e.destexten===String(c.endUserPhone)&&!e.dialstatus&&"true"===d.createTask&&"false"===d.createOnAnswer&&b(e),e.destexten&&e.destexten===String(c.endUserPhone)&&e.dialstatus&&"ANSWER"===e.dialstatus&&"true"===d.createTask&&"true"===d.createOnAnswer&&b(e)}),u.on("voice_outbound_channel:remove",function(e){o.phone="",e.destexten&&e.destexten===String(c.endUserPhone)&&("true"===d.createTask&&"true"===d.updateOnHangup?function(e){c.activityDate=moment().utc();var n="";n+="*** Call Info ***\n",n+="Called Number: "+c.endUserPhone+"\n",n+="Member Name: "+e.membername+"\n",n+="UniqueId: "+e.uniqueid+"\n",n+="Date: "+e.endtime+"\n",n+="*** Time Info ***\n",e.answertime&&(n+="Answer Time: "+e.answertime+"\n"),n+="End Time: "+e.endtime+"\n",e.holdtime&&(n+="Hold Time: "+e.holdtime+"\n"),n+="Duration: "+e.duration+"\n",e.billableseconds&&(n+="Billable Seconds: "+e.billableseconds+"\n");var t="Id="+c.Id;if(t+="&Activitydate="+c.activityDate,t+="&Status="+d.defaultUpdateStatus,t+="&Description="+n,d.date&&e.endtime){var a=String(e.endtime).split(" ")[0];t+="&"+d.date+"="+a}if(d.time&&e.endtime){var r=String(e.endtime).split(" ")[1];t+="&"+d.time+"="+r}d.endtime&&e.endtime&&(t+="&"+d.endtime+"="+e.endtime),d.answertime&&e.answertime&&(t+="&"+d.answertime+"="+e.answertime),d.holdtime&&e.holdtime&&(t+="&"+d.holdtime+"="+e.holdtime),d.duration&&e.duration&&(t+="&"+d.duration+"="+String(e.duration)),d.billsec&&e.billableseconds&&(t+="&"+d.billsec+"="+String(e.billableseconds)),sforce.interaction.saveLog("Task",encodeURI(t),C),n=""}(e):c={})})),u&&u.disconnected&&u.connect()}else o.online=!1}).catch(function(e){console.error(e)})},2e3),n(function(){var e=Date.now();i.get("http://localhost:9888/api/calls").then(l[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;_.isArray(n)&&_.find(n,{stateId:8})?(o.timer=(t=n[0].callingNumber,a=n[0].activeDuration,r=t+" ACTIVE (",r+=a.hours<10?"0":"",r+=a.hours,r+=":",r+=a.minutes<10?"0":"",r+=a.minutes,r+=":",r+=a.seconds<10?"0":"",r+=a.seconds,r+=")"),o.inCall=!0):(o.inCall=!1,o.timer="")}else o.inCall=!1,o.timer="";var t,a,r}).catch(function(e){console.error(e)})},1e3),e.addEventListener("message",function(e){var n=e.data;s[n.uniqueid]?(s[n.uniqueid](n),delete s[n.uniqueid]):l[n.uniqueid]&&(l[n.uniqueid](n),delete l[n.uniqueid]),t.$apply()},!1)}function lightningController(t,e,n,a,r,i){var o=this,s={},l={},u=null;o.timer="",o.phone="",o.inCall=!1;var c={},d={};o.compose=function(e){o.phone=o.phone.concat(e)},o.remove=function(){o.phone=o.phone.substring(0,o.phone.length-1)},o.hangup=function(){o.phone="",i.get("http://localhost:9888/api/hangup")},o.dial=function(){i.get("http://localhost:9888/api/originate/"+o.phone),i.get("http://localhost:9888/api/answer"),e={apexClass:"UserInfo",methodName:"getUserId",callback:w},sforce.opencti.runApex(e);var e};var m=0;function p(e){console.log("enableClickToDialCallback",e),e.success?sforce.opencti.onClickToDial({listener:h}):console.error("Something went wrong! Errors:",e.errors)}function g(e){e.success?(o.host=e.returnValue["/Motion/Host"],d.createTask=e.returnValue["/ManageTask/createTask"],d.createTask=d.createTask?d.createTask:"false",d.createOnAnswer=e.returnValue["/ManageTask/createOnAnswer"],d.createOnAnswer=d.createOnAnswer?d.createOnAnswer:"false",d.updateOnHangup=e.returnValue["/ManageTask/updateOnHangup"],d.updateOnHangup=d.updateOnHangup?d.updateOnHangup:"false",d.refreshOnHangup=e.returnValue["/ManageTask/refreshOnHangup"],d.refreshOnHangup=d.refreshOnHangup?d.refreshOnHangup:"false",d.defaultCreateStatus=e.returnValue["/ManageTask/defaultCreateStatus"],d.defaultCreateStatus=d.defaultCreateStatus?d.defaultCreateStatus:"In Progress",d.defaultUpdateStatus=e.returnValue["/ManageTask/defaultUpdateStatus"],d.defaultUpdateStatus=d.defaultUpdateStatus?d.defaultUpdateStatus:"Completed",d.uniqueid=e.returnValue["/FieldMapping/uniqueid"],d.uniqueid=d.uniqueid?d.uniqueid:null,d.agent=e.returnValue["/FieldMapping/agent"],d.agent=d.agent?d.agent:null,d.callerid=e.returnValue["/FieldMapping/callerid"],d.callerid=d.callerid?d.callerid:null,d.date=e.returnValue["/FieldMapping/date"],d.date=d.date?d.date:null,d.time=e.returnValue["/FieldMapping/time"],d.time=d.time?d.time:null,d.starttime=e.returnValue["/FieldMapping/starttime"],d.starttime=d.starttime?d.starttime:null,d.endtime=e.returnValue["/FieldMapping/endtime"],d.endtime=d.endtime?d.endtime:null,d.answertime=e.returnValue["/FieldMapping/answertime"],d.answertime=d.answertime?d.answertime:null,d.holdtime=e.returnValue["/FieldMapping/holdtime"],d.holdtime=d.holdtime?d.holdtime:null,d.duration=e.returnValue["/FieldMapping/duration"],d.duration=d.duration?d.duration:null,d.billsec=e.returnValue["/FieldMapping/billsec"],d.billsec=d.billsec?d.billsec:null):console.error("Something went wrong! Errors:",e.errors)}function h(e){m<1&&o.online&&e.number&&(o.phone=e.number,c.endUserPhone=angular.copy(e.number),c.endUserObjectType=e.objectType,c.endUserId=e.recordId,c.endUserName=e.recordName,o.dial(),m++)}function f(e){sforce.opencti.screenPop({type:sforce.opencti.SCREENPOP_TYPE.SOBJECT,params:{recordId:e.recordId}})}function w(e){e.success?c.userId=String(e.returnValue.runApex):console.error("Something went wrong! Errors:",e.errors)}function b(e){c.activityDate=moment().utc();var n=c.endUserId.substr(0,3),t="";t+="*** Call Info ***\n",t+="Called Number: "+c.endUserPhone+"\n",t+="Member Name: "+e.membername+"\n",t+="UniqueId: "+e.uniqueid+"\n",t+="Date: "+e.starttime+"\n",t+="*** Time Info ***\n",e.answertime&&(t+="Answer Time: "+e.answertime+"\n");var a={OwnerId:c.userId,ActivityDate:c.activityDate,IsReminderSet:!1,IsRecurrence:!1,Subject:"Outbound Call [xCALLY Ticket] "+c.endUserPhone,Description:t,Priority:"Normal",Type:"Call",Status:d.defaultCreateStatus,entityApiName:"Task"};if("003"===n||"00Q"===n?a.WhoId=c.endUserId:a.WhatId=c.endUserId,d.uniqueid&&e.uniqueid&&(a[d.uniqueid]=String(e.uniqueid)),d.agent&&o.fullname&&(a[d.agent]=o.fullname),d.callerid&&e.calleridnum&&(a[d.callerid]=e.calleridnum),d.date&&e.starttime){var r=String(e.starttime).split(" ")[0];a[d.date]=r}if(d.time&&e.starttime){var i=String(e.starttime).split(" ")[1];a[d.time]=i}d.starttime&&e.starttime&&(a[d.starttime]=e.starttime),d.answertime&&e.answertime&&(a[d.answertime]=e.answertime),sforce.opencti.saveLog({value:JSON.parse(JSON.stringify(a)),callback:S}),t=""}function S(e){e.success?(c.Id=e.returnValue.recordId,m=0,sforce.opencti.screenPop({type:sforce.opencti.SCREENPOP_TYPE.SOBJECT,params:{recordId:c.Id},callback:v})):console.error("Something went wrong! Errors:",e.errors)}function v(e){e.success?console.log("API screenPop executed successfully!"):console.error("Something went wrong! Errors:",e.errors)}function C(e){"true"===d.createTask&&"true"===d.updateOnHangup&&"true"===d.refreshOnHangup?e.success?(c={},sforce.opencti.refreshView({callback:I})):console.error("Something went wrong! Errors:",e.errors):c={}}function I(e){console.log("API refreshView classic executed successfully! returnValue:",e),e.success?console.log("API refreshView lightning executed successfully!"):console.error("Something went wrong! Errors:",e.errors)}angular.element(document.createElement("base")).href=window.location.pathname,r.loadScript(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/js/salesforce/lightning.js").then(function(){console.log("Salesforce Lightning"),sforce.opencti.getCallCenterSettings({callback:g}),sforce.opencti.enableClickToDial({callback:p})}).catch(function(e){console.error(e)}),n(function(){var e=Date.now();i.get("http://localhost:9888/api/agent").then(s[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;o.id=n.id,o.name=n.name,o.fullname=n.fullname,o.internal=String(n.internal),o.online=!0,u||o.host&&o.id&&((u=io(o.host,{query:{id:o.id},autoConnect:!1,transports:["websocket","polling"]})).on("trigger:salesforce:display",f),u.on("voice_outbound_channel:save",function(e){e.destexten&&e.destexten===String(c.endUserPhone)&&!e.dialstatus&&"true"===d.createTask&&"false"===d.createOnAnswer&&b(e),e.destexten&&e.destexten===String(c.endUserPhone)&&e.dialstatus&&"ANSWER"===e.dialstatus&&"true"===d.createTask&&"true"===d.createOnAnswer&&b(e)}),u.on("voice_outbound_channel:remove",function(e){o.phone="",e.destexten&&e.destexten===String(c.endUserPhone)&&("true"===d.createTask&&"true"===d.updateOnHangup?function(e){c.activityDate=moment().utc();var n="";n+="*** Call Info ***\n",n+="Called Number: "+c.endUserPhone+"\n",n+="Member Name: "+e.membername+"\n",n+="UniqueId: "+e.uniqueid+"\n",n+="Date: "+e.endtime+"\n",n+="*** Time Info ***\n",e.answertime&&(n+="Answer Time: "+e.answertime+"\n"),e.endtime&&(n+="End Time: "+e.endtime+"\n"),e.holdtime&&(n+="Hold Time: "+e.holdtime+"\n"),e.duration&&(n+="Duration: "+e.duration+"\n"),e.billableseconds&&(n+="Billable Seconds: "+e.billableseconds+"\n");var t={Id:c.Id,ActivityDate:c.activityDate,Status:d.defaultUpdateStatus,Description:n};if(d.date&&e.endtime){var a=String(e.endtime).split(" ")[0];console.log("TCL: updateLog -> date",a),t[d.date]=a}if(d.time&&e.endtime){var r=String(e.endtime).split(" ")[1];console.log("TCL: updateLog -> time",r),t[d.time]=r}d.endtime&&e.endtime&&(t[d.endtime]=e.endtime),d.answertime&&e.answertime&&(t[d.answertime]=e.answertime),d.holdtime&&e.holdtime&&(t[d.holdtime]=String(e.holdtime)),d.duration&&e.duration&&(t[d.duration]=String(e.duration)),d.billsec&&e.billableseconds&&(t[d.billsec]=String(e.billableseconds)),console.log(t),sforce.opencti.saveLog({value:JSON.parse(JSON.stringify(t)),callback:C}),n=""}(e):c={})})),u&&u.disconnected&&u.connect()}else o.online=!1}).catch(function(e){console.error(e)})},2e3),n(function(){var e=Date.now();i.get("http://localhost:9888/api/calls").then(l[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;_.isArray(n)&&_.find(n,{stateId:8})?(o.timer=(t=n[0].callingNumber,a=n[0].activeDuration,r=t+" ACTIVE (",r+=a.hours<10?"0":"",r+=a.hours,r+=":",r+=a.minutes<10?"0":"",r+=a.minutes,r+=":",r+=a.seconds<10?"0":"",r+=a.seconds,r+=")"),o.inCall=!0):(o.inCall=!1,o.timer="")}else o.inCall=!1,o.timer="";var t,a,r}).catch(function(e){console.error(e)})},1e3),e.addEventListener("message",function(e){var n=e.data;s[n.uniqueid]?(s[n.uniqueid](n),delete s[n.uniqueid]):l[n.uniqueid]&&(l[n.uniqueid](n),delete l[n.uniqueid]),t.$apply()},!1)}function deskController(t,a,e,n,r,i){var o=this,s={},l={},u=null;o.timer="",o.phone="",o.inCall=!1;o.compose=function(e){o.phone=o.phone.concat(e)},o.remove=function(){o.phone=o.phone.substring(0,o.phone.length-1)},o.hangup=function(){o.phone="",c=0,p("http://localhost:9888/api/hangup",Date.now())},o.dial=function(){var e=Date.now();p("http://localhost:9888/api/originate/"+o.phone,e),p("http://localhost:9888/api/answer",e)};var c=0;function d(e){c<1&&o.online&&e.number&&(o.phone=e.number,o.dial(),c++)}function m(e){console.log("Display",e),desk.interaction.screenPop(e.recordId.toString(),"object=case")}function p(e,n){a.parent.postMessage({id:null,tag:"iframe",className:null,uniqueid:n,options:{url:e}},"*")}angular.element(document.createElement("base")).href=window.location.pathname,r.loadScript(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"js/salesforce/interaction-desk.js").then(function(){o.host=n.search().host,desk.ready(function(e){desk.interaction.cti.enableClickToDial(),desk.interaction.cti.onClickToDial(d)})}).catch(function(e){console.error(e)}),e(function(){var e=Date.now();s[e]=function(e){if(e.response&&200<=e.response.status&&e.response.status<300){var n=JSON.parse(e.response.message);o.id=n.id,o.name=n.name,o.fullname=n.fullname,o.internal=String(n.internal),o.online=!0,u||o.host&&o.id&&(console.log("host",o.host),console.log("id",o.id),(u=io(o.host,{query:{id:o.id},autoConnect:!1,transports:["websocket","polling"]})).on("trigger:desk:display",m)),u&&u.disconnected&&u.connect()}else o.online=!1},p("http://localhost:9888/api/agent",e)},2e3),e(function(){var e=Date.now();l[e]=function(e){if(e.response&&200<=e.response.status&&e.response.status<300){var n=JSON.parse(e.response.message);_.isArray(n)&&_.find(n,{stateId:8})?(o.timer=(t=n[0].callingNumber,a=n[0].activeDuration,r=t+" ACTIVE (",r+=a.hours<10?"0":"",r+=a.hours,r+=":",r+=a.minutes<10?"0":"",r+=a.minutes,r+=":",r+=a.seconds<10?"0":"",r+=a.seconds,r+=")"),o.inCall=!0):(o.inCall=!1,o.timer="")}else o.inCall=!1,o.timer="";var t,a,r},p("http://localhost:9888/api/calls",e)},2e3),a.addEventListener("message",function(e){var n=e.data;s[n.uniqueid]?(s[n.uniqueid](n),delete s[n.uniqueid]):l[n.uniqueid]&&(l[n.uniqueid](n),delete l[n.uniqueid]),t.$apply()},!1)}motion.config(config),angular.module("motion").controller("classicController",classicController),angular.module("motion").controller("lightningController",lightningController),angular.module("motion").controller("deskController",deskController); \ No newline at end of file +"use strict";config.$inject=["$locationProvider","$mdThemingProvider"],classicController.$inject=["$scope","$window","$interval","$location","angularLoad","$http"],lightningController.$inject=["$scope","$window","$interval","$location","angularLoad","$http"],deskController.$inject=["$scope","$window","$interval","$location","angularLoad","$http"];var motion=angular.module("motion",["ngMaterial","angularLoad"]);function config(e,n){e.html5Mode(!0),n.theme("default").dark()}function classicController(t,e,n,a,r,i){var o=this,s={},l={},u=null;o.timer="",o.phone="",o.inCall=!1;var c={},d={};o.compose=function(e){o.phone=o.phone.concat(e)},o.remove=function(){o.phone=o.phone.substring(0,o.phone.length-1)},o.hangup=function(){o.phone="",i.get("http://localhost:9888/api/hangup")},o.dial=function(){i.get("http://localhost:9888/api/originate/"+o.phone),i.get("http://localhost:9888/api/answer"),sforce.interaction.runApex("UserInfo","getUserId",null,w)};var m=0;function p(e){e.result?sforce.interaction.cti.onClickToDial(h):console.error("Something went wrong! Errors:",e.errors)}function g(e){var n={};e.result?(n=JSON.parse(e.result),o.host=n["/Motion/Host"],d.createTask=n["/ManageTask/createTask"],d.createTask=d.createTask?d.createTask:"false",d.createOnAnswer=n["/ManageTask/createOnAnswer"],d.createOnAnswer=d.createOnAnswer?d.createOnAnswer:"false",d.updateOnHangup=n["/ManageTask/updateOnHangup"],d.updateOnHangup=d.updateOnHangup?d.updateOnHangup:"false",d.refreshOnHangup=n["/ManageTask/refreshOnHangup"],d.refreshOnHangup=d.refreshOnHangup?d.refreshOnHangup:"false",d.defaultCreateStatus=n["/ManageTask/defaultCreateStatus"],d.defaultCreateStatus=d.defaultCreateStatus?d.defaultCreateStatus:"In Progress",d.defaultUpdateStatus=n["/ManageTask/defaultUpdateStatus"],d.defaultUpdateStatus=d.defaultUpdateStatus?d.defaultUpdateStatus:"Completed",d.uniqueid=n["/FieldMapping/uniqueid"],d.uniqueid=d.uniqueid?d.uniqueid:null,d.agent=n["/FieldMapping/agent"],d.agent=d.agent?d.agent:null,d.callerid=n["/FieldMapping/callerid"],d.callerid=d.callerid?d.callerid:null,d.date=n["/FieldMapping/date"],d.date=d.date?d.date:null,d.time=n["/FieldMapping/time"],d.time=d.time?d.time:null,d.starttime=n["/FieldMapping/starttime"],d.starttime=d.starttime?d.starttime:null,d.endtime=n["/FieldMapping/endtime"],d.endtime=d.endtime?d.endtime:null,d.answertime=n["/FieldMapping/answertime"],d.answertime=d.answertime?d.answertime:null,d.holdtime=n["/FieldMapping/holdtime"],d.holdtime=d.holdtime?d.holdtime:null,d.duration=n["/FieldMapping/duration"],d.duration=d.duration?d.duration:null,d.billsec=n["/FieldMapping/billsec"],d.billsec=d.billsec?d.billsec:null):console.error("Something went wrong! Errors:",e.errors)}function h(e){var n=JSON.parse(e.result);m<1&&o.online&&n.number&&(o.phone=n.number,c.endUserPhone=angular.copy(n.number),c.endUserObjectType=n.object,c.endUserId=n.objectId,c.endUserName=n.objectName,o.dial(),m++)}function f(e){console.log("Display",e),sforce.interaction.screenPop(e.recordId,!0,v)}function w(e){e.result?c.userId=String(e.result):console.error("Something went wrong! Errors:",e.errors)}function b(e){c.activityDate=moment().utc();var n=c.endUserId.substr(0,3),t="";t+="*** Call Info ***\n",t+="Called Number: "+c.endUserPhone+"\n",t+="Member Name: "+e.membername+"\n",t+="UniqueId: "+e.uniqueid+"\n",t+="Date: "+e.starttime+"\n",t+="*** Time Info ***\n",e.answertime&&(t+="Answer Time: "+e.answertime+"\n");var a="Subject=Outbound Call [xCALLY Ticket] "+c.endUserPhone;if(a+="&Activitydate="+c.activityDate,a+="&Phone="+c.endUserPhone,a+="&Description="+t,a+="&OwnerId="+c.userId,a+="003"===n||"00Q"===n?"&whoId="+c.endUserId:"&whatId="+c.endUserId,a+="&Priority=Normal",a+="&Status="+d.defaultCreateStatus,a+="&Type=Call",d.uniqueid&&e.uniqueid&&(a+="&"+d.uniqueid+"="+String(e.uniqueid)),d.agent&&o.fullname&&(a+="&"+d.agent+"="+o.fullname),d.callerid&&e.calleridnum&&(a+="&"+d.callerid+"="+e.calleridnum),d.date&&e.starttime){var r=String(e.starttime).split(" ")[0];a+="&"+d.date+"="+r}if(d.time&&e.starttime){var i=String(e.starttime).split(" ")[1];a+="&"+d.time+"="+i}d.starttime&&e.starttime&&(a+="&"+d.starttime+"="+e.starttime),d.answertime&&e.answertime&&(a+="&"+d.answertime+"="+e.answertime),sforce.interaction.saveLog("Task",encodeURI(a),S),t=""}function S(e){e.result?(c.Id=e.result,m=0,sforce.interaction.screenPop("/"+c.Id,!0,v)):console.error("Something went wrong! Errors:",e.errors)}function v(e){e.result?console.log("API screenPop executed successfully!"):console.error("Something went wrong! Errors:",e.errors)}function C(e){"true"===d.createTask&&"true"===d.updateOnHangup&&"true"===d.refreshOnHangup?e.result?(c={},sforce.interaction.refreshPage(I)):console.error("Something went wrong! Errors:",e.errors):c={}}function I(e){e.result?console.log("API refreshView classic executed successfully! returnValue:",e.result):console.error("Something went wrong! Errors:",e.errors)}angular.element(document.createElement("base")).href=window.location.pathname,r.loadScript(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/js/salesforce/interaction.js").then(function(){console.log("Salesforce Classic"),sforce.interaction.cti.getCallCenterSettings(g),sforce.interaction.cti.enableClickToDial(p)}).catch(function(e){console.error(e)}),n(function(){var e=Date.now();i.get("http://localhost:9888/api/agent").then(s[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;o.id=n.id,o.name=n.name,o.fullname=n.fullname,o.internal=String(n.internal),o.online=!0,u||o.host&&o.id&&((u=io(o.host,{query:{id:o.id},autoConnect:!1,transports:["websocket","polling"]})).on("trigger:salesforce:display",f),u.on("voice_outbound_channel:save",function(e){e.destexten&&e.destexten===String(c.endUserPhone)&&!e.dialstatus&&"true"===d.createTask&&"false"===d.createOnAnswer&&b(e),e.destexten&&e.destexten===String(c.endUserPhone)&&e.dialstatus&&"ANSWER"===e.dialstatus&&"true"===d.createTask&&"true"===d.createOnAnswer&&b(e)}),u.on("voice_outbound_channel:remove",function(e){o.phone="",e.destexten&&e.destexten===String(c.endUserPhone)&&("true"===d.createTask&&"true"===d.updateOnHangup?function(e){c.activityDate=moment().utc();var n="";n+="*** Call Info ***\n",n+="Called Number: "+c.endUserPhone+"\n",n+="Member Name: "+e.membername+"\n",n+="UniqueId: "+e.uniqueid+"\n",n+="Date: "+e.endtime+"\n",n+="*** Time Info ***\n",e.answertime&&(n+="Answer Time: "+e.answertime+"\n"),n+="End Time: "+e.endtime+"\n",e.holdtime&&(n+="Hold Time: "+e.holdtime+"\n"),n+="Duration: "+e.duration+"\n",e.billableseconds&&(n+="Billable Seconds: "+e.billableseconds+"\n");var t="Id="+c.Id;if(t+="&Activitydate="+c.activityDate,t+="&Status="+d.defaultUpdateStatus,t+="&Description="+n,d.date&&e.endtime){var a=String(e.endtime).split(" ")[0];t+="&"+d.date+"="+a}if(d.time&&e.endtime){var r=String(e.endtime).split(" ")[1];t+="&"+d.time+"="+r}d.endtime&&e.endtime&&(t+="&"+d.endtime+"="+e.endtime),d.answertime&&e.answertime&&(t+="&"+d.answertime+"="+e.answertime),d.holdtime&&e.holdtime&&(t+="&"+d.holdtime+"="+e.holdtime),d.duration&&e.duration&&(t+="&"+d.duration+"="+String(e.duration)),d.billsec&&e.billableseconds&&(t+="&"+d.billsec+"="+String(e.billableseconds)),sforce.interaction.saveLog("Task",encodeURI(t),C),n=""}(e):c={})})),u&&u.disconnected&&u.connect()}else o.online=!1}).catch(function(e){console.error(e)})},2e3),n(function(){var e=Date.now();i.get("http://localhost:9888/api/calls").then(l[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;_.isArray(n)&&_.find(n,{stateId:8})?(o.timer=(t=n[0].callingNumber,a=n[0].activeDuration,r=t+" ACTIVE (",r+=a.hours<10?"0":"",r+=a.hours,r+=":",r+=a.minutes<10?"0":"",r+=a.minutes,r+=":",r+=a.seconds<10?"0":"",r+=a.seconds,r+=")"),o.inCall=!0):(o.inCall=!1,o.timer="")}else o.inCall=!1,o.timer="";var t,a,r}).catch(function(e){console.error(e)})},1e3),e.addEventListener("message",function(e){var n=e.data;s[n.uniqueid]?(s[n.uniqueid](n),delete s[n.uniqueid]):l[n.uniqueid]&&(l[n.uniqueid](n),delete l[n.uniqueid]),t.$apply()},!1)}function lightningController(t,e,n,a,r,i){var o=this,s={},l={},u=null;o.timer="",o.phone="",o.inCall=!1;var c={},d={};o.compose=function(e){o.phone=o.phone.concat(e)},o.remove=function(){o.phone=o.phone.substring(0,o.phone.length-1)},o.hangup=function(){o.phone="",i.get("http://localhost:9888/api/hangup")},o.dial=function(){i.get("http://localhost:9888/api/originate/"+o.phone),i.get("http://localhost:9888/api/answer"),e={apexClass:"UserInfo",methodName:"getUserId",callback:w},sforce.opencti.runApex(e);var e};var m=0;function p(e){console.log("enableClickToDialCallback",e),e.success?sforce.opencti.onClickToDial({listener:h}):console.error("Something went wrong! Errors:",e.errors)}function g(e){e.success?(o.host=e.returnValue["/Motion/Host"],d.createTask=e.returnValue["/ManageTask/createTask"],d.createTask=d.createTask?d.createTask:"false",d.createOnAnswer=e.returnValue["/ManageTask/createOnAnswer"],d.createOnAnswer=d.createOnAnswer?d.createOnAnswer:"false",d.updateOnHangup=e.returnValue["/ManageTask/updateOnHangup"],d.updateOnHangup=d.updateOnHangup?d.updateOnHangup:"false",d.refreshOnHangup=e.returnValue["/ManageTask/refreshOnHangup"],d.refreshOnHangup=d.refreshOnHangup?d.refreshOnHangup:"false",d.defaultCreateStatus=e.returnValue["/ManageTask/defaultCreateStatus"],d.defaultCreateStatus=d.defaultCreateStatus?d.defaultCreateStatus:"In Progress",d.defaultUpdateStatus=e.returnValue["/ManageTask/defaultUpdateStatus"],d.defaultUpdateStatus=d.defaultUpdateStatus?d.defaultUpdateStatus:"Completed",d.uniqueid=e.returnValue["/FieldMapping/uniqueid"],d.uniqueid=d.uniqueid?d.uniqueid:null,d.agent=e.returnValue["/FieldMapping/agent"],d.agent=d.agent?d.agent:null,d.callerid=e.returnValue["/FieldMapping/callerid"],d.callerid=d.callerid?d.callerid:null,d.date=e.returnValue["/FieldMapping/date"],d.date=d.date?d.date:null,d.time=e.returnValue["/FieldMapping/time"],d.time=d.time?d.time:null,d.starttime=e.returnValue["/FieldMapping/starttime"],d.starttime=d.starttime?d.starttime:null,d.endtime=e.returnValue["/FieldMapping/endtime"],d.endtime=d.endtime?d.endtime:null,d.answertime=e.returnValue["/FieldMapping/answertime"],d.answertime=d.answertime?d.answertime:null,d.holdtime=e.returnValue["/FieldMapping/holdtime"],d.holdtime=d.holdtime?d.holdtime:null,d.duration=e.returnValue["/FieldMapping/duration"],d.duration=d.duration?d.duration:null,d.billsec=e.returnValue["/FieldMapping/billsec"],d.billsec=d.billsec?d.billsec:null):console.error("Something went wrong! Errors:",e.errors)}function h(e){m<1&&o.online&&e.number&&(o.phone=e.number,c.endUserPhone=angular.copy(e.number),c.endUserObjectType=e.objectType,c.endUserId=e.recordId,c.endUserName=e.recordName,o.dial(),m++)}function f(e){sforce.opencti.screenPop({type:sforce.opencti.SCREENPOP_TYPE.SOBJECT,params:{recordId:e.recordId}})}function w(e){e.success?c.userId=String(e.returnValue.runApex):console.error("Something went wrong! Errors:",e.errors)}function b(e){c.activityDate=moment().utc();var n=c.endUserId.substr(0,3),t="";t+="*** Call Info ***\n",t+="Called Number: "+c.endUserPhone+"\n",t+="Member Name: "+e.membername+"\n",t+="UniqueId: "+e.uniqueid+"\n",t+="Date: "+e.starttime+"\n",t+="*** Time Info ***\n",e.answertime&&(t+="Answer Time: "+e.answertime+"\n");var a={OwnerId:c.userId,ActivityDate:c.activityDate,IsReminderSet:!1,IsRecurrence:!1,Subject:"Outbound Call [xCALLY Ticket] "+c.endUserPhone,Description:t,Priority:"Normal",Type:"Call",Status:d.defaultCreateStatus,entityApiName:"Task"};if("003"===n||"00Q"===n?a.WhoId=c.endUserId:a.WhatId=c.endUserId,d.uniqueid&&e.uniqueid&&(a[d.uniqueid]=String(e.uniqueid)),d.agent&&o.fullname&&(a[d.agent]=o.fullname),d.callerid&&e.calleridnum&&(a[d.callerid]=e.calleridnum),d.date&&e.starttime){var r=String(e.starttime).split(" ")[0];a[d.date]=r}if(d.time&&e.starttime){var i=String(e.starttime).split(" ")[1];a[d.time]=i}d.starttime&&e.starttime&&(a[d.starttime]=e.starttime),d.answertime&&e.answertime&&(a[d.answertime]=e.answertime),sforce.opencti.saveLog({value:JSON.parse(JSON.stringify(a)),callback:S}),t=""}function S(e){e.success?(c.Id=e.returnValue.recordId,m=0,sforce.opencti.screenPop({type:sforce.opencti.SCREENPOP_TYPE.SOBJECT,params:{recordId:c.Id},callback:v})):console.error("Something went wrong! Errors:",e.errors)}function v(e){e.success?console.log("API screenPop executed successfully!"):console.error("Something went wrong! Errors:",e.errors)}function C(e){"true"===d.createTask&&"true"===d.updateOnHangup&&"true"===d.refreshOnHangup?e.success?(c={},sforce.opencti.refreshView({callback:I})):console.error("Something went wrong! Errors:",e.errors):c={}}function I(e){console.log("API refreshView classic executed successfully! returnValue:",e),e.success?console.log("API refreshView lightning executed successfully!"):console.error("Something went wrong! Errors:",e.errors)}angular.element(document.createElement("base")).href=window.location.pathname,r.loadScript(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"/js/salesforce/lightning.js").then(function(){console.log("Salesforce Lightning"),sforce.opencti.getCallCenterSettings({callback:g}),sforce.opencti.enableClickToDial({callback:p})}).catch(function(e){console.error(e)}),n(function(){var e=Date.now();i.get("http://localhost:9888/api/agent").then(s[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;o.id=n.id,o.name=n.name,o.fullname=n.fullname,o.internal=String(n.internal),o.online=!0,u||o.host&&o.id&&((u=io(o.host,{query:{id:o.id},autoConnect:!1,transports:["websocket","polling"]})).on("trigger:salesforce:display",f),u.on("voice_outbound_channel:save",function(e){e.destexten&&e.destexten===String(c.endUserPhone)&&!e.dialstatus&&"true"===d.createTask&&"false"===d.createOnAnswer&&b(e),e.destexten&&e.destexten===String(c.endUserPhone)&&e.dialstatus&&"ANSWER"===e.dialstatus&&"true"===d.createTask&&"true"===d.createOnAnswer&&b(e)}),u.on("voice_outbound_channel:remove",function(e){o.phone="",e.destexten&&e.destexten===String(c.endUserPhone)&&("true"===d.createTask&&"true"===d.updateOnHangup?function(e){c.activityDate=moment().utc();var n="";n+="*** Call Info ***\n",n+="Called Number: "+c.endUserPhone+"\n",n+="Member Name: "+e.membername+"\n",n+="UniqueId: "+e.uniqueid+"\n",n+="Date: "+e.endtime+"\n",n+="*** Time Info ***\n",e.answertime&&(n+="Answer Time: "+e.answertime+"\n"),e.endtime&&(n+="End Time: "+e.endtime+"\n"),e.holdtime&&(n+="Hold Time: "+e.holdtime+"\n"),e.duration&&(n+="Duration: "+e.duration+"\n"),e.billableseconds&&(n+="Billable Seconds: "+e.billableseconds+"\n");var t={Id:c.Id,ActivityDate:c.activityDate,Status:d.defaultUpdateStatus,Description:n};if(d.date&&e.endtime){var a=String(e.endtime).split(" ")[0];t[d.date]=a}if(d.time&&e.endtime){var r=String(e.endtime).split(" ")[1];t[d.time]=r}d.endtime&&e.endtime&&(t[d.endtime]=e.endtime),d.answertime&&e.answertime&&(t[d.answertime]=e.answertime),d.holdtime&&e.holdtime&&(t[d.holdtime]=String(e.holdtime)),d.duration&&e.duration&&(t[d.duration]=String(e.duration)),d.billsec&&e.billableseconds&&(t[d.billsec]=String(e.billableseconds)),console.log(t),sforce.opencti.saveLog({value:JSON.parse(JSON.stringify(t)),callback:C}),n=""}(e):c={})})),u&&u.disconnected&&u.connect()}else o.online=!1}).catch(function(e){console.error(e)})},2e3),n(function(){var e=Date.now();i.get("http://localhost:9888/api/calls").then(l[e]=function(e){if(e&&200<=e.status&&e.status<300){var n=e.data;_.isArray(n)&&_.find(n,{stateId:8})?(o.timer=(t=n[0].callingNumber,a=n[0].activeDuration,r=t+" ACTIVE (",r+=a.hours<10?"0":"",r+=a.hours,r+=":",r+=a.minutes<10?"0":"",r+=a.minutes,r+=":",r+=a.seconds<10?"0":"",r+=a.seconds,r+=")"),o.inCall=!0):(o.inCall=!1,o.timer="")}else o.inCall=!1,o.timer="";var t,a,r}).catch(function(e){console.error(e)})},1e3),e.addEventListener("message",function(e){var n=e.data;s[n.uniqueid]?(s[n.uniqueid](n),delete s[n.uniqueid]):l[n.uniqueid]&&(l[n.uniqueid](n),delete l[n.uniqueid]),t.$apply()},!1)}function deskController(t,a,e,n,r,i){var o=this,s={},l={},u=null;o.timer="",o.phone="",o.inCall=!1;o.compose=function(e){o.phone=o.phone.concat(e)},o.remove=function(){o.phone=o.phone.substring(0,o.phone.length-1)},o.hangup=function(){o.phone="",c=0,p("http://localhost:9888/api/hangup",Date.now())},o.dial=function(){var e=Date.now();p("http://localhost:9888/api/originate/"+o.phone,e),p("http://localhost:9888/api/answer",e)};var c=0;function d(e){c<1&&o.online&&e.number&&(o.phone=e.number,o.dial(),c++)}function m(e){console.log("Display",e),desk.interaction.screenPop(e.recordId.toString(),"object=case")}function p(e,n){a.parent.postMessage({id:null,tag:"iframe",className:null,uniqueid:n,options:{url:e}},"*")}angular.element(document.createElement("base")).href=window.location.pathname,r.loadScript(window.location.pathname.substring(0,window.location.pathname.lastIndexOf("/"))+"js/salesforce/interaction-desk.js").then(function(){o.host=n.search().host,desk.ready(function(e){desk.interaction.cti.enableClickToDial(),desk.interaction.cti.onClickToDial(d)})}).catch(function(e){console.error(e)}),e(function(){var e=Date.now();s[e]=function(e){if(e.response&&200<=e.response.status&&e.response.status<300){var n=JSON.parse(e.response.message);o.id=n.id,o.name=n.name,o.fullname=n.fullname,o.internal=String(n.internal),o.online=!0,u||o.host&&o.id&&(console.log("host",o.host),console.log("id",o.id),(u=io(o.host,{query:{id:o.id},autoConnect:!1,transports:["websocket","polling"]})).on("trigger:desk:display",m)),u&&u.disconnected&&u.connect()}else o.online=!1},p("http://localhost:9888/api/agent",e)},2e3),e(function(){var e=Date.now();l[e]=function(e){if(e.response&&200<=e.response.status&&e.response.status<300){var n=JSON.parse(e.response.message);_.isArray(n)&&_.find(n,{stateId:8})?(o.timer=(t=n[0].callingNumber,a=n[0].activeDuration,r=t+" ACTIVE (",r+=a.hours<10?"0":"",r+=a.hours,r+=":",r+=a.minutes<10?"0":"",r+=a.minutes,r+=":",r+=a.seconds<10?"0":"",r+=a.seconds,r+=")"),o.inCall=!0):(o.inCall=!1,o.timer="")}else o.inCall=!1,o.timer="";var t,a,r},p("http://localhost:9888/api/calls",e)},2e3),a.addEventListener("message",function(e){var n=e.data;s[n.uniqueid]?(s[n.uniqueid](n),delete s[n.uniqueid]):l[n.uniqueid]&&(l[n.uniqueid](n),delete l[n.uniqueid]),t.$apply()},!1)}motion.config(config),angular.module("motion").controller("classicController",classicController),angular.module("motion").controller("lightningController",lightningController),angular.module("motion").controller("deskController",deskController); \ No newline at end of file diff --git a/index.html b/index.html index a4c0c87..6f973f3 100644 --- a/index.html +++ b/index.html @@ -97,8 +97,6 @@ //var dialpad = document.getElementById('dialpad'); var body = document.getElementsByTagName('body')[0]; var urlParams = new URLSearchParams(window.location.search); - console.log("TCL: window.location.search", window.location.search); - //console.log("TCL: urlParams", urlParams); var mode = urlParams.get('mode'); var type = urlParams.get('type'); if (mode && mode.toLowerCase() === 'lightning') { @@ -113,7 +111,7 @@ )(); - + diff --git a/js/controllers/lightning.controller.js b/js/controllers/lightning.controller.js index 9e8d895..785d9a0 100644 --- a/js/controllers/lightning.controller.js +++ b/js/controllers/lightning.controller.js @@ -512,12 +512,10 @@ function lightningController($scope, $window, $interval, $location, angularLoad, // } if (_xml.date && evt.endtime) { var date = String(evt.endtime).split(' ')[0]; - console.log("TCL: updateLog -> date", date); obj_updateLog[_xml.date] = date; } if (_xml.time && evt.endtime) { var time = String(evt.endtime).split(' ')[1]; - console.log("TCL: updateLog -> time", time); obj_updateLog[_xml.time] = time; } // if(_xml.starttime && evt.starttime) {