Dodaj admin web panel u repo (admin/), sinhronizuj systemd unite

- admin/: LAN web panel (Flask + waitress + python-pam), status servisa,
  PAM login sa idriz korisnikom, vertikalni meni. Port 8080, samo LAN.
- systemd/idriz-admin.service: korisnički servis, enabled + Restart=always
  + StartLimitIntervalSec=0.
- systemd/idriz.service: dodan StartLimitIntervalSec=0 (repo je bio zastario).

Od sada sav aplikacioni source code ide u ovaj repo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzKpYaEsuWDevuNnvSjcFW
This commit is contained in:
idriz
2026-09-04 11:26:45 +02:00
parent dbe6ee6f28
commit 24cbe280d6
8 changed files with 500 additions and 0 deletions

114
admin/templates/base.html Normal file
View File

@@ -0,0 +1,114 @@
<!doctype html>
<html lang="bs">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Idriz Admin{% endblock %}</title>
<style>
:root {
--bg: #f4f5f7;
--panel: #ffffff;
--ink: #1c2330;
--muted: #6b7484;
--line: #e3e6eb;
--accent: #2f6df6;
--sidebar: #1c2330;
--sidebar-ink: #c7ccd6;
--sidebar-active: #2f6df6;
--ok: #1f9d55;
--warn: #c9820a;
--bad: #d13b3b;
}
* { box-sizing: border-box; }
body {
margin: 0;
font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
color: var(--ink);
background: var(--bg);
}
.layout { display: flex; min-height: 100vh; }
/* ---- Vertikalni meni lijevo ---- */
.sidebar {
width: 220px;
flex-shrink: 0;
background: var(--sidebar);
color: var(--sidebar-ink);
display: flex;
flex-direction: column;
}
.brand {
padding: 20px 20px 16px;
font-size: 18px;
font-weight: 700;
color: #fff;
letter-spacing: .3px;
border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.nav { padding: 12px 0; flex: 1; }
.nav a {
display: flex;
align-items: center;
gap: 10px;
padding: 11px 20px;
color: var(--sidebar-ink);
text-decoration: none;
font-size: 14px;
border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active {
background: rgba(47,109,246,.15);
color: #fff;
border-left-color: var(--sidebar-active);
font-weight: 600;
}
.nav .icon { width: 18px; text-align: center; }
.sidebar-foot {
padding: 14px 20px;
border-top: 1px solid rgba(255,255,255,.08);
font-size: 13px;
}
.sidebar-foot a { color: var(--muted); text-decoration: none; }
.sidebar-foot a:hover { color: #fff; }
/* ---- Glavni dio ---- */
.main { flex: 1; padding: 28px 32px; max-width: 1000px; }
h1 { margin: 0 0 4px; font-size: 22px; }
.sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.flash {
background: #fdecea;
border: 1px solid #f5c2bd;
color: #a12b2b;
padding: 10px 14px;
border-radius: 8px;
margin-bottom: 16px;
font-size: 14px;
}
{% block extra_css %}{% endblock %}
</style>
</head>
<body>
<div class="layout">
<aside class="sidebar">
<div class="brand">Idriz Admin<small>{{ session.user or '' }}</small></div>
<nav class="nav">
<a href="{{ url_for('status') }}" class="{{ 'active' if active_page == 'status' else '' }}">
<span class="icon">●</span> Status servisa
</a>
</nav>
<div class="sidebar-foot">
{% if session.user %}<a href="{{ url_for('logout') }}">↩ Odjava</a>{% endif %}
</div>
</aside>
<main class="main">
{% with msgs = get_flashed_messages() %}
{% for m in msgs %}<div class="flash">{{ m }}</div>{% endfor %}
{% endwith %}
{% block content %}{% endblock %}
</main>
</div>
</body>
</html>

View File

@@ -0,0 +1,38 @@
{% extends "base.html" %}
{% block title %}Prijava — Idriz Admin{% endblock %}
{% block extra_css %}
.layout { display: block; }
.sidebar { display: none; }
.main { max-width: none; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; }
.main .flash { width: 340px; }
.login-box {
background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
padding: 32px; width: 340px; box-shadow: 0 6px 24px rgba(0,0,0,.06);
}
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box .sub { margin-bottom: 22px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input {
width: 100%; padding: 10px 12px; font-size: 15px; margin-bottom: 16px;
border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus { outline: none; border-color: var(--accent); }
button {
width: 100%; padding: 11px; font-size: 15px; font-weight: 600; color: #fff;
background: var(--accent); border: none; border-radius: 8px; cursor: pointer;
}
button:hover { filter: brightness(1.05); }
{% endblock %}
{% block content %}
<div class="login-box">
<h1>Idriz Admin</h1>
<p class="sub">Prijavi se sa sistemskim korisnikom.</p>
<form method="post">
<label for="username">Korisničko ime</label>
<input id="username" name="username" autofocus autocomplete="username" value="idriz">
<label for="password">Lozinka</label>
<input id="password" name="password" type="password" autocomplete="current-password">
<button type="submit">Prijava</button>
</form>
</div>
{% endblock %}

View File

@@ -0,0 +1,77 @@
{% extends "base.html" %}
{% block title %}Status servisa — Idriz Admin{% endblock %}
{% block extra_css %}
.summary { display: flex; gap: 14px; margin-bottom: 20px; }
.card {
background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
padding: 14px 18px; min-width: 130px;
}
.card .num { font-size: 26px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: var(--panel);
border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; font-size: 14px; }
th { background: #fafbfc; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
tr:not(:last-child) td { border-bottom: 1px solid var(--line); }
.svc-name { font-weight: 600; }
.svc-desc { color: var(--muted); font-size: 12.5px; }
.svc-unit { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
.badge.ok { background: #e6f5ec; color: var(--ok); }
.badge.warn { background: #fdf1dd; color: var(--warn); }
.badge.bad { background: #fdecec; color: var(--bad); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.enabled-yes { color: var(--ok); } .enabled-no { color: var(--muted); }
.foot { color: var(--muted); font-size: 13px; margin-top: 16px; }
.refresh { float: right; font-size: 13px; text-decoration: none; color: var(--accent); }
{% endblock %}
{% block content %}
<a class="refresh" href="{{ url_for('status') }}">↻ Osvježi</a>
<h1>Status servisa</h1>
<p class="sub">Pregled sistemskih i korisničkih servisa mašine <strong>idriz</strong>.</p>
<div class="summary">
<div class="card">
<div class="num">{{ ok }}/{{ total }}</div>
<div class="lbl">servisa aktivno</div>
</div>
</div>
<table>
<thead>
<tr>
<th>Servis</th>
<th>Stanje</th>
<th>Autostart</th>
<th>Uptime</th>
<th>PID</th>
<th>Memorija</th>
</tr>
</thead>
<tbody>
{% for s in services %}
<tr>
<td>
<div class="svc-name"><span class="dot {{ s.state }}"></span>{{ s.label }}</div>
<div class="svc-desc">{{ s.desc }}</div>
<div class="svc-unit">{{ s.unit }}{% if s.scope == 'user' %} (user){% endif %}</div>
</td>
<td>
<span class="badge {{ s.state }}">{{ s.active }}{% if s.sub and s.sub != s.active %} / {{ s.sub }}{% endif %}</span>
</td>
<td>
{% if s.enabled == 'enabled' %}<span class="enabled-yes">✓ enabled</span>
{% elif s.enabled == 'static' %}<span class="enabled-yes">static</span>
{% else %}<span class="enabled-no">{{ s.enabled }}</span>{% endif %}
</td>
<td>{{ s.uptime }}</td>
<td>{% if s.pid and s.pid != '0' %}{{ s.pid }}{% else %}—{% endif %}</td>
<td>{{ s.mem }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p class="foot">Zadnje osvježeno: {{ now }}</p>
{% endblock %}