phosphor-webui: Allow after login redirects

When redirecting a user to a login url, it is helpful to be able to
point them to a url that after login, will forward to the requested
page.

This is accomplished by the use of a url param named "next" which
specifies the URL that the user wants to be redirected to after login.
If no next url is specified, the user is redirected to the overview
page, like the vehavior before.

Change-Id: Iff0da65632119a8f7ae3f35eb74147ca67563f30
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/app/login/controllers/login-controller.js b/app/login/controllers/login-controller.js
index 8877df7..e31a67e 100644
--- a/app/login/controllers/login-controller.js
+++ b/app/login/controllers/login-controller.js
@@ -10,8 +10,12 @@
   'use strict';
 
   angular.module('app.login').controller('LoginController', [
-    '$scope', '$window', 'dataService', 'userModel',
-    function($scope, $window, dataService, userModel) {
+    '$scope',
+    '$window',
+    'dataService',
+    'userModel',
+    '$location',
+    function($scope, $window, dataService, userModel, $location) {
       $scope.dataService = dataService;
       $scope.host = $scope.dataService.host.replace(/^https?\:\/\//ig, '');
 
@@ -34,7 +38,12 @@
           userModel.login(username, password, function(status, description) {
             if (status) {
               $scope.$emit('user-logged-in', {});
-              $window.location.hash = '#/overview/server';
+              var next = $location.search().next;
+              if (next === undefined || next == null) {
+                $window.location.hash = '#/overview/server';
+              } else {
+                $window.location.href = next;
+              }
             } else {
               $scope.error = true;
               if (description) {
@@ -44,6 +53,6 @@
           });
         }
       };
-    }
+    },
   ]);
 })(angular);