2014-04-25 17:49:36 +00:00
|
|
|
App.DcController = Ember.Controller.extend({
|
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,
|
|
|
|
|
|
|
|
checks: function() {
|
2014-04-30 21:31:40 +00:00
|
|
|
var nodes = this.get('nodes');
|
2014-04-25 20:24:36 +00:00
|
|
|
var checks = Ember.A()
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// Combine the checks from all of our nodes
|
|
|
|
// into one.
|
|
|
|
nodes.forEach(function(item) {
|
2014-04-25 20:24:36 +00:00
|
|
|
checks = checks.concat(item.Checks)
|
|
|
|
});
|
|
|
|
|
|
|
|
return checks
|
2014-04-30 21:31:40 +00:00
|
|
|
}.property('Checks'),
|
|
|
|
|
|
|
|
// Returns the total number of failing checks.
|
|
|
|
//
|
|
|
|
// We treat any non-passing checks as failing
|
|
|
|
//
|
|
|
|
totalChecksFailing: function() {
|
|
|
|
var checks = this.get('checks')
|
|
|
|
return (checks.filterBy('Status', 'critical').get('length') +
|
|
|
|
checks.filterBy('Status', 'warning').get('length'))
|
|
|
|
}.property('Checks'),
|
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() {
|
|
|
|
var checks = this.get('checks')
|
2014-04-30 21:31:40 +00:00
|
|
|
var failingChecks = this.get('totalChecksFailing');
|
|
|
|
var passingChecks = checks.filterBy('Status', 'passing').get('length');
|
2014-04-25 20:24:36 +00:00
|
|
|
|
|
|
|
if (this.get('hasFailingChecks') == true) {
|
2014-04-30 21:31:40 +00:00
|
|
|
return failingChecks + ' checks failing';
|
2014-04-25 20:24:36 +00:00
|
|
|
} else {
|
2014-04-30 21:31:40 +00:00
|
|
|
return passingChecks + ' checks passing';
|
2014-04-25 20:24:36 +00:00
|
|
|
}
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
}.property('Checks'),
|
2014-04-25 20:24:36 +00:00
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
//
|
|
|
|
// Boolean if the datacenter has any failing checks.
|
|
|
|
//
|
2014-04-25 20:24:36 +00:00
|
|
|
hasFailingChecks: function() {
|
|
|
|
var checks = this.get('checks')
|
|
|
|
return (checks.filterBy('Status', 'critical').get('length') > 0);
|
2014-04-30 21:31:40 +00:00
|
|
|
}.property('Checks'),
|
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-04-25 17:49:36 +00:00
|
|
|
})
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// Add mixins
|
|
|
|
App.KvShowController = Ember.ObjectController.extend(Ember.Validations.Mixin);
|
2014-04-29 20:16:22 +00:00
|
|
|
|
2014-04-30 14:09:41 +00:00
|
|
|
App.KvShowController.reopen({
|
|
|
|
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);
|
|
|
|
|
|
|
|
var newKey = this.get('newKey');
|
2014-04-30 21:38:56 +00:00
|
|
|
var parentKey = this.get('parentKey');
|
|
|
|
var grandParentKey = this.get('grandParentKey');
|
2014-04-30 20:30:14 +00:00
|
|
|
var controller = this;
|
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-04-30 14:09:41 +00:00
|
|
|
// strip the leading slash.
|
2014-04-30 21:38:56 +00:00
|
|
|
if (!parentKey || parentKey != "/") {
|
|
|
|
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({
|
|
|
|
url: "/v1/kv/" + newKey.get('Key'),
|
|
|
|
type: 'PUT',
|
|
|
|
data: newKey.get('Value')
|
|
|
|
}).then(function(response) {
|
|
|
|
controller.set('isLoading', false)
|
2014-04-30 21:31:40 +00:00
|
|
|
// Transition to edit the key
|
2014-04-30 20:30:14 +00:00
|
|
|
controller.transitionToRoute('kv.edit', newKey.get('urlSafeKey'));
|
2014-04-30 21:31:40 +00:00
|
|
|
// Reload the keys in the left column
|
2014-04-30 20:30:14 +00:00
|
|
|
controller.get('keys').reload()
|
|
|
|
}).fail(function(response) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Render the error message on the form if the request failed
|
2014-04-30 20:30:14 +00:00
|
|
|
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
|
|
|
|
|
|
|
App.KvEditController = Ember.Controller.extend({
|
|
|
|
isLoading: false,
|
|
|
|
|
|
|
|
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-04-30 20:30:14 +00:00
|
|
|
var key = this.get("model");
|
|
|
|
var controller = this;
|
|
|
|
|
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({
|
|
|
|
url: "/v1/kv/" + key.get('Key'),
|
|
|
|
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-04-30 20:30:14 +00:00
|
|
|
controller.set('isLoading', false)
|
|
|
|
}).fail(function(response) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Render the error message on the form if the request failed
|
2014-04-30 20:30:14 +00:00
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText)
|
|
|
|
})
|
2014-04-30 14:16:50 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
deleteKey: function() {
|
|
|
|
this.set('isLoading', true);
|
|
|
|
|
2014-04-30 20:30:14 +00:00
|
|
|
var key = this.get("model");
|
|
|
|
var controller = this;
|
2014-04-30 21:31:40 +00:00
|
|
|
// Get the parent for the transition back up a level
|
|
|
|
// after the delete
|
2014-04-30 20:30:14 +00:00
|
|
|
var parent = key.get('urlSafeParentKey');
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// Delete the key
|
2014-04-30 20:30:14 +00:00
|
|
|
Ember.$.ajax({
|
|
|
|
url: "/v1/kv/" + key.get('Key'),
|
|
|
|
type: 'DELETE'
|
|
|
|
}).then(function(response) {
|
|
|
|
controller.set('isLoading', false);
|
2014-04-30 21:31:40 +00:00
|
|
|
// Tranisiton back up a level
|
2014-04-30 20:30:14 +00:00
|
|
|
controller.transitionToRoute('kv.show', parent);
|
|
|
|
}).fail(function(response) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Render the error message on the form if the request failed
|
2014-04-30 20:30:14 +00:00
|
|
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText)
|
|
|
|
})
|
2014-04-30 14:16:50 +00:00
|
|
|
|
2014-04-29 20:16:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|