Skip to content

Commit

Permalink
strange
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Reynolds committed Apr 29, 2024
1 parent ccff47e commit d432296
Showing 1 changed file with 27 additions and 34 deletions.
61 changes: 27 additions & 34 deletions labapp/app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,46 +150,39 @@
</ul>
{% if udf %}
<script>
document.addEventListener('DOMContentLoaded', function() {
function fetchAndUpdateStatus() {
fetch('/_ce_status')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (!data.err) {
document.getElementById('siteName').textContent = data.site_name;
//document.getElementById('siteState').textContent = data.state;
document.getElementById('statusImage').src = data.state === "PROVISIONED" ? "/static/good.png" : "/static/bad.png";

// Update cookies
setCookie('siteNameCache', data.site_name, 1);
setCookie('stateCache', data.state, 1);
} else {
document.getElementById('siteName').textContent = 'Error fetching data';
//document.getElementById('siteState').textContent = '';
document.getElementById('statusImage').src = "/static/bad.png";
}
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
document.getElementById('siteName').textContent = 'Error';
//document.getElementById('siteState').textContent = '';
document.getElementById('statusImage').src = "/static/bad.png";
});
}
});

function fetchAndUpdateStatus() {
fetch('/_ce_status')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (!data.err) {
document.getElementById('siteName').textContent = data.site_name;
document.getElementById('statusImage').src = data.state === "PROVISIONED" ? "/static/good.png" : "/static/bad.png";

// Update cookies
setCookie('siteNameCache', data.site_name, 1);
setCookie('stateCache', data.state, 1);
} else {
document.getElementById('siteName').textContent = 'Error fetching data';
document.getElementById('statusImage').src = "/static/bad.png";
}
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
document.getElementById('siteName').textContent = 'Error';
document.getElementById('statusImage').src = "/static/bad.png";
});
}
document.addEventListener('DOMContentLoaded', function() {
let cachedSiteName = getCookie('siteNameCache');
let cachedState = getCookie('stateCache');

if (cachedSiteName && cachedState) {
document.getElementById('siteName').textContent = cachedSiteName;
//document.getElementById('siteState').textContent = cachedState;
document.getElementById('statusImage').src = cachedState === "PROVISIONED" ? "/static/good.png" : "/static/bad.png";
} else {
fetchAndUpdateStatus();
Expand Down

0 comments on commit d432296

Please sign in to comment.