89 lines
4.3 KiB
HTML
89 lines
4.3 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Weircon — forside{% endblock %}
|
|
{% block body %}
|
|
<h1>Hej, {{ user.name }}</h1>
|
|
<p class="wt-lead">Tjenester du har adgang til.</p>
|
|
{% if saved %}<div class="wt-flash">{{ saved }}</div>{% endif %}
|
|
|
|
<div id="dash">
|
|
<div class="wt-grid" style="margin-top:1.6rem" aria-hidden="true">
|
|
{% for i in range(8) %}
|
|
<div class="wt-tile skel"><div class="wt-tile-head"><span class="wt-tile-ico"></span><span class="sk" style="width:55%;height:1em"></span></div><span class="sk" style="width:80%;height:.8em;margin-top:.8rem"></span></div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if is_admin %}
|
|
<section class="appgroup">
|
|
<h2>Administration</h2>
|
|
<div class="wt-grid">
|
|
<a class="wt-tile" href="/admin">
|
|
<div class="wt-tile-head"><span class="wt-tile-ico">⚙️</span><span class="wt-tile-name">Admin-panel</span></div>
|
|
<div class="wt-tile-sub">Brugere, grupper, drift, ikoner m.m.</div>
|
|
<div class="wt-tile-go">Åbn →</div>
|
|
</a>
|
|
</div>
|
|
</section>
|
|
{% endif %}
|
|
|
|
<script>
|
|
(function(){
|
|
function setView(v){
|
|
var g=document.getElementById('view-grouped'), a=document.getElementById('view-alpha');
|
|
if(!g||!a) return;
|
|
g.hidden=(v==='alpha'); a.hidden=(v!=='alpha');
|
|
document.querySelectorAll('.wt-segment button').forEach(function(b){ b.classList.toggle('is-on', b.getAttribute('data-view')===v); });
|
|
}
|
|
function setFav(slug,on){
|
|
document.querySelectorAll('.fav[data-slug="'+CSS.escape(slug)+'"]').forEach(function(b){
|
|
b.classList.toggle('on',on); b.setAttribute('aria-pressed', on?'true':'false');
|
|
});
|
|
var favgrid=document.getElementById('favgrid'), favsec=document.getElementById('favsec');
|
|
if(!favgrid) return;
|
|
var has=favgrid.querySelector('.wt-tile[data-slug="'+CSS.escape(slug)+'"]');
|
|
if(on && !has){
|
|
var src=document.querySelector('#view-grouped .wt-tile[data-slug="'+CSS.escape(slug)+'"]') || document.querySelector('.wt-tile[data-slug="'+CSS.escape(slug)+'"]');
|
|
if(src){ favgrid.appendChild(src.cloneNode(true)); }
|
|
} else if(!on && has){ has.remove(); }
|
|
if(favsec) favsec.style.display = favgrid.children.length ? '' : 'none';
|
|
}
|
|
// delegation: virker også for async-indlæst indhold
|
|
document.addEventListener('click',function(e){
|
|
var fav=e.target.closest && e.target.closest('.fav');
|
|
if(fav){ e.preventDefault(); e.stopPropagation();
|
|
var slug=fav.getAttribute('data-slug'), on=!fav.classList.contains('on');
|
|
setFav(slug,on);
|
|
fetch('/api/favorite',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({slug:slug,on:on})});
|
|
return; }
|
|
var vb=e.target.closest && e.target.closest('.wt-segment button');
|
|
if(vb){ var v=vb.getAttribute('data-view'); setView(v);
|
|
fetch('/api/view',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({view:v})}); }
|
|
});
|
|
document.addEventListener('keydown',function(e){
|
|
var inp=document.getElementById('appfilter');
|
|
if(inp && e.key==='/' && document.activeElement!==inp && !/input|textarea/i.test(document.activeElement.tagName)){ e.preventDefault(); inp.focus(); }
|
|
});
|
|
function initDash(){
|
|
var inp=document.getElementById('appfilter');
|
|
if(!inp || inp.__wired) return; inp.__wired=true;
|
|
inp.addEventListener('input',function(){
|
|
var q=inp.value.trim().toLowerCase(), shown=0;
|
|
document.querySelectorAll('.wt-tile[data-search]').forEach(function(c){
|
|
var hit=!q || c.getAttribute('data-search').indexOf(q)>-1;
|
|
c.classList.toggle('hidden',!hit); if(hit && c.offsetParent!==null) shown++;
|
|
});
|
|
document.querySelectorAll('.appgroup').forEach(function(s){
|
|
if(s.id==='favsec') return;
|
|
var any=s.querySelector('.wt-tile:not(.hidden)'); s.style.display=any?'':'none';
|
|
});
|
|
var nm=document.getElementById('nomatch'); if(nm) nm.style.display=shown?'none':'block';
|
|
});
|
|
}
|
|
fetch('/dashboard-content',{headers:{'X-Requested-With':'fetch'}})
|
|
.then(function(r){ if(!r.ok) throw 0; return r.text(); })
|
|
.then(function(html){ document.getElementById('dash').innerHTML=html; initDash(); })
|
|
.catch(function(){ document.getElementById('dash').innerHTML='<p class="wt-muted" style="margin-top:1.6rem">Kunne ikke hente tjenester — prøv at genindlæse siden.</p>'; });
|
|
})();
|
|
</script>
|
|
{% endblock %}
|