mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
parent
d57a9c1322
commit
d7ab304b99
@ -140,7 +140,16 @@ define(function(require) {
|
||||
});
|
||||
|
||||
context.on("change", "#DISK_COST", function() {
|
||||
var disk = document.getElementById('DISK_COST').value;
|
||||
var disk = parseInt(document.getElementById('DISK_COST').value);
|
||||
that.templateDISKS = JSON.parse(localStorage.getItem("disksJSON"));
|
||||
if (that.templateDISKS){
|
||||
var totalGB = 0;
|
||||
$.each(that.templateDISKS, function(key, value){
|
||||
totalGB += value.SIZE / 1024;
|
||||
});
|
||||
totalCostDisk = totalGB * disk;
|
||||
CapacityCreate.totalCost(totalCostDisk);
|
||||
}
|
||||
document.getElementById('total_value_disk').textContent = convertCostNumber(disk * 24 * 30);
|
||||
$(".total_disk_cost", context).show();
|
||||
});
|
||||
@ -234,6 +243,9 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _fill(context, templateJSON) {
|
||||
var that = this;
|
||||
that.templateDISKS = $.extend(true, {}, templateJSON.DISK);
|
||||
localStorage.setItem("disksJSON", JSON.stringify(that.templateDISKS));
|
||||
var sunstone_template = templateJSON.SUNSTONE;
|
||||
if (sunstone_template) {
|
||||
if (sunstone_template["NETWORK_SELECT"] &&
|
||||
|
@ -31,6 +31,8 @@ define(function(require) {
|
||||
|
||||
var TemplateHTML = require('hbs!./capacity-create/html');
|
||||
|
||||
this.totalCostDisk = 0;
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
@ -83,17 +85,21 @@ define(function(require) {
|
||||
return number;
|
||||
}
|
||||
|
||||
function _totalCost(){
|
||||
function _totalCost(totalCostDisk=0){
|
||||
var memory = document.getElementById('real_memory_cost').value;
|
||||
var cpu = document.getElementById('real_cpu_cost').value;
|
||||
if (totalCostDisk != 0){
|
||||
this.totalCostDisk = totalCostDisk;
|
||||
}
|
||||
|
||||
if(memory === undefined && cpu === undefined){
|
||||
document.getElementById('total_cost').textContent = "Total: 0.00";
|
||||
} else if(memory === undefined){
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(cpu);
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(cpu + this.totalCostDisk);
|
||||
} else if(cpu === undefined){
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory);
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory + this.totalCostDisk);
|
||||
} else {
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory + cpu);
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory + cpu + this.totalCostDisk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,11 @@ define(function(require) {
|
||||
if (!$.isEmptyObject(diskJSON)) {disksJSON.push(diskJSON)};
|
||||
})
|
||||
|
||||
if (disksJSON.length > 0) { templateJSON['DISK'] = disksJSON; };
|
||||
if (disksJSON.length > 0) {
|
||||
templateJSON['DISK'] = disksJSON;
|
||||
localStorage.setItem("disksJSON", JSON.stringify(disksJSON));
|
||||
$("#DISK_COST").trigger("change");
|
||||
};
|
||||
|
||||
return templateJSON;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user