consul/ui/javascripts/app/routes.js

158 lines
4.5 KiB
JavaScript
Raw Normal View History

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;
},
2014-04-27 14:42:21 +00:00
setupController: function(controller, model) {
controller.set('content', model);
controller.set('dcs', window.fixtures.dcs);
},
2014-04-23 18:01:42 +00:00
afterModel: function(dcs, transition) {
if (dcs.get('length') === 1) {
this.get('controllers.application').setDc(dcs[0])
this.transitionTo('services', dcs[0]);
}
}
});
2014-04-25 17:49:36 +00:00
// The base DC route
2014-04-23 18:01:42 +00:00
2014-04-25 17:49:36 +00:00
App.DcRoute = App.BaseRoute.extend({
2014-04-23 22:51:06 +00:00
//
2014-04-25 17:49:36 +00:00
// Set the model on the route. We look up the specific service
// by it's identifier passed via the route
2014-04-23 22:51:06 +00:00
//
2014-04-25 17:49:36 +00:00
model: function(params) {
return params.dc;
2014-04-25 20:24:36 +00:00
},
setupController: function(controller, model) {
controller.set('content', model);
controller.set('services', [App.Service.create(window.fixtures.services[0]), App.Service.create(window.fixtures.services[1])]);
controller.set('dcs', window.fixtures.dcs);
},
afterModel: function(dcs, transition) {
this.transitionTo('services');
2014-04-25 17:49:36 +00:00
}
2014-04-23 18:01:42 +00:00
});
2014-04-25 17:49:36 +00:00
/// services
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({
//
// 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
//
// Display an individual service, as well as the global services in the left
// column.
//
App.ServicesShowRoute = 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-24 19:18:11 +00:00
2014-04-25 17:49:36 +00:00
/// nodes
2014-04-24 19:18:11 +00:00
//
// Display an individual node, as well as the global nodes in the left
// column.
//
App.NodesShowRoute = App.BaseRoute.extend({
2014-04-24 19:18:11 +00:00
//
// 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
2014-04-24 19:33:53 +00:00
// list of nodes on the left. Hence setting the attribute
// {{nodes}} on the controller.
2014-04-24 19:18:11 +00:00
//
controller.set('nodes', [App.Node.create(window.fixtures.nodes[0]), App.Node.create(window.fixtures.nodes[1])]);
}
});
//
2014-04-24 19:33:53 +00:00
// Display all the nodes, allow to drill down into the specific nodes.
2014-04-24 19:18:11 +00:00
//
App.NodesRoute = App.BaseRoute.extend({
//
2014-04-24 19:33:53 +00:00
// Set the node as the routes default model to be called in
// the template as {{model}}. This is the "expanded" view.
2014-04-24 19:18:11 +00:00
//
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])]);
}
});