forked from izu/student-web-if-development-kit
Fix RODA dashboard data fallback
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -77,6 +77,7 @@
|
|||||||
debugLogs: false,
|
debugLogs: false,
|
||||||
dashboardRuntimeFetch: 'always',
|
dashboardRuntimeFetch: 'always',
|
||||||
dashboardTargetUrl: 'https://dashboard.informatika.untan.ac.id/index.php?penelitian',
|
dashboardTargetUrl: 'https://dashboard.informatika.untan.ac.id/index.php?penelitian',
|
||||||
|
dashboardSnapshotUrl: 'dashboard-snapshot.txt',
|
||||||
dashboardProxyTemplates: [
|
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://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) {
|
function applyDashboardRows(rows) {
|
||||||
const newData = [];
|
const newData = [];
|
||||||
rows.forEach((row) => {
|
rows.forEach((row) => {
|
||||||
@@ -1671,6 +1691,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const snapshotHtml = await fetchDashboardSnapshotHtml();
|
||||||
|
if (snapshotHtml) {
|
||||||
|
try {
|
||||||
|
applyDashboardRows(parseDashboardRows(snapshotHtml));
|
||||||
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
lastError = error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isDashboardRuntimeFetchAllowed()) {
|
if (!isDashboardRuntimeFetchAllowed()) {
|
||||||
renderRisetFeedback('Pemuatan Data Gagal', getDashboardErrorMessage(lastError || new Error('DASHBOARD_RUNTIME_FETCH_DISABLED')), 'Coba Lagi', 'fetchDashboardData()');
|
renderRisetFeedback('Pemuatan Data Gagal', getDashboardErrorMessage(lastError || new Error('DASHBOARD_RUNTIME_FETCH_DISABLED')), 'Coba Lagi', 'fetchDashboardData()');
|
||||||
return;
|
return;
|
||||||
|
|||||||
+15
-1
@@ -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() {
|
async function requestRodaDashboardHtml() {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeoutId = setTimeout(() => controller.abort(), 12000);
|
const timeoutId = setTimeout(() => controller.abort(), 12000);
|
||||||
@@ -178,7 +192,7 @@ function serveRodaDashboardApi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [serveRodaDashboardApi(), embedRodaDashboardData(), copyStaticAssets()],
|
plugins: [serveRodaDashboardApi(), embedRodaDashboardData(), copyStaticAssets(), copyRodaDashboardSnapshot()],
|
||||||
build: {
|
build: {
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: collectHtmlInputs(root),
|
input: collectHtmlInputs(root),
|
||||||
|
|||||||
Reference in New Issue
Block a user