2014-04-25 17:49:36 +00:00
|
|
|
//
|
|
|
|
// A Consul service.
|
|
|
|
//
|
|
|
|
App.Service = Ember.Object.extend({
|
|
|
|
//
|
|
|
|
// The number of failing checks within the service.
|
|
|
|
//
|
|
|
|
failingChecks: function() {
|
2014-04-30 18:02:20 +00:00
|
|
|
if (this.get('ChecksCritical') != undefined) {
|
|
|
|
return (this.get('ChecksCritical') + this.get('ChecksWarning'))
|
|
|
|
} else {
|
|
|
|
return this.get('Checks').filterBy('Status', 'critical').get('length');
|
|
|
|
}
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('Checks'),
|
2014-04-25 17:49:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// The number of passing checks within the service.
|
|
|
|
//
|
|
|
|
passingChecks: function() {
|
2014-04-30 18:02:20 +00:00
|
|
|
if (this.get('ChecksPassing') != undefined) {
|
|
|
|
return this.get('ChecksPassing')
|
|
|
|
} else {
|
|
|
|
return this.get('Checks').filterBy('Status', 'passing').get('length');
|
|
|
|
}
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('Checks'),
|
2014-04-25 17:49:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// The formatted message returned for the user which represents the
|
|
|
|
// number of checks failing or passing. Returns `1 passing` or `2 failing`
|
|
|
|
//
|
|
|
|
checkMessage: function() {
|
|
|
|
if (this.get('hasFailingChecks') === false) {
|
|
|
|
return this.get('passingChecks') + ' passing';
|
|
|
|
} else {
|
|
|
|
return this.get('failingChecks') + ' failing';
|
|
|
|
}
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('Checks'),
|
2014-04-25 17:49:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Boolean of whether or not there are failing checks in the service.
|
|
|
|
// This is used to set color backgrounds and so on.
|
|
|
|
//
|
|
|
|
hasFailingChecks: function() {
|
|
|
|
return (this.get('failingChecks') > 0);
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('Checks')
|
2014-04-25 17:49:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
//
|
|
|
|
// A Consul Node
|
|
|
|
//
|
|
|
|
App.Node = Ember.Object.extend({
|
|
|
|
//
|
|
|
|
// The number of failing checks within the service.
|
|
|
|
//
|
|
|
|
failingChecks: function() {
|
|
|
|
return this.get('Checks').filterBy('Status', 'critical').get('length');
|
2014-04-29 19:30:00 +00:00
|
|
|
}.property('Checks'),
|
2014-04-25 17:49:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// The number of passing checks within the service.
|
|
|
|
//
|
|
|
|
passingChecks: function() {
|
|
|
|
return this.get('Checks').filterBy('Status', 'passing').get('length');
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('Checks'),
|
2014-04-25 17:49:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// The formatted message returned for the user which represents the
|
|
|
|
// number of checks failing or passing. Returns `1 passing` or `2 failing`
|
|
|
|
//
|
|
|
|
checkMessage: function() {
|
|
|
|
if (this.get('hasFailingChecks') === false) {
|
|
|
|
return this.get('passingChecks') + ' passing';
|
|
|
|
} else {
|
|
|
|
return this.get('failingChecks') + ' failing';
|
|
|
|
}
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('Checks'),
|
2014-04-25 17:49:36 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Boolean of whether or not there are failing checks in the service.
|
|
|
|
// This is used to set color backgrounds and so on.
|
|
|
|
//
|
|
|
|
hasFailingChecks: function() {
|
|
|
|
return (this.get('failingChecks') > 0);
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('Checks')
|
2014-04-25 17:49:36 +00:00
|
|
|
});
|
|
|
|
|
2014-04-29 17:06:26 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// A key/value object
|
|
|
|
//
|
2014-04-30 14:09:41 +00:00
|
|
|
App.Key = Ember.Object.extend(Ember.Validations.Mixin, {
|
|
|
|
validations: {
|
|
|
|
key: { presence: true },
|
|
|
|
value: { presence: true }
|
|
|
|
},
|
|
|
|
|
2014-04-30 16:15:54 +00:00
|
|
|
keyValid: Ember.computed.empty('errors.key'),
|
|
|
|
valueValid: Ember.computed.empty('errors.value'),
|
|
|
|
|
2014-04-29 17:06:26 +00:00
|
|
|
isFolder: function() {
|
|
|
|
return (this.get('key').slice(-1) == "/")
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('key'),
|
2014-04-29 17:06:26 +00:00
|
|
|
|
2014-04-29 20:32:38 +00:00
|
|
|
urlSafeKey: function() {
|
|
|
|
return this.get('key').replace(/\//g, "-")
|
|
|
|
}.property('key'),
|
|
|
|
|
|
|
|
linkToRoute: function() {
|
|
|
|
var key = this.get('urlSafeKey')
|
|
|
|
|
|
|
|
if (key.slice(-1) === "-") {
|
|
|
|
return 'kv.show'
|
|
|
|
} else {
|
|
|
|
return 'kv.edit'
|
|
|
|
}
|
|
|
|
}.property('key'),
|
|
|
|
|
2014-04-29 18:49:07 +00:00
|
|
|
keyParts: function() {
|
|
|
|
var key = this.get('key');
|
2014-04-29 17:34:13 +00:00
|
|
|
|
2014-04-29 18:49:07 +00:00
|
|
|
if (key.slice(-1) == "/") {
|
|
|
|
key = key.substring(0, key.length - 1);
|
|
|
|
}
|
|
|
|
return key.split('/');
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('key'),
|
2014-04-29 18:49:07 +00:00
|
|
|
|
|
|
|
parentKey: function() {
|
2014-04-29 19:24:32 +00:00
|
|
|
var parts = this.get('keyParts').toArray();
|
2014-04-29 18:49:07 +00:00
|
|
|
|
|
|
|
parts.pop();
|
|
|
|
|
|
|
|
return parts.join("/") + "/";
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('key'),
|
2014-04-29 18:49:07 +00:00
|
|
|
|
|
|
|
grandParentKey: function() {
|
2014-04-29 19:24:32 +00:00
|
|
|
var parts = this.get('keyParts').toArray();
|
2014-04-29 17:34:13 +00:00
|
|
|
|
2014-04-29 18:49:07 +00:00
|
|
|
parts.pop();
|
|
|
|
parts.pop();
|
2014-04-29 17:06:26 +00:00
|
|
|
|
2014-04-29 18:49:07 +00:00
|
|
|
return parts.join("/") + "/";
|
2014-04-29 19:24:32 +00:00
|
|
|
}.property('key')
|
2014-04-29 17:06:26 +00:00
|
|
|
});
|