Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @prettier
- */
- angular
- .module("directive.connection-quality", ["factory.ipc", "constants", "service.mobile-utils"])
- .controller("ConnectionQualityCtrl", function(
- $scope,
- $rootScope,
- EVENTS,
- UDA_EVENTS,
- mobileUtils,
- qosMatrixService
- ) {
- var mobileIcons = [
- "VQI-strikethrough.svg",
- "VQI-1bar.svg",
- "VQI-2bar.svg",
- "VQI-3bar.svg",
- "VQI-4bar.svg",
- "VQI.svg"
- ];
- var desktopIcons = [
- "quality01.svg",
- "quality02d.svg",
- "quality02c.svg",
- "quality02b.svg",
- "quality02a.svg",
- "quality02.svg"
- ];
- $rootScope.$on(EVENTS.updateMos, function(inEvent, data) {
- setProperties(data);
- $rootScope.$evalAsync();
- });
- setProperties(qosMatrixService.publishedMOS);
- function setProperties(mos) {
- var bars = getBars(mos);
- $scope.iconDesktop = desktopIcons[bars];
- $scope.iconMobile = mobileIcons[bars];
- $scope.toolTip = getToolTip(mos);
- }
- function getBars(mosval) {
- var bars;
- if (mosval == null || mosval == undefined) bars = 0;
- else if (mosval > 0 && mosval <= 1.0) bars = 1;
- else if (mosval > 1.0 && mosval <= 2.0) bars = 2;
- else if (mosval > 2.0 && mosval <= 3.0) bars = 3;
- else if (mosval > 3.0 && mosval <= 4.0) bars = 4;
- else if (mosval > 4.0) bars = 5;
- else bars = 0;
- return bars;
- }
- function getToolTip(mosval) {
- if (!mosval) return { long: "No active call", short: "No active call" };
- var trns_stat = "Poor";
- var recv_stat = "Poor";
- if (qosMatrixService.sender_MOS && qosMatrixService.receiver_MOS) {
- if (qosMatrixService.sender_MOS >= 3.0 && qosMatrixService.sender_MOS < 4.0) {
- trns_stat = "Fair";
- } else if (qosMatrixService.sender_MOS >= 4) {
- trns_stat = "Strong";
- }
- if (qosMatrixService.receiver_MOS >= 3.0 && qosMatrixService.receiver_MOS < 4.0) {
- recv_stat = "Fair";
- } else if (qosMatrixService.receiver_MOS >= 4) {
- recv_stat = "Strong";
- }
- }
- return {
- long: "Transmit Audio Quality: " + trns_stat + "\nReceive Audio Quality: " + recv_stat,
- short: "Audio Transmit:" + trns_stat + ", Receive:" + recv_stat
- };
- }
- $scope.iconClicked = function() {
- var message = $scope.toolTip.short;
- $rootScope.$broadcast(UDA_EVENTS.clmaNotification, { clmaMsgType: "success", message: message });
- };
- })
- .directive("connectionQuality", function() {
- return {
- restrict: "E",
- templateUrl: "directives/connection-quality/connection-quality.tpl.htm",
- scope: {},
- controller: "ConnectionQualityCtrl"
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement