1 angular.module('RingApp', ['ngMaterial', 'ngCookies', 'ngSanitize'])
2 .controller("RingController", function($scope, $http, $cookies) {
4 $scope.motion_url = "";
6 $scope.error_message = "";
7 $scope.welcome_message = "";
8 $scope.notification_message = "";
10 this.$onInit = function() {
11 $scope.token = $cookies.get('motion.token');
13 if (_.isNil($scope.token))
14 $scope.error_message = "XCally motion token not valid, please connect to XCally Motion, then retry";
16 var urlParams = new URLSearchParams(window.location.search);
17 var params = urlParams.get("params");
18 var arr = params.split("|");
20 $scope.messageId = arr[0];
21 $scope.motionUrl = arr[1];
22 $scope.chatWebsiteId = arr[2];
23 $scope.interactionId = arr[3];
24 $scope.contactId = arr[4];
25 $scope.welcome_message = arr[5];
26 $scope.notification_message = arr[6];
29 window.addEventListener("message", function(e) {
32 if (e.data.data.state) {
33 if (e.data.data.state == "IDLE") {
34 var callId = e.data.data.callId;
35 refuseInteraction(callId);
42 null != a && null != a.namespace && "webclient.teleniasoftware.com" == a.namespace ? "callEvent" == a.event ? callMessageData || (callMessageData = a.data, null !== infoCb && infoCb(callMessageData)) : "allCallsStateEvent" == a.event ? (callsMap = new Map, a.data.forEach(function(e) {
43 callsMap.set(e.callId, e)
44 })) : "userStateEvent" == a.event && (console.info("userStateEvent received", a.data), userData = a.data) : console.info("Received Unknown message", a)
51 $http.get($scope.motion_url + "/api/chat/websites/" + $scope.chatWebsiteId, {
53 'Authorization': 'Bearer ' + $scope.token
57 function successCallback(response) {
58 $scope.logo = $scope.motion_url + "/api/chat/websites/" + $scope.chatWebsiteId + "/logo?token=";
59 //$scope.notification_message=response.data.notificationTemplate;
61 function errorCallback(response) {
62 console.log("Unable to perform get request", response);
68 function refuseInteraction(callId) {
70 id: $scope.interactionId,
72 closeReason: 'unmanaged',
73 disposition: 'unmanaged',
74 closedAt: new Date() // moment().format('YYYY-MM-DD HH:mm:ss'),
77 $http.put($scope.motion_url + "/api/chat/interactions/" + $scope.interactionId + "/custom_update", msg, {
79 'Authorization': 'Bearer ' + $scope.token
83 function ret(response) {
84 tvoxCloseInteraction(callId);
91 $scope.accept = function(event) {
92 tvoxAnswerCall(tvoxGetCallHandle());
94 $scope.refuse = function(event) {
95 tvoxDropCall(tvoxGetCallHandle());