Fix RODA dashboard data fallback

This commit is contained in:
GuavaPopper
2026-06-05 16:45:23 +07:00
parent 1a90411509
commit 7ad7276438
3 changed files with 1689 additions and 1 deletions
File diff suppressed because it is too large Load Diff
+30
View File
@@ -77,6 +77,7 @@
debugLogs: false,
dashboardRuntimeFetch: 'always',
dashboardTargetUrl: 'https://dashboard.informatika.untan.ac.id/index.php?penelitian',
dashboardSnapshotUrl: 'dashboard-snapshot.txt',
dashboardProxyTemplates: [
'https://api.codetabs.com/v1/proxy?quest={{url}}',
'https://api.allorigins.win/get?url={{url}}&ts={{ts}}',
@@ -1580,6 +1581,25 @@
}
}
async function fetchDashboardSnapshotHtml() {
const snapshotUrl = window.APP_CONFIG?.dashboardSnapshotUrl?.trim();
if (!snapshotUrl) return '';
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 8000);
try {
const response = await fetch(snapshotUrl, { signal: controller.signal });
if (!response.ok) return '';
return extractDashboardHtml(await response.text());
} catch (error) {
logAppError('dashboard-snapshot', error);
return '';
} finally {
clearTimeout(timeoutId);
}
}
function applyDashboardRows(rows) {
const newData = [];
rows.forEach((row) => {
@@ -1671,6 +1691,16 @@
}
}
const snapshotHtml = await fetchDashboardSnapshotHtml();
if (snapshotHtml) {
try {
applyDashboardRows(parseDashboardRows(snapshotHtml));
return;
} catch (error) {
lastError = error;
}
}
if (!isDashboardRuntimeFetchAllowed()) {
renderRisetFeedback('Pemuatan Data Gagal', getDashboardErrorMessage(lastError || new Error('DASHBOARD_RUNTIME_FETCH_DISABLED')), 'Coba Lagi', 'fetchDashboardData()');
return;
+15 -1
View File
@@ -55,6 +55,20 @@ function copyStaticAssets() {
};
}
function copyRodaDashboardSnapshot() {
return {
name: 'copy-roda-dashboard-snapshot',
closeBundle() {
const source = path.join(root, 'groups', 'RODA', 'dashboard-snapshot.txt');
const destination = path.join(root, 'dist', 'groups', 'RODA', 'dashboard-snapshot.txt');
if (existsSync(source)) {
cpSync(source, destination);
}
},
};
}
async function requestRodaDashboardHtml() {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 12000);
@@ -178,7 +192,7 @@ function serveRodaDashboardApi() {
}
export default defineConfig({
plugins: [serveRodaDashboardApi(), embedRodaDashboardData(), copyStaticAssets()],
plugins: [serveRodaDashboardApi(), embedRodaDashboardData(), copyStaticAssets(), copyRodaDashboardSnapshot()],
build: {
rollupOptions: {
input: collectHtmlInputs(root),