2014-06-05 17:24:03 +00:00
|
|
|
App.ApplicationController = Ember.ObjectController.extend({
|
|
|
|
updateCurrentPath: function() {
|
|
|
|
App.set('currentPath', this.get('currentPath'));
|
|
|
|
}.observes('currentPath')
|
|
|
|
});
|
|
|
|
|
2014-04-25 17:49:36 +00:00
|
|
|
App.DcController = Ember.Controller.extend({
|
2014-08-23 00:14:26 +00:00
|
|
|
needs: ["application"],
|
2014-04-30 21:31:40 +00:00
|
|
|
// Whether or not the dropdown menu can be seen
|
2014-04-25 20:24:36 +00:00
|
|
|
isDropdownVisible: false,
|
|
|
|
|
2015-10-26 01:21:50 +00:00
|
|
|
datacenter: Ember.computed.alias('content'),
|
2014-04-30 21:31:40 +00:00
|
|
|
|
|
|
|
// Returns the total number of failing checks.
|
|
|
|
//
|
|
|
|
// We treat any non-passing checks as failing
|
|
|
|
//
|
|
|
|
totalChecksFailing: function() {
|
2015-10-26 01:21:50 +00:00
|
|
|
return this.get('nodes').reduce(function(sum, node) {
|
|
|
|
return sum + node.get('failingChecks');
|
|
|
|
}, 0);
|
|
|
|
}.property('nodes'),
|
|
|
|
|
|
|
|
totalChecksPassing: function() {
|
|
|
|
return this.get('nodes').reduce(function(sum, node) {
|
|
|
|
return sum + node.get('passingChecks');
|
|
|
|
}, 0);
|
2014-04-30 22:05:44 +00:00
|
|
|
}.property('nodes'),
|
2014-04-25 20:24:36 +00:00
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
//
|
|
|
|
// Returns the human formatted message for the button state
|
|
|
|
//
|
2014-04-25 20:24:36 +00:00
|
|
|
checkMessage: function() {
|
2014-04-30 21:31:40 +00:00
|
|
|
var failingChecks = this.get('totalChecksFailing');
|
2015-10-26 01:21:50 +00:00
|
|
|
var passingChecks = this.get('totalChecksPassing');
|
2014-04-25 20:24:36 +00:00
|
|
|
|
2014-08-20 23:51:40 +00:00
|
|
|
if (this.get('hasFailingChecks') === true) {
|
2014-08-21 23:00:37 +00:00
|
|
|
return failingChecks + ' failing';
|
2014-04-25 20:24:36 +00:00
|
|
|
} else {
|
2014-08-21 23:00:37 +00:00
|
|
|
return passingChecks + ' passing';
|
2014-04-25 20:24:36 +00:00
|
|
|
}
|
|
|
|
|
2014-04-30 22:05:44 +00:00
|
|
|
}.property('nodes'),
|
2014-04-25 20:24:36 +00:00
|
|
|
|
2014-06-04 20:03:55 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
checkStatus: function() {
|
2014-08-20 23:51:40 +00:00
|
|
|
if (this.get('hasFailingChecks') === true) {
|
2014-06-04 20:03:55 +00:00
|
|
|
return "failing";
|
|
|
|
} else {
|
|
|
|
return "passing";
|
|
|
|
}
|
|
|
|
|
|
|
|
}.property('nodes'),
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
//
|
|
|
|
// Boolean if the datacenter has any failing checks.
|
|
|
|
//
|
2015-10-26 01:21:50 +00:00
|
|
|
hasFailingChecks: Ember.computed.gt('totalChecksFailing', 0),
|
2014-04-25 20:24:36 +00:00
|
|
|
|
|
|
|
actions: {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Hide and show the dropdown menu
|
2014-04-25 20:24:36 +00:00
|
|
|
toggle: function(item){
|
|
|
|
this.toggleProperty('isDropdownVisible');
|
2014-05-01 16:21:32 +00:00
|
|
|
},
|
|
|
|
// Just hide the dropdown menu
|
|
|
|
hideDrop: function(item){
|
|
|
|
this.set('isDropdownVisible', false);
|
2014-04-25 20:24:36 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-20 23:51:40 +00:00
|
|
|
});
|
2014-04-25 17:49:36 +00:00
|
|
|
|
2014-05-05 13:05:30 +00:00
|
|
|
KvBaseController = Ember.ObjectController.extend({
|
2014-05-05 19:32:39 +00:00
|
|
|
getParentKeyRoute: function() {
|
|
|
|
if (this.get('isRoot')) {
|
|
|
|
return this.get('rootKey');
|
|
|
|
}
|
2015-10-26 01:21:50 +00:00
|
|
|
return this.get('parentKey');
|
2014-05-05 19:32:39 +00:00
|
|
|
},
|
|
|
|
|
2014-05-05 07:56:21 +00:00
|
|
|
transitionToNearestParent: function(parent) {
|
|
|
|
var controller = this;
|
|
|
|
var rootKey = controller.get('rootKey');
|
|
|
|
var dc = controller.get('dc').get('datacenter');
|
2014-08-25 18:48:42 +00:00
|
|
|
var token = App.get('settings.token');
|
2014-05-05 07:56:21 +00:00
|
|
|
|
|
|
|
Ember.$.ajax({
|
2014-08-25 18:48:42 +00:00
|
|
|
url: (formatUrl('/v1/kv/' + parent + '?keys', dc, token)),
|
2014-05-05 07:56:21 +00:00
|
|
|
type: 'GET'
|
|
|
|
}).then(function(data) {
|
|
|
|
controller.transitionToRoute('kv.show', parent);
|
|
|
|
}).fail(function(response) {
|
|
|
|
if (response.status === 404) {
|
|
|
|
controller.transitionToRoute('kv.show', rootKey);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
controller.set('isLoading', false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-10-26 01:21:50 +00:00
|
|
|
App.KvShowController = KvBaseController.extend(Ember.Validations.Mixin, {
|
2014-04-30 22:05:44 +00:00
|
|
|
needs: ["dc"],
|
|
|
|
dc: Ember.computed.alias("controllers.dc"),
|
2014-04-30 14:09:41 +00:00
|
|
|
isLoading: false,
|
|
|
|
|
|
|
|
actions: {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Creates the key from the newKey model
|
|
|
|
// set on the route.
|
2014-04-30 14:09:41 +00:00
|
|
|
createKey: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
|
2014-04-30 20:30:14 +00:00
|
|
|
var controller = this;
|
2014-05-05 07:56:21 +00:00
|
|
|
var newKey = controller.get('newKey');
|
|
|
|
var parentKey = controller.get('parentKey');
|
|
|
|
var grandParentKey = controller.get('grandParentKey');
|
|
|
|
var dc = controller.get('dc').get('datacenter');
|
2014-08-25 18:48:42 +00:00
|
|
|
var token = App.get('settings.token');
|
2014-04-30 14:09:41 +00:00
|
|
|
|
|
|
|
// If we don't have a previous model to base
|
2014-04-30 21:31:40 +00:00
|
|
|
// on our parent, or we're not at the root level,
|
2014-05-01 14:00:36 +00:00
|
|
|
// add the prefix
|
2014-08-20 23:51:40 +00:00
|
|
|
if (parentKey !== undefined && parentKey !== "/") {
|
2014-04-30 21:38:56 +00:00
|
|
|
newKey.set('Key', (parentKey + newKey.get('Key')));
|
2014-04-30 14:09:41 +00:00
|
|
|
}
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// Put the Key and the Value retrieved from the form
|
2014-04-30 20:30:14 +00:00
|
|
|
Ember.$.ajax({
|
2014-08-25 18:48:42 +00:00
|
|
|
url: (formatUrl("/v1/kv/" + newKey.get('Key'), dc, token)),
|
2014-04-30 20:30:14 +00:00
|
|
|
type: 'PUT',
|
|
|
|
data: newKey.get('Value')
|
|
|
|
}).then(function(response) {
|
2014-04-30 23:22:07 +00:00
|
|
|
// transition to the right place
|
2014-08-20 23:51:40 +00:00
|
|
|
if (newKey.get('isFolder') === true) {
|
2014-05-04 21:05:00 +00:00
|
|
|
controller.transitionToRoute('kv.show', newKey.get('Key'));
|
2014-04-30 23:22:07 +00:00
|
|
|
} else {
|
2014-05-04 21:05:00 +00:00
|
|
|
controller.transitionToRoute('kv.edit', newKey.get('Key'));
|
2014-04-30 23:22:07 +00:00
|
|
|
}
|
2014-08-20 23:51:40 +00:00
|
|
|
controller.set('isLoading', false);
|
2014-04-30 20:30:14 +00:00
|
|
|
}).fail(function(response) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Render the error message on the form if the request failed
|
2014-08-20 23:51:40 +00:00
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
2014-04-30 20:30:14 +00:00
|
|
|
});
|
2014-05-05 00:12:24 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
deleteFolder: function() {
|
|
|
|
|
2014-12-06 01:14:11 +00:00
|
|
|
this.set('isLoading', true);
|
2014-05-05 00:12:24 +00:00
|
|
|
var controller = this;
|
2014-06-06 19:11:26 +00:00
|
|
|
var dc = controller.get('dc').get('datacenter');
|
2014-05-05 19:32:39 +00:00
|
|
|
var grandParent = controller.get('grandParentKey');
|
2014-08-25 18:48:42 +00:00
|
|
|
var token = App.get('settings.token');
|
2014-04-30 14:09:41 +00:00
|
|
|
|
2014-12-06 01:14:11 +00:00
|
|
|
if (window.confirm("Are you sure you want to delete this folder?")) {
|
|
|
|
// Delete the folder
|
|
|
|
Ember.$.ajax({
|
|
|
|
url: (formatUrl("/v1/kv/" + controller.get('parentKey') + '?recurse', dc, token)),
|
|
|
|
type: 'DELETE'
|
|
|
|
}).then(function(response) {
|
|
|
|
controller.transitionToNearestParent(grandParent);
|
|
|
|
}).fail(function(response) {
|
|
|
|
// Render the error message on the form if the request failed
|
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
|
|
|
});
|
|
|
|
}
|
2014-04-30 14:09:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-04-29 20:16:22 +00:00
|
|
|
|
2014-05-05 13:05:30 +00:00
|
|
|
App.KvEditController = KvBaseController.extend({
|
2014-04-29 20:16:22 +00:00
|
|
|
isLoading: false,
|
2014-05-01 14:00:36 +00:00
|
|
|
needs: ["dc"],
|
|
|
|
dc: Ember.computed.alias("controllers.dc"),
|
2014-04-29 20:16:22 +00:00
|
|
|
|
|
|
|
actions: {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Updates the key set as the model on the route.
|
2014-04-29 20:16:22 +00:00
|
|
|
updateKey: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
|
2014-05-01 14:00:36 +00:00
|
|
|
var dc = this.get('dc').get('datacenter');
|
2014-04-30 20:30:14 +00:00
|
|
|
var key = this.get("model");
|
|
|
|
var controller = this;
|
2014-08-25 18:48:42 +00:00
|
|
|
var token = App.get('settings.token');
|
2014-04-30 20:30:14 +00:00
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// Put the key and the decoded (plain text) value
|
|
|
|
// from the form.
|
2014-04-30 20:30:14 +00:00
|
|
|
Ember.$.ajax({
|
2014-08-25 18:48:42 +00:00
|
|
|
url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)),
|
2014-04-30 20:30:14 +00:00
|
|
|
type: 'PUT',
|
|
|
|
data: key.get('valueDecoded')
|
|
|
|
}).then(function(response) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// If success, just reset the loading state.
|
2014-08-20 23:51:40 +00:00
|
|
|
controller.set('isLoading', false);
|
2014-04-30 20:30:14 +00:00
|
|
|
}).fail(function(response) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Render the error message on the form if the request failed
|
2014-08-20 23:51:40 +00:00
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
|
|
|
});
|
2014-04-30 14:16:50 +00:00
|
|
|
},
|
|
|
|
|
2014-05-04 23:03:47 +00:00
|
|
|
cancelEdit: function() {
|
|
|
|
this.set('isLoading', true);
|
2014-05-05 19:32:39 +00:00
|
|
|
this.transitionToRoute('kv.show', this.getParentKeyRoute());
|
2014-05-04 23:03:47 +00:00
|
|
|
this.set('isLoading', false);
|
|
|
|
},
|
|
|
|
|
2014-04-30 14:16:50 +00:00
|
|
|
deleteKey: function() {
|
2014-12-06 01:14:11 +00:00
|
|
|
this.set('isLoading', true);
|
2014-12-06 19:55:26 +00:00
|
|
|
|
2014-04-30 20:30:14 +00:00
|
|
|
var controller = this;
|
2014-05-05 00:51:34 +00:00
|
|
|
var dc = controller.get('dc').get('datacenter');
|
|
|
|
var key = controller.get("model");
|
2014-05-05 19:32:39 +00:00
|
|
|
var parent = controller.getParentKeyRoute();
|
2014-08-25 18:48:42 +00:00
|
|
|
var token = App.get('settings.token');
|
2014-04-30 20:30:14 +00:00
|
|
|
|
2014-12-06 19:55:26 +00:00
|
|
|
// Delete the key
|
|
|
|
Ember.$.ajax({
|
|
|
|
url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)),
|
|
|
|
type: 'DELETE'
|
|
|
|
}).then(function(data) {
|
|
|
|
controller.transitionToNearestParent(parent);
|
|
|
|
}).fail(function(response) {
|
|
|
|
// Render the error message on the form if the request failed
|
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
|
|
|
});
|
2014-04-29 20:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2014-05-30 18:26:11 +00:00
|
|
|
|
2014-06-02 14:35:46 +00:00
|
|
|
ItemBaseController = Ember.ArrayController.extend({
|
2014-06-05 17:24:03 +00:00
|
|
|
needs: ["dc", "application"],
|
2014-06-04 19:56:00 +00:00
|
|
|
queryParams: ["filter", "status", "condensed"],
|
2014-06-02 14:35:46 +00:00
|
|
|
dc: Ember.computed.alias("controllers.dc"),
|
2014-06-04 19:56:00 +00:00
|
|
|
condensed: true,
|
2014-08-22 19:25:10 +00:00
|
|
|
hasExpanded: true,
|
|
|
|
filterText: "Filter by name",
|
2014-06-02 15:49:01 +00:00
|
|
|
filter: "", // default
|
2014-06-04 19:56:00 +00:00
|
|
|
status: "any status", // default
|
2014-06-02 16:05:13 +00:00
|
|
|
statuses: ["any status", "passing", "failing"],
|
2014-06-02 14:35:46 +00:00
|
|
|
|
2014-06-05 17:24:03 +00:00
|
|
|
isShowingItem: function() {
|
|
|
|
var currentPath = this.get('controllers.application.currentPath');
|
|
|
|
return (currentPath === "dc.nodes.show" || currentPath === "dc.services.show");
|
|
|
|
}.property('controllers.application.currentPath'),
|
|
|
|
|
2014-06-02 14:35:46 +00:00
|
|
|
filteredContent: function() {
|
|
|
|
var filter = this.get('filter');
|
2014-06-04 19:56:00 +00:00
|
|
|
var status = this.get('status');
|
2014-06-02 14:35:46 +00:00
|
|
|
|
2015-10-26 01:21:50 +00:00
|
|
|
var items = this.get('items').filter(function(item){
|
2014-06-02 14:35:46 +00:00
|
|
|
return item.get('filterKey').toLowerCase().match(filter.toLowerCase());
|
|
|
|
});
|
2014-06-02 16:05:13 +00:00
|
|
|
|
2014-06-04 19:56:00 +00:00
|
|
|
switch (status) {
|
2014-06-02 16:05:13 +00:00
|
|
|
case "passing":
|
2014-08-20 23:51:40 +00:00
|
|
|
return items.filterBy('hasFailingChecks', false);
|
2014-06-02 16:05:13 +00:00
|
|
|
case "failing":
|
2014-08-20 23:51:40 +00:00
|
|
|
return items.filterBy('hasFailingChecks', true);
|
2014-06-02 16:05:13 +00:00
|
|
|
default:
|
2014-08-20 23:51:40 +00:00
|
|
|
return items;
|
2014-06-02 16:05:13 +00:00
|
|
|
}
|
|
|
|
|
2014-06-04 19:56:00 +00:00
|
|
|
}.property('filter', 'status', 'items.@each'),
|
2014-06-02 15:49:01 +00:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
toggleCondensed: function() {
|
2015-10-26 01:21:50 +00:00
|
|
|
this.toggleProperty('condensed');
|
2014-06-02 15:49:01 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-30 18:26:11 +00:00
|
|
|
});
|
2014-06-02 14:35:46 +00:00
|
|
|
|
2014-06-06 19:11:26 +00:00
|
|
|
App.NodesShowController = Ember.ObjectController.extend({
|
2014-10-04 16:14:36 +00:00
|
|
|
needs: ["dc", "nodes"],
|
2014-06-06 19:11:26 +00:00
|
|
|
dc: Ember.computed.alias("controllers.dc"),
|
|
|
|
|
|
|
|
actions: {
|
2014-10-04 09:44:50 +00:00
|
|
|
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) {
|
2014-10-04 16:14:36 +00:00
|
|
|
var nodes = controller.get('controllers.nodes').get('nodes');
|
|
|
|
controller.get('controllers.nodes').set('nodes', nodes.filter(function(n) {
|
|
|
|
return n.Node !== node.Node;
|
|
|
|
}));
|
2014-10-04 09:44:50 +00:00
|
|
|
controller.transitionToRoute('nodes');
|
|
|
|
}).fail(function(response) {
|
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-06-06 19:11:26 +00:00
|
|
|
invalidateSession: function(sessionId) {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
var controller = this;
|
|
|
|
var node = controller.get('model');
|
|
|
|
var dc = controller.get('dc').get('datacenter');
|
2014-08-25 18:48:42 +00:00
|
|
|
var token = App.get('settings.token');
|
2014-06-06 19:11:26 +00:00
|
|
|
|
|
|
|
if (window.confirm("Are you sure you want to invalidate this session?")) {
|
|
|
|
// Delete the session
|
|
|
|
Ember.$.ajax({
|
2014-08-25 18:48:42 +00:00
|
|
|
url: (formatUrl("/v1/session/destroy/" + sessionId, dc, token)),
|
2014-06-06 19:11:26 +00:00
|
|
|
type: 'PUT'
|
|
|
|
}).then(function(response) {
|
2014-08-25 18:48:42 +00:00
|
|
|
return Ember.$.getJSON(formatUrl('/v1/session/node/' + node.Node, dc, token)).then(function(data) {
|
2014-08-20 23:51:40 +00:00
|
|
|
controller.set('sessions', data);
|
2014-06-06 19:11:26 +00:00
|
|
|
});
|
|
|
|
}).fail(function(response) {
|
|
|
|
// Render the error message on the form if the request failed
|
2014-08-20 23:51:40 +00:00
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
2014-06-06 19:11:26 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-02 14:35:46 +00:00
|
|
|
App.NodesController = ItemBaseController.extend({
|
|
|
|
items: Ember.computed.alias("nodes"),
|
|
|
|
});
|
|
|
|
|
|
|
|
App.ServicesController = ItemBaseController.extend({
|
|
|
|
items: Ember.computed.alias("services"),
|
|
|
|
});
|
|
|
|
|
2014-08-22 19:25:10 +00:00
|
|
|
App.AclsController = Ember.ArrayController.extend({
|
2014-08-21 21:44:17 +00:00
|
|
|
needs: ["dc", "application"],
|
|
|
|
queryParams: ["filter"],
|
2014-08-22 19:25:10 +00:00
|
|
|
filterText: "Filter by name or ID",
|
|
|
|
searchBar: true,
|
2014-08-23 00:00:26 +00:00
|
|
|
newAclButton: true,
|
2014-08-22 23:46:32 +00:00
|
|
|
types: ["management", "client"],
|
2014-08-22 19:25:10 +00:00
|
|
|
|
2014-08-21 21:44:17 +00:00
|
|
|
dc: Ember.computed.alias("controllers.dc"),
|
2014-08-22 19:25:10 +00:00
|
|
|
items: Ember.computed.alias("acls"),
|
|
|
|
|
|
|
|
filter: "",
|
2014-08-21 21:44:17 +00:00
|
|
|
|
|
|
|
isShowingItem: function() {
|
|
|
|
var currentPath = this.get('controllers.application.currentPath');
|
|
|
|
return (currentPath === "dc.acls.show");
|
|
|
|
}.property('controllers.application.currentPath'),
|
|
|
|
|
|
|
|
filteredContent: function() {
|
|
|
|
var filter = this.get('filter');
|
|
|
|
|
|
|
|
var items = this.get('items').filter(function(item, index, enumerable){
|
|
|
|
// First try to match on the name
|
|
|
|
var nameMatch = item.get('Name').toLowerCase().match(filter.toLowerCase());
|
2014-08-22 19:25:10 +00:00
|
|
|
if (nameMatch !== null) {
|
2014-08-21 21:44:17 +00:00
|
|
|
return nameMatch;
|
|
|
|
} else {
|
|
|
|
return item.get('ID').toLowerCase().match(filter.toLowerCase());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-08-22 19:25:10 +00:00
|
|
|
return items;
|
2014-08-21 21:44:17 +00:00
|
|
|
}.property('filter', 'items.@each'),
|
2014-08-22 23:46:32 +00:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
createAcl: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
|
|
|
|
var controller = this;
|
|
|
|
var newAcl = controller.get('newAcl');
|
|
|
|
var dc = controller.get('dc').get('datacenter');
|
|
|
|
var token = App.get('settings.token');
|
|
|
|
|
|
|
|
// Create the ACL
|
|
|
|
Ember.$.ajax({
|
|
|
|
url: formatUrl('/v1/acl/create', dc, token),
|
|
|
|
type: 'PUT',
|
|
|
|
data: JSON.stringify(newAcl)
|
|
|
|
}).then(function(response) {
|
|
|
|
// transition to the acl
|
|
|
|
controller.transitionToRoute('acls.show', response.ID);
|
2014-10-15 22:55:53 +00:00
|
|
|
|
|
|
|
// Get the ACL again, including the newly created one
|
|
|
|
Ember.$.getJSON(formatUrl('/v1/acl/list', dc, token)).then(function(data) {
|
|
|
|
var objs = [];
|
|
|
|
data.map(function(obj){
|
|
|
|
objs.push(App.Acl.create(obj));
|
|
|
|
});
|
|
|
|
controller.set('items', objs);
|
|
|
|
});
|
|
|
|
|
2014-08-22 23:46:32 +00:00
|
|
|
controller.set('isLoading', false);
|
|
|
|
}).fail(function(response) {
|
|
|
|
// Render the error message on the form if the request failed
|
|
|
|
notify('Received error while creating ACL: ' + response.statusText, 8000);
|
|
|
|
controller.set('isLoading', false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
2014-08-21 21:44:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-08-22 19:25:10 +00:00
|
|
|
App.AclsShowController = Ember.ObjectController.extend({
|
|
|
|
needs: ["dc", "acls"],
|
2014-08-21 21:44:17 +00:00
|
|
|
dc: Ember.computed.alias("controllers.dc"),
|
2014-08-22 19:25:10 +00:00
|
|
|
isLoading: false,
|
2014-08-22 23:46:32 +00:00
|
|
|
types: ["management", "client"],
|
2014-08-22 19:25:10 +00:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
set: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
var controller = this;
|
|
|
|
var acl = controller.get('model');
|
|
|
|
var dc = controller.get('dc').get('datacenter');
|
|
|
|
|
|
|
|
if (window.confirm("Are you sure you want to use this token for your session?")) {
|
|
|
|
// Set
|
|
|
|
var token = App.set('settings.token', acl.ID);
|
|
|
|
controller.transitionToRoute('services');
|
|
|
|
this.set('isLoading', false);
|
2014-08-22 23:03:46 +00:00
|
|
|
notify('Now using token: ' + acl.ID, 3000);
|
2014-08-22 19:25:10 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
clone: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
var controller = this;
|
|
|
|
var acl = controller.get('model');
|
|
|
|
var dc = controller.get('dc').get('datacenter');
|
|
|
|
var token = App.get('settings.token');
|
|
|
|
|
|
|
|
// Set
|
|
|
|
controller.transitionToRoute('services');
|
|
|
|
|
|
|
|
Ember.$.ajax({
|
|
|
|
url: formatUrl('/v1/acl/clone/'+ acl.ID, dc, token),
|
|
|
|
type: 'PUT'
|
|
|
|
}).then(function(response) {
|
|
|
|
controller.transitionToRoute('acls.show', response.ID);
|
|
|
|
controller.set('isLoading', false);
|
2014-12-04 23:25:06 +00:00
|
|
|
notify('Successfully cloned token', 4000);
|
2014-08-22 19:25:10 +00:00
|
|
|
}).fail(function(response) {
|
|
|
|
// Render the error message on the form if the request failed
|
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
|
|
|
controller.set('isLoading', false);
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
delete: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
var controller = this;
|
|
|
|
var acl = 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 delete this token?")) {
|
|
|
|
Ember.$.ajax({
|
|
|
|
url: formatUrl('/v1/acl/destroy/'+ acl.ID, dc, token),
|
|
|
|
type: 'PUT'
|
|
|
|
}).then(function(response) {
|
|
|
|
Ember.$.getJSON(formatUrl('/v1/acl/list', dc, token)).then(function(data) {
|
|
|
|
objs = [];
|
|
|
|
data.map(function(obj){
|
|
|
|
if (obj.ID === "anonymous") {
|
|
|
|
objs.unshift(App.Acl.create(obj));
|
|
|
|
} else {
|
|
|
|
objs.push(App.Acl.create(obj));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
controller.get('controllers.acls').set('acls', objs);
|
|
|
|
}).then(function() {
|
|
|
|
controller.transitionToRoute('acls');
|
|
|
|
controller.set('isLoading', false);
|
2014-08-25 18:48:42 +00:00
|
|
|
notify('ACL deleted successfully', 3000);
|
2014-08-22 19:25:10 +00:00
|
|
|
});
|
|
|
|
}).fail(function(response) {
|
|
|
|
// Render the error message on the form if the request failed
|
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
|
|
|
|
controller.set('isLoading', false);
|
|
|
|
});
|
|
|
|
}
|
2014-08-22 23:46:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updateAcl: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
|
|
|
|
var controller = this;
|
|
|
|
var acl = controller.get('model');
|
|
|
|
var dc = controller.get('dc').get('datacenter');
|
|
|
|
var token = App.get('settings.token');
|
|
|
|
|
|
|
|
// Update the ACL
|
|
|
|
Ember.$.ajax({
|
|
|
|
url: formatUrl('/v1/acl/update', dc, token),
|
|
|
|
type: 'PUT',
|
|
|
|
data: JSON.stringify(acl)
|
|
|
|
}).then(function(response) {
|
|
|
|
// transition to the acl
|
|
|
|
controller.set('isLoading', false);
|
|
|
|
notify('ACL updated successfully', 3000);
|
|
|
|
}).fail(function(response) {
|
|
|
|
// Render the error message on the form if the request failed
|
2014-08-25 18:48:42 +00:00
|
|
|
notify('Received error while updating ACL: ' + response.statusText, 8000);
|
2014-08-22 23:46:32 +00:00
|
|
|
controller.set('isLoading', false);
|
|
|
|
});
|
2014-08-22 19:25:10 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-21 21:44:17 +00:00
|
|
|
});
|
|
|
|
|
2014-08-22 23:03:46 +00:00
|
|
|
App.SettingsController = Ember.ObjectController.extend({
|
|
|
|
actions: {
|
|
|
|
reset: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
var controller = this;
|
|
|
|
|
|
|
|
if (window.confirm("Are your sure you want to reset your settings?")) {
|
|
|
|
localStorage.clear();
|
|
|
|
controller.set('content', App.Settings.create());
|
2014-09-08 13:13:54 +00:00
|
|
|
App.set('settings.token', '');
|
2014-08-22 23:03:46 +00:00
|
|
|
notify('Settings reset', 3000);
|
|
|
|
this.set('isLoading', false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|