Merge pull request #379 from hashicorp/f-ui-deregister-node
Deregister node button in web UI
This commit is contained in:
commit
7fea587a32
|
@ -506,7 +506,10 @@
|
|||
<hr>
|
||||
</div>
|
||||
|
||||
<h3 class="no-margin">{{ model.Node }} <small> {{ model.Address }}</small></h3>
|
||||
<h3 class="no-margin">
|
||||
{{ model.Node }} <small> {{ model.Address }}</small>
|
||||
<button {{ action "deregisterNode" }} {{ bind-attr class=":btn :btn-danger :pull-right :btn-mini isLoading:btn-warning" }}>Deregister</button>
|
||||
</h3>
|
||||
<hr>
|
||||
|
||||
<h5>Services</h5>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue