From 9653cb52fc0d1a89c0e854acee2a9ee0c8b38dda Mon Sep 17 00:00:00 2001
From: Leonardo Menezes <mail@lmenezes.com>
Date: Wed, 25 Oct 2017 19:56:09 +0200
Subject: [PATCH] allow data service to disconnect from a host

---
 public/js/app.js                | 8 ++++++++
 src/app/shared/services/data.js | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/public/js/app.js b/public/js/app.js
index 2519f44..27fd1ce 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -2737,6 +2737,14 @@ angular.module('cerebro').factory('DataService', ['$rootScope', '$timeout',
       RefreshService.refresh();
     };
 
+    this.disconnect = function() {
+      host = undefined;
+      username = undefined;
+      password = undefined;
+      onGoingRequests = {};
+      $location.path('/connect');
+    };
+
     if ($location.search().host) {
       this.setHost($location.search().host);
     }
diff --git a/src/app/shared/services/data.js b/src/app/shared/services/data.js
index e8d40c6..10c467c 100644
--- a/src/app/shared/services/data.js
+++ b/src/app/shared/services/data.js
@@ -23,6 +23,14 @@ angular.module('cerebro').factory('DataService', ['$rootScope', '$timeout',
       RefreshService.refresh();
     };
 
+    this.disconnect = function() {
+      host = undefined;
+      username = undefined;
+      password = undefined;
+      onGoingRequests = {};
+      $location.path('/connect');
+    };
+
     if ($location.search().host) {
       this.setHost($location.search().host);
     }
-- 
GitLab