diff --git a/ui/index.html b/ui/index.html index 1b12711815..2200e992dd 100644 --- a/ui/index.html +++ b/ui/index.html @@ -506,7 +506,10 @@
-

{{ model.Node }} {{ model.Address }}

+

+ {{ model.Node }} {{ model.Address }} + +


Services
diff --git a/ui/javascripts/app/controllers.js b/ui/javascripts/app/controllers.js index 0fb6ef5bba..724a528a6b 100644 --- a/ui/javascripts/app/controllers.js +++ b/ui/javascripts/app/controllers.js @@ -285,10 +285,38 @@ ItemBaseController = Ember.ArrayController.extend({ }); App.NodesShowController = Ember.ObjectController.extend({ - needs: ["dc"], + needs: ["dc", "nodes"], dc: Ember.computed.alias("controllers.dc"), actions: { + deregisterNode: function() { + this.set('isLoading', true); + var controller = this; + var node = controller.get('model'); + var dc = controller.get('dc').get('datacenter'); + var token = App.get('settings.token'); + + if (window.confirm("Are you sure you want to deregister this node?")) { + // Deregister node + Ember.$.ajax({ + url: formatUrl('/v1/catalog/deregister', dc, token), + type: 'PUT', + data: JSON.stringify({ + 'Datacenter': dc, + 'Node': node.Node + }) + }).then(function(response) { + var nodes = controller.get('controllers.nodes').get('nodes'); + controller.get('controllers.nodes').set('nodes', nodes.filter(function(n) { + return n.Node !== node.Node; + })); + controller.transitionToRoute('nodes'); + }).fail(function(response) { + controller.set('errorMessage', 'Received error while processing: ' + response.statusText); + }); + } + }, + invalidateSession: function(sessionId) { this.set('isLoading', true); var controller = this; diff --git a/ui/javascripts/app/routes.js b/ui/javascripts/app/routes.js index 52c1bd1803..d964b8e9e5 100644 --- a/ui/javascripts/app/routes.js +++ b/ui/javascripts/app/routes.js @@ -94,7 +94,7 @@ App.DcRoute = App.BaseRoute.extend({ dc: params.dc, dcs: Ember.$.getJSON('/v1/catalog/datacenters'), nodes: Ember.$.getJSON(formatUrl('/v1/internal/ui/nodes', params.dc)).then(function(data) { - objs = []; + var objs = []; // Merge the nodes into a list and create objects out of them data.map(function(obj){ @@ -131,7 +131,7 @@ App.KvShowRoute = App.BaseRoute.extend({ return Ember.RSVP.hash({ key: key, keys: Ember.$.getJSON(formatUrl('/v1/kv/' + key + '?keys&seperator=/', dc, token)).then(function(data) { - objs = []; + var objs = []; data.map(function(obj){ objs.push(App.Key.create({Key: obj})); }); @@ -170,7 +170,7 @@ App.KvEditRoute = App.BaseRoute.extend({ return App.Key.create().setProperties(data[0]); }), keys: keysPromise = Ember.$.getJSON(formatUrl('/v1/kv/' + parentKeys.parent + '?keys&seperator=/', dc, token)).then(function(data) { - objs = []; + var objs = []; data.map(function(obj){ objs.push(App.Key.create({Key: obj})); }); @@ -213,7 +213,7 @@ App.ServicesRoute = App.BaseRoute.extend({ // Return a promise to retrieve all of the services return Ember.$.getJSON(formatUrl('/v1/internal/ui/services', dc, token)).then(function(data) { - objs = []; + var objs = []; data.map(function(obj){ objs.push(App.Service.create(obj)); }); @@ -234,7 +234,7 @@ App.ServicesShowRoute = App.BaseRoute.extend({ // Here we just use the built-in health endpoint, as it gives us everything // we need. return Ember.$.getJSON(formatUrl('/v1/health/service/' + params.name, dc, token)).then(function(data) { - objs = []; + var objs = []; data.map(function(obj){ objs.push(App.Node.create(obj)); }); @@ -300,7 +300,7 @@ App.NodesRoute = App.BaseRoute.extend({ // Return a promise containing the nodes return Ember.$.getJSON(formatUrl('/v1/internal/ui/nodes', dc, token)).then(function(data) { - objs = []; + var objs = []; data.map(function(obj){ objs.push(App.Node.create(obj)); }); @@ -308,7 +308,7 @@ App.NodesRoute = App.BaseRoute.extend({ }); }, setupController: function(controller, model) { - controller.set('nodes', model); + controller.set('nodes', model); } }); @@ -319,7 +319,7 @@ App.AclsRoute = App.BaseRoute.extend({ var token = App.get('settings.token'); // Return a promise containing the ACLS return Ember.$.getJSON(formatUrl('/v1/acl/list', dc, token)).then(function(data) { - objs = []; + var objs = []; data.map(function(obj){ if (obj.ID === "anonymous") { objs.unshift(App.Acl.create(obj));