FS-8205 [verto_communicator] fix incall redirect and first login (localstorage clear)

This commit is contained in:
Stefan Yohansson 2015-09-24 17:29:49 -03:00 committed by Ken Rice
parent 787671625d
commit 3d86aaacc5
8 changed files with 94 additions and 23 deletions

View File

@ -120,6 +120,7 @@
<script type="text/javascript" src="src/vertoService/vertoService.module.js"></script> <script type="text/javascript" src="src/vertoService/vertoService.module.js"></script>
<script type="text/javascript" src="src/vertoService/services/vertoService.js"></script> <script type="text/javascript" src="src/vertoService/services/vertoService.js"></script>
<script type="text/javascript" src="src/vertoService/services/configService.js"></script> <script type="text/javascript" src="src/vertoService/services/configService.js"></script>
<script type="text/javascript" src="src/vertoService/services/eventQueueService.js"></script>
<script type="text/javascript" src="src/storageService/storageService.module.js"></script> <script type="text/javascript" src="src/storageService/storageService.module.js"></script>
<script type="text/javascript" src="src/storageService/services/storage.js"></script> <script type="text/javascript" src="src/storageService/services/storage.js"></script>

View File

@ -13,7 +13,7 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="#/"> <a class="navbar-brand" href="javascript:void(0)">
Verto Communicator Verto Communicator
</a> </a>
</div> </div>

View File

@ -54,8 +54,19 @@
} }
]); ]);
vertoApp.run(['$rootScope', '$location', 'toastr', 'prompt', vertoApp.run(['$rootScope', '$location', 'toastr', 'prompt', 'verto',
function($rootScope, $location, toastr, prompt) { function($rootScope, $location, toastr, prompt, verto) {
$rootScope.$on( "$routeChangeStart", function(event, next, current) {
if (!verto.data.connected) {
if ( next.templateUrl === "partials/login.html") {
// pass
} else {
$location.path("/");
}
}
});
$rootScope.$on('$routeChangeSuccess', function(event, current, previous) { $rootScope.$on('$routeChangeSuccess', function(event, current, previous) {
$rootScope.title = current.$$route.title; $rootScope.title = current.$$route.title;
}); });

View File

@ -4,9 +4,12 @@
angular angular
.module('vertoControllers') .module('vertoControllers')
.controller('DialPadController', ['$rootScope', '$scope', .controller('DialPadController', ['$rootScope', '$scope',
'$http', '$location', 'toastr', 'verto', 'storage', 'CallHistory', '$http', '$location', 'toastr', 'verto', 'storage', 'CallHistory', 'eventQueue',
function($rootScope, $scope, $http, $location, toastr, verto, storage, CallHistory) { function($rootScope, $scope, $http, $location, toastr, verto, storage, CallHistory, eventQueue) {
console.debug('Executing DialPadController.'); console.debug('Executing DialPadController.');
eventQueue.process();
$scope.call_history = CallHistory.all(); $scope.call_history = CallHistory.all();
$scope.history_control = CallHistory.all_control(); $scope.history_control = CallHistory.all_control();
$scope.has_history = Object.keys($scope.call_history).length; $scope.has_history = Object.keys($scope.call_history).length;

View File

@ -4,7 +4,7 @@
angular angular
.module('vertoControllers') .module('vertoControllers')
.controller('MainController', .controller('MainController',
function($scope, $rootScope, $location, $modal, $timeout, verto, storage, CallHistory, toastr, Fullscreen, prompt) { function($scope, $rootScope, $location, $modal, $timeout, $q, verto, storage, CallHistory, toastr, Fullscreen, prompt, eventQueue) {
console.debug('Executing MainController.'); console.debug('Executing MainController.');
@ -245,6 +245,8 @@
}); });
$rootScope.$on('page.incall', function(event, data) { $rootScope.$on('page.incall', function(event, data) {
var page_incall = function() {
return $q(function(resolve, reject) {
if (storage.data.askRecoverCall) { if (storage.data.askRecoverCall) {
prompt({ prompt({
title: 'Oops, Active Call in Course.', title: 'Oops, Active Call in Course.',
@ -260,7 +262,10 @@
console.log('redirect to incall page'); console.log('redirect to incall page');
$location.path('/incall'); $location.path('/incall');
} }
resolve();
});
};
eventQueue.events.push(page_incall);
}); });
$scope.$on('event:google-plus-signin-success', function (event,authResult) { $scope.$on('event:google-plus-signin-success', function (event,authResult) {

View File

@ -77,6 +77,7 @@
redirectTo('/dialpad'); redirectTo('/dialpad');
} else { } else {
redirectTo('/login'); redirectTo('/login');
$location.path('/login');
} }
}); });

View File

@ -0,0 +1,50 @@
'use strict';
angular
.module('vertoService')
.service('eventQueue', ['$rootScope', '$q', 'storage', 'verto',
function($rootScope, $q, storage, verto) {
var events = [];
var next = function() {
var fn, fn_return;
fn = events.shift();
if (fn == undefined) {
$rootScope.$emit('eventqueue.complete');
return;
}
fn_return = fn();
var emitNextProgress = function() {
$rootScope.$emit('eventqueue.next');
};
fn_return.then(
function() {
emitNextProgress();
},
function() {
emitNextProgress();
}
);
};
var process = function() {
$rootScope.$on('eventqueue.next', function (ev){
next();
});
next();
};
return {
'next': next,
'process': process,
'events': events
};
}]);