Node list divided by roles on assignment screen (WIP)
This commit is contained in:
parent
51038d403a
commit
9c2036c331
@ -38,6 +38,15 @@ define(function() {
|
||||
locked: function() {
|
||||
return this.get('task') && !this.get('task').get('ready');
|
||||
},
|
||||
availableRoles: function() {
|
||||
if (this.get('type') == 'storage') {
|
||||
return ['controller', 'storage']
|
||||
} else if (this.get('type') == 'compute') {
|
||||
return ['controller', 'compute']
|
||||
} else {
|
||||
return ['controller', 'compute', 'storage']
|
||||
}
|
||||
},
|
||||
parse: function(response) {
|
||||
response.nodes = new models.Nodes(response.nodes);
|
||||
response.nodes.cluster = this;
|
||||
|
@ -7,9 +7,10 @@ define(
|
||||
'text!templates/cluster/deployment_control.html',
|
||||
'text!templates/cluster/tab.html',
|
||||
'text!templates/cluster/nodes_tab_summary.html',
|
||||
'text!templates/cluster/node.html',
|
||||
'text!templates/cluster/node_list.html',
|
||||
'text!templates/cluster/node.html'
|
||||
],
|
||||
function(models, dialogViews, taskViews, clusterPageTemplate, deploymentControlTemplate, tabTemplate, nodesTabSummary, nodeTemplate) {
|
||||
function(models, dialogViews, taskViews, clusterPageTemplate, deploymentControlTemplate, tabTemplate, nodesTabSummaryTemplate, nodeListTemplate, nodeTemplate) {
|
||||
var views = {}
|
||||
|
||||
views.ClusterPage = Backbone.View.extend({
|
||||
@ -119,7 +120,7 @@ function(models, dialogViews, taskViews, clusterPageTemplate, deploymentControlT
|
||||
});
|
||||
|
||||
views.NodesTabSummary = Backbone.View.extend({
|
||||
template: _.template(nodesTabSummary),
|
||||
template: _.template(nodesTabSummaryTemplate),
|
||||
render: function() {
|
||||
this.$el.html(this.template({cluster: this.model}));
|
||||
return this;
|
||||
@ -127,26 +128,32 @@ function(models, dialogViews, taskViews, clusterPageTemplate, deploymentControlT
|
||||
});
|
||||
|
||||
views.NodesTabContent = Backbone.View.extend({
|
||||
initialize: function(options) {
|
||||
this.model.get('nodes').bind('reset', this.render, this);
|
||||
this.model.get('nodes').bind('add', this.render, this);
|
||||
},
|
||||
render: function() {
|
||||
this.$el.html((new views.NodeList({collection: this.model.get('nodes')})).render().el);
|
||||
this.$el.html('');
|
||||
_.each(this.model.availableRoles(), function(role) {
|
||||
this.$el.append((new views.NodeList({collection: this.model.get('nodes'), role: role})).render().el);
|
||||
}, this);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
views.NodeList = Backbone.View.extend({
|
||||
className: 'row-fluid',
|
||||
template: _.template(nodeListTemplate),
|
||||
initialize: function(options) {
|
||||
this.collection.bind('reset', this.render, this);
|
||||
this.collection.bind('add', this.render, this);
|
||||
this.role = options.role;
|
||||
},
|
||||
render: function() {
|
||||
this.$el.html(this.template({nodes: this.collection, role: this.role}));
|
||||
if (this.collection.length) {
|
||||
this.$el.html('');
|
||||
this.collection.each(_.bind(function(node) {
|
||||
this.$el.append(new views.Node({model: node}).render().el);
|
||||
}, this));
|
||||
} else {
|
||||
this.$el.html('<div class="span12"><div class="alert">There are no nodes of this type</div></div>');
|
||||
var container = this.$('.node-list-container');
|
||||
this.collection.each(function(node) {
|
||||
container.append(new views.Node({model: node}).render().el);
|
||||
})
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
16
nailgun/static/templates/cluster/node_list.html
Normal file
16
nailgun/static/templates/cluster/node_list.html
Normal file
@ -0,0 +1,16 @@
|
||||
<h2><%= role %></h2>
|
||||
<div>
|
||||
<button class="btn btn-success">
|
||||
<i class="icon-plus icon-white"></i>
|
||||
Add
|
||||
</button>
|
||||
<button class="btn btn-danger <%= nodes.length ? '' : 'disabled' %>">
|
||||
<i class="icon-minus icon-white"></i>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
<% if (nodes.length) { %>
|
||||
<div class="node-list-container"></div>
|
||||
<% } else { %>
|
||||
<div class="span12"><div class="alert">There are no nodes of this type</div></div>
|
||||
<% } %>
|
Loading…
Reference in New Issue
Block a user