]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8205 [verto_communicator] fix incall redirect and first login (localstorage clear)
authorStefan Yohansson <stefan@evolux.net.br>
Thu, 24 Sep 2015 20:29:49 +0000 (17:29 -0300)
committerKen Rice <krice@freeswitch.org>
Fri, 25 Sep 2015 15:08:09 +0000 (10:08 -0500)
html5/verto/verto_communicator/src/index.html
html5/verto/verto_communicator/src/partials/menu.html
html5/verto/verto_communicator/src/vertoApp/vertoApp.module.js
html5/verto/verto_communicator/src/vertoControllers/controllers/DialPadController.js
html5/verto/verto_communicator/src/vertoControllers/controllers/LoginController.js
html5/verto/verto_communicator/src/vertoControllers/controllers/MainController.js
html5/verto/verto_communicator/src/vertoControllers/controllers/SplashScreenController.js
html5/verto/verto_communicator/src/vertoService/services/eventQueueService.js [new file with mode: 0644]

index 79c6a9cc8baa7081da48283dfadda9fd9f0c54aa..ba8b790c2e07b5c0cccd3d092bfbfce1f8a6bfba 100644 (file)
     <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>
index ea846ddc1ee200d1aece7bb635e1d864b5752154..f0adc3f24dfc31361953e1d9eabe7fe2cc84ac37 100644 (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>
index 351dee8733bfbe1d2de8459a37e9b93b73df811e..0952ed1dceb590c273b638d8879b9ff90b121b52 100644 (file)
     }
   ]);
 
-  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;
       });
index 2cc4c983124fcb4efa5730b98e8eb008ed37db52..2944cae46df7b98fe4b2622c2424c379f14a76db 100644 (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;
index 3dda64de89029a23e22fc9f905a00649edde4df8..d6f1d0366fcb009b3db172ba554ac86ae27b88aa 100644 (file)
@@ -11,7 +11,7 @@
           }
         }
         preRoute();
-
+        
         verto.data.name = $scope.storage.data.name;
         verto.data.email = $scope.storage.data.email;
 
index fc403843ec4ba9ca8107374e700a1213a3cd27d9..db8475f9576885dca1090dc39778375b546651d3 100644 (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.');
 
       });
 
       $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) {
index a26ead6be2d5443d85336de88b0bbd53f141b616..fdc96efd59b9c9cf1c4aecd97bb360efd62df9b3 100644 (file)
@@ -18,7 +18,7 @@
             link = activity;
           }
         }
-
+        
         $location.path(link);
       }
 
@@ -77,6 +77,7 @@
           redirectTo('/dialpad');
         } else {
           redirectTo('/login');
+          $location.path('/login');
         }
       });
 
diff --git a/html5/verto/verto_communicator/src/vertoService/services/eventQueueService.js b/html5/verto/verto_communicator/src/vertoService/services/eventQueueService.js
new file mode 100644 (file)
index 0000000..71c48bc
--- /dev/null
@@ -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
+        };
+
+      }]);