ui: use a promise hash for nodes

pull/98/head
Jack Pearkes 2014-04-30 15:25:31 -04:00
parent b2ea2bd96e
commit 4520cff49d
1 changed files with 11 additions and 13 deletions

View File

@ -222,27 +222,25 @@ App.NodesShowRoute = App.BaseRoute.extend({
// by it's identifier passed via the route // by it's identifier passed via the route
// //
model: function(params) { model: function(params) {
return Ember.$.getJSON('/v1/internal/ui/node/' + params.name).then(function(data) { return Ember.RSVP.hash({
return App.Node.create(data) node: Ember.$.getJSON('/v1/internal/ui/node/' + params.name).then(function(data) {
return App.Node.create(data)
}),
nodes: Ember.$.getJSON('/v1/internal/ui/node/' + params.name).then(function(data) {
return App.Node.create(data)
})
}); });
}, },
setupController: function(controller, model) { setupController: function(controller, models) {
controller.set('content', model); controller.set('content', models.node);
// //
// Since we have 2 column layout, we need to also display the // Since we have 2 column layout, we need to also display the
// list of nodes on the left. Hence setting the attribute // list of nodes on the left. Hence setting the attribute
// {{nodes}} on the controller. // {{nodes}} on the controller.
// //
Ember.$.getJSON('/v1/internal/ui/nodes').then(function(data) { controller.set('nodes', models.nodes);
objs = [];
data.map(function(obj){
objs.push(App.Node.create(obj));
});
controller.set('nodes', objs);
});
} }
}); });