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/services/vertoService.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/services/storage.js"></script>

View File

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

View File

@ -54,8 +54,19 @@
}
]);
vertoApp.run(['$rootScope', '$location', 'toastr', 'prompt',
function($rootScope, $location, toastr, prompt) {
vertoApp.run(['$rootScope', '$location', 'toastr', 'prompt', 'verto',
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.title = current.$$route.title;
});

View File

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

View File

@ -11,7 +11,7 @@
}
}
preRoute();
verto.data.name = $scope.storage.data.name;
verto.data.email = $scope.storage.data.email;

View File

@ -4,7 +4,7 @@
angular
.module('vertoControllers')
.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.');
@ -245,22 +245,27 @@
});
$rootScope.$on('page.incall', function(event, data) {
if (storage.data.askRecoverCall) {
prompt({
title: 'Oops, Active Call in Course.',
message: 'It seems you were in a call before leaving the last time. Wanna go back to that?'
}).then(function() {
console.log('redirect to incall page');
$location.path('/incall');
}, function() {
storage.data.userStatus = 'connecting';
verto.hangup();
var page_incall = function() {
return $q(function(resolve, reject) {
if (storage.data.askRecoverCall) {
prompt({
title: 'Oops, Active Call in Course.',
message: 'It seems you were in a call before leaving the last time. Wanna go back to that?'
}).then(function() {
console.log('redirect to incall page');
$location.path('/incall');
}, function() {
storage.data.userStatus = 'connecting';
verto.hangup();
});
} else {
console.log('redirect to incall page');
$location.path('/incall');
}
resolve();
});
} else {
console.log('redirect to incall page');
$location.path('/incall');
}
};
eventQueue.events.push(page_incall);
});
$scope.$on('event:google-plus-signin-success', function (event,authResult) {

View File

@ -18,7 +18,7 @@
link = activity;
}
}
$location.path(link);
}
@ -77,6 +77,7 @@
redirectTo('/dialpad');
} else {
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
};
}]);