Sha256: 35173f4ce7fbd13ab640312508d8baa7a7942ba592e6f709a3ff4db4ddbede4e

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

<div class="card-section section_<%= current_view %>">
  <%= render current_view %>
</div>

<script>
  document.addEventListener("DOMContentLoaded", function() {
    const wrappers = document.querySelectorAll('.autorefresh');

    function updateTableWithJsonData(element) {
      const trs = element.querySelectorAll('tr[data-id]');
      const tr_ids = [...trs].map(tr => parseInt(tr.dataset.id, 10));

      fetch(element.dataset.url + "?" + new URLSearchParams({resources: tr_ids}))
        .then(response => response.json())
        .then(data => {
          trs.forEach(tr => {
            const items = tr.querySelectorAll('[data-autorefresh]');
            const id = parseInt(tr.dataset.id, 10);
            const newData = data.find(item => item.id === id);
            // console.log("newData", newData, "items", items, "id", id, "tr", tr, "data", data);
            if (newData) {
              items.forEach(item => {
                const field = item.dataset.autorefresh;
                if (field && newData[field]) {
                  item.innerHTML = newData[field];
                }
              });
              if (newData.locked) {
                setTimeout(() => updateTableWithJsonData(element), 1000);
              }
            }
          });
        })
        .catch(error => {
          console.error('Error fetching data:', error);
        });
    }

    wrappers.forEach(element => {
      updateTableWithJsonData(element);
    });
  });
</script>
</script>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.10.3 app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb
decidim-decidim_awesome-0.11.2 app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb
decidim-decidim_awesome-0.11.1 app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb