SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * @prettier
  3.  */
  4.  
  5. angular
  6.     .module("directive.connection-quality", ["factory.ipc", "constants", "service.mobile-utils"])
  7.     .controller("ConnectionQualityCtrl", function(
  8.         $scope,
  9.         $rootScope,
  10.         EVENTS,
  11.         UDA_EVENTS,
  12.         mobileUtils,
  13.         qosMatrixService
  14.     ) {
  15.         var mobileIcons = [
  16.             "VQI-strikethrough.svg",
  17.             "VQI-1bar.svg",
  18.             "VQI-2bar.svg",
  19.             "VQI-3bar.svg",
  20.             "VQI-4bar.svg",
  21.             "VQI.svg"
  22.         ];
  23.  
  24.         var desktopIcons = [
  25.             "quality01.svg",
  26.             "quality02d.svg",
  27.             "quality02c.svg",
  28.             "quality02b.svg",
  29.             "quality02a.svg",
  30.             "quality02.svg"
  31.         ];
  32.  
  33.         $rootScope.$on(EVENTS.updateMos, function(inEvent, data) {
  34.             setProperties(data);
  35.             $rootScope.$evalAsync();
  36.         });
  37.  
  38.         setProperties(qosMatrixService.publishedMOS);
  39.  
  40.         function setProperties(mos) {
  41.             var bars = getBars(mos);
  42.             $scope.iconDesktop = desktopIcons[bars];
  43.             $scope.iconMobile = mobileIcons[bars];
  44.             $scope.toolTip = getToolTip(mos);
  45.         }
  46.  
  47.         function getBars(mosval) {
  48.             var bars;
  49.  
  50.             if (mosval == null || mosval == undefined) bars = 0;
  51.             else if (mosval > 0 && mosval <= 1.0) bars = 1;
  52.             else if (mosval > 1.0 && mosval <= 2.0) bars = 2;
  53.             else if (mosval > 2.0 && mosval <= 3.0) bars = 3;
  54.             else if (mosval > 3.0 && mosval <= 4.0) bars = 4;
  55.             else if (mosval > 4.0) bars = 5;
  56.             else bars = 0;
  57.  
  58.             return bars;
  59.         }
  60.  
  61.         function getToolTip(mosval) {
  62.             if (!mosval) return { long: "No active call", short: "No active call" };
  63.  
  64.             var trns_stat = "Poor";
  65.             var recv_stat = "Poor";
  66.             if (qosMatrixService.sender_MOS && qosMatrixService.receiver_MOS) {
  67.                 if (qosMatrixService.sender_MOS >= 3.0 && qosMatrixService.sender_MOS < 4.0) {
  68.                     trns_stat = "Fair";
  69.                 } else if (qosMatrixService.sender_MOS >= 4) {
  70.                     trns_stat = "Strong";
  71.                 }
  72.                 if (qosMatrixService.receiver_MOS >= 3.0 && qosMatrixService.receiver_MOS < 4.0) {
  73.                     recv_stat = "Fair";
  74.                 } else if (qosMatrixService.receiver_MOS >= 4) {
  75.                     recv_stat = "Strong";
  76.                 }
  77.             }
  78.             return {
  79.                 long: "Transmit Audio Quality: " + trns_stat + "\nReceive Audio Quality: " + recv_stat,
  80.                 short: "Audio Transmit:" + trns_stat + ", Receive:" + recv_stat
  81.             };
  82.         }
  83.  
  84.         $scope.iconClicked = function() {
  85.             var message = $scope.toolTip.short;
  86.             $rootScope.$broadcast(UDA_EVENTS.clmaNotification, { clmaMsgType: "success", message: message });
  87.         };
  88.     })
  89.     .directive("connectionQuality", function() {
  90.         return {
  91.             restrict: "E",
  92.             templateUrl: "directives/connection-quality/connection-quality.tpl.htm",
  93.             scope: {},
  94.             controller: "ConnectionQualityCtrl"
  95.         };
  96.     });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top