hardware info output

This commit is contained in:
Julia Aranovich 2013-07-26 14:45:59 +04:00 committed by default
parent 0596bd5139
commit 0ef4cfcabe
5 changed files with 18 additions and 25 deletions

View File

@ -126,18 +126,12 @@ define(['utils'], function(utils) {
if (resourceName == 'cores') {
resource = this.get('meta').cpu.total;
} else if (resourceName == 'hdd') {
var hdd = 0;
_.each(this.get('meta').disks, function(disk) {
if (_.isNumber(disk.size)) {
hdd += disk.size;
}
});
resource = hdd;
resource = _.reduce(this.get('meta').disks, function(hdd, disk) {return _.isNumber(disk.size) ? hdd + disk.size : hdd;}, 0);
} else if (resourceName == 'ram') {
resource = this.get('meta').memory.total / Math.pow(1024, 3);
resource = this.get('meta').memory.total;
}
} catch (e) {}
if (_.isNaN(resource)) {
if (_.isNaN(resource) || !_.isNumber(resource)) {
resource = 0;
}
return resource;

View File

@ -418,6 +418,7 @@ function(utils, models, commonViews, dialogViews, nodesTabSummaryTemplate, editN
Node = Backbone.View.extend({
template: _.template(nodeTemplate),
nodeStatusTemplate: _.template(nodeStatusTemplate),
templateHelpers: _.pick(utils, 'showDiskSize', 'showMemorySize'),
events: {
'click .node-name': 'startNodeRenaming',
'keydown .node-renameable': 'onNodeNameInputKeydown',
@ -510,13 +511,13 @@ function(utils, models, commonViews, dialogViews, nodesTabSummaryTemplate, editN
this.model.on('change:progress', this.updateProgress, this);
},
render: function() {
this.$el.html(this.template({
this.$el.html(this.template(_.extend({
node: this.model,
renaming: this.renaming,
renameable: this.renameable,
selectableForAddition: this.selectableForAddition,
selectableForDeletion: this.selectableForDeletion
}));
}, this.templateHelpers)));
this.updateStatus();
return this;
}
@ -876,9 +877,7 @@ function(utils, models, commonViews, dialogViews, nodesTabSummaryTemplate, editN
NodeInterface = Backbone.View.extend({
template: _.template(nodeInterfaceTemplate),
templateHelpers: {
showBandwidth: utils.showBandwidth
},
templateHelpers: _.pick(utils, 'showBandwidth'),
events: {
'sortremove .logical-network-box': 'dragStart',
'sortreceive .logical-network-box': 'dragStop',

View File

@ -16,13 +16,14 @@
define(
[
'models',
'utils',
'views/common',
'views/dialogs',
'text!templates/clusters/page.html',
'text!templates/clusters/cluster.html',
'text!templates/clusters/new.html'
],
function(models, commonViews, dialogViews, clustersPageTemplate, clusterTemplate, newClusterTemplate) {
function(models, utils, commonViews, dialogViews, clustersPageTemplate, clusterTemplate, newClusterTemplate) {
'use strict';
var ClustersPage, ClusterList, Cluster;
@ -71,6 +72,7 @@ function(models, commonViews, dialogViews, clustersPageTemplate, clusterTemplate
tagName: 'a',
className: 'span3 clusterbox',
template: _.template(clusterTemplate),
templateHelpers: _.pick(utils, 'showDiskSize', 'showMemorySize'),
updateInterval: 3000,
scheduleUpdate: function() {
if (this.model.task('cluster_deletion', ['running', 'ready']) || this.model.task('deploy', 'running')) {
@ -117,7 +119,7 @@ function(models, commonViews, dialogViews, clustersPageTemplate, clusterTemplate
this.model.on('change', this.render, this);
},
render: function() {
this.$el.html(this.template({cluster: this.model}));
this.$el.html(this.template(_.extend({cluster: this.model}, this.templateHelpers)));
this.updateProgress();
if (this.model.task('cluster_deletion', ['running', 'ready'])) {
this.$el.addClass('disabled-cluster');

View File

@ -14,10 +14,9 @@
</div>
<div class="node-status"></div>
<div class="node-hardware">
<span>CPU: <%= node.resource('cores') && _.isNumber(node.resource('cores')) ? node.resource('cores') : '?' %></span>
<% if (node.resource('hdd')) var hdd = node.resource('hdd')/Math.pow(1000, 3) %>
<span>HDD: <%= hdd ? hdd < 100 ? hdd.toFixed(1) + 'GB' : (hdd/1000).toFixed(1) + 'TB' : '?TB' %></span>
<span>RAM: <%= node.resource('ram') && _.isNumber(node.resource('ram')) ? node.resource('ram').toFixed(1) : '?' %>GB</span>
<span>CPU: <%= node.resource('cores') || '?' %></span>
<span>HDD: <%= node.resource('hdd') ? showDiskSize(node.resource('hdd')) : '?GB' %></span>
<span>RAM: <%= node.resource('ram') ? showMemorySize(node.resource('ram')) : '?GB' %></span>
</div>
<% if (!selectableForAddition && !selectableForDeletion) { %>

View File

@ -8,11 +8,10 @@
<% if (nodes.length) { %>
<div class="span6">CPU (cores):</div>
<div class="span4"><%= nodes.resources('cores') %></div>
<div class="span6">RAM (GB):</div>
<div class="span4"><%= nodes.resources('ram').toFixed(1) %></div>
<% var hdd = nodes.resources('hdd')/Math.pow(1000, 3) %>
<div class="span6">HDD (<%= hdd < 100 ? 'GB' : 'TB' %>):</div>
<div class="span4"><%= hdd < 100 ? hdd.toFixed(1) : (hdd/1000).toFixed(1) %></div>
<div class="span6">HDD:</div>
<div class="span4"><%= nodes.resources('hdd') ? showDiskSize(nodes.resources('hdd')) : '?GB' %></div>
<div class="span6">RAM:</div>
<div class="span4"><%= nodes.resources('ram') ? showMemorySize(nodes.resources('ram')) : '?GB' %></div>
<% } %>
</div>
<% } %>