Skip to content
Snippets Groups Projects
Commit 73b6d05a authored by Julian's avatar Julian
Browse files

Merge remote-tracking branch 'origin/feature/dashboard-widgets' into feature/dashboard-widgets

parents 8b268910 7d553ae3
No related branches found
No related tags found
1 merge request!142Implement core functionality for dashboard widgets
Pipeline #752 canceled
{% extends 'core/base.html' %}
{% load i18n %}
{% load i18n static %}
{% block browser_title %}{% blocktrans %}Home{% endblocktrans %}{% endblock %}
......@@ -32,8 +32,7 @@
{% endwith %}
</div>
{% endfor %}
</div>
</div>
<div class="row">
<div class="col s12 m6">
......@@ -89,58 +88,5 @@
</div>
{% endif %}
<script type="text/javascript">
const asyncIntervals = [];
const runAsyncInterval = async (cb, interval, intervalIndex) => {
await cb();
if (asyncIntervals[intervalIndex]) {
setTimeout(() => runAsyncInterval(cb, interval, intervalIndex), interval);
}
};
const setAsyncInterval = (cb, interval) => {
if (cb && typeof cb === "function") {
const intervalIndex = asyncIntervals.length;
asyncIntervals.push(true);
runAsyncInterval(cb, interval, intervalIndex);
return intervalIndex;
} else {
throw new Error('Callback must be a function');
}
};
const clearAsyncInterval = (intervalIndex) => {
if (asyncIntervals[intervalIndex]) {
asyncIntervals[intervalIndex] = false;
}
};
/* SOURCE: https://dev.to/jsmccrumb/asynchronous-setinterval-4j69 */
{# ------------------------------------------ #}
{#$(document).ready(function () {#}
{# setInterval(function () {#}
{# $('#body').load("/");#}
{# }, 3000);#}
{# });#}
{# ------------------------------------------ #}
let dashboard_interval = setAsyncInterval(async () => {
console.log('fetching new data');
const promise = new Promise((resolve) => {
$('#dashboard').load("/?include_by_ajax_full_render=1 #dashboard");
resolve(1);
});
await promise;
console.log('data fetched successfully');
}, 15000);
$(document).on('include_by_ajax_all_loaded', function() {
console.log('Now all placeholders are loaded and replaced with content');
})
</script>
<script type="text/javascript" src="{% static "js/include_ajax_live.js" %}"></script>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment