<html>
<head>
    <link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFsAAABbCAMAAAAr6AmrAAAByFBMVEUAAAAAABcAusoAABcAusoAusoAucoAABcAABcAABcAABcAABcAABcAABcAABcAusoAusoAABcAABcAABcAABgAABcAABcAABcAABcAABcArr8AABcAABcAABcAABcAABcAABcAABcAABcAABcAusoAABcAABgAABcAABcAABcAusoAABcAABcAusoAusoAABcAusoAABgAusoAABcAuskAABcAusoAABcAusoAABgAusoAusoAABcAABcAABcAABcAusoAusoAusoAABcAusoAABcAusoAABcAABcAusoAABgAusoAABgAABcAABcAusoAABgAABcAusoAusoAABcAusoAusoAABgAusoAucoAABcAusoAABcAusoAusoAuskAABgAABcAABcAuskAABcAusoAUGQAusoAusoAFSwAABgAGC8AusoAIjkAABcAusoAuMgABBwAtsYACiIADSUAq7wApbUAW28AJj0AGjEAkaIAPlQAEioAsMEArr8AmKoAZHgAVmsAUGUAHzYAssMAjZ8Ah5kAg5UAfpEAe44AMkgALEIAnq8AlKUAipwAbH8AYHQATGEAN00AIzkAeY0AcoYAZ3sAS1/5Mdi1AAAAbnRSTlMA+zgK+/379fHq56NYHhj467oiDwT524+DNwcG99G2m3peOikL79/Mw21RSEMuIRwU4tfWvr66sKyol3pyaT8m7+G0s6OVj4hiTEw+MzAtGRQSBPPTz8OsqJ5+dnVvbFpSTgTJyIlwNhDRz61mYqInaugAAAafSURBVGjerVkHWxNBEN0zxiQkkISgCZGEJkhHQEEB6UUQEbH33vVyCUWqICoq2OvfNdm7ze7sLuFSXhp8k303zM28mV2QOezZp+3ztB692lXXOI2yhMgdMWDta+86Hcwp994Er6bTa1bP0NihXHJDWD2dj3PLrSVeWvyZeHNfqgvmJt4kIJjduIr14u1gTrhJvDGxRkJzfyxn8aYXINh7vCl33MT1JDy3gtlzQ3ZKbx1oyjbemIwkSTI2+Jf+sSy5CTNNFsyPL+Pums4uJpiV8iWvhj+HMilUi6+gsvjR17XPc6sxEG8O7U/Soj2Y7xr1t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BQYx1kdyZNzbxjHBRg/gekLmfQT9qsoAIw3EBiIpPiq5xhmib0FprgQ0kn/ITc/nGC5e6RB+RVj1G5+BtyJuL5TRbnJEVTfYwtTNjYrL0fctPY+wJEzZggh/qhDU4BbmQDdTBJxJ0KNA1aSaRtixZLrWhsRqgbmAAJqJZR9zTmE0PRYq77+3SIwfmebkvsQ4gSl+iAgH+dEMGzMiYeue8SQqO8NJcEBbxXkWbnDdWIvE7OqAB3mmq66I1wGzq5qzMbkSkLu9sPuUMRt7++Gq/SrVvt74cxydAm2y58ae+x5E8XxADruEved9ScDZacmhCkx+FQQdjp6WfFRcK0K0OJDJuFSoIbNRZjM9wTxntUGyUtNUufnSXsGTu+EmmA4ueooN0Vt8ap8ljATRLzLYxRz+z97hRnuYV4esbtkeOkjGx7eA8fk7tRlvNh8xKTGJEt3mBX8yVferp6PKqLbuvbil5UedDhVDnZX6lgLC5RHF9nzgv5DVJQcwneHLSnOtC5IJCx400N39F3sMZUibrnHkRy+UXHv70jozJFOtyFWfWdZqR6UKLW3QcbcDdIaFnNju66+nbAQWmR9IFRbCMWlZxhETyy3uta4331NCKBHPqGVhIbLKwrP+XwFk/Xdl/Pkrb9GvzdEfeOdksMpsA64b7Pb7TYQZIAD+YCoaeSsrBoyQt4ZtCuKRpWMqIuRCRRdy4C8GlJndxoLEapEZlHfkhaz0lGAzCPfmwa1rcyS3v9Guu1mqQ8Xo3TRe3m/GWZHtwVlgIaaXRPG7m9GGaJhsCRlTgfyURbovda2g/O2sMuCssXkjXAVx68cKHVNodzg3uSdstLBmra2ttCxE/7ahgKUBv4DqBEkc+N2mLEAAAAASUVORK5CYII=" rel="icon" type="image/x-icon">
    <style>
        html,
        body {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 16px;
        }

        body {
            margin: 2em;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        table {
            border-collapse: collapse;
            border-radius: 5px;
            overflow: hidden;
        }

        th,
        td {
            text-align: left;
            padding: 8px;
            border-bottom: 1px solid #ddd;
        }

        th {
            background: rgb(115, 128, 139);
            background: linear-gradient(0deg, rgba(115, 128, 139, 1) 22%, rgba(149, 174, 181, 1) 100%);
            color: #333;
        }

        tr:nth-child(even) {
            background-color: #f2f2f2;
        }

        /* no link underline */
        a:link {
            text-decoration: none;
        }

        a:visited {
            text-decoration: none;
        }

        a:hover {
            text-decoration: none;
        }

        a:active {
            text-decoration: none;
        }

        /* table special columns styling */
        .targs-col{
            max-width: 6em;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
</head>

<body>
    <div
        style="display:flex; justify-content: space-between; padding-bottom: 1em; margin-bottom: 1em; border-bottom: 1px solid;">
        <div>
            <input id="auto_refresh" type="checkbox" onclick="handleOnAutoRefreshClick();" />
            <label for="auto_refresh">Auto Refresh</label>
        </div>
        <div style="display: flex; flex-direction: row-reverse;">
            <a style="margin-left: 1em;" class="preserve-query-params" href="/tasks">tasks</a>
            <a style="margin-left: 1em;" class="preserve-query-params" href="/num_units_status">units status</a>
            <a style="margin-left: 1em;" class="preserve-query-params" href="/tasks_status">tasks status</a>
        </div>
    </div>
    <div style="font-size: 1.5em; font-weight: bold; margin-bottom: 1em;">{{title}}</div>
    {{table}}
    <script>
        const preserveSearchParams = (event) => {
            const link = event.target;
            const url = new URL(window.location);
            const href = link.getAttribute('href');
            link.setAttribute('href', href + '?' + url.searchParams.toString());
        }
        
        window.addEventListener('load', () => {
            const url = new URL(window.location);
            if (url.searchParams.get('auto_refresh')) {
                document.getElementById('auto_refresh').checked = true;
            }

            // Add the query parameters to all links with class "preserve-query-params"
            const links = document.querySelectorAll('.preserve-query-params');
            links.forEach(link => {
                link.addEventListener('click', preserveSearchParams);
            });

        })

        handleOnAutoRefreshClick = (ev) => {
            const url = new URL(window.location);
            url.searchParams.set('auto_refresh', document.getElementById('auto_refresh').checked);
            window.history.replaceState({}, '', url);
        }

        setInterval(() => {
            if (document.getElementById('auto_refresh').checked) {
                window.location.reload()
            }
        }, 1000)

    </script>
</body>

</html>