{% load taskmonitor %}

{% random_id as data_id %}

{% include "admin/taskmonitor/report/div_chart_partial.html" with data_id=data_id %}

<script>
    fetch("{% url 'taskmonitor:admin_taskmonitor_report_html' report_name %}?disable_percent={{ disable_percent }}")
        .then((response) => {
            if (response.ok) {
                return response.text();
            }
            throw new Error(`${response.status} ${response.statusText}: ${response.url}`);
        })
        .then((html) => {
            let div = document.getElementById("{{ data_id }}-container");
            div.innerHTML = html
        })
        .catch((error) => {
            let div = document.getElementById("{{ data_id }}-container");
            div.innerHTML = `<p class="text-danger">${error}</p>`
        });
</script>
