Skip to content

Commit

Permalink
get all info from one place
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Reynolds committed Apr 29, 2024
1 parent 3dbb821 commit c935e70
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
3 changes: 2 additions & 1 deletion labapp/app/ce.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def get_ce_state(ce_info: dict) -> dict:
ce_state = response.json()['state']
return {
"err": False,
"state": ce_state
"state": ce_state,
"site_name": ce_info['site_name']
}
else:
raise Exception(e)
Expand Down
37 changes: 30 additions & 7 deletions labapp/app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
}
return null;
}

</script>

</head>
Expand Down Expand Up @@ -128,6 +129,35 @@
</div>
</li>
</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 => {
document.getElementById('statusText').textContent = data.status; // adjust depending on actual JSON structure
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
document.getElementById('statusText').textContent = 'Error'; // error handling
});
}
fetchAndUpdateStatus();
setInterval(fetchAndUpdateStatus, 10000);
});
</script>
<div class="status-box align-items-center bg-light p-2">
<<p>Status: <strong id="statusText">Loading...</strong></p>
</div>
{% endif %}

</div>
</div>

Expand All @@ -137,13 +167,6 @@
{% endblock %}
</main>
</div>

{% if udf %}
<div class="status-box bg-light p-2">
<p>Status: <strong>Active</strong></p>
</div>
{% endif %}

</div>

</body>
Expand Down

0 comments on commit c935e70

Please sign in to comment.