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

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

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

View File

@ -18,7 +18,7 @@
link = activity; link = activity;
} }
} }
$location.path(link); $location.path(link);
} }
@ -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
};
}]);