/**
* @ngdoc managers
* @name VoipManager
* @module s4c.managers.VoipManager
*
* @description
* `VoipManager` Componente para comunicação entre uma página html qualquer e o controller da diretiva
*
*
*/
(function () {
'use strict';
function VoipManager(MainState, VoipService, $mdDialog, localize) {
return {
'ativo': false,
/**
* @method abrir
*/
'abrir': function () {
/*
* Para o novo layout
this.ativo = true;
MainState.getDirective('voip');
$('.voip-enter-window .panel-primary').css("height", "485px");
*/
if (VoipService.isConnected) {
this.ativo = true;
MainState.getDirective('voip');
// $('.voip-enter-window .panel-primary').css("height", "485px");
} else if (VoipService.isConnecting) {
$mdDialog.show($mdDialog.alert()
.title(localize.res('COMUM_AVISO'))
.content(localize.res('VOIP_LOADING_RETRY_CONECT'))
.ok(localize.res('COMUM_OK')));
} else if (!VoipService.isSetCorrectly) {
$mdDialog.show($mdDialog.alert()
.title(localize.res('COMUM_AVISO'))
.content(localize.res('CHECK_VOIP_CONFIG'))
.ok(localize.res('COMUM_OK')));
} else if (VoipService.isSetCorrectly && !VoipService.isConnecting) {
MainState.getDirective('voip').createSipStack();
$mdDialog.show($mdDialog.alert()
.title(localize.res('COMUM_AVISO'))
.content(localize.res('VOIP_LOADING_RETRY_CONECT'))
.ok(localize.res('COMUM_OK')));
}
},
/**
* @method fechar
*/
'fechar': function () {
this.ativo = false;
},
/**
* @method hangup
*/
'hangup': function () {
if (MainState.getDirective('voip') != null) {
MainState.getDirective('voip').desligar();
}
},
/**
* @method call
* @param {*} voipramal
*/
'call': function (voipramal) {
if (MainState.getDirective('voip') != null) {
MainState.getDirective('voip').ligar(voipramal);
}
}
};
}
VoipManager.$inject = ['MainState', 'VoipService', '$mdDialog', 'localize'];
angular.module('s4c.managers')
.service('VoipManager', VoipManager);
})();