feat: Initial commit - WebGIS Smart City Project by Naufal Zaky Ramadhan (D1041231071)

This commit is contained in:
naukyy
2026-06-13 00:00:33 +07:00
commit 2c123f5af2
163 changed files with 13007 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
const getBaseUrl = () => {
const segments = window.location.pathname.split('/');
const targetIndex = segments.findIndex(seg => ['01', '02', '03', 'versi'].includes(seg));
if (targetIndex !== -1) {
return segments.slice(0, targetIndex).join('/');
}
return '';
};
export const BASE_URL = getBaseUrl();
const createService = (endpoint) => ({
getAll: async () => {
const res = await fetch(`${BASE_URL}/${endpoint}`);
const json = await res.json();
return json.data;
},
create: async (data) => {
const res = await fetch(`${BASE_URL}/${endpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
const json = await res.json();
return json.data;
},
delete: async (id) => {
const res = await fetch(`${BASE_URL}/${endpoint}?id=${id}`, {
method: 'DELETE'
});
const json = await res.json();
return json.data;
}
});
// P01
export const spbuService = createService('01/backend/api/spbu.php');
export const jalanService = createService('01/backend/api/jalan.php');
export const kavlingService = createService('01/backend/api/kavling.php');
// P02
export const rumahIbadahService = createService('02/backend/api/rumah_ibadah.php');
export const wargaMiskinService = createService('02/backend/api/warga_miskin.php');
export const haversineService = {
getDalamRadius: async (id, radius) => {
const res = await fetch(`${BASE_URL}/02/backend/api/haversine.php?rumah_ibadah_id=${id}&radius_km=${radius}`);
const json = await res.json();
return json.data;
}
};
+28
View File
@@ -0,0 +1,28 @@
/**
* jalan.service.js
* Tanggung Jawab: Komunikasi HTTP ke endpoint API jalan.php
*/
import { CONFIG } from '../config.js';
export const jalanService = {
getAll: async () => {
const response = await fetch(`${CONFIG.BASE_URL}/jalan.php`);
return await response.json();
},
save: async (data) => {
const response = await fetch(`${CONFIG.BASE_URL}/jalan.php`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
return await response.json();
},
delete: async (id) => {
const response = await fetch(`${CONFIG.BASE_URL}/jalan.php?id=${id}`, {
method: 'DELETE'
});
return await response.json();
}
};
@@ -0,0 +1,28 @@
/**
* kavling.service.js
* Tanggung Jawab: Komunikasi HTTP ke endpoint API kavling.php
*/
import { CONFIG } from '../config.js';
export const kavlingService = {
getAll: async () => {
const response = await fetch(`${CONFIG.BASE_URL}/kavling.php`);
return await response.json();
},
save: async (data) => {
const response = await fetch(`${CONFIG.BASE_URL}/kavling.php`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
return await response.json();
},
delete: async (id) => {
const response = await fetch(`${CONFIG.BASE_URL}/kavling.php?id=${id}`, {
method: 'DELETE'
});
return await response.json();
}
};
+28
View File
@@ -0,0 +1,28 @@
/**
* spbu.service.js
* Tanggung Jawab: Komunikasi HTTP ke endpoint API spbu.php
*/
import { CONFIG } from '../config.js';
export const spbuService = {
getAll: async () => {
const response = await fetch(`${CONFIG.BASE_URL}/spbu.php`);
return await response.json();
},
save: async (data) => {
const response = await fetch(`${CONFIG.BASE_URL}/spbu.php`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
return await response.json();
},
delete: async (id) => {
const response = await fetch(`${CONFIG.BASE_URL}/spbu.php?id=${id}`, {
method: 'DELETE'
});
return await response.json();
}
};