Merge pull request 'prod' (#22) from Rayhan/roda-student-web-if-development-kit:prod into main

Reviewed-on: #22
Approved
This commit was merged in pull request #22.
This commit is contained in:
izu
2026-06-05 09:22:25 +00:00
2 changed files with 102 additions and 35 deletions
+28 -23
View File
@@ -78,7 +78,9 @@
dashboardRuntimeFetch: 'always',
dashboardTargetUrl: 'https://dashboard.informatika.untan.ac.id/index.php?penelitian',
dashboardProxyTemplates: [
'https://api.codetabs.com/v1/proxy?quest={{url}}'
'https://api.codetabs.com/v1/proxy?quest={{url}}',
'https://api.allorigins.win/get?url={{url}}&ts={{ts}}',
'https://thingproxy.freeboard.io/fetch/{{rawUrl}}'
]
};
</script>
@@ -1631,6 +1633,22 @@
updateStatPub(newData.length);
}
async function fetchProxyRows(proxyUrl) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 15000);
try {
const response = await fetch(proxyUrl, { signal: controller.signal });
if (!response.ok) throw new Error(`HTTP_ERROR_${response.status}`);
const responseData = await response.text();
const html = extractDashboardHtml(responseData);
return parseDashboardRows(html);
} finally {
clearTimeout(timeoutId);
}
}
async function fetchDashboardData() {
const grid = document.getElementById('riset-grid');
if (grid) {
@@ -1681,28 +1699,15 @@
return;
}
for (const getProxyUrl of proxyServers) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 15000);
try {
const proxyUrl = getProxyUrl(targetUrl);
const response = await fetch(proxyUrl, { signal: controller.signal });
clearTimeout(timeoutId);
if (!response.ok) throw new Error(`HTTP_ERROR_${response.status}`);
const responseData = await response.text();
const html = extractDashboardHtml(responseData);
const rows = parseDashboardRows(html);
applyDashboardRows(rows);
return; // Berhasil! Keluar dari loop
} catch (error) {
clearTimeout(timeoutId);
lastError = error;
// Lanjut ke proxy berikutnya...
}
try {
const proxyUrls = proxyServers.map((getProxyUrl) => getProxyUrl(targetUrl));
const rows = await Promise.any(proxyUrls.map((proxyUrl) => fetchProxyRows(proxyUrl)));
applyDashboardRows(rows);
return;
} catch (error) {
lastError = error instanceof AggregateError && error.errors?.length
? error.errors[error.errors.length - 1]
: error;
}
// Jika semua proxy gagal