Skip to content

Commit

Permalink
refractor systemstatus polling (#3587)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashton22305 authored Jun 4, 2024
1 parent 88a6ad2 commit 8a9fd20
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions apps/dashboard/app/javascript/system_status.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import { statusIndexUrl } from './config'
import { replaceHTML } from './turbo_shim'
import { pollAndReplace } from './turbo_shim'

function poll() {
pollDelay = 30000; // Probably want a configuration in the future, but 30 seconds for now

url = statusIndexUrl();
fetch(url, { headers: { Accept: "text/vnd.turbo-stream.html" } })
.then(response => response.ok ? Promise.resolve(response) : Promise.reject(response.text()))
.then((r) => r.text())
.then((html) => replaceHTML("system-status", html))
.then(setTimeout(poll, pollDelay))
.catch((err) => {
console.log('Cannot retrieve system status information due to error:');
console.log(err);
});
}

jQuery(poll)
jQuery(() => {
pollDelay = 30000;
pollAndReplace(statusIndexUrl(), pollDelay, "system-status");
})

0 comments on commit 8a9fd20

Please sign in to comment.