2014-04-23 18:01:42 +00:00
|
|
|
window.App = Ember.Application.create({
|
|
|
|
rootElement: "#app",
|
|
|
|
LOG_TRANSITIONS: true,
|
|
|
|
currentPath: ''
|
|
|
|
});
|
2014-04-21 20:36:50 +00:00
|
|
|
|
|
|
|
App.Router.map(function() {
|
2014-04-23 18:01:42 +00:00
|
|
|
this.route("index", { path: "/" });
|
|
|
|
this.route("services", { path: "/:dc/services" });
|
2014-04-24 17:47:14 +00:00
|
|
|
this.route("service", { path: "/:dc/services/:name" });
|
2014-04-23 18:01:42 +00:00
|
|
|
this.route("nodes", { path: "/:dc/nodes" });
|
|
|
|
this.route("node", { path: "/:dc/nodes/:name" });
|
|
|
|
this.route("kv", { path: "/:dc/kv" });
|
|
|
|
});
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// The main controller for the application. To use this in other
|
|
|
|
// controller you have to use the needs api
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
App.ApplicationController = Ember.Controller.extend({
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// Sets the current datacenter to be used when linking. DC is
|
|
|
|
// a required parameter in the routes, above, and we need
|
|
|
|
// to know our scope. This is so #link-to 'node' dc node-name
|
|
|
|
// works.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
setDc: function(dc) {
|
|
|
|
localStorage.setItem("current_dc", dc);
|
|
|
|
},
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// Retrieves the current datacenter set by this.setDc from
|
|
|
|
// localstorage. returns null if the dc has not been set.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
getDc: function() {
|
|
|
|
return localStorage.getItem("current_dc");
|
|
|
|
}.property("getDc")
|
|
|
|
});
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// Superclass to be used by all of the main routes below. All routes
|
|
|
|
// but the IndexRoute share the need to have a datacenter set.
|
|
|
|
//
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
App.BaseRoute = Ember.Route.extend({
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// When activating the base route, if we don't have a datacenter set,
|
|
|
|
// transition the user to the index route to choose a datacenter.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
activate: function() {
|
|
|
|
var controller = this.controllerFor('application');
|
|
|
|
if (controller.getDc === null) {
|
|
|
|
this.transitionTo('index');
|
|
|
|
};
|
|
|
|
}
|
2014-04-21 20:36:50 +00:00
|
|
|
});
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// The route for choosing datacenters, typically the first route loaded.
|
|
|
|
//
|
|
|
|
// Note: This *does not* extend from BaseRoute as that could cause
|
|
|
|
// and loop of transitions.
|
|
|
|
//
|
2014-04-21 20:36:50 +00:00
|
|
|
App.IndexRoute = Ember.Route.extend({
|
|
|
|
model: function() {
|
2014-04-23 18:01:42 +00:00
|
|
|
return window.fixtures.dcs;
|
|
|
|
},
|
|
|
|
afterModel: function(dcs, transition) {
|
|
|
|
if (dcs.get('length') === 1) {
|
|
|
|
this.get('controllers.application').setDc(dcs[0])
|
|
|
|
this.transitionTo('services', dcs[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// path: /
|
|
|
|
//
|
|
|
|
// The index is for choosing datacenters.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
App.IndexController = Ember.Controller.extend({
|
|
|
|
needs: ['application'],
|
|
|
|
|
|
|
|
actions: {
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// selectDc is called with the datacenter name to be set for
|
|
|
|
// future actions within the application. It's a namespace, essentially.
|
|
|
|
//
|
|
|
|
// See ApplicationController#setDc
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
selectDc: function(dc) {
|
|
|
|
this.get('controllers.application').setDc(dc)
|
|
|
|
this.transitionToRoute('services', dc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// A Consul service.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
App.Service = Ember.Object.extend({
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// The number of failing checks within the service.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
failingChecks: function() {
|
|
|
|
return this.get('Checks').filterBy('Status', 'critical').get('length');
|
|
|
|
}.property('failingChecks'),
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// The number of passing checks within the service.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
passingChecks: function() {
|
|
|
|
return this.get('Checks').filterBy('Status', 'passing').get('length');
|
|
|
|
}.property('passingChecks'),
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// The formatted message returned for the user which represents the
|
|
|
|
// number of checks failing or passing. Returns `1 passing` or `2 failing`
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
checkMessage: function() {
|
|
|
|
if (this.get('hasFailingChecks') === false) {
|
|
|
|
return this.get('passingChecks') + ' passing';
|
|
|
|
} else {
|
|
|
|
return this.get('failingChecks') + ' failing';
|
|
|
|
}
|
|
|
|
}.property('checkMessage'),
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// Boolean of whether or not there are failing checks in the service.
|
|
|
|
// This is used to set color backgrounds and so on.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
hasFailingChecks: function() {
|
|
|
|
return (this.get('failingChecks') > 0);
|
|
|
|
}.property('hasFailingChecks')
|
|
|
|
});
|
|
|
|
|
2014-04-24 17:47:14 +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');
|
|
|
|
}.property('failingChecks'),
|
|
|
|
|
|
|
|
//
|
|
|
|
// The number of passing checks within the service.
|
|
|
|
//
|
|
|
|
passingChecks: function() {
|
|
|
|
return this.get('Checks').filterBy('Status', 'passing').get('length');
|
|
|
|
}.property('passingChecks'),
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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';
|
|
|
|
}
|
|
|
|
}.property('checkMessage'),
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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);
|
|
|
|
}.property('hasFailingChecks')
|
|
|
|
});
|
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// Display all the services, allow to drill down into the specific services.
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
App.ServicesRoute = App.BaseRoute.extend({
|
2014-04-24 17:47:14 +00:00
|
|
|
//
|
|
|
|
// Set the services as the routes default model to be called in
|
|
|
|
// the template as {{model}}
|
|
|
|
//
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
//
|
|
|
|
// Since we have 2 column layout, we need to also display the
|
|
|
|
// list of services on the left. Hence setting the attribute
|
|
|
|
// {{services}} on the controller.
|
|
|
|
//
|
|
|
|
controller.set('services', [App.Service.create(window.fixtures.services[0]), App.Service.create(window.fixtures.services[1])]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-04-24 19:18:11 +00:00
|
|
|
|
2014-04-24 17:47:14 +00:00
|
|
|
//
|
|
|
|
// Display an individual service, as well as the global services in the left
|
|
|
|
// column.
|
|
|
|
//
|
|
|
|
App.ServiceRoute = App.BaseRoute.extend({
|
|
|
|
//
|
|
|
|
// Set the model on the route. We look up the specific service
|
|
|
|
// by it's identifier passed via the route
|
|
|
|
//
|
|
|
|
model: function(params) {
|
|
|
|
return [App.Node.create(window.fixtures.services_full[params.name][0]), App.Node.create(window.fixtures.services_full[params.name][1])];
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
controller.set('content', model);
|
|
|
|
//
|
|
|
|
// Since we have 2 column layout, we need to also display the
|
|
|
|
// list of services on the left. Hence setting the attribute
|
|
|
|
// {{services}} on the controller.
|
|
|
|
//
|
|
|
|
controller.set('services', [App.Service.create(window.fixtures.services[0]), App.Service.create(window.fixtures.services[1])]);
|
2014-04-21 20:36:50 +00:00
|
|
|
}
|
|
|
|
});
|
2014-04-23 18:01:42 +00:00
|
|
|
|
2014-04-23 22:51:06 +00:00
|
|
|
//
|
|
|
|
// Services
|
|
|
|
//
|
2014-04-23 18:01:42 +00:00
|
|
|
App.ServicesView = Ember.View.extend({
|
2014-04-24 17:47:14 +00:00
|
|
|
templateName: 'services',
|
2014-04-23 18:01:42 +00:00
|
|
|
layoutName: 'default_layout'
|
|
|
|
})
|
|
|
|
|
2014-04-24 17:47:14 +00:00
|
|
|
//
|
|
|
|
// Services
|
|
|
|
//
|
|
|
|
App.ServiceView = Ember.View.extend({
|
2014-04-24 19:18:11 +00:00
|
|
|
//
|
|
|
|
// We use the same template as we do for the services
|
|
|
|
// array and have a simple conditional to display the nested
|
|
|
|
// individual service resource.
|
|
|
|
//
|
2014-04-24 17:47:14 +00:00
|
|
|
templateName: 'services',
|
|
|
|
layoutName: 'default_layout'
|
|
|
|
})
|
|
|
|
|
|
|
|
//
|
|
|
|
// path: /:dc/services
|
|
|
|
//
|
|
|
|
App.ServicesController = Ember.Controller.extend({
|
|
|
|
needs: ['application']
|
|
|
|
})
|
|
|
|
|
|
|
|
//
|
|
|
|
// path: /:dc/services/:name
|
|
|
|
//
|
|
|
|
App.ServiceController = Ember.Controller.extend({
|
|
|
|
needs: ['application']
|
|
|
|
})
|
2014-04-24 19:18:11 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// path: /:dc/nodes
|
|
|
|
//
|
|
|
|
App.NodesController = Ember.Controller.extend({
|
|
|
|
needs: ['application']
|
|
|
|
})
|
|
|
|
|
|
|
|
//
|
|
|
|
// path: /:dc/nodes/:name
|
|
|
|
//
|
|
|
|
App.NodeController = Ember.Controller.extend({
|
|
|
|
needs: ['application']
|
|
|
|
})
|
|
|
|
|
|
|
|
//
|
|
|
|
// Nodes
|
|
|
|
//
|
|
|
|
App.NodesView = Ember.View.extend({
|
|
|
|
templateName: 'nodes',
|
|
|
|
layoutName: 'default_layout'
|
|
|
|
})
|
|
|
|
|
|
|
|
App.NodeView = Ember.View.extend({
|
|
|
|
//
|
|
|
|
// We use the same template as we do for the nodes
|
|
|
|
// array and have a simple conditional to display the nested
|
|
|
|
// individual node resource.
|
|
|
|
//
|
|
|
|
templateName: 'nodes',
|
|
|
|
layoutName: 'default_layout'
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Display an individual node, as well as the global nodes in the left
|
|
|
|
// column.
|
|
|
|
//
|
|
|
|
App.NodeRoute = App.BaseRoute.extend({
|
|
|
|
//
|
|
|
|
// Set the model on the route. We look up the specific node
|
|
|
|
// by it's identifier passed via the route
|
|
|
|
//
|
|
|
|
model: function(params) {
|
|
|
|
return App.Node.create(window.fixtures.nodes_full[params.name]);
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
controller.set('content', model);
|
|
|
|
//
|
|
|
|
// Since we have 2 column layout, we need to also display the
|
|
|
|
// list of services on the left. Hence setting the attribute
|
|
|
|
// {{services}} on the controller.
|
|
|
|
//
|
|
|
|
controller.set('nodes', [App.Node.create(window.fixtures.nodes[0]), App.Node.create(window.fixtures.nodes[1])]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//
|
|
|
|
// Display all the services, allow to drill down into the specific services.
|
|
|
|
//
|
|
|
|
App.NodesRoute = App.BaseRoute.extend({
|
|
|
|
//
|
|
|
|
// Set the services as the routes default model to be called in
|
|
|
|
// the template as {{model}}
|
|
|
|
//
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
//
|
|
|
|
// Since we have 2 column layout, we need to also display the
|
|
|
|
// list of nodes on the left. Hence setting the attribute
|
|
|
|
// {{nodes}} on the controller.
|
|
|
|
//
|
|
|
|
controller.set('nodes', [App.Node.create(window.fixtures.nodes[0]), App.Node.create(window.fixtures.nodes[1])]);
|
|
|
|
}
|
|
|
|
});
|