ui: use ACLs everywhere

This commit is contained in:
Jack Pearkes 2014-08-25 11:48:42 -07:00
parent 62a5c89820
commit 29762e80bc
3 changed files with 41 additions and 22 deletions

View File

@ -97,9 +97,10 @@ KvBaseController = Ember.ObjectController.extend({
var controller = this;
var rootKey = controller.get('rootKey');
var dc = controller.get('dc').get('datacenter');
var token = App.get('settings.token');
Ember.$.ajax({
url: ('/v1/kv/' + parent + '?keys&c=' + dc),
url: (formatUrl('/v1/kv/' + parent + '?keys', dc, token)),
type: 'GET'
}).then(function(data) {
controller.transitionToRoute('kv.show', parent);
@ -132,6 +133,7 @@ App.KvShowController.reopen({
var parentKey = controller.get('parentKey');
var grandParentKey = controller.get('grandParentKey');
var dc = controller.get('dc').get('datacenter');
var token = App.get('settings.token');
// If we don't have a previous model to base
// on our parent, or we're not at the root level,
@ -142,7 +144,7 @@ App.KvShowController.reopen({
// Put the Key and the Value retrieved from the form
Ember.$.ajax({
url: ("/v1/kv/" + newKey.get('Key') + '?dc=' + dc),
url: (formatUrl("/v1/kv/" + newKey.get('Key'), dc, token)),
type: 'PUT',
data: newKey.get('Value')
}).then(function(response) {
@ -165,10 +167,11 @@ App.KvShowController.reopen({
var controller = this;
var dc = controller.get('dc').get('datacenter');
var grandParent = controller.get('grandParentKey');
var token = App.get('settings.token');
// Delete the folder
Ember.$.ajax({
url: ("/v1/kv/" + controller.get('parentKey') + '?recurse&dc=' + dc),
url: (formatUrl("/v1/kv/" + controller.get('parentKey') + '?recurse', dc, token)),
type: 'DELETE'
}).then(function(response) {
controller.transitionToNearestParent(grandParent);
@ -193,11 +196,12 @@ App.KvEditController = KvBaseController.extend({
var dc = this.get('dc').get('datacenter');
var key = this.get("model");
var controller = this;
var token = App.get('settings.token');
// Put the key and the decoded (plain text) value
// from the form.
Ember.$.ajax({
url: ("/v1/kv/" + key.get('Key') + '?dc=' + dc),
url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)),
type: 'PUT',
data: key.get('valueDecoded')
}).then(function(response) {
@ -222,10 +226,11 @@ App.KvEditController = KvBaseController.extend({
var dc = controller.get('dc').get('datacenter');
var key = controller.get("model");
var parent = controller.getParentKeyRoute();
var token = App.get('settings.token');
// Delete the key
Ember.$.ajax({
url: ("/v1/kv/" + key.get('Key') + '?dc=' + dc),
url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)),
type: 'DELETE'
}).then(function(data) {
controller.transitionToNearestParent(parent);
@ -290,14 +295,15 @@ App.NodesShowController = Ember.ObjectController.extend({
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 invalidate this session?")) {
// Delete the session
Ember.$.ajax({
url: ("/v1/session/destroy/" + sessionId + '?dc=' + dc),
url: (formatUrl("/v1/session/destroy/" + sessionId, dc, token)),
type: 'PUT'
}).then(function(response) {
return Ember.$.getJSON('/v1/session/node/' + node.Node + '?dc=' + dc).then(function(data) {
return Ember.$.getJSON(formatUrl('/v1/session/node/' + node.Node, dc, token)).then(function(data) {
controller.set('sessions', data);
});
}).fail(function(response) {
@ -451,7 +457,7 @@ App.AclsShowController = Ember.ObjectController.extend({
}).then(function() {
controller.transitionToRoute('acls');
controller.set('isLoading', false);
notify('ACL token deleted', 3000);
notify('ACL deleted successfully', 3000);
});
}).fail(function(response) {
// Render the error message on the form if the request failed
@ -480,7 +486,7 @@ App.AclsShowController = Ember.ObjectController.extend({
notify('ACL updated successfully', 3000);
}).fail(function(response) {
// Render the error message on the form if the request failed
notify('Received error while creating ACL: ' + response.statusText, 8000);
notify('Received error while updating ACL: ' + response.statusText, 8000);
controller.set('isLoading', false);
});
}

View File

@ -93,7 +93,7 @@ App.DcRoute = App.BaseRoute.extend({
return Ember.RSVP.hash({
dc: params.dc,
dcs: Ember.$.getJSON('/v1/catalog/datacenters'),
nodes: Ember.$.getJSON('/v1/internal/ui/nodes?dc=' + params.dc).then(function(data) {
nodes: Ember.$.getJSON(formatUrl('/v1/internal/ui/nodes', params.dc)).then(function(data) {
objs = [];
// Merge the nodes into a list and create objects out of them
@ -124,12 +124,13 @@ App.KvShowRoute = App.BaseRoute.extend({
model: function(params) {
var key = params.key;
var dc = this.modelFor('dc').dc;
var token = App.get('settings.token');
// Return a promise has with the ?keys for that namespace
// and the original key requested in params
return Ember.RSVP.hash({
key: key,
keys: Ember.$.getJSON('/v1/kv/' + key + '?keys&seperator=' + '/&dc=' + dc).then(function(data) {
keys: Ember.$.getJSON(formatUrl('/v1/kv/' + key + '?keys&seperator=/', dc, token)).then(function(data) {
objs = [];
data.map(function(obj){
objs.push(App.Key.create({Key: obj}));
@ -158,15 +159,17 @@ App.KvEditRoute = App.BaseRoute.extend({
var key = params.key;
var dc = this.modelFor('dc').dc;
var parentKeys = this.getParentAndGrandparent(key);
var token = App.get('settings.token');
// Return a promise hash to get the data for both columns
return Ember.RSVP.hash({
dc: dc,
key: Ember.$.getJSON('/v1/kv/' + key + '?dc=' + dc).then(function(data) {
token: token,
key: Ember.$.getJSON(formatUrl('/v1/kv/' + key, dc, token)).then(function(data) {
// Convert the returned data to a Key
return App.Key.create().setProperties(data[0]);
}),
keys: keysPromise = Ember.$.getJSON('/v1/kv/' + parentKeys.parent + '?keys&seperator=' + '/' + '&dc=' + dc).then(function(data) {
keys: keysPromise = Ember.$.getJSON(formatUrl('/v1/kv/' + parentKeys.parent + '?keys&seperator=/', dc, token)).then(function(data) {
objs = [];
data.map(function(obj){
objs.push(App.Key.create({Key: obj}));
@ -179,7 +182,7 @@ App.KvEditRoute = App.BaseRoute.extend({
// Load the session on the key, if there is one
afterModel: function(models) {
if (models.key.get('isLocked')) {
return Ember.$.getJSON('/v1/session/info/' + models.key.Session + '?dc=' + models.dc).then(function(data) {
return Ember.$.getJSON(formatUrl('/v1/session/info/' + models.key.Session, models.dc, models.token)).then(function(data) {
models.session = data[0];
return models;
});
@ -206,8 +209,10 @@ App.KvEditRoute = App.BaseRoute.extend({
App.ServicesRoute = App.BaseRoute.extend({
model: function(params) {
var dc = this.modelFor('dc').dc;
var token = App.get('settings.token');
// Return a promise to retrieve all of the services
return Ember.$.getJSON('/v1/internal/ui/services?dc=' + dc).then(function(data) {
return Ember.$.getJSON(formatUrl('/v1/internal/ui/services', dc, token)).then(function(data) {
objs = [];
data.map(function(obj){
objs.push(App.Service.create(obj));
@ -224,9 +229,11 @@ App.ServicesRoute = App.BaseRoute.extend({
App.ServicesShowRoute = App.BaseRoute.extend({
model: function(params) {
var dc = this.modelFor('dc').dc;
var token = App.get('settings.token');
// Here we just use the built-in health endpoint, as it gives us everything
// we need.
return Ember.$.getJSON('/v1/health/service/' + params.name + '?dc=' + dc).then(function(data) {
return Ember.$.getJSON(formatUrl('/v1/health/service/' + params.name, dc, token)).then(function(data) {
objs = [];
data.map(function(obj){
objs.push(App.Node.create(obj));
@ -251,13 +258,16 @@ App.ServicesShowRoute = App.BaseRoute.extend({
App.NodesShowRoute = App.BaseRoute.extend({
model: function(params) {
var dc = this.modelFor('dc').dc;
var token = App.get('settings.token');
// Return a promise hash of the node and nodes
return Ember.RSVP.hash({
dc: dc,
node: Ember.$.getJSON('/v1/internal/ui/node/' + params.name + '?dc=' + dc).then(function(data) {
token: token,
node: Ember.$.getJSON(formatUrl('/v1/internal/ui/node/' + params.name, dc, token)).then(function(data) {
return App.Node.create(data);
}),
nodes: Ember.$.getJSON('/v1/internal/ui/node/' + params.name + '?dc=' + dc).then(function(data) {
nodes: Ember.$.getJSON(formatUrl('/v1/internal/ui/node/' + params.name, dc, token)).then(function(data) {
return App.Node.create(data);
})
});
@ -265,7 +275,7 @@ App.NodesShowRoute = App.BaseRoute.extend({
// Load the sessions for the node
afterModel: function(models) {
return Ember.$.getJSON('/v1/session/node/' + models.node.Node + '?dc=' + models.dc).then(function(data) {
return Ember.$.getJSON(formatUrl('/v1/session/node/' + models.node.Node, models.dc, models.token)).then(function(data) {
models.sessions = data;
return models;
});
@ -286,8 +296,10 @@ App.NodesShowRoute = App.BaseRoute.extend({
App.NodesRoute = App.BaseRoute.extend({
model: function(params) {
var dc = this.modelFor('dc').dc;
var token = App.get('settings.token');
// Return a promise containing the nodes
return Ember.$.getJSON('/v1/internal/ui/nodes?dc=' + dc).then(function(data) {
return Ember.$.getJSON(formatUrl('/v1/internal/ui/nodes', dc, token)).then(function(data) {
objs = [];
data.map(function(obj){
objs.push(App.Node.create(obj));
@ -343,6 +355,7 @@ App.AclsShowRoute = App.BaseRoute.extend({
model: function(params) {
var dc = this.modelFor('dc').dc;
var token = App.get('settings.token');
// Return a promise hash of the node and nodes
return Ember.RSVP.hash({
dc: dc,

View File

@ -1,14 +1,14 @@
.ns-box {
position: fixed;
background: lighten(black, 40%);
padding: 14px;
padding: 20px;
line-height: 1.4;
z-index: 1000;
min-width: 400px;
pointer-events: none;
color: rgba(250,251,255,0.95);
font-weight: 700;
font-size: 14px;
font-size: 15px;
opacity: 0.8;
}