mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
Solved bug showback (#530)
* Solved bug showback
* '===' instead of '=='
(cherry picked from commit 2f48f1fab5
)
This commit is contained in:
parent
4e8318296c
commit
95332c32d7
@ -103,6 +103,7 @@ define(function(require) {
|
||||
|
||||
var cpuCost = capacity.CPU_COST;
|
||||
var memoryCost = capacity.MEMORY_COST;
|
||||
var memoryUnitCost = capacity.MEMORY_UNIT_COST;
|
||||
var diskCost = capacity.DISK_COST;
|
||||
|
||||
if (cpuCost == undefined){
|
||||
@ -122,7 +123,11 @@ define(function(require) {
|
||||
}
|
||||
|
||||
if (capacity.MEMORY) {
|
||||
cost += capacity.MEMORY * memoryCost;
|
||||
if (memoryUnitCost === "GB"){
|
||||
cost += (capacity.MEMORY / 1024) * memoryCost;
|
||||
} else {
|
||||
cost += capacity.MEMORY * memoryCost;
|
||||
}
|
||||
}
|
||||
|
||||
if (diskCost != 0) {
|
||||
@ -134,9 +139,9 @@ define(function(require) {
|
||||
disks = [template_disk];
|
||||
}
|
||||
|
||||
$.each(disks, function(i,disk){
|
||||
$.each(disks, function(i, disk){
|
||||
if (disk.SIZE) {
|
||||
cost += diskCost * disk.SIZE;
|
||||
cost += diskCost * (disk.SIZE / 1024);
|
||||
}
|
||||
|
||||
if (disk.DISK_SNAPSHOT_TOTAL_SIZE) {
|
||||
|
@ -146,7 +146,7 @@ define(function(require) {
|
||||
total_cost += (cost * role.cardinality);
|
||||
|
||||
$(".total_cost_div", context).show();
|
||||
$(".total_cost_div .cost_value", context).text( (total_cost).toFixed(2) );
|
||||
$(".total_cost_div .cost_value", context).text((total_cost).toFixed(4));
|
||||
}
|
||||
|
||||
UserInputs.vmTemplateInsert(
|
||||
|
@ -163,9 +163,14 @@ define(function(require) {
|
||||
totalGB += ivalue.SIZE / 1024;
|
||||
}
|
||||
});
|
||||
totalCostDisk = totalGB * that.disk;
|
||||
CapacityCreate.totalCost(totalCostDisk);
|
||||
document.getElementById('total_value_disk').textContent = convertCostNumber(totalCostDisk * 24 * 30);
|
||||
var totalCostDisk = 0;
|
||||
if (!isNaN(totalGB)){
|
||||
totalCostDisk = totalGB * that.disk;
|
||||
document.getElementById('total_value_disk').textContent = convertCostNumber(totalCostDisk * 24 * 30);
|
||||
CapacityCreate.totalCost();
|
||||
} else {
|
||||
document.getElementById('total_value_disk').textContent = totalCostDisk;
|
||||
}
|
||||
$(".total_disk_cost", context).show();
|
||||
}
|
||||
});
|
||||
|
@ -70,67 +70,69 @@ define(function(require) {
|
||||
}
|
||||
function convertCostNumber(number){
|
||||
if(number >= 1000000){
|
||||
number = (number/1000000).toFixed(2)
|
||||
return number.toString()+"M";
|
||||
number = (number / 1000000).toFixed(2)
|
||||
return number.toString() + "M";
|
||||
}
|
||||
else if(number >= 1000){
|
||||
number = (number/1000).toFixed(2)
|
||||
return number.toString()+"K";
|
||||
else if (number >= 1000){
|
||||
number = (number / 1000).toFixed(2)
|
||||
return number.toString() + "K";
|
||||
}
|
||||
else if (number >= 0 && number < 1000)
|
||||
else if (number >= 0 && number < 1000){
|
||||
return number.toFixed(2);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
function _totalCost(totalCostDisk=0){
|
||||
if(!this.totalCostDisk){
|
||||
this.totalCostDisk = 0;
|
||||
}
|
||||
var memory = document.getElementById('real_memory_cost').value;
|
||||
var cpu = document.getElementById('real_cpu_cost').value;
|
||||
if (totalCostDisk != 0){
|
||||
this.totalCostDisk = totalCostDisk;
|
||||
function _totalCost(){
|
||||
var memory = $("#real_memory_cost").val();
|
||||
var cpu = $("#real_cpu_cost").val();
|
||||
var disk_cost = $("#total_value_disk").text();
|
||||
if (disk_cost === "") {
|
||||
disk_cost = 0;
|
||||
} else {
|
||||
disk_cost = parseFloat(disk_cost);
|
||||
}
|
||||
|
||||
if(memory === undefined && cpu === undefined){
|
||||
document.getElementById('total_cost').textContent = "Total: " + this.totalCostDisk;
|
||||
} else if(memory === undefined){
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(cpu + this.totalCostDisk);
|
||||
} else if(cpu === undefined){
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory + this.totalCostDisk);
|
||||
if ((memory === undefined || memory === "") && (cpu === undefined || cpu === "")){
|
||||
document.getElementById('total_cost').textContent = "Total: " + disk_cost;
|
||||
} else if(memory === undefined || memory === ""){
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(cpu + disk_cost);
|
||||
} else if(cpu === undefined || cpu === ""){
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory + disk_cost);
|
||||
} else {
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory + cpu + this.totalCostDisk);
|
||||
document.getElementById('total_cost').textContent = "Total: " + convertCostNumber(memory + cpu + disk_cost);
|
||||
}
|
||||
}
|
||||
|
||||
function _calculatedRealMemory(){
|
||||
var memory_cost = document.getElementById('MEMORY_COST').value;
|
||||
var type_cost = document.getElementById('MEMORY_UNIT_COST').value;
|
||||
var memory = document.getElementById('MEMORY').value;
|
||||
var type = document.getElementById('memory_unit').value;
|
||||
if(type_cost == "GB")
|
||||
memory = (memory/1024)*memory_cost*24*30;
|
||||
else
|
||||
memory = memory*memory_cost*24*30;
|
||||
document.getElementById('real_memory_cost').textContent = "Cost: "+ convertCostNumber(memory);
|
||||
var memory_cost = $("#MEMORY_COST").val();
|
||||
var type_cost = $("#MEMORY_UNIT_COST").val();
|
||||
var memory = $("#MEMORY").val();
|
||||
var type = $("#memory_unit").val();
|
||||
if (type_cost == "GB"){
|
||||
memory = (memory / 1024) * memory_cost * 24 * 30;
|
||||
} else {
|
||||
memory = memory * memory_cost * 24 * 30;
|
||||
}
|
||||
document.getElementById('real_memory_cost').textContent = "Cost: " + convertCostNumber(memory);
|
||||
document.getElementById('real_memory_cost').value = memory;
|
||||
document.getElementById('total_value_memory').textContent = memory;
|
||||
_totalCost();
|
||||
}
|
||||
|
||||
function _calculatedRealCpu(){
|
||||
var cpu_cost = document.getElementById('CPU_COST').value;
|
||||
var cpu = document.getElementById('CPU').value;
|
||||
cpu = cpu*cpu_cost*24*30;
|
||||
document.getElementById('real_cpu_cost').textContent = "Cost: "+ convertCostNumber(cpu);
|
||||
var cpu_cost = $("#CPU_COST").val();
|
||||
var cpu = $("#CPU").val();
|
||||
cpu = cpu * cpu_cost * 24 * 30;
|
||||
document.getElementById('real_cpu_cost').textContent = "Cost: " + convertCostNumber(cpu);
|
||||
document.getElementById('real_cpu_cost').value = cpu;
|
||||
document.getElementById('total_value_cpu').textContent = cpu;
|
||||
_totalCost();
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
this.totalCostDisk = 0;
|
||||
context.on("change", "#MEMORY", function() {
|
||||
_calculatedRealMemory();
|
||||
});
|
||||
|
@ -515,7 +515,7 @@ define(function(require) {
|
||||
memoryCost = Config.onedConf.DEFAULT_COST.MEMORY_COST;
|
||||
} else {
|
||||
if (memoryUnitCost == "GB"){
|
||||
memoryCost = memoryCost / 1024 / 1024;
|
||||
memoryCost = memoryCost / 1024;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user