Status Wilayah
This commit is contained in:
+87
-49
@@ -284,33 +284,27 @@
|
||||
|
||||
let klasifikasiHTML = "<li>Tidak ada data</li>";
|
||||
if (Array.isArray(status?.[0])) {
|
||||
indexDesaHTML = status[0]
|
||||
provIndexDesaHTML = status[0]
|
||||
.map(d => `${d[1]}: ${d[4]} / `)
|
||||
.join("");
|
||||
bumdesHTML = status[1]
|
||||
provBumdesHTML = status[1]
|
||||
.map(dt => `${dt[0]}:${dt[1]} / `)
|
||||
.join("");
|
||||
danadesaHTML = `Dana :${status[2].jumlah_per_m}, Persentase : ${status[2].persentage}%`;
|
||||
serapanHTML = status[3]
|
||||
.map(([jabatan, nilai]) => {
|
||||
const alias = jabatan === 'Pendamping Lokal Desa' ? 'PLD' :
|
||||
jabatan === 'Pendamping Desa' ? 'PD' :
|
||||
jabatan;
|
||||
return `${alias}: ${nilai}`;
|
||||
}).join("");
|
||||
|
||||
koperasiHTML = status[4]
|
||||
const raw = Number(status[5]);
|
||||
provDanaTotalHTML = `Total : ${formatWithUnit(raw)}`;
|
||||
provDanadesaHTML = `Total : ${status[2].jumlah_per_m}, Persentase : ${status[2].persentage}%`;
|
||||
provKoperasiHTML = status[4]
|
||||
.map(dt => `${dt[0]}: ${dt[1]} / `)
|
||||
.join("");
|
||||
}
|
||||
const popupContent = `
|
||||
<strong>${feature.properties.nama}</strong><br/>
|
||||
<strong>Status Desa:</strong>
|
||||
<li>IDM - ${indexDesaHTML}</li>
|
||||
<li>BUM - ${bumdesHTML}</li>
|
||||
<li>DD - ${danadesaHTML}</li>
|
||||
<li>SERAPAN - ${serapanHTML} </li>
|
||||
<li>KOPERASI - ${koperasiHTML} </li>
|
||||
<li>IDM - ${provIndexDesaHTML}</li>
|
||||
<li>BUM - ${provBumdesHTML}</li>
|
||||
<li>DD - ${provDanaTotalHTML}</li>
|
||||
<li>SERAPAN - ${provDanadesaHTML} </li>
|
||||
<li>KOPERASI - ${provKoperasiHTML} </li>
|
||||
`;
|
||||
|
||||
layer.bindPopup(popupContent).openPopup(e.latlng);
|
||||
@@ -322,15 +316,19 @@
|
||||
let klasifikasiHTML = "<li>Tidak ada data</li>";
|
||||
|
||||
if (Array.isArray(status?.[0])) {
|
||||
indexDesaHTML = status[0]
|
||||
kabindexDesaHTML= status[0]
|
||||
.map(d => `${d[1]}: ${d[5]} / `)
|
||||
.join("");
|
||||
|
||||
bumdesHTML = status[1]
|
||||
kabbumdesHTML = status[1]
|
||||
.map(dt => `${dt[0]}:${dt[1]} / `)
|
||||
.join("");
|
||||
danadesaHTML = `Dana :${status[2].jumlah_per_m}, Persentase : ${status[2].persentage}%`;
|
||||
serapanHTML = status[3]
|
||||
|
||||
const raw = Number(status[5]);
|
||||
kabdanaTotalHTML = `Total : ${formatWithUnit(raw)}`;
|
||||
|
||||
kabdanadesaHTML = `Dana :${status[2].jumlah_per_m}, Persentase : ${status[2].persentage}%`;
|
||||
kabserapanHTML = status[3]
|
||||
.map(([jabatan, nilai]) => {
|
||||
const alias = jabatan === 'Pendamping Lokal Desa' ? 'PLD' :
|
||||
jabatan === 'Pendamping Desa' ? 'PD' :
|
||||
@@ -338,18 +336,18 @@
|
||||
return `${alias}: ${nilai} /`;
|
||||
}).join("");
|
||||
|
||||
koperasiHTML = status[4]
|
||||
kabkoperasiHTML = status[4]
|
||||
.map(dt => `${dt[0]}: ${dt[1]} / `)
|
||||
.join("");
|
||||
}
|
||||
const popupContent = `
|
||||
<strong>${feature.properties.nama}</strong><br/>
|
||||
<strong>Status Desa (Kabupaten):</strong>
|
||||
<li>IDM - ${indexDesaHTML}</li>
|
||||
<li>BUM - ${bumdesHTML}</li>
|
||||
<li>DD - ${danadesaHTML}</li>
|
||||
<li>SERAPAN - ${serapanHTML} </li>
|
||||
<li>KOPERASI - ${koperasiHTML} </li>
|
||||
<li>IDM - ${kabindexDesaHTML}</li>
|
||||
<li>BUM - ${kabbumdesHTML}</li>
|
||||
<li>DD - ${kabdanaTotalHTML}</li>
|
||||
<li>SERAPAN - ${kabdanadesaHTML} </li>
|
||||
<li>KOPERASI - ${kabkoperasiHTML} </li>
|
||||
`;
|
||||
|
||||
layer.bindPopup(popupContent).openPopup(e.latlng);
|
||||
@@ -357,20 +355,25 @@
|
||||
} else if (currentLevel === 'kecamatan'){
|
||||
const province_code = localStorage.getItem('kode_provinsi')
|
||||
const region_code = localStorage.getItem('kode_kabupatenkota')
|
||||
localStorage.setItem('kode_kecamatan',feature.properties.kode)
|
||||
localStorage.setItem('kode_kecamatan',feature.properties.id)
|
||||
const status = await fetchStatusDesaByKecamatan(province_code, region_code, feature.properties.kode)
|
||||
let klasifikasiHTML = "<li>Tidak ada data</li>";
|
||||
|
||||
if (Array.isArray(status?.[0])) {
|
||||
indexDesaHTML = status[0]
|
||||
kecindexDesaHTML = status[0]
|
||||
.map(d => `${d[1]}: ${d[6]} / `)
|
||||
.join("");
|
||||
|
||||
bumdesHTML = status[1]
|
||||
kecbumdesHTML = status[1]
|
||||
.map(dt => `${dt[0]}:${dt[1]} / `)
|
||||
.join("");
|
||||
danadesaHTML = `Dana :${status[2].jumlah_per_m}, Persentase : ${status[2].persentage}%`;
|
||||
serapanHTML = status[3]
|
||||
|
||||
const raw = Number(status[5]);
|
||||
kecdanaTotalHTML = `Total : ${formatWithUnit(raw)}`;
|
||||
|
||||
kecdanadesaHTML = `Total: ${formatWithUnit(status[2][0])} / Persen: ${Math.round(status[2][1])}`;
|
||||
|
||||
kecserapanHTML = status[3]
|
||||
.map(([jabatan, nilai]) => {
|
||||
const alias = jabatan === 'Pendamping Lokal Desa' ? 'PLD' :
|
||||
jabatan === 'Pendamping Desa' ? 'PD' :
|
||||
@@ -378,7 +381,7 @@
|
||||
return `${alias}: ${nilai} /`;
|
||||
}).join("");
|
||||
|
||||
koperasiHTML = status[4]
|
||||
keckoperasiHTML = status[4]
|
||||
.map(dt => `${dt[0]}: ${dt[1]} / `)
|
||||
.join("");
|
||||
}
|
||||
@@ -387,12 +390,11 @@
|
||||
`
|
||||
<strong> ${feature.properties.nama}</strong>
|
||||
<strong>Status Desa (Kecamatan):</strong>
|
||||
<strong>Status Desa:</strong>
|
||||
<li>IDM - ${indexDesaHTML}</li>
|
||||
<li>BUM - ${bumdesHTML}</li>
|
||||
<li>DD - ${danadesaHTML}</li>
|
||||
<li>SERAPAN - ${serapanHTML} </li>
|
||||
<li>KOPERASI - ${koperasiHTML} </li>
|
||||
<li>IDM - ${kecindexDesaHTML}</li>
|
||||
<li>BUM - ${kecbumdesHTML}</li>
|
||||
<li>DD - ${kecdanaTotalHTML}</li>
|
||||
<li>SERAPAN - ${kecdanadesaHTML} </li>
|
||||
<li>KOPERASI - ${keckoperasiHTML} </li>
|
||||
`
|
||||
layer.bindPopup(popupContent).openPopup(e.latlng);
|
||||
}else {
|
||||
@@ -400,19 +402,24 @@
|
||||
const province_code = localStorage.getItem('kode_provinsi')
|
||||
const region_code = localStorage.getItem('kode_kabupatenkota')
|
||||
const district_code = localStorage.getItem('kode_kecamatan')
|
||||
|
||||
console.log(province_code, region_code , district_code, feature.properties.kode)
|
||||
const status = await fetchStatusDesaByDesa(province_code, region_code , district_code, feature.properties.kode);
|
||||
let klasifikasiHTML = "<li>Tidak ada data</li>";
|
||||
|
||||
if (Array.isArray(status?.[0])) {
|
||||
indexDesaHTML = status[0]
|
||||
.map(d => `${d[1]}: ${d[5]} / `)
|
||||
.map(d => `${d[1]}`)
|
||||
.join("");
|
||||
|
||||
bumdesHTML = status[1]
|
||||
.map(dt => `${dt[0]}:${dt[1]} / `)
|
||||
.join("");
|
||||
danadesaHTML = `Dana :${status[2].jumlah_per_m}, Persentase : ${status[2].persentage}%`;
|
||||
|
||||
const raw = Number(status[5]);
|
||||
danaTotalHTML = `Total : ${formatWithUnit(raw)}`;
|
||||
danadesaHTML = status[2].map(([serapan,persen]) => {
|
||||
return `Nominal - ${formatWithUnit(serapan)} / Persen - ${Math.round(persen)}%`;
|
||||
});
|
||||
serapanHTML = status[3]
|
||||
.map(([jabatan, nilai]) => {
|
||||
const alias = jabatan === 'Pendamping Lokal Desa' ? 'PLD' :
|
||||
@@ -430,8 +437,8 @@
|
||||
<strong>Status Desa (Desa):</strong>
|
||||
<li>IDM - ${indexDesaHTML}</li>
|
||||
<li>BUM - ${bumdesHTML}</li>
|
||||
<li>DD - ${danadesaHTML}</li>
|
||||
<li>SERAPAN - ${serapanHTML} </li>
|
||||
<li>DD - ${danaTotalHTML}</li>
|
||||
<li>SERAPAN - ${danadesaHTML} </li>
|
||||
<li>KOPERASI - ${koperasiHTML} </li>
|
||||
`;
|
||||
|
||||
@@ -453,14 +460,35 @@
|
||||
});
|
||||
}
|
||||
|
||||
function formatWithUnit(value) {
|
||||
const abs = Math.abs(value);
|
||||
let scaled, unit;
|
||||
|
||||
if (abs >= 1e12) { scaled = value / 1e12; unit = 'Triliun'; }
|
||||
else if (abs >= 1e9) { scaled = value / 1e9; unit = 'Miliar'; }
|
||||
else if (abs >= 1e6) { scaled = value / 1e6; unit = 'Juta'; }
|
||||
else if (abs >= 1e3) { scaled = value / 1e3; unit = 'Ribu'; }
|
||||
else { scaled = value; unit = ''; }
|
||||
const formatted = scaled.toLocaleString('id-ID', {
|
||||
minimumFractionDigits: unit ? 2 : 0,
|
||||
maximumFractionDigits: unit ? 2 : 0
|
||||
});
|
||||
|
||||
return unit
|
||||
? `${formatted} ${unit}`
|
||||
: formatted;
|
||||
}
|
||||
|
||||
async function fetchStatusDesaByProvinsi(kodeProvinsi) {
|
||||
const url = `http://localhost:5000/api/status-provinsi/${kodeProvinsi}`;
|
||||
const urltdd = `http://localhost:5000/api/status/danadesa/provinsi/${kodeProvinsi}`;
|
||||
const urldd = `http://localhost:5000/api/provinsi/serapan/${kodeProvinsi}`;
|
||||
const urlpd = `http://localhost:5000//api/provinsi/pendamping/${kodeProvinsi}`
|
||||
const urlkop = `http://localhost:5000//api/provinsi/koperasi/${kodeProvinsi}`
|
||||
const urlbd = `http://localhost:5000/api/provinsi/bumdes/${kodeProvinsi}`;
|
||||
try {
|
||||
const res = await fetch(url);
|
||||
const tdd = await fetch(urltdd)
|
||||
const bumdes = await fetch(urlbd)
|
||||
const dd = await fetch(urldd)
|
||||
const pd = await fetch(urlpd)
|
||||
@@ -468,12 +496,13 @@
|
||||
|
||||
if (!res.ok && !bumdes.ok && !dd.ok) throw new Error(`HTTP ${res.status}`);
|
||||
const IPD = await res.json()
|
||||
const dtdd = await tdd.json()
|
||||
const bd = await bumdes.json()
|
||||
const danadesa = await dd.json()
|
||||
const dtpd = await pd.json()
|
||||
const dtkop = await kop.json()
|
||||
|
||||
return [IPD,bd, danadesa, dtpd, dtkop];
|
||||
console.log([IPD, bd, danadesa, dtpd, dtkop, dtdd]);
|
||||
return [IPD, bd, danadesa, dtpd, dtkop, dtdd];
|
||||
} catch (err) {
|
||||
console.error("Gagal ambil status desa:", err);
|
||||
return null;
|
||||
@@ -482,12 +511,14 @@
|
||||
|
||||
async function fetchStatusDesaByKabupatenkota(kode_prov, kode_kabkota) {
|
||||
const url = `http://localhost:5000/api/status-kabupatenkota/${kode_prov}/${kode_kabkota}`
|
||||
const urltdd = `http://localhost:5000/api/status/danadesa/kabkota/${kode_kabkota}`;
|
||||
const urldd = `http://localhost:5000/api/kabkota/serapan/${kode_kabkota}`;
|
||||
const urlpd = `http://localhost:5000//api/kabkota/pendamping/${kode_kabkota}`
|
||||
const urlkop = `http://localhost:5000//api/kabkota/koperasi/${kode_kabkota}`
|
||||
const urlbd = `http://localhost:5000/api/kabkota/bumdes/${kode_kabkota}`;
|
||||
try{
|
||||
const res = await fetch(url)
|
||||
const tdd = await fetch(urltdd)
|
||||
const bumdes = await fetch(urlbd)
|
||||
const dd = await fetch(urldd)
|
||||
const pd = await fetch(urlpd)
|
||||
@@ -499,8 +530,9 @@
|
||||
const danadesa = await dd.json()
|
||||
const dtpd = await pd.json()
|
||||
const dtkop = await kop.json()
|
||||
const dttd = await tdd.json()
|
||||
|
||||
return [IPD,bd, danadesa, dtpd, dtkop];
|
||||
return [IPD,bd, danadesa, dtpd, dtkop,dttd];
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
return null;
|
||||
@@ -509,12 +541,14 @@
|
||||
|
||||
async function fetchStatusDesaByKecamatan(province_code, region_code, district_code){
|
||||
const url = `http://localhost:5000/api/status-kecamatan/${province_code}/${region_code}/${district_code}`
|
||||
const urltdd = `http://localhost:5000/api/status/danadesa/kecamatan/${district_code}`;
|
||||
const urldd = `http://localhost:5000/api/kecamatan/serapan/${district_code}`;
|
||||
const urlpd = `http://localhost:5000//api/kecamatan/pendamping/${district_code}`
|
||||
const urlkop = `http://localhost:5000//api/kecamatan/koperasi/${district_code}`
|
||||
const urlbd = `http://localhost:5000/api/kecamatan/bumdes/${district_code}`;
|
||||
try {
|
||||
const res = await fetch(url)
|
||||
const tdd = await fetch(urltdd)
|
||||
const bumdes = await fetch(urlbd)
|
||||
const dd = await fetch(urldd)
|
||||
const pd = await fetch(urlpd)
|
||||
@@ -526,8 +560,9 @@
|
||||
const danadesa = await dd.json()
|
||||
const dtpd = await pd.json()
|
||||
const dtkop = await kop.json()
|
||||
const dttd = await tdd.json()
|
||||
|
||||
return [IPD,bd, danadesa, dtpd, dtkop];;
|
||||
return [IPD,bd, danadesa, dtpd, dtkop, dttd];;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return null
|
||||
@@ -536,12 +571,14 @@
|
||||
|
||||
async function fetchStatusDesaByDesa(province_code, region_code, district_code, village_code){
|
||||
const url = `http://localhost:5000//api/desa/status/${province_code}/${region_code}/${district_code}/${village_code}`
|
||||
const urltdd = `http://localhost:5000/api/status/danadesa/desa/${village_code}`;
|
||||
const urldd = `http://localhost:5000/api/desa/serapan/${village_code}`;
|
||||
const urlpd = `http://localhost:5000//api/desa/pendamping/${village_code}`
|
||||
const urlkop = `http://localhost:5000//api/desa/koperasi/${village_code}`
|
||||
const urlbd = `http://localhost:5000/api/desa/bumdes/${village_code}`;
|
||||
try {
|
||||
const res = await fetch(url)
|
||||
const tdd = await fetch(urltdd)
|
||||
const bumdes = await fetch(urlbd)
|
||||
const dd = await fetch(urldd)
|
||||
const pd = await fetch(urlpd)
|
||||
@@ -553,8 +590,9 @@
|
||||
const danadesa = await dd.json()
|
||||
const dtpd = await pd.json()
|
||||
const dtkop = await kop.json()
|
||||
const dttd = await tdd.json()
|
||||
|
||||
return [IPD,bd, danadesa, dtpd, dtkop];;
|
||||
return [IPD,bd, danadesa, dtpd, dtkop, dttd];;
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user