From d88c4c331b27628f8245acdf954e1bdae9aa04f8 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Thu, 3 Mar 2016 16:49:32 -0500 Subject: [PATCH 01/21] Refactored directives before testing --- karma.conf.js | 102 +- package.json | 3 +- src/js/rtcomm-directives.js | 942 ------------------ src/js/rtcomm-services.js | 7 +- src/js/services/rtcomm.event.service.js | 0 src/js/services/rtcomm.service.js | 45 + src/js/services/services.module.js | 7 + src/js/ui/config.controller.js | 76 ++ .../rtcomm-alert.directive.js | 42 + .../rtcomm-chat.directive.js | 107 ++ .../rtcomm-directives.module.js | 9 + .../rtcomm-queues.directive.js | 152 +++ .../rtcomm-register.directive.js | 84 ++ .../rtcomm-session-manager.directive.js | 85 ++ src/js/ui/endpoint.controller.js | 87 ++ src/js/ui/endpoint/rtcomm-endpoint-status.js | 150 +++ src/js/ui/endpoint/rtcomm-iframe.directive.js | 95 ++ src/js/ui/endpoint/rtcomm-video.directive.js | 66 ++ src/js/ui/modals/alert-modal.js | 102 ++ src/js/ui/modals/call-modal.js | 89 ++ src/js/ui/ui.module.js | 12 + test/rtcomm-alert-modal.spec.js | 37 + test/rtcomm-alert.spec.js | 18 + test/rtcomm-chat.spec.js | 18 + test/rtcomm-config.spec.js | 13 + test/rtcomm-endpoint-status.spec.js | 18 + test/rtcomm-iframe.spec.js | 18 + test/rtcomm-presence.directive.spec.js | 1 + test/rtcomm-queues.spec.js | 18 + test/rtcomm-register.directive.spec.js | 18 + test/rtcomm-service.spec.js | 27 + test/rtcomm-session-manager.spec.js | 19 + test/rtcomm-video.spec.js | 18 + test/testRtcommServiceSpec.js | 64 +- 34 files changed, 1520 insertions(+), 1029 deletions(-) delete mode 100644 src/js/rtcomm-directives.js create mode 100644 src/js/services/rtcomm.event.service.js create mode 100644 src/js/services/rtcomm.service.js create mode 100644 src/js/services/services.module.js create mode 100644 src/js/ui/config.controller.js create mode 100644 src/js/ui/endpoint-provider/rtcomm-alert.directive.js create mode 100644 src/js/ui/endpoint-provider/rtcomm-chat.directive.js create mode 100644 src/js/ui/endpoint-provider/rtcomm-directives.module.js create mode 100644 src/js/ui/endpoint-provider/rtcomm-queues.directive.js create mode 100644 src/js/ui/endpoint-provider/rtcomm-register.directive.js create mode 100644 src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js create mode 100644 src/js/ui/endpoint.controller.js create mode 100644 src/js/ui/endpoint/rtcomm-endpoint-status.js create mode 100644 src/js/ui/endpoint/rtcomm-iframe.directive.js create mode 100644 src/js/ui/endpoint/rtcomm-video.directive.js create mode 100644 src/js/ui/modals/alert-modal.js create mode 100644 src/js/ui/modals/call-modal.js create mode 100644 src/js/ui/ui.module.js create mode 100644 test/rtcomm-alert-modal.spec.js create mode 100644 test/rtcomm-alert.spec.js create mode 100644 test/rtcomm-chat.spec.js create mode 100644 test/rtcomm-config.spec.js create mode 100644 test/rtcomm-endpoint-status.spec.js create mode 100644 test/rtcomm-iframe.spec.js create mode 100644 test/rtcomm-presence.directive.spec.js create mode 100644 test/rtcomm-queues.spec.js create mode 100644 test/rtcomm-register.directive.spec.js create mode 100644 test/rtcomm-service.spec.js create mode 100644 test/rtcomm-session-manager.spec.js create mode 100644 test/rtcomm-video.spec.js diff --git a/karma.conf.js b/karma.conf.js index 55b7799..81a2ef3 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,74 +2,74 @@ // Generated on Fri Dec 05 2014 13:58:19 GMT-0500 (Eastern Standard Time) module.exports = function(config) { - config.set({ + config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['jasmine', 'mocha', 'chai'], + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha', 'chai', 'sinon'], + reports: ['spec'], + // list of files / patterns to load in the browser + files: [ + 'bower_components/jquery/dist/jquery.js', + 'bower_components/bootstrap/dist/js/bootstrap.js', + 'bower_components/angular/angular.js', + 'bower_components/angular-mocks/angular-mocks.js', + 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', + 'bower_components/angular-tree-control/angular-tree-control.js', + 'bower_components/bower-mqttws/mqttws31.js', + 'bower_components/rtcomm/dist/rtcomm.js', + 'src/templates/**/*.html', + 'src/js/**/*.module.js', + 'src/js/*.js', + 'src/js/ui/**/*.js', + 'test/*.spec.js' + ], - // list of files / patterns to load in the browser - files: [ - 'node_modules/angular/angular.js', - 'node_modules/angular-mocks/angular-mocks.js', - 'bower_components/jquery/dist/jquery.js', - 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', - 'bower_components/angular-modal-service/dst/angular-modal-service.js', - 'bower_components/angular-tree-control/angular-tree-control.js', - 'bower_components/bower-mqttws/mqttws31.js', - 'bower_components/rtcomm/dist/rtcomm.js', - 'src/js/rtcomm-services.js', - 'src/js/rtcomm-directives.js', - 'test/*Spec.js' - ], + // list of files to exclude + exclude: [], - // list of files to exclude - exclude: [ - ], + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'src/templates/**/*.html': ['ng-html2js'], - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'src/templates/*.html': 'ng-html2js' - }, + }, + ngHtml2JsPreprocessor: { + stripPrefix: 'src/', + moduleName: "rtcomm.templates" + }, - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], + // web server port + port: 9876, - // web server port - port: 9876, + // enable / disable colors in the output (reporters and logs) + colors: true, - // enable / disable colors in the output (reporters and logs) - colors: true, + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_DEBUG, + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + //browsers: ['Chrome', 'Firefox'], + browsers: ['Chrome'], - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - //browsers: ['Chrome', 'Firefox'], - browsers: ['Chrome'], - - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true - }); + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); }; diff --git a/package.json b/package.json index 0984c7c..1ae213e 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "karma-ie-launcher": "^0.1.5", "karma-jasmine": "^0.3.2", "karma-mocha": "^0.1.10", - "karma-ng-html2js-preprocessor": "^0.1.2", + "karma-ng-html2js-preprocessor": "^0.2.1", + "karma-sinon": "^1.0.4", "load-grunt-tasks": "^1.0.0", "mocha": "^2.0.1" } diff --git a/src/js/rtcomm-directives.js b/src/js/rtcomm-directives.js deleted file mode 100644 index e2459de..0000000 --- a/src/js/rtcomm-directives.js +++ /dev/null @@ -1,942 +0,0 @@ -/* - * The angular-rtcomm-ui module - * This has controllers and directives in it. - */ -(function(){ - -angular - .module('angular-rtcomm-ui', [ - 'ui.bootstrap', - 'angular-rtcomm-service']) - .directive('rtcommSessionManager', rtcommSessionManager) - .directive('rtcommRegister', rtcommRegister) - .directive('rtcommQueues', rtcommQueues) - .directive('rtcommAlert', rtcommAlert) - .directive('rtcommEndpointStatus', rtcommEndpointStatus) - .directive('rtcommVideo', rtcommVideo) - .directive('rtcommChat', rtcommChat) - .directive('rtcommIframe', rtcommIframe) - .controller('RtcommAlertModalController', RtcommAlertModalController) - .controller('RtcommAlertModalInstanceController', RtcommAlertModalInstanceController) - .controller('RtcommCallModalController', RtcommCallModalController) - .controller('RtcommCallModalInstanceController', RtcommCallModalInstanceController) - .controller('RtcommConfigController', RtcommConfigController) - .controller('RtcommVideoController', RtcommVideoController) - .controller('RtcommEndpointController', RtcommEndpointController); - -/************* Endpoint Provider Directives *******************************/ -/** - * This directive is used to manage multiple sessions. If you are only supporting at most one session you wont need - * this directive. The associated template provides a way to switch between active sessions. The session must be in - * the started state to be managed by this directive and is removed when the session stops. - */ - -rtcommSessionManager.$inject=['RtcommService', '$log']; -function rtcommSessionManager (RtcommService, $log) { - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-sessionmgr.html', - controller: function ($scope) { - $scope.sessions = RtcommService.getSessions(); - $scope.sessMgrActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.publishPresence = false; - $scope.sessionPresenceData = []; - - $scope.init = function(publishPresence) { - $scope.publishPresence = publishPresence; - $scope.updatePresence(); - }; - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $log.debug('rtcommSessionmgr: endpointActivated =' + endpointUUID); - $scope.sessMgrActiveEndpointUUID = endpointUUID; - }); - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('rtcommSessionmgr: session:started: uuid =' + eventObject.endpoint.id); - - $scope.updatePresence(); - }); - - $scope.activateSession = function(endpointUUID) { - $log.debug('rtcommSessionmgr: activateEndpoint =' + endpointUUID); - if ($scope.sessMgrActiveEndpointUUID != endpointUUID){ - RtcommService.setActiveEndpoint(endpointUUID); - } - }; - - $scope.updatePresence = function(){ - // Update the presence record if enabled - if ($scope.publishPresence == true){ - RtcommService.removeFromPresenceRecord ($scope.sessionPresenceData, false); - - $scope.sessionPresenceData = [{ - 'name' : "sessions", - 'value' : String($scope.sessions.length)}]; - - RtcommService.addToPresenceRecord ($scope.sessionPresenceData); - } - }; - - }, - controllerAs: 'sessionmgr' - }; -}; - -/** - * This directive is used to manage the registration of an endpoint provider. Since the registered name can only - * be set on initialization of the endpoint provider, this directive actually controls the initialization of the - * provider. Note that the endpoint provider must be initialized before any sessions can be created or received. - */ -rtcommRegister.$inject=['RtcommService', '$log']; -function rtcommRegister(RtcommService, $log) { - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-register.html', - controller: function ($scope) { - - $scope.nextAction = 'Register'; - - $scope.reguserid = ''; - - $scope.invalid = false; - - var invalidCharacters = /(\$|#|\+|\/|\\)+/i; //Invalid characters for MQTT Topic Path - - //Watch for changes in reguserid - $scope.$watch('reguserid', function(){ - - if($scope.reguserid.length < 1 || invalidCharacters.test($scope.reguserid)){ - - $scope.invalid = true; - } - else{ - $scope.invalid = false; - } - }); - - - $scope.onRegClick = function() { - if ($scope.nextAction === 'Register' && !invalidCharacters.test($scope.reguserid)){ - - $log.debug('Register: reguserid =' + $scope.reguserid); - RtcommService.register($scope.reguserid); - } - else { - $log.debug('Unregister: reguserid =' + $scope.reguserid); - RtcommService.unregister(); - } - }; - - $scope.$on('rtcomm::init', function (event, success, details) { - - if (success == true){ - $scope.nextAction = 'Unregister'; - $scope.reguserid = details.userid; - } - else{ - $scope.nextAction = 'Register'; - - if (details == 'destroyed') - $scope.reguserid = ''; - else - $scope.reguserid = 'Init failed:' + details; - } - }); - }, - controllerAs: 'register' - }; -}; - -/** - * This directive manages call queues. It provides the ability to display all the available queues - * (along with their descriptions) and by clicking on a queue, allows an agent (or any type of user) - * to subscribe on that queue. - */ -rtcommQueues.$inject = ['RtcommService', '$log']; -function rtcommQueues(RtcommService, $log) { - return { - restrict : 'E', - templateUrl : 'templates/rtcomm/rtcomm-queues.html', - controller : function($scope) { - $scope.rQueues = []; - $scope.autoJoinQueues = false; - $scope.queuePresenceData = []; - $scope.queuePublishPresence = false; - $scope.queueFilter = null; - - /** - * autoJoinQueues - automatically join any queues that are not filtered out - * queuePublishedPresence - will add to the presence document information about what queues this person joins. - * queueFilter - If defined, this specifies which queues should be joined. All others will be ignored. - */ - $scope.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { - $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); - $scope.autoJoinQueues = autoJoinQueues; - $scope.queuePublishPresence = queuePublishPresence; - - if (typeof queueFilter !== "undefined") - $scope.queueFilter = queueFilter; - }; - - $scope.$on('queueupdate', function(event, queues) { - $log.debug('rtcommQueues: scope queues', $scope.rQueues); - - Object.keys(queues).forEach(function(key) { - $log.debug('rtcommQueues: Push queue: ' + queues[key]); - $log.debug('rtcommQueues: autoJoinQueues: ' + $scope.autoJoinQueues); - - // Check to make sure queue is not filteres out before adding it. - if ($scope.filterOutQueue(queues[key]) == false){ - $scope.rQueues.push(queues[key]); - - // If autoJoin we go ahead and join the queue as soon as we get the queue update. - if ($scope.autoJoinQueues == true){ - $scope.onQueueClick(queues[key]); - } - } - }); - - $scope.updateQueuePresence(); - }); - - $scope.$on('rtcomm::init', function (event, success, details) { - if (success == false){ - $log.debug('rtcommQueues: init: clear queues'); - $scope.rQueues = []; - } - }); - - // - $scope.filterOutQueue = function(queue){ - var returnValue = true; - - if ($scope.queueFilter != null){ - - for (var index = 0; index < $scope.queueFilter.length; ++index) { - var entry = $scope.queueFilter[index]; - if (entry == queue.endpointID) { - returnValue = false; - break; - } - } - } - else - returnValue = false; - - return (returnValue); - }; - - $scope.onQueueClick = function(queue){ - $log.debug('rtcommQueues: onClick: TOP'); - for (var index = 0; index < $scope.rQueues.length; index++) { - if($scope.rQueues[index].endpointID === queue.endpointID) - { - $log.debug('rtcommQueues: onClick: queue.endpointID = ' + queue.endpointID); - - if (queue.active == false){ - RtcommService.joinQueue(queue.endpointID); - $scope.rQueues[index].active = true; - } - else{ - RtcommService.leaveQueue(queue.endpointID); - $scope.rQueues[index].active = false; - } - } - else if (index == ($scope.rQueues.length - 1)){ - $log.debug('rtcommQueues: ERROR: queue.endpointID: ' + queue.endpointID + ' not found in list of queues'); - - } - } - - $scope.updateQueuePresence(); - }; - - $scope.updateQueuePresence = function(){ - // Update the presence record if enabled - if ($scope.queuePublishPresence == true){ - RtcommService.removeFromPresenceRecord ($scope.queuePresenceData, false); - - $scope.queuePresenceData = []; - - for (var index = 0; index < $scope.rQueues.length; index++) { - if($scope.rQueues[index].active === true){ - $scope.queuePresenceData.push ( - { - 'name' : "queue", - 'value' : $scope.rQueues[index].endpointID - }); - } - } - - RtcommService.addToPresenceRecord ($scope.queuePresenceData); - } - }; - }, - controllerAs : 'queues' - }; -}; - -//rtcommModule.controller('RtcommAlertController', ['$scope', '$log', function($scope, $log){ -rtcommAlert.$inject = ['$log']; -function rtcommAlert($log) { - return { - restrict: 'E', - templateUrl: "templates/rtcomm/rtcomm-alert.html", - controller: function ($scope) { - $scope.alerts = []; - $scope.addAlert = function(alert) { - $scope.alerts.push(alert); - }; - $scope.closeAlert = function(index) { - $scope.alerts.splice(index, 1); - }; - $scope.$on('rtcomm::alert', function(event, eventObject) { - $scope.addAlert(eventObject); - }); - } - } -}; - -/********************** Endpoint Directives *******************************/ - -/** - * This endpoint status controller only shows the active endpoint. The $scope.sessionState always contains the - * state of the active endpoint if one exist. It will be one of the following states: - * - * 'session:alerting' - * 'session:trying' - * 'session:ringing' - * 'session:queued' - for this one $scope.queueCount will tell you where you are in the queue. - * 'session:failed' - for this one $scope.reason will tell you why the call failed. - * 'session:started' - * 'session:stopped' - * - * You can bind to $scope.sessionState to track state in the view. - */ -rtcommEndpointStatus.$inject = ['RtcommService', '$log']; -function rtcommEndpointStatus(RtcommService, $log){ - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', - controller: function ($scope) { - - // Session states. - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - $scope.failureReason = ''; - $scope.queueCount = 0; // FIX: Currently not implemented! - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:started'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:stopped', function (event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:stopped'; - $scope.epCtrlRemoteEndpointID = null; - } - }); - - $scope.$on('session:failed', function (event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:failed'; - $scope.failureReason = eventObject.reason; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:alerting', function (event, eventObject) { - $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ - $scope.sessionState = 'session:alerting'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:connecting', function (event, eventObject) { - $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); - // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ - $scope.sessionState = 'session:connecting'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - // } - }); - - - $scope.$on('session:queued', function (event, eventObject) { - $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:queued'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:trying', function (event, eventObject) { - $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:trying'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:ringing', function (event, eventObject) { - $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:ringing'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $scope.epCtrlActiveEndpointUUID = endpointUUID; - $scope.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); - $scope.sessionState = RtcommService.getSessionState(endpointUUID); - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.epCtrlRemoteEndpointID = null; - $scope.sessionState = 'session:stopped'; - }); - - $scope.$on('rtcomm::init', function(event, success, details){ - if(success === true){ - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - $scope.failureReason = ''; - } - if(success == false){ - $scope.sessionState = 'session:stopped'; - $scope.epCtrlRemoteEndpointID = null; - } - }); - - - - } - }; -}; - -/** - * This directive manages the WebRTC video screen, including both the self view and the remote view. It - * also takes care of switching state between endpoints based on which endpoint is "actively" being viewed. - */ -rtcommVideo.$inject = ['RtcommService', '$log']; -function rtcommVideo(RtcommService, $log) { - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-video.html', - controller: 'RtcommVideoController' - }; -}; - -/** - * This directive manages the chat portion of a session. The data model for chat - * is maintained in the RtcommService. This directive handles switching between - * active endpoints. - */ -rtcommChat.$inject = ['RtcommService', '$log']; -function rtcommChat(RtcommService, $log) { - return { - restrict: 'E', - templateUrl: "templates/rtcomm/rtcomm-chat.html", - controller: function ($scope) { - $scope.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.chats = RtcommService.getChats($scope.chatActiveEndpointUUID); - // This forces the scroll bar to the bottom and watches the $location.hash - //$anchorScroll(); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $log.debug('rtcommChat: endpointActivated =' + endpointUUID); - - // The data model for the chat is maintained in the RtcommService. - $scope.chats = RtcommService.getChats(endpointUUID); - $scope.chatActiveEndpointUUID = endpointUUID; - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.chats = []; - $scope.chatActiveEndpointUUID = null; - }); - - $scope.keySendMessage = function(keyEvent){ - if (keyEvent.which === 13) - $scope.sendMessage(); - }; - - $scope.sendMessage = function() { - var chat = { - time : new Date(), - name : RtcommService.getEndpoint($scope.chatActiveEndpointUUID).getLocalEndpointID(), - message : angular.copy($scope.message) - }; - - $scope.message = ''; - $scope.scrollToBottom(true); - RtcommService.sendChatMessage(chat, $scope.chatActiveEndpointUUID); - }; - - }, - controllerAs: 'chat', - link: function(scope, element){ - var chatPanel = angular.element(element.find('.panel-body')[0]); - - var bottom = true; - - //Chooses if the scrollbar should be forced to the bottom on the next lifecycle - scope.scrollToBottom = function(flag){ - bottom = flag; - } - - if (chatPanel.length > 0) { - //Watch scroll events - chatPanel.bind('scroll', function(){ - if(chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')){ - scope.scrollToBottom(true); - } - else { - scope.scrollToBottom(false); - } - }); - //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down - scope.$watch('chats', function(){ - if(bottom){ - chatPanel.scrollTop(chatPanel.prop('scrollHeight')); - } - else { - //In this else, a notification could be sent - } - },true); - } - else { - $log.warn('chatPanel not found: most likely you need to load jquery prior to angular'); - } - } - }; - -}; - -/** - * This directive manages the shared iFrame. - */ -rtcommIframe.$inject = ['RtcommService', '$log', '$sce', '$location', '$window']; -function rtcommIframe(RtcommService, $log, $sce, $location, $window) { - return { - restrict: 'E', - templateUrl: "templates/rtcomm/rtcomm-iframe.html", - controller: ["$scope", function ($scope) { - $scope.iframeActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.iframeURL = null; - $scope.initiframeURL = null; - $scope.syncSource = false; - - /* - * syncSourcing means you a providing the URL source but no UI. Typically used in - * customer/agent scenarios. - */ - $scope.init = function(syncSource) { - if (syncSource == true){ - $scope.syncSource = true; - $scope.initiframeURL = $location.absUrl(); // init to current URL - } - }; - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - - if ($scope.syncSource == true){ - RtcommService.putIframeURL(eventObject.endpoint.id,$scope.initiframeURL); //Update on the current or next endpoint to be activated. - } - }); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $log.debug('rtcommIframe: endpointActivated =' + endpointUUID); - - if ($scope.syncSource == false){ - $scope.iframeURL = $sce.trustAsResourceUrl(RtcommService.getIframeURL(endpointUUID)); - $scope.iframeActiveEndpointUUID = endpointUUID; - } - }); - - $scope.$on('noEndpointActivated', function (event) { - if ($scope.syncSource == false){ - $scope.iframeURL = $sce.trustAsResourceUrl('about:blank'); - $scope.iframeActiveEndpointUUID = null; - } - }); - - $scope.$on('rtcomm::iframeUpdate', function (eventType, endpointUUID, url) { - if ($scope.syncSource == false){ - $log.debug('rtcomm::iframeUpdate: ' + url); - // This is needed to prevent rtcomm from logging in when the page is loaded in the iFrame. - url = url + "?disableRtcomm=true"; - $scope.iframeURL = $sce.trustAsResourceUrl(url); - } - else{ - $log.debug('rtcomm::iframeUpdate: load this url in a new tab: ' + url); - // In this case we'll open the pushed URL in a new tab. - $window.open($sce.trustAsResourceUrl(url), '_blank'); - } - }); - - $scope.setURL = function(newURL){ - $log.debug('rtcommIframe: setURL: newURL: ' + newURL); - RtcommService.putIframeURL($scope.iframeActiveEndpointUUID, newURL); - $scope.iframeURL = $sce.trustAsResourceUrl(newURL); - }; - - $scope.forward = function() { - }; - - $scope.backward = function() { - }; - }], - controllerAs: 'rtcommiframe' - }; -}; - - - -/******************************** Rtcomm Modals ************************************************/ - -/** - * This modal is displayed on receiving an inbound call. It handles the alerting event. - * Note that it can also auto accept requests for enabling A/V. - */ - -RtcommAlertModalController.$inject=['$rootScope', '$scope', 'RtcommService', '$modal', '$log']; -function RtcommAlertModalController($rootScope, $scope, RtcommService, $modal, $log) { - - $scope.alertingEndpointUUID = null; - $scope.autoAnswerNewMedia = false; - $scope.alertActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.caller = null; - - $scope.init = function(autoAnswerNewMedia) { - $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); - $scope.autoAnswerNewMedia = autoAnswerNewMedia; - }; - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $scope.alertActiveEndpointUUID = endpointUUID; - }); - - $scope.$on('session:alerting', function (event, eventObject) { - - if (($scope.alertActiveEndpointUUID == eventObject.endpoint.id && $scope.autoAnswerNewMedia == false) || - ($scope.alertActiveEndpointUUID != eventObject.endpoint.id)) - { - $log.debug('rtcommAlert: display alterting model: alertActiveEndpointUUID = ' + eventObject.endpoint + ' autoAnswerNewMedia = ' + $scope.autoAnswerNewMedia); - $scope.caller = eventObject.endpoint.getRemoteEndpointID(); - $scope.alertingEndpointUUID = eventObject.endpoint.id; - $scope.showAlerting(); - } - else{ - $log.debug('Accepting media from: ' + eventObject.endpoint.getRemoteEndpointID() + ' for endpoint: ' + eventObject.endpoint.id); - eventObject.endpoint.accept(); - } - }); - - $scope.showAlerting = function (size) { - - var modalInstance = $modal.open({ - templateUrl: 'templates/rtcomm/rtcomm-modal-alert.html', - controller: 'RtcommAlertModalInstanceController', - size: size, - backdrop: 'static', - resolve: { - caller: function () { - return $scope.caller; - }} - }); - - modalInstance.result.then( - function() { - var alertingEndpointObject = RtcommService.getEndpoint($scope.alertingEndpointUUID); - - if(alertingEndpointObject){ - $log.debug('Accepting call from: ' + $scope.caller + ' for endpoint: ' + $scope.alertingEndpointUUID); - alertingEndpointObject.accept(); - $rootScope.$broadcast('rtcomm::alert-success'); - alertingEndpointObject = null; - } - }, - function () { - var alertingEndpointObject = RtcommService.getEndpoint($scope.alertingEndpointUUID); - if(alertingEndpointObject){ - $log.debug('Rejecting call from: ' + $scope.caller + ' for endpoint: ' + $scope.alertingEndpointUUID); - alertingEndpointObject.reject(); - alertingEndpointObject = null; - } - }); - }; -}; - -RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; - -function RtcommAlertModalInstanceController($scope, $modalInstance, $log, caller) { - $scope.caller = caller; - $scope.ok = function () { - $log.debug('Accepting alerting call'); - $modalInstance.close(); - }; - - $scope.cancel = function () { - $log.debug('Rejecting alerting call'); - $modalInstance.dismiss('cancel'); - }; -}; - -/** - * This is a modal controller for placing an outbound call to a static callee such as a queue. - */ -RtcommCallModalController.$inject = ['$scope', 'RtcommService', '$modal', '$log']; -function RtcommCallModalController($scope, RtcommService, $modal, $log) { - $scope.calleeID = null; - $scope.callerID = null; - - $scope.enableCallModel = false; - $scope.mediaToEnable = ['chat']; - - $scope.init = function(calleeID, mediaToEnable) { - $scope.calleeID = calleeID; - - if (typeof mediaToEnable !== "undefined") - $scope.mediaToEnable = mediaToEnable; - }; - - $scope.$on('rtcomm::init', function (event, success, details) { - $log.debug('RtcommCallModalController: rtcomm::init: success = ' + success); - if (success == true) - $scope.enableCallModel = true; - else - $scope.enableCallModel = false; - }); - - $scope.$on('session:started', function (event, eventObject) { - $scope.enableCallModel = false; - }); - - $scope.$on('session:stopped', function (event, eventObject) { - $scope.enableCallModel = true; - }); - - $scope.placeCall = function (size) { - - var modalInstance = $modal.open({ - templateUrl: 'templates/rtcomm/rtcomm-modal-call.html', - controller: 'RtcommCallModalInstanceController', - size: size, - resolve: {} - }); - - modalInstance.result.then( - function (resultName) { - $log.debug('rtcommCallModal: Calling calleeID: ' + $scope.calleeID); - $log.debug('rtcommCallModal: CallerID: ' + resultName); - - // This is used to set an alias when the endoint is not defined. - if ($scope.callerID == null && (typeof resultName !== "undefined") && resultName != ''){ - $scope.callerID = resultName; - RtcommService.setAlias(resultName); - } - - RtcommService.placeCall($scope.calleeID, $scope.mediaToEnable); - }, - function () { - $log.info('Modal dismissed at: ' + new Date()); - }); - }; -}; - -RtcommCallModalInstanceController.$inject = ['$scope', '$modalInstance', 'RtcommService']; -function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { - $scope.endpointAlias = ''; - $scope.ok = function () { - $modalInstance.close($scope.endpointAlias); - }; - $scope.cancel = function () { - $modalInstance.dismiss('cancel'); - }; -}; - -/********************************************* Rtcomm Controllers ******************************************************/ - -/** - * This is the controller for config loader. It reads a JSON object and utilizes the RtcommService to set the configuration. - * This can also result in the initialization of the endpoint provider if the config JSON object includes a registration name. - * - * Here is an example of the config object: - * - * { - * "server" : "server address", - * "port" : 1883, - * "rtcommTopicPath" : "/rtcomm-helpdesk/", - * "createEndpoint" : false, - * "userid" : "registration name", - * "broadcastAudio" : true, - * "broadcastVideo" : true - * } - * - * NOTE: If the user does not specify a userid, that says one will never be specified so go ahead - * and initialize the endpoint provider and let the provider assign a name. If a defined empty - * string is passed in, that means to wait until the end user registers a name before initializing - * the endpoint provider. - */ - -RtcommConfigController.$inject = ['$scope','$http', 'RtcommService', '$log']; -function RtcommConfigController($scope, $http, RtcommService, $log) { - $scope.extendedConfig = null; - - $log.debug('RtcommConfigController: configURL = ' + $scope.configURL); - - $scope.setConfig = function(data) { - $log.debug('RtcommConfigController: setting config data:' + data); - RtcommService.setConfig(data); - }; - - $scope.init = function(configURL,extendedConfig) { - $log.debug('RtcommConfigController: initing configURL = ' + configURL); - $scope.configURL = configURL; - - if (typeof extendedConfig !== "undefined") - $scope.extendedConfig = extendedConfig; - - $scope.getConfig(); - }; - - $scope.getConfig = function() { - $http.get($scope.configURL).success (function(config){ - - // Now we need to update the config with any extensions passed in on init. - if ($scope.extendedConfig != null){ - angular.extend(config, $scope.extendedConfig); - $log.debug('RtcommConfigController: extended config object: ' + config); - } - - RtcommService.setConfig(config); - }).error(function(data, status, headers, config) { - $log.debug('RtcommConfigController: error accessing config: ' + status); - }); - }; -}; - - -RtcommVideoController.$inject= ['$scope','$http', 'RtcommService', '$log']; -function RtcommVideoController($scope, $http, RtcommService, $log) { - $scope.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); - $scope.init = function(selfView,remoteView) { - RtcommService.setViewSelector(selfView,remoteView); - - var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); - }; - - // Go ahead and initialize the local media here if an endpoint already exist. - var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - // Not to do something here to show that this button is live. - $log.debug('rtcommVideo: endpointActivated =' + endpointUUID); - RtcommService.setVideoView(endpointUUID); - $scope.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.avConnected = false; - }); - - $scope.$on('webrtc:connected', function (event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - $scope.avConnected = true; - }); - - $scope.$on('webrtc:disconnected', function (event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - $scope.avConnected = false; - }); -}; - - -RtcommEndpointController.$inject = ['$scope', '$rootScope', '$http', 'RtcommService', '$log']; -function RtcommEndpointController($scope, $rootScope, $http, RtcommService, $log) { - // Session states. - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - - $scope.disconnect = function() { - $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); - }; - - $scope.toggleAV = function() { - $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - - if ($scope.epCtrlAVConnected == false){ - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { - if (!value) { - $log.debug('Enable failed: ',message); - RtcommService.alert({type: 'danger', msg: message}); - } - }); - } - else{ - $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); - } - }; - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:started'; - } - }); - - $scope.$on('session:stopped', function (event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:stopped'; - } - }); - - $scope.$on('session:failed', function (event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:failed'; - } - }); - - $scope.$on('webrtc:connected', function (event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = true; - }); - - $scope.$on('webrtc:disconnected', function (event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = false; - }); - - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $scope.epCtrlActiveEndpointUUID = endpointUUID; - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.epCtrlAVConnected = false; - }); -}; - -})(); diff --git a/src/js/rtcomm-services.js b/src/js/rtcomm-services.js index ccffb61..bee79b4 100644 --- a/src/js/rtcomm-services.js +++ b/src/js/rtcomm-services.js @@ -16,7 +16,8 @@ requireBase: false}); }) */ .factory('RtcommConfigService', RtcommConfigService) - .factory('RtcommService', RtcommService); + .factory('RtcommService', RtcommService) + .constant('rtcomm', rtcomm); /** * */ @@ -120,8 +121,8 @@ }; }; - RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService']; - function RtcommService($rootScope, $log, $http, RtcommConfigService) { + RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; + function RtcommService($rootScope, $log, $http, RtcommConfigService, rtcomm) { /** Setup the endpoint provider first **/ var myEndpointProvider = new rtcomm.EndpointProvider(); var endpointProviderInitialized = false; diff --git a/src/js/services/rtcomm.event.service.js b/src/js/services/rtcomm.event.service.js new file mode 100644 index 0000000..e69de29 diff --git a/src/js/services/rtcomm.service.js b/src/js/services/rtcomm.service.js new file mode 100644 index 0000000..21db963 --- /dev/null +++ b/src/js/services/rtcomm.service.js @@ -0,0 +1,45 @@ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-service') + .factory('RtcommService', RtcommService); + + RtcommService.$inject = ['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; + + /* @ngInject */ + function RtcommService(dependencies) { + var service = { + alert: alert, + setKarmaTesting: setKarmaTesting, + isInitialized: isInitialized, + setConfig: setConfig, + getPresenceMonitor: getPresenceMonitor, + publishPresence: publishPresence, + addToPresenceRecord: addToPresenceRecord, + removeFromPresenceRecord: removeFromPresenceRecord, + setPresenceRecordState: setPresenceRecordState, + getEndpoint: getEndpoint, + destroyEndpoint: destroyEndpoint, + register: register, + unregister: unregister, + joinQueue: joinQueue, + leaveQueue: leaveQueue, + getQueues: getQueues, + sendChatMessage: sendChatMessage, + getChats: getChats, + isWebrtcConnected: isWebrtcConnected, + + + + }; + + return service; + + function + + function() { + + } + } +})(); diff --git a/src/js/services/services.module.js b/src/js/services/services.module.js new file mode 100644 index 0000000..549d7e8 --- /dev/null +++ b/src/js/services/services.module.js @@ -0,0 +1,7 @@ +// (function() { +// 'use strict'; +// +// angular +// .module('angular-rtcomm-service', []) +// .constant('rtcomm', rtcomm); +// })(); diff --git a/src/js/ui/config.controller.js b/src/js/ui/config.controller.js new file mode 100644 index 0000000..b728b45 --- /dev/null +++ b/src/js/ui/config.controller.js @@ -0,0 +1,76 @@ +/********************************************* Rtcomm Controllers ******************************************************/ + +/** + * This is the controller for config loader. It reads a JSON object and utilizes the RtcommService to set the configuration. + * This can also result in the initialization of the endpoint provider if the config JSON object includes a registration name. + * + * Here is an example of the config object: + * + * { + * "server" : "server address", + * "port" : 1883, + * "rtcommTopicPath" : "/rtcomm-helpdesk/", + * "createEndpoint" : false, + * "userid" : "registration name", + * "broadcastAudio" : true, + * "broadcastVideo" : true + * } + * + * NOTE: If the user does not specify a userid, that says one will never be specified so go ahead + * and initialize the endpoint provider and let the provider assign a name. If a defined empty + * string is passed in, that means to wait until the end user registers a name before initializing + * the endpoint provider. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .controller('RtcommConfigController', RtcommConfigController); + + RtcommConfigController.$inject = ['RtcommService', '$http', '$scope', '$log']; + + /* @ngInject */ + function RtcommConfigController(dependencies) { + var vm = this; + vm.extendedConfig = null; + + $log.debug('RtcommConfigController: configURL = ' + vm.configURL); + + vm.setConfig = function(data) { + $log.debug('RtcommConfigController: setting config data:' + data); + RtcommService.setConfig(data); + }; + + $scope.init = function(configURL, extendedConfig) { + $log.debug('RtcommConfigController: initing configURL = ' + configURL); + vm.configURL = configURL; + + if (typeof extendedConfig !== "undefined") + vm.extendedConfig = extendedConfig; + + vm.getConfig(); + }; + + vm.getConfig = function() { + $http.get(vm.configURL).success(function(config) { + + // Now we need to update the config with any extensions passed in on init. + if (vm.extendedConfig != null) { + angular.extend(config, vm.extendedConfig); + $log.debug('RtcommConfigController: extended config object: ' + config); + } + + RtcommService.setConfig(config); + }).error(function(data, status, headers, config) { + $log.debug('RtcommConfigController: error accessing config: ' + status); + }); + }; + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint-provider/rtcomm-alert.directive.js b/src/js/ui/endpoint-provider/rtcomm-alert.directive.js new file mode 100644 index 0000000..cf48f74 --- /dev/null +++ b/src/js/ui/endpoint-provider/rtcomm-alert.directive.js @@ -0,0 +1,42 @@ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommAlert', rtcommAlert); + + /* @ngInject */ + function rtcommAlert() { + var directive = { + restrict: 'E', + templateUrl: "templates/rtcomm/rtcomm-alert.html", + controller: AlertController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + } + + AlertController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function AlertController(RtcommService, $scope, $log) { + var vm = this; + vm.alerts = []; + vm.addAlert = function(alert) { + vm.alerts.push(alert); + }; + vm.closeAlert = function(index) { + vm.alerts.splice(index, 1); + }; + $scope.$on('rtcomm::alert', function(event, eventObject) { + vm.addAlert(eventObject); + }); + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint-provider/rtcomm-chat.directive.js b/src/js/ui/endpoint-provider/rtcomm-chat.directive.js new file mode 100644 index 0000000..db2baa5 --- /dev/null +++ b/src/js/ui/endpoint-provider/rtcomm-chat.directive.js @@ -0,0 +1,107 @@ +/** + * This directive manages the chat portion of a session. The data model for chat + * is maintained in the RtcommService. This directive handles switching between + * active endpoints. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommChat', rtcommChat); + + rtcommChat.$inject = ['RtcommService', '$log']; + + /* @ngInject */ + function rtcommChat(RtcommService, $log) { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-chat.html', + scope: {}, + link: chatLink, + controller: RtcommChatController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + + function chatLink(scope, element, attr, ctrl) { + var chatPanel = angular.element(element.find('.panel-body')[0]); + + var bottom = true; + + //Chooses if the scrollbar should be forced to the bottom on the next lifecycle + scope.scrollToBottom = function(flag) { + bottom = flag; + } + + if (chatPanel.length > 0) { + //Watch scroll events + chatPanel.bind('scroll', function() { + if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { + scope.scrollToBottom(true); + } else { + scope.scrollToBottom(false); + } + }); + //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down + scope.$watch('chats', function() { + if (bottom) { + chatPanel.scrollTop(chatPanel.prop('scrollHeight')); + } else { + //In this else, a notification could be sent + } + }, true); + } else { + $log.warn('chatPanel not found: most likely you need to load jquery prior to angular'); + } + } + + } + + RtcommChatController.$inject = ['$scope', 'RtcommService', '$log']; + + /* @ngInject */ + function RtcommChatController($scope, RtcommService, $log) { + var vm = this; + + vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommChat: endpointActivated =' + endpointUUID); + + // The data model for the chat is maintained in the RtcommService. + vm.chats = RtcommService.getChats(endpointUUID); + vm.chatActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('noEndpointActivated', function(event) { + $scope.chats = []; + $scope.chatActiveEndpointUUID = null; + }); + + vm.keySendMessage = function(keyEvent) { + if (keyEvent.which === 13) + $scope.sendMessage(); + }; + + vm.sendMessage = function() { + var chat = { + time: new Date(), + name: RtcommService.getEndpoint($scope.chatActiveEndpointUUID).getLocalEndpointID(), + message: angular.copy($scope.message) + }; + + vm.message = ''; + vm.scrollToBottom(true); + RtcommService.sendChatMessage(chat, $scope.chatActiveEndpointUUID); + } + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint-provider/rtcomm-directives.module.js b/src/js/ui/endpoint-provider/rtcomm-directives.module.js new file mode 100644 index 0000000..cc46afb --- /dev/null +++ b/src/js/ui/endpoint-provider/rtcomm-directives.module.js @@ -0,0 +1,9 @@ +// (function() { +// 'use strict'; +// +// angular +// .module('angular-rtcomm-ui', [ +// 'ui.bootstrap', +// 'angular-rtcomm-service' +// ]); +// })(); diff --git a/src/js/ui/endpoint-provider/rtcomm-queues.directive.js b/src/js/ui/endpoint-provider/rtcomm-queues.directive.js new file mode 100644 index 0000000..4940109 --- /dev/null +++ b/src/js/ui/endpoint-provider/rtcomm-queues.directive.js @@ -0,0 +1,152 @@ +/** + * This directive manages call queues. It provides the ability to display all the available queues + * (along with their descriptions) and by clicking on a queue, allows an agent (or any type of user) + * to subscribe on that queue. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommQueues', rtcommQueues); + + /* @ngInject */ + function rtcommQueues() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-queues.html', + controller: QueuesController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + + function linkFunc(scope, el, attr, ctrl) { + + } + } + + QueuesController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function QueuesController(RtcommService, $scope, $log) { + var vm = this; + + vm.rQueues = []; + vm.autoJoinQueues = false; + vm.queuePresenceData = []; + vm.queuePublishPresence = false; + vm.queueFilter = null; + + /** + * autoJoinQueues - automatically join any queues that are not filtered out + * queuePublishedPresence - will add to the presence document information about what queues this person joins. + * queueFilter - If defined, this specifies which queues should be joined. All others will be ignored. + */ + vm.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { + $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); + vm.autoJoinQueues = autoJoinQueues; + vm.queuePublishPresence = queuePublishPresence; + + if (typeof queueFilter !== "undefined") + vm.queueFilter = queueFilter; + }; + + // + vm.filterOutQueue = function(queue) { + var returnValue = true; + + if (vm.queueFilter != null) { + + for (var index = 0; index < vm.queueFilter.length; ++index) { + var entry = vm.queueFilter[index]; + if (entry == queue.endpointID) { + returnValue = false; + break; + } + } + } else + returnValue = false; + + return (returnValue); + }; + + vm.onQueueClick = function(queue) { + $log.debug('rtcommQueues: onClick: TOP'); + for (var index = 0; index < vm.rQueues.length; index++) { + if (vm.rQueues[index].endpointID === queue.endpointID) { + $log.debug('rtcommQueues: onClick: queue.endpointID = ' + queue.endpointID); + + if (queue.active == false) { + RtcommService.joinQueue(queue.endpointID); + vm.rQueues[index].active = true; + } else { + RtcommService.leaveQueue(queue.endpointID); + vm.rQueues[index].active = false; + } + } else if (index == (vm.rQueues.length - 1)) { + $log.debug('rtcommQueues: ERROR: queue.endpointID: ' + queue.endpointID + ' not found in list of queues'); + + } + } + + vm.updateQueuePresence(); + }; + + vm.updateQueuePresence = function() { + // Update the presence record if enabled + if (vm.queuePublishPresence == true) { + RtcommService.removeFromPresenceRecord(vm.queuePresenceData, false); + + vm.queuePresenceData = []; + + for (var index = 0; index < vm.rQueues.length; index++) { + if (vm.rQueues[index].active === true) { + vm.queuePresenceData.push({ + 'name': "queue", + 'value': $scope.rQueues[index].endpointID + }); + } + } + + RtcommService.addToPresenceRecord(vm.queuePresenceData); + } + } + + $scope.$on('queueupdate', function(event, queues) { + $log.debug('rtcommQueues: scope queues', vm.rQueues); + + Object.keys(queues).forEach(function(key) { + $log.debug('rtcommQueues: Push queue: ' + queues[key]); + $log.debug('rtcommQueues: autoJoinQueues: ' + vm.autoJoinQueues); + + // Check to make sure queue is not filteres out before adding it. + if (vm.filterOutQueue(queues[key]) == false) { + vm.rQueues.push(queues[key]); + + // If autoJoin we go ahead and join the queue as soon as we get the queue update. + if (vm.autoJoinQueues == true) { + vm.onQueueClick(queues[key]); + } + } + }); + + vm.updateQueuePresence(); + }); + + $scope.$on('rtcomm::init', function(event, success, details) { + if (success == false) { + $log.debug('rtcommQueues: init: clear queues'); + vm.rQueues = []; + } + }); + + + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint-provider/rtcomm-register.directive.js b/src/js/ui/endpoint-provider/rtcomm-register.directive.js new file mode 100644 index 0000000..ec5e861 --- /dev/null +++ b/src/js/ui/endpoint-provider/rtcomm-register.directive.js @@ -0,0 +1,84 @@ +/** + * This directive is used to manage the registration of an endpoint provider. Since the registered name can only + * be set on initialization of the endpoint provider, this directive actually controls the initialization of the + * provider. Note that the endpoint provider must be initialized before any sessions can be created or received. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommRegister', rtcommRegister); + + /* @ngInject */ + function rtcommRegister() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-register.html', + controller: RegisterController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + + } + + RegisterController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function RegisterController(RtcommService, $scope, $log) { + var vm = this; + + vm.nextAction = 'Register'; + + vm.reguserid = ''; + + vm.invalid = false; + + var invalidCharacters = /(\$|#|\+|\/|\\)+/i; //Invalid characters for MQTT Topic Path + + //Watch for changes in reguserid + $scope.$watch('reguserid', function() { + + if (vm.reguserid.length < 1 || invalidCharacters.test(vm.reguserid)) { + + vm.invalid = true; + } else { + vm.invalid = false; + } + }); + + + vm.onRegClick = function() { + if (vm.nextAction === 'Register' && !invalidCharacters.test(vm.reguserid)) { + + $log.debug('Register: reguserid =' + vm.reguserid); + RtcommService.register(vm.reguserid); + } else { + $log.debug('Unregister: reguserid =' + vm.reguserid); + RtcommService.unregister(); + } + }; + + $scope.$on('rtcomm::init', function(event, success, details) { + + if (success == true) { + vm.nextAction = 'Unregister'; + vm.reguserid = details.userid; + } else { + vm.nextAction = 'Register'; + + if (details == 'destroyed') + vm.reguserid = ''; + else + vm.reguserid = 'Init failed:' + details; + } + }); + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js b/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js new file mode 100644 index 0000000..37f4f07 --- /dev/null +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js @@ -0,0 +1,85 @@ + +/************* Endpoint Provider Directives *******************************/ +/** + * This directive is used to manage multiple sessions. If you are only supporting at most one session you wont need + * this directive. The associated template provides a way to switch between active sessions. The session must be in + * the started state to be managed by this directive and is removed when the session stops. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommSessionManager', rtcommSessionManager); + + /* @ngInject */ + function rtcommSessionManager() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-sessionmgr.html', + controller: SessionManagerController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + + function linkFunc(scope, el, attr, ctrl) { + + } + } + + SessionManagerController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function SessionManagerController(RtcommService, $scope, $log) { + var vm = this; + vm.sessions = RtcommService.getSessions(); + vm.sessMgrActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.publishPresence = false; + vm.sessionPresenceData = []; + + vm.init = function(publishPresence) { + vm.publishPresence = publishPresence; + vm.updatePresence(); + }; + + vm.activateSession = function(endpointUUID) { + $log.debug('rtcommSessionmgr: activateEndpoint =' + endpointUUID); + if (vm.sessMgrActiveEndpointUUID != endpointUUID) { + RtcommService.setActiveEndpoint(endpointUUID); + } + }; + + vm.updatePresence = function() { + // Update the presence record if enabled + if (vm.publishPresence == true) { + RtcommService.removeFromPresenceRecord(vm.sessionPresenceData, false); + + vm.sessionPresenceData = [{ + 'name': "sessions", + 'value': String(vm.sessions.length) + }]; + + RtcommService.addToPresenceRecord(vm.sessionPresenceData); + } + } + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommSessionmgr: endpointActivated =' + endpointUUID); + vm.sessMgrActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('rtcommSessionmgr: session:started: uuid =' + eventObject.endpoint.id); + + vm.updatePresence(); + }); + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint.controller.js b/src/js/ui/endpoint.controller.js new file mode 100644 index 0000000..1f32242 --- /dev/null +++ b/src/js/ui/endpoint.controller.js @@ -0,0 +1,87 @@ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .controller('RtcommEndpointController', RtcommEndpointController); + + RtcommEndpointController.$inject = ['RtcommService', '$http', '$rootScope', '$scope', '$log']; + + /* @ngInject */ + function RtcommEndpointController(RtcommService, $http, $rootScope, $scope, $log) { + var vm = this; + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + + vm.disconnect = function() { + $log.debug('Disconnecting call for endpoint: ' + vm.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).disconnect(); + }; + + vm.toggleAV = function() { + $log.debug('Enable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); + + if (vm.epCtrlAVConnected == false) { + RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { + if (!value) { + $log.debug('Enable failed: ', message); + RtcommService.alert({ + type: 'danger', + msg: message + }); + } + }); + } else { + $log.debug('Disable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.disable(); + } + }; + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:started'; + } + }); + + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:stopped'; + } + }); + + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:failed'; + } + }); + + $scope.$on('webrtc:connected', function(event, eventObject) { + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + vm.epCtrlAVConnected = true; + }); + + $scope.$on('webrtc:disconnected', function(event, eventObject) { + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + vm.epCtrlAVConnected = false; + }); + + + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.epCtrlActiveEndpointUUID = endpointUUID; + vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.epCtrlAVConnected = false; + }); + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status.js b/src/js/ui/endpoint/rtcomm-endpoint-status.js new file mode 100644 index 0000000..09ca073 --- /dev/null +++ b/src/js/ui/endpoint/rtcomm-endpoint-status.js @@ -0,0 +1,150 @@ +/** + * This endpoint status controller only shows the active endpoint. The $scope.sessionState always contains the + * state of the active endpoint if one exist. It will be one of the following states: + * + * 'session:alerting' + * 'session:trying' + * 'session:ringing' + * 'session:queued' - for this one $scope.queueCount will tell you where you are in the queue. + * 'session:failed' - for this one $scope.reason will tell you why the call failed. + * 'session:started' + * 'session:stopped' + * + * You can bind to $scope.sessionState to track state in the view. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommEndpointStatus', rtcommEndpointStatus); + + /* @ngInject */ + function rtcommEndpointStatus() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', + controller: EndpointStatusController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + + function linkFunc(scope, el, attr, ctrl) { + + } + } + + EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function EndpointStatusController(RtcommService, $scope, $log) { + var vm = this; + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + vm.failureReason = ''; + vm.queueCount = 0; // FIX: Currently not implemented! + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:started'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); + + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:failed'; + vm.failureReason = eventObject.reason; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:alerting', function(event, eventObject) { + $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID != eventObject.endpoint.id) { + vm.sessionState = 'session:alerting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:connecting', function(event, eventObject) { + $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); + // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ + vm.sessionState = 'session:connecting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + // } + }); + + + $scope.$on('session:queued', function(event, eventObject) { + $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:queued'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:trying', function(event, eventObject) { + $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:trying'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:ringing', function(event, eventObject) { + $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:ringing'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.epCtrlActiveEndpointUUID = endpointUUID; + vm.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); + vm.sessionState = RtcommService.getSessionState(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.epCtrlRemoteEndpointID = null; + vm.sessionState = 'session:stopped'; + }); + + $scope.$on('rtcomm::init', function(event, success, details) { + if (success === true) { + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + vm.failureReason = ''; + } + if (success == false) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); + + + + } + activate(); + + function activate() { + + } + +})(); diff --git a/src/js/ui/endpoint/rtcomm-iframe.directive.js b/src/js/ui/endpoint/rtcomm-iframe.directive.js new file mode 100644 index 0000000..ffe93f7 --- /dev/null +++ b/src/js/ui/endpoint/rtcomm-iframe.directive.js @@ -0,0 +1,95 @@ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommIframe', rtcommIframe); + + /* @ngInject */ + function rtcommIframe() { + var directive = { + restrict: 'E', + templateUrl: "templates/rtcomm/rtcomm-iframe.html", + controller: IFrameController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + } + + IFrameController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function IFrameController(RtcommService, $scope, $log) { + var vm = this; + vm.iframeActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.iframeURL = null; + vm.initiframeURL = null; + vm.syncSource = false; + + /* + * syncSourcing means you a providing the URL source but no UI. Typically used in + * customer/agent scenarios. + */ + vm.init = function(syncSource) { + if (syncSource == true) { + vm.syncSource = true; + vm.initiframeURL = $location.absUrl(); // init to current URL + } + }; + + + vm.setURL = function(newURL) { + $log.debug('rtcommIframe: setURL: newURL: ' + newURL); + RtcommService.putIframeURL(vm.iframeActiveEndpointUUID, newURL); + vm.iframeURL = $sce.trustAsResourceUrl(newURL); + }; + + vm.forward = function() {}; + + vm.backward = function() {}; + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + + if (vm.syncSource == true) { + RtcommService.putIframeURL(eventObject.endpoint.id, vm.initiframeURL); //Update on the current or next endpoint to be activated. + } + }); + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommIframe: endpointActivated =' + endpointUUID); + + if (vm.syncSource == false) { + vm.iframeURL = $sce.trustAsResourceUrl(RtcommService.getIframeURL(endpointUUID)); + vm.iframeActiveEndpointUUID = endpointUUID; + } + }); + + $scope.$on('noEndpointActivated', function(event) { + if (vm.syncSource == false) { + vm.iframeURL = $sce.trustAsResourceUrl('about:blank'); + vm.iframeActiveEndpointUUID = null; + } + }); + + $scope.$on('rtcomm::iframeUpdate', function(eventType, endpointUUID, url) { + if (vm.syncSource == false) { + $log.debug('rtcomm::iframeUpdate: ' + url); + // This is needed to prevent rtcomm from logging in when the page is loaded in the iFrame. + url = url + "?disableRtcomm=true"; + vm.iframeURL = $sce.trustAsResourceUrl(url); + } else { + $log.debug('rtcomm::iframeUpdate: load this url in a new tab: ' + url); + // In this case we'll open the pushed URL in a new tab. + $window.open($sce.trustAsResourceUrl(url), '_blank'); + } + }); + activate(); + + function activate() { + + } + } +})(); diff --git a/src/js/ui/endpoint/rtcomm-video.directive.js b/src/js/ui/endpoint/rtcomm-video.directive.js new file mode 100644 index 0000000..c53ac2f --- /dev/null +++ b/src/js/ui/endpoint/rtcomm-video.directive.js @@ -0,0 +1,66 @@ +/** + * This directive manages the WebRTC video screen, including both the self view and the remote view. It + * also takes care of switching state between endpoints based on which endpoint is "actively" being viewed. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommVideo', rtcommVideo); + + /* @ngInject */ + function rtcommVideo() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-video.html', + controller: VideoController, + controllerAs: 'vm', + bindToController: true + }; + + return directive; + } + + VideoController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function VideoController(RtcommService, $scope, $log) { + var vm = this; + vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); + vm.init = function(selfView, remoteView) { + RtcommService.setViewSelector(selfView, remoteView); + + var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); + if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) + RtcommService.setVideoView(videoActiveEndpointUUID); + }; + + // Go ahead and initialize the local media here if an endpoint already exist. + var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); + if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) + RtcommService.setVideoView(videoActiveEndpointUUID); + + $scope.$on('endpointActivated', function(event, endpointUUID) { + // Not to do something here to show that this button is live. + $log.debug('rtcommVideo: endpointActivated =' + endpointUUID); + RtcommService.setVideoView(endpointUUID); + vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.avConnected = false; + }); + + $scope.$on('webrtc:connected', function(event, eventObject) { + if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + vm.avConnected = true; + }); + + $scope.$on('webrtc:disconnected', function(event, eventObject) { + if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + vm.avConnected = false; + }); + } +})(); diff --git a/src/js/ui/modals/alert-modal.js b/src/js/ui/modals/alert-modal.js new file mode 100644 index 0000000..c892965 --- /dev/null +++ b/src/js/ui/modals/alert-modal.js @@ -0,0 +1,102 @@ +/** + * This modal is displayed on receiving an inbound call. It handles the alerting event. + * Note that it can also auto accept requests for enabling A/V. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .controller('RtcommAlertModalController', RtcommAlertModalController) + .controller('RtcommAlertModalInstanceController', RtcommAlertModalInstanceController); + + RtcommAlertModalController.$inject = ['RtcommService', '$modal', '$rootScope', '$scope', '$log']; + + /* @ngInject */ + function RtcommAlertModalController(RtcommService, $modal, $rootScope, $scope, $log) { + var vm = this; + vm.alertingEndpointUUID = null; + vm.autoAnswerNewMedia = false; + vm.alertActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.caller = null; + + vm.init = function(autoAnswerNewMedia) { + $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); + vm.autoAnswerNewMedia = autoAnswerNewMedia; + }; + + vm.showAlerting = function(size) { + + var modalInstance = $modal.open({ + templateUrl: 'templates/rtcomm/rtcomm-modal-alert.html', + controller: 'RtcommAlertModalInstanceController', + size: size, + backdrop: 'static', + resolve: { + caller: function() { + return vm.caller; + } + } + }); + + modalInstance.result.then( + function() { + var alertingEndpointObject = RtcommService.getEndpoint(vm.alertingEndpointUUID); + + if (alertingEndpointObject) { + $log.debug('Accepting call from: ' + vm.caller + ' for endpoint: ' + vm.alertingEndpointUUID); + alertingEndpointObject.accept(); + $rootScope.$broadcast('rtcomm::alert-success'); + alertingEndpointObject = null; + } + }, + function() { + var alertingEndpointObject = RtcommService.getEndpoint(vm.alertingEndpointUUID); + if (alertingEndpointObject) { + $log.debug('Rejecting call from: ' + vm.caller + ' for endpoint: ' + vm.alertingEndpointUUID); + alertingEndpointObject.reject(); + alertingEndpointObject = null; + } + }); + }; + + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.alertActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('session:alerting', function(event, eventObject) { + + if ((vm.alertActiveEndpointUUID == eventObject.endpoint.id && vm.autoAnswerNewMedia == false) || + (vm.alertActiveEndpointUUID != eventObject.endpoint.id)) { + $log.debug('rtcommAlert: display alterting model: alertActiveEndpointUUID = ' + eventObject.endpoint + ' autoAnswerNewMedia = ' + vm.autoAnswerNewMedia); + vm.caller = eventObject.endpoint.getRemoteEndpointID(); + vm.alertingEndpointUUID = eventObject.endpoint.id; + vm.showAlerting(); + } else { + $log.debug('Accepting media from: ' + eventObject.endpoint.getRemoteEndpointID() + ' for endpoint: ' + eventObject.endpoint.id); + eventObject.endpoint.accept(); + } + }); + activate(); + + function activate() { + + } + } + + RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; + + function RtcommAlertModalInstanceController($scope, $modalInstance, $log, caller) { + $scope.caller = caller; + $scope.ok = function () { + $log.debug('Accepting alerting call'); + $modalInstance.close(); + }; + + $scope.cancel = function () { + $log.debug('Rejecting alerting call'); + $modalInstance.dismiss('cancel'); + }; + }; +})(); diff --git a/src/js/ui/modals/call-modal.js b/src/js/ui/modals/call-modal.js new file mode 100644 index 0000000..53ef3e2 --- /dev/null +++ b/src/js/ui/modals/call-modal.js @@ -0,0 +1,89 @@ +/** + * This is a modal controller for placing an outbound call to a static callee such as a queue. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .controller('RtcommCallModalController', RtcommCallModalController) + .controller('RtcommCallModalInstanceController', RtcommCallModalInstanceController); + + RtcommCallModalController.$inject = ['RtcommService', '$modal', '$scope', '$log']; + + /* @ngInject */ + function RtcommCallModalController(dependencies) { + var vm = this; + vm.calleeID = null; + vm.callerID = null; + + vm.enableCallModel = false; + vm.mediaToEnable = ['chat']; + + vm.init = function(calleeID, mediaToEnable) { + vm.calleeID = calleeID; + + if (typeof mediaToEnable !== "undefined") + vm.mediaToEnable = mediaToEnable; + }; + + vm.placeCall = function(size) { + + var modalInstance = $modal.open({ + templateUrl: 'templates/rtcomm/rtcomm-modal-call.html', + controller: 'RtcommCallModalInstanceController', + size: size, + resolve: {} + }); + + modalInstance.result.then( + function(resultName) { + $log.debug('rtcommCallModal: Calling calleeID: ' + vm.calleeID); + $log.debug('rtcommCallModal: CallerID: ' + resultName); + + // This is used to set an alias when the endoint is not defined. + if (vm.callerID == null && (typeof resultName !== "undefined") && resultName != '') { + vm.callerID = resultName; + RtcommService.setAlias(resultName); + } + + RtcommService.placeCall(vm.calleeID, vm.mediaToEnable); + }, + function() { + $log.info('Modal dismissed at: ' + new Date()); + }); + }; + + $scope.$on('rtcomm::init', function(event, success, details) { + $log.debug('RtcommCallModalController: rtcomm::init: success = ' + success); + if (success == true) + vm.enableCallModel = true; + else + vm.enableCallModel = false; + }); + + $scope.$on('session:started', function(event, eventObject) { + vm.enableCallModel = false; + }); + + $scope.$on('session:stopped', function(event, eventObject) { + vm.enableCallModel = true; + }); + activate(); + + function activate() { + + } + } + + function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { + $scope.endpointAlias = ''; + $scope.ok = function() { + $modalInstance.close($scope.endpointAlias); + }; + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + }; + +})(); diff --git a/src/js/ui/ui.module.js b/src/js/ui/ui.module.js new file mode 100644 index 0000000..7bb47db --- /dev/null +++ b/src/js/ui/ui.module.js @@ -0,0 +1,12 @@ +/* + * The angular-rtcomm-ui module + * This has controllers and directives in it. + */ +(function(){ + +angular + .module('angular-rtcomm-ui', [ + 'ui.bootstrap', + 'angular-rtcomm-service']); + +})(); diff --git a/test/rtcomm-alert-modal.spec.js b/test/rtcomm-alert-modal.spec.js new file mode 100644 index 0000000..7301ff5 --- /dev/null +++ b/test/rtcomm-alert-modal.spec.js @@ -0,0 +1,37 @@ +describe('Controller Testing: Rtcomm Alert Modal', function(){ + var $compile, $rootScope, $modal; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + + beforeEach(function(){ + + }); + beforeEach(inject( + ['$compile', '$rootScope','$injector', function($c, $r, $i){ + $compile = $c; + $rootScope = $r; + $modal = $i.get('$modal'); + }] + )); + + it('chat directive should be available', function(){ + //Add the controller to the body + var element = $compile('
')($rootScope); + $rootScope.$digest(); + + var modalSpy = sinon.spy($modal, 'open'); + + //Emit an rtcomm-alerting event + $rootScope.$broadcast('session:alerting', { + endpoint: { + id: 'testid', + getRemoteEndpointID: function(){ + return 'temp2' + } + } + }); + + expect(modalSpy.calledOnce).to.be.true; + }); +}) diff --git a/test/rtcomm-alert.spec.js b/test/rtcomm-alert.spec.js new file mode 100644 index 0000000..50b45d3 --- /dev/null +++ b/test/rtcomm-alert.spec.js @@ -0,0 +1,18 @@ +describe('Unit Testing: RtcommChat directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + expect(element.html()).to.include('alert in alerts'); + }); +}) diff --git a/test/rtcomm-chat.spec.js b/test/rtcomm-chat.spec.js new file mode 100644 index 0000000..d40dda6 --- /dev/null +++ b/test/rtcomm-chat.spec.js @@ -0,0 +1,18 @@ +describe('Unit Testing: RtcommChat directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + expect(element.html()).to.include('class="chat"'); + }); +}) diff --git a/test/rtcomm-config.spec.js b/test/rtcomm-config.spec.js new file mode 100644 index 0000000..68c4faa --- /dev/null +++ b/test/rtcomm-config.spec.js @@ -0,0 +1,13 @@ +// describe('Unit Testing: Rtcomm Config Service', function() { +// +// var RtcommConfigService; +// +// beforeEach(function(){ +// +// }); +// +// afterEach(function(){ +// +// }); +// RtcommConfigService +// }); diff --git a/test/rtcomm-endpoint-status.spec.js b/test/rtcomm-endpoint-status.spec.js new file mode 100644 index 0000000..68ae9a0 --- /dev/null +++ b/test/rtcomm-endpoint-status.spec.js @@ -0,0 +1,18 @@ +describe('Unit Testing: RtcommChat directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + expect(element.html()).to.include('class="endpoint-status"'); + }); +}) diff --git a/test/rtcomm-iframe.spec.js b/test/rtcomm-iframe.spec.js new file mode 100644 index 0000000..b1b8754 --- /dev/null +++ b/test/rtcomm-iframe.spec.js @@ -0,0 +1,18 @@ +describe('Unit Testing: RtcommChat directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + expect(element.html()).to.include('class="rtcomm-iframe"'); + }); +}) diff --git a/test/rtcomm-presence.directive.spec.js b/test/rtcomm-presence.directive.spec.js new file mode 100644 index 0000000..6f0b114 --- /dev/null +++ b/test/rtcomm-presence.directive.spec.js @@ -0,0 +1 @@ +// describe('Testing ') diff --git a/test/rtcomm-queues.spec.js b/test/rtcomm-queues.spec.js new file mode 100644 index 0000000..c2363d0 --- /dev/null +++ b/test/rtcomm-queues.spec.js @@ -0,0 +1,18 @@ +describe('Unit Testing: RtcommChat directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + expect(element.html()).to.include('class="queueContainer"'); + }); +}) diff --git a/test/rtcomm-register.directive.spec.js b/test/rtcomm-register.directive.spec.js new file mode 100644 index 0000000..7f7af83 --- /dev/null +++ b/test/rtcomm-register.directive.spec.js @@ -0,0 +1,18 @@ +describe('Unit Testing: Register directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + expect(element.html()).to.include('id="register-input"'); + }); +}) diff --git a/test/rtcomm-service.spec.js b/test/rtcomm-service.spec.js new file mode 100644 index 0000000..430ca47 --- /dev/null +++ b/test/rtcomm-service.spec.js @@ -0,0 +1,27 @@ +describe('Unit Testing: Rtcomm Service', function() { + + var RtcommService; //RtcommService + var sandbox; //Spying and stubbing sandbox + + beforeEach(function() { + module('angular-rtcomm'); + }); + + beforeEach(inject(function($injector) { + RtcommService = $injector.get('RtcommService'); + })); + + it('API & Functions are defined', function() { + expect(RtcommService).to.be.defined; + expect(alert).to.be.defined; + }); + + describe('API & Functions are defined', function() { + beforeEach(function() { + //$rootScope', '$log', '$http', 'RtcommConfigService' + + }); + + }); + +}); diff --git a/test/rtcomm-session-manager.spec.js b/test/rtcomm-session-manager.spec.js new file mode 100644 index 0000000..9c6f13a --- /dev/null +++ b/test/rtcomm-session-manager.spec.js @@ -0,0 +1,19 @@ +describe('Unit Testing: RtcommSessionManager directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + console.log(element[0]); + expect(element.html()).to.include('class="session-manager"'); + }); +}) diff --git a/test/rtcomm-video.spec.js b/test/rtcomm-video.spec.js new file mode 100644 index 0000000..10ebee3 --- /dev/null +++ b/test/rtcomm-video.spec.js @@ -0,0 +1,18 @@ +describe('Unit Testing: RtcommChat directive', function(){ + var $compile, $rootScope; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm')); + beforeEach(inject( + ['$compile', '$rootScope', function($c, $r){ + $compile = $c; + $rootScope = $r; + }] + )); + + it('chat directive should be available', function(){ + var element = $compile('')($rootScope); + $rootScope.$digest(); + expect(element.html()).to.include('id="videoContainer"'); + }); +}) diff --git a/test/testRtcommServiceSpec.js b/test/testRtcommServiceSpec.js index e806194..3851a2d 100644 --- a/test/testRtcommServiceSpec.js +++ b/test/testRtcommServiceSpec.js @@ -8,31 +8,31 @@ describe('Unit testing angular-rtcomm service', function() { //var rtcommTopicPath = "/rtcomm-karma-test-" + Math.floor((Math.random() * 1000000) + 1) + "/"; var testUserID = "TestID " + Math.floor((Math.random() * 1000000) + 1); - + beforeEach(module('angular-rtcomm')); - + beforeEach(module('angular-rtcomm', function($provide) { // Output messages $provide.value('$log', console); - })); - - beforeEach(inject(function (_RtcommService_,_$rootScope_,_$log_) { + })); + + beforeEach(inject(function (_RtcommService_,_$rootScope_,_$log_) { RtcommService = _RtcommService_; $rootScope = _$rootScope_; $log = _$log_; - + // Required to get evalAsync to fire so that broadcasted messages are received by test code. RtcommService.setKarmaTesting(); } )); - - describe('initialization - no user ID', function () { - - // Before init'ing, + + describe('initialization - no user ID', function () { + + // Before init'ing, it('check state before init', function () { - expect(RtcommService.isInitialized()).toEqual(false); + expect(RtcommService.isInitialized()).toEqual(false); }); - + // When init'ing with no user ID, rtcomm.js should not be init'd it('initialize with no user ID', function () { var config = { @@ -44,26 +44,26 @@ describe('Unit testing angular-rtcomm service', function() { "broadcastVideo" : true, "presenceTopic" : "karmaPresence" }; - + RtcommService.setConfig(config); - - expect(RtcommService.isInitialized()).toEqual(false); + + expect(RtcommService.isInitialized()).toEqual(false); }); - }); - - describe('Run test after initialization with user ID', function () { + }); + + describe('Run test after initialization with user ID', function () { var presenceData = null; // When init'ing with user ID, rtcomm.js should be init'd it('initialize with user ID', function (done) { $log.debug('Karma: initialize with user ID: top: $rootScope: ',$rootScope); - + // spyOn($rootScope, '$broadcast').and.callThrough(); - + $rootScope.$on('rtcomm::init', function (event, success, details) { $log.debug('Karma: initialize with user ID: rtcomm::init received'); - expect(RtcommService.isInitialized()).toEqual(true); + expect(RtcommService.isInitialized()).toEqual(true); done(); }); @@ -76,21 +76,21 @@ describe('Unit testing angular-rtcomm service', function() { "broadcastVideo" : true, "presenceTopic" : "karmaPresence" }; - + RtcommService.setConfig(config); - }); - + }); + // Here we publish presence and wait for the result to come in through a notification. it('test pubishing presence', function (done) { - + $rootScope.$on('rtcomm::init', function (event, success, details) { $log.debug('Karma: test pubishing presence: rtcomm::init received'); var presenceMonitor = RtcommService.getPresenceMonitor(); - + presenceMonitor.on('updated', function(){ presenceData = presenceMonitor.getPresenceData(); - + $log.debug('Karma: test pubishing presence: presenceData: ',presenceData); assert.isArray(presenceData); @@ -106,7 +106,7 @@ describe('Unit testing angular-rtcomm service', function() { assert.deepPropertyVal(presenceData[0].nodes[0], "name", "testUserID"); done(); }); - + presenceMonitor.add("karmaPresence"); RtcommService.publishPresence(); }); @@ -120,8 +120,8 @@ describe('Unit testing angular-rtcomm service', function() { "broadcastVideo" : true, "presenceTopic" : "karmaPresence" }; - - RtcommService.setConfig(config); + + RtcommService.setConfig(config); }); - }); -}); \ No newline at end of file + }); +}); From 60f859bf9745f09371e80a4e6874f2e1986b319f Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Fri, 4 Mar 2016 15:22:18 -0500 Subject: [PATCH 02/21] Saving working state of directives --- Gruntfile.js | 16 +- bower.json | 6 + dist/angular-rtcomm.js | 2487 ++++++++++------- dist/angular-rtcomm.min.js | 6 +- src/js/angular-rtcomm.js | 16 +- src/js/rtcomm-presence.js | 17 +- src/js/rtcomm-services.js | 27 +- src/js/services/rtcomm.service.js | 45 - src/js/services/services.module.js | 7 - src/js/ui/config.controller.js | 19 +- .../rtcomm-alert.directive.js | 18 +- .../rtcomm-chat.directive.js | 107 - .../rtcomm-queues.directive.js | 18 +- .../rtcomm-register.directive.js | 50 +- .../rtcomm-session-manager.directive.js | 18 +- src/js/ui/endpoint.controller.js | 15 + src/js/ui/endpoint/rtcomm-chat.directive.js | 123 + src/js/ui/endpoint/rtcomm-endpoint-status.js | 18 +- src/js/ui/endpoint/rtcomm-iframe.directive.js | 17 +- src/js/ui/endpoint/rtcomm-video.directive.js | 25 +- src/js/ui/modals/alert-modal.js | 16 + src/js/ui/modals/call-modal.js | 16 + src/js/ui/ui.module.js | 15 + src/templates/rtcomm/rtcomm-chat.html | 10 +- .../rtcomm/rtcomm-endpoint-status.html | 16 +- src/templates/rtcomm/rtcomm-register.html | 4 +- src/templates/rtcomm/rtcomm-video.html | 4 +- test/rtcomm-register.directive.spec.js | 6 +- 28 files changed, 1873 insertions(+), 1269 deletions(-) delete mode 100644 src/js/services/rtcomm.service.js delete mode 100644 src/js/ui/endpoint-provider/rtcomm-chat.directive.js create mode 100644 src/js/ui/endpoint/rtcomm-chat.directive.js diff --git a/Gruntfile.js b/Gruntfile.js index 163e0ed..a74c8dd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,7 +5,7 @@ module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - + meta: { banner: '/**\n' + ' * Copyright 2014 IBM Corp.\n' + @@ -28,23 +28,23 @@ module.exports = function(grunt) { ' * @author <%= pkg.author %>\n' + ' */\n' }, - + dirs: { src: 'src', dest: 'dist' }, - + concat: { options: { banner: '<%= meta.banner %>' }, dist: { // src: ['<%= dirs.src %>/*.js', '<%= dirs.src %>/**/*.js'], - src: ['<%= dirs.src %>/js/angular-rtcomm.js', '<%= dirs.src %>/js/rtcomm-services.js', '<%= dirs.src %>/js/rtcomm-directives.js', '<%= dirs.src %>/js/rtcomm-presence.js'], + src: ['<%= dirs.src %>/js/**/*.module.js', '<%= dirs.src %>/js/**/*.js'], dest: '<%= dirs.dest %>/<%= pkg.name %>.js' } }, - + copy: { main: { expand: true, @@ -65,7 +65,7 @@ module.exports = function(grunt) { }] } }, - + ngAnnotate: { dist: { files: { @@ -107,14 +107,14 @@ module.exports = function(grunt) { } } }, - + watch: { dev: { files: ['<%= dirs.src %>/**'], tasks: ['build'] }, }, - + ngtemplates: { 'angular-rtcomm-ui': { cwd: '<%= dirs.src %>', diff --git a/bower.json b/bower.json index 66f28ec..61140e1 100644 --- a/bower.json +++ b/bower.json @@ -36,5 +36,11 @@ "angular": "^1.4.6", "angular-bootstrap": "~0.13.0", "rtcomm": "^1.0.0" + }, + "devDependencies": { + "angular-mocks": "~1.5.0" + }, + "resolutions": { + "angular": "1.5.0" } } diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 4a85458..d000e05 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,12 +14,63 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-02-18 + * @version v1.0.3 - 2016-03-04 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ + +// (function() { +// 'use strict'; +// +// angular +// .module('angular-rtcomm-ui', [ +// 'ui.bootstrap', +// 'angular-rtcomm-service' +// ]); +// })(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* - * This is the main angular-rtcomm module. + * The angular-rtcomm-ui module + * This has controllers and directives in it. + */ +(function(){ + +angular + .module('angular-rtcomm-ui', [ + 'ui.bootstrap', + 'angular-rtcomm-service']); + +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ (function() { angular.module('angular-rtcomm', [ @@ -31,6 +82,153 @@ ]); })(); +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * The angular-rtcomm-presence module + * This has controllers and directives in it. + */ +(function(){ + angular + .module('angular-rtcomm-presence', [ + 'ui.bootstrap', + 'treeControl', + 'angular-rtcomm-service']) + .directive('rtcommPresence', rtcommPresence); + + /** + * This directive manages the chat portion of a session. The data model for chat + * is maintained in the RtcommService. This directive handles switching between + * active endpoints. + * + * Here is the formate of the presenceData: + * + * This is a Node: + * { + * "name" : "agents", + * "record" : false, + * "nodes" : [] + * } + * + * This is a record with a set of user defines: + * { + * "name" : "Brian Pulito", + * "record" : true, + * "nodes" : [ + * { + * "name" : "queue", + * "value" : "appliances" + * }, + * { + * "name" : "sessions", + * "value" : "3" + * } + * ] + */ + rtcommPresence.$inject=['RtcommService', '$log']; + function rtcommPresence(RtcommService, $log) { + return { + restrict: 'E', + templateUrl: "templates/rtcomm/rtcomm-presence.html", + controller: ["$scope", "$rootScope", function ($scope, $rootScope) { + + $scope.monitorTopics = []; + $scope.presenceData = []; + $scope.expandedNodes = []; + + // Default protocol list initiated from presence. Start with chat only. + $scope.protocolList = { + chat : true, + webrtc : false}; + + // use a tree view or flatten. + $scope.flatten = false; + $scope.treeOptions = { + nodeChildren: "nodes", + dirSelectable: true, + injectClasses: { + ul: "a1", + li: "a2", + liSelected: "a7", + iExpanded: "a3", + iCollapsed: "a4", + iLeaf: "a5", + label: "a6", + labelSelected: "a8" + } + }; + + $scope.init = function(options) { + $scope.protocolList.chat = (typeof options.chat === 'boolean') ? options.chat : $scope.protocolList.chat; + $scope.protocolList.webrtc = (typeof options.webrtc === 'boolean') ? options.webrtc : $scope.protocolList.webrtc; + $scope.flatten = (typeof options.flatten === 'boolean') ? options.flatten: $scope.flatten; + }; + + $scope.onCallClick = function(calleeEndpointID){ + var endpoint = RtcommService.getEndpoint(); + RtcommService.setActiveEndpoint(endpoint.id); + + if ($scope.protocolList.chat == true) + endpoint.chat.enable(); + + if ($scope.protocolList.webrtc == true){ + endpoint.webrtc.enable(function(value, message) { + if (!value) { + RtcommService.alert({type: 'danger', msg: message}); + } + }); + } + + endpoint.connect(calleeEndpointID); + $rootScope.$broadcast('rtcomm::presence-click'); + }; + + $scope.$on('rtcomm::init', function (event, success, details) { + RtcommService.publishPresence(); + var presenceMonitor = RtcommService.getPresenceMonitor(); + + presenceMonitor.on('updated', function(presenceData){ + $log.debug('<<------rtcommPresence: updated------>>'); + if ($scope.flatten) { + $log.debug('<<------rtcommPresence: updated using flattened data ------>>'); + $scope.presenceData = presenceData[0].flatten(); + } + $scope.$apply(); + }); + + // Binding data if we are going to flatten causes a flash in the UI when it changes. + if (!$scope.flatten) { + $scope.presenceData = presenceMonitor.getPresenceData(); + } + + if ($scope.presenceData.length >= 1) + $scope.expandedNodes.push($scope.presenceData[0]); + + for (var index = 0; index < $scope.monitorTopics.length; index++) { + $log.debug('rtcommPresence: monitorTopic: ' + $scope.monitorTopics[index]); + presenceMonitor.add($scope.monitorTopics[index]); + } + }); + + }], + controllerAs: 'presence' + }; + }; +})(); + /** * Definition for the rtcommModule */ @@ -94,7 +292,6 @@ var rtcommDebug = "DEBUG"; var ringtone = null; var ringbacktone = null; - var trickleICE = true; var setConfig = function(config){ providerConfig.server = (typeof config.server !== "undefined")? config.server : providerConfig.server; @@ -112,7 +309,6 @@ broadcastAudio = (typeof config.broadcastAudio !== "undefined")? config.broadcastAudio: broadcastAudio; broadcastVideo = (typeof config.broadcastVideo !== "undefined")? config.broadcastVideo: broadcastVideo; - trickleICE = (typeof config.trickleICE !== "undefined")? config.trickleICE: trickleICE; ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: ringbacktone; ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : ringtone; @@ -147,9 +343,7 @@ getRtcommDebug: function(){return rtcommDebug;}, - isRtcommDisabled : function(){return _disableRtcomm;}, - - getTrickleICE: function(){return trickleICE;} + isRtcommDisabled : function(){return _disableRtcomm;} }; }; @@ -187,8 +381,7 @@ broadcast : { audio : RtcommConfigService.getBroadcastAudio(), video : RtcommConfigService.getBroadcastVideo() - }, - trickleICE: RtcommConfigService.getTrickleICE() + } }, webrtc : RtcommConfigService.getWebRTCEnabled(), chat : RtcommConfigService.getChatEnabled(), @@ -198,8 +391,7 @@ }; myEndpointProvider.on('reset', function(event_object) { - //The Endpoint provider is destroyed on reset - endpointProviderInitialized = false; + // Should have a reason. _alert({type:'danger', msg: event_object.reason}); }); @@ -312,8 +504,6 @@ }, - 'session:connecting' : callback, - // These are all the WebRTC related events. 'webrtc:connected' : function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); @@ -477,9 +667,7 @@ for (var index = 0; index < sessions.length; index++) { if(sessions[index].endpointUUID === endpointUUID){ - var endpoint = _getEndpoint(endpointUUID); - if(typeof endpoint !== 'undefined') - endpoint.destroy(); + _getEndpoint(endpointUUID).destroy(); // Remove the disconnected endpoint from the list. sessions.splice(index, 1); @@ -901,1079 +1089,1330 @@ })(); -/* - * The angular-rtcomm-ui module - * This has controllers and directives in it. +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -(function(){ - -angular - .module('angular-rtcomm-ui', [ - 'ui.bootstrap', - 'angular-rtcomm-service']) - .directive('rtcommSessionManager', rtcommSessionManager) - .directive('rtcommRegister', rtcommRegister) - .directive('rtcommQueues', rtcommQueues) - .directive('rtcommAlert', rtcommAlert) - .directive('rtcommEndpointStatus', rtcommEndpointStatus) - .directive('rtcommVideo', rtcommVideo) - .directive('rtcommChat', rtcommChat) - .directive('rtcommIframe', rtcommIframe) - .controller('RtcommAlertModalController', RtcommAlertModalController) - .controller('RtcommAlertModalInstanceController', RtcommAlertModalInstanceController) - .controller('RtcommCallModalController', RtcommCallModalController) - .controller('RtcommCallModalInstanceController', RtcommCallModalInstanceController) - .controller('RtcommConfigController', RtcommConfigController) - .controller('RtcommVideoController', RtcommVideoController) - .controller('RtcommEndpointController', RtcommEndpointController); - -/************* Endpoint Provider Directives *******************************/ /** - * This directive is used to manage multiple sessions. If you are only supporting at most one session you wont need - * this directive. The associated template provides a way to switch between active sessions. The session must be in - * the started state to be managed by this directive and is removed when the session stops. + * This is the controller for config loader. It reads a JSON object and utilizes the RtcommService to set the configuration. + * This can also result in the initialization of the endpoint provider if the config JSON object includes a registration name. + * + * Here is an example of the config object: + * + * { + * "server" : "server address", + * "port" : 1883, + * "rtcommTopicPath" : "/rtcomm-helpdesk/", + * "createEndpoint" : false, + * "userid" : "registration name", + * "broadcastAudio" : true, + * "broadcastVideo" : true + * } + * + * NOTE: If the user does not specify a userid, that says one will never be specified so go ahead + * and initialize the endpoint provider and let the provider assign a name. If a defined empty + * string is passed in, that means to wait until the end user registers a name before initializing + * the endpoint provider. */ -rtcommSessionManager.$inject=['RtcommService', '$log']; -function rtcommSessionManager (RtcommService, $log) { - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-sessionmgr.html', - controller: ["$scope", function ($scope) { - $scope.sessions = RtcommService.getSessions(); - $scope.sessMgrActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.publishPresence = false; - $scope.sessionPresenceData = []; - - $scope.init = function(publishPresence) { - $scope.publishPresence = publishPresence; - $scope.updatePresence(); - }; - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $log.debug('rtcommSessionmgr: endpointActivated =' + endpointUUID); - $scope.sessMgrActiveEndpointUUID = endpointUUID; - }); - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('rtcommSessionmgr: session:started: uuid =' + eventObject.endpoint.id); +(function() { + 'use strict'; - $scope.updatePresence(); - }); + angular + .module('angular-rtcomm-ui') + .controller('RtcommConfigController', RtcommConfigController); - $scope.activateSession = function(endpointUUID) { - $log.debug('rtcommSessionmgr: activateEndpoint =' + endpointUUID); - if ($scope.sessMgrActiveEndpointUUID != endpointUUID){ - RtcommService.setActiveEndpoint(endpointUUID); - } - }; + RtcommConfigController.$inject = ['RtcommService', '$http', '$scope', '$log']; - $scope.updatePresence = function(){ - // Update the presence record if enabled - if ($scope.publishPresence == true){ - RtcommService.removeFromPresenceRecord ($scope.sessionPresenceData, false); + /* @ngInject */ + function RtcommConfigController(RtcommService, $http, $scope, $log) { + var vm = this; + vm.extendedConfig = null; - $scope.sessionPresenceData = [{ - 'name' : "sessions", - 'value' : String($scope.sessions.length)}]; + $log.debug('RtcommConfigController: configURL = ' + vm.configURL); - RtcommService.addToPresenceRecord ($scope.sessionPresenceData); - } - }; + vm.setConfig = function(data) { + $log.debug('RtcommConfigController: setting config data:' + data); + RtcommService.setConfig(data); + }; - }], - controllerAs: 'sessionmgr' - }; -}; + $scope.init = function(configURL, extendedConfig) { + $log.debug('RtcommConfigController: initing configURL = ' + configURL); + vm.configURL = configURL; -/** - * This directive is used to manage the registration of an endpoint provider. Since the registered name can only - * be set on initialization of the endpoint provider, this directive actually controls the initialization of the - * provider. Note that the endpoint provider must be initialized before any sessions can be created or received. - */ -rtcommRegister.$inject=['RtcommService', '$log']; -function rtcommRegister(RtcommService, $log) { - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-register.html', - controller: ["$scope", function ($scope) { + if (typeof extendedConfig !== "undefined") + vm.extendedConfig = extendedConfig; - $scope.nextAction = 'Register'; + vm.getConfig(); + }; - $scope.reguserid = ''; + vm.getConfig = function() { + $http.get(vm.configURL).success(function(config) { - $scope.invalid = false; + // Now we need to update the config with any extensions passed in on init. + if (vm.extendedConfig != null) { + angular.extend(config, vm.extendedConfig); + $log.debug('RtcommConfigController: extended config object: ' + config); + } - var invalidCharacters = /(\$|#|\+|\/|\\)+/i; //Invalid characters for MQTT Topic Path + RtcommService.setConfig(config); + }).error(function(data, status, headers, config) { + $log.debug('RtcommConfigController: error accessing config: ' + status); + }); + }; + activate(); - //Watch for changes in reguserid - $scope.$watch('reguserid', function(){ + function activate() { - if($scope.reguserid.length < 1 || invalidCharacters.test($scope.reguserid)){ + } + } +})(); - $scope.invalid = true; - } - else{ - $scope.invalid = false; - } - }); +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommAlert', rtcommAlert); + + /* @ngInject */ + function rtcommAlert() { + var directive = { + restrict: 'E', + templateUrl: "templates/rtcomm/rtcomm-alert.html", + controller: AlertController, + controllerAs: 'alertVM', + bindToController: true + }; + + return directive; + } + + AlertController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function AlertController(RtcommService, $scope, $log) { + var vm = this; + vm.alerts = []; + vm.addAlert = function(alert) { + vm.alerts.push(alert); + }; + vm.closeAlert = function(index) { + vm.alerts.splice(index, 1); + }; + $scope.$on('rtcomm::alert', function(event, eventObject) { + vm.addAlert(eventObject); + }); + activate(); + + function activate() { + + } + } +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This directive manages call queues. It provides the ability to display all the available queues + * (along with their descriptions) and by clicking on a queue, allows an agent (or any type of user) + * to subscribe on that queue. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommQueues', rtcommQueues); + + /* @ngInject */ + function rtcommQueues() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-queues.html', + controller: QueuesController, + controllerAs: 'queueVM', + bindToController: true + }; + + return directive; + + function linkFunc(scope, el, attr, ctrl) { + + } + } + + QueuesController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function QueuesController(RtcommService, $scope, $log) { + var vm = this; + + vm.rQueues = []; + vm.autoJoinQueues = false; + vm.queuePresenceData = []; + vm.queuePublishPresence = false; + vm.queueFilter = null; + + /** + * autoJoinQueues - automatically join any queues that are not filtered out + * queuePublishedPresence - will add to the presence document information about what queues this person joins. + * queueFilter - If defined, this specifies which queues should be joined. All others will be ignored. + */ + vm.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { + $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); + vm.autoJoinQueues = autoJoinQueues; + vm.queuePublishPresence = queuePublishPresence; + + if (typeof queueFilter !== "undefined") + vm.queueFilter = queueFilter; + }; + + // + vm.filterOutQueue = function(queue) { + var returnValue = true; + + if (vm.queueFilter != null) { + + for (var index = 0; index < vm.queueFilter.length; ++index) { + var entry = vm.queueFilter[index]; + if (entry == queue.endpointID) { + returnValue = false; + break; + } + } + } else + returnValue = false; + + return (returnValue); + }; + + vm.onQueueClick = function(queue) { + $log.debug('rtcommQueues: onClick: TOP'); + for (var index = 0; index < vm.rQueues.length; index++) { + if (vm.rQueues[index].endpointID === queue.endpointID) { + $log.debug('rtcommQueues: onClick: queue.endpointID = ' + queue.endpointID); + + if (queue.active == false) { + RtcommService.joinQueue(queue.endpointID); + vm.rQueues[index].active = true; + } else { + RtcommService.leaveQueue(queue.endpointID); + vm.rQueues[index].active = false; + } + } else if (index == (vm.rQueues.length - 1)) { + $log.debug('rtcommQueues: ERROR: queue.endpointID: ' + queue.endpointID + ' not found in list of queues'); + + } + } + + vm.updateQueuePresence(); + }; + + vm.updateQueuePresence = function() { + // Update the presence record if enabled + if (vm.queuePublishPresence == true) { + RtcommService.removeFromPresenceRecord(vm.queuePresenceData, false); + + vm.queuePresenceData = []; + + for (var index = 0; index < vm.rQueues.length; index++) { + if (vm.rQueues[index].active === true) { + vm.queuePresenceData.push({ + 'name': "queue", + 'value': $scope.rQueues[index].endpointID + }); + } + } + + RtcommService.addToPresenceRecord(vm.queuePresenceData); + } + } + + $scope.$on('queueupdate', function(event, queues) { + $log.debug('rtcommQueues: scope queues', vm.rQueues); + + Object.keys(queues).forEach(function(key) { + $log.debug('rtcommQueues: Push queue: ' + queues[key]); + $log.debug('rtcommQueues: autoJoinQueues: ' + vm.autoJoinQueues); + + // Check to make sure queue is not filteres out before adding it. + if (vm.filterOutQueue(queues[key]) == false) { + vm.rQueues.push(queues[key]); + + // If autoJoin we go ahead and join the queue as soon as we get the queue update. + if (vm.autoJoinQueues == true) { + vm.onQueueClick(queues[key]); + } + } + }); + + vm.updateQueuePresence(); + }); + + $scope.$on('rtcomm::init', function(event, success, details) { + if (success == false) { + $log.debug('rtcommQueues: init: clear queues'); + vm.rQueues = []; + } + }); + + + activate(); + + function activate() { + + } + } +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This directive is used to manage the registration of an endpoint provider. Since the registered name can only + * be set on initialization of the endpoint provider, this directive actually controls the initialization of the + * provider. Note that the endpoint provider must be initialized before any sessions can be created or received. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommRegister', rtcommRegister); + + /* @ngInject */ + function rtcommRegister() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-register.html', + controller: RegisterController, + controllerAs: 'registerVM', + bindToController: true + }; + + return directive; + + } + + RegisterController.$inject = ['RtcommService', '$scope', '$log']; + + // /* @ngInject */ + function RegisterController(RtcommService, $scope, $log) { + var vm = this; + + vm.nextAction = 'Register'; + vm.reguserid = ''; + vm.invalid = false; + + var invalidCharacters = /(\$|#|\+|\/|\\)+/i; //Invalid characters for MQTT Topic Path + + vm.onRegClick = function() { + if (vm.nextAction === 'Register' && !invalidCharacters.test(vm.reguserid)) { + + $log.debug('Register: reguserid =' + vm.reguserid); + RtcommService.register(vm.reguserid); + } else { + $log.debug('Unregister: reguserid =' + vm.reguserid); + RtcommService.unregister(); + } + }; + + //Watch for changes in reguserid + $scope.$watch('registerVM.reguserid', function() { + + if (vm.reguserid.length < 1 || invalidCharacters.test(vm.reguserid)) { + + vm.invalid = true; + } else { + vm.invalid = false; + } + }); + + $scope.$on('rtcomm::init', function(event, success, details) { + + if (success == true) { + vm.nextAction = 'Unregister'; + vm.reguserid = details.userid; + } else { + vm.nextAction = 'Register'; + + if (details == 'destroyed') + vm.reguserid = ''; + else + vm.reguserid = 'Init failed:' + details; + } + }); + } +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This directive is used to manage multiple sessions. If you are only supporting at most one session you wont need + * this directive. The associated template provides a way to switch between active sessions. The session must be in + * the started state to be managed by this directive and is removed when the session stops. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommSessionManager', rtcommSessionManager); + + /* @ngInject */ + function rtcommSessionManager() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-sessionmgr.html', + controller: SessionManagerController, + controllerAs: 'sessionVM', + bindToController: true + }; + + return directive; + + function linkFunc(scope, el, attr, ctrl) { + + } + } + + SessionManagerController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function SessionManagerController(RtcommService, $scope, $log) { + var vm = this; + vm.sessions = RtcommService.getSessions(); + vm.sessMgrActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.publishPresence = false; + vm.sessionPresenceData = []; + + vm.init = function(publishPresence) { + vm.publishPresence = publishPresence; + vm.updatePresence(); + }; + + vm.activateSession = function(endpointUUID) { + $log.debug('rtcommSessionmgr: activateEndpoint =' + endpointUUID); + if (vm.sessMgrActiveEndpointUUID != endpointUUID) { + RtcommService.setActiveEndpoint(endpointUUID); + } + }; + + vm.updatePresence = function() { + // Update the presence record if enabled + if (vm.publishPresence == true) { + RtcommService.removeFromPresenceRecord(vm.sessionPresenceData, false); + + vm.sessionPresenceData = [{ + 'name': "sessions", + 'value': String(vm.sessions.length) + }]; + + RtcommService.addToPresenceRecord(vm.sessionPresenceData); + } + } + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommSessionmgr: endpointActivated =' + endpointUUID); + vm.sessMgrActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('rtcommSessionmgr: session:started: uuid =' + eventObject.endpoint.id); + + vm.updatePresence(); + }); + activate(); + + function activate() { + + } + } +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .controller('RtcommEndpointController', RtcommEndpointController); + + RtcommEndpointController.$inject = ['RtcommService', '$http', '$rootScope', '$scope', '$log']; + + /* @ngInject */ + function RtcommEndpointController(RtcommService, $http, $rootScope, $scope, $log) { + var vm = this; + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + + vm.disconnect = function() { + $log.debug('Disconnecting call for endpoint: ' + vm.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).disconnect(); + }; + + vm.toggleAV = function() { + $log.debug('Enable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); + + if (vm.epCtrlAVConnected == false) { + RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { + if (!value) { + $log.debug('Enable failed: ', message); + RtcommService.alert({ + type: 'danger', + msg: message + }); + } + }); + } else { + $log.debug('Disable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.disable(); + } + }; + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:started'; + } + }); + + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:stopped'; + } + }); + + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:failed'; + } + }); + + $scope.$on('webrtc:connected', function(event, eventObject) { + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + vm.epCtrlAVConnected = true; + }); + + $scope.$on('webrtc:disconnected', function(event, eventObject) { + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + vm.epCtrlAVConnected = false; + }); + + + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.epCtrlActiveEndpointUUID = endpointUUID; + vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.epCtrlAVConnected = false; + }); + activate(); + + function activate() { + + } + } +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This directive manages the chat portion of a session. The data model for chat + * is maintained in the RtcommService. This directive handles switching between + * active endpoints. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommChat', rtcommChat); + + rtcommChat.$inject = ['RtcommService', '$log']; + + /* @ngInject */ + function rtcommChat(RtcommService, $log) { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-chat.html', + link: chatLink, + controller: ChatController, + controllerAs: 'chatVM', + bindToController: true + }; + + return directive; + + function chatLink(scope, element, attr, ctrl) { + var chatPanel = angular.element(element.find('.panel-body')[0]); + + var bottom = true; + + //Chooses if the scrollbar should be forced to the bottom on the next lifecycle + ctrl.scrollToBottom = function(flag) { + bottom = flag; + scope.bottom = flag; + + } + + //Watch scroll events + chatPanel.bind('scroll', function() { + if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { + ctrl.scrollToBottom(true); + } else { + ctrl.scrollToBottom(false); + } + }); + + //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down + scope.$watch(function() { + return ctrl.chats + }, function() { + $log.debug('rtcommChat - Link > $watch on chats called'); + if (bottom) { + chatPanel.scrollTop(chatPanel.prop('scrollHeight')); + } else { + //In this else, a notification could be sent + } + }, true); + + } + + } + + //Controller should be used to listen for events from Rtcmo + ChatController.$inject = ['$scope', 'RtcommService', '$log']; + + /* @ngInject */ + function ChatController($scope, RtcommService, $log) { + var vm = this; + + vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); + + vm.keySendMessage = function(keyEvent) { + if (keyEvent.which === 13) + vm.sendMessage(); + }; + + vm.sendMessage = function() { + $log.debug('rtcommChat: sendMessage() -> ' + vm.message); + var chat = { + time: new Date(), + name: RtcommService.getEndpoint(vm.chatActiveEndpointUUID).getLocalEndpointID(), + message: angular.copy(vm.message) + }; + + vm.message = ''; + vm.scrollToBottom(true); + $scope.bottom = true; + RtcommService.sendChatMessage(chat, vm.chatActiveEndpointUUID); + } + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommChat: endpointActivated =' + endpointUUID); + + // The data model for the chat is maintained in the RtcommService. + vm.chats = RtcommService.getChats(endpointUUID); + vm.chatActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.chats = []; + vm.chatActiveEndpointUUID = null; + }); + } +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This endpoint status controller only shows the active endpoint. The $scope.sessionState always contains the + * state of the active endpoint if one exist. It will be one of the following states: + * + * 'session:alerting' + * 'session:trying' + * 'session:ringing' + * 'session:queued' - for this one $scope.queueCount will tell you where you are in the queue. + * 'session:failed' - for this one $scope.reason will tell you why the call failed. + * 'session:started' + * 'session:stopped' + * + * You can bind to $scope.sessionState to track state in the view. + */ + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommEndpointStatus', rtcommEndpointStatus); + + /* @ngInject */ + function rtcommEndpointStatus() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', + controller: EndpointStatusController, + controllerAs: 'endpointStatusVM', + bindToController: true + }; + + return directive; + + function linkFunc(scope, el, attr, ctrl) { + + } + } + + EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function EndpointStatusController(RtcommService, $scope, $log) { + var vm = this; + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + vm.failureReason = ''; + vm.queueCount = 0; // FIX: Currently not implemented! + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:started'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); + + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:failed'; + vm.failureReason = eventObject.reason; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:alerting', function(event, eventObject) { + $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID != eventObject.endpoint.id) { + vm.sessionState = 'session:alerting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:connecting', function(event, eventObject) { + $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); + // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ + vm.sessionState = 'session:connecting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + // } + }); + + + $scope.$on('session:queued', function(event, eventObject) { + $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:queued'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:trying', function(event, eventObject) { + $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:trying'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:ringing', function(event, eventObject) { + $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:ringing'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.epCtrlActiveEndpointUUID = endpointUUID; + vm.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); + vm.sessionState = RtcommService.getSessionState(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.epCtrlRemoteEndpointID = null; + vm.sessionState = 'session:stopped'; + }); + + $scope.$on('rtcomm::init', function(event, success, details) { + if (success === true) { + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + vm.failureReason = ''; + } + if (success == false) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); + + + + } + activate(); + + function activate() { + + } + +})(); + +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommIframe', rtcommIframe); + + /* @ngInject */ + function rtcommIframe() { + var directive = { + restrict: 'E', + templateUrl: "templates/rtcomm/rtcomm-iframe.html", + controller: IFrameController, + controllerAs: 'iframeVM', + bindToController: true + }; + + return directive; + } + + IFrameController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function IFrameController(RtcommService, $scope, $log) { + var vm = this; + vm.iframeActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.iframeURL = null; + vm.initiframeURL = null; + vm.syncSource = false; + + /* + * syncSourcing means you a providing the URL source but no UI. Typically used in + * customer/agent scenarios. + */ + vm.init = function(syncSource) { + if (syncSource == true) { + vm.syncSource = true; + vm.initiframeURL = $location.absUrl(); // init to current URL + } + }; + + + vm.setURL = function(newURL) { + $log.debug('rtcommIframe: setURL: newURL: ' + newURL); + RtcommService.putIframeURL(vm.iframeActiveEndpointUUID, newURL); + vm.iframeURL = $sce.trustAsResourceUrl(newURL); + }; + vm.forward = function() {}; - $scope.onRegClick = function() { - if ($scope.nextAction === 'Register' && !invalidCharacters.test($scope.reguserid)){ - - $log.debug('Register: reguserid =' + $scope.reguserid); - RtcommService.register($scope.reguserid); - } - else { - $log.debug('Unregister: reguserid =' + $scope.reguserid); - RtcommService.unregister(); - } - }; - - $scope.$on('rtcomm::init', function (event, success, details) { - - if (success == true){ - $scope.nextAction = 'Unregister'; - $scope.reguserid = details.userid; - } - else{ - $scope.nextAction = 'Register'; - - if (details == 'destroyed') - $scope.reguserid = ''; - else - $scope.reguserid = 'Init failed:' + details; - } - }); - }], - controllerAs: 'register' - }; -}; + vm.backward = function() {}; -/** - * This directive manages call queues. It provides the ability to display all the available queues - * (along with their descriptions) and by clicking on a queue, allows an agent (or any type of user) - * to subscribe on that queue. - */ -rtcommQueues.$inject = ['RtcommService', '$log']; -function rtcommQueues(RtcommService, $log) { - return { - restrict : 'E', - templateUrl : 'templates/rtcomm/rtcomm-queues.html', - controller : ["$scope", function($scope) { - $scope.rQueues = []; - $scope.autoJoinQueues = false; - $scope.queuePresenceData = []; - $scope.queuePublishPresence = false; - $scope.queueFilter = null; - - /** - * autoJoinQueues - automatically join any queues that are not filtered out - * queuePublishedPresence - will add to the presence document information about what queues this person joins. - * queueFilter - If defined, this specifies which queues should be joined. All others will be ignored. - */ - $scope.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { - $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); - $scope.autoJoinQueues = autoJoinQueues; - $scope.queuePublishPresence = queuePublishPresence; - - if (typeof queueFilter !== "undefined") - $scope.queueFilter = queueFilter; - }; - - $scope.$on('queueupdate', function(event, queues) { - $log.debug('rtcommQueues: scope queues', $scope.rQueues); - - Object.keys(queues).forEach(function(key) { - $log.debug('rtcommQueues: Push queue: ' + queues[key]); - $log.debug('rtcommQueues: autoJoinQueues: ' + $scope.autoJoinQueues); - - // Check to make sure queue is not filteres out before adding it. - if ($scope.filterOutQueue(queues[key]) == false){ - $scope.rQueues.push(queues[key]); - - // If autoJoin we go ahead and join the queue as soon as we get the queue update. - if ($scope.autoJoinQueues == true){ - $scope.onQueueClick(queues[key]); - } - } - }); - - $scope.updateQueuePresence(); - }); - - $scope.$on('rtcomm::init', function (event, success, details) { - if (success == false){ - $log.debug('rtcommQueues: init: clear queues'); - $scope.rQueues = []; - } - }); - - // - $scope.filterOutQueue = function(queue){ - var returnValue = true; - - if ($scope.queueFilter != null){ - - for (var index = 0; index < $scope.queueFilter.length; ++index) { - var entry = $scope.queueFilter[index]; - if (entry == queue.endpointID) { - returnValue = false; - break; - } - } - } - else - returnValue = false; - - return (returnValue); - }; - - $scope.onQueueClick = function(queue){ - $log.debug('rtcommQueues: onClick: TOP'); - for (var index = 0; index < $scope.rQueues.length; index++) { - if($scope.rQueues[index].endpointID === queue.endpointID) - { - $log.debug('rtcommQueues: onClick: queue.endpointID = ' + queue.endpointID); - - if (queue.active == false){ - RtcommService.joinQueue(queue.endpointID); - $scope.rQueues[index].active = true; - } - else{ - RtcommService.leaveQueue(queue.endpointID); - $scope.rQueues[index].active = false; - } - } - else if (index == ($scope.rQueues.length - 1)){ - $log.debug('rtcommQueues: ERROR: queue.endpointID: ' + queue.endpointID + ' not found in list of queues'); - - } - } - - $scope.updateQueuePresence(); - }; - - $scope.updateQueuePresence = function(){ - // Update the presence record if enabled - if ($scope.queuePublishPresence == true){ - RtcommService.removeFromPresenceRecord ($scope.queuePresenceData, false); - - $scope.queuePresenceData = []; - - for (var index = 0; index < $scope.rQueues.length; index++) { - if($scope.rQueues[index].active === true){ - $scope.queuePresenceData.push ( - { - 'name' : "queue", - 'value' : $scope.rQueues[index].endpointID - }); - } - } - - RtcommService.addToPresenceRecord ($scope.queuePresenceData); - } - }; - }], - controllerAs : 'queues' - }; -}; - -//rtcommModule.controller('RtcommAlertController', ['$scope', '$log', function($scope, $log){ -rtcommAlert.$inject = ['$log']; -function rtcommAlert($log) { - return { - restrict: 'E', - templateUrl: "templates/rtcomm/rtcomm-alert.html", - controller: ["$scope", function ($scope) { - $scope.alerts = []; - $scope.addAlert = function(alert) { - $scope.alerts.push(alert); - }; - $scope.closeAlert = function(index) { - $scope.alerts.splice(index, 1); - }; - $scope.$on('rtcomm::alert', function(event, eventObject) { - $scope.addAlert(eventObject); - }); - }] - } -}; + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); -/********************** Endpoint Directives *******************************/ + if (vm.syncSource == true) { + RtcommService.putIframeURL(eventObject.endpoint.id, vm.initiframeURL); //Update on the current or next endpoint to be activated. + } + }); -/** - * This endpoint status controller only shows the active endpoint. The $scope.sessionState always contains the - * state of the active endpoint if one exist. It will be one of the following states: - * - * 'session:alerting' - * 'session:trying' - * 'session:ringing' - * 'session:queued' - for this one $scope.queueCount will tell you where you are in the queue. - * 'session:failed' - for this one $scope.reason will tell you why the call failed. - * 'session:started' - * 'session:stopped' - * - * You can bind to $scope.sessionState to track state in the view. - */ -rtcommEndpointStatus.$inject = ['RtcommService', '$log']; -function rtcommEndpointStatus(RtcommService, $log){ - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', - controller: ["$scope", function ($scope) { - - // Session states. - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - $scope.failureReason = ''; - $scope.queueCount = 0; // FIX: Currently not implemented! - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:started'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:stopped', function (event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:stopped'; - $scope.epCtrlRemoteEndpointID = null; - } - }); - - $scope.$on('session:failed', function (event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:failed'; - $scope.failureReason = eventObject.reason; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:alerting', function (event, eventObject) { - $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ - $scope.sessionState = 'session:alerting'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:connecting', function (event, eventObject) { - $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); - // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ - $scope.sessionState = 'session:connecting'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - // } - }); + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommIframe: endpointActivated =' + endpointUUID); + if (vm.syncSource == false) { + vm.iframeURL = $sce.trustAsResourceUrl(RtcommService.getIframeURL(endpointUUID)); + vm.iframeActiveEndpointUUID = endpointUUID; + } + }); - $scope.$on('session:queued', function (event, eventObject) { - $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:queued'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:trying', function (event, eventObject) { - $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:trying'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:ringing', function (event, eventObject) { - $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:ringing'; - $scope.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $scope.epCtrlActiveEndpointUUID = endpointUUID; - $scope.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); - $scope.sessionState = RtcommService.getSessionState(endpointUUID); - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.epCtrlRemoteEndpointID = null; - $scope.sessionState = 'session:stopped'; - }); - - $scope.$on('rtcomm::init', function(event, success, details){ - if(success === true){ - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - $scope.failureReason = ''; - } - if(success == false){ - $scope.sessionState = 'session:stopped'; - $scope.epCtrlRemoteEndpointID = null; - } - }); + $scope.$on('noEndpointActivated', function(event) { + if (vm.syncSource == false) { + vm.iframeURL = $sce.trustAsResourceUrl('about:blank'); + vm.iframeActiveEndpointUUID = null; + } + }); + $scope.$on('rtcomm::iframeUpdate', function(eventType, endpointUUID, url) { + if (vm.syncSource == false) { + $log.debug('rtcomm::iframeUpdate: ' + url); + // This is needed to prevent rtcomm from logging in when the page is loaded in the iFrame. + url = url + "?disableRtcomm=true"; + vm.iframeURL = $sce.trustAsResourceUrl(url); + } else { + $log.debug('rtcomm::iframeUpdate: load this url in a new tab: ' + url); + // In this case we'll open the pushed URL in a new tab. + $window.open($sce.trustAsResourceUrl(url), '_blank'); + } + }); + activate(); + function activate() { - }] - }; -}; + } + } +})(); /** - * This directive manages the WebRTC video screen, including both the self view and the remote view. It - * also takes care of switching state between endpoints based on which endpoint is "actively" being viewed. + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -rtcommVideo.$inject = ['RtcommService', '$log']; -function rtcommVideo(RtcommService, $log) { - return { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-video.html', - controller: 'RtcommVideoController' - }; -}; /** - * This directive manages the chat portion of a session. The data model for chat - * is maintained in the RtcommService. This directive handles switching between - * active endpoints. + * This directive manages the WebRTC video screen, including both the self view and the remote view. It + * also takes care of switching state between endpoints based on which endpoint is "actively" being viewed. */ -rtcommChat.$inject = ['RtcommService', '$log']; -function rtcommChat(RtcommService, $log) { - return { - restrict: 'E', - templateUrl: "templates/rtcomm/rtcomm-chat.html", - controller: ["$scope", function ($scope) { - $scope.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.chats = RtcommService.getChats($scope.chatActiveEndpointUUID); - // This forces the scroll bar to the bottom and watches the $location.hash - //$anchorScroll(); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $log.debug('rtcommChat: endpointActivated =' + endpointUUID); - - // The data model for the chat is maintained in the RtcommService. - $scope.chats = RtcommService.getChats(endpointUUID); - $scope.chatActiveEndpointUUID = endpointUUID; - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.chats = []; - $scope.chatActiveEndpointUUID = null; - }); - - $scope.keySendMessage = function(keyEvent){ - if (keyEvent.which === 13) - $scope.sendMessage(); - }; - - $scope.sendMessage = function() { - var chat = { - time : new Date(), - name : RtcommService.getEndpoint($scope.chatActiveEndpointUUID).getLocalEndpointID(), - message : angular.copy($scope.message) - }; - - $scope.message = ''; - $scope.scrollToBottom(true); - RtcommService.sendChatMessage(chat, $scope.chatActiveEndpointUUID); - }; - - }], - controllerAs: 'chat', - link: function(scope, element){ - var chatPanel = angular.element(element.find('.panel-body')[0]); - - var bottom = true; - - //Chooses if the scrollbar should be forced to the bottom on the next lifecycle - scope.scrollToBottom = function(flag){ - bottom = flag; - } - - if (chatPanel.length > 0) { - //Watch scroll events - chatPanel.bind('scroll', function(){ - if(chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')){ - scope.scrollToBottom(true); - } - else { - scope.scrollToBottom(false); - } - }); - //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down - scope.$watch('chats', function(){ - if(bottom){ - chatPanel.scrollTop(chatPanel.prop('scrollHeight')); - } - else { - //In this else, a notification could be sent - } - },true); - } - else { - $log.warn('chatPanel not found: most likely you need to load jquery prior to angular'); - } - } - }; - -}; + +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommVideo', rtcommVideo); + + /* @ngInject */ + function rtcommVideo() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-video.html', + controller: VideoController, + controllerAs: 'videoVM', + bindToController: true + }; + + return directive; + } + + VideoController.$inject = ['RtcommService', '$scope', '$log']; + + // /* @ngInject */ + function VideoController(RtcommService, $scope, $log) { + var vm = this; + $log.debug('VideoController Starting'); + vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); + $scope.init = function(selfView, remoteView) { + RtcommService.setViewSelector(selfView, remoteView); + + var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); + if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) + RtcommService.setVideoView(videoActiveEndpointUUID); + }; + + // Go ahead and initialize the local media here if an endpoint already exist. + var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); + if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) + RtcommService.setVideoView(videoActiveEndpointUUID); + + $scope.$on('endpointActivated', function(event, endpointUUID) { + // Not to do something here to show that this button is live. + $log.debug('rtcommVideo: endpointActivated =' + endpointUUID); + RtcommService.setVideoView(endpointUUID); + vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); + }); + // + $scope.$on('noEndpointActivated', function(event) { + vm.avConnected = false; + }); + + $scope.$on('webrtc:connected', function(event, eventObject) { + if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + vm.avConnected = true; + }); + + $scope.$on('webrtc:disconnected', function(event, eventObject) { + if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + vm.avConnected = false; + }); + } +})(); /** - * This directive manages the shared iFrame. + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -rtcommIframe.$inject = ['RtcommService', '$log', '$sce', '$location', '$window']; -function rtcommIframe(RtcommService, $log, $sce, $location, $window) { - return { - restrict: 'E', - templateUrl: "templates/rtcomm/rtcomm-iframe.html", - controller: ["$scope", function ($scope) { - $scope.iframeActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.iframeURL = null; - $scope.initiframeURL = null; - $scope.syncSource = false; - - /* - * syncSourcing means you a providing the URL source but no UI. Typically used in - * customer/agent scenarios. - */ - $scope.init = function(syncSource) { - if (syncSource == true){ - $scope.syncSource = true; - $scope.initiframeURL = $location.absUrl(); // init to current URL - } - }; - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - - if ($scope.syncSource == true){ - RtcommService.putIframeURL(eventObject.endpoint.id,$scope.initiframeURL); //Update on the current or next endpoint to be activated. - } - }); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $log.debug('rtcommIframe: endpointActivated =' + endpointUUID); - - if ($scope.syncSource == false){ - $scope.iframeURL = $sce.trustAsResourceUrl(RtcommService.getIframeURL(endpointUUID)); - $scope.iframeActiveEndpointUUID = endpointUUID; - } - }); - - $scope.$on('noEndpointActivated', function (event) { - if ($scope.syncSource == false){ - $scope.iframeURL = $sce.trustAsResourceUrl('about:blank'); - $scope.iframeActiveEndpointUUID = null; - } - }); - - $scope.$on('rtcomm::iframeUpdate', function (eventType, endpointUUID, url) { - if ($scope.syncSource == false){ - $log.debug('rtcomm::iframeUpdate: ' + url); - // This is needed to prevent rtcomm from logging in when the page is loaded in the iFrame. - url = url + "?disableRtcomm=true"; - $scope.iframeURL = $sce.trustAsResourceUrl(url); - } - else{ - $log.debug('rtcomm::iframeUpdate: load this url in a new tab: ' + url); - // In this case we'll open the pushed URL in a new tab. - $window.open($sce.trustAsResourceUrl(url), '_blank'); - } - }); - - $scope.setURL = function(newURL){ - $log.debug('rtcommIframe: setURL: newURL: ' + newURL); - RtcommService.putIframeURL($scope.iframeActiveEndpointUUID, newURL); - $scope.iframeURL = $sce.trustAsResourceUrl(newURL); - }; - - $scope.forward = function() { - }; - - $scope.backward = function() { - }; - }], - controllerAs: 'rtcommiframe' - }; -}; - - - -/******************************** Rtcomm Modals ************************************************/ /** * This modal is displayed on receiving an inbound call. It handles the alerting event. * Note that it can also auto accept requests for enabling A/V. */ -RtcommAlertModalController.$inject=['$rootScope', '$scope', 'RtcommService', '$modal', '$log']; -function RtcommAlertModalController($rootScope, $scope, RtcommService, $modal, $log) { - - $scope.alertingEndpointUUID = null; - $scope.autoAnswerNewMedia = false; - $scope.alertActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.caller = null; - - $scope.init = function(autoAnswerNewMedia) { - $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); - $scope.autoAnswerNewMedia = autoAnswerNewMedia; - }; - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $scope.alertActiveEndpointUUID = endpointUUID; - }); - - $scope.$on('session:alerting', function (event, eventObject) { - - if (($scope.alertActiveEndpointUUID == eventObject.endpoint.id && $scope.autoAnswerNewMedia == false) || - ($scope.alertActiveEndpointUUID != eventObject.endpoint.id)) - { - $log.debug('rtcommAlert: display alterting model: alertActiveEndpointUUID = ' + eventObject.endpoint + ' autoAnswerNewMedia = ' + $scope.autoAnswerNewMedia); - $scope.caller = eventObject.endpoint.getRemoteEndpointID(); - $scope.alertingEndpointUUID = eventObject.endpoint.id; - $scope.showAlerting(); - } - else{ - $log.debug('Accepting media from: ' + eventObject.endpoint.getRemoteEndpointID() + ' for endpoint: ' + eventObject.endpoint.id); - eventObject.endpoint.accept(); - } - }); - - $scope.showAlerting = function (size) { - - var modalInstance = $modal.open({ - templateUrl: 'templates/rtcomm/rtcomm-modal-alert.html', - controller: 'RtcommAlertModalInstanceController', - size: size, - backdrop: 'static', - resolve: { - caller: function () { - return $scope.caller; - }} - }); - - modalInstance.result.then( - function() { - var alertingEndpointObject = RtcommService.getEndpoint($scope.alertingEndpointUUID); - - if(alertingEndpointObject){ - $log.debug('Accepting call from: ' + $scope.caller + ' for endpoint: ' + $scope.alertingEndpointUUID); - alertingEndpointObject.accept(); - $rootScope.$broadcast('rtcomm::alert-success'); - alertingEndpointObject = null; - } - }, - function () { - var alertingEndpointObject = RtcommService.getEndpoint($scope.alertingEndpointUUID); - if(alertingEndpointObject){ - $log.debug('Rejecting call from: ' + $scope.caller + ' for endpoint: ' + $scope.alertingEndpointUUID); - alertingEndpointObject.reject(); - alertingEndpointObject = null; - } - }); - }; -}; - -RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; - -function RtcommAlertModalInstanceController($scope, $modalInstance, $log, caller) { - $scope.caller = caller; - $scope.ok = function () { - $log.debug('Accepting alerting call'); - $modalInstance.close(); - }; - - $scope.cancel = function () { - $log.debug('Rejecting alerting call'); - $modalInstance.dismiss('cancel'); - }; -}; +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .controller('RtcommAlertModalController', RtcommAlertModalController) + .controller('RtcommAlertModalInstanceController', RtcommAlertModalInstanceController); + + RtcommAlertModalController.$inject = ['RtcommService', '$modal', '$rootScope', '$scope', '$log']; + + /* @ngInject */ + function RtcommAlertModalController(RtcommService, $modal, $rootScope, $scope, $log) { + var vm = this; + vm.alertingEndpointUUID = null; + vm.autoAnswerNewMedia = false; + vm.alertActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.caller = null; + + vm.init = function(autoAnswerNewMedia) { + $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); + vm.autoAnswerNewMedia = autoAnswerNewMedia; + }; -/** - * This is a modal controller for placing an outbound call to a static callee such as a queue. - */ -RtcommCallModalController.$inject = ['$scope', 'RtcommService', '$modal', '$log']; -function RtcommCallModalController($scope, RtcommService, $modal, $log) { - $scope.calleeID = null; - $scope.callerID = null; - - $scope.enableCallModel = false; - $scope.mediaToEnable = ['chat']; - - $scope.init = function(calleeID, mediaToEnable) { - $scope.calleeID = calleeID; - - if (typeof mediaToEnable !== "undefined") - $scope.mediaToEnable = mediaToEnable; - }; - - $scope.$on('rtcomm::init', function (event, success, details) { - $log.debug('RtcommCallModalController: rtcomm::init: success = ' + success); - if (success == true) - $scope.enableCallModel = true; - else - $scope.enableCallModel = false; - }); - - $scope.$on('session:started', function (event, eventObject) { - $scope.enableCallModel = false; - }); - - $scope.$on('session:stopped', function (event, eventObject) { - $scope.enableCallModel = true; - }); - - $scope.placeCall = function (size) { - - var modalInstance = $modal.open({ - templateUrl: 'templates/rtcomm/rtcomm-modal-call.html', - controller: 'RtcommCallModalInstanceController', - size: size, - resolve: {} - }); - - modalInstance.result.then( - function (resultName) { - $log.debug('rtcommCallModal: Calling calleeID: ' + $scope.calleeID); - $log.debug('rtcommCallModal: CallerID: ' + resultName); - - // This is used to set an alias when the endoint is not defined. - if ($scope.callerID == null && (typeof resultName !== "undefined") && resultName != ''){ - $scope.callerID = resultName; - RtcommService.setAlias(resultName); - } - - RtcommService.placeCall($scope.calleeID, $scope.mediaToEnable); - }, - function () { - $log.info('Modal dismissed at: ' + new Date()); - }); - }; -}; - -RtcommCallModalInstanceController.$inject = ['$scope', '$modalInstance', 'RtcommService']; -function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { - $scope.endpointAlias = ''; - $scope.ok = function () { - $modalInstance.close($scope.endpointAlias); - }; - $scope.cancel = function () { - $modalInstance.dismiss('cancel'); - }; -}; - -/********************************************* Rtcomm Controllers ******************************************************/ + vm.showAlerting = function(size) { + + var modalInstance = $modal.open({ + templateUrl: 'templates/rtcomm/rtcomm-modal-alert.html', + controller: 'RtcommAlertModalInstanceController', + size: size, + backdrop: 'static', + resolve: { + caller: function() { + return vm.caller; + } + } + }); + + modalInstance.result.then( + function() { + var alertingEndpointObject = RtcommService.getEndpoint(vm.alertingEndpointUUID); + + if (alertingEndpointObject) { + $log.debug('Accepting call from: ' + vm.caller + ' for endpoint: ' + vm.alertingEndpointUUID); + alertingEndpointObject.accept(); + $rootScope.$broadcast('rtcomm::alert-success'); + alertingEndpointObject = null; + } + }, + function() { + var alertingEndpointObject = RtcommService.getEndpoint(vm.alertingEndpointUUID); + if (alertingEndpointObject) { + $log.debug('Rejecting call from: ' + vm.caller + ' for endpoint: ' + vm.alertingEndpointUUID); + alertingEndpointObject.reject(); + alertingEndpointObject = null; + } + }); + }; + + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.alertActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('session:alerting', function(event, eventObject) { + + if ((vm.alertActiveEndpointUUID == eventObject.endpoint.id && vm.autoAnswerNewMedia == false) || + (vm.alertActiveEndpointUUID != eventObject.endpoint.id)) { + $log.debug('rtcommAlert: display alterting model: alertActiveEndpointUUID = ' + eventObject.endpoint + ' autoAnswerNewMedia = ' + vm.autoAnswerNewMedia); + vm.caller = eventObject.endpoint.getRemoteEndpointID(); + vm.alertingEndpointUUID = eventObject.endpoint.id; + vm.showAlerting(); + } else { + $log.debug('Accepting media from: ' + eventObject.endpoint.getRemoteEndpointID() + ' for endpoint: ' + eventObject.endpoint.id); + eventObject.endpoint.accept(); + } + }); + activate(); + + function activate() { + + } + } + + RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; + + function RtcommAlertModalInstanceController($scope, $modalInstance, $log, caller) { + $scope.caller = caller; + $scope.ok = function () { + $log.debug('Accepting alerting call'); + $modalInstance.close(); + }; + + $scope.cancel = function () { + $log.debug('Rejecting alerting call'); + $modalInstance.dismiss('cancel'); + }; + }; +})(); /** - * This is the controller for config loader. It reads a JSON object and utilizes the RtcommService to set the configuration. - * This can also result in the initialization of the endpoint provider if the config JSON object includes a registration name. + * (C) Copyright IBM Corporation 2016. * - * Here is an example of the config object: + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * { - * "server" : "server address", - * "port" : 1883, - * "rtcommTopicPath" : "/rtcomm-helpdesk/", - * "createEndpoint" : false, - * "userid" : "registration name", - * "broadcastAudio" : true, - * "broadcastVideo" : true - * } + * http://www.apache.org/licenses/LICENSE-2.0 * - * NOTE: If the user does not specify a userid, that says one will never be specified so go ahead - * and initialize the endpoint provider and let the provider assign a name. If a defined empty - * string is passed in, that means to wait until the end user registers a name before initializing - * the endpoint provider. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -RtcommConfigController.$inject = ['$scope','$http', 'RtcommService', '$log']; -function RtcommConfigController($scope, $http, RtcommService, $log) { - $scope.extendedConfig = null; - - $log.debug('RtcommConfigController: configURL = ' + $scope.configURL); - - $scope.setConfig = function(data) { - $log.debug('RtcommConfigController: setting config data:' + data); - RtcommService.setConfig(data); - }; - - $scope.init = function(configURL,extendedConfig) { - $log.debug('RtcommConfigController: initing configURL = ' + configURL); - $scope.configURL = configURL; - - if (typeof extendedConfig !== "undefined") - $scope.extendedConfig = extendedConfig; - - $scope.getConfig(); - }; - - $scope.getConfig = function() { - $http.get($scope.configURL).success (function(config){ - - // Now we need to update the config with any extensions passed in on init. - if ($scope.extendedConfig != null){ - angular.extend(config, $scope.extendedConfig); - $log.debug('RtcommConfigController: extended config object: ' + config); - } - - RtcommService.setConfig(config); - }).error(function(data, status, headers, config) { - $log.debug('RtcommConfigController: error accessing config: ' + status); - }); - }; -}; - - -RtcommVideoController.$inject= ['$scope','$http', 'RtcommService', '$log']; -function RtcommVideoController($scope, $http, RtcommService, $log) { - $scope.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); - $scope.init = function(selfView,remoteView) { - RtcommService.setViewSelector(selfView,remoteView); - - var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); - }; - - // Go ahead and initialize the local media here if an endpoint already exist. - var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); - - $scope.$on('endpointActivated', function (event, endpointUUID) { - // Not to do something here to show that this button is live. - $log.debug('rtcommVideo: endpointActivated =' + endpointUUID); - RtcommService.setVideoView(endpointUUID); - $scope.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.avConnected = false; - }); - - $scope.$on('webrtc:connected', function (event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - $scope.avConnected = true; - }); - - $scope.$on('webrtc:disconnected', function (event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - $scope.avConnected = false; - }); -}; - - -RtcommEndpointController.$inject = ['$scope', '$rootScope', '$http', 'RtcommService', '$log']; -function RtcommEndpointController($scope, $rootScope, $http, RtcommService, $log) { - // Session states. - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - - $scope.disconnect = function() { - $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); - }; - - $scope.toggleAV = function() { - $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - - if ($scope.epCtrlAVConnected == false){ - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { - if (!value) { - $log.debug('Enable failed: ',message); - RtcommService.alert({type: 'danger', msg: message}); - } - }); - } - else{ - $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); - } - }; - - $scope.$on('session:started', function (event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:started'; - } - }); - - $scope.$on('session:stopped', function (event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:stopped'; - } - }); - - $scope.$on('session:failed', function (event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id){ - $scope.sessionState = 'session:failed'; - } - }); - - $scope.$on('webrtc:connected', function (event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = true; - }); - - $scope.$on('webrtc:disconnected', function (event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = false; - }); - - - $scope.$on('endpointActivated', function (event, endpointUUID) { - $scope.epCtrlActiveEndpointUUID = endpointUUID; - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); - }); - - $scope.$on('noEndpointActivated', function (event) { - $scope.epCtrlAVConnected = false; - }); -}; - -})(); - -/* - * The angular-rtcomm-presence module - * This has controllers and directives in it. +/** + * This is a modal controller for placing an outbound call to a static callee such as a queue. */ -(function(){ - angular - .module('angular-rtcomm-presence', [ - 'ui.bootstrap', - 'treeControl', - 'angular-rtcomm-service']) - .directive('rtcommPresence', rtcommPresence); +(function() { + 'use strict'; - /** - * This directive manages the chat portion of a session. The data model for chat - * is maintained in the RtcommService. This directive handles switching between - * active endpoints. - * - * Here is the formate of the presenceData: - * - * This is a Node: - * { - * "name" : "agents", - * "record" : false, - * "nodes" : [] - * } - * - * This is a record with a set of user defines: - * { - * "name" : "Brian Pulito", - * "record" : true, - * "nodes" : [ - * { - * "name" : "queue", - * "value" : "appliances" - * }, - * { - * "name" : "sessions", - * "value" : "3" - * } - * ] - */ - rtcommPresence.$inject=['RtcommService', '$log']; - function rtcommPresence(RtcommService, $log) { - return { - restrict: 'E', - templateUrl: "templates/rtcomm/rtcomm-presence.html", - controller: ["$scope", "$rootScope", function ($scope, $rootScope) { + angular + .module('angular-rtcomm-ui') + .controller('RtcommCallModalController', RtcommCallModalController) + .controller('RtcommCallModalInstanceController', RtcommCallModalInstanceController); - $scope.monitorTopics = []; - $scope.presenceData = []; - $scope.expandedNodes = []; + RtcommCallModalController.$inject = ['RtcommService', '$modal', '$scope', '$log']; - // Default protocol list initiated from presence. Start with chat only. - $scope.protocolList = { - chat : true, - webrtc : false}; + /* @ngInject */ + function RtcommCallModalController(dependencies) { + var vm = this; + vm.calleeID = null; + vm.callerID = null; - // use a tree view or flatten. - $scope.flatten = false; - $scope.treeOptions = { - nodeChildren: "nodes", - dirSelectable: true, - injectClasses: { - ul: "a1", - li: "a2", - liSelected: "a7", - iExpanded: "a3", - iCollapsed: "a4", - iLeaf: "a5", - label: "a6", - labelSelected: "a8" - } - }; + vm.enableCallModel = false; + vm.mediaToEnable = ['chat']; - $scope.init = function(options) { - $scope.protocolList.chat = (typeof options.chat === 'boolean') ? options.chat : $scope.protocolList.chat; - $scope.protocolList.webrtc = (typeof options.webrtc === 'boolean') ? options.webrtc : $scope.protocolList.webrtc; - $scope.flatten = (typeof options.flatten === 'boolean') ? options.flatten: $scope.flatten; - }; + vm.init = function(calleeID, mediaToEnable) { + vm.calleeID = calleeID; - $scope.onCallClick = function(calleeEndpointID){ - var endpoint = RtcommService.getEndpoint(); - RtcommService.setActiveEndpoint(endpoint.id); + if (typeof mediaToEnable !== "undefined") + vm.mediaToEnable = mediaToEnable; + }; - if ($scope.protocolList.chat == true) - endpoint.chat.enable(); + vm.placeCall = function(size) { - if ($scope.protocolList.webrtc == true){ - endpoint.webrtc.enable(function(value, message) { - if (!value) { - RtcommService.alert({type: 'danger', msg: message}); - } + var modalInstance = $modal.open({ + templateUrl: 'templates/rtcomm/rtcomm-modal-call.html', + controller: 'RtcommCallModalInstanceController', + size: size, + resolve: {} }); - } - endpoint.connect(calleeEndpointID); - $rootScope.$broadcast('rtcomm::presence-click'); + modalInstance.result.then( + function(resultName) { + $log.debug('rtcommCallModal: Calling calleeID: ' + vm.calleeID); + $log.debug('rtcommCallModal: CallerID: ' + resultName); + + // This is used to set an alias when the endoint is not defined. + if (vm.callerID == null && (typeof resultName !== "undefined") && resultName != '') { + vm.callerID = resultName; + RtcommService.setAlias(resultName); + } + + RtcommService.placeCall(vm.calleeID, vm.mediaToEnable); + }, + function() { + $log.info('Modal dismissed at: ' + new Date()); + }); }; - $scope.$on('rtcomm::init', function (event, success, details) { - RtcommService.publishPresence(); - var presenceMonitor = RtcommService.getPresenceMonitor(); + $scope.$on('rtcomm::init', function(event, success, details) { + $log.debug('RtcommCallModalController: rtcomm::init: success = ' + success); + if (success == true) + vm.enableCallModel = true; + else + vm.enableCallModel = false; + }); - presenceMonitor.on('updated', function(presenceData){ - $log.debug('<<------rtcommPresence: updated------>>'); - if ($scope.flatten) { - $log.debug('<<------rtcommPresence: updated using flattened data ------>>'); - $scope.presenceData = presenceData[0].flatten(); - } - $scope.$apply(); - }); + $scope.$on('session:started', function(event, eventObject) { + vm.enableCallModel = false; + }); - // Binding data if we are going to flatten causes a flash in the UI when it changes. - if (!$scope.flatten) { - $scope.presenceData = presenceMonitor.getPresenceData(); - } + $scope.$on('session:stopped', function(event, eventObject) { + vm.enableCallModel = true; + }); + activate(); - if ($scope.presenceData.length >= 1) - $scope.expandedNodes.push($scope.presenceData[0]); + function activate() { - for (var index = 0; index < $scope.monitorTopics.length; index++) { - $log.debug('rtcommPresence: monitorTopic: ' + $scope.monitorTopics[index]); - presenceMonitor.add($scope.monitorTopics[index]); - } - }); + } + } + + function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { + $scope.endpointAlias = ''; + $scope.ok = function() { + $modalInstance.close($scope.endpointAlias); + }; + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + } + RtcommCallModalInstanceController.$inject = ["$scope", "$modalInstance", "RtcommService"];; - }], - controllerAs: 'presence' - }; - }; })(); angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCache) { 'use strict'; @@ -1984,12 +2423,12 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-chat.html', - "
Chat
  • {{chat.name}} {{chat.time | date:'HH:mm:ss'}}

    {{chat.message}}

" + "
Chat
  • {{chat.name}} {{chat.time | date:'HH:mm:ss'}}

    {{chat.message}}

" ); $templateCache.put('templates/rtcomm/rtcomm-endpoint-status.html', - "

Connected to {{epCtrlRemoteEndpointID}} No active sessions, waiting... Inbound call from {{epCtrlRemoteEndpointID}} Attempting to call {{epCtrlRemoteEndpointID}} Call to {{epCtrlRemoteEndpointID}} is ringing Waiting in queue at: {{queueCount}} Call failed with reason: {{failureReason}} Connecting to {{epCtrlRemoteEndpointID}} ...

" + "

Connected to {{endpointStatusVM.epCtrlRemoteEndpointID}} No active sessions, waiting... Inbound call from {{endpointStatusVM.epCtrlRemoteEndpointID}} Attempting to call {{endpointStatusVM.epCtrlRemoteEndpointID}} Call to {{endpointStatusVM.epCtrlRemoteEndpointID}} is ringing Waiting in queue at: {{endpointStatusVM.queueCount}} Call failed with reason: {{endpointStatusVM.failureReason}} Connecting to {{endpointStatusVM.epCtrlRemoteEndpointID}} ...

" ); @@ -2014,7 +2453,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-register.html', - "
" + "
" ); @@ -2024,7 +2463,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-video.html', - "
" + "
" ); }]); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index a888892..ae7e4f2 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-02-18 + * @version v1.0.3 - 2016-03-04 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){function a(a,b,c){b.debug("RtcommConfigService: Abs URL: "+a.absUrl());var d=a.search().disableRtcomm;d="undefined"==typeof d||null===d?!1:"true"===d?!0:!1,b.debug("RtcommConfigService: _disableRtcomm = "+d);var e={server:a.host(),port:a.port(),rtcommTopicPath:"/rtcomm/",createEndpoint:!1,appContext:"default",userid:"",presence:{topic:""}};b.debug("providerConfig.server: "+e.server),b.debug("providerConfig.port: "+e.port);var f={chat:!0,webrtc:!0},g=!0,h=!0,i="DEBUG",j=null,k=null,l=!0,m=function(a){e.server="undefined"!=typeof a.server?a.server:e.server,e.port="undefined"!=typeof a.port?a.port:e.port,e.rtcommTopicPath="undefined"!=typeof a.rtcommTopicPath?a.rtcommTopicPath:e.rtcommTopicPath,e.createEndpoint="undefined"!=typeof a.createEndpoint?a.createEndpoint:e.createEndpoint,e.appContext="undefined"!=typeof a.appContext?a.appContext:e.appContext,e.presence.topic="undefined"!=typeof a.presenceTopic?a.presenceTopic:e.presence.topic,f.chat="undefined"!=typeof a.chat?a.chat:f.chat,f.webrtc="undefined"!=typeof a.webrtc?a.webrtc:f.webrtc,g="undefined"!=typeof a.broadcastAudio?a.broadcastAudio:g,h="undefined"!=typeof a.broadcastVideo?a.broadcastVideo:h,l="undefined"!=typeof a.trickleICE?a.trickleICE:l,k="undefined"!=typeof a.ringbacktone?a.ringbacktone:k,j="undefined"!=typeof a.ringtone?a.ringtone:j,i="undefined"!=typeof a.rtcommDebug?a.rtcommDebug:i,b.debug("rtcommDebug from config is: "+a.rtcommDebug),"undefined"!=typeof a.userid&&(e.userid=a.userid),b.debug("providerConfig is now: ",e)};return{setProviderConfig:function(a){m(a)},getProviderConfig:function(){return e},getWebRTCEnabled:function(){return f.webrtc},getChatEnabled:function(){return f.chat},getBroadcastAudio:function(){return g},getBroadcastVideo:function(){return h},getRingTone:function(){return j},getRingBackTone:function(){return k},getRtcommDebug:function(){return i},isRtcommDisabled:function(){return d},getTrickleICE:function(){return l}}}function b(a,b,c,d){var e=new rtcomm.EndpointProvider,f=!1,g=null,h=[],i=null,j=!1,k="selfView",l="remoteView";e.setLogLevel(d.getRtcommDebug()),b.debug("rtcomm-service - endpointProvider log level is: "+e.getLogLevel()),b.debug("rtcomm-service - endpointProvider log level should be: "+d.getRtcommDebug()),e.setAppContext(d.getProviderConfig().appContext);var m=function(){return null==i&&(i={state:"available",userDefines:[]}),i},n=function(){var a={ringbacktone:d.getRingBackTone(),ringtone:d.getRingTone(),webrtcConfig:{broadcast:{audio:d.getBroadcastAudio(),video:d.getBroadcastVideo()},trickleICE:d.getTrickleICE()},webrtc:d.getWebRTCEnabled(),chat:d.getChatEnabled()};return a};e.on("reset",function(a){f=!1,x({type:"danger",msg:a.reason})}),e.on("queueupdate",function(c){b.debug("<<------rtcomm-service------>> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:connecting":o,"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-sessionmgr.html",controller:["$scope",function(c){c.sessions=a.getSessions(),c.sessMgrActiveEndpointUUID=a.getActiveEndpoint(),c.publishPresence=!1,c.sessionPresenceData=[],c.init=function(a){c.publishPresence=a,c.updatePresence()},c.$on("endpointActivated",function(a,d){b.debug("rtcommSessionmgr: endpointActivated ="+d),c.sessMgrActiveEndpointUUID=d}),c.$on("session:started",function(a,d){b.debug("rtcommSessionmgr: session:started: uuid ="+d.endpoint.id),c.updatePresence()}),c.activateSession=function(d){b.debug("rtcommSessionmgr: activateEndpoint ="+d),c.sessMgrActiveEndpointUUID!=d&&a.setActiveEndpoint(d)},c.updatePresence=function(){1==c.publishPresence&&(a.removeFromPresenceRecord(c.sessionPresenceData,!1),c.sessionPresenceData=[{name:"sessions",value:String(c.sessions.length)}],a.addToPresenceRecord(c.sessionPresenceData))}}],controllerAs:"sessionmgr"}}function b(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-register.html",controller:["$scope",function(c){c.nextAction="Register",c.reguserid="",c.invalid=!1;var d=/(\$|#|\+|\/|\\)+/i;c.$watch("reguserid",function(){c.reguserid.length<1||d.test(c.reguserid)?c.invalid=!0:c.invalid=!1}),c.onRegClick=function(){"Register"!==c.nextAction||d.test(c.reguserid)?(b.debug("Unregister: reguserid ="+c.reguserid),a.unregister()):(b.debug("Register: reguserid ="+c.reguserid),a.register(c.reguserid))},c.$on("rtcomm::init",function(a,b,d){1==b?(c.nextAction="Unregister",c.reguserid=d.userid):(c.nextAction="Register","destroyed"==d?c.reguserid="":c.reguserid="Init failed:"+d)})}],controllerAs:"register"}}function c(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:["$scope",function(c){c.rQueues=[],c.autoJoinQueues=!1,c.queuePresenceData=[],c.queuePublishPresence=!1,c.queueFilter=null,c.init=function(a,d,e){b.debug("rtcommQueues: autoJoinQueues = "+a),c.autoJoinQueues=a,c.queuePublishPresence=d,"undefined"!=typeof e&&(c.queueFilter=e)},c.$on("queueupdate",function(a,d){b.debug("rtcommQueues: scope queues",c.rQueues),Object.keys(d).forEach(function(a){b.debug("rtcommQueues: Push queue: "+d[a]),b.debug("rtcommQueues: autoJoinQueues: "+c.autoJoinQueues),0==c.filterOutQueue(d[a])&&(c.rQueues.push(d[a]),1==c.autoJoinQueues&&c.onQueueClick(d[a]))}),c.updateQueuePresence()}),c.$on("rtcomm::init",function(a,d,e){0==d&&(b.debug("rtcommQueues: init: clear queues"),c.rQueues=[])}),c.filterOutQueue=function(a){var b=!0;if(null!=c.queueFilter)for(var d=0;d0?(d.bind("scroll",function(){d.prop("scrollTop")+d.prop("clientHeight")==d.prop("scrollHeight")?a.scrollToBottom(!0):a.scrollToBottom(!1)}),a.$watch("chats",function(){e&&d.scrollTop(d.prop("scrollHeight"))},!0)):b.warn("chatPanel not found: most likely you need to load jquery prior to angular")}}}function h(a,b,c,d,e){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:["$scope",function(f){f.iframeActiveEndpointUUID=a.getActiveEndpoint(),f.iframeURL=null,f.initiframeURL=null,f.syncSource=!1,f.init=function(a){1==a&&(f.syncSource=!0,f.initiframeURL=d.absUrl())},f.$on("session:started",function(c,d){b.debug("session:started received: endpointID = "+d.endpoint.id),1==f.syncSource&&a.putIframeURL(d.endpoint.id,f.initiframeURL)}),f.$on("endpointActivated",function(d,e){b.debug("rtcommIframe: endpointActivated ="+e),0==f.syncSource&&(f.iframeURL=c.trustAsResourceUrl(a.getIframeURL(e)),f.iframeActiveEndpointUUID=e)}),f.$on("noEndpointActivated",function(a){0==f.syncSource&&(f.iframeURL=c.trustAsResourceUrl("about:blank"),f.iframeActiveEndpointUUID=null)}),f.$on("rtcomm::iframeUpdate",function(a,d,g){0==f.syncSource?(b.debug("rtcomm::iframeUpdate: "+g),g+="?disableRtcomm=true",f.iframeURL=c.trustAsResourceUrl(g)):(b.debug("rtcomm::iframeUpdate: load this url in a new tab: "+g),e.open(c.trustAsResourceUrl(g),"_blank"))}),f.setURL=function(d){b.debug("rtcommIframe: setURL: newURL: "+d),a.putIframeURL(f.iframeActiveEndpointUUID,d),f.iframeURL=c.trustAsResourceUrl(d)},f.forward=function(){},f.backward=function(){}}],controllerAs:"rtcommiframe"}}function i(a,b,c,d,e){b.alertingEndpointUUID=null,b.autoAnswerNewMedia=!1,b.alertActiveEndpointUUID=c.getActiveEndpoint(),b.caller=null,b.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),b.autoAnswerNewMedia=a},b.$on("endpointActivated",function(a,c){b.alertActiveEndpointUUID=c}),b.$on("session:alerting",function(a,c){b.alertActiveEndpointUUID==c.endpoint.id&&0==b.autoAnswerNewMedia||b.alertActiveEndpointUUID!=c.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+c.endpoint+" autoAnswerNewMedia = "+b.autoAnswerNewMedia),b.caller=c.endpoint.getRemoteEndpointID(),b.alertingEndpointUUID=c.endpoint.id,b.showAlerting()):(e.debug("Accepting media from: "+c.endpoint.getRemoteEndpointID()+" for endpoint: "+c.endpoint.id),c.endpoint.accept())}),b.showAlerting=function(f){var g=d.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:f,backdrop:"static",resolve:{caller:function(){return b.caller}}});g.result.then(function(){var d=c.getEndpoint(b.alertingEndpointUUID);d&&(e.debug("Accepting call from: "+b.caller+" for endpoint: "+b.alertingEndpointUUID),d.accept(),a.$broadcast("rtcomm::alert-success"),d=null)},function(){var a=c.getEndpoint(b.alertingEndpointUUID);a&&(e.debug("Rejecting call from: "+b.caller+" for endpoint: "+b.alertingEndpointUUID),a.reject(),a=null)})}}function j(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}function k(a,b,c,d){a.calleeID=null,a.callerID=null,a.enableCallModel=!1,a.mediaToEnable=["chat"],a.init=function(b,c){a.calleeID=b,"undefined"!=typeof c&&(a.mediaToEnable=c)},a.$on("rtcomm::init",function(b,c,e){d.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?a.enableCallModel=!0:a.enableCallModel=!1}),a.$on("session:started",function(b,c){a.enableCallModel=!1}),a.$on("session:stopped",function(b,c){a.enableCallModel=!0}),a.placeCall=function(e){var f=c.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:e,resolve:{}});f.result.then(function(c){d.debug("rtcommCallModal: Calling calleeID: "+a.calleeID),d.debug("rtcommCallModal: CallerID: "+c),null==a.callerID&&"undefined"!=typeof c&&""!=c&&(a.callerID=c,b.setAlias(c)),b.placeCall(a.calleeID,a.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})}}function l(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}function m(a,b,c,d){a.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+a.configURL),a.setConfig=function(a){d.debug("RtcommConfigController: setting config data:"+a),c.setConfig(a)},a.init=function(b,c){d.debug("RtcommConfigController: initing configURL = "+b),a.configURL=b,"undefined"!=typeof c&&(a.extendedConfig=c),a.getConfig()},a.getConfig=function(){b.get(a.configURL).success(function(b){null!=a.extendedConfig&&(angular.extend(b,a.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),c.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}function n(a,b,c,d){a.avConnected=c.isWebrtcConnected(c.getActiveEndpoint()),a.init=function(a,b){c.setViewSelector(a,b);var d=c.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&c.setVideoView(d)};var e=c.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&c.setVideoView(e),a.$on("endpointActivated",function(b,e){d.debug("rtcommVideo: endpointActivated ="+e),c.setVideoView(e),a.avConnected=c.isWebrtcConnected(c.getActiveEndpoint())}),a.$on("noEndpointActivated",function(b){a.avConnected=!1}),a.$on("webrtc:connected",function(b,d){c.getActiveEndpoint()==d.endpoint.id&&(a.avConnected=!0)}),a.$on("webrtc:disconnected",function(b,d){c.getActiveEndpoint()==d.endpoint.id&&(a.avConnected=!1)})}function o(a,b,c,d,e){a.epCtrlActiveEndpointUUID=d.getActiveEndpoint(),a.epCtrlAVConnected=d.isWebrtcConnected(a.epCtrlActiveEndpointUUID),a.sessionState=d.getSessionState(a.epCtrlActiveEndpointUUID),a.disconnect=function(){e.debug("Disconnecting call for endpoint: "+a.epCtrlActiveEndpointUUID),d.getEndpoint(a.epCtrlActiveEndpointUUID).disconnect()},a.toggleAV=function(){e.debug("Enable AV for endpoint: "+a.epCtrlActiveEndpointUUID),0==a.epCtrlAVConnected?d.getEndpoint(a.epCtrlActiveEndpointUUID).webrtc.enable(function(a,b){a||(e.debug("Enable failed: ",b),d.alert({type:"danger",msg:b}))}):(e.debug("Disable AV for endpoint: "+a.epCtrlActiveEndpointUUID),d.getEndpoint(a.epCtrlActiveEndpointUUID).webrtc.disable())},a.$on("session:started",function(b,c){e.debug("session:started received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:started")}),a.$on("session:stopped",function(b,c){e.debug("session:stopped received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:stopped")}),a.$on("session:failed",function(b,c){e.debug("session:failed received: endpointID = "+c.endpoint.id),a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.sessionState="session:failed")}),a.$on("webrtc:connected",function(b,c){a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.epCtrlAVConnected=!0)}),a.$on("webrtc:disconnected",function(b,c){a.epCtrlActiveEndpointUUID==c.endpoint.id&&(a.epCtrlAVConnected=!1)}),a.$on("endpointActivated",function(b,c){a.epCtrlActiveEndpointUUID=c,a.epCtrlAVConnected=d.isWebrtcConnected(c)}),a.$on("noEndpointActivated",function(b){a.epCtrlAVConnected=!1})}angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"]).directive("rtcommSessionManager",a).directive("rtcommRegister",b).directive("rtcommQueues",c).directive("rtcommAlert",d).directive("rtcommEndpointStatus",e).directive("rtcommVideo",f).directive("rtcommChat",g).directive("rtcommIframe",h).controller("RtcommAlertModalController",i).controller("RtcommAlertModalInstanceController",j).controller("RtcommCallModalController",k).controller("RtcommCallModalInstanceController",l).controller("RtcommConfigController",m).controller("RtcommVideoController",n).controller("RtcommEndpointController",o),a.$inject=["RtcommService","$log"],b.$inject=["RtcommService","$log"],c.$inject=["RtcommService","$log"],d.$inject=["$log"],e.$inject=["RtcommService","$log"],f.$inject=["RtcommService","$log"],g.$inject=["RtcommService","$log"],h.$inject=["RtcommService","$log","$sce","$location","$window"],i.$inject=["$rootScope","$scope","RtcommService","$modal","$log"],j.$inject=["$scope","$modalInstance","$log","caller"],k.$inject=["$scope","RtcommService","$modal","$log"],l.$inject=["$scope","$modalInstance","RtcommService"],m.$inject=["$scope","$http","RtcommService","$log"],n.$inject=["$scope","$http","RtcommService","$log"],o.$inject=["$scope","$rootScope","$http","RtcommService","$log"]}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h{{alert.msg}}'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), -a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file +!function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){function e(){}var f=this;f.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+f.configURL),f.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),f.configURL=a,"undefined"!=typeof b&&(f.extendedConfig=b),f.getConfig()},f.getConfig=function(){b.get(f.configURL).success(function(b){null!=f.extendedConfig&&(angular.extend(b,f.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})},e()}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.alerts=[],e.addAlert=function(a){e.alerts.push(a)},e.closeAlert=function(a){e.alerts.splice(a,1)},b.$on("rtcomm::alert",function(a,b){e.addAlert(b)}),d()}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.rQueues=[],e.autoJoinQueues=!1,e.queuePresenceData=[],e.queuePublishPresence=!1,e.queueFilter=null,e.init=function(a,b,d){c.debug("rtcommQueues: autoJoinQueues = "+a),e.autoJoinQueues=a,e.queuePublishPresence=b,"undefined"!=typeof d&&(e.queueFilter=d)},e.filterOutQueue=function(a){var b=!0;if(null!=e.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}function c(){}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"],c()}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.iframeActiveEndpointUUID=a.getActiveEndpoint(),e.iframeURL=null,e.initiframeURL=null,e.syncSource=!1,e.init=function(a){1==a&&(e.syncSource=!0,e.initiframeURL=$location.absUrl())},e.setURL=function(b){c.debug("rtcommIframe: setURL: newURL: "+b),a.putIframeURL(e.iframeActiveEndpointUUID,b),e.iframeURL=$sce.trustAsResourceUrl(b)},e.forward=function(){},e.backward=function(){},b.$on("session:started",function(b,d){c.debug("session:started received: endpointID = "+d.endpoint.id),1==e.syncSource&&a.putIframeURL(d.endpoint.id,e.initiframeURL)}),b.$on("endpointActivated",function(b,d){c.debug("rtcommIframe: endpointActivated ="+d),0==e.syncSource&&(e.iframeURL=$sce.trustAsResourceUrl(a.getIframeURL(d)),e.iframeActiveEndpointUUID=d)}),b.$on("noEndpointActivated",function(a){0==e.syncSource&&(e.iframeURL=$sce.trustAsResourceUrl("about:blank"),e.iframeActiveEndpointUUID=null)}),b.$on("rtcomm::iframeUpdate",function(a,b,d){0==e.syncSource?(c.debug("rtcomm::iframeUpdate: "+d),d+="?disableRtcomm=true",e.iframeURL=$sce.trustAsResourceUrl(d)):(c.debug("rtcomm::iframeUpdate: load this url in a new tab: "+d),$window.open($sce.trustAsResourceUrl(d),"_blank"))}),d()}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint()),b.init=function(b,c){a.setViewSelector(b,c);var d=a.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&a.setVideoView(d)};var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())}),b.$on("noEndpointActivated",function(a){d.avConnected=!1}),b.$on("webrtc:connected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!0)}),b.$on("webrtc:disconnected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!1)})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){function f(){}var g=this;g.alertingEndpointUUID=null,g.autoAnswerNewMedia=!1,g.alertActiveEndpointUUID=a.getActiveEndpoint(),g.caller=null,g.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),g.autoAnswerNewMedia=a},g.showAlerting=function(d){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return g.caller}}});f.result.then(function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.reject(),b=null)})},d.$on("endpointActivated",function(a,b){g.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){g.alertActiveEndpointUUID==b.endpoint.id&&0==g.autoAnswerNewMedia||g.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+g.autoAnswerNewMedia),g.caller=b.endpoint.getRemoteEndpointID(),g.alertingEndpointUUID=b.endpoint.id,g.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())}),f()}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){function b(){}var c=this;c.calleeID=null,c.callerID=null,c.enableCallModel=!1,c.mediaToEnable=["chat"],c.init=function(a,b){c.calleeID=a,"undefined"!=typeof b&&(c.mediaToEnable=b)},c.placeCall=function(a){var b=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});b.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+c.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==c.callerID&&"undefined"!=typeof a&&""!=a&&(c.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(c.calleeID,c.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,b,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?c.enableCallModel=!0:c.enableCallModel=!1}),$scope.$on("session:started",function(a,b){c.enableCallModel=!1}),$scope.$on("session:stopped",function(a,b){c.enableCallModel=!0}),b()}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), +a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/angular-rtcomm.js b/src/js/angular-rtcomm.js index aa3958e..4e7338e 100644 --- a/src/js/angular-rtcomm.js +++ b/src/js/angular-rtcomm.js @@ -1,5 +1,17 @@ -/* - * This is the main angular-rtcomm module. +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ (function() { angular.module('angular-rtcomm', [ diff --git a/src/js/rtcomm-presence.js b/src/js/rtcomm-presence.js index e54ebc6..98e022b 100644 --- a/src/js/rtcomm-presence.js +++ b/src/js/rtcomm-presence.js @@ -1,3 +1,18 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * The angular-rtcomm-presence module * This has controllers and directives in it. @@ -5,7 +20,7 @@ (function(){ angular .module('angular-rtcomm-presence', [ - 'ui.bootstrap', + 'ui.bootstrap', 'treeControl', 'angular-rtcomm-service']) .directive('rtcommPresence', rtcommPresence); diff --git a/src/js/rtcomm-services.js b/src/js/rtcomm-services.js index bee79b4..e7009ef 100644 --- a/src/js/rtcomm-services.js +++ b/src/js/rtcomm-services.js @@ -16,8 +16,7 @@ requireBase: false}); }) */ .factory('RtcommConfigService', RtcommConfigService) - .factory('RtcommService', RtcommService) - .constant('rtcomm', rtcomm); + .factory('RtcommService', RtcommService); /** * */ @@ -62,7 +61,6 @@ var rtcommDebug = "DEBUG"; var ringtone = null; var ringbacktone = null; - var trickleICE = true; var setConfig = function(config){ providerConfig.server = (typeof config.server !== "undefined")? config.server : providerConfig.server; @@ -80,7 +78,6 @@ broadcastAudio = (typeof config.broadcastAudio !== "undefined")? config.broadcastAudio: broadcastAudio; broadcastVideo = (typeof config.broadcastVideo !== "undefined")? config.broadcastVideo: broadcastVideo; - trickleICE = (typeof config.trickleICE !== "undefined")? config.trickleICE: trickleICE; ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: ringbacktone; ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : ringtone; @@ -115,14 +112,12 @@ getRtcommDebug: function(){return rtcommDebug;}, - isRtcommDisabled : function(){return _disableRtcomm;}, - - getTrickleICE: function(){return trickleICE;} + isRtcommDisabled : function(){return _disableRtcomm;} }; }; - RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; - function RtcommService($rootScope, $log, $http, RtcommConfigService, rtcomm) { + RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService']; + function RtcommService($rootScope, $log, $http, RtcommConfigService) { /** Setup the endpoint provider first **/ var myEndpointProvider = new rtcomm.EndpointProvider(); var endpointProviderInitialized = false; @@ -155,8 +150,7 @@ broadcast : { audio : RtcommConfigService.getBroadcastAudio(), video : RtcommConfigService.getBroadcastVideo() - }, - trickleICE: RtcommConfigService.getTrickleICE() + } }, webrtc : RtcommConfigService.getWebRTCEnabled(), chat : RtcommConfigService.getChatEnabled(), @@ -166,8 +160,7 @@ }; myEndpointProvider.on('reset', function(event_object) { - //The Endpoint provider is destroyed on reset - endpointProviderInitialized = false; + // Should have a reason. _alert({type:'danger', msg: event_object.reason}); }); @@ -280,8 +273,6 @@ }, - 'session:connecting' : callback, - // These are all the WebRTC related events. 'webrtc:connected' : function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); @@ -445,9 +436,7 @@ for (var index = 0; index < sessions.length; index++) { if(sessions[index].endpointUUID === endpointUUID){ - var endpoint = _getEndpoint(endpointUUID); - if(typeof endpoint !== 'undefined') - endpoint.destroy(); + _getEndpoint(endpointUUID).destroy(); // Remove the disconnected endpoint from the list. sessions.splice(index, 1); @@ -867,4 +856,4 @@ }; }; -})(); +})(); \ No newline at end of file diff --git a/src/js/services/rtcomm.service.js b/src/js/services/rtcomm.service.js deleted file mode 100644 index 21db963..0000000 --- a/src/js/services/rtcomm.service.js +++ /dev/null @@ -1,45 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('angular-rtcomm-service') - .factory('RtcommService', RtcommService); - - RtcommService.$inject = ['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; - - /* @ngInject */ - function RtcommService(dependencies) { - var service = { - alert: alert, - setKarmaTesting: setKarmaTesting, - isInitialized: isInitialized, - setConfig: setConfig, - getPresenceMonitor: getPresenceMonitor, - publishPresence: publishPresence, - addToPresenceRecord: addToPresenceRecord, - removeFromPresenceRecord: removeFromPresenceRecord, - setPresenceRecordState: setPresenceRecordState, - getEndpoint: getEndpoint, - destroyEndpoint: destroyEndpoint, - register: register, - unregister: unregister, - joinQueue: joinQueue, - leaveQueue: leaveQueue, - getQueues: getQueues, - sendChatMessage: sendChatMessage, - getChats: getChats, - isWebrtcConnected: isWebrtcConnected, - - - - }; - - return service; - - function - - function() { - - } - } -})(); diff --git a/src/js/services/services.module.js b/src/js/services/services.module.js index 549d7e8..e69de29 100644 --- a/src/js/services/services.module.js +++ b/src/js/services/services.module.js @@ -1,7 +0,0 @@ -// (function() { -// 'use strict'; -// -// angular -// .module('angular-rtcomm-service', []) -// .constant('rtcomm', rtcomm); -// })(); diff --git a/src/js/ui/config.controller.js b/src/js/ui/config.controller.js index b728b45..ab879b5 100644 --- a/src/js/ui/config.controller.js +++ b/src/js/ui/config.controller.js @@ -1,5 +1,18 @@ -/********************************************* Rtcomm Controllers ******************************************************/ - +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /** * This is the controller for config loader. It reads a JSON object and utilizes the RtcommService to set the configuration. * This can also result in the initialization of the endpoint provider if the config JSON object includes a registration name. @@ -32,7 +45,7 @@ RtcommConfigController.$inject = ['RtcommService', '$http', '$scope', '$log']; /* @ngInject */ - function RtcommConfigController(dependencies) { + function RtcommConfigController(RtcommService, $http, $scope, $log) { var vm = this; vm.extendedConfig = null; diff --git a/src/js/ui/endpoint-provider/rtcomm-alert.directive.js b/src/js/ui/endpoint-provider/rtcomm-alert.directive.js index cf48f74..b94c669 100644 --- a/src/js/ui/endpoint-provider/rtcomm-alert.directive.js +++ b/src/js/ui/endpoint-provider/rtcomm-alert.directive.js @@ -1,3 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + (function() { 'use strict'; @@ -11,7 +27,7 @@ restrict: 'E', templateUrl: "templates/rtcomm/rtcomm-alert.html", controller: AlertController, - controllerAs: 'vm', + controllerAs: 'alertVM', bindToController: true }; diff --git a/src/js/ui/endpoint-provider/rtcomm-chat.directive.js b/src/js/ui/endpoint-provider/rtcomm-chat.directive.js deleted file mode 100644 index db2baa5..0000000 --- a/src/js/ui/endpoint-provider/rtcomm-chat.directive.js +++ /dev/null @@ -1,107 +0,0 @@ -/** - * This directive manages the chat portion of a session. The data model for chat - * is maintained in the RtcommService. This directive handles switching between - * active endpoints. - */ -(function() { - 'use strict'; - - angular - .module('angular-rtcomm-ui') - .directive('rtcommChat', rtcommChat); - - rtcommChat.$inject = ['RtcommService', '$log']; - - /* @ngInject */ - function rtcommChat(RtcommService, $log) { - var directive = { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-chat.html', - scope: {}, - link: chatLink, - controller: RtcommChatController, - controllerAs: 'vm', - bindToController: true - }; - - return directive; - - function chatLink(scope, element, attr, ctrl) { - var chatPanel = angular.element(element.find('.panel-body')[0]); - - var bottom = true; - - //Chooses if the scrollbar should be forced to the bottom on the next lifecycle - scope.scrollToBottom = function(flag) { - bottom = flag; - } - - if (chatPanel.length > 0) { - //Watch scroll events - chatPanel.bind('scroll', function() { - if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { - scope.scrollToBottom(true); - } else { - scope.scrollToBottom(false); - } - }); - //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down - scope.$watch('chats', function() { - if (bottom) { - chatPanel.scrollTop(chatPanel.prop('scrollHeight')); - } else { - //In this else, a notification could be sent - } - }, true); - } else { - $log.warn('chatPanel not found: most likely you need to load jquery prior to angular'); - } - } - - } - - RtcommChatController.$inject = ['$scope', 'RtcommService', '$log']; - - /* @ngInject */ - function RtcommChatController($scope, RtcommService, $log) { - var vm = this; - - vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); - - $scope.$on('endpointActivated', function(event, endpointUUID) { - $log.debug('rtcommChat: endpointActivated =' + endpointUUID); - - // The data model for the chat is maintained in the RtcommService. - vm.chats = RtcommService.getChats(endpointUUID); - vm.chatActiveEndpointUUID = endpointUUID; - }); - - $scope.$on('noEndpointActivated', function(event) { - $scope.chats = []; - $scope.chatActiveEndpointUUID = null; - }); - - vm.keySendMessage = function(keyEvent) { - if (keyEvent.which === 13) - $scope.sendMessage(); - }; - - vm.sendMessage = function() { - var chat = { - time: new Date(), - name: RtcommService.getEndpoint($scope.chatActiveEndpointUUID).getLocalEndpointID(), - message: angular.copy($scope.message) - }; - - vm.message = ''; - vm.scrollToBottom(true); - RtcommService.sendChatMessage(chat, $scope.chatActiveEndpointUUID); - } - activate(); - - function activate() { - - } - } -})(); diff --git a/src/js/ui/endpoint-provider/rtcomm-queues.directive.js b/src/js/ui/endpoint-provider/rtcomm-queues.directive.js index 4940109..6fe978c 100644 --- a/src/js/ui/endpoint-provider/rtcomm-queues.directive.js +++ b/src/js/ui/endpoint-provider/rtcomm-queues.directive.js @@ -1,3 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This directive manages call queues. It provides the ability to display all the available queues * (along with their descriptions) and by clicking on a queue, allows an agent (or any type of user) @@ -16,7 +32,7 @@ restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-queues.html', controller: QueuesController, - controllerAs: 'vm', + controllerAs: 'queueVM', bindToController: true }; diff --git a/src/js/ui/endpoint-provider/rtcomm-register.directive.js b/src/js/ui/endpoint-provider/rtcomm-register.directive.js index ec5e861..eb5da41 100644 --- a/src/js/ui/endpoint-provider/rtcomm-register.directive.js +++ b/src/js/ui/endpoint-provider/rtcomm-register.directive.js @@ -1,3 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This directive is used to manage the registration of an endpoint provider. Since the registered name can only * be set on initialization of the endpoint provider, this directive actually controls the initialization of the @@ -16,7 +32,7 @@ restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-register.html', controller: RegisterController, - controllerAs: 'vm', + controllerAs: 'registerVM', bindToController: true }; @@ -26,30 +42,16 @@ RegisterController.$inject = ['RtcommService', '$scope', '$log']; - /* @ngInject */ + // /* @ngInject */ function RegisterController(RtcommService, $scope, $log) { var vm = this; vm.nextAction = 'Register'; - vm.reguserid = ''; - vm.invalid = false; var invalidCharacters = /(\$|#|\+|\/|\\)+/i; //Invalid characters for MQTT Topic Path - //Watch for changes in reguserid - $scope.$watch('reguserid', function() { - - if (vm.reguserid.length < 1 || invalidCharacters.test(vm.reguserid)) { - - vm.invalid = true; - } else { - vm.invalid = false; - } - }); - - vm.onRegClick = function() { if (vm.nextAction === 'Register' && !invalidCharacters.test(vm.reguserid)) { @@ -61,6 +63,17 @@ } }; + //Watch for changes in reguserid + $scope.$watch('registerVM.reguserid', function() { + + if (vm.reguserid.length < 1 || invalidCharacters.test(vm.reguserid)) { + + vm.invalid = true; + } else { + vm.invalid = false; + } + }); + $scope.$on('rtcomm::init', function(event, success, details) { if (success == true) { @@ -75,10 +88,5 @@ vm.reguserid = 'Init failed:' + details; } }); - activate(); - - function activate() { - - } } })(); diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js b/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js index 37f4f07..5a90f90 100644 --- a/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js @@ -1,5 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -/************* Endpoint Provider Directives *******************************/ /** * This directive is used to manage multiple sessions. If you are only supporting at most one session you wont need * this directive. The associated template provides a way to switch between active sessions. The session must be in @@ -19,7 +33,7 @@ restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-sessionmgr.html', controller: SessionManagerController, - controllerAs: 'vm', + controllerAs: 'sessionVM', bindToController: true }; diff --git a/src/js/ui/endpoint.controller.js b/src/js/ui/endpoint.controller.js index 1f32242..f8d62a5 100644 --- a/src/js/ui/endpoint.controller.js +++ b/src/js/ui/endpoint.controller.js @@ -1,3 +1,18 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ (function() { 'use strict'; diff --git a/src/js/ui/endpoint/rtcomm-chat.directive.js b/src/js/ui/endpoint/rtcomm-chat.directive.js new file mode 100644 index 0000000..4d48a46 --- /dev/null +++ b/src/js/ui/endpoint/rtcomm-chat.directive.js @@ -0,0 +1,123 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This directive manages the chat portion of a session. The data model for chat + * is maintained in the RtcommService. This directive handles switching between + * active endpoints. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommChat', rtcommChat); + + rtcommChat.$inject = ['RtcommService', '$log']; + + /* @ngInject */ + function rtcommChat(RtcommService, $log) { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-chat.html', + link: chatLink, + controller: ChatController, + controllerAs: 'chatVM', + bindToController: true + }; + + return directive; + + function chatLink(scope, element, attr, ctrl) { + var chatPanel = angular.element(element.find('.panel-body')[0]); + + var bottom = true; + + //Chooses if the scrollbar should be forced to the bottom on the next lifecycle + ctrl.scrollToBottom = function(flag) { + bottom = flag; + scope.bottom = flag; + + } + + //Watch scroll events + chatPanel.bind('scroll', function() { + if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { + ctrl.scrollToBottom(true); + } else { + ctrl.scrollToBottom(false); + } + }); + + //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down + scope.$watch(function() { + return ctrl.chats + }, function() { + $log.debug('rtcommChat - Link > $watch on chats called'); + if (bottom) { + chatPanel.scrollTop(chatPanel.prop('scrollHeight')); + } else { + //In this else, a notification could be sent + } + }, true); + + } + + } + + //Controller should be used to listen for events from Rtcmo + ChatController.$inject = ['$scope', 'RtcommService', '$log']; + + /* @ngInject */ + function ChatController($scope, RtcommService, $log) { + var vm = this; + + vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); + + vm.keySendMessage = function(keyEvent) { + if (keyEvent.which === 13) + vm.sendMessage(); + }; + + vm.sendMessage = function() { + $log.debug('rtcommChat: sendMessage() -> ' + vm.message); + var chat = { + time: new Date(), + name: RtcommService.getEndpoint(vm.chatActiveEndpointUUID).getLocalEndpointID(), + message: angular.copy(vm.message) + }; + + vm.message = ''; + vm.scrollToBottom(true); + $scope.bottom = true; + RtcommService.sendChatMessage(chat, vm.chatActiveEndpointUUID); + } + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommChat: endpointActivated =' + endpointUUID); + + // The data model for the chat is maintained in the RtcommService. + vm.chats = RtcommService.getChats(endpointUUID); + vm.chatActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.chats = []; + vm.chatActiveEndpointUUID = null; + }); + } +})(); diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status.js b/src/js/ui/endpoint/rtcomm-endpoint-status.js index 09ca073..1a8b002 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status.js @@ -1,3 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This endpoint status controller only shows the active endpoint. The $scope.sessionState always contains the * state of the active endpoint if one exist. It will be one of the following states: @@ -26,7 +42,7 @@ restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', controller: EndpointStatusController, - controllerAs: 'vm', + controllerAs: 'endpointStatusVM', bindToController: true }; diff --git a/src/js/ui/endpoint/rtcomm-iframe.directive.js b/src/js/ui/endpoint/rtcomm-iframe.directive.js index ffe93f7..e69233f 100644 --- a/src/js/ui/endpoint/rtcomm-iframe.directive.js +++ b/src/js/ui/endpoint/rtcomm-iframe.directive.js @@ -1,3 +1,18 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ (function() { 'use strict'; @@ -11,7 +26,7 @@ restrict: 'E', templateUrl: "templates/rtcomm/rtcomm-iframe.html", controller: IFrameController, - controllerAs: 'vm', + controllerAs: 'iframeVM', bindToController: true }; diff --git a/src/js/ui/endpoint/rtcomm-video.directive.js b/src/js/ui/endpoint/rtcomm-video.directive.js index c53ac2f..e7816ec 100644 --- a/src/js/ui/endpoint/rtcomm-video.directive.js +++ b/src/js/ui/endpoint/rtcomm-video.directive.js @@ -1,3 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This directive manages the WebRTC video screen, including both the self view and the remote view. It * also takes care of switching state between endpoints based on which endpoint is "actively" being viewed. @@ -16,7 +32,7 @@ restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-video.html', controller: VideoController, - controllerAs: 'vm', + controllerAs: 'videoVM', bindToController: true }; @@ -25,11 +41,12 @@ VideoController.$inject = ['RtcommService', '$scope', '$log']; - /* @ngInject */ + // /* @ngInject */ function VideoController(RtcommService, $scope, $log) { var vm = this; + $log.debug('VideoController Starting'); vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); - vm.init = function(selfView, remoteView) { + $scope.init = function(selfView, remoteView) { RtcommService.setViewSelector(selfView, remoteView); var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); @@ -48,7 +65,7 @@ RtcommService.setVideoView(endpointUUID); vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); }); - + // $scope.$on('noEndpointActivated', function(event) { vm.avConnected = false; }); diff --git a/src/js/ui/modals/alert-modal.js b/src/js/ui/modals/alert-modal.js index c892965..6e40620 100644 --- a/src/js/ui/modals/alert-modal.js +++ b/src/js/ui/modals/alert-modal.js @@ -1,3 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This modal is displayed on receiving an inbound call. It handles the alerting event. * Note that it can also auto accept requests for enabling A/V. diff --git a/src/js/ui/modals/call-modal.js b/src/js/ui/modals/call-modal.js index 53ef3e2..831a484 100644 --- a/src/js/ui/modals/call-modal.js +++ b/src/js/ui/modals/call-modal.js @@ -1,3 +1,19 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This is a modal controller for placing an outbound call to a static callee such as a queue. */ diff --git a/src/js/ui/ui.module.js b/src/js/ui/ui.module.js index 7bb47db..95b80e1 100644 --- a/src/js/ui/ui.module.js +++ b/src/js/ui/ui.module.js @@ -1,3 +1,18 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* * The angular-rtcomm-ui module * This has controllers and directives in it. diff --git a/src/templates/rtcomm/rtcomm-chat.html b/src/templates/rtcomm/rtcomm-chat.html index b57225b..e0c9fc7 100644 --- a/src/templates/rtcomm/rtcomm-chat.html +++ b/src/templates/rtcomm/rtcomm-chat.html @@ -6,10 +6,10 @@
    -
  • +
  • - {{chat.name}} - + {{chat.name}} + {{chat.time | date:'HH:mm:ss'}}
    @@ -20,9 +20,9 @@ diff --git a/src/templates/rtcomm/rtcomm-endpoint-status.html b/src/templates/rtcomm/rtcomm-endpoint-status.html index d7ca13a..65ca013 100644 --- a/src/templates/rtcomm/rtcomm-endpoint-status.html +++ b/src/templates/rtcomm/rtcomm-endpoint-status.html @@ -1,13 +1,13 @@
    -
    diff --git a/src/templates/rtcomm/rtcomm-register.html b/src/templates/rtcomm/rtcomm-register.html index c6b2c3e..c6c3d66 100644 --- a/src/templates/rtcomm/rtcomm-register.html +++ b/src/templates/rtcomm/rtcomm-register.html @@ -2,9 +2,9 @@
    + placeholder="Enter your ID here..." type="text" ng-model="registerVM.reguserid" ng-disabled="(registerVM.nextAction=='Unregister')"> - +
    diff --git a/src/templates/rtcomm/rtcomm-video.html b/src/templates/rtcomm/rtcomm-video.html index 641c8e4..50406f1 100644 --- a/src/templates/rtcomm/rtcomm-video.html +++ b/src/templates/rtcomm/rtcomm-video.html @@ -3,7 +3,5 @@
- + - - diff --git a/test/rtcomm-register.directive.spec.js b/test/rtcomm-register.directive.spec.js index 7f7af83..5518e48 100644 --- a/test/rtcomm-register.directive.spec.js +++ b/test/rtcomm-register.directive.spec.js @@ -10,9 +10,13 @@ describe('Unit Testing: Register directive', function(){ }] )); - it('chat directive should be available', function(){ + it('directive should compile', function(){ var element = $compile('')($rootScope); $rootScope.$digest(); expect(element.html()).to.include('id="register-input"'); }); + + it('should register') + + }) From 646612394ae9a6b38288c0253ccd0689709c7fee Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Fri, 4 Mar 2016 15:58:16 -0500 Subject: [PATCH 03/21] Removing the name directives from the file name, directives are in a stable state... for now --- dist/angular-rtcomm.js | 65 +++++++++---------- dist/angular-rtcomm.min.js | 4 +- src/js/ui/config.controller.js | 5 -- ...omm-alert.directive.js => rtcomm-alert.js} | 5 -- .../rtcomm-directives.module.js | 9 --- ...m-queues.directive.js => rtcomm-queues.js} | 10 +-- ...gister.directive.js => rtcomm-register.js} | 0 ...directive.js => rtcomm-session-manager.js} | 5 -- src/js/ui/endpoint.controller.js | 56 +++++++--------- ...tcomm-chat.directive.js => rtcomm-chat.js} | 0 src/js/ui/endpoint/rtcomm-endpoint-status.js | 8 --- ...m-iframe.directive.js => rtcomm-iframe.js} | 11 +--- ...omm-video.directive.js => rtcomm-video.js} | 0 src/js/ui/modals/call-modal.js | 4 -- src/templates/rtcomm/rtcomm-alert.html | 2 +- src/templates/rtcomm/rtcomm-iframe.html | 12 ++-- src/templates/rtcomm/rtcomm-queues.html | 4 +- 17 files changed, 73 insertions(+), 127 deletions(-) rename src/js/ui/endpoint-provider/{rtcomm-alert.directive.js => rtcomm-alert.js} (96%) delete mode 100644 src/js/ui/endpoint-provider/rtcomm-directives.module.js rename src/js/ui/endpoint-provider/{rtcomm-queues.directive.js => rtcomm-queues.js} (96%) rename src/js/ui/endpoint-provider/{rtcomm-register.directive.js => rtcomm-register.js} (100%) rename src/js/ui/endpoint-provider/{rtcomm-session-manager.directive.js => rtcomm-session-manager.js} (98%) rename src/js/ui/endpoint/{rtcomm-chat.directive.js => rtcomm-chat.js} (100%) rename src/js/ui/endpoint/{rtcomm-iframe.directive.js => rtcomm-iframe.js} (93%) rename src/js/ui/endpoint/{rtcomm-video.directive.js => rtcomm-video.js} (100%) diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index d000e05..0041b90 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -1300,7 +1300,7 @@ angular * queuePublishedPresence - will add to the presence document information about what queues this person joins. * queueFilter - If defined, this specifies which queues should be joined. All others will be ignored. */ - vm.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { + $scope.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); vm.autoJoinQueues = autoJoinQueues; vm.queuePublishPresence = queuePublishPresence; @@ -1361,7 +1361,7 @@ angular if (vm.rQueues[index].active === true) { vm.queuePresenceData.push({ 'name': "queue", - 'value': $scope.rQueues[index].endpointID + 'value': vm.rQueues[index].endpointID }); } } @@ -1626,21 +1626,20 @@ angular /* @ngInject */ function RtcommEndpointController(RtcommService, $http, $rootScope, $scope, $log) { - var vm = this; - vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(vm.epCtrlActiveEndpointUUID); - vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); + $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - vm.disconnect = function() { - $log.debug('Disconnecting call for endpoint: ' + vm.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).disconnect(); + $scope.disconnect = function() { + $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); }; - vm.toggleAV = function() { - $log.debug('Enable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); + $scope.toggleAV = function() { + $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - if (vm.epCtrlAVConnected == false) { - RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { + if ($scope.epCtrlAVConnected == false) { + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { if (!value) { $log.debug('Enable failed: ', message); RtcommService.alert({ @@ -1650,50 +1649,50 @@ angular } }); } else { - $log.debug('Disable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.disable(); + $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); } }; $scope.$on('session:started', function(event, eventObject) { $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:started'; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:started'; } }); $scope.$on('session:stopped', function(event, eventObject) { $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:stopped'; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:stopped'; } }); $scope.$on('session:failed', function(event, eventObject) { $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:failed'; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:failed'; } }); $scope.$on('webrtc:connected', function(event, eventObject) { - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - vm.epCtrlAVConnected = true; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = true; }); $scope.$on('webrtc:disconnected', function(event, eventObject) { - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - vm.epCtrlAVConnected = false; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = false; }); $scope.$on('endpointActivated', function(event, endpointUUID) { - vm.epCtrlActiveEndpointUUID = endpointUUID; - vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); + $scope.epCtrlActiveEndpointUUID = endpointUUID; + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); }); $scope.$on('noEndpointActivated', function(event) { - vm.epCtrlAVConnected = false; + $scope.epCtrlAVConnected = false; }); activate(); @@ -2029,10 +2028,10 @@ angular return directive; } - IFrameController.$inject = ['RtcommService', '$scope', '$log']; + IFrameController.$inject = ['RtcommService', '$sce', '$location', '$window','$scope', '$log']; /* @ngInject */ - function IFrameController(RtcommService, $scope, $log) { + function IFrameController(RtcommService, $sce, $location, $window, $scope, $log) { var vm = this; vm.iframeActiveEndpointUUID = RtcommService.getActiveEndpoint(); vm.iframeURL = null; @@ -2043,7 +2042,7 @@ angular * syncSourcing means you a providing the URL source but no UI. Typically used in * customer/agent scenarios. */ - vm.init = function(syncSource) { + $scope.init = function(syncSource) { if (syncSource == true) { vm.syncSource = true; vm.initiframeURL = $location.absUrl(); // init to current URL @@ -2433,7 +2432,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-iframe.html', - "
URL Sharing
" + "
URL Sharing
" ); @@ -2448,7 +2447,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-queues.html', - "
Queues
" + "
Queues
" ); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index ae7e4f2..9368e5e 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -18,5 +18,5 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){function e(){}var f=this;f.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+f.configURL),f.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),f.configURL=a,"undefined"!=typeof b&&(f.extendedConfig=b),f.getConfig()},f.getConfig=function(){b.get(f.configURL).success(function(b){null!=f.extendedConfig&&(angular.extend(b,f.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})},e()}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.alerts=[],e.addAlert=function(a){e.alerts.push(a)},e.closeAlert=function(a){e.alerts.splice(a,1)},b.$on("rtcomm::alert",function(a,b){e.addAlert(b)}),d()}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.rQueues=[],e.autoJoinQueues=!1,e.queuePresenceData=[],e.queuePublishPresence=!1,e.queueFilter=null,e.init=function(a,b,d){c.debug("rtcommQueues: autoJoinQueues = "+a),e.autoJoinQueues=a,e.queuePublishPresence=b,"undefined"!=typeof d&&(e.queueFilter=d)},e.filterOutQueue=function(a){var b=!0;if(null!=e.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}function c(){}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"],c()}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.iframeActiveEndpointUUID=a.getActiveEndpoint(),e.iframeURL=null,e.initiframeURL=null,e.syncSource=!1,e.init=function(a){1==a&&(e.syncSource=!0,e.initiframeURL=$location.absUrl())},e.setURL=function(b){c.debug("rtcommIframe: setURL: newURL: "+b),a.putIframeURL(e.iframeActiveEndpointUUID,b),e.iframeURL=$sce.trustAsResourceUrl(b)},e.forward=function(){},e.backward=function(){},b.$on("session:started",function(b,d){c.debug("session:started received: endpointID = "+d.endpoint.id),1==e.syncSource&&a.putIframeURL(d.endpoint.id,e.initiframeURL)}),b.$on("endpointActivated",function(b,d){c.debug("rtcommIframe: endpointActivated ="+d),0==e.syncSource&&(e.iframeURL=$sce.trustAsResourceUrl(a.getIframeURL(d)),e.iframeActiveEndpointUUID=d)}),b.$on("noEndpointActivated",function(a){0==e.syncSource&&(e.iframeURL=$sce.trustAsResourceUrl("about:blank"),e.iframeActiveEndpointUUID=null)}),b.$on("rtcomm::iframeUpdate",function(a,b,d){0==e.syncSource?(c.debug("rtcomm::iframeUpdate: "+d),d+="?disableRtcomm=true",e.iframeURL=$sce.trustAsResourceUrl(d)):(c.debug("rtcomm::iframeUpdate: load this url in a new tab: "+d),$window.open($sce.trustAsResourceUrl(d),"_blank"))}),d()}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint()),b.init=function(b,c){a.setViewSelector(b,c);var d=a.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&a.setVideoView(d)};var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())}),b.$on("noEndpointActivated",function(a){d.avConnected=!1}),b.$on("webrtc:connected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!0)}),b.$on("webrtc:disconnected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!1)})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){function f(){}var g=this;g.alertingEndpointUUID=null,g.autoAnswerNewMedia=!1,g.alertActiveEndpointUUID=a.getActiveEndpoint(),g.caller=null,g.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),g.autoAnswerNewMedia=a},g.showAlerting=function(d){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return g.caller}}});f.result.then(function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.reject(),b=null)})},d.$on("endpointActivated",function(a,b){g.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){g.alertActiveEndpointUUID==b.endpoint.id&&0==g.autoAnswerNewMedia||g.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+g.autoAnswerNewMedia),g.caller=b.endpoint.getRemoteEndpointID(),g.alertingEndpointUUID=b.endpoint.id,g.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())}),f()}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){function b(){}var c=this;c.calleeID=null,c.callerID=null,c.enableCallModel=!1,c.mediaToEnable=["chat"],c.init=function(a,b){c.calleeID=a,"undefined"!=typeof b&&(c.mediaToEnable=b)},c.placeCall=function(a){var b=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});b.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+c.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==c.callerID&&"undefined"!=typeof a&&""!=a&&(c.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(c.calleeID,c.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,b,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?c.enableCallModel=!0:c.enableCallModel=!1}),$scope.$on("session:started",function(a,b){c.enableCallModel=!1}),$scope.$on("session:stopped",function(a,b){c.enableCallModel=!0}),b()}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), -a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file +!function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){function e(){}var f=this;f.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+f.configURL),f.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),f.configURL=a,"undefined"!=typeof b&&(f.extendedConfig=b),f.getConfig()},f.getConfig=function(){b.get(f.configURL).success(function(b){null!=f.extendedConfig&&(angular.extend(b,f.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})},e()}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.alerts=[],e.addAlert=function(a){e.alerts.push(a)},e.closeAlert=function(a){e.alerts.splice(a,1)},b.$on("rtcomm::alert",function(a,b){e.addAlert(b)}),d()}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.rQueues=[],e.autoJoinQueues=!1,e.queuePresenceData=[],e.queuePublishPresence=!1,e.queueFilter=null,b.init=function(a,b,d){c.debug("rtcommQueues: autoJoinQueues = "+a),e.autoJoinQueues=a,e.queuePublishPresence=b,"undefined"!=typeof d&&(e.queueFilter=d)},e.filterOutQueue=function(a){var b=!0;if(null!=e.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}function c(){}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"],c()}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){function g(){}var h=this;h.iframeActiveEndpointUUID=a.getActiveEndpoint(),h.iframeURL=null,h.initiframeURL=null,h.syncSource=!1,e.init=function(a){1==a&&(h.syncSource=!0,h.initiframeURL=c.absUrl())},h.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(h.iframeActiveEndpointUUID,c),h.iframeURL=b.trustAsResourceUrl(c)},h.forward=function(){},h.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==h.syncSource&&a.putIframeURL(c.endpoint.id,h.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==h.syncSource&&(h.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),h.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==h.syncSource&&(h.iframeURL=b.trustAsResourceUrl("about:blank"),h.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){0==h.syncSource?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",h.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))}),g()}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint()),b.init=function(b,c){a.setViewSelector(b,c);var d=a.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&a.setVideoView(d)};var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())}),b.$on("noEndpointActivated",function(a){d.avConnected=!1}),b.$on("webrtc:connected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!0)}),b.$on("webrtc:disconnected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!1)})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){function f(){}var g=this;g.alertingEndpointUUID=null,g.autoAnswerNewMedia=!1,g.alertActiveEndpointUUID=a.getActiveEndpoint(),g.caller=null,g.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),g.autoAnswerNewMedia=a},g.showAlerting=function(d){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return g.caller}}});f.result.then(function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.reject(),b=null)})},d.$on("endpointActivated",function(a,b){g.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){g.alertActiveEndpointUUID==b.endpoint.id&&0==g.autoAnswerNewMedia||g.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+g.autoAnswerNewMedia),g.caller=b.endpoint.getRemoteEndpointID(),g.alertingEndpointUUID=b.endpoint.id,g.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())}),f()}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){function b(){}var c=this;c.calleeID=null,c.callerID=null,c.enableCallModel=!1,c.mediaToEnable=["chat"],c.init=function(a,b){c.calleeID=a,"undefined"!=typeof b&&(c.mediaToEnable=b)},c.placeCall=function(a){var b=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});b.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+c.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==c.callerID&&"undefined"!=typeof a&&""!=a&&(c.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(c.calleeID,c.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,b,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?c.enableCallModel=!0:c.enableCallModel=!1}),$scope.$on("session:started",function(a,b){c.enableCallModel=!1}),$scope.$on("session:stopped",function(a,b){c.enableCallModel=!0}),b()}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), +a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/ui/config.controller.js b/src/js/ui/config.controller.js index ab879b5..7f5e2eb 100644 --- a/src/js/ui/config.controller.js +++ b/src/js/ui/config.controller.js @@ -80,10 +80,5 @@ $log.debug('RtcommConfigController: error accessing config: ' + status); }); }; - activate(); - - function activate() { - - } } })(); diff --git a/src/js/ui/endpoint-provider/rtcomm-alert.directive.js b/src/js/ui/endpoint-provider/rtcomm-alert.js similarity index 96% rename from src/js/ui/endpoint-provider/rtcomm-alert.directive.js rename to src/js/ui/endpoint-provider/rtcomm-alert.js index b94c669..3a73922 100644 --- a/src/js/ui/endpoint-provider/rtcomm-alert.directive.js +++ b/src/js/ui/endpoint-provider/rtcomm-alert.js @@ -49,10 +49,5 @@ $scope.$on('rtcomm::alert', function(event, eventObject) { vm.addAlert(eventObject); }); - activate(); - - function activate() { - - } } })(); diff --git a/src/js/ui/endpoint-provider/rtcomm-directives.module.js b/src/js/ui/endpoint-provider/rtcomm-directives.module.js deleted file mode 100644 index cc46afb..0000000 --- a/src/js/ui/endpoint-provider/rtcomm-directives.module.js +++ /dev/null @@ -1,9 +0,0 @@ -// (function() { -// 'use strict'; -// -// angular -// .module('angular-rtcomm-ui', [ -// 'ui.bootstrap', -// 'angular-rtcomm-service' -// ]); -// })(); diff --git a/src/js/ui/endpoint-provider/rtcomm-queues.directive.js b/src/js/ui/endpoint-provider/rtcomm-queues.js similarity index 96% rename from src/js/ui/endpoint-provider/rtcomm-queues.directive.js rename to src/js/ui/endpoint-provider/rtcomm-queues.js index 6fe978c..55df5a7 100644 --- a/src/js/ui/endpoint-provider/rtcomm-queues.directive.js +++ b/src/js/ui/endpoint-provider/rtcomm-queues.js @@ -60,7 +60,7 @@ * queuePublishedPresence - will add to the presence document information about what queues this person joins. * queueFilter - If defined, this specifies which queues should be joined. All others will be ignored. */ - vm.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { + $scope.init = function(autoJoinQueues, queuePublishPresence, queueFilter) { $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); vm.autoJoinQueues = autoJoinQueues; vm.queuePublishPresence = queuePublishPresence; @@ -121,7 +121,7 @@ if (vm.rQueues[index].active === true) { vm.queuePresenceData.push({ 'name': "queue", - 'value': $scope.rQueues[index].endpointID + 'value': vm.rQueues[index].endpointID }); } } @@ -158,11 +158,5 @@ } }); - - activate(); - - function activate() { - - } } })(); diff --git a/src/js/ui/endpoint-provider/rtcomm-register.directive.js b/src/js/ui/endpoint-provider/rtcomm-register.js similarity index 100% rename from src/js/ui/endpoint-provider/rtcomm-register.directive.js rename to src/js/ui/endpoint-provider/rtcomm-register.js diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js b/src/js/ui/endpoint-provider/rtcomm-session-manager.js similarity index 98% rename from src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js rename to src/js/ui/endpoint-provider/rtcomm-session-manager.js index 5a90f90..bd37df7 100644 --- a/src/js/ui/endpoint-provider/rtcomm-session-manager.directive.js +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager.js @@ -90,10 +90,5 @@ vm.updatePresence(); }); - activate(); - - function activate() { - - } } })(); diff --git a/src/js/ui/endpoint.controller.js b/src/js/ui/endpoint.controller.js index f8d62a5..62ff203 100644 --- a/src/js/ui/endpoint.controller.js +++ b/src/js/ui/endpoint.controller.js @@ -24,21 +24,20 @@ /* @ngInject */ function RtcommEndpointController(RtcommService, $http, $rootScope, $scope, $log) { - var vm = this; - vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(vm.epCtrlActiveEndpointUUID); - vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); + $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - vm.disconnect = function() { - $log.debug('Disconnecting call for endpoint: ' + vm.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).disconnect(); + $scope.disconnect = function() { + $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); }; - vm.toggleAV = function() { - $log.debug('Enable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); + $scope.toggleAV = function() { + $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - if (vm.epCtrlAVConnected == false) { - RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { + if ($scope.epCtrlAVConnected == false) { + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { if (!value) { $log.debug('Enable failed: ', message); RtcommService.alert({ @@ -48,55 +47,50 @@ } }); } else { - $log.debug('Disable AV for endpoint: ' + vm.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint(vm.epCtrlActiveEndpointUUID).webrtc.disable(); + $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); } }; $scope.$on('session:started', function(event, eventObject) { $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:started'; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:started'; } }); $scope.$on('session:stopped', function(event, eventObject) { $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:stopped'; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:stopped'; } }); $scope.$on('session:failed', function(event, eventObject) { $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:failed'; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:failed'; } }); $scope.$on('webrtc:connected', function(event, eventObject) { - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - vm.epCtrlAVConnected = true; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = true; }); $scope.$on('webrtc:disconnected', function(event, eventObject) { - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - vm.epCtrlAVConnected = false; + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = false; }); $scope.$on('endpointActivated', function(event, endpointUUID) { - vm.epCtrlActiveEndpointUUID = endpointUUID; - vm.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); + $scope.epCtrlActiveEndpointUUID = endpointUUID; + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); }); $scope.$on('noEndpointActivated', function(event) { - vm.epCtrlAVConnected = false; + $scope.epCtrlAVConnected = false; }); - activate(); - - function activate() { - - } } })(); diff --git a/src/js/ui/endpoint/rtcomm-chat.directive.js b/src/js/ui/endpoint/rtcomm-chat.js similarity index 100% rename from src/js/ui/endpoint/rtcomm-chat.directive.js rename to src/js/ui/endpoint/rtcomm-chat.js diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status.js b/src/js/ui/endpoint/rtcomm-endpoint-status.js index 1a8b002..b8e6086 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status.js @@ -153,14 +153,6 @@ vm.epCtrlRemoteEndpointID = null; } }); - - - - } - activate(); - - function activate() { - } })(); diff --git a/src/js/ui/endpoint/rtcomm-iframe.directive.js b/src/js/ui/endpoint/rtcomm-iframe.js similarity index 93% rename from src/js/ui/endpoint/rtcomm-iframe.directive.js rename to src/js/ui/endpoint/rtcomm-iframe.js index e69233f..45df466 100644 --- a/src/js/ui/endpoint/rtcomm-iframe.directive.js +++ b/src/js/ui/endpoint/rtcomm-iframe.js @@ -33,10 +33,10 @@ return directive; } - IFrameController.$inject = ['RtcommService', '$scope', '$log']; + IFrameController.$inject = ['RtcommService', '$sce', '$location', '$window','$scope', '$log']; /* @ngInject */ - function IFrameController(RtcommService, $scope, $log) { + function IFrameController(RtcommService, $sce, $location, $window, $scope, $log) { var vm = this; vm.iframeActiveEndpointUUID = RtcommService.getActiveEndpoint(); vm.iframeURL = null; @@ -47,7 +47,7 @@ * syncSourcing means you a providing the URL source but no UI. Typically used in * customer/agent scenarios. */ - vm.init = function(syncSource) { + $scope.init = function(syncSource) { if (syncSource == true) { vm.syncSource = true; vm.initiframeURL = $location.absUrl(); // init to current URL @@ -101,10 +101,5 @@ $window.open($sce.trustAsResourceUrl(url), '_blank'); } }); - activate(); - - function activate() { - - } } })(); diff --git a/src/js/ui/endpoint/rtcomm-video.directive.js b/src/js/ui/endpoint/rtcomm-video.js similarity index 100% rename from src/js/ui/endpoint/rtcomm-video.directive.js rename to src/js/ui/endpoint/rtcomm-video.js diff --git a/src/js/ui/modals/call-modal.js b/src/js/ui/modals/call-modal.js index 831a484..0075329 100644 --- a/src/js/ui/modals/call-modal.js +++ b/src/js/ui/modals/call-modal.js @@ -85,11 +85,7 @@ $scope.$on('session:stopped', function(event, eventObject) { vm.enableCallModel = true; }); - activate(); - function activate() { - - } } function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { diff --git a/src/templates/rtcomm/rtcomm-alert.html b/src/templates/rtcomm/rtcomm-alert.html index e10be0f..68ebf62 100644 --- a/src/templates/rtcomm/rtcomm-alert.html +++ b/src/templates/rtcomm/rtcomm-alert.html @@ -1,3 +1,3 @@
- {{alert.msg}} + {{alert.msg}}
diff --git a/src/templates/rtcomm/rtcomm-iframe.html b/src/templates/rtcomm/rtcomm-iframe.html index dfba673..33e2166 100644 --- a/src/templates/rtcomm/rtcomm-iframe.html +++ b/src/templates/rtcomm/rtcomm-iframe.html @@ -4,29 +4,29 @@ URL Sharing
- +
-
-
- + - +
- \ No newline at end of file + diff --git a/src/templates/rtcomm/rtcomm-queues.html b/src/templates/rtcomm/rtcomm-queues.html index 394cc30..76b9dad 100644 --- a/src/templates/rtcomm/rtcomm-queues.html +++ b/src/templates/rtcomm/rtcomm-queues.html @@ -4,7 +4,7 @@ Queues
- +
- + From 9c9d0d21dc1772cd35a0306f49df464ba2a2e7ae Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Mon, 7 Mar 2016 10:34:39 -0500 Subject: [PATCH 04/21] Starting new ui directive structure -> Folders endpoint-provider, endpoint and modal directive, also finished test for the 'rtcomm-register' directive --- Gruntfile.js | 2 +- dist/angular-rtcomm.js | 91 ++------- dist/angular-rtcomm.min.js | 2 +- karma.conf.js | 6 +- package.json | 1 + ...lar-rtcomm.js => angular-rtcomm.module.js} | 0 src/js/rtcomm-services.js | 2 +- src/js/services/rtcomm.event.service.js | 0 src/js/services/services.module.js | 0 .../{ => rtcomm-alert}/rtcomm-alert.js | 0 .../rtcomm-alert}/rtcomm-alert.spec.js | 2 +- .../{ => rtcomm-queues}/rtcomm-queues.js | 0 .../rtcomm-queues}/rtcomm-queues.spec.js | 0 .../{ => rtcomm-register}/rtcomm-register.js | 13 +- .../rtcomm-register/rtcomm-register.spec.js | 172 ++++++++++++++++++ .../rtcomm-session-manager.js | 0 .../rtcomm-session-manager.spec.js | 2 +- .../endpoint/{ => rtcomm-chat}/rtcomm-chat.js | 0 .../endpoint/rtcomm-chat}/rtcomm-chat.spec.js | 0 .../rtcomm-endpoint-status.js | 0 .../rtcomm-endpoint-status.spec.js | 0 .../{ => rtcomm-iframe}/rtcomm-iframe.js | 0 .../rtcomm-iframe}/rtcomm-iframe.spec.js | 0 .../{ => rtcomm-video}/rtcomm-video.js | 0 .../rtcomm-video}/rtcomm-video.spec.js | 0 .../modals/{ => alert-modal}/alert-modal.js | 0 .../alert-modal}/rtcomm-alert-modal.spec.js | 0 .../ui/modals/{ => call-modal}/call-modal.js | 0 test/rtcomm-config.spec.js | 13 -- test/rtcomm-presence.directive.spec.js | 1 - test/rtcomm-register.directive.spec.js | 22 --- test/rtcomm-service.spec.js | 27 --- test/sample.html | 126 ------------- test/sampleConfig.json | 9 - test/testChat.js | 29 --- test/testRtcommServiceSpec.js | 127 ------------- 36 files changed, 205 insertions(+), 442 deletions(-) rename src/js/{angular-rtcomm.js => angular-rtcomm.module.js} (100%) delete mode 100644 src/js/services/rtcomm.event.service.js delete mode 100644 src/js/services/services.module.js rename src/js/ui/endpoint-provider/{ => rtcomm-alert}/rtcomm-alert.js (100%) rename {test => src/js/ui/endpoint-provider/rtcomm-alert}/rtcomm-alert.spec.js (87%) rename src/js/ui/endpoint-provider/{ => rtcomm-queues}/rtcomm-queues.js (100%) rename {test => src/js/ui/endpoint-provider/rtcomm-queues}/rtcomm-queues.spec.js (100%) rename src/js/ui/endpoint-provider/{ => rtcomm-register}/rtcomm-register.js (92%) create mode 100644 src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js rename src/js/ui/endpoint-provider/{ => rtcomm-session-manager}/rtcomm-session-manager.js (100%) rename {test => src/js/ui/endpoint-provider/rtcomm-session-manager}/rtcomm-session-manager.spec.js (94%) rename src/js/ui/endpoint/{ => rtcomm-chat}/rtcomm-chat.js (100%) rename {test => src/js/ui/endpoint/rtcomm-chat}/rtcomm-chat.spec.js (100%) rename src/js/ui/endpoint/{ => rtcomm-endpoint-status}/rtcomm-endpoint-status.js (100%) rename {test => src/js/ui/endpoint/rtcomm-endpoint-status}/rtcomm-endpoint-status.spec.js (100%) rename src/js/ui/endpoint/{ => rtcomm-iframe}/rtcomm-iframe.js (100%) rename {test => src/js/ui/endpoint/rtcomm-iframe}/rtcomm-iframe.spec.js (100%) rename src/js/ui/endpoint/{ => rtcomm-video}/rtcomm-video.js (100%) rename {test => src/js/ui/endpoint/rtcomm-video}/rtcomm-video.spec.js (100%) rename src/js/ui/modals/{ => alert-modal}/alert-modal.js (100%) rename {test => src/js/ui/modals/alert-modal}/rtcomm-alert-modal.spec.js (100%) rename src/js/ui/modals/{ => call-modal}/call-modal.js (100%) delete mode 100644 test/rtcomm-config.spec.js delete mode 100644 test/rtcomm-presence.directive.spec.js delete mode 100644 test/rtcomm-register.directive.spec.js delete mode 100644 test/rtcomm-service.spec.js delete mode 100644 test/sample.html delete mode 100644 test/sampleConfig.json delete mode 100644 test/testChat.js delete mode 100644 test/testRtcommServiceSpec.js diff --git a/Gruntfile.js b/Gruntfile.js index a74c8dd..b45567c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -40,7 +40,7 @@ module.exports = function(grunt) { }, dist: { // src: ['<%= dirs.src %>/*.js', '<%= dirs.src %>/**/*.js'], - src: ['<%= dirs.src %>/js/**/*.module.js', '<%= dirs.src %>/js/**/*.js'], + src: ['<%= dirs.src %>/js/**/*.module.js', '<%= dirs.src %>/js/**/*.js', '!**/*.spec.js'], dest: '<%= dirs.dest %>/<%= pkg.name %>.js' } }, diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 0041b90..44a6a5b 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -18,17 +18,6 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ - -// (function() { -// 'use strict'; -// -// angular -// .module('angular-rtcomm-ui', [ -// 'ui.bootstrap', -// 'angular-rtcomm-service' -// ]); -// })(); - /** * (C) Copyright IBM Corporation 2016. * @@ -44,17 +33,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * The angular-rtcomm-ui module - * This has controllers and directives in it. - */ -(function(){ - -angular - .module('angular-rtcomm-ui', [ +(function() { + angular.module('angular-rtcomm', [ 'ui.bootstrap', - 'angular-rtcomm-service']); - + 'treeControl', + 'angular-rtcomm-ui', + 'angular-rtcomm-presence', + 'angular-rtcomm-service' + ]); })(); /** @@ -72,14 +58,17 @@ angular * See the License for the specific language governing permissions and * limitations under the License. */ -(function() { - angular.module('angular-rtcomm', [ +/* + * The angular-rtcomm-ui module + * This has controllers and directives in it. + */ +(function(){ + +angular + .module('angular-rtcomm-ui', [ 'ui.bootstrap', - 'treeControl', - 'angular-rtcomm-ui', - 'angular-rtcomm-presence', - 'angular-rtcomm-service' - ]); + 'angular-rtcomm-service']); + })(); /** @@ -1088,7 +1077,6 @@ angular }; })(); - /** * (C) Copyright IBM Corporation 2016. * @@ -1171,11 +1159,6 @@ angular $log.debug('RtcommConfigController: error accessing config: ' + status); }); }; - activate(); - - function activate() { - - } } })(); @@ -1230,11 +1213,6 @@ angular $scope.$on('rtcomm::alert', function(event, eventObject) { vm.addAlert(eventObject); }); - activate(); - - function activate() { - - } } })(); @@ -1398,12 +1376,6 @@ angular } }); - - activate(); - - function activate() { - - } } })(); @@ -1592,11 +1564,6 @@ angular vm.updatePresence(); }); - activate(); - - function activate() { - - } } })(); @@ -1694,11 +1661,6 @@ angular $scope.$on('noEndpointActivated', function(event) { $scope.epCtrlAVConnected = false; }); - activate(); - - function activate() { - - } } })(); @@ -1981,14 +1943,6 @@ angular vm.epCtrlRemoteEndpointID = null; } }); - - - - } - activate(); - - function activate() { - } })(); @@ -2096,11 +2050,6 @@ angular $window.open($sce.trustAsResourceUrl(url), '_blank'); } }); - activate(); - - function activate() { - - } } })(); @@ -2394,11 +2343,7 @@ angular $scope.$on('session:stopped', function(event, eventObject) { vm.enableCallModel = true; }); - activate(); - - function activate() { - } } function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { @@ -2417,7 +2362,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac 'use strict'; $templateCache.put('templates/rtcomm/rtcomm-alert.html', - "
{{alert.msg}}
" + "
{{alert.msg}}
" ); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index 9368e5e..f2fbe32 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -18,5 +18,5 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){function e(){}var f=this;f.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+f.configURL),f.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),f.configURL=a,"undefined"!=typeof b&&(f.extendedConfig=b),f.getConfig()},f.getConfig=function(){b.get(f.configURL).success(function(b){null!=f.extendedConfig&&(angular.extend(b,f.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})},e()}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.alerts=[],e.addAlert=function(a){e.alerts.push(a)},e.closeAlert=function(a){e.alerts.splice(a,1)},b.$on("rtcomm::alert",function(a,b){e.addAlert(b)}),d()}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){function d(){}var e=this;e.rQueues=[],e.autoJoinQueues=!1,e.queuePresenceData=[],e.queuePublishPresence=!1,e.queueFilter=null,b.init=function(a,b,d){c.debug("rtcommQueues: autoJoinQueues = "+a),e.autoJoinQueues=a,e.queuePublishPresence=b,"undefined"!=typeof d&&(e.queueFilter=d)},e.filterOutQueue=function(a){var b=!0;if(null!=e.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}function c(){}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"],c()}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){function g(){}var h=this;h.iframeActiveEndpointUUID=a.getActiveEndpoint(),h.iframeURL=null,h.initiframeURL=null,h.syncSource=!1,e.init=function(a){1==a&&(h.syncSource=!0,h.initiframeURL=c.absUrl())},h.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(h.iframeActiveEndpointUUID,c),h.iframeURL=b.trustAsResourceUrl(c)},h.forward=function(){},h.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==h.syncSource&&a.putIframeURL(c.endpoint.id,h.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==h.syncSource&&(h.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),h.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==h.syncSource&&(h.iframeURL=b.trustAsResourceUrl("about:blank"),h.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){0==h.syncSource?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",h.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))}),g()}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint()),b.init=function(b,c){a.setViewSelector(b,c);var d=a.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&a.setVideoView(d)};var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())}),b.$on("noEndpointActivated",function(a){d.avConnected=!1}),b.$on("webrtc:connected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!0)}),b.$on("webrtc:disconnected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!1)})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){function f(){}var g=this;g.alertingEndpointUUID=null,g.autoAnswerNewMedia=!1,g.alertActiveEndpointUUID=a.getActiveEndpoint(),g.caller=null,g.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),g.autoAnswerNewMedia=a},g.showAlerting=function(d){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return g.caller}}});f.result.then(function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.reject(),b=null)})},d.$on("endpointActivated",function(a,b){g.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){g.alertActiveEndpointUUID==b.endpoint.id&&0==g.autoAnswerNewMedia||g.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+g.autoAnswerNewMedia),g.caller=b.endpoint.getRemoteEndpointID(),g.alertingEndpointUUID=b.endpoint.id,g.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())}),f()}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){function b(){}var c=this;c.calleeID=null,c.callerID=null,c.enableCallModel=!1,c.mediaToEnable=["chat"],c.init=function(a,b){c.calleeID=a,"undefined"!=typeof b&&(c.mediaToEnable=b)},c.placeCall=function(a){var b=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});b.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+c.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==c.callerID&&"undefined"!=typeof a&&""!=a&&(c.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(c.calleeID,c.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,b,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?c.enableCallModel=!0:c.enableCallModel=!1}),$scope.$on("session:started",function(a,b){c.enableCallModel=!1}),$scope.$on("session:stopped",function(a,b){c.enableCallModel=!0}),b()}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.alerts=[],d.addAlert=function(a){d.alerts.push(a)},d.closeAlert=function(a){d.alerts.splice(a,1)},b.$on("rtcomm::alert",function(a,b){d.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){1==a&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){0==g.syncSource?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint()),b.init=function(b,c){a.setViewSelector(b,c);var d=a.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&a.setVideoView(d)};var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())}),b.$on("noEndpointActivated",function(a){d.avConnected=!1}),b.$on("webrtc:connected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!0)}),b.$on("webrtc:disconnected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!1)})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){function f(){}var g=this;g.alertingEndpointUUID=null,g.autoAnswerNewMedia=!1,g.alertActiveEndpointUUID=a.getActiveEndpoint(),g.caller=null,g.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),g.autoAnswerNewMedia=a},g.showAlerting=function(d){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return g.caller}}});f.result.then(function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.reject(),b=null)})},d.$on("endpointActivated",function(a,b){g.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){g.alertActiveEndpointUUID==b.endpoint.id&&0==g.autoAnswerNewMedia||g.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+g.autoAnswerNewMedia),g.caller=b.endpoint.getRemoteEndpointID(),g.alertingEndpointUUID=b.endpoint.id,g.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())}),f()}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){var b=this;b.calleeID=null,b.callerID=null,b.enableCallModel=!1,b.mediaToEnable=["chat"],b.init=function(a,c){b.calleeID=a,"undefined"!=typeof c&&(b.mediaToEnable=c)},b.placeCall=function(a){var c=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});c.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+b.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==b.callerID&&"undefined"!=typeof a&&""!=a&&(b.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(b.calleeID,b.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,c,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?b.enableCallModel=!0:b.enableCallModel=!1}),$scope.$on("session:started",function(a,c){b.enableCallModel=!1}),$scope.$on("session:stopped",function(a,c){b.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 81a2ef3..0cdc2bb 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,7 +10,7 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha', 'chai', 'sinon'], - reports: ['spec'], + reporters: ['spec'], // list of files / patterns to load in the browser files: [ 'bower_components/jquery/dist/jquery.js', @@ -22,10 +22,10 @@ module.exports = function(config) { 'bower_components/bower-mqttws/mqttws31.js', 'bower_components/rtcomm/dist/rtcomm.js', 'src/templates/**/*.html', + 'src/js/**/*.spec.js', 'src/js/**/*.module.js', 'src/js/*.js', 'src/js/ui/**/*.js', - 'test/*.spec.js' ], @@ -48,6 +48,8 @@ module.exports = function(config) { // web server port port: 9876, + // plugins: ["karma-spec-reporter"], + // enable / disable colors in the output (reporters and logs) colors: true, diff --git a/package.json b/package.json index 1ae213e..bc2256f 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "karma-mocha": "^0.1.10", "karma-ng-html2js-preprocessor": "^0.2.1", "karma-sinon": "^1.0.4", + "karma-spec-reporter": "0.0.24", "load-grunt-tasks": "^1.0.0", "mocha": "^2.0.1" } diff --git a/src/js/angular-rtcomm.js b/src/js/angular-rtcomm.module.js similarity index 100% rename from src/js/angular-rtcomm.js rename to src/js/angular-rtcomm.module.js diff --git a/src/js/rtcomm-services.js b/src/js/rtcomm-services.js index e7009ef..1eaf352 100644 --- a/src/js/rtcomm-services.js +++ b/src/js/rtcomm-services.js @@ -58,7 +58,7 @@ // Default to enabling audio and video. It must be disabled through config. var broadcastAudio = true; var broadcastVideo = true; - var rtcommDebug = "DEBUG"; + var rtcommDebug = "INFO"; var ringtone = null; var ringbacktone = null; diff --git a/src/js/services/rtcomm.event.service.js b/src/js/services/rtcomm.event.service.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/js/services/services.module.js b/src/js/services/services.module.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/js/ui/endpoint-provider/rtcomm-alert.js b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js similarity index 100% rename from src/js/ui/endpoint-provider/rtcomm-alert.js rename to src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js diff --git a/test/rtcomm-alert.spec.js b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js similarity index 87% rename from test/rtcomm-alert.spec.js rename to src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js index 50b45d3..c72c189 100644 --- a/test/rtcomm-alert.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js @@ -13,6 +13,6 @@ describe('Unit Testing: RtcommChat directive', function(){ it('chat directive should be available', function(){ var element = $compile('')($rootScope); $rootScope.$digest(); - expect(element.html()).to.include('alert in alerts'); + expect(element.html()).to.include('alert in alertVM.alerts'); }); }) diff --git a/src/js/ui/endpoint-provider/rtcomm-queues.js b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js similarity index 100% rename from src/js/ui/endpoint-provider/rtcomm-queues.js rename to src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js diff --git a/test/rtcomm-queues.spec.js b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js similarity index 100% rename from test/rtcomm-queues.spec.js rename to src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js diff --git a/src/js/ui/endpoint-provider/rtcomm-register.js b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.js similarity index 92% rename from src/js/ui/endpoint-provider/rtcomm-register.js rename to src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.js index eb5da41..527d6ef 100644 --- a/src/js/ui/endpoint-provider/rtcomm-register.js +++ b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.js @@ -54,7 +54,6 @@ vm.onRegClick = function() { if (vm.nextAction === 'Register' && !invalidCharacters.test(vm.reguserid)) { - $log.debug('Register: reguserid =' + vm.reguserid); RtcommService.register(vm.reguserid); } else { @@ -64,10 +63,9 @@ }; //Watch for changes in reguserid - $scope.$watch('registerVM.reguserid', function() { + $scope.$watch(function(){ return vm.reguserid}, function() { if (vm.reguserid.length < 1 || invalidCharacters.test(vm.reguserid)) { - vm.invalid = true; } else { vm.invalid = false; @@ -76,13 +74,12 @@ $scope.$on('rtcomm::init', function(event, success, details) { - if (success == true) { - vm.nextAction = 'Unregister'; + vm.nextAction = success ? 'Unregister' : 'Register'; + + if (success === true) { vm.reguserid = details.userid; } else { - vm.nextAction = 'Register'; - - if (details == 'destroyed') + if (details === 'destroyed') vm.reguserid = ''; else vm.reguserid = 'Init failed:' + details; diff --git a/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js new file mode 100644 index 0000000..731f8d4 --- /dev/null +++ b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js @@ -0,0 +1,172 @@ +describe('Unit Testing: Register directive', function() { + var $compile, _$rootScope, sandbox, scope, ctrl, element; + + + var input, btn; + + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm-ui')); + + //Mock RtcommService + beforeEach(function() { + RtcommService = { + register: function(userid) { + _$rootScope.$broadcast('rtcomm::init', true, { + userid: userid + }); + }, + unregister: function() { + _$rootScope.$broadcast('rtcomm::init', false, 'destroyed'); + } + } + + module(function($provide) { + $provide.value('RtcommService', RtcommService); + }); + }); + + //Setup Test + beforeEach(inject(function($compile, $rootScope) { + _$rootScope = $rootScope; + + + scope = $rootScope; + element = $compile('')(scope); + scope.$digest(); + + sandbox = sinon.sandbox.create(); + input = element.find('input'); + btn = element.find('button'); + + })); + + afterEach(function() { + sandbox.restore(); + + }) + + it('directive should compile', function() { + expect(element.html()).to.include('id="register-input"'); + }); + + it('initial state should be defined as nextAction = Register and userid empty', function() { + + expect(btn.html()).to.include('Register'); + expect(input.val()).to.be.empty; + + //Empty input should be disabled + expect(btn.is(':disabled')).to.be.true; + + }); + + it('should say "Unregister" when initialized and back to "Register" when uninitialized', function() { + + sandbox.spy(_$rootScope, '$broadcast'); //Spy for broadcasts called + + //Emit the 'rtcomm::init' event + _$rootScope.$broadcast('rtcomm::init', true, { + userid: 'MockUser' + }); + // Force changes on UI + _$rootScope.$digest(); + + expect(_$rootScope.$broadcast.calledOnce).to.be.true; + expect(btn.html()).to.include('Unregister'); + expect(input.val()).to.include('MockUser'); + + + _$rootScope.$broadcast('rtcomm::init', false, 'destroyed'); + _$rootScope.$digest(); + + expect(_$rootScope.$broadcast.called).to.be.true; + expect(btn.html()).to.include('Register'); + expect(input.val()).to.be.empty; + + }); + + it('should display an error with details when failure to initialize', function() { + sandbox.spy(_$rootScope, '$broadcast'); + var error = 'SERVICE_QUERY_FAILED'; + + _$rootScope.$broadcast('rtcomm::init', false, error); + + _$rootScope.$digest(); + + expect(_$rootScope.$broadcast.calledOnce).to.be.true; + expect(input.val()).to.include(error); + }); + + it('should successfully register using the input and btn -> Input should be disabled', function() { + + //Fill input + input.val('MockUser'); + input.trigger('input'); + + _$rootScope.$digest(); + expect(input.val()).to.include('MockUser'); + expect(btn.html()).to.include('Register'); + + + btn.click(); //Register + _$rootScope.$digest(); + + expect(input.val()).to.include('MockUser'); + expect(btn.html()).to.include('Unregister'); + expect(input.is(':disabled')).to.be.true; //Input field should be disabled + + }); + + it('should unregister using the "Unregister" button', function() { + input.val('MockUser'); + input.trigger('input'); + + expect(btn.html()).to.equal('Register'); + + btn.click(); + + _$rootScope.$digest(); + + expect(btn.html()).to.equal('Unregister'); + + btn.click(); + _$rootScope.$digest(); + + // _$rootScope.$digest(); + + expect(btn.html()).to.equal('Register'); + expect(input.is(':enabled')).to.be.true; + expect(input.val()).to.be.empty; + }); + + it('should disable input fields on invalid characters', function(done) { + var invalidCharacters = ['$', '#', '+', '/', '\\']; //Invalid characters for MQTT Topic Path + + + invalidCharacters.forEach(function(invalid_char) { + + inputHelper(invalid_char); + expect(btn.is(':disabled')).to.be.true; + + //Clear + inputHelper(''); + + inputHelper('MockUser' + invalid_char); + expect(btn.is(':disabled')).to.be.true; + + inputHelper(''); + + inputHelper(invalid_char + 'MockUser'); + expect(btn.is(':disabled')).to.be.true; + }); + + function inputHelper(value) { + input.val(value); + input.trigger('input'); //Trigger user input action + _$rootScope.$digest(); + } + //TODO Test permutations and combinations between all characters + + done(); + }); +}); diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager.js b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js similarity index 100% rename from src/js/ui/endpoint-provider/rtcomm-session-manager.js rename to src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js diff --git a/test/rtcomm-session-manager.spec.js b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js similarity index 94% rename from test/rtcomm-session-manager.spec.js rename to src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js index 9c6f13a..8d128aa 100644 --- a/test/rtcomm-session-manager.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js @@ -13,7 +13,7 @@ describe('Unit Testing: RtcommSessionManager directive', function(){ it('chat directive should be available', function(){ var element = $compile('')($rootScope); $rootScope.$digest(); - console.log(element[0]); + // console.log(element[0]); expect(element.html()).to.include('class="session-manager"'); }); }) diff --git a/src/js/ui/endpoint/rtcomm-chat.js b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js similarity index 100% rename from src/js/ui/endpoint/rtcomm-chat.js rename to src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js diff --git a/test/rtcomm-chat.spec.js b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js similarity index 100% rename from test/rtcomm-chat.spec.js rename to src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js similarity index 100% rename from src/js/ui/endpoint/rtcomm-endpoint-status.js rename to src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js diff --git a/test/rtcomm-endpoint-status.spec.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js similarity index 100% rename from test/rtcomm-endpoint-status.spec.js rename to src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js diff --git a/src/js/ui/endpoint/rtcomm-iframe.js b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js similarity index 100% rename from src/js/ui/endpoint/rtcomm-iframe.js rename to src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js diff --git a/test/rtcomm-iframe.spec.js b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js similarity index 100% rename from test/rtcomm-iframe.spec.js rename to src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js diff --git a/src/js/ui/endpoint/rtcomm-video.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js similarity index 100% rename from src/js/ui/endpoint/rtcomm-video.js rename to src/js/ui/endpoint/rtcomm-video/rtcomm-video.js diff --git a/test/rtcomm-video.spec.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js similarity index 100% rename from test/rtcomm-video.spec.js rename to src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js diff --git a/src/js/ui/modals/alert-modal.js b/src/js/ui/modals/alert-modal/alert-modal.js similarity index 100% rename from src/js/ui/modals/alert-modal.js rename to src/js/ui/modals/alert-modal/alert-modal.js diff --git a/test/rtcomm-alert-modal.spec.js b/src/js/ui/modals/alert-modal/rtcomm-alert-modal.spec.js similarity index 100% rename from test/rtcomm-alert-modal.spec.js rename to src/js/ui/modals/alert-modal/rtcomm-alert-modal.spec.js diff --git a/src/js/ui/modals/call-modal.js b/src/js/ui/modals/call-modal/call-modal.js similarity index 100% rename from src/js/ui/modals/call-modal.js rename to src/js/ui/modals/call-modal/call-modal.js diff --git a/test/rtcomm-config.spec.js b/test/rtcomm-config.spec.js deleted file mode 100644 index 68c4faa..0000000 --- a/test/rtcomm-config.spec.js +++ /dev/null @@ -1,13 +0,0 @@ -// describe('Unit Testing: Rtcomm Config Service', function() { -// -// var RtcommConfigService; -// -// beforeEach(function(){ -// -// }); -// -// afterEach(function(){ -// -// }); -// RtcommConfigService -// }); diff --git a/test/rtcomm-presence.directive.spec.js b/test/rtcomm-presence.directive.spec.js deleted file mode 100644 index 6f0b114..0000000 --- a/test/rtcomm-presence.directive.spec.js +++ /dev/null @@ -1 +0,0 @@ -// describe('Testing ') diff --git a/test/rtcomm-register.directive.spec.js b/test/rtcomm-register.directive.spec.js deleted file mode 100644 index 5518e48..0000000 --- a/test/rtcomm-register.directive.spec.js +++ /dev/null @@ -1,22 +0,0 @@ -describe('Unit Testing: Register directive', function(){ - var $compile, $rootScope; - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm')); - beforeEach(inject( - ['$compile', '$rootScope', function($c, $r){ - $compile = $c; - $rootScope = $r; - }] - )); - - it('directive should compile', function(){ - var element = $compile('')($rootScope); - $rootScope.$digest(); - expect(element.html()).to.include('id="register-input"'); - }); - - it('should register') - - -}) diff --git a/test/rtcomm-service.spec.js b/test/rtcomm-service.spec.js deleted file mode 100644 index 430ca47..0000000 --- a/test/rtcomm-service.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -describe('Unit Testing: Rtcomm Service', function() { - - var RtcommService; //RtcommService - var sandbox; //Spying and stubbing sandbox - - beforeEach(function() { - module('angular-rtcomm'); - }); - - beforeEach(inject(function($injector) { - RtcommService = $injector.get('RtcommService'); - })); - - it('API & Functions are defined', function() { - expect(RtcommService).to.be.defined; - expect(alert).to.be.defined; - }); - - describe('API & Functions are defined', function() { - beforeEach(function() { - //$rootScope', '$log', '$http', 'RtcommConfigService' - - }); - - }); - -}); diff --git a/test/sample.html b/test/sample.html deleted file mode 100644 index 1564a9f..0000000 --- a/test/sample.html +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - angular-rtcomm Sample Page - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
-
- - -
-
- -
-
-
-
-
- - -
-
- - -
-
-
-
- Video -
-
- -
-
-
-
- Presence -
-
- -
-
- -
-
- - -
-
-
-
-
- - diff --git a/test/sampleConfig.json b/test/sampleConfig.json deleted file mode 100644 index 00c4ab4..0000000 --- a/test/sampleConfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "server" : "messagesight.demos.ibm.com", - "port" : 1884, - "rtcommTopicPath" : "/rtcommAngularSample/", - "userid" : "", - "broadcastAudio" : true, - "broadcastVideo" : true, - "presenceTopic" : "sampleRoom" -} diff --git a/test/testChat.js b/test/testChat.js deleted file mode 100644 index c695f06..0000000 --- a/test/testChat.js +++ /dev/null @@ -1,29 +0,0 @@ -describe('Unit testing angular-rtcomm chat', function() { - var $compile, - $rootScope; - - // Load the myApp module, which contains the directive - beforeEach(module('angular-rtcomm')); - - // Store references to $rootScope and $compile - // so they are available to all tests in this describe block - beforeEach(inject(function(_$compile_, _$rootScope_){ - // The injector unwraps the underscores (_) from around the parameter names when matching - $compile = _$compile_; - $rootScope = _$rootScope_; - })); - - angular.mock.module('RtcommService', { - widgetStorage: self.widgetStorage, - widgetEditor: self.widgetEditor - }); - - it('Replaces the element with the appropriate content', function() { - // Compile a piece of HTML containing the directive - var element = $compile("")($rootScope); - // fire all the watches, so the scope expression {{1 + 1}} will be evaluated - $rootScope.$digest(); - // Check that the compiled element contains the templated content - expect(element.html()).toContain("lidless, wreathed in flame, 2 times"); - }); -}); \ No newline at end of file diff --git a/test/testRtcommServiceSpec.js b/test/testRtcommServiceSpec.js deleted file mode 100644 index 3851a2d..0000000 --- a/test/testRtcommServiceSpec.js +++ /dev/null @@ -1,127 +0,0 @@ -describe('Unit testing angular-rtcomm service', function() { - var $rootScope, $log; - - // Load the myApp module, which contains the directive - var RtcommService; - - var rtcommTopicPath = "/testTopic/"; - //var rtcommTopicPath = "/rtcomm-karma-test-" + Math.floor((Math.random() * 1000000) + 1) + "/"; - - var testUserID = "TestID " + Math.floor((Math.random() * 1000000) + 1); - - beforeEach(module('angular-rtcomm')); - - beforeEach(module('angular-rtcomm', function($provide) { - // Output messages - $provide.value('$log', console); - })); - - beforeEach(inject(function (_RtcommService_,_$rootScope_,_$log_) { - RtcommService = _RtcommService_; - $rootScope = _$rootScope_; - $log = _$log_; - - // Required to get evalAsync to fire so that broadcasted messages are received by test code. - RtcommService.setKarmaTesting(); - } - )); - - describe('initialization - no user ID', function () { - - // Before init'ing, - it('check state before init', function () { - expect(RtcommService.isInitialized()).toEqual(false); - }); - - // When init'ing with no user ID, rtcomm.js should not be init'd - it('initialize with no user ID', function () { - var config = { - "server" : "localhost", - "port" : 9080, - "rtcommTopicPath" : "/rtcomm/", - "userid" : "", - "broadcastAudio" : true, - "broadcastVideo" : true, - "presenceTopic" : "karmaPresence" - }; - - RtcommService.setConfig(config); - - expect(RtcommService.isInitialized()).toEqual(false); - }); - }); - - describe('Run test after initialization with user ID', function () { - - var presenceData = null; - - // When init'ing with user ID, rtcomm.js should be init'd - it('initialize with user ID', function (done) { - $log.debug('Karma: initialize with user ID: top: $rootScope: ',$rootScope); - -// spyOn($rootScope, '$broadcast').and.callThrough(); - - $rootScope.$on('rtcomm::init', function (event, success, details) { - $log.debug('Karma: initialize with user ID: rtcomm::init received'); - expect(RtcommService.isInitialized()).toEqual(true); - done(); - }); - - var config = { - "server" : "localhost", - "port" : 9080, - "rtcommTopicPath" : "/rtcomm/", - "userid" : "testUserID", - "broadcastAudio" : true, - "broadcastVideo" : true, - "presenceTopic" : "karmaPresence" - }; - - RtcommService.setConfig(config); - }); - - // Here we publish presence and wait for the result to come in through a notification. - it('test pubishing presence', function (done) { - - $rootScope.$on('rtcomm::init', function (event, success, details) { - $log.debug('Karma: test pubishing presence: rtcomm::init received'); - var presenceMonitor = RtcommService.getPresenceMonitor(); - - presenceMonitor.on('updated', function(){ - - presenceData = presenceMonitor.getPresenceData(); - - $log.debug('Karma: test pubishing presence: presenceData: ',presenceData); - - assert.isArray(presenceData); - assert.lengthOf(presenceData, 1); - assert.deepProperty(presenceData[0], "name"); - assert.deepProperty(presenceData[0], "record"); - assert.deepProperty(presenceData[0], "nodes"); - assert.deepPropertyVal(presenceData[0], "name", "karmaPresence"); - - assert.isArray(presenceData[0].nodes); - assert.lengthOf(presenceData[0].nodes, 1); - assert.deepProperty(presenceData[0].nodes[0], "name"); - assert.deepPropertyVal(presenceData[0].nodes[0], "name", "testUserID"); - done(); - }); - - presenceMonitor.add("karmaPresence"); - RtcommService.publishPresence(); - }); - - var config = { - "server" : "localhost", - "port" : 9080, - "rtcommTopicPath" : "/rtcomm/", - "userid" : "testUserID", - "broadcastAudio" : true, - "broadcastVideo" : true, - "presenceTopic" : "karmaPresence" - }; - - RtcommService.setConfig(config); - }); - }); -}); From cff4aba86459ccbf4fdf159e613fbaf8a7b0cfd9 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Tue, 8 Mar 2016 10:36:52 -0500 Subject: [PATCH 05/21] Updating finished tests for video, chat, register and endpoint-status, removed RtcommService dependency for the rtcomm-alert directive --- .../rtcomm-alert/rtcomm-alert.js | 4 +- .../rtcomm-register/rtcomm-register.spec.js | 3 +- .../endpoint/rtcomm-chat/rtcomm-chat.spec.js | 273 ++++++++++++++++-- .../rtcomm-endpoint-status.js | 8 +- .../rtcomm-endpoint-status.spec.js | 174 +++++++++-- .../ui/endpoint/rtcomm-video/rtcomm-video.js | 47 +-- .../rtcomm-video/rtcomm-video.spec.js | 102 +++++-- 7 files changed, 529 insertions(+), 82 deletions(-) diff --git a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js index 3a73922..7b25903 100644 --- a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js +++ b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js @@ -34,10 +34,10 @@ return directive; } - AlertController.$inject = ['RtcommService', '$scope', '$log']; + AlertController.$inject = ['$scope', '$log']; /* @ngInject */ - function AlertController(RtcommService, $scope, $log) { + function AlertController($scope, $log) { var vm = this; vm.alerts = []; vm.addAlert = function(alert) { diff --git a/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js index 731f8d4..92f71b9 100644 --- a/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js @@ -1,3 +1,4 @@ + describe('Unit Testing: Register directive', function() { var $compile, _$rootScope, sandbox, scope, ctrl, element; @@ -44,7 +45,7 @@ describe('Unit Testing: Register directive', function() { afterEach(function() { sandbox.restore(); - }) + }); it('directive should compile', function() { expect(element.html()).to.include('id="register-input"'); diff --git a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js index d40dda6..d2960f1 100644 --- a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js +++ b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js @@ -1,18 +1,257 @@ -describe('Unit Testing: RtcommChat directive', function(){ - var $compile, $rootScope; - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm')); - beforeEach(inject( - ['$compile', '$rootScope', function($c, $r){ - $compile = $c; - $rootScope = $r; - }] - )); - - it('chat directive should be available', function(){ - var element = $compile('')($rootScope); - $rootScope.$digest(); - expect(element.html()).to.include('class="chat"'); - }); +describe('Unit Testing: RtcommChat directive', function() { + var $compile, _$rootScope, sandbox, scope, element; + + var chatInput, sendBtn; + + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm-ui')); + + //Mock RtcommService + beforeEach(function() { + RtcommService = { + endpoints: [], + activeEndpoint: null, + getActiveEndpoint: function() { + return this.activeEndpoint; + }, + getChats: function() { + + var ep = this.getEndpoint(this.activeEndpoint); + if (ep !== null) { + return ep.chats; + } else { + return []; + } + }, + getEndpoint: function(id) { + var endpoint = null + this.endpoints.forEach(function(_endpoint) { + if (_endpoint.id === id) { + endpoint = _endpoint; + } + }); + return endpoint; + }, + sendChatMessage: function(chat, endpoint) { + //Store chats locally, RtcommService uses a session storage mechanism, since this is a + //mock we can just store teh chats on the mockendpoint itself + var endpoint = this.getEndpoint(this.activeEndpoint); + endpoint.chats.push(chat); + }, + //Interface methods for manipulating the RtcommService through the test + _MockCreateEndpoint: function(id, userid) { + var mockEP = createMockEndpoint(id, userid); + this.endpoints.push(mockEP); + }, + _setActiveEndpoint: function(id) { + this.activeEndpoint = id; + }, + _emitChatMessage: function(eventObject) { + this.endpoints.forEach(function(_endpoint) { + if (_endpoint.id === eventObject.id) { + var chatMessage = { + name: eventObject.message.from, + time: new Date(), + message: eventObject.message.message + + } + _endpoint.chats.push(chatMessage); + + } + }); + }, + _destroyEndpoint: function(id){ + // console.log(this.endpoints); + this.endpoints.forEach(function(_endpoint, index, endpoints){ + if(_endpoint.id === id){ + _endpoint.chats = []; + endpoints.splice(index, 1); + } + }); + console.log(this.endpoints); + + } + } + + module(function($provide) { + $provide.value('RtcommService', RtcommService); + }); + }); + + //Setup Test + beforeEach(inject(function($compile, $rootScope) { + _$rootScope = $rootScope; + + + scope = $rootScope; + element = $compile('')(scope); + scope.$digest(); + + sandbox = sinon.sandbox.create(); + chatInput = element.find('input'); + sendBtn = element.find('button'); + + })); + + afterEach(function() { + sandbox.restore(); + }); + + it('chat directive should be available', function() { + expect(element.html()).to.include('class="chat"'); + }); + + it('intial state send button should be disabled', function() { + expect(sendBtn.is(':disabled')).to.be.true; + }); + + + it('should activate when an endpoint session is created', function() { + sandbox.spy(_$rootScope, '$broadcast'); + sandbox.spy(RtcommService, 'getChats'); + sandbox.spy(RtcommService, 'getEndpoint'); + + RtcommService._MockCreateEndpoint('A'); + RtcommService._setActiveEndpoint('A'); + + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + expect(_$rootScope.$broadcast.calledOnce).to.be.true; + expect(RtcommService.getChats.called).to.be.true; + expect(RtcommService.getEndpoint.called).to.be.true; + expect(sendBtn.is(':enabled')).to.be.true; + }); + + it('should display messages sent from the local user', function() { + var chatMsg = 'Hello World!'; + var userid = 'MockUser'; + RtcommService._MockCreateEndpoint('A', userid); + RtcommService._setActiveEndpoint('A'); + + var testMessages = ['Hey!', 'How\'s it going?', 'Just found out this is an amazing framework']; + + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + + testMessages.forEach(function(testMessage) { + + sendMessage(testMessage); + + }); + + var messageElements = element.find('ul.chat > li'); + + expect(messageElements.length).to.equal(testMessages.length); + + for (var i = 0; i < messageElements.length; i++) { + var messageElement = angular.element(messageElements[i]); + + var chatMessage = messageDecomposer(messageElement); + expect(chatMessage.user).to.equal(userid); + expect(chatMessage.message).to.equal(testMessages[i]); + } + + }); + + it('should display messages from a mock remote user', function() { + + + var userid = 'MockUser'; + RtcommService._MockCreateEndpoint('A', userid); + RtcommService._setActiveEndpoint('A'); + + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + + var eventObject = { + id: 'A', + message: { + message: 'Hello, this is me the second person', + from: 'MockUser2' + } + } + RtcommService._emitChatMessage(eventObject); + + _$rootScope.$digest(); + var messageElements = element.find('ul.chat > li'); + + var message = messageDecomposer(angular.element(messageElements[0])); + expect(message.message).to.equal(eventObject.message.message); + expect(message.user).to.equal(eventObject.message.from); + + + }); + + it('should remove all messages when endpoint is removed or destroyed', function(){ + var chatMsg = 'Hello World!'; + var userid = 'MockUser'; + RtcommService._MockCreateEndpoint('A', userid); + RtcommService._setActiveEndpoint('A'); + + var testMessages = ['Hey!', 'How\'s it going?', 'Just found out this is an amazing framework']; + + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + + testMessages.forEach(function(testMessage) { + + sendMessage(testMessage); + + }); + + var messageElements = element.find('ul.chat > li'); + + expect(messageElements.length).to.equal(testMessages.length); + + for (var i = 0; i < messageElements.length; i++) { + var messageElement = angular.element(messageElements[i]); + + var chatMessage = messageDecomposer(messageElement); + expect(chatMessage.user).to.equal(userid); + expect(chatMessage.message).to.equal(testMessages[i]); + } + + _$rootScope.$broadcast('noEndpointActivated'); + _$rootScope.$digest(); + + var messageElements = element.find('ul.chat > li'); + + expect(messageElements.length).to.equal(0); + + }); + + function createMockEndpoint(id, name) { + var endpoint = { + id: id, + chats: [], + localId: name, + getLocalEndpointID: function() { + return this.localId; + } + } + return endpoint; + } + + function messageDecomposer(chatMessageElement) { + var user = chatMessageElement.find('strong').html(); + var time = chatMessageElement.find('small').html(); + var message = chatMessageElement.find('p').html(); + + var chatMessage = { + user: user, + time: time, + message: message + + } + return chatMessage; + } + + function sendMessage(message) { + chatInput.val(message); + chatInput.trigger('input'); + sendBtn.click(); + _$rootScope.$digest(); + + } }) diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js index b8e6086..381d8f7 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js @@ -47,10 +47,6 @@ }; return directive; - - function linkFunc(scope, el, attr, ctrl) { - - } } EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; @@ -62,11 +58,11 @@ vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); vm.failureReason = ''; - vm.queueCount = 0; // FIX: Currently not implemented! + vm.queueCount = 0; //TODO FIX: Currently not implemented! $scope.$on('session:started', function(event, eventObject) { $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + if (vm.epCtrlActiveEndpointUUID === eventObject.endpoint.id) { vm.sessionState = 'session:started'; vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); } diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js index 68ae9a0..73779b7 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js @@ -1,18 +1,158 @@ -describe('Unit Testing: RtcommChat directive', function(){ - var $compile, $rootScope; - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm')); - beforeEach(inject( - ['$compile', '$rootScope', function($c, $r){ - $compile = $c; - $rootScope = $r; - }] - )); - - it('chat directive should be available', function(){ - var element = $compile('')($rootScope); - $rootScope.$digest(); - expect(element.html()).to.include('class="endpoint-status"'); - }); +describe('Unit Testing: RtcommEndpointStatus directive', function() { + var $compile, _$rootScope, sandbox, scope, element, endpointStatusElement; + + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm-ui')); + + beforeEach(function() { + RtcommService = { + sessions: [ + + ], + getActiveEndpoint: function(endpointUUID) { + return 'A'; + }, + getRemoteEndpoint: function(endpointUUID) { + return { + id: 'B', + localName: 'RemoteMockUser' + + } + }, + getSessionState: function(endpointUUID) { + return 'session:stopped'; + + }, + getEndpoint: function(endpointUUID) { + return { + id: 'A', + getRemoteEndpointID : function(){ + return 'RemoteMockUser' + } + } + } + } + + module(function($provide) { + $provide.value('RtcommService', RtcommService); + }); + }); + + //Setup Test + beforeEach(inject(function($compile, $rootScope) { + _$rootScope = $rootScope; + + + scope = $rootScope; + element = $compile('')(scope); + scope.$digest(); + + sandbox = sinon.sandbox.create(); + endpointStatusElement = element.find('span'); //Holds the state of the endpoint + + })); + + afterEach(function() { + sandbox.restore(); + }); + + it('endpoint-status directive should be available', function() { + expect(element.html()).to.include('class="endpoint-status"'); + }); + + it('should display an initial state of the endpoint', function() { + expect(endpointStatusElement.html()).to.equal('No active sessions, waiting...'); + }); + + it('should display a "session:started" event correct', function(){ + //Event object + generateEvent('session:started', {id: 'A', user: 'RemoteMockUser'}); + expect(getEndpointStatus()).to.equal('Connected to RemoteMockUser'); + }); + + it('should display a "session:stopped" event correctly', function(){ + + generateEvent('session:stopped', {id: 'A', user: 'RemoteMockUser'}); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + + }); + + it('should display a "session:alerting", event correctly', function(){ + //Receive event from a new endpoint different from the current active endpoint + generateEvent('session:alerting', {id: 'B', user: 'RemoteMockUser2'}); + expect(getEndpointStatus()).to.equal('Inbound call from RemoteMockUser2'); + }); + + it('should display a "session:failed" event correctly', function(){ + generateEvent('session:failed', {id: 'A', reason: 'User dropped the call', user: 'RemoteMockUser'}); + expect(getEndpointStatus()).to.equal('Call failed with reason: User dropped the call'); + }) + + it('should display a "session:connecting" event correctly', function(){ + generateEvent('session:connecting', {id: 'B', user: 'RemoteMockUser2'}); + expect(getEndpointStatus()).to.equal('Connecting to RemoteMockUser2 ...'); + }); + + it('should display a "session:queued" event correctly', function(){ + generateEvent('session:queued', {id: 'A', user: 'RemoteMockUser'}); + expect(getEndpointStatus()).to.equal('Waiting in queue at: 0'); + + }); + it('should display a "session:trying" event correctly', function(){ + generateEvent('session:trying', {id: 'A', user: 'RemoteMockUser'}); + expect(getEndpointStatus()).to.equal('Attempting to call RemoteMockUser'); + }); + + it('should display a "session:ringing" event correctly', function(){ + generateEvent('session:ringing', {id: 'A', user: 'RemoteMockUser'}); + expect(getEndpointStatus()).to.equal('Call to RemoteMockUser is ringing'); + }); + + it('should initialize endpoint on successful "rtcomm::init" event', function(){ + _$rootScope.$broadcast('rtcomm::init', true); + _$rootScope.$digest(); + + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + it('should deinitialize endpoint on unsuccesful "rtcomm::init" event', function(){ + _$rootScope.$broadcast('rtcomm::init', false); + _$rootScope.$digest(); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + it('should listen to an endpointActivated event', function(){ + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + it('should listen to an noEndpointActivated event', function(){ + _$rootScope.$broadcast('noEndpointActivated'); + _$rootScope.$digest(); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + function generateEvent(eventName, endpointDetails){ + var eventObject = createEventObject(endpointDetails); + _$rootScope.$broadcast(eventName, eventObject); + _$rootScope.$digest(); + } + + function createEventObject(endpointDetails){ + return { + reason: endpointDetails.reason, + endpoint:{ + id: endpointDetails.id, + getRemoteEndpointID: function(){ + return endpointDetails.user; + }, + } + } + } + function getEndpointStatus(){ + var endpointStatusElement = element.find('span'); + return endpointStatusElement.html(); + } }) diff --git a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js index e7816ec..46b0469 100644 --- a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js +++ b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js @@ -46,18 +46,21 @@ var vm = this; $log.debug('VideoController Starting'); vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); - $scope.init = function(selfView, remoteView) { - RtcommService.setViewSelector(selfView, remoteView); - - var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); - }; + // $scope.init = function(selfView, remoteView) { + // RtcommService.setViewSelector(selfView, remoteView); + // + // var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); + // if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) + // RtcommService.setVideoView(videoActiveEndpointUUID); + // }; // Go ahead and initialize the local media here if an endpoint already exist. var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); + if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null){ + console.log(videoActiveEndpointUUID); + RtcommService.setVideoView(videoActiveEndpointUUID); + + } $scope.$on('endpointActivated', function(event, endpointUUID) { // Not to do something here to show that this button is live. @@ -65,19 +68,19 @@ RtcommService.setVideoView(endpointUUID); vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); }); + // // + // $scope.$on('noEndpointActivated', function(event) { + // vm.avConnected = false; + // }); // - $scope.$on('noEndpointActivated', function(event) { - vm.avConnected = false; - }); - - $scope.$on('webrtc:connected', function(event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - vm.avConnected = true; - }); - - $scope.$on('webrtc:disconnected', function(event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - vm.avConnected = false; - }); + // $scope.$on('webrtc:connected', function(event, eventObject) { + // if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + // vm.avConnected = true; + // }); + // + // $scope.$on('webrtc:disconnected', function(event, eventObject) { + // if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + // vm.avConnected = false; + // }); } })(); diff --git a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js index 10ebee3..1ac02bf 100644 --- a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js +++ b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js @@ -1,18 +1,86 @@ -describe('Unit Testing: RtcommChat directive', function(){ - var $compile, $rootScope; - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm')); - beforeEach(inject( - ['$compile', '$rootScope', function($c, $r){ - $compile = $c; - $rootScope = $r; - }] - )); - - it('chat directive should be available', function(){ - var element = $compile('')($rootScope); - $rootScope.$digest(); - expect(element.html()).to.include('id="videoContainer"'); - }); +describe('Unit Testing: RtcommVideo directive', function() { + var $compile, _$rootScope, sandbox, scope, element; + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm-ui')); + + //Mock RtcommService + beforeEach(function() { + RtcommService = { + isWebrtcConnected: function() {}, + setViewSelector: function(selfView, remoteView) {}, + + setVideoView: function(activeEndpointUUID) {}, + + getActiveEndpoint: function() {} + } + + module(function($provide) { + $provide.value('RtcommService', RtcommService); + }); + }); + + + afterEach(function() { + sandbox.restore(); + }); + + describe('when an endpoint is already initialized', function() { + //Setup Test + beforeEach(inject(function($compile, $rootScope) { + sandbox = sinon.sandbox.create(); + + sandbox.stub(RtcommService, 'getActiveEndpoint', function() { + return 'A'; + }); + sandbox.spy(RtcommService, 'setVideoView'); + _$rootScope = $rootScope; + + compileVideoElement($compile); + + + })); + + it('should call RtcommService to attach endpoint to the video elements', function() { + expect(RtcommService.setVideoView.calledOnce).to.be.true; + }) + + }); + + describe('when an endpoint not initialized', function() { + //Setup Test + beforeEach(inject(function($compile, $rootScope) { + sandbox = sinon.sandbox.create(); + + sandbox.spy(RtcommService, 'setVideoView'); + sandbox.stub(RtcommService, 'isWebrtcConnected', function(){ + return true; + }); + _$rootScope = $rootScope; + + compileVideoElement($compile); + })); + + it('should activate the video view on endpoint activated event', function(){ + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + expect(RtcommService.setVideoView.calledOnce).to.be.true; + expect(RtcommService.isWebrtcConnected.called).to.be.true; + }); + + + }); + + + function compileVideoElement($compile){ + element = $compile('')(_$rootScope); + _$rootScope.$digest(); + + } + + // it('RtcommVideo directive should be available', function() { + // var element = $compile('')($rootScope); + // $rootScope.$digest(); + // expect(element.html()).to.include('id="videoContainer"'); + // }); }) From a998f643246f9adde5bbecf986c90df01b723486 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Fri, 11 Mar 2016 16:35:03 -0500 Subject: [PATCH 06/21] Adding test updates and new tests for config.controller nad alert-modal --- dist/angular-rtcomm.js | 93 +++---- dist/angular-rtcomm.min.js | 6 +- karma.conf.js | 8 +- package.json | 4 + src/js/rtcomm-services.js | 2 +- src/js/ui/config.controller.js | 1 + src/js/ui/config.controller.spec.js | 70 +++++ .../rtcomm-alert/rtcomm-alert.spec.js | 57 +++- .../rtcomm-queues/rtcomm-queues.js | 8 +- .../rtcomm-queues/rtcomm-queues.spec.js | 243 ++++++++++++++++-- .../rtcomm-session-manager.js | 8 +- .../rtcomm-session-manager.spec.js | 3 +- .../endpoint/rtcomm-iframe/rtcomm-iframe.js | 4 +- .../rtcomm-iframe/rtcomm-iframe.spec.js | 212 +++++++++++++-- .../ui/endpoint/rtcomm-video/rtcomm-video.js | 3 +- src/js/ui/modals/alert-modal/alert-modal.js | 14 +- .../ui/modals/alert-modal/alert-modal.spec.js | 153 +++++++++++ .../alert-modal/rtcomm-alert-modal.spec.js | 37 --- src/templates/rtcomm/rtcomm-iframe.html | 4 +- src/templates/rtcomm/rtcomm-sessionmgr.html | 4 +- 20 files changed, 763 insertions(+), 171 deletions(-) create mode 100644 src/js/ui/config.controller.spec.js create mode 100644 src/js/ui/modals/alert-modal/alert-modal.spec.js delete mode 100644 src/js/ui/modals/alert-modal/rtcomm-alert-modal.spec.js diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 44a6a5b..b7dd6de 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-04 + * @version v1.0.3 - 2016-03-08 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -278,7 +278,7 @@ angular // Default to enabling audio and video. It must be disabled through config. var broadcastAudio = true; var broadcastVideo = true; - var rtcommDebug = "DEBUG"; + var rtcommDebug = "INFO"; var ringtone = null; var ringbacktone = null; @@ -913,7 +913,7 @@ angular // Save this chat in the local session store var session = _createSession(endpointUUID); session.chats.push(chat); - + myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); }, @@ -1198,10 +1198,10 @@ angular return directive; } - AlertController.$inject = ['RtcommService', '$scope', '$log']; + AlertController.$inject = ['$scope', '$log']; /* @ngInject */ - function AlertController(RtcommService, $scope, $log) { + function AlertController($scope, $log) { var vm = this; vm.alerts = []; vm.addAlert = function(alert) { @@ -1435,7 +1435,6 @@ angular vm.onRegClick = function() { if (vm.nextAction === 'Register' && !invalidCharacters.test(vm.reguserid)) { - $log.debug('Register: reguserid =' + vm.reguserid); RtcommService.register(vm.reguserid); } else { @@ -1445,10 +1444,9 @@ angular }; //Watch for changes in reguserid - $scope.$watch('registerVM.reguserid', function() { + $scope.$watch(function(){ return vm.reguserid}, function() { if (vm.reguserid.length < 1 || invalidCharacters.test(vm.reguserid)) { - vm.invalid = true; } else { vm.invalid = false; @@ -1457,13 +1455,12 @@ angular $scope.$on('rtcomm::init', function(event, success, details) { - if (success == true) { - vm.nextAction = 'Unregister'; + vm.nextAction = success ? 'Unregister' : 'Register'; + + if (success === true) { vm.reguserid = details.userid; } else { - vm.nextAction = 'Register'; - - if (details == 'destroyed') + if (details === 'destroyed') vm.reguserid = ''; else vm.reguserid = 'Init failed:' + details; @@ -1837,10 +1834,6 @@ angular }; return directive; - - function linkFunc(scope, el, attr, ctrl) { - - } } EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; @@ -1852,11 +1845,11 @@ angular vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); vm.failureReason = ''; - vm.queueCount = 0; // FIX: Currently not implemented! + vm.queueCount = 0; //TODO FIX: Currently not implemented! $scope.$on('session:started', function(event, eventObject) { $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + if (vm.epCtrlActiveEndpointUUID === eventObject.endpoint.id) { vm.sessionState = 'session:started'; vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); } @@ -2101,18 +2094,20 @@ angular var vm = this; $log.debug('VideoController Starting'); vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); - $scope.init = function(selfView, remoteView) { - RtcommService.setViewSelector(selfView, remoteView); - - var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); - }; + // $scope.init = function(selfView, remoteView) { + // RtcommService.setViewSelector(selfView, remoteView); + // + // var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); + // if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) + // RtcommService.setVideoView(videoActiveEndpointUUID); + // }; // Go ahead and initialize the local media here if an endpoint already exist. var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); - if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null) - RtcommService.setVideoView(videoActiveEndpointUUID); + if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null){ + RtcommService.setVideoView(videoActiveEndpointUUID); + + } $scope.$on('endpointActivated', function(event, endpointUUID) { // Not to do something here to show that this button is live. @@ -2120,20 +2115,20 @@ angular RtcommService.setVideoView(endpointUUID); vm.avConnected = RtcommService.isWebrtcConnected(RtcommService.getActiveEndpoint()); }); + // // + // $scope.$on('noEndpointActivated', function(event) { + // vm.avConnected = false; + // }); // - $scope.$on('noEndpointActivated', function(event) { - vm.avConnected = false; - }); - - $scope.$on('webrtc:connected', function(event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - vm.avConnected = true; - }); - - $scope.$on('webrtc:disconnected', function(event, eventObject) { - if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) - vm.avConnected = false; - }); + // $scope.$on('webrtc:connected', function(event, eventObject) { + // if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + // vm.avConnected = true; + // }); + // + // $scope.$on('webrtc:disconnected', function(event, eventObject) { + // if (RtcommService.getActiveEndpoint() == eventObject.endpoint.id) + // vm.avConnected = false; + // }); } })(); @@ -2176,11 +2171,6 @@ angular vm.alertActiveEndpointUUID = RtcommService.getActiveEndpoint(); vm.caller = null; - vm.init = function(autoAnswerNewMedia) { - $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); - vm.autoAnswerNewMedia = autoAnswerNewMedia; - }; - vm.showAlerting = function(size) { var modalInstance = $modal.open({ @@ -2216,6 +2206,11 @@ angular }); }; + $scope.init = function(autoAnswerNewMedia) { + $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); + vm.autoAnswerNewMedia = autoAnswerNewMedia; + }; + $scope.$on('endpointActivated', function(event, endpointUUID) { vm.alertActiveEndpointUUID = endpointUUID; }); @@ -2233,11 +2228,7 @@ angular eventObject.endpoint.accept(); } }); - activate(); - function activate() { - - } } RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; @@ -2377,7 +2368,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-iframe.html', - "
URL Sharing
" + "
URL Sharing
" ); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index f2fbe32..76c27fd 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-04 + * @version v1.0.3 - 2016-03-08 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.alerts=[],d.addAlert=function(a){d.alerts.push(a)},d.closeAlert=function(a){d.alerts.splice(a,1)},b.$on("rtcomm::alert",function(a,b){d.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){1==a&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){0==g.syncSource?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint()),b.init=function(b,c){a.setViewSelector(b,c);var d=a.getActiveEndpoint();"undefined"!=typeof d&&null!=d&&a.setVideoView(d)};var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())}),b.$on("noEndpointActivated",function(a){d.avConnected=!1}),b.$on("webrtc:connected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!0)}),b.$on("webrtc:disconnected",function(b,c){a.getActiveEndpoint()==c.endpoint.id&&(d.avConnected=!1)})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){function f(){}var g=this;g.alertingEndpointUUID=null,g.autoAnswerNewMedia=!1,g.alertActiveEndpointUUID=a.getActiveEndpoint(),g.caller=null,g.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),g.autoAnswerNewMedia=a},g.showAlerting=function(d){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return g.caller}}});f.result.then(function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(g.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+g.caller+" for endpoint: "+g.alertingEndpointUUID),b.reject(),b=null)})},d.$on("endpointActivated",function(a,b){g.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){g.alertActiveEndpointUUID==b.endpoint.id&&0==g.autoAnswerNewMedia||g.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+g.autoAnswerNewMedia),g.caller=b.endpoint.getRemoteEndpointID(),g.alertingEndpointUUID=b.endpoint.id,g.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())}),f()}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){var b=this;b.calleeID=null,b.callerID=null,b.enableCallModel=!1,b.mediaToEnable=["chat"],b.init=function(a,c){b.calleeID=a,"undefined"!=typeof c&&(b.mediaToEnable=c)},b.placeCall=function(a){var c=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});c.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+b.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==b.callerID&&"undefined"!=typeof a&&""!=a&&(b.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(b.calleeID,b.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,c,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?b.enableCallModel=!0:b.enableCallModel=!1}),$scope.$on("session:started",function(a,c){b.enableCallModel=!1}),$scope.$on("session:stopped",function(a,c){b.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), -a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){1==a&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){0==g.syncSource?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){var b=this;b.calleeID=null,b.callerID=null,b.enableCallModel=!1,b.mediaToEnable=["chat"],b.init=function(a,c){b.calleeID=a,"undefined"!=typeof c&&(b.mediaToEnable=c)},b.placeCall=function(a){var c=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});c.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+b.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==b.callerID&&"undefined"!=typeof a&&""!=a&&(b.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(b.calleeID,b.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,c,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?b.enableCallModel=!0:b.enableCallModel=!1}),$scope.$on("session:started",function(a,c){b.enableCallModel=!1}),$scope.$on("session:stopped",function(a,c){b.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), +a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 0cdc2bb..af1c022 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,7 +10,7 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha', 'chai', 'sinon'], - reporters: ['spec'], + reporters: ['spec', 'coverage'], // list of files / patterns to load in the browser files: [ 'bower_components/jquery/dist/jquery.js', @@ -37,8 +37,12 @@ module.exports = function(config) { // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { 'src/templates/**/*.html': ['ng-html2js'], - + 'src/js/**/!(*.spec).js' : ['coverage'] }, + coverageReporter: { + type : 'html', + dir : 'coverage/' + }, ngHtml2JsPreprocessor: { stripPrefix: 'src/', diff --git a/package.json b/package.json index bc2256f..502e498 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "karma": "^0.12.28", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^0.1.7", + "karma-coverage": "^0.5.5", "karma-firefox-launcher": "^0.1.3", "karma-ie-launcher": "^0.1.5", "karma-jasmine": "^0.3.2", @@ -47,5 +48,8 @@ "karma-spec-reporter": "0.0.24", "load-grunt-tasks": "^1.0.0", "mocha": "^2.0.1" + }, + "dependencies": { + "istanbul": "^0.4.2" } } diff --git a/src/js/rtcomm-services.js b/src/js/rtcomm-services.js index 1eaf352..8f0b77d 100644 --- a/src/js/rtcomm-services.js +++ b/src/js/rtcomm-services.js @@ -693,7 +693,7 @@ // Save this chat in the local session store var session = _createSession(endpointUUID); session.chats.push(chat); - + myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); }, diff --git a/src/js/ui/config.controller.js b/src/js/ui/config.controller.js index 7f5e2eb..37c6e7a 100644 --- a/src/js/ui/config.controller.js +++ b/src/js/ui/config.controller.js @@ -57,6 +57,7 @@ }; $scope.init = function(configURL, extendedConfig) { + $log.debug('RtcommConfigController: initing configURL = ' + configURL); vm.configURL = configURL; diff --git a/src/js/ui/config.controller.spec.js b/src/js/ui/config.controller.spec.js new file mode 100644 index 0000000..e4e39b6 --- /dev/null +++ b/src/js/ui/config.controller.spec.js @@ -0,0 +1,70 @@ +describe('Unit Testing: RtcommConfigController', function() { + + var sandbox; + + var $rootScope, RtcommService, $compile, $httpBackend, rtcommConfigGET, rtcommConfig; + beforeEach(module('rtcomm.templates')); + + beforeEach(module('angular-rtcomm-ui')); + + beforeEach(inject( + function($injector) { + + sandbox = sinon.sandbox.create(); + $rootScope = $injector.get('$rootScope'); + RtcommService = $injector.get('RtcommService'); + $compile = $injector.get('$compile'); + $httpBackend = $injector.get('$httpBackend'); + + rtcommConfig = { + 'rtcommTopicPath': '/rtcomm/', + 'createEndpoint': true, + 'presenceTopic': 'sampleRoom', + 'broadcastVideo': true, + 'broadcastAudio': true, + 'userid': '' + }; + + rtcommConfigGET = $httpBackend.when('GET', 'rtcommConfig.json'); + rtcommConfigGET.respond(rtcommConfig); + + + } + )); + + afterEach(function(){ + sandbox.restore(); + }); + + it('should initialize with a simple config', function(){ + sandbox.stub(RtcommService, 'setConfig', function(data){ + expect(data).to.deep.equal(angular.extend(rtcommConfig, {})); + }); + + $httpBackend.expectGET('rtcommConfig.json'); + + var rtcommConfigDiv = compileRtcommConfigController(); + + $httpBackend.flush(); + + }); + + it('should combine the simple config and extended config', function(){ + + sandbox.stub(RtcommService, 'setConfig', function(data){ + expect(data).to.deep.equal(angular.extend(rtcommConfig, {chat: false})); + }); + $httpBackend.expectGET('rtcommConfig.json'); + + var rtcommConfigDiv = compileRtcommConfigController({'chat': false}); + + $httpBackend.flush(); + + }); + + function compileRtcommConfigController(extendedConfig){ + var html = '
'; + var configCtrl = $compile(html)($rootScope); + return configCtrl; + } +}); diff --git a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js index c72c189..082fac3 100644 --- a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js @@ -1,18 +1,49 @@ -describe('Unit Testing: RtcommChat directive', function(){ - var $compile, $rootScope; +describe('Unit Testing: RtcommAlert directive', function(){ + var _$rootScope, element; beforeEach(module("rtcomm.templates")); - beforeEach(module('angular-rtcomm')); - beforeEach(inject( - ['$compile', '$rootScope', function($c, $r){ - $compile = $c; - $rootScope = $r; - }] - )); - - it('chat directive should be available', function(){ - var element = $compile('')($rootScope); - $rootScope.$digest(); + beforeEach(module('angular-rtcomm-ui')); beforeEach(module("rtcomm.templates")); + + beforeEach(inject(function($compile, $rootScope) { + _$rootScope = $rootScope; + element = $compile('')(_$rootScope); + _$rootScope.$digest(); + + })); + + it('alert directive should be available', function(){ expect(element.html()).to.include('alert in alertVM.alerts'); }); + + it('should create an alert object on rtcomm::alert', function(){ + var type = 'error', msg = 'Disconnected from the server!'; + _$rootScope.$broadcast('rtcomm::alert', createEventObject(type, msg) ); + _$rootScope.$digest(); + + var alertElements = element.find('.alert'); + expect(angular.element(alertElements[0]).html()).to.include(msg); + }); + + it('should delete an alert object on close click', function(){ + var type = 'error', msg = 'Disconnected from the server!'; + _$rootScope.$broadcast('rtcomm::alert', createEventObject(type, msg) ); + _$rootScope.$digest(); + var alertElements = element.find('.alert'); + var alert = angular.element(alertElements[0]); + var closeBtn = alert.find('button'); + closeBtn.click(); + _$rootScope.$digest(); + + var alertElements = element.find('.alert'); + + expect(alertElements.length).to.equal(0); + }) + + function createEventObject(_type, _msg){ + return { + type: _type, + msg: _msg + } + } + // it() }) diff --git a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js index 55df5a7..db1de10 100644 --- a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js +++ b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js @@ -32,15 +32,12 @@ restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-queues.html', controller: QueuesController, - controllerAs: 'queueVM', + controllerAs: 'queuesVM', bindToController: true }; return directive; - function linkFunc(scope, el, attr, ctrl) { - - } } QueuesController.$inject = ['RtcommService', '$scope', '$log']; @@ -64,7 +61,6 @@ $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); vm.autoJoinQueues = autoJoinQueues; vm.queuePublishPresence = queuePublishPresence; - if (typeof queueFilter !== "undefined") vm.queueFilter = queueFilter; }; @@ -132,7 +128,6 @@ $scope.$on('queueupdate', function(event, queues) { $log.debug('rtcommQueues: scope queues', vm.rQueues); - Object.keys(queues).forEach(function(key) { $log.debug('rtcommQueues: Push queue: ' + queues[key]); $log.debug('rtcommQueues: autoJoinQueues: ' + vm.autoJoinQueues); @@ -140,7 +135,6 @@ // Check to make sure queue is not filteres out before adding it. if (vm.filterOutQueue(queues[key]) == false) { vm.rQueues.push(queues[key]); - // If autoJoin we go ahead and join the queue as soon as we get the queue update. if (vm.autoJoinQueues == true) { vm.onQueueClick(queues[key]); diff --git a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js index c2363d0..950e9b9 100644 --- a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js @@ -1,18 +1,225 @@ -describe('Unit Testing: RtcommChat directive', function(){ - var $compile, $rootScope; - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm')); - beforeEach(inject( - ['$compile', '$rootScope', function($c, $r){ - $compile = $c; - $rootScope = $r; - }] - )); - - it('chat directive should be available', function(){ - var element = $compile('')($rootScope); - $rootScope.$digest(); - expect(element.html()).to.include('class="queueContainer"'); - }); -}) +//TODO Finish rtcomm-queues unit test +describe('Unit Testing: RtcommQueues directive', function() { + + //Dependencies + var $rootScope, RtcommService, $scope, $log, $compile, rtcommQueues; + + var sandbox; + + beforeEach(module('rtcomm.templates')); + + beforeEach(module('angular-rtcomm-ui')); + + beforeEach(inject( + function($injector) { + sandbox = sinon.sandbox.create(); + $rootScope = $injector.get('$rootScope'); + RtcommService = $injector.get('RtcommService'); + $compile = $injector.get('$compile'); + + } + )); + afterEach(function() { + sandbox.restore(); + }); + + it('queues directive should be available', function() { + var rtcommQueue = compileRtcommQueue(false, false, false); + expect(rtcommQueue.html()).to.include('class="queueContainer"'); + }); + + it('should update the queuelist correctly on update', function() { + + var rtcommQueue = compileRtcommQueue(false, false); + + var mockQueues = [ + createMockQueue({ + active: false, + endpointID: 'Mock Queue' + }), + createMockQueue({ + active: true, + endpointID: 'Mock Queue 2' + }) + ]; + + //Emit queueupdate + $rootScope.$broadcast('queueupdate', mockQueues); + $rootScope.$digest(); + + //All Queues should be visible + var queuesElements = rtcommQueue.find('button'); + expect(queuesElements.length).to.equal(mockQueues.length); + + for (var i = 0; i < queuesElements.length; i++) { + var mockQueue = mockQueues[i]; + var actionString = mockQueue.active ? 'Leave ' : 'Join '; + expect(queuesElements[i].innerHTML).to.equal(actionString + mockQueues[i].endpointID); + } + }); + + it('should filter out queues correctly', function() { + var rtcommQueue = compileRtcommQueue(false, false, ['Mock Queue 2']); + + var mockQueues = [ + createMockQueue({ + active: false, + endpointID: 'Mock Queue' + }), + createMockQueue({ + active: true, + endpointID: 'Mock Queue 2' + }) + ]; + + //Emit queueupdate + $rootScope.$broadcast('queueupdate', mockQueues); + $rootScope.$digest(); + var queuesElements = rtcommQueue.find('button'); + expect(queuesElements.length).to.equal(1); + + expect(queuesElements[0].innerHTML).to.equal('Leave Mock Queue 2'); + }); + + it('when autojoin is enabled it should join the queues', function() { + sandbox.stub(RtcommService, 'joinQueue', function(id) {}); + + var rtcommQueue = compileRtcommQueue(true, false); + + var mockQueues = [ + createMockQueue({ + active: false, + endpointID: 'Mock Queue' + }) + ]; + + //Emite queueupdate + + $rootScope.$broadcast('queueupdate', mockQueues); + $rootScope.$digest(); + + var queueElement = rtcommQueue.find('button'); + expect(queueElement.length).to.equal(1); + expect(queueElement.html()).to.equal('Leave Mock Queue'); + // expect(RtcommService.joinQueue.called).to.be.true; + expect(RtcommService.joinQueue.calledWith('Mock Queue')).to.be.true; + + }); + + it('should be able to join and leave a queue', function() { + sandbox.stub(RtcommService, 'joinQueue', function(id) {}); + sandbox.stub(RtcommService, 'leaveQueue', function(id) {}); + var rtcommQueue = compileRtcommQueue(false, false); + + var mockQueues = [ + createMockQueue({ + active: false, + endpointID: 'Mock Queue' + }) + ]; + + //Emit queueupdate + $rootScope.$broadcast('queueupdate', mockQueues); + $rootScope.$digest(); + + var queueElement = rtcommQueue.find('button'); + expect(queueElement.length).to.equal(1); + + + expect(queueElement.html()).to.equal('Join Mock Queue'); + + queueElement.click(); + expect(RtcommService.joinQueue.calledWith('Mock Queue')).to.be.true; + + + expect(queueElement.html()).to.equal('Leave Mock Queue'); + queueElement.click(); + + expect(RtcommService.leaveQueue.calledWith('Mock Queue')).to.be.true; + + expect(queueElement.html()).to.equal('Join Mock Queue'); + + }); + + + it('should publish queue status on presence', function() { + sandbox.stub(RtcommService, 'removeFromPresenceRecord', function(id) {}); + sandbox.stub(RtcommService, 'addToPresenceRecord', function(presenceData) {}); + sandbox.stub(RtcommService, 'joinQueue', function(id) {}); + sandbox.stub(RtcommService, 'leaveQueue', function(id) {}); + + + var rtcommQueue = compileRtcommQueue(false, true); + + var mockQueues = [ + createMockQueue({ + active: false, + endpointID: 'Mock Queue' + }) + ]; + + //Emit queueupdate + $rootScope.$broadcast('queueupdate', mockQueues); + $rootScope.$digest(); + + var queueElement = rtcommQueue.find('button'); + expect(queueElement.length).to.equal(1); + + queueElement.click(); + + + expect(RtcommService.joinQueue.calledWith('Mock Queue')).to.be.true; + expect(RtcommService.removeFromPresenceRecord.calledWith([], false)).to.be.true; + + expect(RtcommService.addToPresenceRecord.calledWith([{ + name: 'queue', + value: 'Mock Queue' + }])).to.be.true; + + }); + + it('should empty queues on rtcomm::init', function() { + var rtcommQueue = compileRtcommQueue(false, false); + + var mockQueues = [ + createMockQueue({ + active: false, + endpointID: 'Mock Queue' + }) + ]; + + //Emit queueupdate + $rootScope.$broadcast('queueupdate', mockQueues); + $rootScope.$digest(); + + var queueElement = rtcommQueue.find('button'); + + expect(queueElement.length).to.equal(1); + + $rootScope.$broadcast('rtcomm::init', false); + $rootScope.$digest(); + queueElement = rtcommQueue.find('button'); + + expect(queueElement.length).to.equal(0); + + }); + + + //Helper functions + function compileRtcommQueue(autoJoinQueues, queuePublishPresence, queueFilter) { + var html = ''; + var rtcommQueue = $compile(html)($rootScope); + + $rootScope.$digest(); + return rtcommQueue; + } + + function createMockQueue(options) { + return { + active: options.active ? options.active : false, + description: options.description || 'Default description', + title: options.title || 'Default Queue Title', + endpointID: options.endpointID || 'Queue ID' + }; + } +}); diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js index bd37df7..cc36198 100644 --- a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js @@ -33,7 +33,7 @@ restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-sessionmgr.html', controller: SessionManagerController, - controllerAs: 'sessionVM', + controllerAs: 'sessionMgrVM', bindToController: true }; @@ -54,21 +54,21 @@ vm.publishPresence = false; vm.sessionPresenceData = []; - vm.init = function(publishPresence) { + $scope.init = function(publishPresence) { vm.publishPresence = publishPresence; vm.updatePresence(); }; vm.activateSession = function(endpointUUID) { $log.debug('rtcommSessionmgr: activateEndpoint =' + endpointUUID); - if (vm.sessMgrActiveEndpointUUID != endpointUUID) { + if (vm.sessMgrActiveEndpointUUID !== endpointUUID) { RtcommService.setActiveEndpoint(endpointUUID); } }; vm.updatePresence = function() { // Update the presence record if enabled - if (vm.publishPresence == true) { + if (vm.publishPresence === true) { RtcommService.removeFromPresenceRecord(vm.sessionPresenceData, false); vm.sessionPresenceData = [{ diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js index 8d128aa..76021e6 100644 --- a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js @@ -1,3 +1,4 @@ +//TODO Finish Session manager Unit Test describe('Unit Testing: RtcommSessionManager directive', function(){ var $compile, $rootScope; beforeEach(module("rtcomm.templates")); @@ -10,7 +11,7 @@ describe('Unit Testing: RtcommSessionManager directive', function(){ }] )); - it('chat directive should be available', function(){ + it('session-manager directive should be available', function(){ var element = $compile('')($rootScope); $rootScope.$digest(); // console.log(element[0]); diff --git a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js index 45df466..ac2154c 100644 --- a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js +++ b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js @@ -48,7 +48,7 @@ * customer/agent scenarios. */ $scope.init = function(syncSource) { - if (syncSource == true) { + if (syncSource === true) { vm.syncSource = true; vm.initiframeURL = $location.absUrl(); // init to current URL } @@ -90,7 +90,7 @@ }); $scope.$on('rtcomm::iframeUpdate', function(eventType, endpointUUID, url) { - if (vm.syncSource == false) { + if (vm.syncSource === false) { $log.debug('rtcomm::iframeUpdate: ' + url); // This is needed to prevent rtcomm from logging in when the page is loaded in the iFrame. url = url + "?disableRtcomm=true"; diff --git a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js index b1b8754..33e009a 100644 --- a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js +++ b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js @@ -1,18 +1,196 @@ -describe('Unit Testing: RtcommChat directive', function(){ - var $compile, $rootScope; - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm')); - beforeEach(inject( - ['$compile', '$rootScope', function($c, $r){ - $compile = $c; - $rootScope = $r; - }] - )); - - it('chat directive should be available', function(){ - var element = $compile('')($rootScope); - $rootScope.$digest(); - expect(element.html()).to.include('class="rtcomm-iframe"'); - }); +describe('Unit Testing: RtcommIFrame directive', function() { + + //Dependencies + var $rootScope, RtcommService, $compile, $sce, $location, $window; + + var sandbox; + + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm-ui')); + + //Mock RtcommService + + beforeEach(function() { + + }) + beforeEach(inject( + function($injector) { + sandbox = sinon.sandbox.create(); + $compile = $injector.get('$compile'); + $rootScope = $injector.get('$rootScope'); + RtcommService = $injector.get('RtcommService'); + $location = $injector.get('$location'); + $sce = $injector.get('$sce'); + $window = $injector.get('$window'); + sandbox.stub(RtcommService, 'getActiveEndpoint', function() { + return 'ID'; + }); + } + )); + afterEach(function() { + sandbox.restore(); + }); + + + it('iframe directive should be available', function() { + var element = compileIFrame(); + expect(element.html()).to.include('class="rtcomm-iframe"'); + }); + + it('iframe directive should accept ng-init', function() { + var element = compileIFrame(false); + expect(element.html()).to.include('class="rtcomm-iframe"'); + }); + + it('should have its buttons disabled if the iframeUrl is null', function() { + var element = compileIFrame(); + var backwardBtn = element.find('#btnBackward'); + var forwardBtn = element.find('#btnForward'); + + expect(backwardBtn.is(':disabled')).to.be.true; + expect(forwardBtn.is(':disabled')).to.be.true; + + }); + + it('should be able to set an URL', function() { + sandbox.stub(RtcommService, 'putIframeURL'); + sandbox.stub($sce, 'trustAsResourceUrl'); + + var element = compileIFrame(); + var urlInput = element.find('#setUrl'); + var setUrlBtn = element.find('#btn-send-url'); + + urlInput.val('https://wasdev.net/webrtc'); + urlInput.trigger('input'); + $rootScope.$digest(); + + expect(urlInput.val()).to.equal('https://wasdev.net/webrtc'); + + setUrlBtn.click(); + $rootScope.$digest(); + + var iframe = angular.element(element.find('iframe')[0]); + // expect(iframe.attr('src')).to.equal('https://wasdev.net/webrtc'); + expect(RtcommService.putIframeURL.calledOnce).to.be.true; + expect(RtcommService.putIframeURL.calledWithExactly('ID', 'https://wasdev.net/webrtc')).to.be.true; + + expect($sce.trustAsResourceUrl.calledOnce).to.be.true; + }); + + it('should set the directive\'s url when the endpoint is activated', function() { + + sandbox.stub(RtcommService, 'getIframeURL', function() { + return 'https://wasdev.net/webrtc'; + }); + sandbox.stub($sce, 'trustAsResourceUrl'); + + var element = compileIFrame(); + $rootScope.$broadcast('endpointActivated', 'ID'); + $rootScope.$digest(); + + expect(RtcommService.getIframeURL.calledWith('ID')).to.be.true; + + }); + + it('should clear the iframe when endpoint is deactivated', function() { + sandbox.stub($sce, 'trustAsResourceUrl'); + var element = compileIFrame(); + + $rootScope.$broadcast('noEndpointActivated'); + $rootScope.$digest(); + + expect($sce.trustAsResourceUrl.calledOnce).to.be.true; + expect($sce.trustAsResourceUrl.calledWith('about:blank')).to.be.true; + }); + + it('should not do anything on session:started if no syncsource is active',function(){ + sandbox.stub(RtcommService, 'putIframeURL'); + + var element = compileIFrame(); + + var eventObject = { + endpoint: { + id: 'MockID' + } + }; + + $rootScope.$broadcast('session:started', eventObject); + $rootScope.$digest(); + + expect(RtcommService.putIframeURL.called).to.be.false; + }); + + it('should flag disable rtcomm inside the iframe', function(){ + sandbox.stub($sce, 'trustAsResourceUrl', function(url){return url;}); + + + var element = compileIFrame(); + $rootScope.$broadcast('rtcomm::iframeUpdate', 'MockID','https://wasdev.net/webrtc'); + // $rootScope.$digest(); + + expect($sce.trustAsResourceUrl.calledOnce).to.be.true; + expect($sce.trustAsResourceUrl.calledWith('https://wasdev.net/webrtc?disableRtcomm=true')).to.be.true; + + }); + + describe('using syncsource (providing the url but no UI):', function() { + + + it('should update iFrameURL with the new session\'s url on session:started', function() { + sandbox.stub(RtcommService, 'putIframeURL'); + sandbox.stub($location, 'absUrl', function() { + return 'localhost'; + }); + + var element = compileIFrame(true); + + expect($location.absUrl.called).to.be.true; + + var eventObject = { + endpoint: { + id: 'MockID' + } + }; + + $rootScope.$broadcast('session:started', eventObject); + $rootScope.$digest(); + + expect(RtcommService.putIframeURL.calledOnce).to.be.true; + expect(RtcommService.putIframeURL.calledWith('MockID', 'localhost')).to.be.true; + + }); + + it('should open a pushed iframe url in a new tab', function(){ + sandbox.stub($sce, 'trustAsResourceUrl', function(url){return url;}); + sandbox.stub($window, 'open'); + var element = compileIFrame(true); + + $rootScope.$broadcast('rtcomm::iframeUpdate', 'MockID','https://wasdev.net/webrtc'); + $rootScope.$digest(); + + expect($sce.trustAsResourceUrl.calledOnce).to.be.true; + + expect($sce.trustAsResourceUrl.calledWith('https://wasdev.net/webrtc')).to.be.true; + + expect($window.open.calledOnce).to.be.true; + expect($window.open.calledWith('https://wasdev.net/webrtc', '_blank')).to.be.true; + + + }); + + + + }) + + function compileIFrame(_syncSource) { + var syncSource; + if (typeof _syncSource !== 'undefined') { + syncSource = 'ng-init="(init(' + _syncSource +'))"'; + } + var element = $compile('')($rootScope); + $rootScope.$digest(); + return element; + + } }) diff --git a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js index 46b0469..e66bfb1 100644 --- a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js +++ b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js @@ -25,7 +25,7 @@ angular .module('angular-rtcomm-ui') .directive('rtcommVideo', rtcommVideo); - + /* @ngInject */ function rtcommVideo() { var directive = { @@ -57,7 +57,6 @@ // Go ahead and initialize the local media here if an endpoint already exist. var videoActiveEndpointUUID = RtcommService.getActiveEndpoint(); if (typeof videoActiveEndpointUUID !== "undefined" && videoActiveEndpointUUID != null){ - console.log(videoActiveEndpointUUID); RtcommService.setVideoView(videoActiveEndpointUUID); } diff --git a/src/js/ui/modals/alert-modal/alert-modal.js b/src/js/ui/modals/alert-modal/alert-modal.js index 6e40620..4705691 100644 --- a/src/js/ui/modals/alert-modal/alert-modal.js +++ b/src/js/ui/modals/alert-modal/alert-modal.js @@ -37,11 +37,6 @@ vm.alertActiveEndpointUUID = RtcommService.getActiveEndpoint(); vm.caller = null; - vm.init = function(autoAnswerNewMedia) { - $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); - vm.autoAnswerNewMedia = autoAnswerNewMedia; - }; - vm.showAlerting = function(size) { var modalInstance = $modal.open({ @@ -77,6 +72,11 @@ }); }; + $scope.init = function(autoAnswerNewMedia) { + $log.debug('rtcommAlert: autoAnswerNewMedia = ' + autoAnswerNewMedia); + vm.autoAnswerNewMedia = autoAnswerNewMedia; + }; + $scope.$on('endpointActivated', function(event, endpointUUID) { vm.alertActiveEndpointUUID = endpointUUID; }); @@ -94,11 +94,7 @@ eventObject.endpoint.accept(); } }); - activate(); - - function activate() { - } } RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; diff --git a/src/js/ui/modals/alert-modal/alert-modal.spec.js b/src/js/ui/modals/alert-modal/alert-modal.spec.js new file mode 100644 index 0000000..121dcb8 --- /dev/null +++ b/src/js/ui/modals/alert-modal/alert-modal.spec.js @@ -0,0 +1,153 @@ +describe('Controller Testing: Rtcomm Alert Modal', function() { + var $compile, $rootScope, $modal, element, sandbox, body; + + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm-ui')); + + //Setup test environment + beforeEach(inject(function($compile, $rootScope, $modal, RtcommService, $window) { + sandbox = sinon.sandbox.create(); + _$rootScope = $rootScope; + element = $compile('
')(_$rootScope); + _$rootScope.$digest(); + + })); + + afterEach(function() { + sandbox.restore(); + }); + it('alert modal controller should be available', function() { + expect(element.attr('ng-controller')).to.include('RtcommAlertModalController'); + }) + it('should open on sesssion:alerting and accept', inject(function($modal, RtcommService) { + + var mockModal = getMockModal(); + + var rtcommServiceStub = sinon.stub(RtcommService, 'getEndpoint', function() { + return { + accept: function() {} + } + }); + + var modalSpy = sinon.stub($modal, 'open', function() { + return mockModal; + }); + + //Emit an rtcomm-alerting event + _$rootScope.$broadcast('session:alerting', { + endpoint: { + id: 'testid', + getRemoteEndpointID: function() { + return 'temp2' + } + } + }); + + expect(modalSpy.calledOnce).to.be.true; + + mockModal.close(); + expect(rtcommServiceStub.calledOnce).to.be.true; + + modalSpy.restore(); + })); + + it('should open on session:alerting and reject correctly', inject(function(RtcommService, $modal) { + var mockModal = getMockModal(); + + var rtcommServiceStub = sinon.stub(RtcommService, 'getEndpoint', function() { + return { + reject: function() {} + } + }); + + var modalSpy = sinon.stub($modal, 'open', function() { + return mockModal; + }); + + //Emit an rtcomm-alerting event + _$rootScope.$broadcast('session:alerting', { + endpoint: { + id: 'testid', + getRemoteEndpointID: function() { + return 'temp2' + } + } + }); + + expect(modalSpy.calledOnce).to.be.true; + + mockModal.dismiss('cancel'); + expect(rtcommServiceStub.calledOnce).to.be.true; + + modalSpy.restore(); + rtcommServiceStub.restore(); + })); + + it('should listen to endpointActivated event', function(){ + _$rootScope.$broadcast('endpointActivated', 'EndpointUUID'); + _$rootScope.$digest(); + + + }); + + describe('Testing RtcommAlertModalInstanceController', function() { + var scope, ctrl; + beforeEach(inject(function($rootScope, $log, $controller) { + modalInstance = { + close: function(){}, + dismiss: function(){} + } + scope = $rootScope.$new(); + ctrl = $controller('RtcommAlertModalInstanceController', { + $scope: scope, + $modalInstance: modalInstance, + $log: $log, + caller: 'MockUser' + }); + })); + + it('should be defined correctly', function(){ + expect(scope.caller).to.equal('MockUser'); + }); + + it('should call "ok" on click', function(){ + var modalInstanceSpy = sinon.spy(modalInstance, 'close'); + scope.ok(); + + expect(modalInstanceSpy.called).to.be.true; + modalInstanceSpy.restore(); + }); + + it('should call "cancel" on click', function(){ + var modalInstanceSpy = sinon.spy(modalInstance, 'dismiss'); + scope.cancel(); + expect(modalInstanceSpy.called).to.be.true; + modalInstanceSpy.restore(); + + }); + + }); + describe.skip('should automatically accept calls when autoAnswerNewMedia is enabeld', function() { + + + }) + + function getMockModal() { + return { + result: { + then: function(successCallback, failureCallback) { + this.successCallback = successCallback; + this.failureCallback = failureCallback; + } + }, + close: function() { + this.result.successCallback(); + }, + + dismiss: function(type) { + this.result.failureCallback(); + } + } + } +}) diff --git a/src/js/ui/modals/alert-modal/rtcomm-alert-modal.spec.js b/src/js/ui/modals/alert-modal/rtcomm-alert-modal.spec.js deleted file mode 100644 index 7301ff5..0000000 --- a/src/js/ui/modals/alert-modal/rtcomm-alert-modal.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -describe('Controller Testing: Rtcomm Alert Modal', function(){ - var $compile, $rootScope, $modal; - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm')); - - beforeEach(function(){ - - }); - beforeEach(inject( - ['$compile', '$rootScope','$injector', function($c, $r, $i){ - $compile = $c; - $rootScope = $r; - $modal = $i.get('$modal'); - }] - )); - - it('chat directive should be available', function(){ - //Add the controller to the body - var element = $compile('
')($rootScope); - $rootScope.$digest(); - - var modalSpy = sinon.spy($modal, 'open'); - - //Emit an rtcomm-alerting event - $rootScope.$broadcast('session:alerting', { - endpoint: { - id: 'testid', - getRemoteEndpointID: function(){ - return 'temp2' - } - } - }); - - expect(modalSpy.calledOnce).to.be.true; - }); -}) diff --git a/src/templates/rtcomm/rtcomm-iframe.html b/src/templates/rtcomm/rtcomm-iframe.html index 33e2166..a2ac28c 100644 --- a/src/templates/rtcomm/rtcomm-iframe.html +++ b/src/templates/rtcomm/rtcomm-iframe.html @@ -14,7 +14,7 @@
- @@ -23,7 +23,7 @@
- +
diff --git a/src/templates/rtcomm/rtcomm-sessionmgr.html b/src/templates/rtcomm/rtcomm-sessionmgr.html index 9bd9955..a054eb6 100644 --- a/src/templates/rtcomm/rtcomm-sessionmgr.html +++ b/src/templates/rtcomm/rtcomm-sessionmgr.html @@ -1,7 +1,7 @@
-
-
\ No newline at end of file + From 5ef947b456603ee14256d3f08713749307d3c0f1 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Tue, 15 Mar 2016 13:51:24 -0400 Subject: [PATCH 07/21] Saving state for ui components, TODO ~ Need to add unit tests for session-mgr, call-modal and endpoint-controller --- package.json | 5 +- src/js/ui/endpoint.controller.js | 96 -------------------------------- 2 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 src/js/ui/endpoint.controller.js diff --git a/package.json b/package.json index 502e498..2a8df16 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "angular": "^1.3.5", "angular-mocks": "^1.3.5", "chai": "^1.10.0", + "firefox-profile": "^0.3.11", "grunt": "^0.4.5", "grunt-angular-templates": "^0.5.7", "grunt-contrib-concat": "^0.5.0", @@ -47,7 +48,9 @@ "karma-sinon": "^1.0.4", "karma-spec-reporter": "0.0.24", "load-grunt-tasks": "^1.0.0", - "mocha": "^2.0.1" + "mocha": "^2.0.1", + "protractor": "^3.1.1", + "q": "^1.4.1" }, "dependencies": { "istanbul": "^0.4.2" diff --git a/src/js/ui/endpoint.controller.js b/src/js/ui/endpoint.controller.js deleted file mode 100644 index 62ff203..0000000 --- a/src/js/ui/endpoint.controller.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * (C) Copyright IBM Corporation 2016. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -(function() { - 'use strict'; - - angular - .module('angular-rtcomm-ui') - .controller('RtcommEndpointController', RtcommEndpointController); - - RtcommEndpointController.$inject = ['RtcommService', '$http', '$rootScope', '$scope', '$log']; - - /* @ngInject */ - function RtcommEndpointController(RtcommService, $http, $rootScope, $scope, $log) { - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - - $scope.disconnect = function() { - $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); - }; - - $scope.toggleAV = function() { - $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - - if ($scope.epCtrlAVConnected == false) { - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { - if (!value) { - $log.debug('Enable failed: ', message); - RtcommService.alert({ - type: 'danger', - msg: message - }); - } - }); - } else { - $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); - } - }; - - $scope.$on('session:started', function(event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:started'; - } - }); - - $scope.$on('session:stopped', function(event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:stopped'; - } - }); - - $scope.$on('session:failed', function(event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:failed'; - } - }); - - $scope.$on('webrtc:connected', function(event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = true; - }); - - $scope.$on('webrtc:disconnected', function(event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = false; - }); - - - $scope.$on('endpointActivated', function(event, endpointUUID) { - $scope.epCtrlActiveEndpointUUID = endpointUUID; - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); - }); - - $scope.$on('noEndpointActivated', function(event) { - $scope.epCtrlAVConnected = false; - }); - } -})(); From 82f13368e060823032751a79412b241ee003b572 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Tue, 15 Mar 2016 13:52:32 -0400 Subject: [PATCH 08/21] Adding endpoint-controller directory --- .../endpoint.controller.js | 101 ++++++++++++++++++ .../endpoint.controller.spec.js | 44 ++++++++ 2 files changed, 145 insertions(+) create mode 100644 src/js/ui/endpoint/endpoint-controller/endpoint.controller.js create mode 100644 src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js new file mode 100644 index 0000000..2306f0c --- /dev/null +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js @@ -0,0 +1,101 @@ +/** + * (C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .controller('RtcommEndpointController', RtcommEndpointController); + + RtcommEndpointController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function RtcommEndpointController(RtcommService, $scope, $log) { + $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); + $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); + + function getActiveEndpoint() { + return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); + } + + $scope.disconnect = function() { + $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + var ep = getActiveEndpoint; + ep.disconnect(); + }; + + $scope.toggleAV = function() { + $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + + if ($scope.epCtrlAVConnected == false) { + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { + if (!value) { + $log.debug('Enable failed: ', message); + RtcommService.alert({ + type: 'danger', + msg: message + }); + } + }); + } else { + $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); + } + }; + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:started'; + } + }); + + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:stopped'; + } + }); + + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:failed'; + } + }); + + $scope.$on('webrtc:connected', function(event, eventObject) { + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = true; + }); + + $scope.$on('webrtc:disconnected', function(event, eventObject) { + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = false; + }); + + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $scope.epCtrlActiveEndpointUUID = endpointUUID; + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + $scope.epCtrlAVConnected = false; + }); + } +})(); diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js new file mode 100644 index 0000000..42d26c7 --- /dev/null +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js @@ -0,0 +1,44 @@ +describe('Unit Testing: Endpoint Controller', function(){ + //Dependency + var RtcommService; + + //Utilities + var $compile; + //Mock and stubbing + var sandbox; + + beforeEach(module('rtcomm.templates')); + beforeEach(module('angular-rtcomm-ui')); + + + beforeEach(inject(function($injector){ + sandbox = sinon.sandbox.create(); + RtcommService = $injector.get('RtcommService'); + $compile= $injector.get('$compile'); + $rootScope = $injector.get('$rootScope'); + + + })); + + beforeEach(function(){ + //Mock initial state of the controller + // + var endpoint = { + + } + sandbox.stub(RtcommService, 'getActiveEndpoint', function(){ + return 'MOCK_ID'; + }); + sandbox.stub(RtcommService, 'isWebrtcConnected', function(id){ + return false; + }); + + sandbox.stub(RtcommService, 'getSessionState', function(){ + return 'session:stopped'; + }); + }); + it('should enable webrtc on the current active endpoint', function(){ + + + }); +}); From 8b24d1373b38967fd7a21cb17268e83354aeae0d Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Wed, 16 Mar 2016 16:26:14 -0400 Subject: [PATCH 09/21] Split rtcommConfig and RtcommService into separate files, added test for the config service --- dist/angular-rtcomm.js | 330 ++++++++++-------- dist/angular-rtcomm.min.js | 6 +- karma.conf.js | 3 +- src/js/{ => presence}/rtcomm-presence.js | 0 src/js/services/config.service.js | 135 +++++++ src/js/services/config.service.spec.js | 183 ++++++++++ .../rtcomm-service.js} | 145 +------- src/js/services/rtcomm-service.spec.js | 152 ++++++++ src/js/services/services.module.js | 6 + .../ui/endpoint/rtcomm-video/rtcomm-video.js | 4 +- 10 files changed, 673 insertions(+), 291 deletions(-) rename src/js/{ => presence}/rtcomm-presence.js (100%) create mode 100644 src/js/services/config.service.js create mode 100644 src/js/services/config.service.spec.js rename src/js/{rtcomm-services.js => services/rtcomm-service.js} (80%) create mode 100644 src/js/services/rtcomm-service.spec.js create mode 100644 src/js/services/services.module.js diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index b7dd6de..7917953 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-08 + * @version v1.0.3 - 2016-03-16 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -43,6 +43,13 @@ ]); })(); +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-service', []); +})(); + /** * (C) Copyright IBM Corporation 2016. * @@ -218,128 +225,162 @@ angular }; })(); +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-service') + .factory('RtcommConfigService', RtcommConfigService); + + /* @ngInject */ + function RtcommConfigService($location, $log, $window) { + var service = { + setProviderConfig: setProviderConfig, + getProviderConfig: getProviderConfig, + getWebRTCEnabled: getWebRTCEnabled, + getChatEnabled: getChatEnabled, + getBroadcastAudio: getBroadcastAudio, + getBroadcastVideo: getBroadcastVideo, + getRingTone: getRingTone, + getRingBackTone: getRingBackTone, + getRtcommDebug: getRtcommDebug, + isRtcommDisabled: isRtcommDisabled, + getMediaConfig: getMediaConfig + }; + + //Default provider + var providerConfig = { + server: $location.host(), + port: $location.port(), + rtcommTopicPath: '/rtcomm/', + createEndpoint: false, + appContext: 'default', + userid: '', + presence: {topic: ''} + }; + + //Rtcomm Endpoint Config Defaults + var mediaConfig = { + chat: true, + webrtc: true, + webrtcConfig: { + broadcast: { + audio: true, + video: true + } + }, + ringbacktone: null, + ringtone: null + }; + + //Rtcomm Debug + var rtcommDebug = 'INFO'; + + $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); + $log.debug('providerConfig.server: ' + providerConfig.server); + $log.debug('providerConfig.port: ' + providerConfig.port); + + return service; + + function setProviderConfig(config) { + + //Provider Config + providerConfig = { + + server : (typeof config.server !== 'undefined')? config.server : providerConfig.server, + port : (typeof config.port !== 'undefined')? config.port : providerConfig.port, + rtcommTopicPath : (typeof config.rtcommTopicPath !== 'undefined')? config.rtcommTopicPath : providerConfig.rtcommTopicPath, + createEndpoint : (typeof config.createEndpoint !== 'undefined')? config.createEndpoint : providerConfig.createEndpoint, + appContext : (typeof config.appContext !== 'undefined')? config.appContext : providerConfig.appContext, + presence : { + topic : (typeof config.presenceTopic !== 'undefined')? config.presenceTopic : providerConfig.presence.topic, + }, + userid : (typeof config.userid !== 'undefined') ? config.userid : providerConfig.userid + }; + + //Media Configuration + mediaConfig = { + chat : (typeof config.chat !== 'undefined') ? config.chat : mediaConfig.chat, + webrtc: (typeof config.video !== 'undefined') ? config.webrtc: mediaConfig.webrtc, + webrtcConfig : { + broadcast : { + video: typeof config.broadcastVideo !== 'undefined' ? config.broadcastVideo : mediaConfig.webrtcConfig.broadcast.video, + audio: typeof config.broadcastAudio !== 'undefined' ? config.broadcastAudio : mediaConfig.webrtcConfig.broadcast.audio + } + }, + ringbacktone: typeof config.ringbacktone !== 'undefined' ? config.ringbacktone : mediaConfig.ringbacktone, + ringtone: typeof config.ringtone !== 'undefined' ? config.ringtone : mediaConfig.ringtone + }; + + rtcommDebug = (typeof config.rtcommDebug !== 'undefined')? config.rtcommDebug: rtcommDebug; + + $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); + + $log.debug('providerConfig is: ' + providerConfig); + } + + function getProviderConfig(){ + return providerConfig; + } + + function getWebRTCEnabled(){ + return mediaConfig.webrtc; + } + + function getChatEnabled(){ + return mediaConfig.chat; + } + + function getBroadcastAudio(){ + return mediaConfig.webrtcConfig.broadcast.audio; + } + + function getBroadcastVideo(){ + return mediaConfig.webrtcConfig.broadcast.video; + } + + function getRingTone(){ + return mediaConfig.ringtone; + } + + function getRingBackTone(){ + return mediaConfig.ringbacktone; + } + + function getRtcommDebug(){ + return rtcommDebug; + } + + function isRtcommDisabled(){ + return false; + } + + function getMediaConfig(){ + return mediaConfig; + } + } + RtcommConfigService.$inject = ["$location", "$log", "$window"]; +})(); + /** * Definition for the rtcommModule */ (function() { - angular.module('angular-rtcomm-service', []) + angular.module('angular-rtcomm-service') /** * Set debugEnabled to true to enable the debug messages in this rtcomm angular module. */ .config(["$logProvider", function($logProvider){ $logProvider.debugEnabled(true); }]) - /* This causes a problem in ionic/iosrtc - .config(function($locationProvider) { - $locationProvider.html5Mode( {enabled: true, - requireBase: false}); - }) */ - .factory('RtcommConfigService', RtcommConfigService) - .factory('RtcommService', RtcommService); - /** - * - */ - RtcommConfigService.$inject = ['$location', '$log', '$window']; - function RtcommConfigService($location, $log, $window) { - // First we check to see if the URL includes the query string disableRtcomm=true. - // This is typically done when a URL is being shared vian an iFrame that includes Rtcomm directives. - // If it is set we just return without setting up Rtcomm. - $log.debug('RtcommConfigService: Abs URL: ' + $location.absUrl()); - var _disableRtcomm = $location.search().disableRtcomm; - if (typeof _disableRtcomm === "undefined" || _disableRtcomm === null) { - _disableRtcomm = false; - } else if (_disableRtcomm === "true") { - _disableRtcomm = true; - } else { - _disableRtcomm = false; - } - - $log.debug('RtcommConfigService: _disableRtcomm = ' + _disableRtcomm); - - var providerConfig = { - server : $location.host(), - port : $location.port(), - rtcommTopicPath : "/rtcomm/", - createEndpoint : false, - appContext: 'default', - userid: "", - presence : {topic : ""} - }; - - $log.debug('providerConfig.server: ' + providerConfig.server); - $log.debug('providerConfig.port: ' + providerConfig.port); - - var endpointConfig = { - chat: true, - webrtc: true - }; - - // Default to enabling audio and video. It must be disabled through config. - var broadcastAudio = true; - var broadcastVideo = true; - var rtcommDebug = "INFO"; - var ringtone = null; - var ringbacktone = null; - - var setConfig = function(config){ - providerConfig.server = (typeof config.server !== "undefined")? config.server : providerConfig.server; - providerConfig.port = (typeof config.port !== "undefined")? config.port : providerConfig.port; - providerConfig.rtcommTopicPath = (typeof config.rtcommTopicPath !== "undefined")? config.rtcommTopicPath : providerConfig.rtcommTopicPath; - providerConfig.createEndpoint = (typeof config.createEndpoint !== "undefined")? config.createEndpoint : providerConfig.createEndpoint; - providerConfig.appContext = (typeof config.appContext !== "undefined")? config.appContext : providerConfig.appContext; - providerConfig.presence.topic = (typeof config.presenceTopic !== "undefined")? config.presenceTopic : providerConfig.presence.topic; - - // We no longer need to set 'useSSL' This will be set based on how page is served. -// providerConfig.useSSL = (typeof config.useSSL !== "undefined")? config.useSSL : providerConfig.useSSL; - // Protocol related booleans - endpointConfig.chat= (typeof config.chat!== "undefined")? config.chat: endpointConfig.chat; - endpointConfig.webrtc = (typeof config.webrtc!== "undefined")? config.webrtc: endpointConfig.webrtc; - - broadcastAudio = (typeof config.broadcastAudio !== "undefined")? config.broadcastAudio: broadcastAudio; - broadcastVideo = (typeof config.broadcastVideo !== "undefined")? config.broadcastVideo: broadcastVideo; - - ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: ringbacktone; - ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : ringtone; - - rtcommDebug = (typeof config.rtcommDebug !== "undefined")? config.rtcommDebug: rtcommDebug; - - $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); - - if (typeof config.userid !== "undefined") - providerConfig.userid = config.userid; - - $log.debug('providerConfig is now: ', providerConfig); - - }; - - return { - setProviderConfig : function(config){setConfig(config);}, - - getProviderConfig : function(){return providerConfig;}, - - getWebRTCEnabled : function(){return endpointConfig.webrtc;}, - - getChatEnabled : function(){return endpointConfig.chat;}, - - getBroadcastAudio : function(){return broadcastAudio;}, - - getBroadcastVideo : function(){return broadcastVideo;}, - - getRingTone : function(){return ringtone;}, - - getRingBackTone : function(){return ringbacktone;}, - - getRtcommDebug: function(){return rtcommDebug;}, - - isRtcommDisabled : function(){return _disableRtcomm;} - }; - }; - - RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService']; - function RtcommService($rootScope, $log, $http, RtcommConfigService) { +.constant('rtcomm', rtcomm) +.factory('RtcommService', RtcommService); + RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; + function RtcommService($rootScope, $log, $http, RtcommConfigService, rtcomm) { /** Setup the endpoint provider first **/ - var myEndpointProvider = new rtcomm.EndpointProvider(); + + var myEndpointProvider = new rtcomm.EndpointProvider(); var endpointProviderInitialized = false; var queueList = null; var sessions = []; @@ -762,30 +803,15 @@ angular return; } - + if(config.rtcommDebug === "INFO" || config.rtcommDebug === "DEBUG"){ + myEndpointProvider.setLogLevel(config.rtcommDebug); + } $log.debug('rtcomm-services: setConfig: config: ', config); RtcommConfigService.setProviderConfig(config); - myEndpointProvider.setRtcommEndpointConfig(getMediaConfig()); + myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); if (endpointProviderInitialized == false){ - // If an identityServlet is defined we will get the User ID from the servlet. - // This is used when the user ID needs to be derived from an SSO token like LTPA. - if (typeof config.identityServlet !== "undefined" && config.identityServlet != null){ - $http.get(config.identityServlet).success (function(data){ - - if (typeof data.userid !== "undefined"){ - RtcommConfigService.setProviderConfig(data); - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; - } - else - $log.error('RtcommService: setConfig promise: Invalid JSON object return from identityServlet: ', data); - }).error(function(data, status, headers, config) { - $log.debug('RtcommService: setConfig promise: error accessing userid from identityServlet: ' + status); - }); - } - else{ // If the user does not specify a userid, that says one will never be specified so go ahead // and initialize the endpoint provider and let the provider assign a name. If a defined empty // string is passed in, that means to wait until the end user registers a name. @@ -793,7 +819,6 @@ angular myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); endpointProviderInitialized = true; } - } } }, @@ -1065,7 +1090,7 @@ angular endpoint = _getEndpoint(_getActiveEndpointUUID()); if (endpoint != null){ - + $log.debug(endpoint); endpoint.webrtc.setLocalMedia( { mediaOut: document.querySelector('#' + _selfView), @@ -1077,6 +1102,7 @@ angular }; })(); + /** * (C) Copyright IBM Corporation 2016. * @@ -1136,6 +1162,7 @@ angular }; $scope.init = function(configURL, extendedConfig) { + $log.debug('RtcommConfigController: initing configURL = ' + configURL); vm.configURL = configURL; @@ -1250,15 +1277,12 @@ angular restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-queues.html', controller: QueuesController, - controllerAs: 'queueVM', + controllerAs: 'queuesVM', bindToController: true }; return directive; - function linkFunc(scope, el, attr, ctrl) { - - } } QueuesController.$inject = ['RtcommService', '$scope', '$log']; @@ -1282,7 +1306,6 @@ angular $log.debug('rtcommQueues: autoJoinQueues = ' + autoJoinQueues); vm.autoJoinQueues = autoJoinQueues; vm.queuePublishPresence = queuePublishPresence; - if (typeof queueFilter !== "undefined") vm.queueFilter = queueFilter; }; @@ -1350,7 +1373,6 @@ angular $scope.$on('queueupdate', function(event, queues) { $log.debug('rtcommQueues: scope queues', vm.rQueues); - Object.keys(queues).forEach(function(key) { $log.debug('rtcommQueues: Push queue: ' + queues[key]); $log.debug('rtcommQueues: autoJoinQueues: ' + vm.autoJoinQueues); @@ -1358,7 +1380,6 @@ angular // Check to make sure queue is not filteres out before adding it. if (vm.filterOutQueue(queues[key]) == false) { vm.rQueues.push(queues[key]); - // If autoJoin we go ahead and join the queue as soon as we get the queue update. if (vm.autoJoinQueues == true) { vm.onQueueClick(queues[key]); @@ -1504,7 +1525,7 @@ angular restrict: 'E', templateUrl: 'templates/rtcomm/rtcomm-sessionmgr.html', controller: SessionManagerController, - controllerAs: 'sessionVM', + controllerAs: 'sessionMgrVM', bindToController: true }; @@ -1525,21 +1546,21 @@ angular vm.publishPresence = false; vm.sessionPresenceData = []; - vm.init = function(publishPresence) { + $scope.init = function(publishPresence) { vm.publishPresence = publishPresence; vm.updatePresence(); }; vm.activateSession = function(endpointUUID) { $log.debug('rtcommSessionmgr: activateEndpoint =' + endpointUUID); - if (vm.sessMgrActiveEndpointUUID != endpointUUID) { + if (vm.sessMgrActiveEndpointUUID !== endpointUUID) { RtcommService.setActiveEndpoint(endpointUUID); } }; vm.updatePresence = function() { // Update the presence record if enabled - if (vm.publishPresence == true) { + if (vm.publishPresence === true) { RtcommService.removeFromPresenceRecord(vm.sessionPresenceData, false); vm.sessionPresenceData = [{ @@ -1586,17 +1607,22 @@ angular .module('angular-rtcomm-ui') .controller('RtcommEndpointController', RtcommEndpointController); - RtcommEndpointController.$inject = ['RtcommService', '$http', '$rootScope', '$scope', '$log']; + RtcommEndpointController.$inject = ['RtcommService', '$scope', '$log']; /* @ngInject */ - function RtcommEndpointController(RtcommService, $http, $rootScope, $scope, $log) { + function RtcommEndpointController(RtcommService, $scope, $log) { $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); + function getActiveEndpoint() { + return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); + } + $scope.disconnect = function() { $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); + var ep = getActiveEndpoint; + ep.disconnect(); }; $scope.toggleAV = function() { @@ -1990,7 +2016,7 @@ angular * customer/agent scenarios. */ $scope.init = function(syncSource) { - if (syncSource == true) { + if (syncSource === true) { vm.syncSource = true; vm.initiframeURL = $location.absUrl(); // init to current URL } @@ -2032,7 +2058,7 @@ angular }); $scope.$on('rtcomm::iframeUpdate', function(eventType, endpointUUID, url) { - if (vm.syncSource == false) { + if (vm.syncSource === false) { $log.debug('rtcomm::iframeUpdate: ' + url); // This is needed to prevent rtcomm from logging in when the page is loaded in the iFrame. url = url + "?disableRtcomm=true"; @@ -2072,8 +2098,8 @@ angular angular .module('angular-rtcomm-ui') - .directive('rtcommVideo', rtcommVideo); - + .directive('rtcommVideo', rtcommVideo) + .controller('RtcommVideoController', VideoController); /* @ngInject */ function rtcommVideo() { var directive = { @@ -2368,7 +2394,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-iframe.html', - "
URL Sharing
" + "
URL Sharing
" ); @@ -2393,7 +2419,7 @@ angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCac $templateCache.put('templates/rtcomm/rtcomm-sessionmgr.html', - "

Sessions

" + "

Sessions

" ); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index 76c27fd..e3792f2 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-08 + * @version v1.0.3 - 2016-03-16 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),e.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==j&&a.$digest()};e.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==j&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=i&&(b.debug("RtcommService: initSuccess: updating presence record"),e.publishPresence(i)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==j&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==j&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=e.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return h},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){k="selfView",l="remoteView"},setViewSelector:function(a,b){k=a,l=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+k),mediaIn:document.querySelector("#"+l)})}}}angular.module("angular-rtcomm-service",[]).config(["$logProvider",function(a){a.debugEnabled(!0)}]).factory("RtcommConfigService",a).factory("RtcommService",b),a.$inject=["$location","$log","$window"],b.$inject=["$rootScope","$log","$http","RtcommConfigService"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queueVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){1==a&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){0==g.syncSource?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){var b=this;b.calleeID=null,b.callerID=null,b.enableCallModel=!1,b.mediaToEnable=["chat"],b.init=function(a,c){b.calleeID=a,"undefined"!=typeof c&&(b.mediaToEnable=c)},b.placeCall=function(a){var c=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});c.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+b.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==b.callerID&&"undefined"!=typeof a&&""!=a&&(b.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(b.calleeID,b.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,c,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?b.enableCallModel=!0:b.enableCallModel=!1}),$scope.$on("session:started",function(a,c){b.enableCallModel=!1}),$scope.$on("session:stopped",function(a,c){b.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), -a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){var b=this;b.calleeID=null,b.callerID=null,b.enableCallModel=!1,b.mediaToEnable=["chat"],b.init=function(a,c){b.calleeID=a,"undefined"!=typeof c&&(b.mediaToEnable=c)},b.placeCall=function(a){var c=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});c.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+b.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==b.callerID&&"undefined"!=typeof a&&""!=a&&(b.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(b.calleeID,b.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,c,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?b.enableCallModel=!0:b.enableCallModel=!1}),$scope.$on("session:started",function(a,c){b.enableCallModel=!1}),$scope.$on("session:stopped",function(a,c){b.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index af1c022..dc3e187 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -24,8 +24,7 @@ module.exports = function(config) { 'src/templates/**/*.html', 'src/js/**/*.spec.js', 'src/js/**/*.module.js', - 'src/js/*.js', - 'src/js/ui/**/*.js', + 'src/js/**/*.js', ], diff --git a/src/js/rtcomm-presence.js b/src/js/presence/rtcomm-presence.js similarity index 100% rename from src/js/rtcomm-presence.js rename to src/js/presence/rtcomm-presence.js diff --git a/src/js/services/config.service.js b/src/js/services/config.service.js new file mode 100644 index 0000000..c0eb840 --- /dev/null +++ b/src/js/services/config.service.js @@ -0,0 +1,135 @@ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-service') + .factory('RtcommConfigService', RtcommConfigService); + + /* @ngInject */ + function RtcommConfigService($location, $log, $window) { + var service = { + setProviderConfig: setProviderConfig, + getProviderConfig: getProviderConfig, + getWebRTCEnabled: getWebRTCEnabled, + getChatEnabled: getChatEnabled, + getBroadcastAudio: getBroadcastAudio, + getBroadcastVideo: getBroadcastVideo, + getRingTone: getRingTone, + getRingBackTone: getRingBackTone, + getRtcommDebug: getRtcommDebug, + isRtcommDisabled: isRtcommDisabled, + getMediaConfig: getMediaConfig + }; + + //Default provider + var providerConfig = { + server: $location.host(), + port: $location.port(), + rtcommTopicPath: '/rtcomm/', + createEndpoint: false, + appContext: 'default', + userid: '', + presence: {topic: ''} + }; + + //Rtcomm Endpoint Config Defaults + var mediaConfig = { + chat: true, + webrtc: true, + webrtcConfig: { + broadcast: { + audio: true, + video: true + } + }, + ringbacktone: null, + ringtone: null + }; + + //Rtcomm Debug + var rtcommDebug = 'INFO'; + + $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); + $log.debug('providerConfig.server: ' + providerConfig.server); + $log.debug('providerConfig.port: ' + providerConfig.port); + + return service; + + function setProviderConfig(config) { + + //Provider Config + providerConfig = { + + server : (typeof config.server !== 'undefined')? config.server : providerConfig.server, + port : (typeof config.port !== 'undefined')? config.port : providerConfig.port, + rtcommTopicPath : (typeof config.rtcommTopicPath !== 'undefined')? config.rtcommTopicPath : providerConfig.rtcommTopicPath, + createEndpoint : (typeof config.createEndpoint !== 'undefined')? config.createEndpoint : providerConfig.createEndpoint, + appContext : (typeof config.appContext !== 'undefined')? config.appContext : providerConfig.appContext, + presence : { + topic : (typeof config.presenceTopic !== 'undefined')? config.presenceTopic : providerConfig.presence.topic, + }, + userid : (typeof config.userid !== 'undefined') ? config.userid : providerConfig.userid + }; + + //Media Configuration + mediaConfig = { + chat : (typeof config.chat !== 'undefined') ? config.chat : mediaConfig.chat, + webrtc: (typeof config.video !== 'undefined') ? config.webrtc: mediaConfig.webrtc, + webrtcConfig : { + broadcast : { + video: typeof config.broadcastVideo !== 'undefined' ? config.broadcastVideo : mediaConfig.webrtcConfig.broadcast.video, + audio: typeof config.broadcastAudio !== 'undefined' ? config.broadcastAudio : mediaConfig.webrtcConfig.broadcast.audio + } + }, + ringbacktone: typeof config.ringbacktone !== 'undefined' ? config.ringbacktone : mediaConfig.ringbacktone, + ringtone: typeof config.ringtone !== 'undefined' ? config.ringtone : mediaConfig.ringtone + }; + + rtcommDebug = (typeof config.rtcommDebug !== 'undefined')? config.rtcommDebug: rtcommDebug; + + $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); + + $log.debug('providerConfig is: ' + providerConfig); + } + + function getProviderConfig(){ + return providerConfig; + } + + function getWebRTCEnabled(){ + return mediaConfig.webrtc; + } + + function getChatEnabled(){ + return mediaConfig.chat; + } + + function getBroadcastAudio(){ + return mediaConfig.webrtcConfig.broadcast.audio; + } + + function getBroadcastVideo(){ + return mediaConfig.webrtcConfig.broadcast.video; + } + + function getRingTone(){ + return mediaConfig.ringtone; + } + + function getRingBackTone(){ + return mediaConfig.ringbacktone; + } + + function getRtcommDebug(){ + return rtcommDebug; + } + + function isRtcommDisabled(){ + return false; + } + + function getMediaConfig(){ + return mediaConfig; + } + } +})(); diff --git a/src/js/services/config.service.spec.js b/src/js/services/config.service.spec.js new file mode 100644 index 0000000..b4ca5fb --- /dev/null +++ b/src/js/services/config.service.spec.js @@ -0,0 +1,183 @@ +describe('Unit Testing: Rtcomm Config Service', function() { + + var RtcommConfigService; + + //Dependencies + var $location, $window; + + //Mock and stub + var sandbox; + + beforeEach(module('angular-rtcomm-service')); + + beforeEach(inject(['$location', '$window', function(_$location_, _$window_) { + + $location = _$location_; + $window = _$window_; + sandbox = sinon.sandbox.create(); + //Mock the dependencies + sandbox.stub($location, 'absUrl', function() { + 'http://localhost:3000'; + }); + sandbox.stub($location, 'host', function() { + return 'localhost'; + }); + sandbox.stub($location, 'port', function() { + return 3000; + }); + sandbox.stub($location, 'search', function() { + return { + disableRtcomm: false + }; + }); + + }])); + + beforeEach(inject(['RtcommConfigService', function(_RtcommConfigService_) { + RtcommConfigService = _RtcommConfigService_; + }])); + + afterEach(function() { + sandbox.restore(); + }); + + var defaultConfig = { + server: 'localhost', + port: 3000, + rtcommTopicPath: '/rtcomm/', + createEndpoint: false, + appContext: 'default', + userid: '', + presence: { + topic: '' + } + }; + + + it('API should be defined', function() { + expect(RtcommConfigService.setProviderConfig).to.not.be.undefined; + expect(RtcommConfigService.getProviderConfig).to.not.be.undefined; + expect(RtcommConfigService.getWebRTCEnabled).to.not.be.undefined; + expect(RtcommConfigService.getChatEnabled).to.not.be.undefined; + expect(RtcommConfigService.getBroadcastVideo).to.not.be.undefined; + expect(RtcommConfigService.getBroadcastAudio).to.not.be.undefined; + expect(RtcommConfigService.getRingTone).to.not.be.undefined; + expect(RtcommConfigService.getRingBackTone).to.not.be.undefined; + expect(RtcommConfigService.getRtcommDebug).to.not.be.undefined; + expect(RtcommConfigService.isRtcommDisabled).to.not.be.undefined; + expect(RtcommConfigService.getMediaConfig).to.not.be.undefined; + }); + + + + + describe('default configuration values', function() { + + it('should have a default provider configuration', function() { + var providerConfig = RtcommConfigService.getProviderConfig(); + expect(providerConfig).to.deep.equal(defaultConfig); + }); + + it('webrtc should be enabled', function() { + expect(RtcommConfigService.getWebRTCEnabled()).to.be.true; + }); + + it('chat should be enabeld', function() { + expect(RtcommConfigService.getChatEnabled()).to.be.true; + }); + + it('video broadcast should be enabled', function() { + expect(RtcommConfigService.getBroadcastVideo()).to.be.true; + }); + + it('audio broadcast should be enabled', function() { + expect(RtcommConfigService.getBroadcastAudio()).to.be.true; + }); + + it('ringtone should be null', function() { + + expect(RtcommConfigService.getRingTone()).to.be.null; + }); + + it('ringbacktone should be null', function() { + + expect(RtcommConfigService.getRingBackTone()).to.be.null; + }); + + it('rtcomm debug should be on level INFO', function() { + expect(RtcommConfigService.getRtcommDebug()).to.equal('INFO'); + }); + + it('rtcommdisabled should false', function() { + expect(RtcommConfigService.isRtcommDisabled()).to.not.be.true; + }); + }); + + + it('should set the server correctly', function() { + + var config = { + server: 'localhost2' + }; + + RtcommConfigService.setProviderConfig(config); + + var rtcommConfig = RtcommConfigService.getProviderConfig(); + + expect(rtcommConfig.server).to.equal(config.server); + + for (var property in rtcommConfig) { + if (property !== 'server') { + expect(rtcommConfig[property]).to.deep.equal(defaultConfig[property]); + } + } + }); + + it('should set the port correctly', function() { + var config = { + port: 8083 + }; + + RtcommConfigService.setProviderConfig(config); + + var rtcommConfig = RtcommConfigService.getProviderConfig(); + + expect(rtcommConfig.port).to.equal(config.port); + }); + + it('should correctly set broadcastAudio and broadcastVideo property', function() { + var config = { + broadcastAudio: false, + broadcastVideo: false + }; + + RtcommConfigService.setProviderConfig(config); + + expect(RtcommConfigService.getBroadcastAudio()).to.equal(false); + expect(RtcommConfigService.getBroadcastVideo()).to.equal(false); + + config.broadcastAudio = true; + + RtcommConfigService.setProviderConfig(config); + + expect(RtcommConfigService.getBroadcastAudio()).to.equal(true); + expect(RtcommConfigService.getBroadcastVideo()).to.equal(false); + + config.broadcastVideo = true; + + RtcommConfigService.setProviderConfig(config); + expect(RtcommConfigService.getBroadcastAudio()).to.equal(true); + expect(RtcommConfigService.getBroadcastVideo()).to.equal(true); + + }); + +it('should set appContext', function(){ + var config = { + appContext: 'rtcommContext' + }; + + RtcommConfigService.setProviderConfig(config); + + expect(RtcommConfigService.getProviderConfig().appContext).to.be.equal(config.appContext); +}); +}); diff --git a/src/js/rtcomm-services.js b/src/js/services/rtcomm-service.js similarity index 80% rename from src/js/rtcomm-services.js rename to src/js/services/rtcomm-service.js index 8f0b77d..5ce3f03 100644 --- a/src/js/rtcomm-services.js +++ b/src/js/services/rtcomm-service.js @@ -3,123 +3,20 @@ */ (function() { - angular.module('angular-rtcomm-service', []) + angular.module('angular-rtcomm-service') /** * Set debugEnabled to true to enable the debug messages in this rtcomm angular module. */ .config(function($logProvider){ $logProvider.debugEnabled(true); }) - /* This causes a problem in ionic/iosrtc - .config(function($locationProvider) { - $locationProvider.html5Mode( {enabled: true, - requireBase: false}); - }) */ - .factory('RtcommConfigService', RtcommConfigService) - .factory('RtcommService', RtcommService); - /** - * - */ - RtcommConfigService.$inject = ['$location', '$log', '$window']; - function RtcommConfigService($location, $log, $window) { - // First we check to see if the URL includes the query string disableRtcomm=true. - // This is typically done when a URL is being shared vian an iFrame that includes Rtcomm directives. - // If it is set we just return without setting up Rtcomm. - $log.debug('RtcommConfigService: Abs URL: ' + $location.absUrl()); - var _disableRtcomm = $location.search().disableRtcomm; - if (typeof _disableRtcomm === "undefined" || _disableRtcomm === null) { - _disableRtcomm = false; - } else if (_disableRtcomm === "true") { - _disableRtcomm = true; - } else { - _disableRtcomm = false; - } - - $log.debug('RtcommConfigService: _disableRtcomm = ' + _disableRtcomm); - - var providerConfig = { - server : $location.host(), - port : $location.port(), - rtcommTopicPath : "/rtcomm/", - createEndpoint : false, - appContext: 'default', - userid: "", - presence : {topic : ""} - }; - - $log.debug('providerConfig.server: ' + providerConfig.server); - $log.debug('providerConfig.port: ' + providerConfig.port); - - var endpointConfig = { - chat: true, - webrtc: true - }; - - // Default to enabling audio and video. It must be disabled through config. - var broadcastAudio = true; - var broadcastVideo = true; - var rtcommDebug = "INFO"; - var ringtone = null; - var ringbacktone = null; - - var setConfig = function(config){ - providerConfig.server = (typeof config.server !== "undefined")? config.server : providerConfig.server; - providerConfig.port = (typeof config.port !== "undefined")? config.port : providerConfig.port; - providerConfig.rtcommTopicPath = (typeof config.rtcommTopicPath !== "undefined")? config.rtcommTopicPath : providerConfig.rtcommTopicPath; - providerConfig.createEndpoint = (typeof config.createEndpoint !== "undefined")? config.createEndpoint : providerConfig.createEndpoint; - providerConfig.appContext = (typeof config.appContext !== "undefined")? config.appContext : providerConfig.appContext; - providerConfig.presence.topic = (typeof config.presenceTopic !== "undefined")? config.presenceTopic : providerConfig.presence.topic; - - // We no longer need to set 'useSSL' This will be set based on how page is served. -// providerConfig.useSSL = (typeof config.useSSL !== "undefined")? config.useSSL : providerConfig.useSSL; - // Protocol related booleans - endpointConfig.chat= (typeof config.chat!== "undefined")? config.chat: endpointConfig.chat; - endpointConfig.webrtc = (typeof config.webrtc!== "undefined")? config.webrtc: endpointConfig.webrtc; - - broadcastAudio = (typeof config.broadcastAudio !== "undefined")? config.broadcastAudio: broadcastAudio; - broadcastVideo = (typeof config.broadcastVideo !== "undefined")? config.broadcastVideo: broadcastVideo; - - ringbacktone = (typeof config.ringbacktone !== "undefined")? config.ringbacktone: ringbacktone; - ringtone = (typeof config.ringtone !== "undefined")? config.ringtone : ringtone; - - rtcommDebug = (typeof config.rtcommDebug !== "undefined")? config.rtcommDebug: rtcommDebug; - - $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); - - if (typeof config.userid !== "undefined") - providerConfig.userid = config.userid; - - $log.debug('providerConfig is now: ', providerConfig); - - }; - - return { - setProviderConfig : function(config){setConfig(config);}, - - getProviderConfig : function(){return providerConfig;}, - - getWebRTCEnabled : function(){return endpointConfig.webrtc;}, - - getChatEnabled : function(){return endpointConfig.chat;}, - - getBroadcastAudio : function(){return broadcastAudio;}, - - getBroadcastVideo : function(){return broadcastVideo;}, - - getRingTone : function(){return ringtone;}, - - getRingBackTone : function(){return ringbacktone;}, - - getRtcommDebug: function(){return rtcommDebug;}, - - isRtcommDisabled : function(){return _disableRtcomm;} - }; - }; - - RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService']; - function RtcommService($rootScope, $log, $http, RtcommConfigService) { +.constant('rtcomm', rtcomm) +.factory('RtcommService', RtcommService); + RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; + function RtcommService($rootScope, $log, $http, RtcommConfigService, rtcomm) { /** Setup the endpoint provider first **/ - var myEndpointProvider = new rtcomm.EndpointProvider(); + + var myEndpointProvider = new rtcomm.EndpointProvider(); var endpointProviderInitialized = false; var queueList = null; var sessions = []; @@ -542,30 +439,15 @@ return; } - + if(config.rtcommDebug === "INFO" || config.rtcommDebug === "DEBUG"){ + myEndpointProvider.setLogLevel(config.rtcommDebug); + } $log.debug('rtcomm-services: setConfig: config: ', config); RtcommConfigService.setProviderConfig(config); - myEndpointProvider.setRtcommEndpointConfig(getMediaConfig()); + myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); if (endpointProviderInitialized == false){ - // If an identityServlet is defined we will get the User ID from the servlet. - // This is used when the user ID needs to be derived from an SSO token like LTPA. - if (typeof config.identityServlet !== "undefined" && config.identityServlet != null){ - $http.get(config.identityServlet).success (function(data){ - - if (typeof data.userid !== "undefined"){ - RtcommConfigService.setProviderConfig(data); - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; - } - else - $log.error('RtcommService: setConfig promise: Invalid JSON object return from identityServlet: ', data); - }).error(function(data, status, headers, config) { - $log.debug('RtcommService: setConfig promise: error accessing userid from identityServlet: ' + status); - }); - } - else{ // If the user does not specify a userid, that says one will never be specified so go ahead // and initialize the endpoint provider and let the provider assign a name. If a defined empty // string is passed in, that means to wait until the end user registers a name. @@ -573,7 +455,6 @@ myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); endpointProviderInitialized = true; } - } } }, @@ -845,7 +726,7 @@ endpoint = _getEndpoint(_getActiveEndpointUUID()); if (endpoint != null){ - + $log.debug(endpoint); endpoint.webrtc.setLocalMedia( { mediaOut: document.querySelector('#' + _selfView), @@ -856,4 +737,4 @@ }; }; -})(); \ No newline at end of file +})(); diff --git a/src/js/services/rtcomm-service.spec.js b/src/js/services/rtcomm-service.spec.js new file mode 100644 index 0000000..0ff2a06 --- /dev/null +++ b/src/js/services/rtcomm-service.spec.js @@ -0,0 +1,152 @@ +describe('Unit Testing: RtcommService', function(){ + //Dependencies + var $rootScope, $httpBackend, RtcommConfigService, rtcomm; + + //Mock and stubbing sandbox + var sandbox; + + var RtcommService; + + + beforeEach(function(){ + module('angular-rtcomm-service'); + }); + + beforeEach(function(){ + + var rtcomm = generateMockRtcomm(); + module(function($provide){ + $provide.constant('rtcomm', rtcomm); + }); + }); + + beforeEach(inject(['$rootScope', 'RtcommConfigService', 'rtcomm', '$httpBackend', 'RtcommService', + function(_$rootScope_, _RtcommConfigService_, _rtcomm_, _$httpBackend_, _RtcommService_){ + + $rootScope = _$rootScope_; + RtcommConfigService = _RtcommConfigService_; + rtcomm = _rtcomm_; + $httpBackend = _$httpBackend_; + RtcommService = _RtcommService_; + sandbox = sinon.sandbox.create(); + }])); + + afterEach(function(){ + sandbox.restore(); + }); + describe('initialization without user id', function(){ + + it('check state before init', function(){ + expect(RtcommService.isInitialized()).to.be.false; + }); + + it('should still not initialize without a userid defined', function(){ + var config = { + userid: '' + }; + sandbox.stub(RtcommConfigService, 'setProviderConfig', function(config){}); + sandbox.stub(RtcommConfigService, 'getMediaConfig', function(){}); + RtcommService.setConfig(config); + + expect(RtcommConfigService.setProviderConfig.calledWith(config)).to.be.true; + expect(RtcommConfigService.getMediaConfig.calledOnce).to.be.true; + expect(RtcommService.isInitialized()).to.be.false; + }); + }); + + describe('setConfig functionalities', function(){ + var sampleConfig = { + server: 'localhost', + port: '80', + rtcommTopicPath: '/rtcomm/', + userid: '' + }; + it('should do nothing if isRtcommDisabled', function(){ + sandbox.stub(RtcommConfigService, 'isRtcommDisabled', function(){ return true;}); + + RtcommService.setConfig({}); + expect(RtcommConfigService.isRtcommDisabled.calledOnce).to.be.true; + + expect(RtcommService.isInitialized()).to.be.false; + }); + + it('should setConfiguration but not initialize if the userid is not set', function(){ + + sandbox.stub(RtcommConfigService, 'setProviderConfig', function(config){}); + sandbox.stub(RtcommConfigService, 'getMediaConfig', function(){}); + sandbox.stub(RtcommConfigService, 'getProviderConfig', function(){return sampleConfig}); + + RtcommService.setConfig(sampleConfig); + + expect(RtcommConfigService.setProviderConfig.calledWith(sampleConfig)).to.be.true; + expect(RtcommService.isInitialized()).to.be.false; + }); + + it('should initialize if a userid is defined', function(){ + sandbox.stub(RtcommConfigService, 'setProviderConfig', function(config){}); + sandbox.stub(RtcommConfigService, 'getMediaConfig', function(){}); + sandbox.stub(RtcommConfigService, 'getProviderConfig', function(){return sampleConfig}); + sampleConfig.userid = 'MockUser'; + RtcommService.setConfig(sampleConfig); + + expect(RtcommService.isInitialized()).to.be.true; + }); + + + }); + //TODO Need better presence test methods + describe('presence related events', function(){ + it('should get an empty presence monitor', function(){ + expect(RtcommService.getPresenceMonitor).to.not.be.undefined; + var presenceMonitor = RtcommService.getPresenceMonitor('someTopic'); + + expect(presenceMonitor).to.be.empty; + + }); + + it('should be able to publish a presence', function(){ + expect(RtcommService.publishPresence).to.not.be.undefined; + + //Initialize first + RtcommService.publishPresence(); + }); + + }); + + //Helper functions + function generateMockRtcomm(){ + + return { + EndpointProvider: MockEndpointProvider + + }; + + + } + + function MockEndpointProvider(){ + this.setLogLevel = function(level){ + }; + this.getLogLevel = function(){ + return 'DEBUG';}; + + this.setAppContext = function(appContext){}; + + this.on = function(eventName, func){}; + + this.setRtcommEndpointConfig = function(configurationCallbacks){}; + + this.getPresenceMonitor = function(topic){ return {}}; + + this.publishPresence = function(record){}; + + this.createRtcommEndpoint = function() { return null; }; + + this.getRtcommEndpoint = function(id) { return null; }; + + this.init = function(providerConfig, successCallback, failureCallback){}; + + } + + +}); diff --git a/src/js/services/services.module.js b/src/js/services/services.module.js new file mode 100644 index 0000000..5ab2b7f --- /dev/null +++ b/src/js/services/services.module.js @@ -0,0 +1,6 @@ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-service', []); +})(); diff --git a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js index e66bfb1..c34738d 100644 --- a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js +++ b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js @@ -24,8 +24,8 @@ angular .module('angular-rtcomm-ui') - .directive('rtcommVideo', rtcommVideo); - + .directive('rtcommVideo', rtcommVideo) + .controller('RtcommVideoController', VideoController); /* @ngInject */ function rtcommVideo() { var directive = { From 78a11d984271a686b0277de4e0e853f74d719efd Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Thu, 17 Mar 2016 08:54:26 -0400 Subject: [PATCH 10/21] Adding a simple test file for call-modal, fixing dependency injection of call-modal --- src/js/ui/modals/call-modal/call-modal.js | 2 +- .../ui/modals/call-modal/call-modal.spec.js | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/js/ui/modals/call-modal/call-modal.spec.js diff --git a/src/js/ui/modals/call-modal/call-modal.js b/src/js/ui/modals/call-modal/call-modal.js index 0075329..f07cdf9 100644 --- a/src/js/ui/modals/call-modal/call-modal.js +++ b/src/js/ui/modals/call-modal/call-modal.js @@ -28,7 +28,7 @@ RtcommCallModalController.$inject = ['RtcommService', '$modal', '$scope', '$log']; /* @ngInject */ - function RtcommCallModalController(dependencies) { + function RtcommCallModalController(RtcommService, $modal, $scope, $log){ var vm = this; vm.calleeID = null; vm.callerID = null; diff --git a/src/js/ui/modals/call-modal/call-modal.spec.js b/src/js/ui/modals/call-modal/call-modal.spec.js new file mode 100644 index 0000000..c008eef --- /dev/null +++ b/src/js/ui/modals/call-modal/call-modal.spec.js @@ -0,0 +1,29 @@ +describe('Unit Test: Call Modal', function(){ + //Dependencies + var RtcommService, $modal, $rootScope; + + //Sandbox + var sandbox; + + var RtcommCallDiv; + beforeEach(module('angular-rtcomm-ui')); + + beforeEach(inject(['$modal', 'RtcommService', '$compile', '$rootScope', + function(_$modal_, _RtcommService_, _$compile_, _$rootScope_){ + + $modal = _$modal_; + RtcommService = _RtcommService_; + $compile = _$compile_; + $rootScope = _$rootScope_; + RtcommCallDiv = $compile('
')($rootScope); + + + + } + + ])); + + it('should at least compile without errors', function(){ + + }); +}); From 4d86243bf9f73d39945df19beb82dce6bf42f247 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Thu, 17 Mar 2016 08:56:47 -0400 Subject: [PATCH 11/21] Adding a simple test file for call-modal, fixing dependency injection of call-modal --- dist/angular-rtcomm.js | 4 ++-- dist/angular-rtcomm.min.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 7917953..d0b2b5d 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-16 + * @version v1.0.3 - 2016-03-17 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -2303,7 +2303,7 @@ angular RtcommCallModalController.$inject = ['RtcommService', '$modal', '$scope', '$log']; /* @ngInject */ - function RtcommCallModalController(dependencies) { + function RtcommCallModalController(RtcommService, $modal, $scope, $log){ var vm = this; vm.calleeID = null; vm.callerID = null; diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index e3792f2..68b33be 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-16 + * @version v1.0.3 - 2016-03-17 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a){var b=this;b.calleeID=null,b.callerID=null,b.enableCallModel=!1,b.mediaToEnable=["chat"],b.init=function(a,c){b.calleeID=a,"undefined"!=typeof c&&(b.mediaToEnable=c)},b.placeCall=function(a){var c=$modal.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:a,resolve:{}});c.result.then(function(a){$log.debug("rtcommCallModal: Calling calleeID: "+b.calleeID),$log.debug("rtcommCallModal: CallerID: "+a),null==b.callerID&&"undefined"!=typeof a&&""!=a&&(b.callerID=a,RtcommService.setAlias(a)),RtcommService.placeCall(b.calleeID,b.mediaToEnable)},function(){$log.info("Modal dismissed at: "+new Date)})},$scope.$on("rtcomm::init",function(a,c,d){$log.debug("RtcommCallModalController: rtcomm::init: success = "+c),1==c?b.enableCallModel=!0:b.enableCallModel=!1}),$scope.$on("session:started",function(a,c){b.enableCallModel=!1}),$scope.$on("session:stopped",function(a,c){b.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file From 6d42b28c8ff7d0f3583f5f5c591b9c9fdb0177a6 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Thu, 17 Mar 2016 10:02:44 -0400 Subject: [PATCH 12/21] Updating license headers on source files --- dist/angular-rtcomm.js | 83 +++++++++++++++---- dist/angular-rtcomm.min.js | 2 +- src/js/presence/rtcomm-presence.js | 2 +- src/js/services/config.service.js | 17 ++++ src/js/services/config.service.spec.js | 18 ++++ src/js/services/rtcomm-service.js | 18 ++++ src/js/services/rtcomm-service.spec.js | 17 ++++ src/js/services/services.module.js | 18 ++++ src/js/ui/config.controller.js | 2 +- src/js/ui/config.controller.spec.js | 18 ++++ .../rtcomm-alert/rtcomm-alert.js | 2 +- .../rtcomm-alert/rtcomm-alert.spec.js | 19 +++++ .../rtcomm-queues/rtcomm-queues.js | 2 +- .../rtcomm-queues/rtcomm-queues.spec.js | 18 ++++ .../rtcomm-register/rtcomm-register.js | 2 +- .../rtcomm-register/rtcomm-register.spec.js | 16 ++++ .../rtcomm-session-manager.js | 2 +- .../rtcomm-session-manager.spec.js | 18 ++++ .../endpoint.controller.js | 2 +- .../endpoint.controller.spec.js | 18 ++++ src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js | 6 +- .../endpoint/rtcomm-chat/rtcomm-chat.spec.js | 18 ++++ .../rtcomm-endpoint-status.js | 2 +- .../rtcomm-endpoint-status.spec.js | 17 ++++ .../endpoint/rtcomm-iframe/rtcomm-iframe.js | 2 +- .../rtcomm-iframe/rtcomm-iframe.spec.js | 18 ++++ .../ui/endpoint/rtcomm-video/rtcomm-video.js | 2 +- .../rtcomm-video/rtcomm-video.spec.js | 17 ++++ src/js/ui/modals/alert-modal/alert-modal.js | 2 +- .../ui/modals/alert-modal/alert-modal.spec.js | 18 ++++ src/js/ui/modals/call-modal/call-modal.js | 2 +- .../ui/modals/call-modal/call-modal.spec.js | 18 ++++ 32 files changed, 385 insertions(+), 31 deletions(-) diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index d0b2b5d..7a598de 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -43,6 +43,24 @@ ]); })(); + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + (function() { 'use strict'; @@ -79,7 +97,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -225,6 +243,23 @@ angular }; })(); + +/** + * (C) Copyright IBM Corporation 2015. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + (function() { 'use strict'; @@ -362,6 +397,24 @@ angular RtcommConfigService.$inject = ["$location", "$log", "$window"]; })(); + +/** + *(C) Copyright IBM Corporation 2015. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** * Definition for the rtcommModule */ @@ -1104,7 +1157,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1190,7 +1243,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1244,7 +1297,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1401,7 +1454,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1491,7 +1544,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1586,7 +1639,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1688,7 +1741,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1741,7 +1794,7 @@ angular scope.bottom = flag; } - + if(chatPanel.length > 0){ //Watch scroll events chatPanel.bind('scroll', function() { if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { @@ -1763,7 +1816,7 @@ angular } }, true); - } + }} } @@ -1812,7 +1865,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1967,7 +2020,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -2073,7 +2126,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -2159,7 +2212,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -2274,7 +2327,7 @@ angular })(); /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index 68b33be..7646d0f 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -18,5 +18,5 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0)}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/presence/rtcomm-presence.js b/src/js/presence/rtcomm-presence.js index 98e022b..93e0be3 100644 --- a/src/js/presence/rtcomm-presence.js +++ b/src/js/presence/rtcomm-presence.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/services/config.service.js b/src/js/services/config.service.js index c0eb840..6bc6560 100644 --- a/src/js/services/config.service.js +++ b/src/js/services/config.service.js @@ -1,3 +1,20 @@ + +/** + * (C) Copyright IBM Corporation 2015. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + (function() { 'use strict'; diff --git a/src/js/services/config.service.spec.js b/src/js/services/config.service.spec.js index b4ca5fb..3236e8e 100644 --- a/src/js/services/config.service.spec.js +++ b/src/js/services/config.service.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Unit Testing: Rtcomm Config Service', function() { var RtcommConfigService; diff --git a/src/js/services/rtcomm-service.js b/src/js/services/rtcomm-service.js index 5ce3f03..22d1e91 100644 --- a/src/js/services/rtcomm-service.js +++ b/src/js/services/rtcomm-service.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2015. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** * Definition for the rtcommModule */ diff --git a/src/js/services/rtcomm-service.spec.js b/src/js/services/rtcomm-service.spec.js index 0ff2a06..50d379d 100644 --- a/src/js/services/rtcomm-service.spec.js +++ b/src/js/services/rtcomm-service.spec.js @@ -1,3 +1,20 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + describe('Unit Testing: RtcommService', function(){ //Dependencies var $rootScope, $httpBackend, RtcommConfigService, rtcomm; diff --git a/src/js/services/services.module.js b/src/js/services/services.module.js index 5ab2b7f..91da229 100644 --- a/src/js/services/services.module.js +++ b/src/js/services/services.module.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + (function() { 'use strict'; diff --git a/src/js/ui/config.controller.js b/src/js/ui/config.controller.js index 37c6e7a..3e0a496 100644 --- a/src/js/ui/config.controller.js +++ b/src/js/ui/config.controller.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/config.controller.spec.js b/src/js/ui/config.controller.spec.js index e4e39b6..fec38d5 100644 --- a/src/js/ui/config.controller.spec.js +++ b/src/js/ui/config.controller.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Unit Testing: RtcommConfigController', function() { var sandbox; diff --git a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js index 7b25903..61ac3f0 100644 --- a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js +++ b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js index 082fac3..e71f6e7 100644 --- a/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-alert/rtcomm-alert.spec.js @@ -1,3 +1,22 @@ + + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Unit Testing: RtcommAlert directive', function(){ var _$rootScope, element; beforeEach(module("rtcomm.templates")); diff --git a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js index db1de10..f89fed1 100644 --- a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js +++ b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js index 950e9b9..9b72a83 100644 --- a/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-queues/rtcomm-queues.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + //TODO Finish rtcomm-queues unit test describe('Unit Testing: RtcommQueues directive', function() { diff --git a/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.js b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.js index 527d6ef..fbb57f0 100644 --- a/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.js +++ b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js index 92f71b9..2f8fa69 100644 --- a/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-register/rtcomm-register.spec.js @@ -1,4 +1,20 @@ +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + describe('Unit Testing: Register directive', function() { var $compile, _$rootScope, sandbox, scope, ctrl, element; diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js index cc36198..63d2afc 100644 --- a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js index 76021e6..5590218 100644 --- a/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js +++ b/src/js/ui/endpoint-provider/rtcomm-session-manager/rtcomm-session-manager.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + //TODO Finish Session manager Unit Test describe('Unit Testing: RtcommSessionManager directive', function(){ var $compile, $rootScope; diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js index 2306f0c..1305822 100644 --- a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js index 42d26c7..9a53a4d 100644 --- a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Unit Testing: Endpoint Controller', function(){ //Dependency var RtcommService; diff --git a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js index 4d48a46..6b0fe20 100644 --- a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js +++ b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ scope.bottom = flag; } - + if(chatPanel.length > 0){ //Watch scroll events chatPanel.bind('scroll', function() { if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { @@ -74,7 +74,7 @@ } }, true); - } + }} } diff --git a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js index d2960f1..2aeb3b1 100644 --- a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js +++ b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Unit Testing: RtcommChat directive', function() { var $compile, _$rootScope, sandbox, scope, element; diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js index 381d8f7..4ed1715 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js index 73779b7..54dc84b 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js @@ -1,3 +1,20 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + describe('Unit Testing: RtcommEndpointStatus directive', function() { var $compile, _$rootScope, sandbox, scope, element, endpointStatusElement; diff --git a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js index ac2154c..675aa1c 100644 --- a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js +++ b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js index 33e009a..3746cc5 100644 --- a/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js +++ b/src/js/ui/endpoint/rtcomm-iframe/rtcomm-iframe.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Unit Testing: RtcommIFrame directive', function() { //Dependencies diff --git a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js index c34738d..a788c60 100644 --- a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js +++ b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js index 1ac02bf..7b4c6fa 100644 --- a/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js +++ b/src/js/ui/endpoint/rtcomm-video/rtcomm-video.spec.js @@ -1,3 +1,20 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + describe('Unit Testing: RtcommVideo directive', function() { var $compile, _$rootScope, sandbox, scope, element; beforeEach(module("rtcomm.templates")); diff --git a/src/js/ui/modals/alert-modal/alert-modal.js b/src/js/ui/modals/alert-modal/alert-modal.js index 4705691..d58ed50 100644 --- a/src/js/ui/modals/alert-modal/alert-modal.js +++ b/src/js/ui/modals/alert-modal/alert-modal.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/modals/alert-modal/alert-modal.spec.js b/src/js/ui/modals/alert-modal/alert-modal.spec.js index 121dcb8..c81a10b 100644 --- a/src/js/ui/modals/alert-modal/alert-modal.spec.js +++ b/src/js/ui/modals/alert-modal/alert-modal.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Controller Testing: Rtcomm Alert Modal', function() { var $compile, $rootScope, $modal, element, sandbox, body; diff --git a/src/js/ui/modals/call-modal/call-modal.js b/src/js/ui/modals/call-modal/call-modal.js index f07cdf9..b61b80d 100644 --- a/src/js/ui/modals/call-modal/call-modal.js +++ b/src/js/ui/modals/call-modal/call-modal.js @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2016. + * (C) Copyright IBM Corporation 2015. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/js/ui/modals/call-modal/call-modal.spec.js b/src/js/ui/modals/call-modal/call-modal.spec.js index c008eef..3cd467f 100644 --- a/src/js/ui/modals/call-modal/call-modal.spec.js +++ b/src/js/ui/modals/call-modal/call-modal.spec.js @@ -1,3 +1,21 @@ + +/** + *(C) Copyright IBM Corporation 2016. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + describe('Unit Test: Call Modal', function(){ //Dependencies var RtcommService, $modal, $rootScope; From 864144ebb7f334a845b7698bce1960836fb1a1de Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Thu, 17 Mar 2016 10:52:00 -0400 Subject: [PATCH 13/21] Updating bower.json to version 1.0.3 -> 1.0.4, updated dependencies to latest releases, RtcommVideoController is no longer backwards compatible --- bower.json | 17 ++++------ dist/angular-rtcomm.js | 33 ++++++++++--------- dist/angular-rtcomm.min.js | 2 +- src/js/services/config.service.js | 2 +- src/js/ui/modals/alert-modal/alert-modal.js | 15 +++++---- .../ui/modals/alert-modal/alert-modal.spec.js | 14 ++++---- src/js/ui/modals/call-modal/call-modal.js | 12 +++---- .../ui/modals/call-modal/call-modal.spec.js | 8 ++--- src/templates/rtcomm/rtcomm-alert.html | 2 +- 9 files changed, 52 insertions(+), 53 deletions(-) diff --git a/bower.json b/bower.json index 61140e1..692eedf 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-rtcomm", - "version": "1.0.3", + "version": "1.0.4", "description": "Angular module for Rtcomm", "main": [ "dist/angular-rtcomm.js", @@ -30,17 +30,14 @@ "package.json" ], "dependencies": { - "jquery": "~2.1.1", - "angular-tree-control": "~0.2.7", - "bootstrap": "~3.3.1", - "angular": "^1.4.6", - "angular-bootstrap": "~0.13.0", + "jquery": "~2.2.x", + "angular-tree-control": "~0.2.x", + "bootstrap": "~3.3.6", + "angular": "~1.4.0", + "angular-bootstrap": "1.2.x", "rtcomm": "^1.0.0" }, "devDependencies": { - "angular-mocks": "~1.5.0" - }, - "resolutions": { - "angular": "1.5.0" + "angular-mocks": "~1.4.0" } } diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 7a598de..643dacc 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -309,7 +309,7 @@ angular }; //Rtcomm Debug - var rtcommDebug = 'INFO'; + var rtcommDebug = 'DEBUG'; $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); $log.debug('providerConfig.server: ' + providerConfig.server); @@ -2240,10 +2240,10 @@ angular .controller('RtcommAlertModalController', RtcommAlertModalController) .controller('RtcommAlertModalInstanceController', RtcommAlertModalInstanceController); - RtcommAlertModalController.$inject = ['RtcommService', '$modal', '$rootScope', '$scope', '$log']; + RtcommAlertModalController.$inject = ['RtcommService', '$uibModal', '$rootScope', '$scope', '$log']; /* @ngInject */ - function RtcommAlertModalController(RtcommService, $modal, $rootScope, $scope, $log) { + function RtcommAlertModalController(RtcommService, $uibModal, $rootScope, $scope, $log) { var vm = this; vm.alertingEndpointUUID = null; vm.autoAnswerNewMedia = false; @@ -2252,7 +2252,7 @@ angular vm.showAlerting = function(size) { - var modalInstance = $modal.open({ + var modalInstance = $uibModal.open({ templateUrl: 'templates/rtcomm/rtcomm-modal-alert.html', controller: 'RtcommAlertModalInstanceController', size: size, @@ -2310,18 +2310,19 @@ angular } - RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; + RtcommAlertModalInstanceController.$inject = ['$scope', '$uibModalInstance', '$log', 'caller']; - function RtcommAlertModalInstanceController($scope, $modalInstance, $log, caller) { + function RtcommAlertModalInstanceController($scope, $uibModalInstance, $log, caller) { $scope.caller = caller; $scope.ok = function () { $log.debug('Accepting alerting call'); - $modalInstance.close(); + $uibModalInstance.close(); }; $scope.cancel = function () { $log.debug('Rejecting alerting call'); - $modalInstance.dismiss('cancel'); + $uibModalInstance.dismiss('cancel'); + }; }; })(); @@ -2353,10 +2354,10 @@ angular .controller('RtcommCallModalController', RtcommCallModalController) .controller('RtcommCallModalInstanceController', RtcommCallModalInstanceController); - RtcommCallModalController.$inject = ['RtcommService', '$modal', '$scope', '$log']; + RtcommCallModalController.$inject = ['RtcommService', '$uibModal', '$scope', '$log']; /* @ngInject */ - function RtcommCallModalController(RtcommService, $modal, $scope, $log){ + function RtcommCallModalController(RtcommService, $uibModal, $scope, $log){ var vm = this; vm.calleeID = null; vm.callerID = null; @@ -2373,7 +2374,7 @@ angular vm.placeCall = function(size) { - var modalInstance = $modal.open({ + var modalInstance = $uibModal.open({ templateUrl: 'templates/rtcomm/rtcomm-modal-call.html', controller: 'RtcommCallModalInstanceController', size: size, @@ -2416,23 +2417,23 @@ angular } - function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { + function RtcommCallModalInstanceController($scope, $uibModalInstance, RtcommService) { $scope.endpointAlias = ''; $scope.ok = function() { - $modalInstance.close($scope.endpointAlias); + $uibModalInstance.close($scope.endpointAlias); }; $scope.cancel = function() { - $modalInstance.dismiss('cancel'); + $uibModalInstance.dismiss('cancel'); }; } - RtcommCallModalInstanceController.$inject = ["$scope", "$modalInstance", "RtcommService"];; + RtcommCallModalInstanceController.$inject = ["$scope", "$uibModalInstance", "RtcommService"];; })(); angular.module('angular-rtcomm-ui').run(['$templateCache', function($templateCache) { 'use strict'; $templateCache.put('templates/rtcomm/rtcomm-alert.html', - "
{{alert.msg}}
" + "
{{alert.msg}}
" ); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index 7646d0f..d396aa6 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -18,5 +18,5 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$modal","$rootScope","$scope","$log"],b.$inject=["$scope","$modalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$modal","$scope","$log"],b.$inject=["$scope","$modalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/services/config.service.js b/src/js/services/config.service.js index 6bc6560..bf12a65 100644 --- a/src/js/services/config.service.js +++ b/src/js/services/config.service.js @@ -64,7 +64,7 @@ }; //Rtcomm Debug - var rtcommDebug = 'INFO'; + var rtcommDebug = 'DEBUG'; $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); $log.debug('providerConfig.server: ' + providerConfig.server); diff --git a/src/js/ui/modals/alert-modal/alert-modal.js b/src/js/ui/modals/alert-modal/alert-modal.js index d58ed50..72cb30b 100644 --- a/src/js/ui/modals/alert-modal/alert-modal.js +++ b/src/js/ui/modals/alert-modal/alert-modal.js @@ -27,10 +27,10 @@ .controller('RtcommAlertModalController', RtcommAlertModalController) .controller('RtcommAlertModalInstanceController', RtcommAlertModalInstanceController); - RtcommAlertModalController.$inject = ['RtcommService', '$modal', '$rootScope', '$scope', '$log']; + RtcommAlertModalController.$inject = ['RtcommService', '$uibModal', '$rootScope', '$scope', '$log']; /* @ngInject */ - function RtcommAlertModalController(RtcommService, $modal, $rootScope, $scope, $log) { + function RtcommAlertModalController(RtcommService, $uibModal, $rootScope, $scope, $log) { var vm = this; vm.alertingEndpointUUID = null; vm.autoAnswerNewMedia = false; @@ -39,7 +39,7 @@ vm.showAlerting = function(size) { - var modalInstance = $modal.open({ + var modalInstance = $uibModal.open({ templateUrl: 'templates/rtcomm/rtcomm-modal-alert.html', controller: 'RtcommAlertModalInstanceController', size: size, @@ -97,18 +97,19 @@ } - RtcommAlertModalInstanceController.$inject = ['$scope', '$modalInstance', '$log', 'caller']; + RtcommAlertModalInstanceController.$inject = ['$scope', '$uibModalInstance', '$log', 'caller']; - function RtcommAlertModalInstanceController($scope, $modalInstance, $log, caller) { + function RtcommAlertModalInstanceController($scope, $uibModalInstance, $log, caller) { $scope.caller = caller; $scope.ok = function () { $log.debug('Accepting alerting call'); - $modalInstance.close(); + $uibModalInstance.close(); }; $scope.cancel = function () { $log.debug('Rejecting alerting call'); - $modalInstance.dismiss('cancel'); + $uibModalInstance.dismiss('cancel'); + }; }; })(); diff --git a/src/js/ui/modals/alert-modal/alert-modal.spec.js b/src/js/ui/modals/alert-modal/alert-modal.spec.js index c81a10b..892edb3 100644 --- a/src/js/ui/modals/alert-modal/alert-modal.spec.js +++ b/src/js/ui/modals/alert-modal/alert-modal.spec.js @@ -17,14 +17,14 @@ describe('Controller Testing: Rtcomm Alert Modal', function() { - var $compile, $rootScope, $modal, element, sandbox, body; + var $compile, $rootScope, $uibModal, element, sandbox, body; beforeEach(module("rtcomm.templates")); beforeEach(module('angular-rtcomm-ui')); //Setup test environment - beforeEach(inject(function($compile, $rootScope, $modal, RtcommService, $window) { + beforeEach(inject(function($compile, $rootScope, $uibModal, RtcommService, $window) { sandbox = sinon.sandbox.create(); _$rootScope = $rootScope; element = $compile('
')(_$rootScope); @@ -38,7 +38,7 @@ describe('Controller Testing: Rtcomm Alert Modal', function() { it('alert modal controller should be available', function() { expect(element.attr('ng-controller')).to.include('RtcommAlertModalController'); }) - it('should open on sesssion:alerting and accept', inject(function($modal, RtcommService) { + it('should open on sesssion:alerting and accept', inject(function($uibModal, RtcommService) { var mockModal = getMockModal(); @@ -48,7 +48,7 @@ describe('Controller Testing: Rtcomm Alert Modal', function() { } }); - var modalSpy = sinon.stub($modal, 'open', function() { + var modalSpy = sinon.stub($uibModal, 'open', function() { return mockModal; }); @@ -70,7 +70,7 @@ describe('Controller Testing: Rtcomm Alert Modal', function() { modalSpy.restore(); })); - it('should open on session:alerting and reject correctly', inject(function(RtcommService, $modal) { + it('should open on session:alerting and reject correctly', inject(function(RtcommService, $uibModal) { var mockModal = getMockModal(); var rtcommServiceStub = sinon.stub(RtcommService, 'getEndpoint', function() { @@ -79,7 +79,7 @@ describe('Controller Testing: Rtcomm Alert Modal', function() { } }); - var modalSpy = sinon.stub($modal, 'open', function() { + var modalSpy = sinon.stub($uibModal, 'open', function() { return mockModal; }); @@ -119,7 +119,7 @@ describe('Controller Testing: Rtcomm Alert Modal', function() { scope = $rootScope.$new(); ctrl = $controller('RtcommAlertModalInstanceController', { $scope: scope, - $modalInstance: modalInstance, + $uibModalInstance: modalInstance, $log: $log, caller: 'MockUser' }); diff --git a/src/js/ui/modals/call-modal/call-modal.js b/src/js/ui/modals/call-modal/call-modal.js index b61b80d..86e5057 100644 --- a/src/js/ui/modals/call-modal/call-modal.js +++ b/src/js/ui/modals/call-modal/call-modal.js @@ -25,10 +25,10 @@ .controller('RtcommCallModalController', RtcommCallModalController) .controller('RtcommCallModalInstanceController', RtcommCallModalInstanceController); - RtcommCallModalController.$inject = ['RtcommService', '$modal', '$scope', '$log']; + RtcommCallModalController.$inject = ['RtcommService', '$uibModal', '$scope', '$log']; /* @ngInject */ - function RtcommCallModalController(RtcommService, $modal, $scope, $log){ + function RtcommCallModalController(RtcommService, $uibModal, $scope, $log){ var vm = this; vm.calleeID = null; vm.callerID = null; @@ -45,7 +45,7 @@ vm.placeCall = function(size) { - var modalInstance = $modal.open({ + var modalInstance = $uibModal.open({ templateUrl: 'templates/rtcomm/rtcomm-modal-call.html', controller: 'RtcommCallModalInstanceController', size: size, @@ -88,13 +88,13 @@ } - function RtcommCallModalInstanceController($scope, $modalInstance, RtcommService) { + function RtcommCallModalInstanceController($scope, $uibModalInstance, RtcommService) { $scope.endpointAlias = ''; $scope.ok = function() { - $modalInstance.close($scope.endpointAlias); + $uibModalInstance.close($scope.endpointAlias); }; $scope.cancel = function() { - $modalInstance.dismiss('cancel'); + $uibModalInstance.dismiss('cancel'); }; }; diff --git a/src/js/ui/modals/call-modal/call-modal.spec.js b/src/js/ui/modals/call-modal/call-modal.spec.js index 3cd467f..872861d 100644 --- a/src/js/ui/modals/call-modal/call-modal.spec.js +++ b/src/js/ui/modals/call-modal/call-modal.spec.js @@ -18,7 +18,7 @@ describe('Unit Test: Call Modal', function(){ //Dependencies - var RtcommService, $modal, $rootScope; + var RtcommService, $uibModal, $rootScope; //Sandbox var sandbox; @@ -26,10 +26,10 @@ describe('Unit Test: Call Modal', function(){ var RtcommCallDiv; beforeEach(module('angular-rtcomm-ui')); - beforeEach(inject(['$modal', 'RtcommService', '$compile', '$rootScope', - function(_$modal_, _RtcommService_, _$compile_, _$rootScope_){ + beforeEach(inject(['$uibModal', 'RtcommService', '$compile', '$rootScope', + function(_$uibModal_, _RtcommService_, _$compile_, _$rootScope_){ - $modal = _$modal_; + $uibModal = _$uibModal_; RtcommService = _RtcommService_; $compile = _$compile_; $rootScope = _$rootScope_; diff --git a/src/templates/rtcomm/rtcomm-alert.html b/src/templates/rtcomm/rtcomm-alert.html index 68ebf62..60e0326 100644 --- a/src/templates/rtcomm/rtcomm-alert.html +++ b/src/templates/rtcomm/rtcomm-alert.html @@ -1,3 +1,3 @@
- {{alert.msg}} + {{alert.msg}}
From 30a41faaaaa213a9e86cde19659dc2cd9a3933cb Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Thu, 17 Mar 2016 13:47:37 -0400 Subject: [PATCH 14/21] Initial refactoring to rtcomm-service.js --- dist/angular-rtcomm.js | 1494 +++++++++-------- dist/angular-rtcomm.min.js | 4 +- src/js/services/config.service.js | 2 +- src/js/services/rtcomm-service.js | 913 +++++----- src/js/services/rtcomm-service.spec.js | 36 + src/js/ui/config.controller.js | 68 +- src/js/ui/config.controller.spec.js | 99 +- .../endpoint.controller.js | 138 +- .../endpoint.controller.spec.js | 87 +- src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js | 191 +-- .../endpoint/rtcomm-chat/rtcomm-chat.spec.js | 391 +++-- .../rtcomm-endpoint-status.js | 232 +-- .../rtcomm-endpoint-status.spec.js | 275 +-- 13 files changed, 2076 insertions(+), 1854 deletions(-) diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 643dacc..b25b663 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -309,7 +309,7 @@ angular }; //Rtcomm Debug - var rtcommDebug = 'DEBUG'; + var rtcommDebug = 'INFO'; $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); $log.debug('providerConfig.server: ' + providerConfig.server); @@ -397,18 +397,17 @@ angular RtcommConfigService.$inject = ["$location", "$log", "$window"]; })(); - /** *(C) Copyright IBM Corporation 2015. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -424,32 +423,45 @@ angular /** * Set debugEnabled to true to enable the debug messages in this rtcomm angular module. */ - .config(["$logProvider", function($logProvider){ - $logProvider.debugEnabled(true); + .config(["$logProvider", function($logProvider) { + $logProvider.debugEnabled(true); }]) -.constant('rtcomm', rtcomm) -.factory('RtcommService', RtcommService); - RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; - function RtcommService($rootScope, $log, $http, RtcommConfigService, rtcomm) { - /** Setup the endpoint provider first **/ + .constant('rtcomm', rtcomm) + .factory('RtcommService', RtcommService); + RtcommService.$inject = ['$rootScope', '$log', 'RtcommConfigService', 'rtcomm']; + + function RtcommService($rootScope, $log, RtcommConfigService, rtcomm) { + /** Setup the endpoint provider first **/ + /*var service = { + alert: alert, + setKarmaTesting: setKarmaTesting, + isInitialized: isInitialized, + setConfig: setConfig + /* Presence Methods */ - var myEndpointProvider = new rtcomm.EndpointProvider(); + //}/ + + + var myEndpointProvider = new rtcomm.EndpointProvider(); var endpointProviderInitialized = false; var queueList = null; var sessions = []; var presenceRecord = null; var karmaTesting = false; - var _selfView = "selfView"; // Default self view - var _remoteView = "remoteView"; // Default remote view + var _selfView = 'selfView'; // Default self view + var _remoteView = 'remoteView'; // Default remote view myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); - $log.debug('rtcomm-service - endpointProvider log level is: '+myEndpointProvider.getLogLevel()); - $log.debug('rtcomm-service - endpointProvider log level should be: '+RtcommConfigService.getRtcommDebug()); + $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); + $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); myEndpointProvider.setAppContext(RtcommConfigService.getProviderConfig().appContext); - var getPresenceRecord = function(){ + var getPresenceRecord = function() { if (presenceRecord == null) - presenceRecord = {'state': 'available', userDefines: []}; + presenceRecord = { + 'state': 'available', + userDefines: [] + }; return (presenceRecord); }; @@ -458,16 +470,16 @@ angular var getMediaConfig = function() { var mediaConfig = { - ringbacktone: RtcommConfigService.getRingBackTone(), - ringtone: RtcommConfigService.getRingTone(), - webrtcConfig: { - broadcast : { - audio : RtcommConfigService.getBroadcastAudio(), - video : RtcommConfigService.getBroadcastVideo() - } - }, - webrtc : RtcommConfigService.getWebRTCEnabled(), - chat : RtcommConfigService.getChatEnabled(), + ringbacktone: RtcommConfigService.getRingBackTone(), + ringtone: RtcommConfigService.getRingTone(), + webrtcConfig: { + broadcast: { + audio: RtcommConfigService.getBroadcastAudio(), + video: RtcommConfigService.getBroadcastVideo() + } + }, + webrtc: RtcommConfigService.getWebRTCEnabled(), + chat: RtcommConfigService.getChatEnabled(), }; return (mediaConfig); @@ -475,7 +487,10 @@ angular myEndpointProvider.on('reset', function(event_object) { // Should have a reason. - _alert({type:'danger', msg: event_object.reason}); + _alert({ + type: 'danger', + msg: event_object.reason + }); }); @@ -483,45 +498,45 @@ angular $log.debug('<<------rtcomm-service------>> - Event: queueupdate'); $log.debug('queueupdate', queuelist); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('queueupdate', queuelist); - } + function() { + $rootScope.$broadcast('queueupdate', queuelist); + } ); }); myEndpointProvider.on('newendpoint', function(endpoint) { $log.debug('<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: ' + endpoint.getRemoteEndpointID()); - endpoint.on('onetimemessage',function(event){ + endpoint.on('onetimemessage', function(event) { $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != "undefined" && event.onetimemessage.type == 'iFrameURL'){ + if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { var session = _createSession(event.endpoint.id); session.iFrameURL = event.onetimemessage.iFrameURL; $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } + function() { + $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + } ); } }); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('newendpoint', endpoint); - } + function() { + $rootScope.$broadcast('newendpoint', endpoint); + } ); }); var callback = function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - if (eventObject.eventName.indexOf("session:") > -1){ - var session = _createSession(eventObject.endpoint.id); - session.sessionState = eventObject.eventName; - } - $rootScope.$broadcast(eventObject.eventName, eventObject); + function() { + if (eventObject.eventName.indexOf('session:') > -1) { + var session = _createSession(eventObject.endpoint.id); + session.sessionState = eventObject.eventName; } + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -531,21 +546,21 @@ angular }; // Setup all the callbacks here because they are all static. - myEndpointProvider.setRtcommEndpointConfig ({ + myEndpointProvider.setRtcommEndpointConfig({ ringtone: RtcommConfigService.getRingTone(), ringbacktone: RtcommConfigService.getRingBackTone(), // These are all the session related events. - 'session:started' : function(eventObject) { + 'session:started': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - var session = _createSession(eventObject.endpoint.id); - _setActiveEndpoint(eventObject.endpoint.id); + function() { + var session = _createSession(eventObject.endpoint.id); + _setActiveEndpoint(eventObject.endpoint.id); - session.sessionStarted = true; - session.remoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + session.sessionStarted = true; + session.remoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -554,18 +569,18 @@ angular }, - 'session:alerting' : callback, - 'session:trying' : callback, - 'session:ringing' : callback, - 'session:queued' : callback, + 'session:alerting': callback, + 'session:trying': callback, + 'session:ringing': callback, + 'session:queued': callback, - 'session:failed' : function(eventObject) { + 'session:failed': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + _removeSession(eventObject.endpoint.id); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) @@ -573,13 +588,13 @@ angular }, - 'session:stopped' : function(eventObject) { + 'session:stopped': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + _removeSession(eventObject.endpoint.id); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) @@ -588,42 +603,42 @@ angular }, // These are all the WebRTC related events. - 'webrtc:connected' : function(eventObject) { + 'webrtc:connected': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - _createSession(eventObject.endpoint.id).webrtcConnected = true; - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + _createSession(eventObject.endpoint.id).webrtcConnected = true; + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) $rootScope.$digest(); }, // These are all the WebRTC related events. - 'webrtc:remotemuted' : function(eventObject) { + 'webrtc:remotemuted': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) $rootScope.$digest(); }, - 'webrtc:disconnected' : function(eventObject) { + 'webrtc:disconnected': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - var session = _getSession(eventObject.endpoint.id); - if (session != null) - session.webrtcConnected = false; - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + var session = _getSession(eventObject.endpoint.id); + if (session != null) + session.webrtcConnected = false; + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -632,22 +647,22 @@ angular }, // These are all the chat related events. - 'chat:connected' : callback, - 'chat:disconnected' : callback, + 'chat:connected': callback, + 'chat:disconnected': callback, - 'chat:message' : function(eventObject) { + 'chat:message': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - var chat = { - time : new Date(), - name : eventObject.message.from, - message : angular.copy(eventObject.message.message) - }; - - _createSession(eventObject.endpoint.id).chats.push(chat); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + var chat = { + time: new Date(), + name: eventObject.message.from, + message: angular.copy(eventObject.message.message) + }; + + _createSession(eventObject.endpoint.id).chats.push(chat); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -656,28 +671,28 @@ angular }, // Endpoint destroyed - 'destroyed' : callback + 'destroyed': callback }); var initSuccess = function(event) { $log.debug('<<------rtcomm-service------>> - Event: Provider init succeeded'); - if (presenceRecord != null){ + if (presenceRecord != null) { $log.debug('RtcommService: initSuccess: updating presence record'); myEndpointProvider.publishPresence(presenceRecord); } $rootScope.$evalAsync( - function () { - var broadcastEvent = { - 'ready': event.ready, - 'registered': event.registered, - 'endpoint': event.endpoint, - 'userid' : RtcommConfigService.getProviderConfig().userid - }; - - $rootScope.$broadcast('rtcomm::init', true, broadcastEvent); - } + function() { + var broadcastEvent = { + 'ready': event.ready, + 'registered': event.registered, + 'endpoint': event.endpoint, + 'userid': RtcommConfigService.getProviderConfig().userid + }; + + $rootScope.$broadcast('rtcomm::init', true, broadcastEvent); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -686,11 +701,11 @@ angular }; var initFailure = function(error) { - $log.debug('<<------rtcomm-service------>> - Event: Provider init failed: error: ',error); + $log.debug('<<------rtcomm-service------>> - Event: Provider init failed: error: ', error); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::init', false, error); - } + function() { + $rootScope.$broadcast('rtcomm::init', false, error); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) @@ -700,12 +715,12 @@ angular /* * Get session from local endpoint ID */ - var _getSession = function(endpointUUID){ + var _getSession = function(endpointUUID) { var session = null; - for (var index = 0; index < sessions.length; index++) { - if(sessions[index].endpointUUID === endpointUUID){ + for (var index = 0; index < sessions.length; index++) { + if (sessions[index].endpointUUID === endpointUUID) { session = sessions[index]; break; } @@ -717,27 +732,27 @@ angular /* * Get session from local endpoint ID */ - var _createSession = function(endpointUUID){ + var _createSession = function(endpointUUID) { var session = null; - for (var index = 0; index < sessions.length; index++) { - if(sessions[index].endpointUUID === endpointUUID){ + for (var index = 0; index < sessions.length; index++) { + if (sessions[index].endpointUUID === endpointUUID) { session = sessions[index]; break; } } - if (session == null){ + if (session == null) { session = { - endpointUUID : endpointUUID, - chats : [], - webrtcConnected : false, - sessionStarted : false, - iFrameURL : 'about:blank', - remoteEndpointID : null, - activated : true, - sessionState : 'session:stopped' + endpointUUID: endpointUUID, + chats: [], + webrtcConnected: false, + sessionStarted: false, + iFrameURL: 'about:blank', + remoteEndpointID: null, + activated: true, + sessionState: 'session:stopped' }; sessions[sessions.length] = session; } @@ -745,10 +760,10 @@ angular return (session); }; - var _removeSession = function(endpointUUID){ + var _removeSession = function(endpointUUID) { for (var index = 0; index < sessions.length; index++) { - if(sessions[index].endpointUUID === endpointUUID){ + if (sessions[index].endpointUUID === endpointUUID) { _getEndpoint(endpointUUID).destroy(); @@ -756,10 +771,9 @@ angular sessions.splice(index, 1); // Now we need to set the active endpoint to someone else or to no endpoint if none are left. - if (sessions.length == 0){ + if (sessions.length == 0) { $rootScope.$broadcast('noEndpointActivated'); - } - else{ + } else { _setActiveEndpoint(sessions[0].endpointUUID); } break; @@ -771,35 +785,34 @@ angular var _getEndpoint = function(uuid) { var endpoint = null; - if ((typeof uuid === "undefined") || uuid == null){ + if ((typeof uuid === 'undefined') || uuid == null) { $log.debug('getEndpoint: create new endpoint and setup onetimemessage event'); endpoint = myEndpointProvider.createRtcommEndpoint(); - endpoint.on('onetimemessage',function(event){ + endpoint.on('onetimemessage', function(event) { $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != "undefined" && event.onetimemessage.type == 'iFrameURL'){ + if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { var session = _createSession(event.endpoint.id); session.iFrameURL = event.onetimemessage.iFrameURL; $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } + function() { + $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + } ); } }); - } - else + } else endpoint = myEndpointProvider.getRtcommEndpoint(uuid); return (endpoint); }; - var _setActiveEndpoint = function(endpointID){ + var _setActiveEndpoint = function(endpointID) { // First get the old active endpoint var activeEndpoint = _getActiveEndpointUUID(); - if ((activeEndpoint != null) && (activeEndpoint != endpointID)){ + if ((activeEndpoint != null) && (activeEndpoint != endpointID)) { var session = _getSession(activeEndpoint); if (session != null) session.activated = false; @@ -811,11 +824,11 @@ angular $rootScope.$broadcast('endpointActivated', endpointID); }; - var _getActiveEndpointUUID = function(){ + var _getActiveEndpointUUID = function() { var activeEndpoint = null; for (var index = 0; index < sessions.length; index++) { - if(sessions[index].activated == true){ + if (sessions[index].activated == true) { activeEndpoint = sessions[index].endpointUUID; break; } @@ -823,337 +836,403 @@ angular return (activeEndpoint); }; var _alert = function _alert(alertObject) { - var a = { type: 'info', - msg: 'default message'}; - if (typeof alertObject === 'string') { - a.msg = alertObject; - } else { - a = alertObject; - } - $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::alert', a); - } - ); + var a = { + type: 'info', + msg: 'default message' }; + if (typeof alertObject === 'string') { + a.msg = alertObject; + } else { + a = alertObject; + } + $rootScope.$evalAsync( + function() { + $rootScope.$broadcast('rtcomm::alert', a); + } + ); + }; + /** External functionalities fror the RtcommService API */ + function isInitialized() { + return endpointProviderInitialized; + } - return { + function setConfig(config) { - alert: _alert, + if (RtcommConfigService.isRtcommDisabled() == true) { + $log.debug('RtcommService:setConfig: isRtcommDisabled = true; return with no setup'); + return; + } - setKarmaTesting : function(){ - karmaTesting = true; - }, + if (config.rtcommDebug === 'INFO' || config.rtcommDebug === 'DEBUG') { + myEndpointProvider.setLogLevel(config.rtcommDebug); + } + $log.debug('rtcomm-services: setConfig: config: ', config); - isInitialized : function(){ - return(endpointProviderInitialized); - }, + RtcommConfigService.setProviderConfig(config); + myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); - setConfig : function(config){ - if (RtcommConfigService.isRtcommDisabled() == true){ - $log.debug('RtcommService:setConfig: isRtcommDisabled = true; return with no setup'); - return; + if (endpointProviderInitialized == false) { + // If the user does not specify a userid, that says one will never be specified so go ahead + // and initialize the endpoint provider and let the provider assign a name. If a defined empty + // string is passed in, that means to wait until the end user registers a name. + if (typeof config.userid == 'undefined' || RtcommConfigService.getProviderConfig().userid != '') { + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; } + } + } - if(config.rtcommDebug === "INFO" || config.rtcommDebug === "DEBUG"){ - myEndpointProvider.setLogLevel(config.rtcommDebug); - } - $log.debug('rtcomm-services: setConfig: config: ', config); - - RtcommConfigService.setProviderConfig(config); - myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); - - if (endpointProviderInitialized == false){ - // If the user does not specify a userid, that says one will never be specified so go ahead - // and initialize the endpoint provider and let the provider assign a name. If a defined empty - // string is passed in, that means to wait until the end user registers a name. - if (typeof config.userid == "undefined" || RtcommConfigService.getProviderConfig().userid != ''){ - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; - } - } - }, - // Presence related methods - getPresenceMonitor:function(topic) { - return myEndpointProvider.getPresenceMonitor(topic); - }, + function getPresenceMonitor(topic) { + return myEndpointProvider.getPresenceMonitor(topic); + } - publishPresence:function() { - if (endpointProviderInitialized == true) - myEndpointProvider.publishPresence(getPresenceRecord()); - }, + function publishPresence() { - /** - * userDefines is an array of JSON objects that look like: - * - * { - * name : "some name", - * value : "some value" - * } - * - * The only rule is that some name and some value have to both be strings. - */ - addToPresenceRecord:function(userDefines) { - - for (var index = 0; index < userDefines.length; index++) { - getPresenceRecord().userDefines.push(userDefines[index]); - } + if (endpointProviderInitialized === true) + myEndpointProvider.publishPresence(getPresenceRecord()); + } - if (endpointProviderInitialized == true){ - $log.debug('RtcommService: addToPresenceRecord: updating presence record to: ', getPresenceRecord()); - myEndpointProvider.publishPresence(getPresenceRecord()); - } - }, + function addToPresenceRecord(userDefines) { - /** - * userDefines is an array of JSON objects that look like: - * - * { - * name : "some name", - * value : "some value" - * } - * - * The only rule is that some name and some value have to both be strings. - */ - removeFromPresenceRecord:function(userDefines, doPublish) { - - for (var i = 0; i < userDefines.length; i++) { - for (var j = 0; j < getPresenceRecord().userDefines.length; j++) { - - if (getPresenceRecord().userDefines[j].name == userDefines[i].name){ - getPresenceRecord().userDefines.splice(j,1); - break; - } + for (var index = 0; index < userDefines.length; index++) { + getPresenceRecord().userDefines.push(userDefines[index]); + } + + if (endpointProviderInitialized == true) { + $log.debug('RtcommService: addToPresenceRecord: updating presence record to: ', getPresenceRecord()); + myEndpointProvider.publishPresence(getPresenceRecord()); + } + } + + function removeFromPresenceRecord(userDefines, doPublish) { + + for (var i = 0; i < userDefines.length; i++) { + for (var j = 0; j < getPresenceRecord().userDefines.length; j++) { + + if (getPresenceRecord().userDefines[j].name == userDefines[i].name) { + getPresenceRecord().userDefines.splice(j, 1); + break; } } + } - if ((endpointProviderInitialized == true) && doPublish){ - $log.debug('RtcommService: removeFromPresenceRecord: updating presence record to: ', getPresenceRecord()); - myEndpointProvider.publishPresence(getPresenceRecord()); - } - }, + if ((endpointProviderInitialized == true) && doPublish) { + $log.debug('RtcommService: removeFromPresenceRecord: updating presence record to: ', getPresenceRecord()); + myEndpointProvider.publishPresence(getPresenceRecord()); + } + } - setPresenceRecordState:function(state) { - getPresenceRecord().state = state; - return myEndpointProvider.publishPresence(getPresenceRecord()); - }, + function setPresenceRecordState(state) { - // Endpoint related methods - getEndpoint : function(uuid) { - return(_getEndpoint(uuid)); - }, + getPresenceRecord().state = state; + return myEndpointProvider.publishPresence(getPresenceRecord()); + } - destroyEndpoint : function(uuid) { - myEndpointProvider.getRtcommEndpoint(uuid).destroy(); - }, + function getEndpoint(uuid) { + return _getEndpoint(uuid); + } - // Registration related methods. - register : function(userid) { - if (endpointProviderInitialized == false){ - RtcommConfigService.getProviderConfig().userid = userid; + function destroyEndpoint(uuid) { + myEndpointProvider.getRtcommEndpoint(uuid).destroy(); + } - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; - } - else - $log.error('rtcomm-services: register: ERROR: endpoint provider already initialized'); - }, + function register(userid) { - unregister : function() { - if (endpointProviderInitialized == true){ - myEndpointProvider.destroy(); - endpointProviderInitialized = false; - initFailure("destroyed"); - } - else - $log.error('rtcomm-services: unregister: ERROR: endpoint provider not initialized'); - }, + if (endpointProviderInitialized == false) { + RtcommConfigService.getProviderConfig().userid = userid; - // Queue related methods - joinQueue : function(queueID) { - myEndpointProvider.joinQueue(queueID); - }, + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; + } else + $log.error('rtcomm-services: register: ERROR: endpoint provider already initialized'); + } - leaveQueue : function(queueID) { - myEndpointProvider.leaveQueue(queueID); - }, + function unregister() { - getQueues : function() { - return(queueList); - }, + if (endpointProviderInitialized == true) { + myEndpointProvider.destroy(); + endpointProviderInitialized = false; + initFailure('destroyed'); + } else + $log.error('rtcomm-services: unregister: ERROR: endpoint provider not initialized'); + } - /** - * Chat related methods - */ - sendChatMessage : function(chat, endpointUUID){ - // Save this chat in the local session store - var session = _createSession(endpointUUID); - session.chats.push(chat); - - myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); - }, - getChats : function(endpointUUID) { - if (typeof endpointUUID !== "undefined" && endpointUUID != null){ - var session = _getSession(endpointUUID); - if (session != null) - return (session.chats); - else - return(null); - } - else - return(null); - }, + /** + * Queue API + */ + function joinQueue(queueID) { + myEndpointProvider.joinQueue(queueID); + } - isWebrtcConnected : function(endpointUUID) { - if (typeof endpointUUID !== 'undefined' && endpointUUID != null){ - var session = _getSession(endpointUUID); - if (session != null) - return (session.webrtcConnected); - else - return(false); - } + function leaveQueue(queueID) { + myEndpointProvider.leaveQueue(queueID); + } + + function getQueues() { + return queueList; + } + + /** + * Chat API + */ + function sendChatMessage(chat, endpointUUID) { + + // Save this chat in the local session store + var session = _createSession(endpointUUID); + session.chats.push(chat); + + myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); + + } + + function getChats(endpointUUID) { + + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { + var session = _getSession(endpointUUID); + if (session != null) + return (session.chats); else - return(false); - }, + return (null); + } else + return (null); + + } + + function isWebrtcConnected(endpointUUID) { - getSessionState : function(endpointUUID) { - if (typeof endpointUUID !== "undefined" && endpointUUID != null) - return (myEndpointProvider.getRtcommEndpoint(endpointUUID).getState()); + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { + var session = _getSession(endpointUUID); + if (session != null) + return (session.webrtcConnected); else - return ("session:stopped"); - }, + return (false); + } else + return (false); + } - setAlias : function(aliasID) { - if ((typeof aliasID !== "undefined") && aliasID != '') - myEndpointProvider.setUserID(aliasID); - }, + function getSessionState(endpointUUID) { - setUserID : function(userID) { - if ((typeof userID !== "undefined") && userID != ''){ - RtcommConfigService.setProviderConfig({userid: userID}); - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - } - }, + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) + return (myEndpointProvider.getRtcommEndpoint(endpointUUID).getState()); + else + return ('session:stopped'); + } - setPresenceTopic : function(presenceTopic) { - if ((typeof presenceTopic !== "undefined") && presenceTopic != ''){ - RtcommConfigService.setProviderConfig({presenceTopic : presenceTopic}); - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - } - }, + function setAlias(aliasID) { - getIframeURL : function(endpointUUID){ - if (typeof endpointUUID !== "undefined" && endpointUUID != null){ - var session = _getSession(endpointUUID); - if (session != null) - return (session.iFrameURL); - else - return(null); - } + if ((typeof aliasID !== 'undefined') && aliasID != '') + myEndpointProvider.setUserID(aliasID); + } + + function setUserID(userID) { + + if ((typeof userID !== 'undefined') && userID != '') { + RtcommConfigService.setProviderConfig({ + userid: userID + }); + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + } + } + + function setPresenceTopic(presenceTopic) { + + if ((typeof presenceTopic !== 'undefined') && presenceTopic != '') { + RtcommConfigService.setProviderConfig({ + presenceTopic: presenceTopic + }); + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + } + + } + + function getIframeURL(endpointUUID) { + + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { + var session = _getSession(endpointUUID); + if (session != null) + return (session.iFrameURL); else - return(null); - }, + return (null); + } else + return (null); + } - putIframeURL : function(endpointUUID, newUrl){ - $log.debug('RtcommService: putIframeURL: endpointUUID: ' + endpointUUID + ' newURL: ' + newUrl); - var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); + function putIframeURL(endpointUUID, newUrl) { - if (endpoint != null){ - var session = _createSession(endpointUUID); - session.iFrameURL = newUrl; - var message = { type : 'iFrameURL', - iFrameURL : newUrl}; + $log.debug('RtcommService: putIframeURL: endpointUUID: ' + endpointUUID + ' newURL: ' + newUrl); + var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); - $log.debug('RtcommService: putIframeURL: sending new iFrame URL'); - endpoint.sendOneTimeMessage(message); - } - }, + if (endpoint != null) { + var session = _createSession(endpointUUID); + session.iFrameURL = newUrl; - placeCall : function(calleeID, mediaToEnable){ - var endpoint = _getEndpoint(); + var message = { + type: 'iFrameURL', + iFrameURL: newUrl + }; - if (mediaToEnable.indexOf('chat') > -1) - endpoint.chat.enable(); + $log.debug('RtcommService: putIframeURL: sending new iFrame URL'); + endpoint.sendOneTimeMessage(message); + } + } - if (mediaToEnable.indexOf('webrtc') > -1) { - // Support turning off trickle ICE - var trickleICE = true; - if (mediaToEnable.indexOf('disableTrickleICE') > -1) { - trickleICE = false; - } - endpoint.webrtc.enable({'trickleICE': trickleICE}); + function placeCall(calleeID, mediaToEnable) { + + var endpoint = _getEndpoint(); + + if (mediaToEnable.indexOf('chat') > -1) + endpoint.chat.enable(); + + if (mediaToEnable.indexOf('webrtc') > -1) { + // Support turning off trickle ICE + var trickleICE = true; + if (mediaToEnable.indexOf('disableTrickleICE') > -1) { + trickleICE = false; } - _setActiveEndpoint(endpoint.id); + endpoint.webrtc.enable({ + 'trickleICE': trickleICE + }); + } + _setActiveEndpoint(endpoint.id); - endpoint.connect(calleeID); - return(endpoint.id); - }, + endpoint.connect(calleeID); + return (endpoint.id); + } - getSessions : function(){ - return(sessions); - }, + function getSessions() { + return sessions; + } - endCall : function(endpoint) { - endpoint.disconnect(); - }, + function endCall(endpoint) { + endpoint.disconnect(); + } - setActiveEndpoint : function(endpointID){ - _setActiveEndpoint(endpointID); - }, + function setActiveEndpoint(endpointID) { + _setActiveEndpoint(endpointID); + } - getActiveEndpoint : function(){ - return(_getActiveEndpointUUID()); - }, + function getActiveEndpoint() { + return _getActiveEndpointUUID(); + } - getRemoteEndpoint : function(localEndpointID){ - var remoteEndpointID = null; + function getRemoteEndpoint(localEndpointID) { - if (localEndpointID != null){ - var session = _getSession(localEndpointID); - if (session != null){ - remoteEndpointID = session.remoteEndpointID; - } + var remoteEndpointID = null; + + if (localEndpointID != null) { + var session = _getSession(localEndpointID); + + if (session != null) { + remoteEndpointID = session.remoteEndpointID; } + } - return (remoteEndpointID); - }, + return (remoteEndpointID); + } - setDefaultViewSelector : function() { - _selfView = "selfView"; - _remoteView = "remoteView"; - }, + function setDefaultViewSelector() { - setViewSelector : function(selfView, remoteView) { - _selfView = selfView; - _remoteView = remoteView; - }, + _selfView = 'selfView'; + _remoteView = 'remoteView'; + } - setVideoView : function(endpointUUID){ - $log.debug('rtcommVideo: setting local media'); - var endpoint = null; - - if (typeof endpointUUID != "undefined" && endpointUUID != null) - endpoint = _getEndpoint(endpointUUID); - else if (_getActiveEndpointUUID() != null) - endpoint = _getEndpoint(_getActiveEndpointUUID()); - - if (endpoint != null){ - $log.debug(endpoint); - endpoint.webrtc.setLocalMedia( - { - mediaOut: document.querySelector('#' + _selfView), - mediaIn: document.querySelector('#' + _remoteView) - }); - } - }, - }; - }; + function setViewSelector(selfView, remoteView) { + _selfView = selfView; + _remoteView = remoteView; + } + + function setVideoView(endpointUUID) { + + $log.debug('rtcommVideo: setting local media'); + var endpoint = null; + + if (typeof endpointUUID != 'undefined' && endpointUUID != null) + endpoint = _getEndpoint(endpointUUID); + else if (_getActiveEndpointUUID() != null) + endpoint = _getEndpoint(_getActiveEndpointUUID()); + + if (endpoint != null) { + $log.debug(endpoint); + endpoint.webrtc.setLocalMedia({ + mediaOut: document.querySelector('#' + _selfView), + mediaIn: document.querySelector('#' + _remoteView) + }); + } + } + return { + + alert: _alert, + + isInitialized: isInitialized, + + setConfig: setConfig, + + getPresenceMonitor: getPresenceMonitor, + + publishPresence: publishPresence, + + addToPresenceRecord: addToPresenceRecord, + + removeFromPresenceRecord: removeFromPresenceRecord, + + setPresenceRecordState: setPresenceRecordState, + + getEndpoint: getEndpoint, + + destroyEndpoint: destroyEndpoint, + + register: register, + + unregister: unregister, + + joinQueue: joinQueue, + + leaveQueue: leaveQueue, + + getQueues: getQueues, + + sendChatMessage: sendChatMessage, + + getChats: getChats, + + isWebrtcConnected: isWebrtcConnected, + + getSessionState: getSessionState, + + setAlias: setAlias, + + setUserID: setUserID, + + setPresenceTopic: setPresenceTopic, + + getIframeURL: getIframeURL, + + putIframeURL: putIframeURL, + placeCall: placeCall, + + getSessions: getSessions, + + endCall: endCall, + + setActiveEndpoint: setActiveEndpoint, + + getActiveEndpoint: getActiveEndpoint, + + getRemoteEndpoint: getRemoteEndpoint, + + setDefaultViewSelector: setDefaultViewSelector, + + setViewSelector: setViewSelector, + + setVideoView: setVideoView + }; + } })(); /** @@ -1194,52 +1273,52 @@ angular */ (function() { - 'use strict'; + 'use strict'; - angular - .module('angular-rtcomm-ui') - .controller('RtcommConfigController', RtcommConfigController); + angular + .module('angular-rtcomm-ui') + .controller('RtcommConfigController', RtcommConfigController); - RtcommConfigController.$inject = ['RtcommService', '$http', '$scope', '$log']; + RtcommConfigController.$inject = ['RtcommService', '$http', '$scope', '$log']; - /* @ngInject */ - function RtcommConfigController(RtcommService, $http, $scope, $log) { - var vm = this; - vm.extendedConfig = null; + /* @ngInject */ + function RtcommConfigController(RtcommService, $http, $scope, $log) { + var vm = this; + vm.extendedConfig = null; - $log.debug('RtcommConfigController: configURL = ' + vm.configURL); + $log.debug('RtcommConfigController: configURL = ' + vm.configURL); - vm.setConfig = function(data) { - $log.debug('RtcommConfigController: setting config data:' + data); - RtcommService.setConfig(data); - }; + vm.setConfig = function(data) { + $log.debug('RtcommConfigController: setting config data:' + data); + RtcommService.setConfig(data); + }; - $scope.init = function(configURL, extendedConfig) { + $scope.init = function(configURL, extendedConfig) { - $log.debug('RtcommConfigController: initing configURL = ' + configURL); - vm.configURL = configURL; + $log.debug('RtcommConfigController: initing configURL = ' + configURL); + vm.configURL = configURL; - if (typeof extendedConfig !== "undefined") - vm.extendedConfig = extendedConfig; + if (typeof extendedConfig !== 'undefined') + vm.extendedConfig = extendedConfig; - vm.getConfig(); - }; + vm.getConfig(); + }; - vm.getConfig = function() { - $http.get(vm.configURL).success(function(config) { + vm.getConfig = function() { + $http.get(vm.configURL).success(function(config) { - // Now we need to update the config with any extensions passed in on init. - if (vm.extendedConfig != null) { - angular.extend(config, vm.extendedConfig); - $log.debug('RtcommConfigController: extended config object: ' + config); - } + // Now we need to update the config with any extensions passed in on init. + if (vm.extendedConfig != null) { + angular.extend(config, vm.extendedConfig); + $log.debug('RtcommConfigController: extended config object: ' + config); + } - RtcommService.setConfig(config); - }).error(function(data, status, headers, config) { - $log.debug('RtcommConfigController: error accessing config: ' + status); - }); - }; - } + RtcommService.setConfig(config); + }).error(function(data, status, headers, config) { + $log.debug('RtcommConfigController: error accessing config: ' + status); + }); + }; + } })(); /** @@ -1654,90 +1733,90 @@ angular * limitations under the License. */ (function() { - 'use strict'; - - angular - .module('angular-rtcomm-ui') - .controller('RtcommEndpointController', RtcommEndpointController); + 'use strict'; - RtcommEndpointController.$inject = ['RtcommService', '$scope', '$log']; + angular + .module('angular-rtcomm-ui') + .controller('RtcommEndpointController', RtcommEndpointController); - /* @ngInject */ - function RtcommEndpointController(RtcommService, $scope, $log) { - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); + RtcommEndpointController.$inject = ['RtcommService', '$scope', '$log']; - function getActiveEndpoint() { - return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); - } + /* @ngInject */ + function RtcommEndpointController(RtcommService, $scope, $log) { + $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); + $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - $scope.disconnect = function() { - $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - var ep = getActiveEndpoint; - ep.disconnect(); - }; + function getActiveEndpoint() { + return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); + } - $scope.toggleAV = function() { - $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + $scope.disconnect = function() { + $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + var ep = getActiveEndpoint; + ep.disconnect(); + }; - if ($scope.epCtrlAVConnected == false) { - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { - if (!value) { - $log.debug('Enable failed: ', message); - RtcommService.alert({ - type: 'danger', - msg: message - }); - } - }); - } else { - $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); - } - }; + $scope.toggleAV = function() { + $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - $scope.$on('session:started', function(event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:started'; - } + if ($scope.epCtrlAVConnected == false) { + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { + if (!value) { + $log.debug('Enable failed: ', message); + RtcommService.alert({ + type: 'danger', + msg: message + }); + } }); + } else { + $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); + } + }; - $scope.$on('session:stopped', function(event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:stopped'; - } - }); + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:started'; + } + }); - $scope.$on('session:failed', function(event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:failed'; - } - }); + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:stopped'; + } + }); - $scope.$on('webrtc:connected', function(event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = true; - }); + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:failed'; + } + }); - $scope.$on('webrtc:disconnected', function(event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = false; - }); + $scope.$on('webrtc:connected', function(event, eventObject) { + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = true; + }); + $scope.$on('webrtc:disconnected', function(event, eventObject) { + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = false; + }); - $scope.$on('endpointActivated', function(event, endpointUUID) { - $scope.epCtrlActiveEndpointUUID = endpointUUID; - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); - }); - $scope.$on('noEndpointActivated', function(event) { - $scope.epCtrlAVConnected = false; - }); - } + $scope.$on('endpointActivated', function(event, endpointUUID) { + $scope.epCtrlActiveEndpointUUID = endpointUUID; + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + $scope.epCtrlAVConnected = false; + }); + } })(); /** @@ -1762,106 +1841,107 @@ angular * active endpoints. */ (function() { - 'use strict'; + 'use strict'; - angular - .module('angular-rtcomm-ui') - .directive('rtcommChat', rtcommChat); + angular + .module('angular-rtcomm-ui') + .directive('rtcommChat', rtcommChat); - rtcommChat.$inject = ['RtcommService', '$log']; + rtcommChat.$inject = ['RtcommService', '$log']; - /* @ngInject */ - function rtcommChat(RtcommService, $log) { - var directive = { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-chat.html', - link: chatLink, - controller: ChatController, - controllerAs: 'chatVM', - bindToController: true - }; - - return directive; + /* @ngInject */ + function rtcommChat(RtcommService, $log) { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-chat.html', + link: chatLink, + controller: ChatController, + controllerAs: 'chatVM', + bindToController: true + }; - function chatLink(scope, element, attr, ctrl) { - var chatPanel = angular.element(element.find('.panel-body')[0]); + return directive; - var bottom = true; + function chatLink(scope, element, attr, ctrl) { + var chatPanel = angular.element(element.find('.panel-body')[0]); - //Chooses if the scrollbar should be forced to the bottom on the next lifecycle - ctrl.scrollToBottom = function(flag) { - bottom = flag; - scope.bottom = flag; + var bottom = true; - } - if(chatPanel.length > 0){ - //Watch scroll events - chatPanel.bind('scroll', function() { - if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { - ctrl.scrollToBottom(true); - } else { - ctrl.scrollToBottom(false); - } - }); + //Chooses if the scrollbar should be forced to the bottom on the next lifecycle + ctrl.scrollToBottom = function(flag) { + bottom = flag; + scope.bottom = flag; - //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down - scope.$watch(function() { - return ctrl.chats - }, function() { - $log.debug('rtcommChat - Link > $watch on chats called'); - if (bottom) { - chatPanel.scrollTop(chatPanel.prop('scrollHeight')); - } else { - //In this else, a notification could be sent - } - }, true); + } + if (chatPanel.length > 0) { + //Watch scroll events + chatPanel.bind('scroll', function() { + if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { + ctrl.scrollToBottom(true); + } else { + ctrl.scrollToBottom(false); + } + }); - }} + //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down + scope.$watch(function() { + return ctrl.chats + }, function() { + $log.debug('rtcommChat - Link > $watch on chats called'); + if (bottom) { + chatPanel.scrollTop(chatPanel.prop('scrollHeight')); + } else { + //In this else, a notification could be sent + } + }, true); + } } - //Controller should be used to listen for events from Rtcmo - ChatController.$inject = ['$scope', 'RtcommService', '$log']; + } - /* @ngInject */ - function ChatController($scope, RtcommService, $log) { - var vm = this; + //Controller should be used to listen for events from Rtcmo + ChatController.$inject = ['$scope', 'RtcommService', '$log']; - vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); + /* @ngInject */ + function ChatController($scope, RtcommService, $log) { + var vm = this; - vm.keySendMessage = function(keyEvent) { - if (keyEvent.which === 13) - vm.sendMessage(); - }; + vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); - vm.sendMessage = function() { - $log.debug('rtcommChat: sendMessage() -> ' + vm.message); - var chat = { - time: new Date(), - name: RtcommService.getEndpoint(vm.chatActiveEndpointUUID).getLocalEndpointID(), - message: angular.copy(vm.message) - }; + vm.keySendMessage = function(keyEvent) { + if (keyEvent.which === 13) + vm.sendMessage(); + }; - vm.message = ''; - vm.scrollToBottom(true); - $scope.bottom = true; - RtcommService.sendChatMessage(chat, vm.chatActiveEndpointUUID); - } + vm.sendMessage = function() { + $log.debug('rtcommChat: sendMessage() -> ' + vm.message); + var chat = { + time: new Date(), + name: RtcommService.getEndpoint(vm.chatActiveEndpointUUID).getLocalEndpointID(), + message: angular.copy(vm.message) + }; - $scope.$on('endpointActivated', function(event, endpointUUID) { - $log.debug('rtcommChat: endpointActivated =' + endpointUUID); + vm.message = ''; + vm.scrollToBottom(true); + $scope.bottom = true; + RtcommService.sendChatMessage(chat, vm.chatActiveEndpointUUID); + } - // The data model for the chat is maintained in the RtcommService. - vm.chats = RtcommService.getChats(endpointUUID); - vm.chatActiveEndpointUUID = endpointUUID; - }); + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommChat: endpointActivated =' + endpointUUID); - $scope.$on('noEndpointActivated', function(event) { - vm.chats = []; - vm.chatActiveEndpointUUID = null; - }); - } + // The data model for the chat is maintained in the RtcommService. + vm.chats = RtcommService.getChats(endpointUUID); + vm.chatActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.chats = []; + vm.chatActiveEndpointUUID = null; + }); + } })(); /** @@ -1896,126 +1976,126 @@ angular */ (function() { - 'use strict'; - - angular - .module('angular-rtcomm-ui') - .directive('rtcommEndpointStatus', rtcommEndpointStatus); - - /* @ngInject */ - function rtcommEndpointStatus() { - var directive = { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', - controller: EndpointStatusController, - controllerAs: 'endpointStatusVM', - bindToController: true - }; - - return directive; - } + 'use strict'; - EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; + angular + .module('angular-rtcomm-ui') + .directive('rtcommEndpointStatus', rtcommEndpointStatus); - /* @ngInject */ - function EndpointStatusController(RtcommService, $scope, $log) { - var vm = this; - vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); - vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); - vm.failureReason = ''; - vm.queueCount = 0; //TODO FIX: Currently not implemented! + /* @ngInject */ + function rtcommEndpointStatus() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', + controller: EndpointStatusController, + controllerAs: 'endpointStatusVM', + bindToController: true + }; - $scope.$on('session:started', function(event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID === eventObject.endpoint.id) { - vm.sessionState = 'session:started'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); + return directive; + } + + EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function EndpointStatusController(RtcommService, $scope, $log) { + var vm = this; + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + vm.failureReason = ''; + vm.queueCount = 0; //TODO FIX: Currently not implemented! + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID === eventObject.endpoint.id) { + vm.sessionState = 'session:started'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); - $scope.$on('session:stopped', function(event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:stopped'; - vm.epCtrlRemoteEndpointID = null; - } - }); + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); - $scope.$on('session:failed', function(event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:failed'; - vm.failureReason = eventObject.reason; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:failed'; + vm.failureReason = eventObject.reason; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); - $scope.$on('session:alerting', function(event, eventObject) { - $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID != eventObject.endpoint.id) { - vm.sessionState = 'session:alerting'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); + $scope.$on('session:alerting', function(event, eventObject) { + $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID != eventObject.endpoint.id) { + vm.sessionState = 'session:alerting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); - $scope.$on('session:connecting', function(event, eventObject) { - $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); - // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ - vm.sessionState = 'session:connecting'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - // } - }); + $scope.$on('session:connecting', function(event, eventObject) { + $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); + // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ + vm.sessionState = 'session:connecting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + // } + }); - $scope.$on('session:queued', function(event, eventObject) { - $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:queued'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); + $scope.$on('session:queued', function(event, eventObject) { + $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:queued'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); - $scope.$on('session:trying', function(event, eventObject) { - $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:trying'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); + $scope.$on('session:trying', function(event, eventObject) { + $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:trying'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); - $scope.$on('session:ringing', function(event, eventObject) { - $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:ringing'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); + $scope.$on('session:ringing', function(event, eventObject) { + $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:ringing'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); - $scope.$on('endpointActivated', function(event, endpointUUID) { - vm.epCtrlActiveEndpointUUID = endpointUUID; - vm.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); - vm.sessionState = RtcommService.getSessionState(endpointUUID); - }); + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.epCtrlActiveEndpointUUID = endpointUUID; + vm.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); + vm.sessionState = RtcommService.getSessionState(endpointUUID); + }); - $scope.$on('noEndpointActivated', function(event) { - vm.epCtrlRemoteEndpointID = null; - vm.sessionState = 'session:stopped'; - }); + $scope.$on('noEndpointActivated', function(event) { + vm.epCtrlRemoteEndpointID = null; + vm.sessionState = 'session:stopped'; + }); - $scope.$on('rtcomm::init', function(event, success, details) { - if (success === true) { - vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); - vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); - vm.failureReason = ''; - } - if (success == false) { - vm.sessionState = 'session:stopped'; - vm.epCtrlRemoteEndpointID = null; - } - }); - } + $scope.$on('rtcomm::init', function(event, success, details) { + if (success === true) { + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + vm.failureReason = ''; + } + if (success == false) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); + } })(); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index d396aa6..fff0cc5 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -18,5 +18,5 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),f.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var o=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=s(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==k&&a.$digest()};f.setRtcommEndpointConfig({ringtone:d.getRingTone(),ringbacktone:d.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=s(c.endpoint.id);v(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:alerting":o,"session:trying":o,"session:ringing":o,"session:queued":o,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){t(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){s(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=r(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},"chat:connected":o,"chat:disconnected":o,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};s(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==k&&a.$digest()},destroyed:o});var p=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=j&&(b.debug("RtcommService: initSuccess: updating presence record"),f.publishPresence(j)),a.$evalAsync(function(){var b={ready:c.ready,registered:c.registered,endpoint:c.endpoint,userid:d.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==k&&a.$digest()},q=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==k&&a.$digest()},r=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=s(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=f.getRtcommEndpoint(c),d},v=function(b){var c=w();if(null!=c&&c!=b){var d=r(c);null!=d&&(d.activated=!1)}var d=s(b);d.activated=!0,a.$broadcast("endpointActivated",b)},w=function(){for(var a=null,b=0;b-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return v(c.id),c.connect(a),c.id},getSessions:function(){return i},endCall:function(a){a.disconnect()},setActiveEndpoint:function(a){v(a)},getActiveEndpoint:function(){return w()},getRemoteEndpoint:function(a){var b=null;if(null!=a){var c=r(a);null!=c&&(b=c.remoteEndpointID)}return b},setDefaultViewSelector:function(){l="selfView",m="remoteView"},setViewSelector:function(a,b){l=a,m=b},setVideoView:function(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=u(a):null!=w()&&(c=u(w())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+l),mediaIn:document.querySelector("#"+m)}))}}}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","$http","RtcommConfigService","rtcomm"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.extendedConfig=null,d.debug("RtcommConfigController: configURL = "+e.configURL),e.setConfig=function(b){d.debug("RtcommConfigController: setting config data:"+b),a.setConfig(b)},c.init=function(a,b){d.debug("RtcommConfigController: initing configURL = "+a),e.configURL=a,"undefined"!=typeof b&&(e.extendedConfig=b),e.getConfig()},e.getConfig=function(){b.get(e.configURL).success(function(b){null!=e.extendedConfig&&(angular.extend(b,e.extendedConfig),d.debug("RtcommConfigController: extended config object: "+b)),a.setConfig(b)}).error(function(a,b,c,e){d.debug("RtcommConfigController: error accessing config: "+b)})}}angular.module("angular-rtcomm-ui").controller("RtcommConfigController",a),a.$inject=["RtcommService","$http","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-alert.html",controller:b,controllerAs:"alertVM",bindToController:!0};return a}function b(a,b){var c=this;c.alerts=[],c.addAlert=function(a){c.alerts.push(a)},c.closeAlert=function(a){c.alerts.splice(a,1)},a.$on("rtcomm::alert",function(a,b){c.addAlert(b)})}angular.module("angular-rtcomm-ui").directive("rtcommAlert",a),b.$inject=["$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-queues.html",controller:b,controllerAs:"queuesVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.rQueues=[],d.autoJoinQueues=!1,d.queuePresenceData=[],d.queuePublishPresence=!1,d.queueFilter=null,b.init=function(a,b,e){c.debug("rtcommQueues: autoJoinQueues = "+a),d.autoJoinQueues=a,d.queuePublishPresence=b,"undefined"!=typeof e&&(d.queueFilter=e)},d.filterOutQueue=function(a){var b=!0;if(null!=d.queueFilter)for(var c=0;c0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), -a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return $(c.id),c.connect(a),c.id}function C(){return N}function D(a){a.disconnect()}function E(a){$(a)}function F(){return _()}function G(a){var b=null;if(null!=a){var c=W(a);null!=c&&(b=c.remoteEndpointID)}return b}function H(){Q="selfView",R="remoteView"}function I(a,b){Q=a,R=b}function J(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=Z(a):null!=_()&&(c=Z(_())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Q),mediaIn:document.querySelector("#"+R)}))}var K=new d.EndpointProvider,L=!1,M=null,N=[],O=null,P=!1,Q="selfView",R="remoteView";K.setLogLevel(c.getRtcommDebug()),b.debug("rtcomm-service - endpointProvider log level is: "+K.getLogLevel()),b.debug("rtcomm-service - endpointProvider log level should be: "+c.getRtcommDebug()),K.setAppContext(c.getProviderConfig().appContext);var S=function(){return null==O&&(O={state:"available",userDefines:[]}),O};K.on("reset",function(a){aa({type:"danger",msg:a.reason})}),K.on("queueupdate",function(c){b.debug("<<------rtcomm-service------>> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),K.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=X(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var T=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=X(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==P&&a.$digest()};K.setRtcommEndpointConfig({ringtone:c.getRingTone(),ringbacktone:c.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=X(c.endpoint.id);$(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"session:alerting":T,"session:trying":T,"session:ringing":T,"session:queued":T,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){Y(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){Y(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){X(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=W(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"chat:connected":T,"chat:disconnected":T,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};X(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},destroyed:T});var U=function(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=O&&(b.debug("RtcommService: initSuccess: updating presence record"),K.publishPresence(O)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==P&&a.$digest()},V=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==P&&a.$digest()},W=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=X(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=K.getRtcommEndpoint(c),d},$=function(b){var c=_();if(null!=c&&c!=b){var d=W(c);null!=d&&(d.activated=!1)}var d=X(b);d.activated=!0,a.$broadcast("endpointActivated",b)},_=function(){for(var a=null,b=0;b0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), +a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/services/config.service.js b/src/js/services/config.service.js index bf12a65..6bc6560 100644 --- a/src/js/services/config.service.js +++ b/src/js/services/config.service.js @@ -64,7 +64,7 @@ }; //Rtcomm Debug - var rtcommDebug = 'DEBUG'; + var rtcommDebug = 'INFO'; $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); $log.debug('providerConfig.server: ' + providerConfig.server); diff --git a/src/js/services/rtcomm-service.js b/src/js/services/rtcomm-service.js index 22d1e91..d0c1531 100644 --- a/src/js/services/rtcomm-service.js +++ b/src/js/services/rtcomm-service.js @@ -1,15 +1,14 @@ - /** *(C) Copyright IBM Corporation 2015. * - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -25,32 +24,45 @@ /** * Set debugEnabled to true to enable the debug messages in this rtcomm angular module. */ - .config(function($logProvider){ - $logProvider.debugEnabled(true); + .config(function($logProvider) { + $logProvider.debugEnabled(true); }) -.constant('rtcomm', rtcomm) -.factory('RtcommService', RtcommService); - RtcommService.$inject=['$rootScope', '$log', '$http', 'RtcommConfigService', 'rtcomm']; - function RtcommService($rootScope, $log, $http, RtcommConfigService, rtcomm) { - /** Setup the endpoint provider first **/ + .constant('rtcomm', rtcomm) + .factory('RtcommService', RtcommService); + RtcommService.$inject = ['$rootScope', '$log', 'RtcommConfigService', 'rtcomm']; + + function RtcommService($rootScope, $log, RtcommConfigService, rtcomm) { + /** Setup the endpoint provider first **/ + /*var service = { + alert: alert, + setKarmaTesting: setKarmaTesting, + isInitialized: isInitialized, + setConfig: setConfig + /* Presence Methods */ + + //}/ + - var myEndpointProvider = new rtcomm.EndpointProvider(); + var myEndpointProvider = new rtcomm.EndpointProvider(); var endpointProviderInitialized = false; var queueList = null; var sessions = []; var presenceRecord = null; var karmaTesting = false; - var _selfView = "selfView"; // Default self view - var _remoteView = "remoteView"; // Default remote view + var _selfView = 'selfView'; // Default self view + var _remoteView = 'remoteView'; // Default remote view myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); - $log.debug('rtcomm-service - endpointProvider log level is: '+myEndpointProvider.getLogLevel()); - $log.debug('rtcomm-service - endpointProvider log level should be: '+RtcommConfigService.getRtcommDebug()); + $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); + $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); myEndpointProvider.setAppContext(RtcommConfigService.getProviderConfig().appContext); - var getPresenceRecord = function(){ + var getPresenceRecord = function() { if (presenceRecord == null) - presenceRecord = {'state': 'available', userDefines: []}; + presenceRecord = { + 'state': 'available', + userDefines: [] + }; return (presenceRecord); }; @@ -59,16 +71,16 @@ var getMediaConfig = function() { var mediaConfig = { - ringbacktone: RtcommConfigService.getRingBackTone(), - ringtone: RtcommConfigService.getRingTone(), - webrtcConfig: { - broadcast : { - audio : RtcommConfigService.getBroadcastAudio(), - video : RtcommConfigService.getBroadcastVideo() - } - }, - webrtc : RtcommConfigService.getWebRTCEnabled(), - chat : RtcommConfigService.getChatEnabled(), + ringbacktone: RtcommConfigService.getRingBackTone(), + ringtone: RtcommConfigService.getRingTone(), + webrtcConfig: { + broadcast: { + audio: RtcommConfigService.getBroadcastAudio(), + video: RtcommConfigService.getBroadcastVideo() + } + }, + webrtc: RtcommConfigService.getWebRTCEnabled(), + chat: RtcommConfigService.getChatEnabled(), }; return (mediaConfig); @@ -76,7 +88,10 @@ myEndpointProvider.on('reset', function(event_object) { // Should have a reason. - _alert({type:'danger', msg: event_object.reason}); + _alert({ + type: 'danger', + msg: event_object.reason + }); }); @@ -84,45 +99,45 @@ $log.debug('<<------rtcomm-service------>> - Event: queueupdate'); $log.debug('queueupdate', queuelist); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('queueupdate', queuelist); - } + function() { + $rootScope.$broadcast('queueupdate', queuelist); + } ); }); myEndpointProvider.on('newendpoint', function(endpoint) { $log.debug('<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: ' + endpoint.getRemoteEndpointID()); - endpoint.on('onetimemessage',function(event){ + endpoint.on('onetimemessage', function(event) { $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != "undefined" && event.onetimemessage.type == 'iFrameURL'){ + if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { var session = _createSession(event.endpoint.id); session.iFrameURL = event.onetimemessage.iFrameURL; $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } + function() { + $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + } ); } }); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('newendpoint', endpoint); - } + function() { + $rootScope.$broadcast('newendpoint', endpoint); + } ); }); var callback = function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - if (eventObject.eventName.indexOf("session:") > -1){ - var session = _createSession(eventObject.endpoint.id); - session.sessionState = eventObject.eventName; - } - $rootScope.$broadcast(eventObject.eventName, eventObject); + function() { + if (eventObject.eventName.indexOf('session:') > -1) { + var session = _createSession(eventObject.endpoint.id); + session.sessionState = eventObject.eventName; } + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -132,21 +147,21 @@ }; // Setup all the callbacks here because they are all static. - myEndpointProvider.setRtcommEndpointConfig ({ + myEndpointProvider.setRtcommEndpointConfig({ ringtone: RtcommConfigService.getRingTone(), ringbacktone: RtcommConfigService.getRingBackTone(), // These are all the session related events. - 'session:started' : function(eventObject) { + 'session:started': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - var session = _createSession(eventObject.endpoint.id); - _setActiveEndpoint(eventObject.endpoint.id); + function() { + var session = _createSession(eventObject.endpoint.id); + _setActiveEndpoint(eventObject.endpoint.id); - session.sessionStarted = true; - session.remoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + session.sessionStarted = true; + session.remoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -155,18 +170,18 @@ }, - 'session:alerting' : callback, - 'session:trying' : callback, - 'session:ringing' : callback, - 'session:queued' : callback, + 'session:alerting': callback, + 'session:trying': callback, + 'session:ringing': callback, + 'session:queued': callback, - 'session:failed' : function(eventObject) { + 'session:failed': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + _removeSession(eventObject.endpoint.id); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) @@ -174,13 +189,13 @@ }, - 'session:stopped' : function(eventObject) { + 'session:stopped': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + _removeSession(eventObject.endpoint.id); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) @@ -189,42 +204,42 @@ }, // These are all the WebRTC related events. - 'webrtc:connected' : function(eventObject) { + 'webrtc:connected': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - _createSession(eventObject.endpoint.id).webrtcConnected = true; - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + _createSession(eventObject.endpoint.id).webrtcConnected = true; + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) $rootScope.$digest(); }, // These are all the WebRTC related events. - 'webrtc:remotemuted' : function(eventObject) { + 'webrtc:remotemuted': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) $rootScope.$digest(); }, - 'webrtc:disconnected' : function(eventObject) { + 'webrtc:disconnected': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - var session = _getSession(eventObject.endpoint.id); - if (session != null) - session.webrtcConnected = false; - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + var session = _getSession(eventObject.endpoint.id); + if (session != null) + session.webrtcConnected = false; + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -233,22 +248,22 @@ }, // These are all the chat related events. - 'chat:connected' : callback, - 'chat:disconnected' : callback, + 'chat:connected': callback, + 'chat:disconnected': callback, - 'chat:message' : function(eventObject) { + 'chat:message': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( - function () { - var chat = { - time : new Date(), - name : eventObject.message.from, - message : angular.copy(eventObject.message.message) - }; - - _createSession(eventObject.endpoint.id).chats.push(chat); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } + function() { + var chat = { + time: new Date(), + name: eventObject.message.from, + message: angular.copy(eventObject.message.message) + }; + + _createSession(eventObject.endpoint.id).chats.push(chat); + $rootScope.$broadcast(eventObject.eventName, eventObject); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -257,28 +272,28 @@ }, // Endpoint destroyed - 'destroyed' : callback + 'destroyed': callback }); var initSuccess = function(event) { $log.debug('<<------rtcomm-service------>> - Event: Provider init succeeded'); - if (presenceRecord != null){ + if (presenceRecord != null) { $log.debug('RtcommService: initSuccess: updating presence record'); myEndpointProvider.publishPresence(presenceRecord); } $rootScope.$evalAsync( - function () { - var broadcastEvent = { - 'ready': event.ready, - 'registered': event.registered, - 'endpoint': event.endpoint, - 'userid' : RtcommConfigService.getProviderConfig().userid - }; - - $rootScope.$broadcast('rtcomm::init', true, broadcastEvent); - } + function() { + var broadcastEvent = { + 'ready': event.ready, + 'registered': event.registered, + 'endpoint': event.endpoint, + 'userid': RtcommConfigService.getProviderConfig().userid + }; + + $rootScope.$broadcast('rtcomm::init', true, broadcastEvent); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... @@ -287,11 +302,11 @@ }; var initFailure = function(error) { - $log.debug('<<------rtcomm-service------>> - Event: Provider init failed: error: ',error); + $log.debug('<<------rtcomm-service------>> - Event: Provider init failed: error: ', error); $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::init', false, error); - } + function() { + $rootScope.$broadcast('rtcomm::init', false, error); + } ); // This is required in karma to get the evalAsync to fire. Ugly but necessary... if (karmaTesting == true) @@ -301,12 +316,12 @@ /* * Get session from local endpoint ID */ - var _getSession = function(endpointUUID){ + var _getSession = function(endpointUUID) { var session = null; - for (var index = 0; index < sessions.length; index++) { - if(sessions[index].endpointUUID === endpointUUID){ + for (var index = 0; index < sessions.length; index++) { + if (sessions[index].endpointUUID === endpointUUID) { session = sessions[index]; break; } @@ -318,27 +333,27 @@ /* * Get session from local endpoint ID */ - var _createSession = function(endpointUUID){ + var _createSession = function(endpointUUID) { var session = null; - for (var index = 0; index < sessions.length; index++) { - if(sessions[index].endpointUUID === endpointUUID){ + for (var index = 0; index < sessions.length; index++) { + if (sessions[index].endpointUUID === endpointUUID) { session = sessions[index]; break; } } - if (session == null){ + if (session == null) { session = { - endpointUUID : endpointUUID, - chats : [], - webrtcConnected : false, - sessionStarted : false, - iFrameURL : 'about:blank', - remoteEndpointID : null, - activated : true, - sessionState : 'session:stopped' + endpointUUID: endpointUUID, + chats: [], + webrtcConnected: false, + sessionStarted: false, + iFrameURL: 'about:blank', + remoteEndpointID: null, + activated: true, + sessionState: 'session:stopped' }; sessions[sessions.length] = session; } @@ -346,10 +361,10 @@ return (session); }; - var _removeSession = function(endpointUUID){ + var _removeSession = function(endpointUUID) { for (var index = 0; index < sessions.length; index++) { - if(sessions[index].endpointUUID === endpointUUID){ + if (sessions[index].endpointUUID === endpointUUID) { _getEndpoint(endpointUUID).destroy(); @@ -357,10 +372,9 @@ sessions.splice(index, 1); // Now we need to set the active endpoint to someone else or to no endpoint if none are left. - if (sessions.length == 0){ + if (sessions.length == 0) { $rootScope.$broadcast('noEndpointActivated'); - } - else{ + } else { _setActiveEndpoint(sessions[0].endpointUUID); } break; @@ -372,35 +386,34 @@ var _getEndpoint = function(uuid) { var endpoint = null; - if ((typeof uuid === "undefined") || uuid == null){ + if ((typeof uuid === 'undefined') || uuid == null) { $log.debug('getEndpoint: create new endpoint and setup onetimemessage event'); endpoint = myEndpointProvider.createRtcommEndpoint(); - endpoint.on('onetimemessage',function(event){ + endpoint.on('onetimemessage', function(event) { $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != "undefined" && event.onetimemessage.type == 'iFrameURL'){ + if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { var session = _createSession(event.endpoint.id); session.iFrameURL = event.onetimemessage.iFrameURL; $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } + function() { + $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + } ); } }); - } - else + } else endpoint = myEndpointProvider.getRtcommEndpoint(uuid); return (endpoint); }; - var _setActiveEndpoint = function(endpointID){ + var _setActiveEndpoint = function(endpointID) { // First get the old active endpoint var activeEndpoint = _getActiveEndpointUUID(); - if ((activeEndpoint != null) && (activeEndpoint != endpointID)){ + if ((activeEndpoint != null) && (activeEndpoint != endpointID)) { var session = _getSession(activeEndpoint); if (session != null) session.activated = false; @@ -412,11 +425,11 @@ $rootScope.$broadcast('endpointActivated', endpointID); }; - var _getActiveEndpointUUID = function(){ + var _getActiveEndpointUUID = function() { var activeEndpoint = null; for (var index = 0; index < sessions.length; index++) { - if(sessions[index].activated == true){ + if (sessions[index].activated == true) { activeEndpoint = sessions[index].endpointUUID; break; } @@ -424,335 +437,401 @@ return (activeEndpoint); }; var _alert = function _alert(alertObject) { - var a = { type: 'info', - msg: 'default message'}; - if (typeof alertObject === 'string') { - a.msg = alertObject; - } else { - a = alertObject; - } - $rootScope.$evalAsync( - function () { - $rootScope.$broadcast('rtcomm::alert', a); - } - ); + var a = { + type: 'info', + msg: 'default message' }; + if (typeof alertObject === 'string') { + a.msg = alertObject; + } else { + a = alertObject; + } + $rootScope.$evalAsync( + function() { + $rootScope.$broadcast('rtcomm::alert', a); + } + ); + }; + /** External functionalities fror the RtcommService API */ + function isInitialized() { + return endpointProviderInitialized; + } - return { + function setConfig(config) { - alert: _alert, + if (RtcommConfigService.isRtcommDisabled() == true) { + $log.debug('RtcommService:setConfig: isRtcommDisabled = true; return with no setup'); + return; + } - setKarmaTesting : function(){ - karmaTesting = true; - }, + if (config.rtcommDebug === 'INFO' || config.rtcommDebug === 'DEBUG') { + myEndpointProvider.setLogLevel(config.rtcommDebug); + } + $log.debug('rtcomm-services: setConfig: config: ', config); - isInitialized : function(){ - return(endpointProviderInitialized); - }, + RtcommConfigService.setProviderConfig(config); + myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); - setConfig : function(config){ - if (RtcommConfigService.isRtcommDisabled() == true){ - $log.debug('RtcommService:setConfig: isRtcommDisabled = true; return with no setup'); - return; + if (endpointProviderInitialized == false) { + // If the user does not specify a userid, that says one will never be specified so go ahead + // and initialize the endpoint provider and let the provider assign a name. If a defined empty + // string is passed in, that means to wait until the end user registers a name. + if (typeof config.userid == 'undefined' || RtcommConfigService.getProviderConfig().userid != '') { + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; } + } + } - if(config.rtcommDebug === "INFO" || config.rtcommDebug === "DEBUG"){ - myEndpointProvider.setLogLevel(config.rtcommDebug); - } - $log.debug('rtcomm-services: setConfig: config: ', config); - - RtcommConfigService.setProviderConfig(config); - myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); - - if (endpointProviderInitialized == false){ - // If the user does not specify a userid, that says one will never be specified so go ahead - // and initialize the endpoint provider and let the provider assign a name. If a defined empty - // string is passed in, that means to wait until the end user registers a name. - if (typeof config.userid == "undefined" || RtcommConfigService.getProviderConfig().userid != ''){ - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; - } - } - }, - // Presence related methods - getPresenceMonitor:function(topic) { - return myEndpointProvider.getPresenceMonitor(topic); - }, + function getPresenceMonitor(topic) { + return myEndpointProvider.getPresenceMonitor(topic); + } - publishPresence:function() { - if (endpointProviderInitialized == true) - myEndpointProvider.publishPresence(getPresenceRecord()); - }, + function publishPresence() { - /** - * userDefines is an array of JSON objects that look like: - * - * { - * name : "some name", - * value : "some value" - * } - * - * The only rule is that some name and some value have to both be strings. - */ - addToPresenceRecord:function(userDefines) { - - for (var index = 0; index < userDefines.length; index++) { - getPresenceRecord().userDefines.push(userDefines[index]); - } + if (endpointProviderInitialized === true) + myEndpointProvider.publishPresence(getPresenceRecord()); + } - if (endpointProviderInitialized == true){ - $log.debug('RtcommService: addToPresenceRecord: updating presence record to: ', getPresenceRecord()); - myEndpointProvider.publishPresence(getPresenceRecord()); - } - }, + function addToPresenceRecord(userDefines) { - /** - * userDefines is an array of JSON objects that look like: - * - * { - * name : "some name", - * value : "some value" - * } - * - * The only rule is that some name and some value have to both be strings. - */ - removeFromPresenceRecord:function(userDefines, doPublish) { - - for (var i = 0; i < userDefines.length; i++) { - for (var j = 0; j < getPresenceRecord().userDefines.length; j++) { - - if (getPresenceRecord().userDefines[j].name == userDefines[i].name){ - getPresenceRecord().userDefines.splice(j,1); - break; - } + for (var index = 0; index < userDefines.length; index++) { + getPresenceRecord().userDefines.push(userDefines[index]); + } + + if (endpointProviderInitialized == true) { + $log.debug('RtcommService: addToPresenceRecord: updating presence record to: ', getPresenceRecord()); + myEndpointProvider.publishPresence(getPresenceRecord()); + } + } + + function removeFromPresenceRecord(userDefines, doPublish) { + + for (var i = 0; i < userDefines.length; i++) { + for (var j = 0; j < getPresenceRecord().userDefines.length; j++) { + + if (getPresenceRecord().userDefines[j].name == userDefines[i].name) { + getPresenceRecord().userDefines.splice(j, 1); + break; } } + } - if ((endpointProviderInitialized == true) && doPublish){ - $log.debug('RtcommService: removeFromPresenceRecord: updating presence record to: ', getPresenceRecord()); - myEndpointProvider.publishPresence(getPresenceRecord()); - } - }, + if ((endpointProviderInitialized == true) && doPublish) { + $log.debug('RtcommService: removeFromPresenceRecord: updating presence record to: ', getPresenceRecord()); + myEndpointProvider.publishPresence(getPresenceRecord()); + } + } - setPresenceRecordState:function(state) { - getPresenceRecord().state = state; - return myEndpointProvider.publishPresence(getPresenceRecord()); - }, + function setPresenceRecordState(state) { - // Endpoint related methods - getEndpoint : function(uuid) { - return(_getEndpoint(uuid)); - }, + getPresenceRecord().state = state; + return myEndpointProvider.publishPresence(getPresenceRecord()); + } - destroyEndpoint : function(uuid) { - myEndpointProvider.getRtcommEndpoint(uuid).destroy(); - }, + function getEndpoint(uuid) { + return _getEndpoint(uuid); + } - // Registration related methods. - register : function(userid) { - if (endpointProviderInitialized == false){ - RtcommConfigService.getProviderConfig().userid = userid; + function destroyEndpoint(uuid) { + myEndpointProvider.getRtcommEndpoint(uuid).destroy(); + } - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; - } - else - $log.error('rtcomm-services: register: ERROR: endpoint provider already initialized'); - }, + function register(userid) { - unregister : function() { - if (endpointProviderInitialized == true){ - myEndpointProvider.destroy(); - endpointProviderInitialized = false; - initFailure("destroyed"); - } - else - $log.error('rtcomm-services: unregister: ERROR: endpoint provider not initialized'); - }, + if (endpointProviderInitialized == false) { + RtcommConfigService.getProviderConfig().userid = userid; - // Queue related methods - joinQueue : function(queueID) { - myEndpointProvider.joinQueue(queueID); - }, + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; + } else + $log.error('rtcomm-services: register: ERROR: endpoint provider already initialized'); + } - leaveQueue : function(queueID) { - myEndpointProvider.leaveQueue(queueID); - }, + function unregister() { - getQueues : function() { - return(queueList); - }, + if (endpointProviderInitialized == true) { + myEndpointProvider.destroy(); + endpointProviderInitialized = false; + initFailure('destroyed'); + } else + $log.error('rtcomm-services: unregister: ERROR: endpoint provider not initialized'); + } - /** - * Chat related methods - */ - sendChatMessage : function(chat, endpointUUID){ - // Save this chat in the local session store - var session = _createSession(endpointUUID); - session.chats.push(chat); - - myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); - }, - getChats : function(endpointUUID) { - if (typeof endpointUUID !== "undefined" && endpointUUID != null){ - var session = _getSession(endpointUUID); - if (session != null) - return (session.chats); - else - return(null); - } - else - return(null); - }, + /** + * Queue API + */ + function joinQueue(queueID) { + myEndpointProvider.joinQueue(queueID); + } - isWebrtcConnected : function(endpointUUID) { - if (typeof endpointUUID !== 'undefined' && endpointUUID != null){ - var session = _getSession(endpointUUID); - if (session != null) - return (session.webrtcConnected); - else - return(false); - } + function leaveQueue(queueID) { + myEndpointProvider.leaveQueue(queueID); + } + + function getQueues() { + return queueList; + } + + /** + * Chat API + */ + function sendChatMessage(chat, endpointUUID) { + + // Save this chat in the local session store + var session = _createSession(endpointUUID); + session.chats.push(chat); + + myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); + + } + + function getChats(endpointUUID) { + + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { + var session = _getSession(endpointUUID); + if (session != null) + return (session.chats); else - return(false); - }, + return (null); + } else + return (null); + + } - getSessionState : function(endpointUUID) { - if (typeof endpointUUID !== "undefined" && endpointUUID != null) - return (myEndpointProvider.getRtcommEndpoint(endpointUUID).getState()); + function isWebrtcConnected(endpointUUID) { + + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { + var session = _getSession(endpointUUID); + if (session != null) + return (session.webrtcConnected); else - return ("session:stopped"); - }, + return (false); + } else + return (false); + } - setAlias : function(aliasID) { - if ((typeof aliasID !== "undefined") && aliasID != '') - myEndpointProvider.setUserID(aliasID); - }, + function getSessionState(endpointUUID) { - setUserID : function(userID) { - if ((typeof userID !== "undefined") && userID != ''){ - RtcommConfigService.setProviderConfig({userid: userID}); - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - } - }, + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) + return (myEndpointProvider.getRtcommEndpoint(endpointUUID).getState()); + else + return ('session:stopped'); + } - setPresenceTopic : function(presenceTopic) { - if ((typeof presenceTopic !== "undefined") && presenceTopic != ''){ - RtcommConfigService.setProviderConfig({presenceTopic : presenceTopic}); - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - } - }, + function setAlias(aliasID) { - getIframeURL : function(endpointUUID){ - if (typeof endpointUUID !== "undefined" && endpointUUID != null){ - var session = _getSession(endpointUUID); - if (session != null) - return (session.iFrameURL); - else - return(null); - } + if ((typeof aliasID !== 'undefined') && aliasID != '') + myEndpointProvider.setUserID(aliasID); + } + + function setUserID(userID) { + + if ((typeof userID !== 'undefined') && userID != '') { + RtcommConfigService.setProviderConfig({ + userid: userID + }); + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + } + } + + function setPresenceTopic(presenceTopic) { + + if ((typeof presenceTopic !== 'undefined') && presenceTopic != '') { + RtcommConfigService.setProviderConfig({ + presenceTopic: presenceTopic + }); + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + } + + } + + function getIframeURL(endpointUUID) { + + if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { + var session = _getSession(endpointUUID); + if (session != null) + return (session.iFrameURL); else - return(null); - }, + return (null); + } else + return (null); + } - putIframeURL : function(endpointUUID, newUrl){ - $log.debug('RtcommService: putIframeURL: endpointUUID: ' + endpointUUID + ' newURL: ' + newUrl); - var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); + function putIframeURL(endpointUUID, newUrl) { - if (endpoint != null){ - var session = _createSession(endpointUUID); - session.iFrameURL = newUrl; - var message = { type : 'iFrameURL', - iFrameURL : newUrl}; + $log.debug('RtcommService: putIframeURL: endpointUUID: ' + endpointUUID + ' newURL: ' + newUrl); + var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); - $log.debug('RtcommService: putIframeURL: sending new iFrame URL'); - endpoint.sendOneTimeMessage(message); - } - }, + if (endpoint != null) { + var session = _createSession(endpointUUID); + session.iFrameURL = newUrl; - placeCall : function(calleeID, mediaToEnable){ - var endpoint = _getEndpoint(); + var message = { + type: 'iFrameURL', + iFrameURL: newUrl + }; - if (mediaToEnable.indexOf('chat') > -1) - endpoint.chat.enable(); + $log.debug('RtcommService: putIframeURL: sending new iFrame URL'); + endpoint.sendOneTimeMessage(message); + } + } - if (mediaToEnable.indexOf('webrtc') > -1) { - // Support turning off trickle ICE - var trickleICE = true; - if (mediaToEnable.indexOf('disableTrickleICE') > -1) { - trickleICE = false; - } - endpoint.webrtc.enable({'trickleICE': trickleICE}); + function placeCall(calleeID, mediaToEnable) { + + var endpoint = _getEndpoint(); + + if (mediaToEnable.indexOf('chat') > -1) + endpoint.chat.enable(); + + if (mediaToEnable.indexOf('webrtc') > -1) { + // Support turning off trickle ICE + var trickleICE = true; + if (mediaToEnable.indexOf('disableTrickleICE') > -1) { + trickleICE = false; } - _setActiveEndpoint(endpoint.id); + endpoint.webrtc.enable({ + 'trickleICE': trickleICE + }); + } + _setActiveEndpoint(endpoint.id); - endpoint.connect(calleeID); - return(endpoint.id); - }, + endpoint.connect(calleeID); + return (endpoint.id); + } - getSessions : function(){ - return(sessions); - }, + function getSessions() { + return sessions; + } - endCall : function(endpoint) { - endpoint.disconnect(); - }, + function endCall(endpoint) { + endpoint.disconnect(); + } - setActiveEndpoint : function(endpointID){ - _setActiveEndpoint(endpointID); - }, + function setActiveEndpoint(endpointID) { + _setActiveEndpoint(endpointID); + } - getActiveEndpoint : function(){ - return(_getActiveEndpointUUID()); - }, + function getActiveEndpoint() { + return _getActiveEndpointUUID(); + } - getRemoteEndpoint : function(localEndpointID){ - var remoteEndpointID = null; + function getRemoteEndpoint(localEndpointID) { - if (localEndpointID != null){ - var session = _getSession(localEndpointID); - if (session != null){ - remoteEndpointID = session.remoteEndpointID; - } + var remoteEndpointID = null; + + if (localEndpointID != null) { + var session = _getSession(localEndpointID); + + if (session != null) { + remoteEndpointID = session.remoteEndpointID; } + } - return (remoteEndpointID); - }, + return (remoteEndpointID); + } - setDefaultViewSelector : function() { - _selfView = "selfView"; - _remoteView = "remoteView"; - }, + function setDefaultViewSelector() { - setViewSelector : function(selfView, remoteView) { - _selfView = selfView; - _remoteView = remoteView; - }, + _selfView = 'selfView'; + _remoteView = 'remoteView'; + } - setVideoView : function(endpointUUID){ - $log.debug('rtcommVideo: setting local media'); - var endpoint = null; - - if (typeof endpointUUID != "undefined" && endpointUUID != null) - endpoint = _getEndpoint(endpointUUID); - else if (_getActiveEndpointUUID() != null) - endpoint = _getEndpoint(_getActiveEndpointUUID()); - - if (endpoint != null){ - $log.debug(endpoint); - endpoint.webrtc.setLocalMedia( - { - mediaOut: document.querySelector('#' + _selfView), - mediaIn: document.querySelector('#' + _remoteView) - }); - } - }, - }; - }; + function setViewSelector(selfView, remoteView) { + _selfView = selfView; + _remoteView = remoteView; + } + + function setVideoView(endpointUUID) { + + $log.debug('rtcommVideo: setting local media'); + var endpoint = null; + + if (typeof endpointUUID != 'undefined' && endpointUUID != null) + endpoint = _getEndpoint(endpointUUID); + else if (_getActiveEndpointUUID() != null) + endpoint = _getEndpoint(_getActiveEndpointUUID()); + + if (endpoint != null) { + $log.debug(endpoint); + endpoint.webrtc.setLocalMedia({ + mediaOut: document.querySelector('#' + _selfView), + mediaIn: document.querySelector('#' + _remoteView) + }); + } + } + return { + + alert: _alert, + + isInitialized: isInitialized, + + setConfig: setConfig, + + getPresenceMonitor: getPresenceMonitor, + + publishPresence: publishPresence, + + addToPresenceRecord: addToPresenceRecord, + removeFromPresenceRecord: removeFromPresenceRecord, + + setPresenceRecordState: setPresenceRecordState, + + getEndpoint: getEndpoint, + + destroyEndpoint: destroyEndpoint, + + register: register, + + unregister: unregister, + + joinQueue: joinQueue, + + leaveQueue: leaveQueue, + + getQueues: getQueues, + + sendChatMessage: sendChatMessage, + + getChats: getChats, + + isWebrtcConnected: isWebrtcConnected, + + getSessionState: getSessionState, + + setAlias: setAlias, + + setUserID: setUserID, + + setPresenceTopic: setPresenceTopic, + + getIframeURL: getIframeURL, + + putIframeURL: putIframeURL, + + placeCall: placeCall, + + getSessions: getSessions, + + endCall: endCall, + + setActiveEndpoint: setActiveEndpoint, + + getActiveEndpoint: getActiveEndpoint, + + getRemoteEndpoint: getRemoteEndpoint, + + setDefaultViewSelector: setDefaultViewSelector, + + setViewSelector: setViewSelector, + + setVideoView: setVideoView + }; + } })(); diff --git a/src/js/services/rtcomm-service.spec.js b/src/js/services/rtcomm-service.spec.js index 50d379d..4f4f01e 100644 --- a/src/js/services/rtcomm-service.spec.js +++ b/src/js/services/rtcomm-service.spec.js @@ -130,6 +130,42 @@ describe('Unit Testing: RtcommService', function(){ }); + it('should have the API defined for backward compability', function(){ + + expect(RtcommService.alert).to.not.be.undefined; + expect(RtcommService.isInitialized).to.not.be.undefined; + expect(RtcommService.setConfig).to.not.be.undefined; + expect(RtcommService.getPresenceMonitor).to.not.be.undefined; + expect(RtcommService.publishPresence).to.not.be.undefined; + expect(RtcommService.addToPresenceRecord).to.not.be.undefined; + expect(RtcommService.removeFromPresenceRecord).to.not.be.undefined; + expect(RtcommService.setPresenceRecordState).to.not.be.undefined; + expect(RtcommService.getEndpoint).to.not.be.undefined; + expect(RtcommService.destroyEndpoint).to.not.be.undefined; + expect(RtcommService.register).to.not.be.undefined; + expect(RtcommService.unregister).to.not.be.undefined; + expect(RtcommService.joinQueue).to.not.be.undefined; + expect(RtcommService.leaveQueue).to.not.be.undefined; + expect(RtcommService.getQueues).to.not.be.undefined; + expect(RtcommService.sendChatMessage).to.not.be.undefined; + expect(RtcommService.getChats).to.not.be.undefined; + expect(RtcommService.isWebrtcConnected).to.not.be.undefined; + expect(RtcommService.getSessionState).to.not.be.undefined; + expect(RtcommService.setAlias).to.not.be.undefined; + expect(RtcommService.setUserID).to.not.be.undefined; + expect(RtcommService.setPresenceTopic).to.not.be.undefined; + expect(RtcommService.getIframeURL).to.not.be.undefined; + expect(RtcommService.putIframeURL).to.not.be.undefined; + expect(RtcommService.placeCall).to.not.be.undefined; + expect(RtcommService.getSessions).to.not.be.undefined; + expect(RtcommService.endCall).to.not.be.undefined; + expect(RtcommService.setActiveEndpoint).to.not.be.undefined; + expect(RtcommService.getActiveEndpoint).to.not.be.undefined; + expect(RtcommService.getRemoteEndpoint).to.not.be.undefined; + expect(RtcommService.setDefaultViewSelector).to.not.be.undefined; + expect(RtcommService.setViewSelector).to.not.be.undefined; + expect(RtcommService.setVideoView).to.not.be.undefined; + }); //Helper functions function generateMockRtcomm(){ diff --git a/src/js/ui/config.controller.js b/src/js/ui/config.controller.js index 3e0a496..e1a92ce 100644 --- a/src/js/ui/config.controller.js +++ b/src/js/ui/config.controller.js @@ -36,50 +36,50 @@ */ (function() { - 'use strict'; + 'use strict'; - angular - .module('angular-rtcomm-ui') - .controller('RtcommConfigController', RtcommConfigController); + angular + .module('angular-rtcomm-ui') + .controller('RtcommConfigController', RtcommConfigController); - RtcommConfigController.$inject = ['RtcommService', '$http', '$scope', '$log']; + RtcommConfigController.$inject = ['RtcommService', '$http', '$scope', '$log']; - /* @ngInject */ - function RtcommConfigController(RtcommService, $http, $scope, $log) { - var vm = this; - vm.extendedConfig = null; + /* @ngInject */ + function RtcommConfigController(RtcommService, $http, $scope, $log) { + var vm = this; + vm.extendedConfig = null; - $log.debug('RtcommConfigController: configURL = ' + vm.configURL); + $log.debug('RtcommConfigController: configURL = ' + vm.configURL); - vm.setConfig = function(data) { - $log.debug('RtcommConfigController: setting config data:' + data); - RtcommService.setConfig(data); - }; + vm.setConfig = function(data) { + $log.debug('RtcommConfigController: setting config data:' + data); + RtcommService.setConfig(data); + }; - $scope.init = function(configURL, extendedConfig) { + $scope.init = function(configURL, extendedConfig) { - $log.debug('RtcommConfigController: initing configURL = ' + configURL); - vm.configURL = configURL; + $log.debug('RtcommConfigController: initing configURL = ' + configURL); + vm.configURL = configURL; - if (typeof extendedConfig !== "undefined") - vm.extendedConfig = extendedConfig; + if (typeof extendedConfig !== 'undefined') + vm.extendedConfig = extendedConfig; - vm.getConfig(); - }; + vm.getConfig(); + }; - vm.getConfig = function() { - $http.get(vm.configURL).success(function(config) { + vm.getConfig = function() { + $http.get(vm.configURL).success(function(config) { - // Now we need to update the config with any extensions passed in on init. - if (vm.extendedConfig != null) { - angular.extend(config, vm.extendedConfig); - $log.debug('RtcommConfigController: extended config object: ' + config); - } + // Now we need to update the config with any extensions passed in on init. + if (vm.extendedConfig != null) { + angular.extend(config, vm.extendedConfig); + $log.debug('RtcommConfigController: extended config object: ' + config); + } - RtcommService.setConfig(config); - }).error(function(data, status, headers, config) { - $log.debug('RtcommConfigController: error accessing config: ' + status); - }); - }; - } + RtcommService.setConfig(config); + }).error(function(data, status, headers, config) { + $log.debug('RtcommConfigController: error accessing config: ' + status); + }); + }; + } })(); diff --git a/src/js/ui/config.controller.spec.js b/src/js/ui/config.controller.spec.js index fec38d5..25cde65 100644 --- a/src/js/ui/config.controller.spec.js +++ b/src/js/ui/config.controller.spec.js @@ -1,4 +1,3 @@ - /** *(C) Copyright IBM Corporation 2016. * @@ -18,71 +17,75 @@ describe('Unit Testing: RtcommConfigController', function() { - var sandbox; + var sandbox; - var $rootScope, RtcommService, $compile, $httpBackend, rtcommConfigGET, rtcommConfig; - beforeEach(module('rtcomm.templates')); + var $rootScope, RtcommService, $compile, $httpBackend, rtcommConfigGET, rtcommConfig; + beforeEach(module('rtcomm.templates')); - beforeEach(module('angular-rtcomm-ui')); + beforeEach(module('angular-rtcomm-ui')); - beforeEach(inject( - function($injector) { + beforeEach(inject( + function($injector) { - sandbox = sinon.sandbox.create(); - $rootScope = $injector.get('$rootScope'); - RtcommService = $injector.get('RtcommService'); - $compile = $injector.get('$compile'); - $httpBackend = $injector.get('$httpBackend'); + sandbox = sinon.sandbox.create(); + $rootScope = $injector.get('$rootScope'); + RtcommService = $injector.get('RtcommService'); + $compile = $injector.get('$compile'); + $httpBackend = $injector.get('$httpBackend'); - rtcommConfig = { - 'rtcommTopicPath': '/rtcomm/', - 'createEndpoint': true, - 'presenceTopic': 'sampleRoom', - 'broadcastVideo': true, - 'broadcastAudio': true, - 'userid': '' - }; + rtcommConfig = { + 'rtcommTopicPath': '/rtcomm/', + 'createEndpoint': true, + 'presenceTopic': 'sampleRoom', + 'broadcastVideo': true, + 'broadcastAudio': true, + 'userid': '' + }; - rtcommConfigGET = $httpBackend.when('GET', 'rtcommConfig.json'); - rtcommConfigGET.respond(rtcommConfig); + rtcommConfigGET = $httpBackend.when('GET', 'rtcommConfig.json'); + rtcommConfigGET.respond(rtcommConfig); - } - )); + } + )); - afterEach(function(){ - sandbox.restore(); - }); + afterEach(function() { + sandbox.restore(); + }); - it('should initialize with a simple config', function(){ - sandbox.stub(RtcommService, 'setConfig', function(data){ - expect(data).to.deep.equal(angular.extend(rtcommConfig, {})); - }); + it('should initialize with a simple config', function() { + sandbox.stub(RtcommService, 'setConfig', function(data) { + expect(data).to.deep.equal(angular.extend(rtcommConfig, {})); + }); - $httpBackend.expectGET('rtcommConfig.json'); + $httpBackend.expectGET('rtcommConfig.json'); - var rtcommConfigDiv = compileRtcommConfigController(); + var rtcommConfigDiv = compileRtcommConfigController(); - $httpBackend.flush(); + $httpBackend.flush(); - }); + }); - it('should combine the simple config and extended config', function(){ + it('should combine the simple config and extended config', function() { - sandbox.stub(RtcommService, 'setConfig', function(data){ - expect(data).to.deep.equal(angular.extend(rtcommConfig, {chat: false})); - }); - $httpBackend.expectGET('rtcommConfig.json'); + sandbox.stub(RtcommService, 'setConfig', function(data) { + expect(data).to.deep.equal(angular.extend(rtcommConfig, { + chat: false + })); + }); + $httpBackend.expectGET('rtcommConfig.json'); - var rtcommConfigDiv = compileRtcommConfigController({'chat': false}); + var rtcommConfigDiv = compileRtcommConfigController({ + 'chat': false + }); - $httpBackend.flush(); + $httpBackend.flush(); - }); + }); - function compileRtcommConfigController(extendedConfig){ - var html = '
'; - var configCtrl = $compile(html)($rootScope); - return configCtrl; - } + function compileRtcommConfigController(extendedConfig) { + var html = '
'; + var configCtrl = $compile(html)($rootScope); + return configCtrl; + } }); diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js index 1305822..3d0a192 100644 --- a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js @@ -14,88 +14,88 @@ * limitations under the License. */ (function() { - 'use strict'; + 'use strict'; - angular - .module('angular-rtcomm-ui') - .controller('RtcommEndpointController', RtcommEndpointController); + angular + .module('angular-rtcomm-ui') + .controller('RtcommEndpointController', RtcommEndpointController); - RtcommEndpointController.$inject = ['RtcommService', '$scope', '$log']; + RtcommEndpointController.$inject = ['RtcommService', '$scope', '$log']; - /* @ngInject */ - function RtcommEndpointController(RtcommService, $scope, $log) { - $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); - $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); + /* @ngInject */ + function RtcommEndpointController(RtcommService, $scope, $log) { + $scope.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); + $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - function getActiveEndpoint() { - return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); - } - - $scope.disconnect = function() { - $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - var ep = getActiveEndpoint; - ep.disconnect(); - }; + function getActiveEndpoint() { + return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); + } - $scope.toggleAV = function() { - $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + $scope.disconnect = function() { + $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + var ep = getActiveEndpoint; + ep.disconnect(); + }; - if ($scope.epCtrlAVConnected == false) { - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { - if (!value) { - $log.debug('Enable failed: ', message); - RtcommService.alert({ - type: 'danger', - msg: message - }); - } - }); - } else { - $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); - } - }; + $scope.toggleAV = function() { + $log.debug('Enable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - $scope.$on('session:started', function(event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:started'; - } + if ($scope.epCtrlAVConnected == false) { + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.enable(function(value, message) { + if (!value) { + $log.debug('Enable failed: ', message); + RtcommService.alert({ + type: 'danger', + msg: message + }); + } }); + } else { + $log.debug('Disable AV for endpoint: ' + $scope.epCtrlActiveEndpointUUID); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).webrtc.disable(); + } + }; - $scope.$on('session:stopped', function(event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:stopped'; - } - }); + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:started'; + } + }); - $scope.$on('session:failed', function(event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - $scope.sessionState = 'session:failed'; - } - }); + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:stopped'; + } + }); - $scope.$on('webrtc:connected', function(event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = true; - }); + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + $scope.sessionState = 'session:failed'; + } + }); - $scope.$on('webrtc:disconnected', function(event, eventObject) { - if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) - $scope.epCtrlAVConnected = false; - }); + $scope.$on('webrtc:connected', function(event, eventObject) { + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = true; + }); + $scope.$on('webrtc:disconnected', function(event, eventObject) { + if ($scope.epCtrlActiveEndpointUUID == eventObject.endpoint.id) + $scope.epCtrlAVConnected = false; + }); - $scope.$on('endpointActivated', function(event, endpointUUID) { - $scope.epCtrlActiveEndpointUUID = endpointUUID; - $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); - }); - $scope.$on('noEndpointActivated', function(event) { - $scope.epCtrlAVConnected = false; - }); - } + $scope.$on('endpointActivated', function(event, endpointUUID) { + $scope.epCtrlActiveEndpointUUID = endpointUUID; + $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + $scope.epCtrlAVConnected = false; + }); + } })(); diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js index 9a53a4d..75d7e08 100644 --- a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js @@ -1,4 +1,3 @@ - /** *(C) Copyright IBM Corporation 2016. * @@ -16,47 +15,47 @@ */ -describe('Unit Testing: Endpoint Controller', function(){ - //Dependency - var RtcommService; - - //Utilities - var $compile; - //Mock and stubbing - var sandbox; - - beforeEach(module('rtcomm.templates')); - beforeEach(module('angular-rtcomm-ui')); - - - beforeEach(inject(function($injector){ - sandbox = sinon.sandbox.create(); - RtcommService = $injector.get('RtcommService'); - $compile= $injector.get('$compile'); - $rootScope = $injector.get('$rootScope'); - - - })); - - beforeEach(function(){ - //Mock initial state of the controller - // - var endpoint = { - - } - sandbox.stub(RtcommService, 'getActiveEndpoint', function(){ - return 'MOCK_ID'; - }); - sandbox.stub(RtcommService, 'isWebrtcConnected', function(id){ - return false; - }); - - sandbox.stub(RtcommService, 'getSessionState', function(){ - return 'session:stopped'; - }); - }); - it('should enable webrtc on the current active endpoint', function(){ - - - }); +describe('Unit Testing: Endpoint Controller', function() { + //Dependency + var RtcommService; + + //Utilities + var $compile; + //Mock and stubbing + var sandbox; + + beforeEach(module('rtcomm.templates')); + beforeEach(module('angular-rtcomm-ui')); + + + beforeEach(inject(function($injector) { + sandbox = sinon.sandbox.create(); + RtcommService = $injector.get('RtcommService'); + $compile = $injector.get('$compile'); + $rootScope = $injector.get('$rootScope'); + + + })); + + beforeEach(function() { + //Mock initial state of the controller + // + var endpoint = { + + } + sandbox.stub(RtcommService, 'getActiveEndpoint', function() { + return 'MOCK_ID'; + }); + sandbox.stub(RtcommService, 'isWebrtcConnected', function(id) { + return false; + }); + + sandbox.stub(RtcommService, 'getSessionState', function() { + return 'session:stopped'; + }); + }); + it('should enable webrtc on the current active endpoint', function() { + + + }); }); diff --git a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js index 6b0fe20..4e440ed 100644 --- a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js +++ b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.js @@ -20,104 +20,105 @@ * active endpoints. */ (function() { - 'use strict'; - - angular - .module('angular-rtcomm-ui') - .directive('rtcommChat', rtcommChat); - - rtcommChat.$inject = ['RtcommService', '$log']; - - /* @ngInject */ - function rtcommChat(RtcommService, $log) { - var directive = { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-chat.html', - link: chatLink, - controller: ChatController, - controllerAs: 'chatVM', - bindToController: true - }; - - return directive; - - function chatLink(scope, element, attr, ctrl) { - var chatPanel = angular.element(element.find('.panel-body')[0]); - - var bottom = true; - - //Chooses if the scrollbar should be forced to the bottom on the next lifecycle - ctrl.scrollToBottom = function(flag) { - bottom = flag; - scope.bottom = flag; - - } - if(chatPanel.length > 0){ - //Watch scroll events - chatPanel.bind('scroll', function() { - if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { - ctrl.scrollToBottom(true); - } else { - ctrl.scrollToBottom(false); - } - }); - - //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down - scope.$watch(function() { - return ctrl.chats - }, function() { - $log.debug('rtcommChat - Link > $watch on chats called'); - if (bottom) { - chatPanel.scrollTop(chatPanel.prop('scrollHeight')); - } else { - //In this else, a notification could be sent - } - }, true); - - }} + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommChat', rtcommChat); + + rtcommChat.$inject = ['RtcommService', '$log']; + + /* @ngInject */ + function rtcommChat(RtcommService, $log) { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-chat.html', + link: chatLink, + controller: ChatController, + controllerAs: 'chatVM', + bindToController: true + }; + + return directive; + + function chatLink(scope, element, attr, ctrl) { + var chatPanel = angular.element(element.find('.panel-body')[0]); + + var bottom = true; + + //Chooses if the scrollbar should be forced to the bottom on the next lifecycle + ctrl.scrollToBottom = function(flag) { + bottom = flag; + scope.bottom = flag; + + } + if (chatPanel.length > 0) { + //Watch scroll events + chatPanel.bind('scroll', function() { + if (chatPanel.prop('scrollTop') + chatPanel.prop('clientHeight') == chatPanel.prop('scrollHeight')) { + ctrl.scrollToBottom(true); + } else { + ctrl.scrollToBottom(false); + } + }); + //Watch the chat messages, if the scroll bar is in the bottom keep it on the bottom so the user can view incoming chat messages, else possibly send a notification and don't scroll down + scope.$watch(function() { + return ctrl.chats + }, function() { + $log.debug('rtcommChat - Link > $watch on chats called'); + if (bottom) { + chatPanel.scrollTop(chatPanel.prop('scrollHeight')); + } else { + //In this else, a notification could be sent + } + }, true); + + } } - //Controller should be used to listen for events from Rtcmo - ChatController.$inject = ['$scope', 'RtcommService', '$log']; - - /* @ngInject */ - function ChatController($scope, RtcommService, $log) { - var vm = this; - - vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); - - vm.keySendMessage = function(keyEvent) { - if (keyEvent.which === 13) - vm.sendMessage(); - }; - - vm.sendMessage = function() { - $log.debug('rtcommChat: sendMessage() -> ' + vm.message); - var chat = { - time: new Date(), - name: RtcommService.getEndpoint(vm.chatActiveEndpointUUID).getLocalEndpointID(), - message: angular.copy(vm.message) - }; - - vm.message = ''; - vm.scrollToBottom(true); - $scope.bottom = true; - RtcommService.sendChatMessage(chat, vm.chatActiveEndpointUUID); - } - - $scope.$on('endpointActivated', function(event, endpointUUID) { - $log.debug('rtcommChat: endpointActivated =' + endpointUUID); - - // The data model for the chat is maintained in the RtcommService. - vm.chats = RtcommService.getChats(endpointUUID); - vm.chatActiveEndpointUUID = endpointUUID; - }); + } - $scope.$on('noEndpointActivated', function(event) { - vm.chats = []; - vm.chatActiveEndpointUUID = null; - }); + //Controller should be used to listen for events from Rtcmo + ChatController.$inject = ['$scope', 'RtcommService', '$log']; + + /* @ngInject */ + function ChatController($scope, RtcommService, $log) { + var vm = this; + + vm.chatActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.chats = RtcommService.getChats(vm.chatActiveEndpointUUID); + + vm.keySendMessage = function(keyEvent) { + if (keyEvent.which === 13) + vm.sendMessage(); + }; + + vm.sendMessage = function() { + $log.debug('rtcommChat: sendMessage() -> ' + vm.message); + var chat = { + time: new Date(), + name: RtcommService.getEndpoint(vm.chatActiveEndpointUUID).getLocalEndpointID(), + message: angular.copy(vm.message) + }; + + vm.message = ''; + vm.scrollToBottom(true); + $scope.bottom = true; + RtcommService.sendChatMessage(chat, vm.chatActiveEndpointUUID); } + + $scope.$on('endpointActivated', function(event, endpointUUID) { + $log.debug('rtcommChat: endpointActivated =' + endpointUUID); + + // The data model for the chat is maintained in the RtcommService. + vm.chats = RtcommService.getChats(endpointUUID); + vm.chatActiveEndpointUUID = endpointUUID; + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.chats = []; + vm.chatActiveEndpointUUID = null; + }); + } })(); diff --git a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js index 2aeb3b1..959ace7 100644 --- a/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js +++ b/src/js/ui/endpoint/rtcomm-chat/rtcomm-chat.spec.js @@ -1,4 +1,3 @@ - /** *(C) Copyright IBM Corporation 2016. * @@ -17,259 +16,259 @@ describe('Unit Testing: RtcommChat directive', function() { - var $compile, _$rootScope, sandbox, scope, element; - - var chatInput, sendBtn; - - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm-ui')); - - //Mock RtcommService - beforeEach(function() { - RtcommService = { - endpoints: [], - activeEndpoint: null, - getActiveEndpoint: function() { - return this.activeEndpoint; - }, - getChats: function() { - - var ep = this.getEndpoint(this.activeEndpoint); - if (ep !== null) { - return ep.chats; - } else { - return []; - } - }, - getEndpoint: function(id) { - var endpoint = null - this.endpoints.forEach(function(_endpoint) { - if (_endpoint.id === id) { - endpoint = _endpoint; - } - }); - return endpoint; - }, - sendChatMessage: function(chat, endpoint) { - //Store chats locally, RtcommService uses a session storage mechanism, since this is a - //mock we can just store teh chats on the mockendpoint itself - var endpoint = this.getEndpoint(this.activeEndpoint); - endpoint.chats.push(chat); - }, - //Interface methods for manipulating the RtcommService through the test - _MockCreateEndpoint: function(id, userid) { - var mockEP = createMockEndpoint(id, userid); - this.endpoints.push(mockEP); - }, - _setActiveEndpoint: function(id) { - this.activeEndpoint = id; - }, - _emitChatMessage: function(eventObject) { - this.endpoints.forEach(function(_endpoint) { - if (_endpoint.id === eventObject.id) { - var chatMessage = { - name: eventObject.message.from, - time: new Date(), - message: eventObject.message.message - - } - _endpoint.chats.push(chatMessage); - - } - }); - }, - _destroyEndpoint: function(id){ - // console.log(this.endpoints); - this.endpoints.forEach(function(_endpoint, index, endpoints){ - if(_endpoint.id === id){ - _endpoint.chats = []; - endpoints.splice(index, 1); - } - }); - console.log(this.endpoints); + var $compile, _$rootScope, sandbox, scope, element; - } + var chatInput, sendBtn; + + beforeEach(module("rtcomm.templates")); + + beforeEach(module('angular-rtcomm-ui')); + + //Mock RtcommService + beforeEach(function() { + RtcommService = { + endpoints: [], + activeEndpoint: null, + getActiveEndpoint: function() { + return this.activeEndpoint; + }, + getChats: function() { + + var ep = this.getEndpoint(this.activeEndpoint); + if (ep !== null) { + return ep.chats; + } else { + return []; } + }, + getEndpoint: function(id) { + var endpoint = null + this.endpoints.forEach(function(_endpoint) { + if (_endpoint.id === id) { + endpoint = _endpoint; + } + }); + return endpoint; + }, + sendChatMessage: function(chat, endpoint) { + //Store chats locally, RtcommService uses a session storage mechanism, since this is a + //mock we can just store teh chats on the mockendpoint itself + var endpoint = this.getEndpoint(this.activeEndpoint); + endpoint.chats.push(chat); + }, + //Interface methods for manipulating the RtcommService through the test + _MockCreateEndpoint: function(id, userid) { + var mockEP = createMockEndpoint(id, userid); + this.endpoints.push(mockEP); + }, + _setActiveEndpoint: function(id) { + this.activeEndpoint = id; + }, + _emitChatMessage: function(eventObject) { + this.endpoints.forEach(function(_endpoint) { + if (_endpoint.id === eventObject.id) { + var chatMessage = { + name: eventObject.message.from, + time: new Date(), + message: eventObject.message.message + + } + _endpoint.chats.push(chatMessage); - module(function($provide) { - $provide.value('RtcommService', RtcommService); + } }); + }, + _destroyEndpoint: function(id) { + // console.log(this.endpoints); + this.endpoints.forEach(function(_endpoint, index, endpoints) { + if (_endpoint.id === id) { + _endpoint.chats = []; + endpoints.splice(index, 1); + } + }); + console.log(this.endpoints); + + } + } + + module(function($provide) { + $provide.value('RtcommService', RtcommService); }); + }); - //Setup Test - beforeEach(inject(function($compile, $rootScope) { - _$rootScope = $rootScope; + //Setup Test + beforeEach(inject(function($compile, $rootScope) { + _$rootScope = $rootScope; - scope = $rootScope; - element = $compile('')(scope); - scope.$digest(); + scope = $rootScope; + element = $compile('')(scope); + scope.$digest(); - sandbox = sinon.sandbox.create(); - chatInput = element.find('input'); - sendBtn = element.find('button'); + sandbox = sinon.sandbox.create(); + chatInput = element.find('input'); + sendBtn = element.find('button'); - })); + })); - afterEach(function() { - sandbox.restore(); - }); + afterEach(function() { + sandbox.restore(); + }); - it('chat directive should be available', function() { - expect(element.html()).to.include('class="chat"'); - }); + it('chat directive should be available', function() { + expect(element.html()).to.include('class="chat"'); + }); - it('intial state send button should be disabled', function() { - expect(sendBtn.is(':disabled')).to.be.true; - }); + it('intial state send button should be disabled', function() { + expect(sendBtn.is(':disabled')).to.be.true; + }); - it('should activate when an endpoint session is created', function() { - sandbox.spy(_$rootScope, '$broadcast'); - sandbox.spy(RtcommService, 'getChats'); - sandbox.spy(RtcommService, 'getEndpoint'); + it('should activate when an endpoint session is created', function() { + sandbox.spy(_$rootScope, '$broadcast'); + sandbox.spy(RtcommService, 'getChats'); + sandbox.spy(RtcommService, 'getEndpoint'); - RtcommService._MockCreateEndpoint('A'); - RtcommService._setActiveEndpoint('A'); + RtcommService._MockCreateEndpoint('A'); + RtcommService._setActiveEndpoint('A'); - _$rootScope.$broadcast('endpointActivated', 'A'); - _$rootScope.$digest(); - expect(_$rootScope.$broadcast.calledOnce).to.be.true; - expect(RtcommService.getChats.called).to.be.true; - expect(RtcommService.getEndpoint.called).to.be.true; - expect(sendBtn.is(':enabled')).to.be.true; - }); + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + expect(_$rootScope.$broadcast.calledOnce).to.be.true; + expect(RtcommService.getChats.called).to.be.true; + expect(RtcommService.getEndpoint.called).to.be.true; + expect(sendBtn.is(':enabled')).to.be.true; + }); - it('should display messages sent from the local user', function() { - var chatMsg = 'Hello World!'; - var userid = 'MockUser'; - RtcommService._MockCreateEndpoint('A', userid); - RtcommService._setActiveEndpoint('A'); + it('should display messages sent from the local user', function() { + var chatMsg = 'Hello World!'; + var userid = 'MockUser'; + RtcommService._MockCreateEndpoint('A', userid); + RtcommService._setActiveEndpoint('A'); - var testMessages = ['Hey!', 'How\'s it going?', 'Just found out this is an amazing framework']; + var testMessages = ['Hey!', 'How\'s it going?', 'Just found out this is an amazing framework']; - _$rootScope.$broadcast('endpointActivated', 'A'); - _$rootScope.$digest(); + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); - testMessages.forEach(function(testMessage) { + testMessages.forEach(function(testMessage) { - sendMessage(testMessage); + sendMessage(testMessage); - }); + }); - var messageElements = element.find('ul.chat > li'); + var messageElements = element.find('ul.chat > li'); - expect(messageElements.length).to.equal(testMessages.length); + expect(messageElements.length).to.equal(testMessages.length); - for (var i = 0; i < messageElements.length; i++) { - var messageElement = angular.element(messageElements[i]); + for (var i = 0; i < messageElements.length; i++) { + var messageElement = angular.element(messageElements[i]); - var chatMessage = messageDecomposer(messageElement); - expect(chatMessage.user).to.equal(userid); - expect(chatMessage.message).to.equal(testMessages[i]); - } + var chatMessage = messageDecomposer(messageElement); + expect(chatMessage.user).to.equal(userid); + expect(chatMessage.message).to.equal(testMessages[i]); + } - }); + }); - it('should display messages from a mock remote user', function() { + it('should display messages from a mock remote user', function() { - var userid = 'MockUser'; - RtcommService._MockCreateEndpoint('A', userid); - RtcommService._setActiveEndpoint('A'); + var userid = 'MockUser'; + RtcommService._MockCreateEndpoint('A', userid); + RtcommService._setActiveEndpoint('A'); - _$rootScope.$broadcast('endpointActivated', 'A'); - _$rootScope.$digest(); + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); - var eventObject = { - id: 'A', - message: { - message: 'Hello, this is me the second person', - from: 'MockUser2' - } + var eventObject = { + id: 'A', + message: { + message: 'Hello, this is me the second person', + from: 'MockUser2' } - RtcommService._emitChatMessage(eventObject); + } + RtcommService._emitChatMessage(eventObject); - _$rootScope.$digest(); - var messageElements = element.find('ul.chat > li'); + _$rootScope.$digest(); + var messageElements = element.find('ul.chat > li'); - var message = messageDecomposer(angular.element(messageElements[0])); - expect(message.message).to.equal(eventObject.message.message); - expect(message.user).to.equal(eventObject.message.from); + var message = messageDecomposer(angular.element(messageElements[0])); + expect(message.message).to.equal(eventObject.message.message); + expect(message.user).to.equal(eventObject.message.from); - }); + }); - it('should remove all messages when endpoint is removed or destroyed', function(){ - var chatMsg = 'Hello World!'; - var userid = 'MockUser'; - RtcommService._MockCreateEndpoint('A', userid); - RtcommService._setActiveEndpoint('A'); + it('should remove all messages when endpoint is removed or destroyed', function() { + var chatMsg = 'Hello World!'; + var userid = 'MockUser'; + RtcommService._MockCreateEndpoint('A', userid); + RtcommService._setActiveEndpoint('A'); - var testMessages = ['Hey!', 'How\'s it going?', 'Just found out this is an amazing framework']; + var testMessages = ['Hey!', 'How\'s it going?', 'Just found out this is an amazing framework']; - _$rootScope.$broadcast('endpointActivated', 'A'); - _$rootScope.$digest(); + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); - testMessages.forEach(function(testMessage) { + testMessages.forEach(function(testMessage) { - sendMessage(testMessage); + sendMessage(testMessage); - }); + }); - var messageElements = element.find('ul.chat > li'); + var messageElements = element.find('ul.chat > li'); - expect(messageElements.length).to.equal(testMessages.length); + expect(messageElements.length).to.equal(testMessages.length); - for (var i = 0; i < messageElements.length; i++) { - var messageElement = angular.element(messageElements[i]); + for (var i = 0; i < messageElements.length; i++) { + var messageElement = angular.element(messageElements[i]); - var chatMessage = messageDecomposer(messageElement); - expect(chatMessage.user).to.equal(userid); - expect(chatMessage.message).to.equal(testMessages[i]); - } + var chatMessage = messageDecomposer(messageElement); + expect(chatMessage.user).to.equal(userid); + expect(chatMessage.message).to.equal(testMessages[i]); + } - _$rootScope.$broadcast('noEndpointActivated'); - _$rootScope.$digest(); + _$rootScope.$broadcast('noEndpointActivated'); + _$rootScope.$digest(); - var messageElements = element.find('ul.chat > li'); + var messageElements = element.find('ul.chat > li'); - expect(messageElements.length).to.equal(0); + expect(messageElements.length).to.equal(0); - }); + }); - function createMockEndpoint(id, name) { - var endpoint = { - id: id, - chats: [], - localId: name, - getLocalEndpointID: function() { - return this.localId; - } - } - return endpoint; + function createMockEndpoint(id, name) { + var endpoint = { + id: id, + chats: [], + localId: name, + getLocalEndpointID: function() { + return this.localId; + } } + return endpoint; + } - function messageDecomposer(chatMessageElement) { - var user = chatMessageElement.find('strong').html(); - var time = chatMessageElement.find('small').html(); - var message = chatMessageElement.find('p').html(); + function messageDecomposer(chatMessageElement) { + var user = chatMessageElement.find('strong').html(); + var time = chatMessageElement.find('small').html(); + var message = chatMessageElement.find('p').html(); - var chatMessage = { - user: user, - time: time, - message: message + var chatMessage = { + user: user, + time: time, + message: message - } - return chatMessage; } + return chatMessage; + } - function sendMessage(message) { - chatInput.val(message); - chatInput.trigger('input'); - sendBtn.click(); - _$rootScope.$digest(); + function sendMessage(message) { + chatInput.val(message); + chatInput.trigger('input'); + sendBtn.click(); + _$rootScope.$digest(); - } + } }) diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js index 4ed1715..2a10345 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.js @@ -30,125 +30,125 @@ */ (function() { - 'use strict'; - - angular - .module('angular-rtcomm-ui') - .directive('rtcommEndpointStatus', rtcommEndpointStatus); - - /* @ngInject */ - function rtcommEndpointStatus() { - var directive = { - restrict: 'E', - templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', - controller: EndpointStatusController, - controllerAs: 'endpointStatusVM', - bindToController: true - }; - - return directive; - } - - EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; - - /* @ngInject */ - function EndpointStatusController(RtcommService, $scope, $log) { - var vm = this; + 'use strict'; + + angular + .module('angular-rtcomm-ui') + .directive('rtcommEndpointStatus', rtcommEndpointStatus); + + /* @ngInject */ + function rtcommEndpointStatus() { + var directive = { + restrict: 'E', + templateUrl: 'templates/rtcomm/rtcomm-endpoint-status.html', + controller: EndpointStatusController, + controllerAs: 'endpointStatusVM', + bindToController: true + }; + + return directive; + } + + EndpointStatusController.$inject = ['RtcommService', '$scope', '$log']; + + /* @ngInject */ + function EndpointStatusController(RtcommService, $scope, $log) { + var vm = this; + vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); + vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); + vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); + vm.failureReason = ''; + vm.queueCount = 0; //TODO FIX: Currently not implemented! + + $scope.$on('session:started', function(event, eventObject) { + $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID === eventObject.endpoint.id) { + vm.sessionState = 'session:started'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:stopped', function(event, eventObject) { + $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); + + $scope.$on('session:failed', function(event, eventObject) { + $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:failed'; + vm.failureReason = eventObject.reason; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:alerting', function(event, eventObject) { + $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID != eventObject.endpoint.id) { + vm.sessionState = 'session:alerting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:connecting', function(event, eventObject) { + $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); + // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ + vm.sessionState = 'session:connecting'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + // } + }); + + + $scope.$on('session:queued', function(event, eventObject) { + $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:queued'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:trying', function(event, eventObject) { + $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:trying'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('session:ringing', function(event, eventObject) { + $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); + if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { + vm.sessionState = 'session:ringing'; + vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); + } + }); + + $scope.$on('endpointActivated', function(event, endpointUUID) { + vm.epCtrlActiveEndpointUUID = endpointUUID; + vm.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); + vm.sessionState = RtcommService.getSessionState(endpointUUID); + }); + + $scope.$on('noEndpointActivated', function(event) { + vm.epCtrlRemoteEndpointID = null; + vm.sessionState = 'session:stopped'; + }); + + $scope.$on('rtcomm::init', function(event, success, details) { + if (success === true) { vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); vm.failureReason = ''; - vm.queueCount = 0; //TODO FIX: Currently not implemented! - - $scope.$on('session:started', function(event, eventObject) { - $log.debug('session:started received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID === eventObject.endpoint.id) { - vm.sessionState = 'session:started'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:stopped', function(event, eventObject) { - $log.debug('session:stopped received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:stopped'; - vm.epCtrlRemoteEndpointID = null; - } - }); - - $scope.$on('session:failed', function(event, eventObject) { - $log.debug('session:failed received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:failed'; - vm.failureReason = eventObject.reason; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:alerting', function(event, eventObject) { - $log.debug('session:alerting received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID != eventObject.endpoint.id) { - vm.sessionState = 'session:alerting'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:connecting', function(event, eventObject) { - $log.debug('session:connecting received: endpointID = ' + eventObject.endpoint.id); - // if ($scope.epCtrlActiveEndpointUUID != eventObject.endpoint.id){ - vm.sessionState = 'session:connecting'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - // } - }); - - - $scope.$on('session:queued', function(event, eventObject) { - $log.debug('session:queued received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:queued'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:trying', function(event, eventObject) { - $log.debug('session:trying received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:trying'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('session:ringing', function(event, eventObject) { - $log.debug('session:ringing received: endpointID = ' + eventObject.endpoint.id); - if (vm.epCtrlActiveEndpointUUID == eventObject.endpoint.id) { - vm.sessionState = 'session:ringing'; - vm.epCtrlRemoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - } - }); - - $scope.$on('endpointActivated', function(event, endpointUUID) { - vm.epCtrlActiveEndpointUUID = endpointUUID; - vm.epCtrlRemoteEndpointID = RtcommService.getEndpoint(endpointUUID).getRemoteEndpointID(); - vm.sessionState = RtcommService.getSessionState(endpointUUID); - }); - - $scope.$on('noEndpointActivated', function(event) { - vm.epCtrlRemoteEndpointID = null; - vm.sessionState = 'session:stopped'; - }); - - $scope.$on('rtcomm::init', function(event, success, details) { - if (success === true) { - vm.epCtrlActiveEndpointUUID = RtcommService.getActiveEndpoint(); - vm.epCtrlRemoteEndpointID = RtcommService.getRemoteEndpoint(vm.epCtrlActiveEndpointUUID); - vm.sessionState = RtcommService.getSessionState(vm.epCtrlActiveEndpointUUID); - vm.failureReason = ''; - } - if (success == false) { - vm.sessionState = 'session:stopped'; - vm.epCtrlRemoteEndpointID = null; - } - }); - } + } + if (success == false) { + vm.sessionState = 'session:stopped'; + vm.epCtrlRemoteEndpointID = null; + } + }); + } })(); diff --git a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js index 54dc84b..6c799fb 100644 --- a/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js +++ b/src/js/ui/endpoint/rtcomm-endpoint-status/rtcomm-endpoint-status.spec.js @@ -1,4 +1,3 @@ - /** *(C) Copyright IBM Corporation 2016. * @@ -16,160 +15,186 @@ */ describe('Unit Testing: RtcommEndpointStatus directive', function() { - var $compile, _$rootScope, sandbox, scope, element, endpointStatusElement; - - beforeEach(module("rtcomm.templates")); - - beforeEach(module('angular-rtcomm-ui')); - - beforeEach(function() { - RtcommService = { - sessions: [ - - ], - getActiveEndpoint: function(endpointUUID) { - return 'A'; - }, - getRemoteEndpoint: function(endpointUUID) { - return { - id: 'B', - localName: 'RemoteMockUser' - - } - }, - getSessionState: function(endpointUUID) { - return 'session:stopped'; - - }, - getEndpoint: function(endpointUUID) { - return { - id: 'A', - getRemoteEndpointID : function(){ - return 'RemoteMockUser' - } - } - } - } - - module(function($provide) { - $provide.value('RtcommService', RtcommService); - }); - }); + var $compile, _$rootScope, sandbox, scope, element, endpointStatusElement; - //Setup Test - beforeEach(inject(function($compile, $rootScope) { - _$rootScope = $rootScope; + beforeEach(module("rtcomm.templates")); + beforeEach(module('angular-rtcomm-ui')); - scope = $rootScope; - element = $compile('')(scope); - scope.$digest(); + beforeEach(function() { + RtcommService = { + sessions: [ - sandbox = sinon.sandbox.create(); - endpointStatusElement = element.find('span'); //Holds the state of the endpoint + ], + getActiveEndpoint: function(endpointUUID) { + return 'A'; + }, + getRemoteEndpoint: function(endpointUUID) { + return { + id: 'B', + localName: 'RemoteMockUser' - })); + } + }, + getSessionState: function(endpointUUID) { + return 'session:stopped'; + + }, + getEndpoint: function(endpointUUID) { + return { + id: 'A', + getRemoteEndpointID: function() { + return 'RemoteMockUser' + } + } + } + } - afterEach(function() { - sandbox.restore(); + module(function($provide) { + $provide.value('RtcommService', RtcommService); }); + }); - it('endpoint-status directive should be available', function() { - expect(element.html()).to.include('class="endpoint-status"'); - }); + //Setup Test + beforeEach(inject(function($compile, $rootScope) { + _$rootScope = $rootScope; - it('should display an initial state of the endpoint', function() { - expect(endpointStatusElement.html()).to.equal('No active sessions, waiting...'); - }); - it('should display a "session:started" event correct', function(){ - //Event object - generateEvent('session:started', {id: 'A', user: 'RemoteMockUser'}); - expect(getEndpointStatus()).to.equal('Connected to RemoteMockUser'); - }); + scope = $rootScope; + element = $compile('')(scope); + scope.$digest(); - it('should display a "session:stopped" event correctly', function(){ + sandbox = sinon.sandbox.create(); + endpointStatusElement = element.find('span'); //Holds the state of the endpoint - generateEvent('session:stopped', {id: 'A', user: 'RemoteMockUser'}); - expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + })); - }); + afterEach(function() { + sandbox.restore(); + }); - it('should display a "session:alerting", event correctly', function(){ - //Receive event from a new endpoint different from the current active endpoint - generateEvent('session:alerting', {id: 'B', user: 'RemoteMockUser2'}); - expect(getEndpointStatus()).to.equal('Inbound call from RemoteMockUser2'); - }); + it('endpoint-status directive should be available', function() { + expect(element.html()).to.include('class="endpoint-status"'); + }); - it('should display a "session:failed" event correctly', function(){ - generateEvent('session:failed', {id: 'A', reason: 'User dropped the call', user: 'RemoteMockUser'}); - expect(getEndpointStatus()).to.equal('Call failed with reason: User dropped the call'); - }) + it('should display an initial state of the endpoint', function() { + expect(endpointStatusElement.html()).to.equal('No active sessions, waiting...'); + }); - it('should display a "session:connecting" event correctly', function(){ - generateEvent('session:connecting', {id: 'B', user: 'RemoteMockUser2'}); - expect(getEndpointStatus()).to.equal('Connecting to RemoteMockUser2 ...'); + it('should display a "session:started" event correct', function() { + //Event object + generateEvent('session:started', { + id: 'A', + user: 'RemoteMockUser' }); + expect(getEndpointStatus()).to.equal('Connected to RemoteMockUser'); + }); - it('should display a "session:queued" event correctly', function(){ - generateEvent('session:queued', {id: 'A', user: 'RemoteMockUser'}); - expect(getEndpointStatus()).to.equal('Waiting in queue at: 0'); - - }); - it('should display a "session:trying" event correctly', function(){ - generateEvent('session:trying', {id: 'A', user: 'RemoteMockUser'}); - expect(getEndpointStatus()).to.equal('Attempting to call RemoteMockUser'); - }); + it('should display a "session:stopped" event correctly', function() { - it('should display a "session:ringing" event correctly', function(){ - generateEvent('session:ringing', {id: 'A', user: 'RemoteMockUser'}); - expect(getEndpointStatus()).to.equal('Call to RemoteMockUser is ringing'); + generateEvent('session:stopped', { + id: 'A', + user: 'RemoteMockUser' }); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); - it('should initialize endpoint on successful "rtcomm::init" event', function(){ - _$rootScope.$broadcast('rtcomm::init', true); - _$rootScope.$digest(); + }); - expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + it('should display a "session:alerting", event correctly', function() { + //Receive event from a new endpoint different from the current active endpoint + generateEvent('session:alerting', { + id: 'B', + user: 'RemoteMockUser2' }); - - it('should deinitialize endpoint on unsuccesful "rtcomm::init" event', function(){ - _$rootScope.$broadcast('rtcomm::init', false); - _$rootScope.$digest(); - expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + expect(getEndpointStatus()).to.equal('Inbound call from RemoteMockUser2'); + }); + + it('should display a "session:failed" event correctly', function() { + generateEvent('session:failed', { + id: 'A', + reason: 'User dropped the call', + user: 'RemoteMockUser' }); + expect(getEndpointStatus()).to.equal('Call failed with reason: User dropped the call'); + }) - it('should listen to an endpointActivated event', function(){ - _$rootScope.$broadcast('endpointActivated', 'A'); - _$rootScope.$digest(); - expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + it('should display a "session:connecting" event correctly', function() { + generateEvent('session:connecting', { + id: 'B', + user: 'RemoteMockUser2' }); + expect(getEndpointStatus()).to.equal('Connecting to RemoteMockUser2 ...'); + }); - it('should listen to an noEndpointActivated event', function(){ - _$rootScope.$broadcast('noEndpointActivated'); - _$rootScope.$digest(); - expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + it('should display a "session:queued" event correctly', function() { + generateEvent('session:queued', { + id: 'A', + user: 'RemoteMockUser' }); + expect(getEndpointStatus()).to.equal('Waiting in queue at: 0'); - function generateEvent(eventName, endpointDetails){ - var eventObject = createEventObject(endpointDetails); - _$rootScope.$broadcast(eventName, eventObject); - _$rootScope.$digest(); - } + }); + it('should display a "session:trying" event correctly', function() { + generateEvent('session:trying', { + id: 'A', + user: 'RemoteMockUser' + }); + expect(getEndpointStatus()).to.equal('Attempting to call RemoteMockUser'); + }); - function createEventObject(endpointDetails){ - return { - reason: endpointDetails.reason, - endpoint:{ - id: endpointDetails.id, - getRemoteEndpointID: function(){ - return endpointDetails.user; - }, - } + it('should display a "session:ringing" event correctly', function() { + generateEvent('session:ringing', { + id: 'A', + user: 'RemoteMockUser' + }); + expect(getEndpointStatus()).to.equal('Call to RemoteMockUser is ringing'); + }); + + it('should initialize endpoint on successful "rtcomm::init" event', function() { + _$rootScope.$broadcast('rtcomm::init', true); + _$rootScope.$digest(); + + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + it('should deinitialize endpoint on unsuccesful "rtcomm::init" event', function() { + _$rootScope.$broadcast('rtcomm::init', false); + _$rootScope.$digest(); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + it('should listen to an endpointActivated event', function() { + _$rootScope.$broadcast('endpointActivated', 'A'); + _$rootScope.$digest(); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + it('should listen to an noEndpointActivated event', function() { + _$rootScope.$broadcast('noEndpointActivated'); + _$rootScope.$digest(); + expect(getEndpointStatus()).to.equal('No active sessions, waiting...'); + }); + + function generateEvent(eventName, endpointDetails) { + var eventObject = createEventObject(endpointDetails); + _$rootScope.$broadcast(eventName, eventObject); + _$rootScope.$digest(); + } + + function createEventObject(endpointDetails) { + return { + reason: endpointDetails.reason, + endpoint: { + id: endpointDetails.id, + getRemoteEndpointID: function() { + return endpointDetails.user; + }, } } - function getEndpointStatus(){ - var endpointStatusElement = element.find('span'); - return endpointStatusElement.html(); - } + } + + function getEndpointStatus() { + var endpointStatusElement = element.find('span'); + return endpointStatusElement.html(); + } }) From b1bd54e6ea7e13a667f0fd927f27a0248c2cb0c1 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Wed, 23 Mar 2016 11:28:02 -0400 Subject: [PATCH 15/21] Added minor fixes to the rtcomm-service for equality, added the service for identityServlet purposes --- dist/angular-rtcomm.js | 727 +++++++++++++++--------------- dist/angular-rtcomm.min.js | 6 +- src/js/services/config.service.js | 2 +- src/js/services/rtcomm-service.js | 672 ++++++++++++--------------- 4 files changed, 644 insertions(+), 763 deletions(-) diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index b25b663..90b67e8 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-17 + * @version v1.0.3 - 2016-03-23 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -309,7 +309,7 @@ angular }; //Rtcomm Debug - var rtcommDebug = 'INFO'; + var rtcommDebug = 'DEBUG'; $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); $log.debug('providerConfig.server: ' + providerConfig.server); @@ -428,253 +428,272 @@ angular }]) .constant('rtcomm', rtcomm) .factory('RtcommService', RtcommService); - RtcommService.$inject = ['$rootScope', '$log', 'RtcommConfigService', 'rtcomm']; + RtcommService.$inject = ['$rootScope', '$log', 'RtcommConfigService', 'RtcommSessions', 'rtcomm', '$http']; - function RtcommService($rootScope, $log, RtcommConfigService, rtcomm) { + function RtcommService($rootScope, $log, RtcommConfigService, RtcommSessions, rtcomm, $http) { /** Setup the endpoint provider first **/ - /*var service = { + + var service = { + alert: alert, - setKarmaTesting: setKarmaTesting, + isInitialized: isInitialized, - setConfig: setConfig - /* Presence Methods */ - //}/ + setConfig: setConfig, + getPresenceMonitor: getPresenceMonitor, - var myEndpointProvider = new rtcomm.EndpointProvider(); - var endpointProviderInitialized = false; - var queueList = null; - var sessions = []; - var presenceRecord = null; - var karmaTesting = false; - var _selfView = 'selfView'; // Default self view - var _remoteView = 'remoteView'; // Default remote view + publishPresence: publishPresence, - myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); - $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); - $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); - myEndpointProvider.setAppContext(RtcommConfigService.getProviderConfig().appContext); + addToPresenceRecord: addToPresenceRecord, - var getPresenceRecord = function() { - if (presenceRecord == null) - presenceRecord = { - 'state': 'available', - userDefines: [] - }; + removeFromPresenceRecord: removeFromPresenceRecord, - return (presenceRecord); - }; + setPresenceRecordState: setPresenceRecordState, - // This defines all the media related configuration and is controlled through external config. - var getMediaConfig = function() { + getEndpoint: getEndpoint, - var mediaConfig = { - ringbacktone: RtcommConfigService.getRingBackTone(), - ringtone: RtcommConfigService.getRingTone(), - webrtcConfig: { - broadcast: { - audio: RtcommConfigService.getBroadcastAudio(), - video: RtcommConfigService.getBroadcastVideo() - } - }, - webrtc: RtcommConfigService.getWebRTCEnabled(), - chat: RtcommConfigService.getChatEnabled(), - }; + destroyEndpoint: destroyEndpoint, - return (mediaConfig); - }; + register: register, - myEndpointProvider.on('reset', function(event_object) { - // Should have a reason. - _alert({ - type: 'danger', - msg: event_object.reason - }); - }); + unregister: unregister, + joinQueue: joinQueue, - myEndpointProvider.on('queueupdate', function(queuelist) { - $log.debug('<<------rtcomm-service------>> - Event: queueupdate'); - $log.debug('queueupdate', queuelist); - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('queueupdate', queuelist); - } - ); - }); + leaveQueue: leaveQueue, - myEndpointProvider.on('newendpoint', function(endpoint) { - $log.debug('<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: ' + endpoint.getRemoteEndpointID()); - - endpoint.on('onetimemessage', function(event) { - $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { - var session = _createSession(event.endpoint.id); - session.iFrameURL = event.onetimemessage.iFrameURL; - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } - ); - } - }); + getQueues: getQueues, - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('newendpoint', endpoint); - } - ); - }); + sendChatMessage: sendChatMessage, - var callback = function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - if (eventObject.eventName.indexOf('session:') > -1) { - var session = _createSession(eventObject.endpoint.id); - session.sessionState = eventObject.eventName; - } - $rootScope.$broadcast(eventObject.eventName, eventObject); - } - ); + getChats: getChats, - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + isWebrtcConnected: isWebrtcConnected, + + getSessionState: getSessionState, + + setAlias: setAlias, + + setUserID: setUserID, + + setPresenceTopic: setPresenceTopic, + + getIframeURL: getIframeURL, + + putIframeURL: putIframeURL, + + placeCall: placeCall, + + getSessions: getSessions, + + endCall: endCall, + setActiveEndpoint: setActiveEndpoint, + + getActiveEndpoint: getActiveEndpoint, + + getRemoteEndpoint: getRemoteEndpoint, + + setDefaultViewSelector: setDefaultViewSelector, + + setViewSelector: setViewSelector, + + setVideoView: setVideoView }; - // Setup all the callbacks here because they are all static. - myEndpointProvider.setRtcommEndpointConfig({ - ringtone: RtcommConfigService.getRingTone(), - ringbacktone: RtcommConfigService.getRingBackTone(), - // These are all the session related events. - 'session:started': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - var session = _createSession(eventObject.endpoint.id); - _setActiveEndpoint(eventObject.endpoint.id); - session.sessionStarted = true; - session.remoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } - ); + var endpointProviderInitialized = false; + var queueList = null; + var presenceRecord = null; + var _selfView = 'selfView'; // Default self view + var _remoteView = 'remoteView'; // Default remote view + var myEndpointProvider = null; + activate(); + return service; + + function activate() { + myEndpointProvider = new rtcomm.EndpointProvider(); + + myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); + $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); + myEndpointProvider.setAppContext(RtcommConfigService.getProviderConfig().appContext); - }, - 'session:alerting': callback, - 'session:trying': callback, - 'session:ringing': callback, - 'session:queued': callback, + myEndpointProvider.on('reset', function(event_object) { + // Should have a reason. + alert({ + type: 'danger', + msg: event_object.reason + }); + }); + - 'session:failed': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + myEndpointProvider.on('queueupdate', function(queuelist) { + $log.debug('<<------rtcomm-service------>> - Event: queueupdate'); + $log.debug('queueupdate', queuelist); $rootScope.$evalAsync( function() { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); + $rootScope.$broadcast('queueupdate', queuelist); } ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + }); - }, + myEndpointProvider.on('newendpoint', function(endpoint) { + $log.debug('<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: ' + endpoint.getRemoteEndpointID()); - 'session:stopped': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( function() { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); + $rootScope.$broadcast('newendpoint', endpoint); } ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + }); - }, + function sessionEstablishmentCallback(eventObject) { + var id = eventObject.endpoint.id; - // These are all the WebRTC related events. - 'webrtc:connected': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + var session = RtcommSessions.getSession(id); + if (session === null) session = RtcommSessions.createSession(id); - $rootScope.$evalAsync( - function() { - _createSession(eventObject.endpoint.id).webrtcConnected = true; - $rootScope.$broadcast(eventObject.eventName, eventObject); + + session.state = eventObject.eventName; + broadcastRtcommEvent(eventObject); + }; + + + /** + * Setup all the callbacks here because they are all static. + */ + myEndpointProvider.setRtcommEndpointConfig({ + // These are all the session related events. + + 'onetimemessage': function(eventObject) { + $log.debug('<<------- rtcomm-service ----->> - Event: ' + eventObject); + + if (event.onetimemessage.type !== 'undefined' && event.onetimemessage.type === 'iFrameURL') { + var id = event.endpoint.id; + + var session = RtcommSessions.getSession(id); + if (session === null) { + session = RtcommSessions.createSession(id); + } + session.iFrameURL = event.onetimemessage.iFrameURL; + $rootScope.$evalAsync( + function() { + $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + } + ); } - ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, - // These are all the WebRTC related events. - 'webrtc:remotemuted': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast(eventObject.eventName, eventObject); + }, + 'session:started': function(eventObject) { + $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + var id = eventObject.endpoint.id; + var endoint = eventObject.endpoint; + var session = RtcommSessions.getSession(id); + + if (session === null) $log.error('Session:started but a previous session hasn\'t been created!'); + else { + _setActiveEndpoint(id); + session.started = true; + session.remoteEndpointID = endpoint.getRemoteEndpointID(); + broadcastRtcommEvent(eventObject); } - ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, + }, + 'session:alerting': sessionEstablishmentCallback, - 'webrtc:disconnected': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + 'session:trying': sessionEstablishmentCallback, - $rootScope.$evalAsync( - function() { - var session = _getSession(eventObject.endpoint.id); - if (session != null) - session.webrtcConnected = false; - $rootScope.$broadcast(eventObject.eventName, eventObject); + 'session:ringing': sessionEstablishmentCallback, + + 'session:queued': sessionEstablishmentCallback, + + 'session:failed': function(eventObject) { + + RtcommSessions.removeSession(eventObject.endpoint.id); + broadcastRtcommEvent(eventObject); + }, + + /** + * Handle when the endpoint stops the session + */ + 'session:stopped': function(eventObject) { + //Remove the session + RtcommSessions.removeSession(eventObject.endpoint.id); + + broadcastRtcommEvent(eventObject); + }, + + // These are all the WebRTC related events. + 'webrtc:connected': function(eventObject) { + + var session = RtcommSessions.getSession(eventObject.endpoint.id); + if (session !== null) { + session.webrtcConnected = true; + broadcastRtcommEvent(eventObject); } - ); + }, + 'webrtc:remotemuted': function(eventObject) { + broadcastRtcommEvent(eventObject); + }, + + 'webrtc:disconnected': function(eventObject) { - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, + var session = RtcommSessions.getSession(eventObject.endpoint.id); + if (session !== null) + session.webrtcConnected = false; + broadcastRtcommEvent(eventObject); + }, - // These are all the chat related events. - 'chat:connected': callback, - 'chat:disconnected': callback, + // These are all the chat related events. + 'chat:connected': broadcastRtcommEvent, + 'chat:disconnected': broadcastRtcommEvent, - 'chat:message': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - var chat = { - time: new Date(), - name: eventObject.message.from, - message: angular.copy(eventObject.message.message) - }; - - _createSession(eventObject.endpoint.id).chats.push(chat); - $rootScope.$broadcast(eventObject.eventName, eventObject); + 'chat:message': function(eventObject) { + + //Create a message object + + var chat = { + time: new Date(), + name: eventObject.message.from, + message: angular.copy(eventObject.message.message) + }; + + var session = RtcommSessions.getSession(eventObject.endpoint.id); + + if(session !== null) { + session.chats.push(chat); + broadcastRtcommEvent(eventObject); } - ); + }, - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, + // Endpoint destroyed + 'destroyed': broadcastRtcommEvent + }); + } - // Endpoint destroyed - 'destroyed': callback - }); + function broadcastRtcommEvent(eventObject) { + + $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + $rootScope.$evalAsync( + function() { + $rootScope.$broadcast(eventObject.eventName, eventObject); + } + ); + } + + function getPresenceRecord() { + if (presenceRecord == null) + presenceRecord = { + 'state': 'available', + userDefines: [] + }; + + return (presenceRecord); + }; - var initSuccess = function(event) { + function initSuccess(event) { $log.debug('<<------rtcomm-service------>> - Event: Provider init succeeded'); if (presenceRecord != null) { @@ -694,148 +713,58 @@ angular $rootScope.$broadcast('rtcomm::init', true, broadcastEvent); } ); - - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); }; - var initFailure = function(error) { + function initFailure(error) { $log.debug('<<------rtcomm-service------>> - Event: Provider init failed: error: ', error); $rootScope.$evalAsync( function() { $rootScope.$broadcast('rtcomm::init', false, error); } ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }; - - /* - * Get session from local endpoint ID - */ - var _getSession = function(endpointUUID) { - - var session = null; - - for (var index = 0; index < sessions.length; index++) { - if (sessions[index].endpointUUID === endpointUUID) { - session = sessions[index]; - break; - } - } - - return (session); - }; - - /* - * Get session from local endpoint ID - */ - var _createSession = function(endpointUUID) { - - var session = null; - - for (var index = 0; index < sessions.length; index++) { - if (sessions[index].endpointUUID === endpointUUID) { - session = sessions[index]; - break; - } - } - - if (session == null) { - session = { - endpointUUID: endpointUUID, - chats: [], - webrtcConnected: false, - sessionStarted: false, - iFrameURL: 'about:blank', - remoteEndpointID: null, - activated: true, - sessionState: 'session:stopped' - }; - sessions[sessions.length] = session; - } - - return (session); - }; - - var _removeSession = function(endpointUUID) { - - for (var index = 0; index < sessions.length; index++) { - if (sessions[index].endpointUUID === endpointUUID) { - - _getEndpoint(endpointUUID).destroy(); - - // Remove the disconnected endpoint from the list. - sessions.splice(index, 1); - - // Now we need to set the active endpoint to someone else or to no endpoint if none are left. - if (sessions.length == 0) { - $rootScope.$broadcast('noEndpointActivated'); - } else { - _setActiveEndpoint(sessions[0].endpointUUID); - } - break; - } - } }; - - var _getEndpoint = function(uuid) { + function _getEndpoint(uuid) { var endpoint = null; - if ((typeof uuid === 'undefined') || uuid == null) { - $log.debug('getEndpoint: create new endpoint and setup onetimemessage event'); - endpoint = myEndpointProvider.createRtcommEndpoint(); - endpoint.on('onetimemessage', function(event) { - $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { - var session = _createSession(event.endpoint.id); - - session.iFrameURL = event.onetimemessage.iFrameURL; - - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } - ); - } - }); - } else - endpoint = myEndpointProvider.getRtcommEndpoint(uuid); + endpoint = myEndpointProvider.getRtcommEndpoint(uuid); return (endpoint); }; - var _setActiveEndpoint = function(endpointID) { + function _setActiveEndpoint(endpointID) { + + //base case // First get the old active endpoint var activeEndpoint = _getActiveEndpointUUID(); - if ((activeEndpoint != null) && (activeEndpoint != endpointID)) { - var session = _getSession(activeEndpoint); - if (session != null) + if ((activeEndpoint !== null) && (activeEndpoint !== endpointID)) { + var session = RtcommSessions.getSession(activeEndpoint); + if (typeof session !== 'undefined') session.activated = false; - } + } else { - var session = _createSession(endpointID); - session.activated = true; + var session = RtcommSessions.createSession(endpointID); + session.activated = true; + } $rootScope.$broadcast('endpointActivated', endpointID); }; - var _getActiveEndpointUUID = function() { + function _getActiveEndpointUUID() { var activeEndpoint = null; + var sessions = RtcommSessions.getAllSessions(); for (var index = 0; index < sessions.length; index++) { - if (sessions[index].activated == true) { + if (sessions[index].activated === true) { activeEndpoint = sessions[index].endpointUUID; break; } } return (activeEndpoint); }; - var _alert = function _alert(alertObject) { + + function alert(alertObject) { var a = { type: 'info', msg: 'default message' @@ -872,13 +801,28 @@ angular RtcommConfigService.setProviderConfig(config); myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); - if (endpointProviderInitialized == false) { - // If the user does not specify a userid, that says one will never be specified so go ahead - // and initialize the endpoint provider and let the provider assign a name. If a defined empty - // string is passed in, that means to wait until the end user registers a name. - if (typeof config.userid == 'undefined' || RtcommConfigService.getProviderConfig().userid != '') { - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; + if (endpointProviderInitialized === false) { + + if (typeof config.identityServlet !== "undefined" && config.identityServlet != null) { + $http.get(config.identityServlet).success(function(data) { + + if (typeof data.userid !== "undefined") { + RtcommConfigService.setProviderConfig(data); + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; + } else + $log.error('RtcommService: setConfig promise: Invalid JSON object return from identityServlet: ', data); + }).error(function(data, status, headers, config) { + $log.debug('RtcommService: setConfig promise: error accessing userid from identityServlet: ' + status); + }); + } else { + // If the user does not specify a userid, that says one will never be specified so go ahead + // and initialize the endpoint provider and let the provider assign a name. If a defined empty + // string is passed in, that means to wait until the end user registers a name. + if (typeof config.userid === 'undefined' || RtcommConfigService.getProviderConfig().userid !== '') { + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; + } } } } @@ -900,7 +844,7 @@ angular getPresenceRecord().userDefines.push(userDefines[index]); } - if (endpointProviderInitialized == true) { + if (endpointProviderInitialized === true) { $log.debug('RtcommService: addToPresenceRecord: updating presence record to: ', getPresenceRecord()); myEndpointProvider.publishPresence(getPresenceRecord()); } @@ -911,14 +855,14 @@ angular for (var i = 0; i < userDefines.length; i++) { for (var j = 0; j < getPresenceRecord().userDefines.length; j++) { - if (getPresenceRecord().userDefines[j].name == userDefines[i].name) { + if (getPresenceRecord().userDefines[j].name === userDefines[i].name) { getPresenceRecord().userDefines.splice(j, 1); break; } } } - if ((endpointProviderInitialized == true) && doPublish) { + if ((endpointProviderInitialized === true) && doPublish) { $log.debug('RtcommService: removeFromPresenceRecord: updating presence record to: ', getPresenceRecord()); myEndpointProvider.publishPresence(getPresenceRecord()); } @@ -940,7 +884,7 @@ angular function register(userid) { - if (endpointProviderInitialized == false) { + if (endpointProviderInitialized === false) { RtcommConfigService.getProviderConfig().userid = userid; myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); @@ -980,8 +924,13 @@ angular */ function sendChatMessage(chat, endpointUUID) { + var session; // Save this chat in the local session store - var session = _createSession(endpointUUID); + if (sessionExists(endpointUUID)) { + session = RtcommSessions.getSession(endpointUUID); + } else { + session = RtcommSessions.createSession(endpointUUID); + } session.chats.push(chat); myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); @@ -991,8 +940,8 @@ angular function getChats(endpointUUID) { if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { - var session = _getSession(endpointUUID); - if (session != null) + var session = RtcommSessions.getSession(endpointUUID); + if (typeof session !== 'undefined') return (session.chats); else return (null); @@ -1004,7 +953,7 @@ angular function isWebrtcConnected(endpointUUID) { if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { - var session = _getSession(endpointUUID); + var session = RtcommSessions.getSession(endpointUUID); if (session != null) return (session.webrtcConnected); else @@ -1023,13 +972,13 @@ angular function setAlias(aliasID) { - if ((typeof aliasID !== 'undefined') && aliasID != '') + if ((typeof aliasID !== 'undefined') && aliasID !== '') myEndpointProvider.setUserID(aliasID); } function setUserID(userID) { - if ((typeof userID !== 'undefined') && userID != '') { + if ((typeof userID !== 'undefined') && userID !== '') { RtcommConfigService.setProviderConfig({ userid: userID }); @@ -1039,7 +988,7 @@ angular function setPresenceTopic(presenceTopic) { - if ((typeof presenceTopic !== 'undefined') && presenceTopic != '') { + if ((typeof presenceTopic !== 'undefined') && presenceTopic !== '') { RtcommConfigService.setProviderConfig({ presenceTopic: presenceTopic }); @@ -1051,7 +1000,7 @@ angular function getIframeURL(endpointUUID) { if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { - var session = _getSession(endpointUUID); + var session = RtcommSessions.getSession(endpointUUID); if (session != null) return (session.iFrameURL); else @@ -1067,7 +1016,8 @@ angular var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); if (endpoint != null) { - var session = _createSession(endpointUUID); + + var session = RtcommSessions.createSession(endpointUUID); session.iFrameURL = newUrl; var message = { @@ -1082,6 +1032,7 @@ angular function placeCall(calleeID, mediaToEnable) { + //Create new endpoint var endpoint = _getEndpoint(); if (mediaToEnable.indexOf('chat') > -1) @@ -1098,13 +1049,12 @@ angular }); } _setActiveEndpoint(endpoint.id); - endpoint.connect(calleeID); return (endpoint.id); } function getSessions() { - return sessions; + return RtcommSessions.getAllSessions(); } function endCall(endpoint) { @@ -1125,7 +1075,7 @@ angular var remoteEndpointID = null; if (localEndpointID != null) { - var session = _getSession(localEndpointID); + var session = RtcommSessions.getSession(localEndpointID); if (session != null) { remoteEndpointID = session.remoteEndpointID; @@ -1151,7 +1101,7 @@ angular $log.debug('rtcommVideo: setting local media'); var endpoint = null; - if (typeof endpointUUID != 'undefined' && endpointUUID != null) + if (typeof endpointUUID !== 'undefined' && endpointUUID !== null) endpoint = _getEndpoint(endpointUUID); else if (_getActiveEndpointUUID() != null) endpoint = _getEndpoint(_getActiveEndpointUUID()); @@ -1164,75 +1114,124 @@ angular }); } } - return { - - alert: _alert, + } +})(); - isInitialized: isInitialized, +(function() { + 'use strict'; - setConfig: setConfig, + angular + .module('angular-rtcomm-service') + .factory('RtcommSessions', RtcommSessions); - getPresenceMonitor: getPresenceMonitor, + /* @ngInject */ + function RtcommSessions($log) { + var service = { + getAllSessions: getAllSessions, + createSession: createSession, + getSession: getSession, + updateSession: updateSession, +removeSession: removeSession - publishPresence: publishPresence, + }; - addToPresenceRecord: addToPresenceRecord, + var sessions = []; + return service; - removeFromPresenceRecord: removeFromPresenceRecord, + //////////////// - setPresenceRecordState: setPresenceRecordState, + function getAllSessions() { + return sessions; + } - getEndpoint: getEndpoint, + function removeAllSessions() { - destroyEndpoint: destroyEndpoint, + sessions.forEach(function(session) { + removeSession(session.endpointUUID); + }); + } - register: register, + function getSession(endpointUUID) { + $log.debug('Retrieving session linked to EndpointUUID: ' + endpointUUID); - unregister: unregister, + var session = null; + sessions.forEach(function(_session) { + if (_session.endpointUUID === endpointUUID) { + session = _session; + } + }); - joinQueue: joinQueue, + return session; + } - leaveQueue: leaveQueue, + function createSession(endpointUUID) { + $log.debug('Creating a session for EndpointUUID: ' + endpointUUID); - getQueues: getQueues, + var session; - sendChatMessage: sendChatMessage, + /* Define a session */ + session = { - getChats: getChats, + endpointUUID: endpointUUID, + remoteEndpointID: null, + chats: [], + webrtcConnected: false, + started: false, + state: 'session:stopped', + activated: true, + iFrameURL: 'about:blank', + }; + sessions.push(session); + return session; - isWebrtcConnected: isWebrtcConnected, + } - getSessionState: getSessionState, + function updateSession(endpointUUID, config) { - setAlias: setAlias, + $log.debug('Updating session for EndpointUUID: ' + endpointUUID); - setUserID: setUserID, + var session = getSession(endpointUUID); - setPresenceTopic: setPresenceTopic, + if (typeof session === 'undefined') + $log.debug('Unable to update endpoint due to it not existing'); + else { - getIframeURL: getIframeURL, + for (var property in session) { + if (session.hasOwnProperty(property)) { - putIframeURL: putIframeURL, + session[property] = typeof config[property] !== 'undefined' ? config[property] : session[property]; + } + } + } - placeCall: placeCall, + return session; - getSessions: getSessions, + } - endCall: endCall, + function removeSession(endpointUUID) { + $log.debug('Destroy session for EndpointUUID: ' + endpointUUID); + var session; + for (var i = 0; i < sessions.length; i++) { + session = sessions[i]; - setActiveEndpoint: setActiveEndpoint, + if (session.endpointUUID === endpointUUID) { + sessions.splice(i, 1); + $log.debug('Session with endpointUUID === ' + endpointUUID + 'has been removed'); + break; + } + } - getActiveEndpoint: getActiveEndpoint, + if (typeof session === 'undefined') { + $log.debug('Unable to destroy session due to it not existing'); + } - getRemoteEndpoint: getRemoteEndpoint, + return session; - setDefaultViewSelector: setDefaultViewSelector, + } - setViewSelector: setViewSelector, - setVideoView: setVideoView - }; } + RtcommSessions.$inject = ["$log"]; })(); /** diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index fff0cc5..d8bd353 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-17 + * @version v1.0.3 - 2016-03-23 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return $(c.id),c.connect(a),c.id}function C(){return N}function D(a){a.disconnect()}function E(a){$(a)}function F(){return _()}function G(a){var b=null;if(null!=a){var c=W(a);null!=c&&(b=c.remoteEndpointID)}return b}function H(){Q="selfView",R="remoteView"}function I(a,b){Q=a,R=b}function J(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!=a?c=Z(a):null!=_()&&(c=Z(_())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Q),mediaIn:document.querySelector("#"+R)}))}var K=new d.EndpointProvider,L=!1,M=null,N=[],O=null,P=!1,Q="selfView",R="remoteView";K.setLogLevel(c.getRtcommDebug()),b.debug("rtcomm-service - endpointProvider log level is: "+K.getLogLevel()),b.debug("rtcomm-service - endpointProvider log level should be: "+c.getRtcommDebug()),K.setAppContext(c.getProviderConfig().appContext);var S=function(){return null==O&&(O={state:"available",userDefines:[]}),O};K.on("reset",function(a){aa({type:"danger",msg:a.reason})}),K.on("queueupdate",function(c){b.debug("<<------rtcomm-service------>> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),K.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),c.on("onetimemessage",function(c){if(b.debug("<<------rtcomm-onetimemessage------>> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=X(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}}),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})});var T=function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){if(c.eventName.indexOf("session:")>-1){var b=X(c.endpoint.id);b.sessionState=c.eventName}a.$broadcast(c.eventName,c)}),1==P&&a.$digest()};K.setRtcommEndpointConfig({ringtone:c.getRingTone(),ringbacktone:c.getRingBackTone(),"session:started":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=X(c.endpoint.id);$(c.endpoint.id),b.sessionStarted=!0,b.remoteEndpointID=c.endpoint.getRemoteEndpointID(),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"session:alerting":T,"session:trying":T,"session:ringing":T,"session:queued":T,"session:failed":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){Y(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"session:stopped":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){Y(c.endpoint.id),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"webrtc:connected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){X(c.endpoint.id).webrtcConnected=!0,a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"webrtc:remotemuted":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"webrtc:disconnected":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b=W(c.endpoint.id);null!=b&&(b.webrtcConnected=!1),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},"chat:connected":T,"chat:disconnected":T,"chat:message":function(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){var b={time:new Date,name:c.message.from,message:angular.copy(c.message.message)};X(c.endpoint.id).chats.push(b),a.$broadcast(c.eventName,c)}),1==P&&a.$digest()},destroyed:T});var U=function(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=O&&(b.debug("RtcommService: initSuccess: updating presence record"),K.publishPresence(O)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)}),1==P&&a.$digest()},V=function(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)}),1==P&&a.$digest()},W=function(a){for(var b=null,c=0;c> - Event: ",c),"undefined"!=c.onetimemessage.type&&"iFrameURL"==c.onetimemessage.type){var d=X(c.endpoint.id);d.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}})):d=K.getRtcommEndpoint(c),d},$=function(b){var c=_();if(null!=c&&c!=b){var d=W(c);null!=d&&(d.activated=!1)}var d=X(b);d.activated=!0,a.$broadcast("endpointActivated",b)},_=function(){for(var a=null,b=0;b0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'), -a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'),a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==event.onetimemessage.type&&"iFrameURL"===event.onetimemessage.type){var e=event.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=event.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",event.endpoint.id,event.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=(a.endpoint,d.getSession(c));null===e?b.error("Session:started but a previous session hasn't been created!"):(m(c),e.started=!0,e.remoteEndpointID=endpoint.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var b=null;return b=_.getRtcommEndpoint(a)}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);"undefined"!=typeof e&&(e.activated=!1)}else{var e=d.createSession(b);e.activated=!0}a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/services/config.service.js b/src/js/services/config.service.js index 6bc6560..bf12a65 100644 --- a/src/js/services/config.service.js +++ b/src/js/services/config.service.js @@ -64,7 +64,7 @@ }; //Rtcomm Debug - var rtcommDebug = 'INFO'; + var rtcommDebug = 'DEBUG'; $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); $log.debug('providerConfig.server: ' + providerConfig.server); diff --git a/src/js/services/rtcomm-service.js b/src/js/services/rtcomm-service.js index d0c1531..1aadd0a 100644 --- a/src/js/services/rtcomm-service.js +++ b/src/js/services/rtcomm-service.js @@ -29,253 +29,272 @@ }) .constant('rtcomm', rtcomm) .factory('RtcommService', RtcommService); - RtcommService.$inject = ['$rootScope', '$log', 'RtcommConfigService', 'rtcomm']; + RtcommService.$inject = ['$rootScope', '$log', 'RtcommConfigService', 'RtcommSessions', 'rtcomm', '$http']; - function RtcommService($rootScope, $log, RtcommConfigService, rtcomm) { + function RtcommService($rootScope, $log, RtcommConfigService, RtcommSessions, rtcomm, $http) { /** Setup the endpoint provider first **/ - /*var service = { + + var service = { + alert: alert, - setKarmaTesting: setKarmaTesting, + isInitialized: isInitialized, - setConfig: setConfig - /* Presence Methods */ - //}/ + setConfig: setConfig, + getPresenceMonitor: getPresenceMonitor, - var myEndpointProvider = new rtcomm.EndpointProvider(); - var endpointProviderInitialized = false; - var queueList = null; - var sessions = []; - var presenceRecord = null; - var karmaTesting = false; - var _selfView = 'selfView'; // Default self view - var _remoteView = 'remoteView'; // Default remote view + publishPresence: publishPresence, - myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); - $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); - $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); - myEndpointProvider.setAppContext(RtcommConfigService.getProviderConfig().appContext); + addToPresenceRecord: addToPresenceRecord, - var getPresenceRecord = function() { - if (presenceRecord == null) - presenceRecord = { - 'state': 'available', - userDefines: [] - }; + removeFromPresenceRecord: removeFromPresenceRecord, - return (presenceRecord); - }; + setPresenceRecordState: setPresenceRecordState, - // This defines all the media related configuration and is controlled through external config. - var getMediaConfig = function() { + getEndpoint: getEndpoint, - var mediaConfig = { - ringbacktone: RtcommConfigService.getRingBackTone(), - ringtone: RtcommConfigService.getRingTone(), - webrtcConfig: { - broadcast: { - audio: RtcommConfigService.getBroadcastAudio(), - video: RtcommConfigService.getBroadcastVideo() - } - }, - webrtc: RtcommConfigService.getWebRTCEnabled(), - chat: RtcommConfigService.getChatEnabled(), - }; + destroyEndpoint: destroyEndpoint, - return (mediaConfig); - }; + register: register, - myEndpointProvider.on('reset', function(event_object) { - // Should have a reason. - _alert({ - type: 'danger', - msg: event_object.reason - }); - }); + unregister: unregister, + joinQueue: joinQueue, - myEndpointProvider.on('queueupdate', function(queuelist) { - $log.debug('<<------rtcomm-service------>> - Event: queueupdate'); - $log.debug('queueupdate', queuelist); - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('queueupdate', queuelist); - } - ); - }); - - myEndpointProvider.on('newendpoint', function(endpoint) { - $log.debug('<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: ' + endpoint.getRemoteEndpointID()); - - endpoint.on('onetimemessage', function(event) { - $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { - var session = _createSession(event.endpoint.id); - session.iFrameURL = event.onetimemessage.iFrameURL; - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } - ); - } - }); + leaveQueue: leaveQueue, - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('newendpoint', endpoint); - } - ); - }); + getQueues: getQueues, - var callback = function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - if (eventObject.eventName.indexOf('session:') > -1) { - var session = _createSession(eventObject.endpoint.id); - session.sessionState = eventObject.eventName; - } - $rootScope.$broadcast(eventObject.eventName, eventObject); - } - ); + sendChatMessage: sendChatMessage, + + getChats: getChats, + + isWebrtcConnected: isWebrtcConnected, + + getSessionState: getSessionState, + + setAlias: setAlias, + + setUserID: setUserID, + + setPresenceTopic: setPresenceTopic, + + getIframeURL: getIframeURL, + + putIframeURL: putIframeURL, + + placeCall: placeCall, + + getSessions: getSessions, + + endCall: endCall, + + setActiveEndpoint: setActiveEndpoint, + + getActiveEndpoint: getActiveEndpoint, - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + getRemoteEndpoint: getRemoteEndpoint, + + setDefaultViewSelector: setDefaultViewSelector, + + setViewSelector: setViewSelector, + setVideoView: setVideoView }; - // Setup all the callbacks here because they are all static. - myEndpointProvider.setRtcommEndpointConfig({ - ringtone: RtcommConfigService.getRingTone(), - ringbacktone: RtcommConfigService.getRingBackTone(), - // These are all the session related events. - 'session:started': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - var session = _createSession(eventObject.endpoint.id); - _setActiveEndpoint(eventObject.endpoint.id); - session.sessionStarted = true; - session.remoteEndpointID = eventObject.endpoint.getRemoteEndpointID(); - $rootScope.$broadcast(eventObject.eventName, eventObject); - } - ); + var endpointProviderInitialized = false; + var queueList = null; + var presenceRecord = null; + var _selfView = 'selfView'; // Default self view + var _remoteView = 'remoteView'; // Default remote view + var myEndpointProvider = null; + activate(); + return service; + + function activate() { + myEndpointProvider = new rtcomm.EndpointProvider(); + + myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); + $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); + myEndpointProvider.setAppContext(RtcommConfigService.getProviderConfig().appContext); - }, - 'session:alerting': callback, - 'session:trying': callback, - 'session:ringing': callback, - 'session:queued': callback, + myEndpointProvider.on('reset', function(event_object) { + // Should have a reason. + alert({ + type: 'danger', + msg: event_object.reason + }); + }); - 'session:failed': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + + myEndpointProvider.on('queueupdate', function(queuelist) { + $log.debug('<<------rtcomm-service------>> - Event: queueupdate'); + $log.debug('queueupdate', queuelist); $rootScope.$evalAsync( function() { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); + $rootScope.$broadcast('queueupdate', queuelist); } ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + }); - }, + myEndpointProvider.on('newendpoint', function(endpoint) { + $log.debug('<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: ' + endpoint.getRemoteEndpointID()); - 'session:stopped': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); $rootScope.$evalAsync( function() { - _removeSession(eventObject.endpoint.id); - $rootScope.$broadcast(eventObject.eventName, eventObject); + $rootScope.$broadcast('newendpoint', endpoint); } ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); + }); - }, + function sessionEstablishmentCallback(eventObject) { + var id = eventObject.endpoint.id; - // These are all the WebRTC related events. - 'webrtc:connected': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + var session = RtcommSessions.getSession(id); + if (session === null) session = RtcommSessions.createSession(id); - $rootScope.$evalAsync( - function() { - _createSession(eventObject.endpoint.id).webrtcConnected = true; - $rootScope.$broadcast(eventObject.eventName, eventObject); + + session.state = eventObject.eventName; + broadcastRtcommEvent(eventObject); + }; + + + /** + * Setup all the callbacks here because they are all static. + */ + myEndpointProvider.setRtcommEndpointConfig({ + // These are all the session related events. + + 'onetimemessage': function(eventObject) { + $log.debug('<<------- rtcomm-service ----->> - Event: ' + eventObject); + + if (event.onetimemessage.type !== 'undefined' && event.onetimemessage.type === 'iFrameURL') { + var id = event.endpoint.id; + + var session = RtcommSessions.getSession(id); + if (session === null) { + session = RtcommSessions.createSession(id); + } + session.iFrameURL = event.onetimemessage.iFrameURL; + $rootScope.$evalAsync( + function() { + $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + } + ); } - ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, - // These are all the WebRTC related events. - 'webrtc:remotemuted': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast(eventObject.eventName, eventObject); + }, + 'session:started': function(eventObject) { + $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + var id = eventObject.endpoint.id; + var endoint = eventObject.endpoint; + var session = RtcommSessions.getSession(id); + + if (session === null) $log.error('Session:started but a previous session hasn\'t been created!'); + else { + _setActiveEndpoint(id); + session.started = true; + session.remoteEndpointID = endpoint.getRemoteEndpointID(); + broadcastRtcommEvent(eventObject); } - ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, + }, + 'session:alerting': sessionEstablishmentCallback, - 'webrtc:disconnected': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + 'session:trying': sessionEstablishmentCallback, - $rootScope.$evalAsync( - function() { - var session = _getSession(eventObject.endpoint.id); - if (session != null) - session.webrtcConnected = false; - $rootScope.$broadcast(eventObject.eventName, eventObject); + 'session:ringing': sessionEstablishmentCallback, + + 'session:queued': sessionEstablishmentCallback, + + 'session:failed': function(eventObject) { + + RtcommSessions.removeSession(eventObject.endpoint.id); + broadcastRtcommEvent(eventObject); + }, + + /** + * Handle when the endpoint stops the session + */ + 'session:stopped': function(eventObject) { + //Remove the session + RtcommSessions.removeSession(eventObject.endpoint.id); + + broadcastRtcommEvent(eventObject); + }, + + // These are all the WebRTC related events. + 'webrtc:connected': function(eventObject) { + + var session = RtcommSessions.getSession(eventObject.endpoint.id); + if (session !== null) { + session.webrtcConnected = true; + broadcastRtcommEvent(eventObject); } - ); + }, + 'webrtc:remotemuted': function(eventObject) { + broadcastRtcommEvent(eventObject); + }, + + 'webrtc:disconnected': function(eventObject) { - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, + var session = RtcommSessions.getSession(eventObject.endpoint.id); + if (session !== null) + session.webrtcConnected = false; + broadcastRtcommEvent(eventObject); + }, - // These are all the chat related events. - 'chat:connected': callback, - 'chat:disconnected': callback, + // These are all the chat related events. + 'chat:connected': broadcastRtcommEvent, + 'chat:disconnected': broadcastRtcommEvent, - 'chat:message': function(eventObject) { - $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); - $rootScope.$evalAsync( - function() { - var chat = { - time: new Date(), - name: eventObject.message.from, - message: angular.copy(eventObject.message.message) - }; - - _createSession(eventObject.endpoint.id).chats.push(chat); - $rootScope.$broadcast(eventObject.eventName, eventObject); + 'chat:message': function(eventObject) { + + //Create a message object + + var chat = { + time: new Date(), + name: eventObject.message.from, + message: angular.copy(eventObject.message.message) + }; + + var session = RtcommSessions.getSession(eventObject.endpoint.id); + + if(session !== null) { + session.chats.push(chat); + broadcastRtcommEvent(eventObject); } - ); + }, - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }, + // Endpoint destroyed + 'destroyed': broadcastRtcommEvent + }); + } - // Endpoint destroyed - 'destroyed': callback - }); + function broadcastRtcommEvent(eventObject) { - var initSuccess = function(event) { + $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); + $rootScope.$evalAsync( + function() { + $rootScope.$broadcast(eventObject.eventName, eventObject); + } + ); + } + + function getPresenceRecord() { + if (presenceRecord == null) + presenceRecord = { + 'state': 'available', + userDefines: [] + }; + + return (presenceRecord); + }; + + function initSuccess(event) { $log.debug('<<------rtcomm-service------>> - Event: Provider init succeeded'); if (presenceRecord != null) { @@ -295,148 +314,58 @@ $rootScope.$broadcast('rtcomm::init', true, broadcastEvent); } ); - - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); }; - var initFailure = function(error) { + function initFailure(error) { $log.debug('<<------rtcomm-service------>> - Event: Provider init failed: error: ', error); $rootScope.$evalAsync( function() { $rootScope.$broadcast('rtcomm::init', false, error); } ); - // This is required in karma to get the evalAsync to fire. Ugly but necessary... - if (karmaTesting == true) - $rootScope.$digest(); - }; - - /* - * Get session from local endpoint ID - */ - var _getSession = function(endpointUUID) { - - var session = null; - - for (var index = 0; index < sessions.length; index++) { - if (sessions[index].endpointUUID === endpointUUID) { - session = sessions[index]; - break; - } - } - - return (session); }; - /* - * Get session from local endpoint ID - */ - var _createSession = function(endpointUUID) { - - var session = null; - - for (var index = 0; index < sessions.length; index++) { - if (sessions[index].endpointUUID === endpointUUID) { - session = sessions[index]; - break; - } - } - - if (session == null) { - session = { - endpointUUID: endpointUUID, - chats: [], - webrtcConnected: false, - sessionStarted: false, - iFrameURL: 'about:blank', - remoteEndpointID: null, - activated: true, - sessionState: 'session:stopped' - }; - sessions[sessions.length] = session; - } - - return (session); - }; - - var _removeSession = function(endpointUUID) { - - for (var index = 0; index < sessions.length; index++) { - if (sessions[index].endpointUUID === endpointUUID) { - - _getEndpoint(endpointUUID).destroy(); - - // Remove the disconnected endpoint from the list. - sessions.splice(index, 1); - - // Now we need to set the active endpoint to someone else or to no endpoint if none are left. - if (sessions.length == 0) { - $rootScope.$broadcast('noEndpointActivated'); - } else { - _setActiveEndpoint(sessions[0].endpointUUID); - } - break; - } - } - }; - - - var _getEndpoint = function(uuid) { + function _getEndpoint(uuid) { var endpoint = null; - if ((typeof uuid === 'undefined') || uuid == null) { - $log.debug('getEndpoint: create new endpoint and setup onetimemessage event'); - endpoint = myEndpointProvider.createRtcommEndpoint(); - endpoint.on('onetimemessage', function(event) { - $log.debug('<<------rtcomm-onetimemessage------>> - Event: ', event); - if (event.onetimemessage.type != 'undefined' && event.onetimemessage.type == 'iFrameURL') { - var session = _createSession(event.endpoint.id); - - session.iFrameURL = event.onetimemessage.iFrameURL; - - $rootScope.$evalAsync( - function() { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); - } - ); - } - }); - } else - endpoint = myEndpointProvider.getRtcommEndpoint(uuid); + endpoint = myEndpointProvider.getRtcommEndpoint(uuid); return (endpoint); }; - var _setActiveEndpoint = function(endpointID) { + function _setActiveEndpoint(endpointID) { + + //base case // First get the old active endpoint var activeEndpoint = _getActiveEndpointUUID(); - if ((activeEndpoint != null) && (activeEndpoint != endpointID)) { - var session = _getSession(activeEndpoint); - if (session != null) + if ((activeEndpoint !== null) && (activeEndpoint !== endpointID)) { + var session = RtcommSessions.getSession(activeEndpoint); + if (typeof session !== 'undefined') session.activated = false; - } + } else { - var session = _createSession(endpointID); - session.activated = true; + var session = RtcommSessions.createSession(endpointID); + session.activated = true; + } $rootScope.$broadcast('endpointActivated', endpointID); }; - var _getActiveEndpointUUID = function() { + function _getActiveEndpointUUID() { var activeEndpoint = null; + var sessions = RtcommSessions.getAllSessions(); for (var index = 0; index < sessions.length; index++) { - if (sessions[index].activated == true) { + if (sessions[index].activated === true) { activeEndpoint = sessions[index].endpointUUID; break; } } return (activeEndpoint); }; - var _alert = function _alert(alertObject) { + + function alert(alertObject) { var a = { type: 'info', msg: 'default message' @@ -473,13 +402,28 @@ RtcommConfigService.setProviderConfig(config); myEndpointProvider.setRtcommEndpointConfig(RtcommConfigService.getMediaConfig()); - if (endpointProviderInitialized == false) { - // If the user does not specify a userid, that says one will never be specified so go ahead - // and initialize the endpoint provider and let the provider assign a name. If a defined empty - // string is passed in, that means to wait until the end user registers a name. - if (typeof config.userid == 'undefined' || RtcommConfigService.getProviderConfig().userid != '') { - myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); - endpointProviderInitialized = true; + if (endpointProviderInitialized === false) { + + if (typeof config.identityServlet !== "undefined" && config.identityServlet != null) { + $http.get(config.identityServlet).success(function(data) { + + if (typeof data.userid !== "undefined") { + RtcommConfigService.setProviderConfig(data); + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; + } else + $log.error('RtcommService: setConfig promise: Invalid JSON object return from identityServlet: ', data); + }).error(function(data, status, headers, config) { + $log.debug('RtcommService: setConfig promise: error accessing userid from identityServlet: ' + status); + }); + } else { + // If the user does not specify a userid, that says one will never be specified so go ahead + // and initialize the endpoint provider and let the provider assign a name. If a defined empty + // string is passed in, that means to wait until the end user registers a name. + if (typeof config.userid === 'undefined' || RtcommConfigService.getProviderConfig().userid !== '') { + myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); + endpointProviderInitialized = true; + } } } } @@ -501,7 +445,7 @@ getPresenceRecord().userDefines.push(userDefines[index]); } - if (endpointProviderInitialized == true) { + if (endpointProviderInitialized === true) { $log.debug('RtcommService: addToPresenceRecord: updating presence record to: ', getPresenceRecord()); myEndpointProvider.publishPresence(getPresenceRecord()); } @@ -512,14 +456,14 @@ for (var i = 0; i < userDefines.length; i++) { for (var j = 0; j < getPresenceRecord().userDefines.length; j++) { - if (getPresenceRecord().userDefines[j].name == userDefines[i].name) { + if (getPresenceRecord().userDefines[j].name === userDefines[i].name) { getPresenceRecord().userDefines.splice(j, 1); break; } } } - if ((endpointProviderInitialized == true) && doPublish) { + if ((endpointProviderInitialized === true) && doPublish) { $log.debug('RtcommService: removeFromPresenceRecord: updating presence record to: ', getPresenceRecord()); myEndpointProvider.publishPresence(getPresenceRecord()); } @@ -541,7 +485,7 @@ function register(userid) { - if (endpointProviderInitialized == false) { + if (endpointProviderInitialized === false) { RtcommConfigService.getProviderConfig().userid = userid; myEndpointProvider.init(RtcommConfigService.getProviderConfig(), initSuccess, initFailure); @@ -581,8 +525,13 @@ */ function sendChatMessage(chat, endpointUUID) { + var session; // Save this chat in the local session store - var session = _createSession(endpointUUID); + if (sessionExists(endpointUUID)) { + session = RtcommSessions.getSession(endpointUUID); + } else { + session = RtcommSessions.createSession(endpointUUID); + } session.chats.push(chat); myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); @@ -592,8 +541,8 @@ function getChats(endpointUUID) { if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { - var session = _getSession(endpointUUID); - if (session != null) + var session = RtcommSessions.getSession(endpointUUID); + if (typeof session !== 'undefined') return (session.chats); else return (null); @@ -605,7 +554,7 @@ function isWebrtcConnected(endpointUUID) { if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { - var session = _getSession(endpointUUID); + var session = RtcommSessions.getSession(endpointUUID); if (session != null) return (session.webrtcConnected); else @@ -624,13 +573,13 @@ function setAlias(aliasID) { - if ((typeof aliasID !== 'undefined') && aliasID != '') + if ((typeof aliasID !== 'undefined') && aliasID !== '') myEndpointProvider.setUserID(aliasID); } function setUserID(userID) { - if ((typeof userID !== 'undefined') && userID != '') { + if ((typeof userID !== 'undefined') && userID !== '') { RtcommConfigService.setProviderConfig({ userid: userID }); @@ -640,7 +589,7 @@ function setPresenceTopic(presenceTopic) { - if ((typeof presenceTopic !== 'undefined') && presenceTopic != '') { + if ((typeof presenceTopic !== 'undefined') && presenceTopic !== '') { RtcommConfigService.setProviderConfig({ presenceTopic: presenceTopic }); @@ -652,7 +601,7 @@ function getIframeURL(endpointUUID) { if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { - var session = _getSession(endpointUUID); + var session = RtcommSessions.getSession(endpointUUID); if (session != null) return (session.iFrameURL); else @@ -668,7 +617,8 @@ var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); if (endpoint != null) { - var session = _createSession(endpointUUID); + + var session = RtcommSessions.createSession(endpointUUID); session.iFrameURL = newUrl; var message = { @@ -683,6 +633,7 @@ function placeCall(calleeID, mediaToEnable) { + //Create new endpoint var endpoint = _getEndpoint(); if (mediaToEnable.indexOf('chat') > -1) @@ -699,13 +650,12 @@ }); } _setActiveEndpoint(endpoint.id); - endpoint.connect(calleeID); return (endpoint.id); } function getSessions() { - return sessions; + return RtcommSessions.getAllSessions(); } function endCall(endpoint) { @@ -726,7 +676,7 @@ var remoteEndpointID = null; if (localEndpointID != null) { - var session = _getSession(localEndpointID); + var session = RtcommSessions.getSession(localEndpointID); if (session != null) { remoteEndpointID = session.remoteEndpointID; @@ -752,7 +702,7 @@ $log.debug('rtcommVideo: setting local media'); var endpoint = null; - if (typeof endpointUUID != 'undefined' && endpointUUID != null) + if (typeof endpointUUID !== 'undefined' && endpointUUID !== null) endpoint = _getEndpoint(endpointUUID); else if (_getActiveEndpointUUID() != null) endpoint = _getEndpoint(_getActiveEndpointUUID()); @@ -765,73 +715,5 @@ }); } } - return { - - alert: _alert, - - isInitialized: isInitialized, - - setConfig: setConfig, - - getPresenceMonitor: getPresenceMonitor, - - publishPresence: publishPresence, - - addToPresenceRecord: addToPresenceRecord, - - removeFromPresenceRecord: removeFromPresenceRecord, - - setPresenceRecordState: setPresenceRecordState, - - getEndpoint: getEndpoint, - - destroyEndpoint: destroyEndpoint, - - register: register, - - unregister: unregister, - - joinQueue: joinQueue, - - leaveQueue: leaveQueue, - - getQueues: getQueues, - - sendChatMessage: sendChatMessage, - - getChats: getChats, - - isWebrtcConnected: isWebrtcConnected, - - getSessionState: getSessionState, - - setAlias: setAlias, - - setUserID: setUserID, - - setPresenceTopic: setPresenceTopic, - - getIframeURL: getIframeURL, - - putIframeURL: putIframeURL, - - placeCall: placeCall, - - getSessions: getSessions, - - endCall: endCall, - - setActiveEndpoint: setActiveEndpoint, - - getActiveEndpoint: getActiveEndpoint, - - getRemoteEndpoint: getRemoteEndpoint, - - setDefaultViewSelector: setDefaultViewSelector, - - setViewSelector: setViewSelector, - - setVideoView: setVideoView - }; } })(); From 6b4c11bd9f960467aca5c7547a51f793c7d2ce51 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Wed, 23 Mar 2016 13:29:26 -0400 Subject: [PATCH 16/21] Fixing chat service --- dist/angular-rtcomm.js | 46 +++++++++++++++---------------- dist/angular-rtcomm.min.js | 2 +- src/js/services/rtcomm-service.js | 40 +++++++++++++-------------- 3 files changed, 42 insertions(+), 46 deletions(-) diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 90b67e8..fb70c4c 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -572,17 +572,17 @@ angular 'onetimemessage': function(eventObject) { $log.debug('<<------- rtcomm-service ----->> - Event: ' + eventObject); - if (event.onetimemessage.type !== 'undefined' && event.onetimemessage.type === 'iFrameURL') { - var id = event.endpoint.id; + if (eventObject.onetimemessage.type !== 'undefined' && eventObject.onetimemessage.type === 'iFrameURL') { + var id = eventObject.endpoint.id; var session = RtcommSessions.getSession(id); if (session === null) { session = RtcommSessions.createSession(id); } - session.iFrameURL = event.onetimemessage.iFrameURL; + session.iFrameURL = eventObject.onetimemessage.iFrameURL; $rootScope.$evalAsync( function() { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + $rootScope.$broadcast('rtcomm::iframeUpdate', eventObject.endpoint.id, eventObject.onetimemessage.iFrameURL); } ); } @@ -590,7 +590,7 @@ angular 'session:started': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); var id = eventObject.endpoint.id; - var endoint = eventObject.endpoint; + var endpoint = eventObject.endpoint; var session = RtcommSessions.getSession(id); if (session === null) $log.error('Session:started but a previous session hasn\'t been created!'); @@ -662,7 +662,7 @@ angular var session = RtcommSessions.getSession(eventObject.endpoint.id); - if(session !== null) { + if (session !== null) { session.chats.push(chat); broadcastRtcommEvent(eventObject); } @@ -734,19 +734,18 @@ angular function _setActiveEndpoint(endpointID) { - //base case - - // First get the old active endpoint var activeEndpoint = _getActiveEndpointUUID(); + if ((activeEndpoint !== null) && (activeEndpoint !== endpointID)) { var session = RtcommSessions.getSession(activeEndpoint); - if (typeof session !== 'undefined') + if (session !== null) session.activated = false; - } else { - - var session = RtcommSessions.createSession(endpointID); - session.activated = true; } + var session = RtcommSessions.getSession(endpointID); + + if (session === null) session = RtcommSessions.createSession(endpointID); + session.activated = true; + $rootScope.$broadcast('endpointActivated', endpointID); }; @@ -926,11 +925,9 @@ angular var session; // Save this chat in the local session store - if (sessionExists(endpointUUID)) { - session = RtcommSessions.getSession(endpointUUID); - } else { - session = RtcommSessions.createSession(endpointUUID); - } + session = RtcommSessions.getSession(endpointUUID); + if (session === null) session = RtcommSessions.createSession(endpointUUID); + session.chats.push(chat); myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); @@ -941,7 +938,7 @@ angular if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { var session = RtcommSessions.getSession(endpointUUID); - if (typeof session !== 'undefined') + if (session !== null) return (session.chats); else return (null); @@ -1016,8 +1013,9 @@ angular var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); if (endpoint != null) { + var session = RtcommSessions.getSession(endpointUUID); - var session = RtcommSessions.createSession(endpointUUID); + if(session === null) session = RtcommSessions.createSession(endpointUUID); session.iFrameURL = newUrl; var message = { @@ -1131,7 +1129,7 @@ angular createSession: createSession, getSession: getSession, updateSession: updateSession, -removeSession: removeSession + removeSession: removeSession }; @@ -1216,15 +1214,15 @@ removeSession: removeSession if (session.endpointUUID === endpointUUID) { sessions.splice(i, 1); + $log.debug('Session with endpointUUID === ' + endpointUUID + 'has been removed'); break; } } - if (typeof session === 'undefined') { + if (session === null) { $log.debug('Unable to destroy session due to it not existing'); } - return session; } diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index d8bd353..b62f50a 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -18,5 +18,5 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==event.onetimemessage.type&&"iFrameURL"===event.onetimemessage.type){var e=event.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=event.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",event.endpoint.id,event.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=(a.endpoint,d.getSession(c));null===e?b.error("Session:started but a previous session hasn't been created!"):(m(c),e.started=!0,e.remoteEndpointID=endpoint.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var b=null;return b=_.getRtcommEndpoint(a)}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);"undefined"!=typeof e&&(e.activated=!1)}else{var e=d.createSession(b);e.activated=!0}a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var b=null;return b=_.getRtcommEndpoint(a)}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/services/rtcomm-service.js b/src/js/services/rtcomm-service.js index 1aadd0a..3f11d95 100644 --- a/src/js/services/rtcomm-service.js +++ b/src/js/services/rtcomm-service.js @@ -173,17 +173,17 @@ 'onetimemessage': function(eventObject) { $log.debug('<<------- rtcomm-service ----->> - Event: ' + eventObject); - if (event.onetimemessage.type !== 'undefined' && event.onetimemessage.type === 'iFrameURL') { - var id = event.endpoint.id; + if (eventObject.onetimemessage.type !== 'undefined' && eventObject.onetimemessage.type === 'iFrameURL') { + var id = eventObject.endpoint.id; var session = RtcommSessions.getSession(id); if (session === null) { session = RtcommSessions.createSession(id); } - session.iFrameURL = event.onetimemessage.iFrameURL; + session.iFrameURL = eventObject.onetimemessage.iFrameURL; $rootScope.$evalAsync( function() { - $rootScope.$broadcast('rtcomm::iframeUpdate', event.endpoint.id, event.onetimemessage.iFrameURL); + $rootScope.$broadcast('rtcomm::iframeUpdate', eventObject.endpoint.id, eventObject.onetimemessage.iFrameURL); } ); } @@ -191,7 +191,7 @@ 'session:started': function(eventObject) { $log.debug('<<------rtcomm-service------>> - Event: ' + eventObject.eventName + ' remoteEndpointID: ' + eventObject.endpoint.getRemoteEndpointID()); var id = eventObject.endpoint.id; - var endoint = eventObject.endpoint; + var endpoint = eventObject.endpoint; var session = RtcommSessions.getSession(id); if (session === null) $log.error('Session:started but a previous session hasn\'t been created!'); @@ -263,7 +263,7 @@ var session = RtcommSessions.getSession(eventObject.endpoint.id); - if(session !== null) { + if (session !== null) { session.chats.push(chat); broadcastRtcommEvent(eventObject); } @@ -335,19 +335,18 @@ function _setActiveEndpoint(endpointID) { - //base case - - // First get the old active endpoint var activeEndpoint = _getActiveEndpointUUID(); + if ((activeEndpoint !== null) && (activeEndpoint !== endpointID)) { var session = RtcommSessions.getSession(activeEndpoint); - if (typeof session !== 'undefined') + if (session !== null) session.activated = false; - } else { - - var session = RtcommSessions.createSession(endpointID); - session.activated = true; } + var session = RtcommSessions.getSession(endpointID); + + if (session === null) session = RtcommSessions.createSession(endpointID); + session.activated = true; + $rootScope.$broadcast('endpointActivated', endpointID); }; @@ -527,11 +526,9 @@ var session; // Save this chat in the local session store - if (sessionExists(endpointUUID)) { - session = RtcommSessions.getSession(endpointUUID); - } else { - session = RtcommSessions.createSession(endpointUUID); - } + session = RtcommSessions.getSession(endpointUUID); + if (session === null) session = RtcommSessions.createSession(endpointUUID); + session.chats.push(chat); myEndpointProvider.getRtcommEndpoint(endpointUUID).chat.send(chat.message); @@ -542,7 +539,7 @@ if (typeof endpointUUID !== 'undefined' && endpointUUID != null) { var session = RtcommSessions.getSession(endpointUUID); - if (typeof session !== 'undefined') + if (session !== null) return (session.chats); else return (null); @@ -617,8 +614,9 @@ var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); if (endpoint != null) { + var session = RtcommSessions.getSession(endpointUUID); - var session = RtcommSessions.createSession(endpointUUID); + if(session === null) session = RtcommSessions.createSession(endpointUUID); session.iFrameURL = newUrl; var message = { From bc707598231fbd4a5930b07b1721e10e5073c947 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Wed, 23 Mar 2016 14:47:16 -0400 Subject: [PATCH 17/21] Fixing endpoint controller --- dist/angular-rtcomm.js | 4 ++-- dist/angular-rtcomm.min.js | 2 +- src/js/ui/endpoint/endpoint-controller/endpoint.controller.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index fb70c4c..1ea0d05 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -1750,8 +1750,8 @@ angular $scope.disconnect = function() { $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - var ep = getActiveEndpoint; - ep.disconnect(); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); + }; $scope.toggleAV = function() { diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index b62f50a..39044d0 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -18,5 +18,5 @@ * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var b=null;return b=_.getRtcommEndpoint(a)}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var b=null;return b=_.getRtcommEndpoint(a)}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js index 3d0a192..60cd9ee 100644 --- a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js @@ -34,8 +34,8 @@ $scope.disconnect = function() { $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); - var ep = getActiveEndpoint; - ep.disconnect(); + RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); + }; $scope.toggleAV = function() { From 9c61e889fe6d3eab6b28624781b123c5d2aa44dc Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Wed, 23 Mar 2016 14:49:16 -0400 Subject: [PATCH 18/21] Restructuring service file structure --- .../services/{ => config}/config.service.js | 0 .../{ => config}/config.service.spec.js | 0 .../{ => rtcomm-service}/rtcomm-service.js | 0 .../rtcomm-service.spec.js | 0 src/js/services/sessions/sessions.service.js | 115 ++++++++++++++++++ .../sessions/sessions.service.spec.js | 87 +++++++++++++ 6 files changed, 202 insertions(+) rename src/js/services/{ => config}/config.service.js (100%) rename src/js/services/{ => config}/config.service.spec.js (100%) rename src/js/services/{ => rtcomm-service}/rtcomm-service.js (100%) rename src/js/services/{ => rtcomm-service}/rtcomm-service.spec.js (100%) create mode 100644 src/js/services/sessions/sessions.service.js create mode 100644 src/js/services/sessions/sessions.service.spec.js diff --git a/src/js/services/config.service.js b/src/js/services/config/config.service.js similarity index 100% rename from src/js/services/config.service.js rename to src/js/services/config/config.service.js diff --git a/src/js/services/config.service.spec.js b/src/js/services/config/config.service.spec.js similarity index 100% rename from src/js/services/config.service.spec.js rename to src/js/services/config/config.service.spec.js diff --git a/src/js/services/rtcomm-service.js b/src/js/services/rtcomm-service/rtcomm-service.js similarity index 100% rename from src/js/services/rtcomm-service.js rename to src/js/services/rtcomm-service/rtcomm-service.js diff --git a/src/js/services/rtcomm-service.spec.js b/src/js/services/rtcomm-service/rtcomm-service.spec.js similarity index 100% rename from src/js/services/rtcomm-service.spec.js rename to src/js/services/rtcomm-service/rtcomm-service.spec.js diff --git a/src/js/services/sessions/sessions.service.js b/src/js/services/sessions/sessions.service.js new file mode 100644 index 0000000..f685349 --- /dev/null +++ b/src/js/services/sessions/sessions.service.js @@ -0,0 +1,115 @@ +(function() { + 'use strict'; + + angular + .module('angular-rtcomm-service') + .factory('RtcommSessions', RtcommSessions); + + /* @ngInject */ + function RtcommSessions($log) { + var service = { + getAllSessions: getAllSessions, + createSession: createSession, + getSession: getSession, + updateSession: updateSession, + removeSession: removeSession + + }; + + var sessions = []; + return service; + + //////////////// + + function getAllSessions() { + return sessions; + } + + function removeAllSessions() { + + sessions.forEach(function(session) { + removeSession(session.endpointUUID); + }); + } + + function getSession(endpointUUID) { + $log.debug('Retrieving session linked to EndpointUUID: ' + endpointUUID); + + var session = null; + sessions.forEach(function(_session) { + if (_session.endpointUUID === endpointUUID) { + session = _session; + } + }); + + return session; + } + + function createSession(endpointUUID) { + $log.debug('Creating a session for EndpointUUID: ' + endpointUUID); + + var session; + + /* Define a session */ + session = { + + endpointUUID: endpointUUID, + remoteEndpointID: null, + chats: [], + webrtcConnected: false, + started: false, + state: 'session:stopped', + activated: true, + iFrameURL: 'about:blank', + }; + sessions.push(session); + return session; + + } + + function updateSession(endpointUUID, config) { + + $log.debug('Updating session for EndpointUUID: ' + endpointUUID); + + var session = getSession(endpointUUID); + + if (typeof session === 'undefined') + $log.debug('Unable to update endpoint due to it not existing'); + else { + + for (var property in session) { + if (session.hasOwnProperty(property)) { + + session[property] = typeof config[property] !== 'undefined' ? config[property] : session[property]; + } + } + } + + return session; + + } + + function removeSession(endpointUUID) { + $log.debug('Destroy session for EndpointUUID: ' + endpointUUID); + var session; + for (var i = 0; i < sessions.length; i++) { + session = sessions[i]; + + if (session.endpointUUID === endpointUUID) { + sessions.splice(i, 1); + + $log.debug('Session with endpointUUID === ' + endpointUUID + 'has been removed'); + break; + } + } + + if (session === null) { + $log.debug('Unable to destroy session due to it not existing'); + } + return session; + + } + + + } +})(); diff --git a/src/js/services/sessions/sessions.service.spec.js b/src/js/services/sessions/sessions.service.spec.js new file mode 100644 index 0000000..c7a7643 --- /dev/null +++ b/src/js/services/sessions/sessions.service.spec.js @@ -0,0 +1,87 @@ +describe('Unit Testing: RtcommSessions', function(){ + + var RtcommSessions; + + beforeEach(module('angular-rtcomm-service')); + + beforeEach(inject(function(_RtcommSessions_){ + RtcommSessions = _RtcommSessions_; + })); + + it('should be able to create a session', function(){ + + var session = RtcommSessions.createSession('MockID'); + + expect(session.endpointUUID).to.equal('MockID'); + expect(session.remoteEndpointID).to.be.null; + expect(session.chats).to.be.empty; + expect(session.webrtcConnected).to.be.false; + expect(session.started).to.be.false; + expect(session.state).to.equal('session:stopped'); + expect(session.activated).to.equal(true); + expect(session.iFrameURL).to.equal('about:blank'); + }); + + it('should be able to retrieve created sessions', function(){ + + //Create some session + var N = 5; + for(var i = 0; i < N; i++){ RtcommSessions.createSession('MockID'+i);} + + var session; + for(var i =0; i < N; i++){ + session = RtcommSessions.getSession('MockID'+i); + expect(session.endpointUUID).to.equal('MockID'+i); + } + }); + + it('should return a null session if it wasn\'t created', function(){ + var session = RtcommSessions.getSession('MockID0'); + + expect(session).to.be.null; + }); + + it('should update an existing session', function(){ + var id = 'MockID42'; + + RtcommSessions.createSession(id); + + RtcommSessions.updateSession(id, { state: 'session:started'}); + + var session = RtcommSessions.getSession(id); + + expect(session.state).to.equal('session:started'); + }); + + it('should destroy an existing session', function(){ + var id = 'MockID45'; + var session; + + RtcommSessions.createSession(id); + + session = RtcommSessions.getSession(id); + expect(session).to.not.be.undefined; + + RtcommSessions.removeSession(id); + session = RtcommSessions.getSession(id); + + expect(session).to.be.null; + }); + + it('should update properties on returned object', function(){ + var session = RtcommSessions.createSession('ID'); + + session.state = 'session:started'; + + var _session = RtcommSessions.getSession('ID'); + expect(session.state).to.equal(_session.state); + + session.chats.push({message: 'Hello World!'}); + + _session = RtcommSessions.getSession('ID'); + expect(session.chats).to.deep.equal(_session.chats); + }); + + + +}); From e52449ac9fb9e54d4b804d05c2192d030325e536 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Thu, 24 Mar 2016 15:28:34 -0400 Subject: [PATCH 19/21] Adding basic integration tests, modified Gruntfile to automatically plug in dependencies to test samples --- Gruntfile.js | 139 ++++++++++-------- bower.json | 4 +- dist/angular-rtcomm.js | 14 +- dist/angular-rtcomm.min.js | 4 +- package.json | 4 +- src/js/services/config/config.service.spec.js | 2 +- .../services/rtcomm-service/rtcomm-service.js | 12 +- src/test/angular-rtcomm-directives.js | 91 ++++++++++++ src/test/index.html | 69 +++++++++ src/test/lib/browser-config-generator.js | 52 +++++++ src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp | Bin 0 -> 12288 bytes src/test/rtcomm-chat/index.html | 62 ++++++++ src/test/rtcomm-chat/rtcomm-chat.spec.js | 27 ++++ src/test/rtcomm-chat/script.js | 30 ++++ src/test/rtcomm-video/index.html | 68 +++++++++ .../rtcomm-video-integration.spec.js | 62 ++++++++ src/test/rtcomm-video/script.js | 30 ++++ src/test/session-conf.js | 61 ++++++++ 18 files changed, 655 insertions(+), 76 deletions(-) create mode 100644 src/test/angular-rtcomm-directives.js create mode 100644 src/test/index.html create mode 100644 src/test/lib/browser-config-generator.js create mode 100644 src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp create mode 100644 src/test/rtcomm-chat/index.html create mode 100644 src/test/rtcomm-chat/rtcomm-chat.spec.js create mode 100644 src/test/rtcomm-chat/script.js create mode 100644 src/test/rtcomm-video/index.html create mode 100644 src/test/rtcomm-video/rtcomm-video-integration.spec.js create mode 100644 src/test/rtcomm-video/script.js create mode 100644 src/test/session-conf.js diff --git a/Gruntfile.js b/Gruntfile.js index b45567c..4f8d2c1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,25 +8,25 @@ module.exports = function(grunt) { meta: { banner: '/**\n' + - ' * Copyright 2014 IBM Corp.\n' + - ' *\n' + - ' * Licensed under the Apache License, Version 2.0 (the "License");\n' + - ' * you may not use this file except in compliance with the License.\n' + - ' * You may obtain a copy of the License at\n' + - ' *\n' + - ' * http://www.apache.org/licenses/LICENSE-2.0\n' + - ' *\n' + - ' * Unless required by applicable law or agreed to in writing, software\n' + - ' * distributed under the License is distributed on an "AS IS" BASIS,\n' + - ' * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' + - ' * See the License for the specific language governing permissions and\n' + - ' * limitations under the License.\n' + - ' *\n' + - ' * <%= pkg.description %>\n' + - ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + - ' * @link <%= pkg.homepage %>\n' + - ' * @author <%= pkg.author %>\n' + - ' */\n' + ' * Copyright 2014 IBM Corp.\n' + + ' *\n' + + ' * Licensed under the Apache License, Version 2.0 (the "License");\n' + + ' * you may not use this file except in compliance with the License.\n' + + ' * You may obtain a copy of the License at\n' + + ' *\n' + + ' * http://www.apache.org/licenses/LICENSE-2.0\n' + + ' *\n' + + ' * Unless required by applicable law or agreed to in writing, software\n' + + ' * distributed under the License is distributed on an "AS IS" BASIS,\n' + + ' * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n' + + ' * See the License for the specific language governing permissions and\n' + + ' * limitations under the License.\n' + + ' *\n' + + ' * <%= pkg.description %>\n' + + ' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' + + ' * @link <%= pkg.homepage %>\n' + + ' * @author <%= pkg.author %>\n' + + ' */\n' }, dirs: { @@ -39,40 +39,40 @@ module.exports = function(grunt) { banner: '<%= meta.banner %>' }, dist: { -// src: ['<%= dirs.src %>/*.js', '<%= dirs.src %>/**/*.js'], + // src: ['<%= dirs.src %>/*.js', '<%= dirs.src %>/**/*.js'], src: ['<%= dirs.src %>/js/**/*.module.js', '<%= dirs.src %>/js/**/*.js', '!**/*.spec.js'], dest: '<%= dirs.dest %>/<%= pkg.name %>.js' } }, copy: { - main: { - expand: true, - cwd: '<%= dirs.src %>', - src: ['css/*.css'], - dest: '<%= dirs.dest %>', - } + main: { + expand: true, + cwd: '<%= dirs.src %>', + src: ['css/*.css'], + dest: '<%= dirs.dest %>', + } }, cssmin: { - my_target: { - files: [{ - expand: true, - cwd: '<%= dirs.src %>', - src: ['css/*.css'], - dest: '<%= dirs.dest %>', - ext: '.min.css' - }] - } + my_target: { + files: [{ + expand: true, + cwd: '<%= dirs.src %>', + src: ['css/*.css'], + dest: '<%= dirs.dest %>', + ext: '.min.css' + }] + } }, ngAnnotate: { - dist: { - files: { - '<%= dirs.dest %>/<%= pkg.name %>.js': ['<%= dirs.dest %>/<%= pkg.name %>.js'] - } + dist: { + files: { + '<%= dirs.dest %>/<%= pkg.name %>.js': ['<%= dirs.dest %>/<%= pkg.name %>.js'] } - }, + } + }, uglify: { options: { @@ -108,34 +108,49 @@ module.exports = function(grunt) { } }, - watch: { + watch: { dev: { files: ['<%= dirs.src %>/**'], tasks: ['build'] }, }, + wiredep: { + task: { + src: ['<%= dirs.src %>/test/**/*.html'] + }, + options:{ + ignorePath: '../../..' + } + }, + ngtemplates: { + 'angular-rtcomm-ui': { + cwd: '<%= dirs.src %>', + src: ['templates/rtcomm/**.html', '!templates/rtcomm/rtcomm-presence.html'], + dest: '<%= dirs.dest %>/<%= pkg.name %>.js', + options: { + htmlmin: { + collapseWhitespace: true, + collapseBooleanAttributes: true + }, + append: 'true' + } + }, + 'angular-rtcomm-presence': { + cwd: '<%= dirs.src %>', + src: 'templates/rtcomm/rtcomm-presence.html', + dest: '<%= dirs.dest %>/<%= pkg.name %>.js', + options: { + htmlmin: { + collapseWhitespace: true, + collapseBooleanAttributes: true + }, + append: 'true' + } + + } + }, + - ngtemplates: { - 'angular-rtcomm-ui': { - cwd: '<%= dirs.src %>', - src: ['templates/rtcomm/**.html', '!templates/rtcomm/rtcomm-presence.html'], - dest: '<%= dirs.dest %>/<%= pkg.name %>.js', - options: { - htmlmin: { collapseWhitespace: true, collapseBooleanAttributes: true }, - append: 'true' - } - }, - 'angular-rtcomm-presence': { - cwd: '<%= dirs.src %>', - src: 'templates/rtcomm/rtcomm-presence.html', - dest: '<%= dirs.dest %>/<%= pkg.name %>.js', - options: { - htmlmin: { collapseWhitespace: true, collapseBooleanAttributes: true }, - append: 'true' - } - - } - } }); // Build task. diff --git a/bower.json b/bower.json index 692eedf..c2054b4 100644 --- a/bower.json +++ b/bower.json @@ -4,9 +4,7 @@ "description": "Angular module for Rtcomm", "main": [ "dist/angular-rtcomm.js", - "dist/angular-rtcomm.min.js", - "dist/css/angular-rtcomm.css", - "dist/css/angular-rtcomm.min.css" + "dist/css/angular-rtcomm.css" ], "keywords": [ "webrtc", diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 1ea0d05..6d9b438 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-23 + * @version v1.0.3 - 2016-03-24 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -727,7 +727,13 @@ angular function _getEndpoint(uuid) { var endpoint = null; - endpoint = myEndpointProvider.getRtcommEndpoint(uuid); + if (typeof uuid === 'undefined' || uuid === null) { + $log.debug('getEndpoint: create new endpoint'); + endpoint = myEndpointProvider.createRtcommEndpoint(); + } else { + $log.debug('getEndpoint: get an endpoint with id -> ' + uuid); + endpoint = myEndpointProvider.getRtcommEndpoint(uuid); + } return (endpoint); }; @@ -1013,9 +1019,9 @@ angular var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); if (endpoint != null) { - var session = RtcommSessions.getSession(endpointUUID); + var session = RtcommSessions.getSession(endpointUUID); - if(session === null) session = RtcommSessions.createSession(endpointUUID); + if (session === null) session = RtcommSessions.createSession(endpointUUID); session.iFrameURL = newUrl; var message = { diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index 39044d0..972a98a 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-23 + * @version v1.0.3 - 2016-03-24 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var b=null;return b=_.getRtcommEndpoint(a)}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var c=null;return"undefined"==typeof a||null===a?(b.debug("getEndpoint: create new endpoint"),c=_.createRtcommEndpoint()):(b.debug("getEndpoint: get an endpoint with id -> "+a),c=_.getRtcommEndpoint(a)),c}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/package.json b/package.json index 2a8df16..800ff7b 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "devDependencies": { "angular": "^1.3.5", "angular-mocks": "^1.3.5", - "chai": "^1.10.0", + "chai": "^3.5.0", + "chai-as-promised": "^5.3.0", "firefox-profile": "^0.3.11", "grunt": "^0.4.5", "grunt-angular-templates": "^0.5.7", @@ -36,6 +37,7 @@ "grunt-karma": "^0.9.0", "grunt-ng-annotate": "^0.8.0", "grunt-serve": "^0.1.6", + "grunt-wiredep": "^2.0.0", "karma": "^0.12.28", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^0.1.7", diff --git a/src/js/services/config/config.service.spec.js b/src/js/services/config/config.service.spec.js index 3236e8e..11772e9 100644 --- a/src/js/services/config/config.service.spec.js +++ b/src/js/services/config/config.service.spec.js @@ -123,7 +123,7 @@ describe('Unit Testing: Rtcomm Config Service', function() { }); it('rtcomm debug should be on level INFO', function() { - expect(RtcommConfigService.getRtcommDebug()).to.equal('INFO'); + expect(RtcommConfigService.getRtcommDebug()).to.equal('DEBUG'); }); it('rtcommdisabled should false', function() { diff --git a/src/js/services/rtcomm-service/rtcomm-service.js b/src/js/services/rtcomm-service/rtcomm-service.js index 3f11d95..20c82f4 100644 --- a/src/js/services/rtcomm-service/rtcomm-service.js +++ b/src/js/services/rtcomm-service/rtcomm-service.js @@ -328,7 +328,13 @@ function _getEndpoint(uuid) { var endpoint = null; - endpoint = myEndpointProvider.getRtcommEndpoint(uuid); + if (typeof uuid === 'undefined' || uuid === null) { + $log.debug('getEndpoint: create new endpoint'); + endpoint = myEndpointProvider.createRtcommEndpoint(); + } else { + $log.debug('getEndpoint: get an endpoint with id -> ' + uuid); + endpoint = myEndpointProvider.getRtcommEndpoint(uuid); + } return (endpoint); }; @@ -614,9 +620,9 @@ var endpoint = myEndpointProvider.getRtcommEndpoint(endpointUUID); if (endpoint != null) { - var session = RtcommSessions.getSession(endpointUUID); + var session = RtcommSessions.getSession(endpointUUID); - if(session === null) session = RtcommSessions.createSession(endpointUUID); + if (session === null) session = RtcommSessions.createSession(endpointUUID); session.iFrameURL = newUrl; var message = { diff --git a/src/test/angular-rtcomm-directives.js b/src/test/angular-rtcomm-directives.js new file mode 100644 index 0000000..0bb2512 --- /dev/null +++ b/src/test/angular-rtcomm-directives.js @@ -0,0 +1,91 @@ +'use strict'; + + + +/* globals element */ +/* globals by */ +function AngularRtcommDirectives(browser) { + + + var element = browser.element; + + return { + + rtcommRegister: RtcommRegister, + rtcommAlertModal: rtcommAlertModal, + rtcommVideo: rtcommVideo, + rtcommChat: rtcommChat + }; + + function RtcommRegister() { + this.inputElement = element(by.model('registerVM.reguserid')); + this.button = element(by.id('btn-register')); + this.input = function(user) { + this.inputElement.sendKeys(user); + return this; + }; + + this.clickRegister = function() { + this.button.click(); + return this; + }; + } + + function rtcommVideo() { + this.remoteViewID = 'remoteView'; + this.selfViewID = 'selfView'; + this.remoteView = element(by.id('remoteView')); + this.selfView = element(by.id('selfView')); + + this.waitForVideoReady = function(selector, _ms, _msg) { + var msg = _msg || "Timed out while retrieving video state"; + var ms = _ms || 5000; + + var script = function(selector) { + var callback = arguments[arguments.length - 1]; + + try { + + var video = document.querySelector(selector); + if (video.readyState === 4) { + callback(video.readyState); + } else { + video.onloadeddata = function() { + if (video.readyState === 4) { + callback(video.readyState); + } + }; + } + + } catch (err) { + callback(-1); + } + }; + + return browser.driver.wait(browser.driver.executeAsyncScript(script, [selector]), ms, msg); + } + } + + + + function rtcommChat() { + + this.chats = element(by.css('ul.chat')); + this.send = element(by.id('btn-chat')); + this.input = element(by.model('chatVM.message')); + + } + + function rtcommEndpointStatus() { + this.statusText = element(by.css('p.endpoint-controls-title > span')); + } + + + function rtcommAlertModal() { + + this.ok = element(by.css('[ng-click="ok()"]')); + this.cancel = element(by.css('[ng-click="cancel()"]')); + } +} + +module.exports = AngularRtcommDirectives; diff --git a/src/test/index.html b/src/test/index.html new file mode 100644 index 0000000..6237b5d --- /dev/null +++ b/src/test/index.html @@ -0,0 +1,69 @@ + + + + + + + + + E2E: rtcomm-video + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + +
+ +
+
+
+ +
+ +
+ +
+ +
+ + + + + +
+
+ +
+ +
+ + + diff --git a/src/test/lib/browser-config-generator.js b/src/test/lib/browser-config-generator.js new file mode 100644 index 0000000..35bf471 --- /dev/null +++ b/src/test/lib/browser-config-generator.js @@ -0,0 +1,52 @@ +var FirefoxProfile = require('firefox-profile'); +var q = require('q'); + +module.exports = { + generateBrowserProfile: generateBrowserProfile +}; + +function generateBrowserProfile(capability) { + + if (capability.browserName === 'chrome') + return generateChromeProfile(capability); + else if (capability.browserName === 'firefox') + return generateFirefoxProfile(capability); +} + + +function generateFirefoxProfile(capability) { + var deferred = q.defer(); + + var firefoxProfile = new FirefoxProfile(); + firefoxProfile.setPreference('media.peerconnection.enabled', true); + firefoxProfile.setPreference('media.navigator.enabled', true); + firefoxProfile.setPreference("media.navigator.streams.fake", true); + firefoxProfile.setPreference('media.navigator.permission.disabled', true); + firefoxProfile.encoded(function(encodedProfile) { + capability.firefox_profile = encodedProfile; + deferred.resolve(capability); + }); + return deferred.promise; + +} + +function generateChromeProfile(capability) { + var deferred = q.defer(); + var chromeFlags = { + 'args': ['--start-maximized', + '--allow-file-access-from-files', + '--disable-gesture-requirement-for-media-playback', + '--allow-file-access', + '--use-fake-ui-for-media-stream', + '--use-fake-device-for-media-stream', + '--start-maximized' + ] + }; + + setTimeout(function(){ + capability.chromeOptions = chromeFlags; + deferred.resolve(capability); + }, 1000); + + return deferred.promise; +} diff --git a/src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp b/src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..9ccebaff8c3fb455b6404a9df3f3906475c2a639 GIT binary patch literal 12288 zcmeI2zi-n(6vwY@8Cp;~P(+aq7~)j5U0Nhip+f~3I&`VjzyQP9c}X1kN4PsDLa4AY zb>~0e-+=!D{sjaQ3qnFdg0Ew@#Z}vh1@un(9*!3$vv5+RMX){zDp5oQ)Dn ztsh5$r_z2NEA48FcM{*|(6?l)Up~9xK-Io`W<;SkG_~yfzy{dBnFey(bMMZI^|f28 zMa<0`*X6?e-kIUN!3Nj>8(;%$fDNz#Hoykh!2f5!j%LIwT zfDNz#Hoykh02^QfY=8~00XDz}{y_t(E5z$rA?D_Ac>Mo=`1}9YMIk<~18m^08`wW*wC)Mf*q?qjL?g0J(+sja?#e_(sRdHWq8nSH>)8&2y5GL`+?yVQ@2B`r5)N)s8z5&FKp`ksTDRrpp++U{gs6`%IP@vhTa zL5Z=_vP|`$IM*p9iuL2zvbwASx5~!z-D%&s6X + + + + + + + + E2E: rtcomm-video + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ +
+ +
+ +
+ + + + + +
+
+ +
+ +
+ + + diff --git a/src/test/rtcomm-chat/rtcomm-chat.spec.js b/src/test/rtcomm-chat/rtcomm-chat.spec.js new file mode 100644 index 0000000..1a0622a --- /dev/null +++ b/src/test/rtcomm-chat/rtcomm-chat.spec.js @@ -0,0 +1,27 @@ + +/* globals browser */ +/* globals by */ + +var AngularRtcomm = require('../angular-rtcomm-directives.js'); +describe('E2E Integration: rtcomm-chat directive', function(){ + + + + beforeEach(function(){ + + browser.get('rtcomm-chat/'); + }); + + var client = new AngularRtcomm(browser); + + var rtcommChat = new client.rtcommChat(), + + rtcommAlertModal = new client.rtcommAlertModal(), + rtcommRegister = new client.rtcommRegister(); + + it('should maintain a chat session between users', function(){ + + + }); + +}); diff --git a/src/test/rtcomm-chat/script.js b/src/test/rtcomm-chat/script.js new file mode 100644 index 0000000..1b19f8a --- /dev/null +++ b/src/test/rtcomm-chat/script.js @@ -0,0 +1,30 @@ + 'use strict'; + angular + .module('app', [ + 'angular-rtcomm' + ]) + + .controller('MyController', RtcommController); + + function RtcommController($scope, RtcommService, $log){ + var vm = this; + var config = { + server: 'localhost', + port: 8083, + userid: '', + presenceTopic: 'rtcomm' + } + $log.debug('Activated'); + RtcommService.setConfig(config); + vm.callee = ''; + + vm.call = function(){ + $log.debug('Calling: ' + vm.callee); + RtcommService.placeCall(vm.callee, ['webrtc']); + + } + + } + + + diff --git a/src/test/rtcomm-video/index.html b/src/test/rtcomm-video/index.html new file mode 100644 index 0000000..84e42a0 --- /dev/null +++ b/src/test/rtcomm-video/index.html @@ -0,0 +1,68 @@ + + + + + + + + + E2E: rtcomm-video + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ + + + + +
+
+ +
+ +
+ + + diff --git a/src/test/rtcomm-video/rtcomm-video-integration.spec.js b/src/test/rtcomm-video/rtcomm-video-integration.spec.js new file mode 100644 index 0000000..3d9e66d --- /dev/null +++ b/src/test/rtcomm-video/rtcomm-video-integration.spec.js @@ -0,0 +1,62 @@ +var AngularRtcomm = require('../angular-rtcomm-directives.js'); +/* globals browser */ +/* globals expect */ +/* globals element */ +/* glboals EC */ +/* globals by */ +describe('E2E Integration Testing: Rtcomm-Video with RtcommService', function() { + + var placeCallBtn = element(by.id('place-call-btn')); + + var calleeInput = element(by.model('vm.callee')); + + var client = new AngularRtcomm(browser), + + rtcommRegister = new client.rtcommRegister(), + + rtcommAlertModal = new client.rtcommAlertModal(), + + rtcommVideo = new client.rtcommVideo(); + + beforeEach(function() { + browser.get('rtcomm-video/'); + }); + + + it('should display the video session between two users', function() { + //We're running two instances + + browser.driver.sleep(2000); + + if (browser.caller) { + rtcommRegister.input('User1') + .clickRegister(); + + + calleeInput.sendKeys('User2'); + placeCallBtn.click(); + + rtcommVideo.waitForVideoReady('#' + rtcommVideo.selfViewID); + //Should wait until + } else if (browser.callee) { + + rtcommRegister.input('User2') + .clickRegister(); + + + browser.wait(EC.elementToBeClickable(rtcommAlertModal.ok), 5000, 'Waited too long for alert modal'); + rtcommAlertModal.ok.click(); + + } + + + browser.driver.sleep(10000); + + expect(rtcommVideo.waitForVideoReady('#' + rtcommVideo.selfViewID)).to.eventually.equal(4); + expect(rtcommVideo.waitForVideoReady('#' + rtcommVideo.remoteViewID)).to.eventually.equal(4); + + + + }); + +}); diff --git a/src/test/rtcomm-video/script.js b/src/test/rtcomm-video/script.js new file mode 100644 index 0000000..1b19f8a --- /dev/null +++ b/src/test/rtcomm-video/script.js @@ -0,0 +1,30 @@ + 'use strict'; + angular + .module('app', [ + 'angular-rtcomm' + ]) + + .controller('MyController', RtcommController); + + function RtcommController($scope, RtcommService, $log){ + var vm = this; + var config = { + server: 'localhost', + port: 8083, + userid: '', + presenceTopic: 'rtcomm' + } + $log.debug('Activated'); + RtcommService.setConfig(config); + vm.callee = ''; + + vm.call = function(){ + $log.debug('Calling: ' + vm.callee); + RtcommService.placeCall(vm.callee, ['webrtc']); + + } + + } + + + diff --git a/src/test/session-conf.js b/src/test/session-conf.js new file mode 100644 index 0000000..99b36fa --- /dev/null +++ b/src/test/session-conf.js @@ -0,0 +1,61 @@ +//Required to use Mocha in Protractor +var chai = require('chai'); +var chaiAsPromised = require('chai-as-promised'); +chai.use(chaiAsPromised); +var expect = chai.expect; +var q = require('q'); +var RtcommHelper = require('./lib/browser-config-generator.js'); + +///Define the users in the session +var session = [{ + browserName: process.env.BROWSER || 'chrome', + caller: true +}, { + browserName: process.env.BROWSER || 'chrome', + callee: true +}]; + +function establishSessionMeta(capabilities) { + var USERS = []; + var promises = []; + // var defer = q.defer(); + + capabilities.forEach(function(cap) { + + cap.USERS = USERS; + USERS.push(cap.userName); + + promises.push(RtcommHelper.generateBrowserProfile(cap)); + + }); + return q.all(promises); +} + +exports.config = { + directConnect: true, + specs: ['**/*.spec.js'], + getMultiCapabilities: function() { + return establishSessionMeta(session); + }, + onPrepare: function() { + global.EC = protractor.ExpectedConditions; + global.expect = expect; + // browser.driver.manage().window().maximize(); + + return browser.getProcessedConfig().then(function(config) { +browser.driver.manage().window().maximize(); + + browser.caller = config.capabilities.caller; + browser.callee = config.capabilities.callee; + browser.userName = config.capabilities.userName; + browser.USERS = config.capabilities.USERS; + }); + }, + + framework: 'mocha', + + mochaOpts: { + reporter: 'spec', + timeout: 60000 + } +}; From d45a99ff69536404dfe4d5be62f4aa3a4d2dd85e Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Fri, 25 Mar 2016 15:11:41 -0400 Subject: [PATCH 20/21] Adding unit test for endpoint controller --- .gitignore | 3 +- Gruntfile.js | 17 +- dist/angular-rtcomm.js | 284 ++++++++-------- dist/angular-rtcomm.min.js | 4 +- karma.conf.js | 2 +- package.json | 6 +- src/js/services/config/config.service.js | 271 +++++++-------- src/js/services/config/config.service.spec.js | 309 ++++++++++-------- src/js/ui/config.controller.js | 5 - src/js/ui/config.controller.spec.js | 16 +- .../endpoint.controller.js | 4 - .../endpoint.controller.spec.js | 181 +++++++++- 12 files changed, 651 insertions(+), 451 deletions(-) diff --git a/.gitignore b/.gitignore index 0732f74..11df243 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.settings /bower_components /node_modules -.project \ No newline at end of file +.project +*.swp diff --git a/Gruntfile.js b/Gruntfile.js index 4f8d2c1..8b7bfc6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -107,7 +107,16 @@ module.exports = function(grunt) { } } }, + karma: { + unit: { + configFile: 'karma.conf.js', + singleRun: true + }, + watch :{ + configFile: 'karma.conf.js' + } + }, watch: { dev: { files: ['<%= dirs.src %>/**'], @@ -118,9 +127,9 @@ module.exports = function(grunt) { task: { src: ['<%= dirs.src %>/test/**/*.html'] }, - options:{ - ignorePath: '../../..' - } + options: { + ignorePath: '../../..' + } }, ngtemplates: { 'angular-rtcomm-ui': { @@ -154,7 +163,7 @@ module.exports = function(grunt) { }); // Build task. - grunt.registerTask('build', ['jshint', 'concat', 'ngtemplates', 'ngAnnotate', 'uglify', 'copy', 'cssmin']); + grunt.registerTask('build', ['karma:unit', 'jshint', 'concat', 'ngtemplates', 'ngAnnotate', 'uglify', 'copy', 'cssmin']); // Default task. //grunt.registerTask('default', ['build', 'watch']); diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 6d9b438..582d22c 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-24 + * @version v1.0.3 - 2016-03-25 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -243,7 +243,6 @@ angular }; })(); - /** * (C) Copyright IBM Corporation 2015. * @@ -261,140 +260,144 @@ angular */ (function() { - 'use strict'; + 'use strict'; - angular - .module('angular-rtcomm-service') - .factory('RtcommConfigService', RtcommConfigService); - - /* @ngInject */ - function RtcommConfigService($location, $log, $window) { - var service = { - setProviderConfig: setProviderConfig, - getProviderConfig: getProviderConfig, - getWebRTCEnabled: getWebRTCEnabled, - getChatEnabled: getChatEnabled, - getBroadcastAudio: getBroadcastAudio, - getBroadcastVideo: getBroadcastVideo, - getRingTone: getRingTone, - getRingBackTone: getRingBackTone, - getRtcommDebug: getRtcommDebug, - isRtcommDisabled: isRtcommDisabled, - getMediaConfig: getMediaConfig - }; - - //Default provider - var providerConfig = { - server: $location.host(), - port: $location.port(), - rtcommTopicPath: '/rtcomm/', - createEndpoint: false, - appContext: 'default', - userid: '', - presence: {topic: ''} - }; - - //Rtcomm Endpoint Config Defaults - var mediaConfig = { - chat: true, - webrtc: true, - webrtcConfig: { - broadcast: { - audio: true, - video: true - } - }, - ringbacktone: null, - ringtone: null - }; - - //Rtcomm Debug - var rtcommDebug = 'DEBUG'; - - $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); - $log.debug('providerConfig.server: ' + providerConfig.server); - $log.debug('providerConfig.port: ' + providerConfig.port); - - return service; - - function setProviderConfig(config) { - - //Provider Config - providerConfig = { - - server : (typeof config.server !== 'undefined')? config.server : providerConfig.server, - port : (typeof config.port !== 'undefined')? config.port : providerConfig.port, - rtcommTopicPath : (typeof config.rtcommTopicPath !== 'undefined')? config.rtcommTopicPath : providerConfig.rtcommTopicPath, - createEndpoint : (typeof config.createEndpoint !== 'undefined')? config.createEndpoint : providerConfig.createEndpoint, - appContext : (typeof config.appContext !== 'undefined')? config.appContext : providerConfig.appContext, - presence : { - topic : (typeof config.presenceTopic !== 'undefined')? config.presenceTopic : providerConfig.presence.topic, - }, - userid : (typeof config.userid !== 'undefined') ? config.userid : providerConfig.userid - }; - - //Media Configuration - mediaConfig = { - chat : (typeof config.chat !== 'undefined') ? config.chat : mediaConfig.chat, - webrtc: (typeof config.video !== 'undefined') ? config.webrtc: mediaConfig.webrtc, - webrtcConfig : { - broadcast : { - video: typeof config.broadcastVideo !== 'undefined' ? config.broadcastVideo : mediaConfig.webrtcConfig.broadcast.video, - audio: typeof config.broadcastAudio !== 'undefined' ? config.broadcastAudio : mediaConfig.webrtcConfig.broadcast.audio - } - }, - ringbacktone: typeof config.ringbacktone !== 'undefined' ? config.ringbacktone : mediaConfig.ringbacktone, - ringtone: typeof config.ringtone !== 'undefined' ? config.ringtone : mediaConfig.ringtone - }; - - rtcommDebug = (typeof config.rtcommDebug !== 'undefined')? config.rtcommDebug: rtcommDebug; - - $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); - - $log.debug('providerConfig is: ' + providerConfig); - } - - function getProviderConfig(){ - return providerConfig; - } - - function getWebRTCEnabled(){ - return mediaConfig.webrtc; - } - - function getChatEnabled(){ - return mediaConfig.chat; - } - - function getBroadcastAudio(){ - return mediaConfig.webrtcConfig.broadcast.audio; - } - - function getBroadcastVideo(){ - return mediaConfig.webrtcConfig.broadcast.video; - } - - function getRingTone(){ - return mediaConfig.ringtone; - } - - function getRingBackTone(){ - return mediaConfig.ringbacktone; - } - - function getRtcommDebug(){ - return rtcommDebug; - } - - function isRtcommDisabled(){ - return false; - } - - function getMediaConfig(){ - return mediaConfig; - } - } - RtcommConfigService.$inject = ["$location", "$log", "$window"]; + angular + .module('angular-rtcomm-service') + .factory('RtcommConfigService', RtcommConfigService); + + /* @ngInject */ + function RtcommConfigService($location, $log, $window) { + var service = { + setProviderConfig: setProviderConfig, + getProviderConfig: getProviderConfig, + getWebRTCEnabled: getWebRTCEnabled, + getChatEnabled: getChatEnabled, + getBroadcastAudio: getBroadcastAudio, + getBroadcastVideo: getBroadcastVideo, + getRingTone: getRingTone, + getRingBackTone: getRingBackTone, + getRtcommDebug: getRtcommDebug, + isRtcommDisabled: isRtcommDisabled, + getMediaConfig: getMediaConfig + }; + + //Default provider + var providerConfig = { + server: $location.host(), + port: $location.port(), + rtcommTopicPath: '/rtcomm/', + createEndpoint: false, + appContext: 'default', + userid: '', + presence: { + topic: '' + } + }; + + //Rtcomm Endpoint Config Defaults + var mediaConfig = { + chat: true, + webrtc: true, + webrtcConfig: { + broadcast: { + audio: true, + video: true + }, + trickleICE: true + }, + ringbacktone: null, + ringtone: null + }; + + //Rtcomm Debug + var rtcommDebug = 'DEBUG'; + + $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); + $log.debug('providerConfig.server: ' + providerConfig.server); + $log.debug('providerConfig.port: ' + providerConfig.port); + + return service; + + function setProviderConfig(config) { + + //Provider Config + providerConfig = { + + server: (typeof config.server !== 'undefined') ? config.server : providerConfig.server, + port: (typeof config.port !== 'undefined') ? config.port : providerConfig.port, + rtcommTopicPath: (typeof config.rtcommTopicPath !== 'undefined') ? config.rtcommTopicPath : providerConfig.rtcommTopicPath, + createEndpoint: (typeof config.createEndpoint !== 'undefined') ? config.createEndpoint : providerConfig.createEndpoint, + appContext: (typeof config.appContext !== 'undefined') ? config.appContext : providerConfig.appContext, + presence: { + topic: (typeof config.presenceTopic !== 'undefined') ? config.presenceTopic : providerConfig.presence.topic, + }, + userid: (typeof config.userid !== 'undefined') ? config.userid : providerConfig.userid + }; + + //Media Configuration + mediaConfig = { + chat: (typeof config.chat !== 'undefined') ? config.chat : mediaConfig.chat, + webrtc: (typeof config.video !== 'undefined') ? config.webrtc : mediaConfig.webrtc, + webrtcConfig: { + broadcast: { + video: typeof config.broadcastVideo !== 'undefined' ? config.broadcastVideo : mediaConfig.webrtcConfig.broadcast.video, + audio: typeof config.broadcastAudio !== 'undefined' ? config.broadcastAudio : mediaConfig.webrtcConfig.broadcast.audio + }, + trickleICE: typeof config.trickleICE !== 'undefined' ? config.trickleICE : mediaConfig.webrtcConfig.trickleICE + }, + ringbacktone: typeof config.ringbacktone !== 'undefined' ? config.ringbacktone : mediaConfig.ringbacktone, + ringtone: typeof config.ringtone !== 'undefined' ? config.ringtone : mediaConfig.ringtone + }; + + rtcommDebug = (typeof config.rtcommDebug !== 'undefined') ? config.rtcommDebug : rtcommDebug; + + $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); + + $log.debug('providerConfig is: ' + providerConfig); + } + + function getProviderConfig() { + return providerConfig; + } + + function getWebRTCEnabled() { + return mediaConfig.webrtc; + } + + function getChatEnabled() { + return mediaConfig.chat; + } + + function getBroadcastAudio() { + return mediaConfig.webrtcConfig.broadcast.audio; + } + + function getBroadcastVideo() { + return mediaConfig.webrtcConfig.broadcast.video; + } + + function getRingTone() { + return mediaConfig.ringtone; + } + + function getRingBackTone() { + return mediaConfig.ringbacktone; + } + + function getRtcommDebug() { + return rtcommDebug; + } + + function isRtcommDisabled() { + return false; + } + + function getMediaConfig() { + return mediaConfig; + } + } + RtcommConfigService.$inject = ["$location", "$log", "$window"]; })(); /** @@ -515,7 +518,7 @@ angular function activate() { myEndpointProvider = new rtcomm.EndpointProvider(); - myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); +// myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); @@ -1291,11 +1294,6 @@ angular $log.debug('RtcommConfigController: configURL = ' + vm.configURL); - vm.setConfig = function(data) { - $log.debug('RtcommConfigController: setting config data:' + data); - RtcommService.setConfig(data); - }; - $scope.init = function(configURL, extendedConfig) { $log.debug('RtcommConfigController: initing configURL = ' + configURL); @@ -1750,10 +1748,6 @@ angular $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - function getActiveEndpoint() { - return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); - } - $scope.disconnect = function() { $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index 972a98a..a06904a 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-24 + * @version v1.0.3 - 2016-03-25 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var c=null;return"undefined"==typeof a||null===a?(b.debug("getEndpoint: create new endpoint"),c=_.createRtcommEndpoint()):(b.debug("getEndpoint: get an endpoint with id -> "+a),c=_.getRtcommEndpoint(a)),c}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var c=null;return"undefined"==typeof a||null===a?(b.debug("getEndpoint: create new endpoint"),c=_.createRtcommEndpoint()):(b.debug("getEndpoint: get an endpoint with id -> "+a),c=_.getRtcommEndpoint(a)),c}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index dc3e187..f173d70 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,7 +10,7 @@ module.exports = function(config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha', 'chai', 'sinon'], - reporters: ['spec', 'coverage'], + reporters: ['progress', 'coverage'], // list of files / patterns to load in the browser files: [ 'bower_components/jquery/dist/jquery.js', diff --git a/package.json b/package.json index 800ff7b..a5b4347 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,6 @@ }, "homepage": "https://github.com/WASdev/lib.angular-rtcomm", "devDependencies": { - "angular": "^1.3.5", - "angular-mocks": "^1.3.5", "chai": "^3.5.0", "chai-as-promised": "^5.3.0", "firefox-profile": "^0.3.11", @@ -38,6 +36,7 @@ "grunt-ng-annotate": "^0.8.0", "grunt-serve": "^0.1.6", "grunt-wiredep": "^2.0.0", + "istanbul": "^0.4.2", "karma": "^0.12.28", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^0.1.7", @@ -53,8 +52,5 @@ "mocha": "^2.0.1", "protractor": "^3.1.1", "q": "^1.4.1" - }, - "dependencies": { - "istanbul": "^0.4.2" } } diff --git a/src/js/services/config/config.service.js b/src/js/services/config/config.service.js index bf12a65..ba08587 100644 --- a/src/js/services/config/config.service.js +++ b/src/js/services/config/config.service.js @@ -1,4 +1,3 @@ - /** * (C) Copyright IBM Corporation 2015. * @@ -16,137 +15,141 @@ */ (function() { - 'use strict'; - - angular - .module('angular-rtcomm-service') - .factory('RtcommConfigService', RtcommConfigService); - - /* @ngInject */ - function RtcommConfigService($location, $log, $window) { - var service = { - setProviderConfig: setProviderConfig, - getProviderConfig: getProviderConfig, - getWebRTCEnabled: getWebRTCEnabled, - getChatEnabled: getChatEnabled, - getBroadcastAudio: getBroadcastAudio, - getBroadcastVideo: getBroadcastVideo, - getRingTone: getRingTone, - getRingBackTone: getRingBackTone, - getRtcommDebug: getRtcommDebug, - isRtcommDisabled: isRtcommDisabled, - getMediaConfig: getMediaConfig - }; - - //Default provider - var providerConfig = { - server: $location.host(), - port: $location.port(), - rtcommTopicPath: '/rtcomm/', - createEndpoint: false, - appContext: 'default', - userid: '', - presence: {topic: ''} - }; - - //Rtcomm Endpoint Config Defaults - var mediaConfig = { - chat: true, - webrtc: true, - webrtcConfig: { - broadcast: { - audio: true, - video: true - } - }, - ringbacktone: null, - ringtone: null - }; - - //Rtcomm Debug - var rtcommDebug = 'DEBUG'; - - $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); - $log.debug('providerConfig.server: ' + providerConfig.server); - $log.debug('providerConfig.port: ' + providerConfig.port); - - return service; - - function setProviderConfig(config) { - - //Provider Config - providerConfig = { - - server : (typeof config.server !== 'undefined')? config.server : providerConfig.server, - port : (typeof config.port !== 'undefined')? config.port : providerConfig.port, - rtcommTopicPath : (typeof config.rtcommTopicPath !== 'undefined')? config.rtcommTopicPath : providerConfig.rtcommTopicPath, - createEndpoint : (typeof config.createEndpoint !== 'undefined')? config.createEndpoint : providerConfig.createEndpoint, - appContext : (typeof config.appContext !== 'undefined')? config.appContext : providerConfig.appContext, - presence : { - topic : (typeof config.presenceTopic !== 'undefined')? config.presenceTopic : providerConfig.presence.topic, - }, - userid : (typeof config.userid !== 'undefined') ? config.userid : providerConfig.userid - }; - - //Media Configuration - mediaConfig = { - chat : (typeof config.chat !== 'undefined') ? config.chat : mediaConfig.chat, - webrtc: (typeof config.video !== 'undefined') ? config.webrtc: mediaConfig.webrtc, - webrtcConfig : { - broadcast : { - video: typeof config.broadcastVideo !== 'undefined' ? config.broadcastVideo : mediaConfig.webrtcConfig.broadcast.video, - audio: typeof config.broadcastAudio !== 'undefined' ? config.broadcastAudio : mediaConfig.webrtcConfig.broadcast.audio - } - }, - ringbacktone: typeof config.ringbacktone !== 'undefined' ? config.ringbacktone : mediaConfig.ringbacktone, - ringtone: typeof config.ringtone !== 'undefined' ? config.ringtone : mediaConfig.ringtone - }; - - rtcommDebug = (typeof config.rtcommDebug !== 'undefined')? config.rtcommDebug: rtcommDebug; - - $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); - - $log.debug('providerConfig is: ' + providerConfig); - } - - function getProviderConfig(){ - return providerConfig; - } - - function getWebRTCEnabled(){ - return mediaConfig.webrtc; - } - - function getChatEnabled(){ - return mediaConfig.chat; - } - - function getBroadcastAudio(){ - return mediaConfig.webrtcConfig.broadcast.audio; - } - - function getBroadcastVideo(){ - return mediaConfig.webrtcConfig.broadcast.video; - } - - function getRingTone(){ - return mediaConfig.ringtone; - } - - function getRingBackTone(){ - return mediaConfig.ringbacktone; - } - - function getRtcommDebug(){ - return rtcommDebug; - } - - function isRtcommDisabled(){ - return false; - } - - function getMediaConfig(){ - return mediaConfig; - } - } + 'use strict'; + + angular + .module('angular-rtcomm-service') + .factory('RtcommConfigService', RtcommConfigService); + + /* @ngInject */ + function RtcommConfigService($location, $log, $window) { + var service = { + setProviderConfig: setProviderConfig, + getProviderConfig: getProviderConfig, + getWebRTCEnabled: getWebRTCEnabled, + getChatEnabled: getChatEnabled, + getBroadcastAudio: getBroadcastAudio, + getBroadcastVideo: getBroadcastVideo, + getRingTone: getRingTone, + getRingBackTone: getRingBackTone, + getRtcommDebug: getRtcommDebug, + isRtcommDisabled: isRtcommDisabled, + getMediaConfig: getMediaConfig + }; + + //Default provider + var providerConfig = { + server: $location.host(), + port: $location.port(), + rtcommTopicPath: '/rtcomm/', + createEndpoint: false, + appContext: 'default', + userid: '', + presence: { + topic: '' + } + }; + + //Rtcomm Endpoint Config Defaults + var mediaConfig = { + chat: true, + webrtc: true, + webrtcConfig: { + broadcast: { + audio: true, + video: true + }, + trickleICE: true + }, + ringbacktone: null, + ringtone: null + }; + + //Rtcomm Debug + var rtcommDebug = 'DEBUG'; + + $log.debug('RtcommConfigService: Abs Url: ' + $location.absUrl()); + $log.debug('providerConfig.server: ' + providerConfig.server); + $log.debug('providerConfig.port: ' + providerConfig.port); + + return service; + + function setProviderConfig(config) { + + //Provider Config + providerConfig = { + + server: (typeof config.server !== 'undefined') ? config.server : providerConfig.server, + port: (typeof config.port !== 'undefined') ? config.port : providerConfig.port, + rtcommTopicPath: (typeof config.rtcommTopicPath !== 'undefined') ? config.rtcommTopicPath : providerConfig.rtcommTopicPath, + createEndpoint: (typeof config.createEndpoint !== 'undefined') ? config.createEndpoint : providerConfig.createEndpoint, + appContext: (typeof config.appContext !== 'undefined') ? config.appContext : providerConfig.appContext, + presence: { + topic: (typeof config.presenceTopic !== 'undefined') ? config.presenceTopic : providerConfig.presence.topic, + }, + userid: (typeof config.userid !== 'undefined') ? config.userid : providerConfig.userid + }; + + //Media Configuration + mediaConfig = { + chat: (typeof config.chat !== 'undefined') ? config.chat : mediaConfig.chat, + webrtc: (typeof config.video !== 'undefined') ? config.webrtc : mediaConfig.webrtc, + webrtcConfig: { + broadcast: { + video: typeof config.broadcastVideo !== 'undefined' ? config.broadcastVideo : mediaConfig.webrtcConfig.broadcast.video, + audio: typeof config.broadcastAudio !== 'undefined' ? config.broadcastAudio : mediaConfig.webrtcConfig.broadcast.audio + }, + trickleICE: typeof config.trickleICE !== 'undefined' ? config.trickleICE : mediaConfig.webrtcConfig.trickleICE + }, + ringbacktone: typeof config.ringbacktone !== 'undefined' ? config.ringbacktone : mediaConfig.ringbacktone, + ringtone: typeof config.ringtone !== 'undefined' ? config.ringtone : mediaConfig.ringtone + }; + + rtcommDebug = (typeof config.rtcommDebug !== 'undefined') ? config.rtcommDebug : rtcommDebug; + + $log.debug('rtcommDebug from config is: ' + config.rtcommDebug); + + $log.debug('providerConfig is: ' + providerConfig); + } + + function getProviderConfig() { + return providerConfig; + } + + function getWebRTCEnabled() { + return mediaConfig.webrtc; + } + + function getChatEnabled() { + return mediaConfig.chat; + } + + function getBroadcastAudio() { + return mediaConfig.webrtcConfig.broadcast.audio; + } + + function getBroadcastVideo() { + return mediaConfig.webrtcConfig.broadcast.video; + } + + function getRingTone() { + return mediaConfig.ringtone; + } + + function getRingBackTone() { + return mediaConfig.ringbacktone; + } + + function getRtcommDebug() { + return rtcommDebug; + } + + function isRtcommDisabled() { + return false; + } + + function getMediaConfig() { + return mediaConfig; + } + } })(); diff --git a/src/js/services/config/config.service.spec.js b/src/js/services/config/config.service.spec.js index 11772e9..266f1ef 100644 --- a/src/js/services/config/config.service.spec.js +++ b/src/js/services/config/config.service.spec.js @@ -1,4 +1,3 @@ - /** *(C) Copyright IBM Corporation 2016. * @@ -18,184 +17,206 @@ describe('Unit Testing: Rtcomm Config Service', function() { - var RtcommConfigService; - - //Dependencies - var $location, $window; - - //Mock and stub - var sandbox; - - beforeEach(module('angular-rtcomm-service')); - - beforeEach(inject(['$location', '$window', function(_$location_, _$window_) { - - $location = _$location_; - $window = _$window_; - sandbox = sinon.sandbox.create(); - //Mock the dependencies - sandbox.stub($location, 'absUrl', function() { - 'http://localhost:3000'; - }); - sandbox.stub($location, 'host', function() { - return 'localhost'; - }); - sandbox.stub($location, 'port', function() { - return 3000; - }); - sandbox.stub($location, 'search', function() { - return { - disableRtcomm: false - }; - }); - - }])); - - beforeEach(inject(['RtcommConfigService', function(_RtcommConfigService_) { - RtcommConfigService = _RtcommConfigService_; - }])); - - afterEach(function() { - sandbox.restore(); - }); - - var defaultConfig = { - server: 'localhost', - port: 3000, - rtcommTopicPath: '/rtcomm/', - createEndpoint: false, - appContext: 'default', - userid: '', - presence: { - topic: '' - } - }; - - - it('API should be defined', function() { - expect(RtcommConfigService.setProviderConfig).to.not.be.undefined; - expect(RtcommConfigService.getProviderConfig).to.not.be.undefined; - expect(RtcommConfigService.getWebRTCEnabled).to.not.be.undefined; - expect(RtcommConfigService.getChatEnabled).to.not.be.undefined; - expect(RtcommConfigService.getBroadcastVideo).to.not.be.undefined; - expect(RtcommConfigService.getBroadcastAudio).to.not.be.undefined; - expect(RtcommConfigService.getRingTone).to.not.be.undefined; - expect(RtcommConfigService.getRingBackTone).to.not.be.undefined; - expect(RtcommConfigService.getRtcommDebug).to.not.be.undefined; - expect(RtcommConfigService.isRtcommDisabled).to.not.be.undefined; - expect(RtcommConfigService.getMediaConfig).to.not.be.undefined; - }); - - - - - describe('default configuration values', function() { + var RtcommConfigService; + + //Dependencies + var $location, $window; + + //Mock and stub + var sandbox; + + beforeEach(module('angular-rtcomm-service')); + + beforeEach(inject(['$location', '$window', + function(_$location_, _$window_) { + + $location = _$location_; + $window = _$window_; + sandbox = sinon.sandbox.create(); + //Mock the dependencies + sandbox.stub($location, 'absUrl', function() { + 'http://localhost:3000'; + }); + sandbox.stub($location, 'host', function() { + return 'localhost'; + }); + sandbox.stub($location, 'port', function() { + return 3000; + }); + sandbox.stub($location, 'search', function() { + return { + disableRtcomm: false + }; + }); + + } + ])); + + beforeEach(inject(['RtcommConfigService', + function(_RtcommConfigService_) { + RtcommConfigService = _RtcommConfigService_; + } + ])); + + afterEach(function() { + sandbox.restore(); + }); + + var defaultConfig = { + server: 'localhost', + port: 3000, + rtcommTopicPath: '/rtcomm/', + createEndpoint: false, + appContext: 'default', + userid: '', + presence: { + topic: '' + } + }; + + var defaultMediaConfig = { + + chat: true, + webrtc: true, + webrtcConfig: { + broadcast: { + audio: true, + video: true + }, + trickleICE: true + }, + ringbacktone: null, + ringtone: null + + } + it('API should be defined', function() { + expect(RtcommConfigService.setProviderConfig).to.not.be.undefined; + expect(RtcommConfigService.getProviderConfig).to.not.be.undefined; + expect(RtcommConfigService.getWebRTCEnabled).to.not.be.undefined; + expect(RtcommConfigService.getChatEnabled).to.not.be.undefined; + expect(RtcommConfigService.getBroadcastVideo).to.not.be.undefined; + expect(RtcommConfigService.getBroadcastAudio).to.not.be.undefined; + expect(RtcommConfigService.getRingTone).to.not.be.undefined; + expect(RtcommConfigService.getRingBackTone).to.not.be.undefined; + expect(RtcommConfigService.getRtcommDebug).to.not.be.undefined; + expect(RtcommConfigService.isRtcommDisabled).to.not.be.undefined; + expect(RtcommConfigService.getMediaConfig).to.not.be.undefined; + }); + + + + + describe('default configuration values', function() { it('should have a default provider configuration', function() { - var providerConfig = RtcommConfigService.getProviderConfig(); - expect(providerConfig).to.deep.equal(defaultConfig); + var providerConfig = RtcommConfigService.getProviderConfig(); + expect(providerConfig).to.deep.equal(defaultConfig); }); - it('webrtc should be enabled', function() { - expect(RtcommConfigService.getWebRTCEnabled()).to.be.true; - }); + it('should have a default media configuration', function() { + var mediaConfig = RtcommConfigService.getMediaConfig(); + expect(mediaConfig).to.deep.equal(defaultMediaConfig); + }); + it('webrtc should be enabled', function() { + expect(RtcommConfigService.getWebRTCEnabled()).to.be.true; + }); - it('chat should be enabeld', function() { - expect(RtcommConfigService.getChatEnabled()).to.be.true; - }); + it('chat should be enabeld', function() { + expect(RtcommConfigService.getChatEnabled()).to.be.true; + }); - it('video broadcast should be enabled', function() { - expect(RtcommConfigService.getBroadcastVideo()).to.be.true; - }); + it('video broadcast should be enabled', function() { + expect(RtcommConfigService.getBroadcastVideo()).to.be.true; + }); - it('audio broadcast should be enabled', function() { - expect(RtcommConfigService.getBroadcastAudio()).to.be.true; - }); + it('audio broadcast should be enabled', function() { + expect(RtcommConfigService.getBroadcastAudio()).to.be.true; + }); - it('ringtone should be null', function() { + it('ringtone should be null', function() { - expect(RtcommConfigService.getRingTone()).to.be.null; - }); + expect(RtcommConfigService.getRingTone()).to.be.null; + }); - it('ringbacktone should be null', function() { + it('ringbacktone should be null', function() { - expect(RtcommConfigService.getRingBackTone()).to.be.null; - }); + expect(RtcommConfigService.getRingBackTone()).to.be.null; + }); - it('rtcomm debug should be on level INFO', function() { - expect(RtcommConfigService.getRtcommDebug()).to.equal('DEBUG'); - }); + it('rtcomm debug should be on level INFO', function() { + expect(RtcommConfigService.getRtcommDebug()).to.equal('DEBUG'); + }); - it('rtcommdisabled should false', function() { - expect(RtcommConfigService.isRtcommDisabled()).to.not.be.true; - }); + it('rtcommdisabled should false', function() { + expect(RtcommConfigService.isRtcommDisabled()).to.not.be.true; }); + }); - it('should set the server correctly', function() { + it('should set the server correctly', function() { - var config = { - server: 'localhost2' - }; + var config = { + server: 'localhost2' + }; - RtcommConfigService.setProviderConfig(config); + RtcommConfigService.setProviderConfig(config); - var rtcommConfig = RtcommConfigService.getProviderConfig(); + var rtcommConfig = RtcommConfigService.getProviderConfig(); - expect(rtcommConfig.server).to.equal(config.server); + expect(rtcommConfig.server).to.equal(config.server); - for (var property in rtcommConfig) { - if (property !== 'server') { - expect(rtcommConfig[property]).to.deep.equal(defaultConfig[property]); - } - } - }); + for (var property in rtcommConfig) { + if (property !== 'server') { + expect(rtcommConfig[property]).to.deep.equal(defaultConfig[property]); + } + } + }); - it('should set the port correctly', function() { - var config = { - port: 8083 - }; + it('should set the port correctly', function() { + var config = { + port: 8083 + }; - RtcommConfigService.setProviderConfig(config); + RtcommConfigService.setProviderConfig(config); - var rtcommConfig = RtcommConfigService.getProviderConfig(); + var rtcommConfig = RtcommConfigService.getProviderConfig(); - expect(rtcommConfig.port).to.equal(config.port); - }); + expect(rtcommConfig.port).to.equal(config.port); + }); - it('should correctly set broadcastAudio and broadcastVideo property', function() { - var config = { - broadcastAudio: false, - broadcastVideo: false - }; + it('should correctly set broadcastAudio and broadcastVideo property', function() { + var config = { + broadcastAudio: false, + broadcastVideo: false + }; - RtcommConfigService.setProviderConfig(config); + RtcommConfigService.setProviderConfig(config); - expect(RtcommConfigService.getBroadcastAudio()).to.equal(false); - expect(RtcommConfigService.getBroadcastVideo()).to.equal(false); + expect(RtcommConfigService.getBroadcastAudio()).to.equal(false); + expect(RtcommConfigService.getBroadcastVideo()).to.equal(false); - config.broadcastAudio = true; + config.broadcastAudio = true; - RtcommConfigService.setProviderConfig(config); + RtcommConfigService.setProviderConfig(config); - expect(RtcommConfigService.getBroadcastAudio()).to.equal(true); - expect(RtcommConfigService.getBroadcastVideo()).to.equal(false); + expect(RtcommConfigService.getBroadcastAudio()).to.equal(true); + expect(RtcommConfigService.getBroadcastVideo()).to.equal(false); - config.broadcastVideo = true; + config.broadcastVideo = true; - RtcommConfigService.setProviderConfig(config); - expect(RtcommConfigService.getBroadcastAudio()).to.equal(true); - expect(RtcommConfigService.getBroadcastVideo()).to.equal(true); + RtcommConfigService.setProviderConfig(config); + expect(RtcommConfigService.getBroadcastAudio()).to.equal(true); + expect(RtcommConfigService.getBroadcastVideo()).to.equal(true); - }); + }); -it('should set appContext', function(){ - var config = { - appContext: 'rtcommContext' - }; + it('should set appContext', function() { + var config = { + appContext: 'rtcommContext' + }; - RtcommConfigService.setProviderConfig(config); + RtcommConfigService.setProviderConfig(config); - expect(RtcommConfigService.getProviderConfig().appContext).to.be.equal(config.appContext); -}); + expect(RtcommConfigService.getProviderConfig().appContext).to.be.equal(config.appContext); + }); }); diff --git a/src/js/ui/config.controller.js b/src/js/ui/config.controller.js index e1a92ce..6ea4f8d 100644 --- a/src/js/ui/config.controller.js +++ b/src/js/ui/config.controller.js @@ -51,11 +51,6 @@ $log.debug('RtcommConfigController: configURL = ' + vm.configURL); - vm.setConfig = function(data) { - $log.debug('RtcommConfigController: setting config data:' + data); - RtcommService.setConfig(data); - }; - $scope.init = function(configURL, extendedConfig) { $log.debug('RtcommConfigController: initing configURL = ' + configURL); diff --git a/src/js/ui/config.controller.spec.js b/src/js/ui/config.controller.spec.js index 25cde65..36661aa 100644 --- a/src/js/ui/config.controller.spec.js +++ b/src/js/ui/config.controller.spec.js @@ -19,7 +19,8 @@ describe('Unit Testing: RtcommConfigController', function() { var sandbox; - var $rootScope, RtcommService, $compile, $httpBackend, rtcommConfigGET, rtcommConfig; + var $rootScope, RtcommService, $compile, $httpBackend, rtcommConfigGET, rtcommConfig, $log; + beforeEach(module('rtcomm.templates')); beforeEach(module('angular-rtcomm-ui')); @@ -32,7 +33,7 @@ describe('Unit Testing: RtcommConfigController', function() { RtcommService = $injector.get('RtcommService'); $compile = $injector.get('$compile'); $httpBackend = $injector.get('$httpBackend'); - + $log = $injector.get('$log'); rtcommConfig = { 'rtcommTopicPath': '/rtcomm/', 'createEndpoint': true, @@ -83,6 +84,17 @@ describe('Unit Testing: RtcommConfigController', function() { }); + it('should display an error on accessing the config', function() { + rtcommConfigGET.respond(404, ''); + sandbox.spy($log, 'error'); + + var rtcommConfigDiv = compileRtcommConfigController({}); + + $httpBackend.flush(); + + expect($log.calledOnce); + }); + function compileRtcommConfigController(extendedConfig) { var html = '
'; var configCtrl = $compile(html)($rootScope); diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js index 60cd9ee..67c0d53 100644 --- a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.js @@ -28,10 +28,6 @@ $scope.epCtrlAVConnected = RtcommService.isWebrtcConnected($scope.epCtrlActiveEndpointUUID); $scope.sessionState = RtcommService.getSessionState($scope.epCtrlActiveEndpointUUID); - function getActiveEndpoint() { - return RtcommService.getEndpoint(RtcommService.getActiveEndpoint()); - } - $scope.disconnect = function() { $log.debug('Disconnecting call for endpoint: ' + $scope.epCtrlActiveEndpointUUID); RtcommService.getEndpoint($scope.epCtrlActiveEndpointUUID).disconnect(); diff --git a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js index 75d7e08..d185072 100644 --- a/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js +++ b/src/js/ui/endpoint/endpoint-controller/endpoint.controller.spec.js @@ -18,12 +18,13 @@ describe('Unit Testing: Endpoint Controller', function() { //Dependency var RtcommService; - + var ctrl, scope; //Utilities - var $compile; + var $compile, $rootScope, $controller; //Mock and stubbing var sandbox; + var endpointEvents = ['session:started', 'session:stopped', 'session:failed']; beforeEach(module('rtcomm.templates')); beforeEach(module('angular-rtcomm-ui')); @@ -33,7 +34,7 @@ describe('Unit Testing: Endpoint Controller', function() { RtcommService = $injector.get('RtcommService'); $compile = $injector.get('$compile'); $rootScope = $injector.get('$rootScope'); - + $controller = $injector.get('$controller'); })); @@ -53,9 +54,181 @@ describe('Unit Testing: Endpoint Controller', function() { sandbox.stub(RtcommService, 'getSessionState', function() { return 'session:stopped'; }); + scope = $rootScope.$new(); + ctrl = $controller('RtcommEndpointController', { + $scope: scope + }); + + compileRtcommEndpointController(); }); - it('should enable webrtc on the current active endpoint', function() { + describe('behavior when receiving events from the same endpoint', function() { + var endpoint = null; + beforeEach(function() { + endpoint = { + id: 'MOCK_ID' + }; + }); + + it('should change state accordingly to session events', function() { + + endpointEvents.forEach(function(eventName) { + $rootScope.$broadcast(eventName, { + endpoint: endpoint + }); + $rootScope.$digest(); + + expect(scope.sessionState).to.equal(eventName); + + }); + }); + + it('should activate the AV Connected flag', function() { + + $rootScope.$broadcast('webrtc:connected', { + endpoint: endpoint + }); + + $rootScope.$digest(); + + expect(scope.epCtrlAVConnected).to.be.true; + }); + + it('should deactivate the AV Connected flag', function() { + $rootScope.$broadcast('webrtc:disconnected', { + endpoint: endpoint + }); + + $rootScope.$digest(); + + expect(scope.epCtrlAVConnected).to.be.false; + }); + }); + + /* The controller depends readily on the events that are happening, + * need to test how its functions and states vary in each event + */ + describe('behavior when receiving events from a non-active endpoint', function() { + + var endpoint = { + id: 'WRONG_MOCK_ID' + }; + + + it('should maintain the same state if events are from a non active endpoint', function() { + + endpointEvents.forEach(function(eventName) { + $rootScope.$broadcast(eventName, { + endpoint: { + id: 'WRONG_MOCK_ID' + } + }); + $rootScope.$digest(); + + expect(scope.sessionState).to.equal('session:stopped'); + + }); + }); + + it('should not change the AV Connected flag', function() { + scope.epCtrlAVConnected = false; + $rootScope.$broadcast('webrtc:connected', { + endpoint: endpoint + }); + + $rootScope.$digest(); + expect(scope.epCtrlAVConnected).to.be.false; + + scope.epCtrlAVConnected = true; + $rootScope.$broadcast('webrtc:disconnected', { + endpoint: endpoint + }); + $rootScope.$digest(); + + expect(scope.epCtrlAVConnected).to.be.true; + }); + }); + + + it('should switch active endpoint on active endpoint event', function() { + var activeEndpoint = { + id: 'NEW_ID' + } + $rootScope.$broadcast('endpointActivated', activeEndpoint.id); + $rootScope.$digest(); + + expect(scope.epCtrlActiveEndpointUUID).to.equal(activeEndpoint.id); + expect(scope.epCtrlAVConnected).to.be.false; + + }); + + it('should disable the AV flag when no endpoint is activated', function() { + scope.epCtrlAVConnected = true; + $rootScope.$broadcast('noEndpointActivated'); + + $rootScope.$digest(); + + expect(scope.epCtrlAVConnected).to.be.false; + }); + + describe('Testing external methods', function() { + + it('should call disconnect on the active endpoint', function() { + var endpoint = { + disconnect: function() {} + } + sandbox.stub(endpoint, 'disconnect'); + sandbox.stub(RtcommService, 'getEndpoint', function() { + return endpoint; + }); + + scope.disconnect(); + + expect(RtcommService.getEndpoint.calledWith('MOCK_ID')).to.be.true; + expect(endpoint.disconnect.calledOnce).to.be.true; + + }); + + it('should toggleAV depending on the state of the connection', function(){ + var webrtc = { + enable: function(){}, + disable: function(){} + }, + endpoint = {}; + sandbox.stub(webrtc, 'enable'); + + sandbox.stub(webrtc, 'disable'); + endpoint.webrtc = webrtc; + sandbox.stub(RtcommService, 'getEndpoint', function(){ return endpoint}); + scope.epCtrlAVConnected = false; + scope.toggleAV(); + + expect(RtcommService.getEndpoint.calledWith('MOCK_ID')).to.be.true; + expect(webrtc.enable.calledOnce).to.be.true; + + //Force webrtc.enable to throw an error + webrtc.enable.restore(); + sandbox.stub(webrtc, 'enable', function(func){ func(false)}); + sandbox.stub(RtcommService, 'alert'); + scope.toggleAV(); + + expect(RtcommService.getEndpoint.calledWith('MOCK_ID')).to.be.true; + expect(webrtc.enable.called).to.be.true; + + scope.epCtrlAVConnected = true; + + scope.toggleAV(); + expect(RtcommService.getEndpoint.calledWith('MOCK_ID')).to.be.true; + expect(webrtc.disable.called).to.be.true; + + }); + }); + + function compileRtcommEndpointController() { + var html = ' < div ng - controller = "RtcommEndpointController" > < /div>'; + var configCtrl = $compile(html)($rootScope); + return configCtrl; + } }); From 2a9e1b7b13d7d274d09305b8ae58963ec1599699 Mon Sep 17 00:00:00 2001 From: "Jose F. Martinez" Date: Tue, 29 Mar 2016 11:19:17 -0400 Subject: [PATCH 21/21] Added basic e2e integration testing (moved test to the root directory), updated package.json to include integration testing script --- README.md | 68 ++++-- dist/angular-rtcomm.js | 4 +- dist/angular-rtcomm.min.js | 4 +- karma.conf.js | 112 +++++----- package.json | 4 +- .../session-conf.js => protractor.conf.js | 29 +-- src/test/angular-rtcomm-directives.js | 91 -------- src/test/index.html | 69 ------ src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp | Bin 12288 -> 0 bytes src/test/rtcomm-chat/rtcomm-chat.spec.js | 27 --- .../rtcomm-video-integration.spec.js | 62 ------ test/angular-rtcomm-directives.js | 202 ++++++++++++++++++ .../lib/browser-config-generator.js | 0 {src/test => test}/rtcomm-chat/index.html | 0 test/rtcomm-chat/rtcomm-chat.spec.js | 113 ++++++++++ .../rtcomm-chat}/script.js | 2 +- {src/test => test}/rtcomm-video/index.html | 0 .../rtcomm-video-integration.spec.js | 83 +++++++ .../rtcomm-video}/script.js | 0 test/sample/index.html | 111 ++++++++++ test/sample/integration.spec.js | 156 ++++++++++++++ test/sample/sampleConfig.json | 9 + test/server.js | 27 +++ 23 files changed, 817 insertions(+), 356 deletions(-) rename src/test/session-conf.js => protractor.conf.js (55%) delete mode 100644 src/test/angular-rtcomm-directives.js delete mode 100644 src/test/index.html delete mode 100644 src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp delete mode 100644 src/test/rtcomm-chat/rtcomm-chat.spec.js delete mode 100644 src/test/rtcomm-video/rtcomm-video-integration.spec.js create mode 100644 test/angular-rtcomm-directives.js rename {src/test => test}/lib/browser-config-generator.js (100%) rename {src/test => test}/rtcomm-chat/index.html (100%) create mode 100644 test/rtcomm-chat/rtcomm-chat.spec.js rename {src/test/rtcomm-video => test/rtcomm-chat}/script.js (90%) rename {src/test => test}/rtcomm-video/index.html (100%) create mode 100644 test/rtcomm-video/rtcomm-video-integration.spec.js rename {src/test/rtcomm-chat => test/rtcomm-video}/script.js (100%) create mode 100644 test/sample/index.html create mode 100644 test/sample/integration.spec.js create mode 100644 test/sample/sampleConfig.json create mode 100644 test/server.js diff --git a/README.md b/README.md index 2b9428b..8a5583b 100644 --- a/README.md +++ b/README.md @@ -4,33 +4,55 @@ This repository contains the Rtcomm Angular.js module. The Rtcomm Angular module This module is built on the [rtcomm.js](https://github.com/WASdev/lib.rtcomm.clientjs) open source JavaScript library which wraps [WebRTC](http://www.webrtc.org/) with call signaling and a number of advanced real-time communications capabilities like presence and chat. -##Requirements +## Requirements Rtcomm utilizes MQTT for call signaling so at a minimum you will need an MQTT message broker that supports web sockets. There are many open source and productized versions of MQTT message brokers available. A great option is to download the WebSphere Liberty Server which includes an embedded MQTT broker and a number of backend Rtcomm services such as call queueing. The WebSphere Liberty server is free for development and the beta version that includes support for MQTT can be downloaded from [here](https://developer.ibm.com/wasdev/downloads/liberty-profile-beta/). -##Install +## Install To install the angular-rtcomm module for use in an AngularJS application, you can use bower: **bower install angular-rtcomm** -##Build -To build the angular-rtcomm module, you can use npm: +## Build +To build the angular-rtcomm module, you can use npm and [Grunt](http://gruntjs.com/): +``` +npm install +grunt build +``` This is useful if you want to modify the angular-rtcomm templates. -##Test -This repository relies on Karma for testing. To run the test framework you can type the following in the root lib.angular-rtcomm directory: +## Test + +This repository relies on [Karma](https://github.com/karma-runner/karma) and [Protractor](http://www.protractortest.org/) for Unit and Integration testing respectively. + +To run Unit Tests against this project: -**karma start** +``` +karma start karma.conf.js +``` -Note that the test framework assumes the MQTT broker is running on localhost:9080. There is also currently a dependency on the WebSphere Liberty server (which includes an embedded MQTT broker) for some of the Rtcomm features. The link to download a version of WebSphere Liberty for development and testing can be found at the top of the page. +Integration Testing requires more previous configuration. First you'll want to update and start a Selenium Webdriver server on your machine: -We are working on an npm install of the development environment so stay tuned. +``` +$ node_modules/.bin/webdriver-manager update +$ node_modules/.bin/webdriver-manager start +``` + +Once that is setup you can simply start the MQTT broker + Static Server combo: + +``` +npm start +``` + +And finally, run the integration test: +``` +npm test +``` -A sample page is also included in the test directory along with a sample config file that can be used to run the test. -##Usage +## Usage -###Initialization +### Initialization To use the module, you will need to include the following js and css files with your project: First the angular-rtcomm related files: @@ -64,12 +86,12 @@ The above dependencies can be accessed via CDN as above or via your bower_compon We are also working to reduce the number of dependencies (or to at least provide more flexibility in when these dependencies are required). -###Module injection +### Module injection AngularJS applications inject the angular-rtcomm module as follows: var sampleModule = angular.module('sampleModule', ['angular-rtcomm']); -###RtcommService +### RtcommService The RtcommService is the singleton that controls all aspects of the Rtcomm module. Its the only service AngularJS applications need to inject when using the angular-rtcomm module. The RtcommService broadcasts all its related events to the $rootScope. The events published by the RtcommService are a combination of events generated by the angular-rtcomm module and the rtcomm.js library described above that this module wraps. Here is the list of events: @@ -128,53 +150,53 @@ And the methods exposed by the RtcommService include the following: * setVideoView -###List of AngularJS directives +### List of AngularJS directives Here is a complete list of all the currently supported directives. -####rtcomm-register: +#### rtcomm-register: Directive used to register an endpoint. Registration implies creation of a user record as a retained message on the configured presence topic which can be accessed by any endpoint or service that has permissions to subscribe on the registration topic. This is registration is required after initialization. If the user name is specified in advance, for example via a cookie, the userid can be specified when initializing the RtcommService: ```html ``` No init parameters. -####rtcomm-queues: +#### rtcomm-queues: Directive used to view and join any available call queue. Can be used by helpdesk agents (only availble when working with WebSphere): ```html ``` -####rtcomm-presence: +#### rtcomm-presence: Directive used to view presence information: ```html ``` -####rtcomm-chat: +#### rtcomm-chat: Directive used to display a chat window: ```html ``` -####rtcomm-video: +#### rtcomm-video: Directive that contains a WebRTC video window (both self and remote views): ```html ``` -####rtcomm-endpoint-status: +#### rtcomm-endpoint-status: Directive that displays status about the active endpoint: ```html ``` -####rtcomm-sessionmgr: +#### rtcomm-sessionmgr: Directive that manages multiple endpoints and their associated sessions. For instance, used by a helpdesk agent to manage multiple sessions: ```html ``` -###List of AngularJS Controllers +### List of AngularJS Controllers This controller can read configuration from a specified JSON file: **RtcommConfigController** diff --git a/dist/angular-rtcomm.js b/dist/angular-rtcomm.js index 582d22c..fcab06b 100644 --- a/dist/angular-rtcomm.js +++ b/dist/angular-rtcomm.js @@ -14,7 +14,7 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-25 + * @version v1.0.3 - 2016-03-29 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ @@ -518,7 +518,7 @@ angular function activate() { myEndpointProvider = new rtcomm.EndpointProvider(); -// myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); + myEndpointProvider.setLogLevel(RtcommConfigService.getRtcommDebug()); $log.debug('rtcomm-service - endpointProvider log level is: ' + myEndpointProvider.getLogLevel()); $log.debug('rtcomm-service - endpointProvider log level should be: ' + RtcommConfigService.getRtcommDebug()); diff --git a/dist/angular-rtcomm.min.js b/dist/angular-rtcomm.min.js index a06904a..6f51c0a 100644 --- a/dist/angular-rtcomm.min.js +++ b/dist/angular-rtcomm.min.js @@ -14,9 +14,9 @@ * limitations under the License. * * Angular module for Rtcomm - * @version v1.0.3 - 2016-03-25 + * @version v1.0.3 - 2016-03-29 * @link https://github.com/WASdev/lib.angular-rtcomm * @author Brian Pulito (https://github.com/bpulito) */ -!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var c=null;return"undefined"==typeof a||null===a?(b.debug("getEndpoint: create new endpoint"),c=_.createRtcommEndpoint()):(b.debug("getEndpoint: get an endpoint with id -> "+a),c=_.getRtcommEndpoint(a)),c}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), +!function(){angular.module("angular-rtcomm",["ui.bootstrap","treeControl","angular-rtcomm-ui","angular-rtcomm-presence","angular-rtcomm-service"])}(),function(){"use strict";angular.module("angular-rtcomm-service",[])}(),function(){angular.module("angular-rtcomm-ui",["ui.bootstrap","angular-rtcomm-service"])}(),function(){function a(a,b){return{restrict:"E",templateUrl:"templates/rtcomm/rtcomm-presence.html",controller:["$scope","$rootScope",function(c,d){c.monitorTopics=[],c.presenceData=[],c.expandedNodes=[],c.protocolList={chat:!0,webrtc:!1},c.flatten=!1,c.treeOptions={nodeChildren:"nodes",dirSelectable:!0,injectClasses:{ul:"a1",li:"a2",liSelected:"a7",iExpanded:"a3",iCollapsed:"a4",iLeaf:"a5",label:"a6",labelSelected:"a8"}},c.init=function(a){c.protocolList.chat="boolean"==typeof a.chat?a.chat:c.protocolList.chat,c.protocolList.webrtc="boolean"==typeof a.webrtc?a.webrtc:c.protocolList.webrtc,c.flatten="boolean"==typeof a.flatten?a.flatten:c.flatten},c.onCallClick=function(b){var e=a.getEndpoint();a.setActiveEndpoint(e.id),1==c.protocolList.chat&&e.chat.enable(),1==c.protocolList.webrtc&&e.webrtc.enable(function(b,c){b||a.alert({type:"danger",msg:c})}),e.connect(b),d.$broadcast("rtcomm::presence-click")},c.$on("rtcomm::init",function(d,e,f){a.publishPresence();var g=a.getPresenceMonitor();g.on("updated",function(a){b.debug("<<------rtcommPresence: updated------>>"),c.flatten&&(b.debug("<<------rtcommPresence: updated using flattened data ------>>"),c.presenceData=a[0].flatten()),c.$apply()}),c.flatten||(c.presenceData=g.getPresenceData()),c.presenceData.length>=1&&c.expandedNodes.push(c.presenceData[0]);for(var h=0;h> - Event: queueupdate"),b.debug("queueupdate",c),a.$evalAsync(function(){a.$broadcast("queueupdate",c)})}),_.on("newendpoint",function(c){b.debug("<<------rtcomm-service------>> - Event: newendpoint remoteEndpointID: "+c.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast("newendpoint",c)})}),_.setRtcommEndpointConfig({onetimemessage:function(c){if(b.debug("<<------- rtcomm-service ----->> - Event: "+c),"undefined"!==c.onetimemessage.type&&"iFrameURL"===c.onetimemessage.type){var e=c.endpoint.id,f=d.getSession(e);null===f&&(f=d.createSession(e)),f.iFrameURL=c.onetimemessage.iFrameURL,a.$evalAsync(function(){a.$broadcast("rtcomm::iframeUpdate",c.endpoint.id,c.onetimemessage.iFrameURL)})}},"session:started":function(a){b.debug("<<------rtcomm-service------>> - Event: "+a.eventName+" remoteEndpointID: "+a.endpoint.getRemoteEndpointID());var c=a.endpoint.id,e=a.endpoint,f=d.getSession(c);null===f?b.error("Session:started but a previous session hasn't been created!"):(m(c),f.started=!0,f.remoteEndpointID=e.getRemoteEndpointID(),h(a))},"session:alerting":f,"session:trying":f,"session:ringing":f,"session:queued":f,"session:failed":function(a){d.removeSession(a.endpoint.id),h(a)},"session:stopped":function(a){d.removeSession(a.endpoint.id),h(a)},"webrtc:connected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!0,h(a))},"webrtc:remotemuted":function(a){h(a)},"webrtc:disconnected":function(a){var b=d.getSession(a.endpoint.id);null!==b&&(b.webrtcConnected=!1),h(a)},"chat:connected":h,"chat:disconnected":h,"chat:message":function(a){var b={time:new Date,name:a.message.from,message:angular.copy(a.message.message)},c=d.getSession(a.endpoint.id);null!==c&&(c.chats.push(b),h(a))},destroyed:h})}function h(c){b.debug("<<------rtcomm-service------>> - Event: "+c.eventName+" remoteEndpointID: "+c.endpoint.getRemoteEndpointID()),a.$evalAsync(function(){a.$broadcast(c.eventName,c)})}function i(){return null==Y&&(Y={state:"available",userDefines:[]}),Y}function j(d){b.debug("<<------rtcomm-service------>> - Event: Provider init succeeded"),null!=Y&&(b.debug("RtcommService: initSuccess: updating presence record"),_.publishPresence(Y)),a.$evalAsync(function(){var b={ready:d.ready,registered:d.registered,endpoint:d.endpoint,userid:c.getProviderConfig().userid};a.$broadcast("rtcomm::init",!0,b)})}function k(c){b.debug("<<------rtcomm-service------>> - Event: Provider init failed: error: ",c),a.$evalAsync(function(){a.$broadcast("rtcomm::init",!1,c)})}function l(a){var c=null;return"undefined"==typeof a||null===a?(b.debug("getEndpoint: create new endpoint"),c=_.createRtcommEndpoint()):(b.debug("getEndpoint: get an endpoint with id -> "+a),c=_.getRtcommEndpoint(a)),c}function m(b){var c=n();if(null!==c&&c!==b){var e=d.getSession(c);null!==e&&(e.activated=!1)}var e=d.getSession(b);null===e&&(e=d.createSession(b)),e.activated=!0,a.$broadcast("endpointActivated",b)}function n(){for(var a=null,b=d.getAllSessions(),c=0;c-1&&c.chat.enable(),b.indexOf("webrtc")>-1){var d=!0;b.indexOf("disableTrickleICE")>-1&&(d=!1),c.webrtc.enable({trickleICE:d})}return m(c.id),c.connect(a),c.id}function N(){return d.getAllSessions()}function O(a){a.disconnect()}function P(a){m(a)}function Q(){return n()}function R(a){var b=null;if(null!=a){var c=d.getSession(a);null!=c&&(b=c.remoteEndpointID)}return b}function S(){Z="selfView",$="remoteView"}function T(a,b){Z=a,$=b}function U(a){b.debug("rtcommVideo: setting local media");var c=null;"undefined"!=typeof a&&null!==a?c=l(a):null!=n()&&(c=l(n())),null!=c&&(b.debug(c),c.webrtc.setLocalMedia({mediaOut:document.querySelector("#"+Z),mediaIn:document.querySelector("#"+$)}))}var V={alert:o,isInitialized:p,setConfig:q,getPresenceMonitor:r,publishPresence:s,addToPresenceRecord:t,removeFromPresenceRecord:u,setPresenceRecordState:v,getEndpoint:w,destroyEndpoint:x,register:y,unregister:z,joinQueue:A,leaveQueue:B,getQueues:C,sendChatMessage:D,getChats:E,isWebrtcConnected:F,getSessionState:G,setAlias:H,setUserID:I,setPresenceTopic:J,getIframeURL:K,putIframeURL:L,placeCall:M,getSessions:N,endCall:O,setActiveEndpoint:P,getActiveEndpoint:Q,getRemoteEndpoint:R,setDefaultViewSelector:S,setViewSelector:T,setVideoView:U},W=!1,X=null,Y=null,Z="selfView",$="remoteView",_=null;return g(),V}angular.module("angular-rtcomm-service").config(["$logProvider",function(a){a.debugEnabled(!0)}]).constant("rtcomm",rtcomm).factory("RtcommService",a),a.$inject=["$rootScope","$log","RtcommConfigService","RtcommSessions","rtcomm","$http"]}(),function(){"use strict";function a(a){function b(){return h}function c(b){a.debug("Retrieving session linked to EndpointUUID: "+b);var c=null;return h.forEach(function(a){a.endpointUUID===b&&(c=a)}),c}function d(b){a.debug("Creating a session for EndpointUUID: "+b);var c;return c={endpointUUID:b,remoteEndpointID:null,chats:[],webrtcConnected:!1,started:!1,state:"session:stopped",activated:!0,iFrameURL:"about:blank"},h.push(c),c}function e(b,d){a.debug("Updating session for EndpointUUID: "+b);var e=c(b);if("undefined"==typeof e)a.debug("Unable to update endpoint due to it not existing");else for(var f in e)e.hasOwnProperty(f)&&(e[f]="undefined"!=typeof d[f]?d[f]:e[f]);return e}function f(b){a.debug("Destroy session for EndpointUUID: "+b);for(var c,d=0;d0&&(f.bind("scroll",function(){f.prop("scrollTop")+f.prop("clientHeight")==f.prop("scrollHeight")?e.scrollToBottom(!0):e.scrollToBottom(!1)}),a.$watch(function(){return e.chats},function(){c.debug("rtcommChat - Link > $watch on chats called"),g&&f.scrollTop(f.prop("scrollHeight"))},!0))}var e={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-chat.html",link:d,controller:b,controllerAs:"chatVM",bindToController:!0};return e}function b(a,b,c){var d=this;d.chatActiveEndpointUUID=b.getActiveEndpoint(),d.chats=b.getChats(d.chatActiveEndpointUUID),d.keySendMessage=function(a){13===a.which&&d.sendMessage()},d.sendMessage=function(){c.debug("rtcommChat: sendMessage() -> "+d.message);var e={time:new Date,name:b.getEndpoint(d.chatActiveEndpointUUID).getLocalEndpointID(),message:angular.copy(d.message)};d.message="",d.scrollToBottom(!0),a.bottom=!0,b.sendChatMessage(e,d.chatActiveEndpointUUID)},a.$on("endpointActivated",function(a,e){c.debug("rtcommChat: endpointActivated ="+e),d.chats=b.getChats(e),d.chatActiveEndpointUUID=e}),a.$on("noEndpointActivated",function(a){d.chats=[],d.chatActiveEndpointUUID=null})}angular.module("angular-rtcomm-ui").directive("rtcommChat",a),a.$inject=["RtcommService","$log"],b.$inject=["$scope","RtcommService","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-endpoint-status.html",controller:b,controllerAs:"endpointStatusVM",bindToController:!0};return a}function b(a,b,c){var d=this;d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason="",d.queueCount=0,b.$on("session:started",function(a,b){c.debug("session:started received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID===b.endpoint.id&&(d.sessionState="session:started",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:stopped",function(a,b){c.debug("session:stopped received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)}),b.$on("session:failed",function(a,b){c.debug("session:failed received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:failed",d.failureReason=b.reason,d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:alerting",function(a,b){c.debug("session:alerting received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID!=b.endpoint.id&&(d.sessionState="session:alerting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:connecting",function(a,b){c.debug("session:connecting received: endpointID = "+b.endpoint.id),d.sessionState="session:connecting",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID()}),b.$on("session:queued",function(a,b){c.debug("session:queued received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:queued",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:trying",function(a,b){c.debug("session:trying received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:trying",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("session:ringing",function(a,b){c.debug("session:ringing received: endpointID = "+b.endpoint.id),d.epCtrlActiveEndpointUUID==b.endpoint.id&&(d.sessionState="session:ringing",d.epCtrlRemoteEndpointID=b.endpoint.getRemoteEndpointID())}),b.$on("endpointActivated",function(b,c){d.epCtrlActiveEndpointUUID=c,d.epCtrlRemoteEndpointID=a.getEndpoint(c).getRemoteEndpointID(),d.sessionState=a.getSessionState(c)}),b.$on("noEndpointActivated",function(a){d.epCtrlRemoteEndpointID=null,d.sessionState="session:stopped"}),b.$on("rtcomm::init",function(b,c,e){c===!0&&(d.epCtrlActiveEndpointUUID=a.getActiveEndpoint(),d.epCtrlRemoteEndpointID=a.getRemoteEndpoint(d.epCtrlActiveEndpointUUID),d.sessionState=a.getSessionState(d.epCtrlActiveEndpointUUID),d.failureReason=""),0==c&&(d.sessionState="session:stopped",d.epCtrlRemoteEndpointID=null)})}angular.module("angular-rtcomm-ui").directive("rtcommEndpointStatus",a),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-iframe.html",controller:b,controllerAs:"iframeVM",bindToController:!0};return a}function b(a,b,c,d,e,f){var g=this;g.iframeActiveEndpointUUID=a.getActiveEndpoint(),g.iframeURL=null,g.initiframeURL=null,g.syncSource=!1,e.init=function(a){a===!0&&(g.syncSource=!0,g.initiframeURL=c.absUrl())},g.setURL=function(c){f.debug("rtcommIframe: setURL: newURL: "+c),a.putIframeURL(g.iframeActiveEndpointUUID,c),g.iframeURL=b.trustAsResourceUrl(c)},g.forward=function(){},g.backward=function(){},e.$on("session:started",function(b,c){f.debug("session:started received: endpointID = "+c.endpoint.id),1==g.syncSource&&a.putIframeURL(c.endpoint.id,g.initiframeURL)}),e.$on("endpointActivated",function(c,d){f.debug("rtcommIframe: endpointActivated ="+d),0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl(a.getIframeURL(d)),g.iframeActiveEndpointUUID=d)}),e.$on("noEndpointActivated",function(a){0==g.syncSource&&(g.iframeURL=b.trustAsResourceUrl("about:blank"),g.iframeActiveEndpointUUID=null)}),e.$on("rtcomm::iframeUpdate",function(a,c,e){g.syncSource===!1?(f.debug("rtcomm::iframeUpdate: "+e),e+="?disableRtcomm=true",g.iframeURL=b.trustAsResourceUrl(e)):(f.debug("rtcomm::iframeUpdate: load this url in a new tab: "+e),d.open(b.trustAsResourceUrl(e),"_blank"))})}angular.module("angular-rtcomm-ui").directive("rtcommIframe",a),b.$inject=["RtcommService","$sce","$location","$window","$scope","$log"]}(),function(){"use strict";function a(){var a={restrict:"E",templateUrl:"templates/rtcomm/rtcomm-video.html",controller:b,controllerAs:"videoVM",bindToController:!0};return a}function b(a,b,c){var d=this;c.debug("VideoController Starting"),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint());var e=a.getActiveEndpoint();"undefined"!=typeof e&&null!=e&&a.setVideoView(e),b.$on("endpointActivated",function(b,e){c.debug("rtcommVideo: endpointActivated ="+e),a.setVideoView(e),d.avConnected=a.isWebrtcConnected(a.getActiveEndpoint())})}angular.module("angular-rtcomm-ui").directive("rtcommVideo",a).controller("RtcommVideoController",b),b.$inject=["RtcommService","$scope","$log"]}(),function(){"use strict";function a(a,b,c,d,e){var f=this;f.alertingEndpointUUID=null,f.autoAnswerNewMedia=!1,f.alertActiveEndpointUUID=a.getActiveEndpoint(),f.caller=null,f.showAlerting=function(d){var g=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-alert.html",controller:"RtcommAlertModalInstanceController",size:d,backdrop:"static",resolve:{caller:function(){return f.caller}}});g.result.then(function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Accepting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.accept(),c.$broadcast("rtcomm::alert-success"),b=null)},function(){var b=a.getEndpoint(f.alertingEndpointUUID);b&&(e.debug("Rejecting call from: "+f.caller+" for endpoint: "+f.alertingEndpointUUID),b.reject(),b=null)})},d.init=function(a){e.debug("rtcommAlert: autoAnswerNewMedia = "+a),f.autoAnswerNewMedia=a},d.$on("endpointActivated",function(a,b){f.alertActiveEndpointUUID=b}),d.$on("session:alerting",function(a,b){f.alertActiveEndpointUUID==b.endpoint.id&&0==f.autoAnswerNewMedia||f.alertActiveEndpointUUID!=b.endpoint.id?(e.debug("rtcommAlert: display alterting model: alertActiveEndpointUUID = "+b.endpoint+" autoAnswerNewMedia = "+f.autoAnswerNewMedia),f.caller=b.endpoint.getRemoteEndpointID(),f.alertingEndpointUUID=b.endpoint.id,f.showAlerting()):(e.debug("Accepting media from: "+b.endpoint.getRemoteEndpointID()+" for endpoint: "+b.endpoint.id),b.endpoint.accept())})}function b(a,b,c,d){a.caller=d,a.ok=function(){c.debug("Accepting alerting call"),b.close()},a.cancel=function(){c.debug("Rejecting alerting call"),b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommAlertModalController",a).controller("RtcommAlertModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$rootScope","$scope","$log"],b.$inject=["$scope","$uibModalInstance","$log","caller"]}(),function(){"use strict";function a(a,b,c,d){var e=this;e.calleeID=null,e.callerID=null,e.enableCallModel=!1,e.mediaToEnable=["chat"],e.init=function(a,b){e.calleeID=a,"undefined"!=typeof b&&(e.mediaToEnable=b)},e.placeCall=function(c){var f=b.open({templateUrl:"templates/rtcomm/rtcomm-modal-call.html",controller:"RtcommCallModalInstanceController",size:c,resolve:{}});f.result.then(function(b){d.debug("rtcommCallModal: Calling calleeID: "+e.calleeID),d.debug("rtcommCallModal: CallerID: "+b),null==e.callerID&&"undefined"!=typeof b&&""!=b&&(e.callerID=b,a.setAlias(b)),a.placeCall(e.calleeID,e.mediaToEnable)},function(){d.info("Modal dismissed at: "+new Date)})},c.$on("rtcomm::init",function(a,b,c){d.debug("RtcommCallModalController: rtcomm::init: success = "+b),1==b?e.enableCallModel=!0:e.enableCallModel=!1}),c.$on("session:started",function(a,b){e.enableCallModel=!1}),c.$on("session:stopped",function(a,b){e.enableCallModel=!0})}function b(a,b,c){a.endpointAlias="",a.ok=function(){b.close(a.endpointAlias)},a.cancel=function(){b.dismiss("cancel")}}angular.module("angular-rtcomm-ui").controller("RtcommCallModalController",a).controller("RtcommCallModalInstanceController",b),a.$inject=["RtcommService","$uibModal","$scope","$log"],b.$inject=["$scope","$uibModalInstance","RtcommService"]}(),angular.module("angular-rtcomm-ui").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-alert.html",'
{{alert.msg}}
'),a.put("templates/rtcomm/rtcomm-chat.html",'
Chat
  • {{chat.name}} {{chat.time | date:\'HH:mm:ss\'}}

    {{chat.message}}

'),a.put("templates/rtcomm/rtcomm-endpoint-status.html",'
'), a.put("templates/rtcomm/rtcomm-iframe.html",'
URL Sharing
'),a.put("templates/rtcomm/rtcomm-modal-alert.html",''),a.put("templates/rtcomm/rtcomm-modal-call.html",''),a.put("templates/rtcomm/rtcomm-queues.html",'
Queues
'),a.put("templates/rtcomm/rtcomm-register.html",'
'),a.put("templates/rtcomm/rtcomm-sessionmgr.html",'
'),a.put("templates/rtcomm/rtcomm-video.html",'
')}]),angular.module("angular-rtcomm-presence").run(["$templateCache",function(a){"use strict";a.put("templates/rtcomm/rtcomm-presence.html",'
{{node.name}} {{node.value ? \': \' + node.value : \'\'}}
')}]); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index f173d70..1790c5c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,79 +2,79 @@ // Generated on Fri Dec 05 2014 13:58:19 GMT-0500 (Eastern Standard Time) module.exports = function(config) { - config.set({ + config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai', 'sinon'], - reporters: ['progress', 'coverage'], - // list of files / patterns to load in the browser - files: [ - 'bower_components/jquery/dist/jquery.js', - 'bower_components/bootstrap/dist/js/bootstrap.js', - 'bower_components/angular/angular.js', - 'bower_components/angular-mocks/angular-mocks.js', - 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', - 'bower_components/angular-tree-control/angular-tree-control.js', - 'bower_components/bower-mqttws/mqttws31.js', - 'bower_components/rtcomm/dist/rtcomm.js', - 'src/templates/**/*.html', - 'src/js/**/*.spec.js', - 'src/js/**/*.module.js', - 'src/js/**/*.js', - ], + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['mocha', 'chai', 'sinon'], + reporters: ['progress', 'coverage'], + // list of files / patterns to load in the browser + files: [ + 'bower_components/jquery/dist/jquery.js', + 'bower_components/bootstrap/dist/js/bootstrap.js', + 'bower_components/angular/angular.js', + 'bower_components/angular-mocks/angular-mocks.js', + 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', + 'bower_components/angular-tree-control/angular-tree-control.js', + 'bower_components/bower-mqttws/mqttws31.js', + 'bower_components/rtcomm/dist/rtcomm.js', + 'src/templates/**/*.html', + 'src/js/**/*.spec.js', + 'src/js/**/*.module.js', + 'src/js/**/*.js', + ], - // list of files to exclude - exclude: [], + // list of files to exclude + exclude: [], - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'src/templates/**/*.html': ['ng-html2js'], - 'src/js/**/!(*.spec).js' : ['coverage'] - }, - coverageReporter: { - type : 'html', - dir : 'coverage/' - }, + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + 'src/templates/**/*.html': ['ng-html2js'], + 'src/js/**/!(*.spec).js': ['coverage'] + }, + coverageReporter: { + type: 'html', + dir: 'coverage/' + }, - ngHtml2JsPreprocessor: { - stripPrefix: 'src/', - moduleName: "rtcomm.templates" - }, + ngHtml2JsPreprocessor: { + stripPrefix: 'src/', + moduleName: 'rtcomm.templates' + }, - // web server port - port: 9876, + // web server port + port: 9876, - // plugins: ["karma-spec-reporter"], + // plugins: ["karma-spec-reporter"], - // enable / disable colors in the output (reporters and logs) - colors: true, + // enable / disable colors in the output (reporters and logs) + colors: true, - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - //browsers: ['Chrome', 'Firefox'], - browsers: ['Chrome'], + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + //browsers: ['Chrome', 'Firefox'], + browsers: ['Chrome', 'Firefox'], - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false - }); + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); }; diff --git a/package.json b/package.json index a5b4347..1d9690f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Angular module for Rtcomm", "main": "Gruntfile.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "start": "node test/server.js", + "test": "node_modules/.bin/protractor protractor.conf.js" }, "repository": { "type": "git", @@ -50,6 +51,7 @@ "karma-spec-reporter": "0.0.24", "load-grunt-tasks": "^1.0.0", "mocha": "^2.0.1", + "mosca": "^1.1.2", "protractor": "^3.1.1", "q": "^1.4.1" } diff --git a/src/test/session-conf.js b/protractor.conf.js similarity index 55% rename from src/test/session-conf.js rename to protractor.conf.js index 99b36fa..8f85392 100644 --- a/src/test/session-conf.js +++ b/protractor.conf.js @@ -4,52 +4,37 @@ var chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); var expect = chai.expect; var q = require('q'); -var RtcommHelper = require('./lib/browser-config-generator.js'); +var RtcommHelper = require('./test/lib/browser-config-generator.js'); ///Define the users in the session var session = [{ browserName: process.env.BROWSER || 'chrome', caller: true -}, { - browserName: process.env.BROWSER || 'chrome', - callee: true }]; + function establishSessionMeta(capabilities) { - var USERS = []; var promises = []; - // var defer = q.defer(); capabilities.forEach(function(cap) { - - cap.USERS = USERS; - USERS.push(cap.userName); - promises.push(RtcommHelper.generateBrowserProfile(cap)); - }); return q.all(promises); } exports.config = { - directConnect: true, - specs: ['**/*.spec.js'], + seleniumAddress: process.env.SELENIUM_ADDRESS || 'http://localhost:4444/wd/hub', + specs: ['test/**/*.spec.js'], + baseUrl: process.env.BASE_URL || 'http://localhost:8083/test/', getMultiCapabilities: function() { return establishSessionMeta(session); }, onPrepare: function() { + global.EC = protractor.ExpectedConditions; global.expect = expect; - // browser.driver.manage().window().maximize(); - - return browser.getProcessedConfig().then(function(config) { -browser.driver.manage().window().maximize(); + browser.driver.manage().window().maximize(); - browser.caller = config.capabilities.caller; - browser.callee = config.capabilities.callee; - browser.userName = config.capabilities.userName; - browser.USERS = config.capabilities.USERS; - }); }, framework: 'mocha', diff --git a/src/test/angular-rtcomm-directives.js b/src/test/angular-rtcomm-directives.js deleted file mode 100644 index 0bb2512..0000000 --- a/src/test/angular-rtcomm-directives.js +++ /dev/null @@ -1,91 +0,0 @@ -'use strict'; - - - -/* globals element */ -/* globals by */ -function AngularRtcommDirectives(browser) { - - - var element = browser.element; - - return { - - rtcommRegister: RtcommRegister, - rtcommAlertModal: rtcommAlertModal, - rtcommVideo: rtcommVideo, - rtcommChat: rtcommChat - }; - - function RtcommRegister() { - this.inputElement = element(by.model('registerVM.reguserid')); - this.button = element(by.id('btn-register')); - this.input = function(user) { - this.inputElement.sendKeys(user); - return this; - }; - - this.clickRegister = function() { - this.button.click(); - return this; - }; - } - - function rtcommVideo() { - this.remoteViewID = 'remoteView'; - this.selfViewID = 'selfView'; - this.remoteView = element(by.id('remoteView')); - this.selfView = element(by.id('selfView')); - - this.waitForVideoReady = function(selector, _ms, _msg) { - var msg = _msg || "Timed out while retrieving video state"; - var ms = _ms || 5000; - - var script = function(selector) { - var callback = arguments[arguments.length - 1]; - - try { - - var video = document.querySelector(selector); - if (video.readyState === 4) { - callback(video.readyState); - } else { - video.onloadeddata = function() { - if (video.readyState === 4) { - callback(video.readyState); - } - }; - } - - } catch (err) { - callback(-1); - } - }; - - return browser.driver.wait(browser.driver.executeAsyncScript(script, [selector]), ms, msg); - } - } - - - - function rtcommChat() { - - this.chats = element(by.css('ul.chat')); - this.send = element(by.id('btn-chat')); - this.input = element(by.model('chatVM.message')); - - } - - function rtcommEndpointStatus() { - this.statusText = element(by.css('p.endpoint-controls-title > span')); - } - - - function rtcommAlertModal() { - - this.ok = element(by.css('[ng-click="ok()"]')); - this.cancel = element(by.css('[ng-click="cancel()"]')); - } -} - -module.exports = AngularRtcommDirectives; diff --git a/src/test/index.html b/src/test/index.html deleted file mode 100644 index 6237b5d..0000000 --- a/src/test/index.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - E2E: rtcomm-video - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
- - -
- -
-
-
- -
- -
- -
- -
- - - - - -
-
- -
- -
- - - diff --git a/src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp b/src/test/rtcomm-chat/.rtcomm-chat.spec.js.swp deleted file mode 100644 index 9ccebaff8c3fb455b6404a9df3f3906475c2a639..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2zi-n(6vwY@8Cp;~P(+aq7~)j5U0Nhip+f~3I&`VjzyQP9c}X1kN4PsDLa4AY zb>~0e-+=!D{sjaQ3qnFdg0Ew@#Z}vh1@un(9*!3$vv5+RMX){zDp5oQ)Dn ztsh5$r_z2NEA48FcM{*|(6?l)Up~9xK-Io`W<;SkG_~yfzy{dBnFey(bMMZI^|f28 zMa<0`*X6?e-kIUN!3Nj>8(;%$fDNz#Hoykh!2f5!j%LIwT zfDNz#Hoykh02^QfY=8~00XDz}{y_t(E5z$rA?D_Ac>Mo=`1}9YMIk<~18m^08`wW*wC)Mf*q?qjL?g0J(+sja?#e_(sRdHWq8nSH>)8&2y5GL`+?yVQ@2B`r5)N)s8z5&FKp`ksTDRrpp++U{gs6`%IP@vhTa zL5Z=_vP|`$IM*p9iuL2zvbwASx5~!z-D%&s6X li')); + + var chats = this.chatElements.map(function(chatMessage, index) { + + return { + name: chatMessage.element(by.css('strong.ng-binding')).getText(), + message: chatMessage.element(by.css('p.ng-binding')).getText() + }; + }); + + return chats; + }; + +} + +function RtcommEndpointStatus() { + this.statusText = element(by.css('p.endpoint-controls-title > span')); +} + +/** + * Represents the rtcomm-alert-modal + */ +function RtcommAlertModal(_browser) { + var browser = _browser; + var element = browser.element; + this.ok = element(by.css('[ng-click="ok()"]')); + this.cancel = element(by.css('[ng-click="cancel()"]')); + + this.waitUntilDisplayed = function(_ms, _msg) { + var msg = _msg || 'Waited too long until alert modal was displayed...'; + var ms = _ms || 5000; + + browser.wait(EC.elementToBeClickable(this.ok), ms, msg); + + }; +} + + +/** + * Represents the rtcomm-presence directive + */ +function RtcommPresence(_browser) { + var browser = _browser; + var element = browser.element; + + this.call = function(name) { + + browser.wait(EC.visibilityOf(element(by.css('div[treecontrol]'))), 5000, + 'Rtcomm-presence tree structure not found -> Possibly not initialized correctly'); + + //Expand the presence tree + expandPresenceTree(); + + function clickNodeToCall() { + var nodes = element.all(by.css('div.tree-label')); + + var calleeNode = nodes.filter(function(node, index) { + var span = node.element(by.css('span.ng-binding')); + return span.getText().then(function(text) { + return text.indexOf(name) > -1; + }); + + }); + + calleeNode.first().element(by.css('button')).click(); + } + + function expandPresenceTree() { + //Find collapsed elements + var collapsedElements = element.all(by.css('.tree-collapsed > i.tree-branch-head')); + + + collapsedElements.count().then(function(count) { + + //If no more collapsed elements exist, you can click on the node to call + if (count === 0) { + + clickNodeToCall(); + } + //Expand the collapsed nodes found + else { + + + collapsedElements.each(function(element, index) { + element.click(); + if (index === count - 1) { + expandPresenceTree(); + } + }); + } + }); + } + }; +} +/** + * Represents the RtcommEndpointController + */ +function RtcommEndpointController(_browser) { + + var browser = _browser; + var element = browser.element; + + this.disconnectBtn = element(by.id('btnDisconnectEndpoint')); + this.toggleAVBtn = element(by.id('btnEnableAV')); + +} + + +module.exports = { + RtcommRegister: RtcommRegister, + RtcommChat: RtcommChat, + RtcommVideo: RtcommVideo, + RtcommAlertModal: RtcommAlertModal, + RtcommPresence: RtcommPresence, + RtcommEndpointController: RtcommEndpointController + +}; diff --git a/src/test/lib/browser-config-generator.js b/test/lib/browser-config-generator.js similarity index 100% rename from src/test/lib/browser-config-generator.js rename to test/lib/browser-config-generator.js diff --git a/src/test/rtcomm-chat/index.html b/test/rtcomm-chat/index.html similarity index 100% rename from src/test/rtcomm-chat/index.html rename to test/rtcomm-chat/index.html diff --git a/test/rtcomm-chat/rtcomm-chat.spec.js b/test/rtcomm-chat/rtcomm-chat.spec.js new file mode 100644 index 0000000..cb514aa --- /dev/null +++ b/test/rtcomm-chat/rtcomm-chat.spec.js @@ -0,0 +1,113 @@ +/* globals browser */ +/* globals by */ +/* globals element */ + +var AngularRtcomm = require('../angular-rtcomm-directives.js'); + +var RtcommChat = AngularRtcomm.RtcommChat; +var RtcommAlertModal = AngularRtcomm.RtcommAlertModal; +var RtcommRegister = AngularRtcomm.RtcommRegister; + +describe('E2E Integration: rtcomm-chat directive with RtcommService', function() { + var newBrowser; + var userOne, userTwo; + beforeEach(function() { + browser.get('rtcomm-chat/'); + newBrowser = browser.forkNewDriverInstance(true); + userOne = createUser(browser); + userTwo = createUser(newBrowser); + }); + + afterEach(function(){ + newBrowser.quit(); + }); + it('should maintain a chat session between users', function() { + //Register User one + userOne.register('UserOne'); + + //Register user two + userTwo.register('UserTwo'); + + //UserOne places a call to UserTwo + userOne.placeCall('UserTwo'); + + //User Two should wait for alert modal + browser.wait(EC.elementToBeClickable(userTwo.rtcommAlertModal.ok), 5000, 'Waited too long for alert modal'); + + //Accept the modal + userTwo.rtcommAlertModal.ok.click(); + + //Send a message to user one + userTwo.rtcommChat.sendChatMessage('Hello World!'); + + browser.driver.sleep(500); + + userOne.rtcommChat.getChatMessages().then(function(messages) { + + expect(messages[0].message).to.equal('Hello World!', 'Should\' received a message in the chat'); + }); + + + userOne.rtcommChat.sendChatMessage('How are you doing!?'); + + userTwo.rtcommChat.sendChatMessage('Pretty good and you?'); + + userOne.rtcommChat.sendChatMessage('Great, just testing out this directive!!!'); + + var conversation = [{ + name: 'UserTwo', + message: 'Hello World!' + }, { + name: 'UserOne', + message: 'How are you doing!?' + }, { + name: 'UserTwo', + message: 'Pretty good and you?' + }, { + name: 'UserOne', + message: 'Great, just testing out this directive!!!' + }]; + + //Verify that both sides of the chats appear + userOne.rtcommChat.getChatMessages().then(function(messages) { + messages.forEach(function(message, index) { + expect(message.name).to.equal(conversation[index].name, 'Incorrect user match in chat'); + expect(message.message).to.equal(conversation[index].message, 'Incorrect message sent in chat'); + }); + }); + + //Verify user two can also see the chats + userTwo.rtcommChat.getChatMessages().then(function(messages) { + messages.forEach(function(message, index) { + expect(message.name).to.equal(conversation[index].name, 'Incorrect user match in chat'); + expect(message.message).to.equal(conversation[index].message, 'Incorrect message sent in chat'); + }); + }); + }); + + + function createUser(browser) { + var user = {}; + user.rtcommChat = new RtcommChat(browser); + user.rtcommRegister = new RtcommRegister(browser); + user.rtcommAlertModal = new RtcommAlertModal(browser); + user.register = function(name) { + + user.rtcommRegister + .input(name) + .clickRegister(); + return this; + }; + + user.placeCall = function(name) { + var input = element(by.model('vm.callee')); + var callBtn = element(by.id('place-call-btn')); + + input.sendKeys(name); + callBtn.click(); + + } + return user; + + } +}); diff --git a/src/test/rtcomm-video/script.js b/test/rtcomm-chat/script.js similarity index 90% rename from src/test/rtcomm-video/script.js rename to test/rtcomm-chat/script.js index 1b19f8a..75fc544 100644 --- a/src/test/rtcomm-video/script.js +++ b/test/rtcomm-chat/script.js @@ -20,7 +20,7 @@ vm.call = function(){ $log.debug('Calling: ' + vm.callee); - RtcommService.placeCall(vm.callee, ['webrtc']); + RtcommService.placeCall(vm.callee, ['chat']); } diff --git a/src/test/rtcomm-video/index.html b/test/rtcomm-video/index.html similarity index 100% rename from src/test/rtcomm-video/index.html rename to test/rtcomm-video/index.html diff --git a/test/rtcomm-video/rtcomm-video-integration.spec.js b/test/rtcomm-video/rtcomm-video-integration.spec.js new file mode 100644 index 0000000..3ffec47 --- /dev/null +++ b/test/rtcomm-video/rtcomm-video-integration.spec.js @@ -0,0 +1,83 @@ +/* globals browser */ +/* globals expect */ +/* globals element */ +/* glboals EC */ +/* globals by */ + +var AngularRtcomm = require('../angular-rtcomm-directives.js'); + +var RtcommVideo = AngularRtcomm.RtcommVideo; +var RtcommAlertModal = AngularRtcomm.RtcommAlertModal; +var RtcommRegister = AngularRtcomm.RtcommRegister; + +describe('E2E Integration: rtcomm-video with RtcommService', function() { + + var newBrowser; + + var userOne, userTwo; + beforeEach(function() { + browser.get('rtcomm-video/'); + + newBrowser = browser.forkNewDriverInstance(true); + userOne = createUser(browser); + userTwo = createUser(newBrowser); + + }); + + afterEach(function() { + newBrowser.quit(); + }); + it('should display the video session between two users', function() { + + //Register user one + userOne.register('UserOne'); + + //Register user two + userTwo.register('UserTwo'); + + + userOne.placeCall('UserTwo'); + + browser.wait(EC.elementToBeClickable(userTwo.rtcommAlertModal.ok), 5000, 'Waited too long for alert moda'); + + userTwo.rtcommAlertModal.ok.click(); + + browser.driver.sleep(3000); + + //Video ready state is supposed to be 4 (READY_STATE ENUM === 4) + + + expect(userOne.rtcommVideo.waitForVideoReady('#selfView', 5000)).to.eventually.equal(4); + expect(userOne.rtcommVideo.waitForVideoReady('#remoteView', 5000)).to.eventually.equal(4); + + + + expect(userTwo.rtcommVideo.waitForVideoReady('#selfView', 5000)).to.eventually.equal(4); + expect(userTwo.rtcommVideo.waitForVideoReady('#remoteView', 5000)).to.eventually.equal(4); + }); + + function createUser(browser) { + + var user = {}; + + user.rtcommVideo = new RtcommVideo(browser); + user.rtcommRegister = new RtcommRegister(browser); + user.rtcommAlertModal = new RtcommAlertModal(browser); + + user.placeCall = function(name) { + var input = element(by.model('vm.callee')); + var callBtn = element(by.id('place-call-btn')); + + input.sendKeys(name); + callBtn.click(); + + } + user.register = function(name) { + user.rtcommRegister + .input(name) + .clickRegister(); + } + return user; + } + +}); diff --git a/src/test/rtcomm-chat/script.js b/test/rtcomm-video/script.js similarity index 100% rename from src/test/rtcomm-chat/script.js rename to test/rtcomm-video/script.js diff --git a/test/sample/index.html b/test/sample/index.html new file mode 100644 index 0000000..7358d54 --- /dev/null +++ b/test/sample/index.html @@ -0,0 +1,111 @@ + + + + + + + + + E2E: Sample Angular-Rtcomm + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ + +
+
+ +
+
+
+
+
+ + + +
+
+ + +
+
+
+
+ Video +
+
+ +
+
+
+
+ Presence +
+
+ +
+
+ +
+
+ + +
+
+
+
+
+ + + diff --git a/test/sample/integration.spec.js b/test/sample/integration.spec.js new file mode 100644 index 0000000..f74309a --- /dev/null +++ b/test/sample/integration.spec.js @@ -0,0 +1,156 @@ +/* globals browser */ +var AngularRtcomm = require('../angular-rtcomm-directives.js'); +var RtcommEndpointController = AngularRtcomm.RtcommEndpointController; +var RtcommChat = AngularRtcomm.RtcommChat; +var RtcommVideo = AngularRtcomm.RtcommVideo; +var RtcommPresence = AngularRtcomm.RtcommPresence; +var RtcommAlertModal = AngularRtcomm.RtcommAlertModal; +var RtcommRegister = AngularRtcomm.RtcommRegister; +/** + * Integration Test for the Sample + */ +describe('E2E Testing: Directives Integration Sample', function() { + + var newBrowser; + var userOne, userTwo; + /** + * Before each test retrieve the url and create a second browser window + */ + beforeEach(function() { + browser.get('sample/'); + newBrowser = browser.forkNewDriverInstance(true); + + //Create users (see below) + userOne = createUser(browser); + userTwo = createUser(newBrowser); + + }); + + //Close the second window after each test spec + afterEach(function() { + newBrowser.quit(); + }); + + + it('each user should be able to register successfully', function() { + + userOne.register('UserOne'); + + userTwo.register('UserTwo'); + + browser.driver.sleep(2000); + }); + + it('should be able to maintain a chat session between users', function() { + //Register both users + userOne.register('UserOne'); + userTwo.register('UserTwo'); + + //Define chat conversation + var conversation = [{ + name: 'UserTwo', + message: 'Hello!' + }, { + name: 'UserOne', + message: 'Hi!' + }, { + name: 'UserOne', + message: 'Do you want to start a video chat?' + }, { + name: 'UserTwo', + message: 'Sure' + } + + ]; + + //Call using the presence directive + userOne.rtcommPresence.call('UserTwo'); + + //Wait for alert modal to show + userTwo.rtcommAlertModal.waitUntilDisplayed(); + + //Click 'ok' + userTwo.rtcommAlertModal.ok.click(); + + //Send chat messages from both sides + conversation.forEach(function(message, index) { + var sendee; + + if (message.name === 'UserTwo') + sendee = userTwo; + else if (message.name === 'UserOne') + sendee = userOne; + sendee.rtcommChat.sendChatMessage(message.message); + }); + + //Expect that user one can see both chats + userOne.rtcommChat.getChatMessages().then(function(messages) { + messages.forEach(function(message, index) { + expect(message.name).to.equal(conversation[index].name, 'Incorrect user match in chat'); + expect(message.message).to.equal(conversation[index].message, 'Incorrect message sent in chat'); + }); + }); + + //Verify user two can also see the chats + userTwo.rtcommChat.getChatMessages().then(function(messages) { + messages.forEach(function(message, index) { + expect(message.name).to.equal(conversation[index].name, 'Incorrect user match in chat'); + expect(message.message).to.equal(conversation[index].message, 'Incorrect message sent in chat'); + }); + }); + + //Now we enable the video + + //Click 'Enable A/V' + userOne.browser.wait(EC.elementToBeClickable(userOne.rtcommEndpointController.toggleAVBtn), 5000, "Wait till the button is clickable"); + expect(userOne.rtcommEndpointController.toggleAVBtn.getText()).to.eventually.equal('Enable A/V', 'Verify the \'Enable A/V\' button is functioning correctly'); + userOne.rtcommEndpointController.toggleAVBtn.click(); + + userTwo.rtcommAlertModal.waitUntilDisplayed(); + + userTwo.rtcommAlertModal.ok.click(); + + browser.driver.sleep(3000); //Let the video play out for a bit + //We should expect to see the video to work + expect(userOne.rtcommVideo.waitForVideoReady('#selfView', 5000)).to.eventually.equal(4); + expect(userOne.rtcommVideo.waitForVideoReady('#remoteView', 5000)).to.eventually.equal(4); + + + + expect(userTwo.rtcommVideo.waitForVideoReady('#selfView', 5000)).to.eventually.equal(4); + expect(userTwo.rtcommVideo.waitForVideoReady('#remoteView', 5000)).to.eventually.equal(4); + }); + + function createUser(browser) { + var user = {}; + user.browser = browser; + user.rtcommChat = new RtcommChat(browser); + user.rtcommRegister = new RtcommRegister(browser); + user.rtcommAlertModal = new RtcommAlertModal(browser); + user.rtcommVideo = new RtcommVideo(browser); + user.rtcommPresence = new RtcommPresence(browser); + user.rtcommEndpointController = new RtcommEndpointController(browser); + user.register = function(name) { + + user.rtcommRegister + .input(name) + .clickRegister(); + + user.browser.wait(EC.not(EC.elementToBeClickable(user.rtcommRegister.inputElement)), 5000); + expect(user.rtcommRegister.inputElement.getAttribute('value')).to.eventually.equal(name); + return this; + }; + + + user.placeCall = function(name) { + var input = element(by.model('vm.callee')); + var callBtn = element(by.id('place-call-btn')); + + input.sendKeys(name); + callBtn.click(); + + } + return user; + + } +}); diff --git a/test/sample/sampleConfig.json b/test/sample/sampleConfig.json new file mode 100644 index 0000000..b027d31 --- /dev/null +++ b/test/sample/sampleConfig.json @@ -0,0 +1,9 @@ +{ + "server": "messagesight.demos.ibm.com", + "port": 1883, + "rtcommTopicPath": "/rtcommAngularSample/", + "userid": "", + "broadcastAudio": true, + "broadcastVideo": true, + "presenceTopic": "sampleRoom" +} diff --git a/test/server.js b/test/server.js new file mode 100644 index 0000000..e508188 --- /dev/null +++ b/test/server.js @@ -0,0 +1,27 @@ +var mosca = require('mosca'); + +var settings = { + logger: { + level: 'info' + }, + persistence: { + factory: mosca.persistence.Memory + }, + port: 1883, + http: { + port: 8083, + static: './', + bundle: true + } + +}; + +var server = new mosca.Server(settings); +server.on('ready', setup); + +function setup() { + + console.log('Mosca Broker and Web Server are up and running!'); + console.log('MQTT Websocket Port: 8083'); + console.log('Hostname: localhost'); +}