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-29 17:06:26 +00:00
|
|
|
actions: {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Used to link to keys that are not objects,
|
|
|
|
// like parents and grandParents
|
2014-04-29 17:06:26 +00:00
|
|
|
linkToKey: function(key) {
|
|
|
|
key = key.replace(/\//g, "-")
|
|
|
|
|
|
|
|
if (key.slice(-1) === "-") {
|
|
|
|
this.transitionTo('kv.show', key)
|
|
|
|
} else {
|
|
|
|
this.transitionTo('kv.edit', key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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.
|
|
|
|
//
|
2014-04-30 21:31:40 +00:00
|
|
|
App.IndexRoute = App.BaseRoute.extend({
|
|
|
|
// Retrieve the list of datacenters
|
2014-04-30 18:02:20 +00:00
|
|
|
model: function(params) {
|
|
|
|
return Ember.$.getJSON('/v1/catalog/datacenters').then(function(data) {
|
|
|
|
return data
|
2014-04-30 21:31:40 +00:00
|
|
|
})
|
2014-04-27 14:42:21 +00:00
|
|
|
},
|
|
|
|
|
2014-04-30 20:30:14 +00:00
|
|
|
afterModel: function(model, transition) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// If we only have one datacenter, jump
|
|
|
|
// straight to it and bypass the global
|
|
|
|
// view
|
2014-04-30 20:30:14 +00:00
|
|
|
if (model.get('length') === 1) {
|
|
|
|
this.transitionTo('services', model[0]);
|
2014-04-23 18:01:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// The parent route for all resources. This keeps the top bar
|
|
|
|
// functioning, as well as the per-dc requests.
|
2014-04-25 17:49:36 +00:00
|
|
|
App.DcRoute = App.BaseRoute.extend({
|
|
|
|
model: function(params) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Return a promise hash to retreieve the
|
|
|
|
// dcs and nodes used in the header
|
2014-04-30 20:30:14 +00:00
|
|
|
return Ember.RSVP.hash({
|
|
|
|
dc: params.dc,
|
|
|
|
dcs: Ember.$.getJSON('/v1/catalog/datacenters'),
|
|
|
|
nodes: Ember.$.getJSON('/v1/internal/ui/nodes').then(function(data) {
|
|
|
|
objs = [];
|
2014-04-30 18:02:20 +00:00
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// Merge the nodes into a list and create objects out of them
|
2014-04-30 20:30:14 +00:00
|
|
|
data.map(function(obj){
|
|
|
|
objs.push(App.Node.create(obj));
|
|
|
|
});
|
2014-04-25 20:24:36 +00:00
|
|
|
|
2014-04-30 20:30:14 +00:00
|
|
|
return objs;
|
|
|
|
})
|
2014-04-30 18:02:20 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-04-30 20:30:14 +00:00
|
|
|
setupController: function(controller, models) {
|
|
|
|
controller.set('content', models.dc);
|
|
|
|
controller.set('nodes', models.nodes);
|
|
|
|
controller.set('dcs', models.dcs);
|
2014-04-25 17:49:36 +00:00
|
|
|
}
|
2014-04-23 18:01:42 +00:00
|
|
|
});
|
|
|
|
|
2014-04-28 22:23:01 +00:00
|
|
|
|
2014-04-29 18:49:07 +00:00
|
|
|
App.KvIndexRoute = App.BaseRoute.extend({
|
2014-04-30 21:31:40 +00:00
|
|
|
// If they hit /kv we want to just move them to /kv/-
|
2014-04-29 17:06:26 +00:00
|
|
|
beforeModel: function() {
|
|
|
|
this.transitionTo('kv.show', '-')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
App.KvShowRoute = App.BaseRoute.extend({
|
|
|
|
model: function(params) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Convert the key back to the format consul understands
|
2014-04-29 17:06:26 +00:00
|
|
|
var key = params.key.replace(/-/g, "/")
|
2014-04-30 22:05:44 +00:00
|
|
|
var dc = this.modelFor('dc').dc;
|
2014-04-28 22:23:01 +00:00
|
|
|
|
2014-04-30 22:31:45 +00:00
|
|
|
// Return a promise has with the ?keys for that namespace
|
|
|
|
// and the original key requested in params
|
|
|
|
return Ember.RSVP.hash({
|
|
|
|
key: key,
|
|
|
|
keys: Ember.$.getJSON('/v1/kv/' + key + '?keys&seperator=' + '/&dc=' + dc).then(function(data) {
|
|
|
|
objs = [];
|
|
|
|
data.map(function(obj){
|
|
|
|
objs.push(App.Key.create({Key: obj}));
|
|
|
|
});
|
|
|
|
return objs;
|
|
|
|
})
|
2014-04-30 19:02:31 +00:00
|
|
|
});
|
2014-04-28 22:23:01 +00:00
|
|
|
},
|
|
|
|
|
2014-04-30 22:31:45 +00:00
|
|
|
setupController: function(controller, models) {
|
2014-04-30 22:05:44 +00:00
|
|
|
var parentKey = "/";
|
|
|
|
var grandParentKey = "/";
|
2014-04-30 22:31:45 +00:00
|
|
|
var key = models.key;
|
|
|
|
|
|
|
|
// Loop over the keys
|
|
|
|
models.keys.forEach(function(item, index) {
|
|
|
|
if (item.get('Key') == key) {
|
2014-04-30 23:22:07 +00:00
|
|
|
// Handle having only one key as a sub-parent
|
2014-04-30 22:31:45 +00:00
|
|
|
parentKey = item.get('Key');
|
2014-04-30 23:22:07 +00:00
|
|
|
grandParentKey = item.get('parentKey');
|
2014-04-30 22:31:45 +00:00
|
|
|
// Remove the dupe
|
|
|
|
models.keys.splice(index, 1);
|
|
|
|
}
|
|
|
|
});
|
2014-04-30 22:05:44 +00:00
|
|
|
|
2014-04-30 22:31:45 +00:00
|
|
|
controller.set('content', models.keys);
|
2014-04-30 21:37:05 +00:00
|
|
|
controller.set('parentKey', parentKey);
|
|
|
|
controller.set('grandParentKey', grandParentKey);
|
2014-04-30 14:09:41 +00:00
|
|
|
controller.set('newKey', App.Key.create());
|
2014-04-29 17:06:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
App.KvEditRoute = App.BaseRoute.extend({
|
|
|
|
model: function(params) {
|
2014-04-30 22:05:44 +00:00
|
|
|
var keyName = params.key.replace(/-/g, "/");
|
2014-04-30 19:02:31 +00:00
|
|
|
var key = keyName;
|
|
|
|
var parentKey;
|
2014-04-30 22:05:44 +00:00
|
|
|
var dc = this.modelFor('dc').dc;
|
2014-04-30 19:02:31 +00:00
|
|
|
|
|
|
|
// Get the parent key
|
|
|
|
if (key.slice(-1) == "/") {
|
|
|
|
key = key.substring(0, key.length - 1);
|
|
|
|
}
|
|
|
|
parts = key.split('/');
|
2014-04-30 21:31:40 +00:00
|
|
|
// Go one level up
|
2014-04-30 19:02:31 +00:00
|
|
|
parts.pop();
|
2014-04-30 21:31:40 +00:00
|
|
|
// If we are all the way up, just return nothing for the root
|
2014-04-30 19:02:31 +00:00
|
|
|
if (parts.length == 0) {
|
|
|
|
parentKey = ""
|
|
|
|
} else {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Add a slash
|
2014-04-30 19:02:31 +00:00
|
|
|
parentKey = parts.join("/") + "/";
|
|
|
|
}
|
|
|
|
|
2014-04-30 21:31:40 +00:00
|
|
|
// Return a promise hash to get the data for both columns
|
2014-04-30 20:30:14 +00:00
|
|
|
return Ember.RSVP.hash({
|
|
|
|
key: Ember.$.getJSON('/v1/kv/' + keyName).then(function(data) {
|
2014-04-30 21:31:40 +00:00
|
|
|
// Convert the returned data to a Key
|
2014-04-30 20:30:14 +00:00
|
|
|
return App.Key.create().setProperties(data[0]);
|
|
|
|
}),
|
2014-04-30 22:05:44 +00:00
|
|
|
keys: keysPromise = Ember.$.getJSON('/v1/kv/' + parentKey + '?keys&seperator=' + '/' + '&dc=' + dc).then(function(data) {
|
2014-04-30 20:30:14 +00:00
|
|
|
objs = [];
|
|
|
|
data.map(function(obj){
|
|
|
|
objs.push(App.Key.create({Key: obj}));
|
|
|
|
});
|
|
|
|
return objs;
|
|
|
|
}),
|
2014-04-30 19:02:31 +00:00
|
|
|
});
|
2014-04-29 17:06:26 +00:00
|
|
|
},
|
2014-04-29 17:34:13 +00:00
|
|
|
|
2014-04-30 20:30:14 +00:00
|
|
|
setupController: function(controller, models) {
|
|
|
|
controller.set('content', models.key);
|
2014-04-29 18:49:07 +00:00
|
|
|
|
2014-04-30 22:31:45 +00:00
|
|
|
var parentKey = "/";
|
|
|
|
var grandParentKey = "/";
|
|
|
|
|
|
|
|
// Loop over the keys
|
|
|
|
models.keys.forEach(function(item, index) {
|
|
|
|
if (item.get('Key') == models.key.get('parentKey')) {
|
|
|
|
parentKey = item.get('Key');
|
2014-04-30 23:22:07 +00:00
|
|
|
grandParentKey = item.get('parentKey');
|
2014-04-30 22:31:45 +00:00
|
|
|
// Remove the dupe
|
|
|
|
models.keys.splice(index, 1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-05-01 01:29:45 +00:00
|
|
|
controller.set('parentKey', parentKey);
|
|
|
|
controller.set('grandParentKey', grandParentKey);
|
2014-05-01 02:16:12 +00:00
|
|
|
controller.set('siblings', models.keys);
|
2014-04-28 22:23:01 +00:00
|
|
|
}
|
|
|
|
});
|
2014-04-24 17:47:14 +00:00
|
|
|
|
2014-04-23 18:01:42 +00:00
|
|
|
App.ServicesRoute = App.BaseRoute.extend({
|
2014-04-30 18:02:20 +00:00
|
|
|
model: function(params) {
|
2014-04-30 22:05:44 +00:00
|
|
|
var dc = this.modelFor('dc').dc
|
2014-04-30 21:31:40 +00:00
|
|
|
// Return a promise to retrieve all of the services
|
2014-04-30 22:05:44 +00:00
|
|
|
return Ember.$.getJSON('/v1/internal/ui/services?dc=' + dc).then(function(data) {
|
2014-04-30 18:02:20 +00:00
|
|
|
objs = [];
|
|
|
|
data.map(function(obj){
|
|
|
|
objs.push(App.Service.create(obj));
|
|
|
|
});
|
|
|
|
return objs
|
|
|
|
});
|
|
|
|
},
|
2014-04-24 17:47:14 +00:00
|
|
|
setupController: function(controller, model) {
|
2014-04-30 18:02:20 +00:00
|
|
|
controller.set('services', model);
|
2014-04-24 17:47:14 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-04-24 19:18:11 +00:00
|
|
|
|
2014-04-25 17:25:12 +00:00
|
|
|
App.ServicesShowRoute = App.BaseRoute.extend({
|
2014-04-24 17:47:14 +00:00
|
|
|
model: function(params) {
|
2014-04-30 22:05:44 +00:00
|
|
|
var dc = this.modelFor('dc').dc
|
2014-04-30 21:31:40 +00:00
|
|
|
// Here we just use the built-in health endpoint, as it gives us everything
|
|
|
|
// we need.
|
2014-04-30 22:05:44 +00:00
|
|
|
return Ember.$.getJSON('/v1/health/service/' + params.name + '?dc=' + dc).then(function(data) {
|
2014-04-30 18:02:20 +00:00
|
|
|
objs = [];
|
|
|
|
data.map(function(obj){
|
|
|
|
objs.push(App.Node.create(obj));
|
|
|
|
});
|
|
|
|
return objs;
|
|
|
|
});
|
|
|
|
},
|
2014-04-21 20:36:50 +00:00
|
|
|
});
|
2014-04-23 18:01:42 +00:00
|
|
|
|
2014-04-25 17:32:41 +00:00
|
|
|
App.NodesShowRoute = App.BaseRoute.extend({
|
2014-04-24 19:18:11 +00:00
|
|
|
model: function(params) {
|
2014-04-30 22:05:44 +00:00
|
|
|
var dc = this.modelFor('dc').dc
|
2014-04-30 21:31:40 +00:00
|
|
|
// Return a promise hash of the node and nodes
|
2014-04-30 19:25:31 +00:00
|
|
|
return Ember.RSVP.hash({
|
2014-04-30 22:05:44 +00:00
|
|
|
node: Ember.$.getJSON('/v1/internal/ui/node/' + params.name + '?dc=' + dc).then(function(data) {
|
2014-04-30 19:25:31 +00:00
|
|
|
return App.Node.create(data)
|
|
|
|
}),
|
2014-04-30 22:05:44 +00:00
|
|
|
nodes: Ember.$.getJSON('/v1/internal/ui/node/' + params.name + '?dc=' + dc).then(function(data) {
|
2014-04-30 19:25:31 +00:00
|
|
|
return App.Node.create(data)
|
|
|
|
})
|
2014-04-30 18:02:20 +00:00
|
|
|
});
|
2014-04-24 19:18:11 +00:00
|
|
|
},
|
|
|
|
|
2014-04-30 19:25:31 +00:00
|
|
|
setupController: function(controller, models) {
|
|
|
|
controller.set('content', models.node);
|
2014-04-24 19:18:11 +00:00
|
|
|
//
|
|
|
|
// 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
|
|
|
//
|
2014-04-30 19:25:31 +00:00
|
|
|
controller.set('nodes', models.nodes);
|
2014-04-24 19:18:11 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
App.NodesRoute = App.BaseRoute.extend({
|
2014-04-30 18:02:20 +00:00
|
|
|
model: function(params) {
|
2014-04-30 22:05:44 +00:00
|
|
|
var dc = this.modelFor('dc').dc
|
2014-04-30 21:31:40 +00:00
|
|
|
// Return a promise containing the nodes
|
2014-04-30 22:05:44 +00:00
|
|
|
return Ember.$.getJSON('/v1/internal/ui/nodes?dc=' + dc).then(function(data) {
|
2014-04-30 18:02:20 +00:00
|
|
|
objs = [];
|
|
|
|
data.map(function(obj){
|
|
|
|
objs.push(App.Node.create(obj));
|
|
|
|
});
|
|
|
|
return objs
|
|
|
|
});
|
|
|
|
},
|
2014-04-24 19:18:11 +00:00
|
|
|
setupController: function(controller, model) {
|
2014-04-30 18:02:20 +00:00
|
|
|
controller.set('nodes', model);
|
2014-04-24 19:18:11 +00:00
|
|
|
}
|
|
|
|
});
|