refactor: split ui into modules (resources, domains, infra, costs, modals)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
window.loadCosts = async function(){
|
||||
|
||||
const resources = window.resources || []
|
||||
const domains = await api(API + "/domains")
|
||||
|
||||
let month = 0
|
||||
let year = 0
|
||||
let domainYear = 0
|
||||
|
||||
resources.forEach(r => {
|
||||
|
||||
if(r.kosten_monat){
|
||||
month += parseFloat(r.kosten_monat)
|
||||
}
|
||||
|
||||
if(r.kosten_jahr){
|
||||
year += parseFloat(r.kosten_jahr)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
domains.forEach(d => {
|
||||
|
||||
if(d.yearly_cost){
|
||||
domainYear += parseFloat(d.yearly_cost)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
document.getElementById("costMonth").innerText = month.toFixed(2)
|
||||
document.getElementById("costYear").innerText = year.toFixed(2)
|
||||
document.getElementById("costDomain").innerText = domainYear.toFixed(2)
|
||||
|
||||
const total = year + domainYear
|
||||
|
||||
document.getElementById("costTotal").innerText = total.toFixed(2)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user