mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
development: fix rounding in template cost calculation
This commit is contained in:
parent
5afdaf4e74
commit
4d514a0abe
@ -122,15 +122,6 @@ define(function(require) {
|
||||
}
|
||||
return number.toFixed(6);
|
||||
}
|
||||
function caculatedTotalMemory(context){
|
||||
var memory_cost = document.getElementById('MEMORY_COST').value;
|
||||
var type = document.getElementById('MEMORY_UNIT_COST').value;
|
||||
var real_memory = document.getElementById('MEMORY').value;
|
||||
memory = memory_cost * real_memory * 24 * 30; //24 hours and 30 days
|
||||
document.getElementById('total_value_memory').textContent = convertCostNumber(memory);
|
||||
if (memory_cost != "")
|
||||
$(".total_memory_cost", context).show();
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
@ -145,21 +136,15 @@ define(function(require) {
|
||||
});
|
||||
|
||||
context.on("change", "#MEMORY_COST", function() {
|
||||
caculatedTotalMemory(context);
|
||||
CapacityCreate.calculatedRealMemory(context);
|
||||
});
|
||||
|
||||
context.on("change", "#MEMORY_UNIT_COST", function() {
|
||||
caculatedTotalMemory(context);
|
||||
CapacityCreate.calculatedRealMemory();
|
||||
CapacityCreate.calculatedRealMemory(context);
|
||||
});
|
||||
|
||||
context.on("change", "#CPU_COST", function() {
|
||||
var cpu = document.getElementById('CPU').value;
|
||||
var cpu_cost = document.getElementById('CPU_COST').value;
|
||||
document.getElementById('total_value_cpu').textContent = convertCostNumber(cpu * cpu_cost * 24 * 30);
|
||||
$(".total_cpu_cost", context).show();
|
||||
CapacityCreate.calculatedRealCpu();
|
||||
CapacityCreate.calculatedRealCpu(context);
|
||||
});
|
||||
|
||||
context.on("change", "#DISK_COST", function() {
|
||||
|
@ -106,47 +106,58 @@ define(function(require) {
|
||||
}
|
||||
}
|
||||
|
||||
function _calculatedRealMemory(){
|
||||
function _calculatedRealMemory(context){
|
||||
var memory_cost = $("#MEMORY_COST").val();
|
||||
var type_cost = $("#MEMORY_UNIT_COST").val();
|
||||
var type_cost = $("#MEMORY_UNIT_COST").val();
|
||||
|
||||
var memory = $("#MEMORY").val();
|
||||
var type = $("#memory_unit").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;
|
||||
document.getElementById('total_value_memory').textContent = convertCostNumber(memory);
|
||||
|
||||
if (memory_cost != "")
|
||||
$(".total_memory_cost", context).show();
|
||||
|
||||
_totalCost();
|
||||
}
|
||||
|
||||
function _calculatedRealCpu(){
|
||||
function _calculatedRealCpu(context){
|
||||
var cpu_cost = $("#CPU_COST").val();
|
||||
var cpu = $("#CPU").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;
|
||||
document.getElementById('total_value_cpu').textContent = convertCostNumber(cpu);
|
||||
|
||||
if (cpu_cost != "")
|
||||
$(".total_cpu_cost", context).show();
|
||||
|
||||
_totalCost();
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
context.on("change", "#MEMORY", function() {
|
||||
_calculatedRealMemory();
|
||||
_calculatedRealMemory(context);
|
||||
});
|
||||
|
||||
context.on("change", "#MEMORY_GB", function() {
|
||||
_calculatedRealMemory();
|
||||
_calculatedRealMemory(context);
|
||||
});
|
||||
|
||||
context.on("change", "#memory_unit", function() {
|
||||
_calculatedRealMemory();
|
||||
_calculatedRealMemory(context);
|
||||
});
|
||||
|
||||
context.on("change", "#CPU", function() {
|
||||
_calculatedRealCpu();
|
||||
_calculatedRealCpu(context);
|
||||
});
|
||||
|
||||
// MB to GB
|
||||
|
Loading…
Reference in New Issue
Block a user