Fixing login issue when session expires (or containers are rebuilt)

Change-Id: Ibd41d92bbccadfd1529f01d0b84a5a3c8e10f7ee
(cherry picked from commit afd05d7fd951df52bfe32a15cd8a3d79a9bd9049)
diff --git a/src/app/views/dashboard/dashboard.ts b/src/app/views/dashboard/dashboard.ts
index 45bd138..285c2df 100644
--- a/src/app/views/dashboard/dashboard.ts
+++ b/src/app/views/dashboard/dashboard.ts
@@ -18,37 +18,53 @@
 
 import {IXosModelStoreService} from '../../datasources/stores/model.store';
 import {IXosAuthService} from '../../datasources/rest/auth.rest';
+import {Subscription} from 'rxjs/Subscription';
+
+
 class DashboardController {
-  static $inject = ['$scope', '$state', 'XosModelStore', 'AuthService'];
+  static $inject = [
+    '$log',
+    '$scope',
+    '$state',
+    'XosModelStore',
+    'AuthService'
+  ];
 
   public nodes: number;
   public slices: number;
   public instances: number;
 
+  private nodeSubscription: Subscription;
+  private sliceSubscription: Subscription;
+  private instanceSubscription: Subscription;
+
   constructor(
+    private $log: ng.ILogService,
     private $scope: ng.IScope,
     private $state: ng.ui.IStateService,
     private store: IXosModelStoreService,
     private auth: IXosAuthService
   ) {
 
+    this.$log.info(`[XosDashboardView] Setup`);
+
     if (!this.auth.isAuthenticated()) {
       this.$state.go('login');
     }
     else {
-      this.store.query('Node')
+      this.nodeSubscription = this.store.query('Node')
         .subscribe((event) => {
           this.$scope.$evalAsync(() => {
             this.nodes = event.length;
           });
         });
-      this.store.query('Instance')
+      this.instanceSubscription = this.store.query('Instance')
         .subscribe((event) => {
           this.$scope.$evalAsync(() => {
             this.instances = event.length;
           });
         });
-      this.store.query('Slice')
+      this.sliceSubscription = this.store.query('Slice')
         .subscribe((event) => {
           this.$scope.$evalAsync(() => {
             this.slices = event.length;
@@ -59,6 +75,12 @@
       this.slices = 0;
     }
   }
+
+  $onDestroy () {
+    this.nodeSubscription.unsubscribe();
+    this.instanceSubscription.unsubscribe();
+    this.sliceSubscription.unsubscribe();
+  }
 }
 
 export const xosDashboard: angular.IComponentOptions = {