Initial commit — Server_Monitorizare_v2

This commit is contained in:
ske087
2026-04-23 15:55:46 +03:00
commit d2485e4c66
61 changed files with 13861 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
{% extends "base.html" %}
{% block title %}{% if device %}Edit Device{% else %}New Device{% endif %} WMT {{ app_name }}{% endblock %}
{% block page_title %}{% if device %}Edit Device{% else %}New Device{% endif %}{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-lg-7">
<div class="card">
<div class="card-header">
<i class="fas fa-desktop me-2"></i>
{% if device %}
Edit: <code>{{ device.mac_address }}</code>
{% else %}
Register New WMT Device
{% endif %}
</div>
<div class="card-body">
<form method="post">
<div class="mb-3">
<label class="form-label fw-semibold">MAC Address <span class="text-danger">*</span>
<small class="text-muted fw-normal">(unique identifier, e.g. b8:27:eb:aa:bb:cc)</small>
</label>
{% if device %}
<input type="text" class="form-control" value="{{ device.mac_address }}" readonly disabled>
<small class="text-muted">MAC cannot be changed after registration.</small>
{% else %}
<input type="text" name="mac_address" class="form-control"
placeholder="b8:27:eb:aa:bb:cc" required
pattern="^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$">
{% endif %}
</div>
<div class="mb-3">
<label class="form-label fw-semibold">Work Place
<small class="text-muted fw-normal">(table / workstation identifier)</small>
</label>
<input type="text" name="device_name" class="form-control"
value="{{ device.device_name or '' if device else '' }}"
placeholder="Masa-01">
</div>
<div class="row g-3 mb-3">
<div class="col-md-6">
<label class="form-label fw-semibold">Hostname</label>
<input type="text" name="hostname" class="form-control"
value="{{ device.hostname or '' if device else '' }}"
placeholder="rpi-masa01">
</div>
<div class="col-md-6">
<label class="form-label fw-semibold">IP Address</label>
<input type="text" name="device_ip" class="form-control"
value="{{ device.device_ip or '' if device else '' }}"
placeholder="192.168.1.100">
</div>
</div>
<div class="mb-4">
<label class="form-label fw-semibold">Notes</label>
<textarea name="notes" class="form-control" rows="2">{{ device.notes or '' if device else '' }}</textarea>
</div>
{% if device %}
<div class="alert alert-light border small mb-4">
<strong>Last seen:</strong>
{{ device.last_seen.strftime('%Y-%m-%d %H:%M:%S') if device.last_seen else 'Never' }}<br>
<strong>Config updated:</strong>
{{ device.config_updated_at.strftime('%Y-%m-%d %H:%M:%S') if device.config_updated_at else '—' }}<br>
<strong>Info reviewed at:</strong>
<span class="{% if device.info_reviewed_at and device.info_reviewed_at.year > 1970 %}text-success{% else %}text-muted{% endif %}">
{{ device.info_reviewed_at.strftime('%Y-%m-%d %H:%M:%S') if (device.info_reviewed_at and device.info_reviewed_at.year > 1970) else 'Never reviewed' }}
</span>
<br><small class="text-muted">Updated automatically when you save this form, accept or reject a device request.</small>
</div>
{% endif %}
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="fas fa-save me-1"></i> {% if device %}Save Changes{% else %}Register Device{% endif %}
</button>
<a href="{{ url_for('wmt_web.devices') }}" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,70 @@
{% extends "base.html" %}
{% block title %}WMT Devices {{ app_name }}{% endblock %}
{% block page_title %}WMT Devices{% endblock %}
{% block content %}
<div class="mb-3 d-flex justify-content-between align-items-center">
<p class="text-muted mb-0">{{ devices | length }} device(s) registered.</p>
<a href="{{ url_for('wmt_web.device_new') }}" class="btn btn-success">
<i class="fas fa-plus me-1"></i> New Device
</a>
</div>
<div class="card">
<div class="card-body p-0">
{% if devices %}
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>Work Place</th>
<th>MAC Address</th>
<th>Hostname</th>
<th>IP Address</th>
<th>Last Seen</th>
<th>Config Updated</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for d in devices %}
<tr>
<td><strong>{{ d.device_name or '—' }}</strong></td>
<td><code>{{ d.mac_address }}</code></td>
<td>{{ d.hostname or '—' }}</td>
<td>{{ d.device_ip or '—' }}</td>
<td class="text-muted small">
{{ d.last_seen.strftime('%Y-%m-%d %H:%M') if d.last_seen else 'Never' }}
</td>
<td class="text-muted small">
{{ d.config_updated_at.strftime('%Y-%m-%d %H:%M') if d.config_updated_at else '—' }}
</td>
<td class="text-end">
<a href="{{ url_for('wmt_web.device_edit', device_id=d.id) }}"
class="btn btn-sm btn-outline-primary">
<i class="fas fa-edit"></i> Edit
</a>
<form method="post" action="{{ url_for('wmt_web.device_delete', device_id=d.id) }}"
class="d-inline"
onsubmit="return confirm('Delete device {{ d.mac_address }}?')">
<button type="submit" class="btn btn-sm btn-outline-danger">
<i class="fas fa-trash"></i>
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center text-muted py-5">
<i class="fas fa-desktop fa-3x mb-3 opacity-25"></i>
<p>No devices registered yet. <a href="{{ url_for('wmt_web.device_new') }}">Add the first one</a>.</p>
</div>
{% endif %}
</div>
</div>
{% endblock %}

181
templates/wmt/index.html Normal file
View File

@@ -0,0 +1,181 @@
{% extends "base.html" %}
{% block title %}WMT Management {{ app_name }}{% endblock %}
{% block extra_css %}
<style>
.stat-card { border-left: 4px solid; }
.stat-card.blue { border-color: #3498db; }
.stat-card.green { border-color: #2ecc71; }
.stat-card.orange{ border-color: #f39c12; }
.stat-card.red { border-color: #e74c3c; }
.badge-pending { background-color: #f39c12; }
.badge-accepted { background-color: #2ecc71; }
.badge-rejected { background-color: #e74c3c; }
</style>
{% endblock %}
{% block page_title %}WMT Management{% endblock %}
{% block content %}
<div class="row mb-3">
<div class="col">
<a href="{{ url_for('wmt_web.settings') }}" class="btn btn-primary me-2">
<i class="fas fa-cog"></i> Global Settings
</a>
<a href="{{ url_for('main.devices') }}" class="btn btn-outline-primary me-2">
<i class="fas fa-desktop"></i> Devices
</a>
<a href="{{ url_for('wmt_web.update_requests') }}" class="btn btn-outline-warning">
<i class="fas fa-inbox"></i> Update Requests
{% if pending_count > 0 %}
<span class="badge bg-danger ms-1">{{ pending_count }}</span>
{% endif %}
</a>
</div>
</div>
<!-- Stats row -->
<div class="row g-3 mb-4">
<div class="col-sm-6 col-lg-3">
<div class="card stat-card blue h-100">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div>
<p class="text-muted mb-1 small">Registered Devices</p>
<h4 class="mb-0">{{ devices | length }}</h4>
</div>
<i class="fas fa-desktop fa-2x text-primary opacity-50"></i>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-3">
<div class="card stat-card orange h-100">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div>
<p class="text-muted mb-1 small">Pending Requests</p>
<h4 class="mb-0">{{ pending_count }}</h4>
</div>
<i class="fas fa-clock fa-2x text-warning opacity-50"></i>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-3">
<div class="card stat-card green h-100">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div>
<p class="text-muted mb-1 small">Config Last Updated</p>
<h6 class="mb-0">
{% if global_cfg and global_cfg.updated_at %}
{{ global_cfg.updated_at.strftime('%Y-%m-%d %H:%M') }}
{% else %}
Never
{% endif %}
</h6>
</div>
<i class="fas fa-sync fa-2x text-success opacity-50"></i>
</div>
</div>
</div>
</div>
<div class="col-sm-6 col-lg-3">
<div class="card stat-card red h-100">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div>
<p class="text-muted mb-1 small">Chrome URL</p>
<small class="text-truncate d-block" style="max-width:160px">
{{ global_cfg.chrome_url if global_cfg else '—' }}
</small>
</div>
<i class="fas fa-globe fa-2x text-danger opacity-50"></i>
</div>
</div>
</div>
</div>
</div>
<div class="row g-3">
<!-- Device list -->
<div class="col-lg-7">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<strong><i class="fas fa-desktop me-2"></i>WMT Client Devices</strong>
<a href="{{ url_for('main.devices') }}" class="btn btn-sm btn-success">
<i class="fas fa-plus"></i> Add
</a>
</div>
<div class="card-body p-0">
{% if devices %}
<div class="table-responsive">
<table class="table table-sm table-hover mb-0">
<thead class="table-light">
<tr>
<th>Device Name</th>
<th>MAC</th>
<th>IP</th>
<th>Last Seen</th>
<th></th>
</tr>
</thead>
<tbody>
{% for d in devices %}
<tr>
<td><strong>{{ d.device_name or '—' }}</strong></td>
<td><code>{{ d.mac_address }}</code></td>
<td>{{ d.device_ip or '—' }}</td>
<td class="text-muted small">
{{ d.last_seen.strftime('%Y-%m-%d %H:%M') if d.last_seen else 'Never' }}
</td>
<td>
<a href="{{ url_for('main.device_edit', device_id=d.id) }}"
class="btn btn-xs btn-outline-primary btn-sm py-0">Edit</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p class="text-muted p-3 mb-0">No WMT client devices registered yet.
<a href="{{ url_for('main.devices') }}">Manage devices</a>.
</p>
{% endif %}
</div>
</div>
</div>
<!-- Recent update requests -->
<div class="col-lg-5">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<strong><i class="fas fa-inbox me-2"></i>Recent Requests</strong>
<a href="{{ url_for('wmt_web.update_requests') }}" class="btn btn-sm btn-outline-secondary">
View All
</a>
</div>
<div class="card-body p-0">
{% if recent_requests %}
<ul class="list-group list-group-flush">
{% for r in recent_requests %}
<li class="list-group-item d-flex justify-content-between align-items-start py-2">
<div>
<code class="small">{{ r.mac_address }}</code><br>
<small class="text-muted">{{ r.submitted_at.strftime('%Y-%m-%d %H:%M') }}</small>
</div>
<span class="badge badge-{{ r.status }} rounded-pill">{{ r.status }}</span>
</li>
{% endfor %}
</ul>
{% else %}
<p class="text-muted p-3 mb-0">No recent requests.</p>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock %}

124
templates/wmt/requests.html Normal file
View File

@@ -0,0 +1,124 @@
{% extends "base.html" %}
{% block title %}Update Requests WMT {{ app_name }}{% endblock %}
{% block extra_css %}
<style>
.badge-pending { background-color: #f39c12; color: #fff; }
.badge-accepted { background-color: #2ecc71; color: #fff; }
.badge-rejected { background-color: #e74c3c; color: #fff; }
</style>
{% endblock %}
{% block page_title %}
WMT Update Requests
{% if pending_count > 0 %}
<span class="badge bg-danger ms-2">{{ pending_count }} pending</span>
{% endif %}
{% endblock %}
{% block content %}
<!-- Filter tabs -->
<ul class="nav nav-tabs mb-4">
<li class="nav-item">
<a class="nav-link {% if status_filter == 'pending' %}active{% endif %}"
href="{{ url_for('wmt_web.update_requests', status='pending') }}">
Pending
{% if pending_count > 0 %}<span class="badge bg-danger ms-1">{{ pending_count }}</span>{% endif %}
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if status_filter == 'accepted' %}active{% endif %}"
href="{{ url_for('wmt_web.update_requests', status='accepted') }}">Accepted</a>
</li>
<li class="nav-item">
<a class="nav-link {% if status_filter == 'rejected' %}active{% endif %}"
href="{{ url_for('wmt_web.update_requests', status='rejected') }}">Rejected</a>
</li>
<li class="nav-item">
<a class="nav-link {% if status_filter == 'all' %}active{% endif %}"
href="{{ url_for('wmt_web.update_requests', status='all') }}">All</a>
</li>
</ul>
{% if requests %}
<div class="card">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>#</th>
<th>MAC Address</th>
<th>Proposed Device Name</th>
<th>Proposed Hostname</th>
<th>Proposed IP</th>
<th>Submitted</th>
<th>Client Config Time</th>
<th>Status</th>
{% if status_filter == 'pending' or status_filter == 'all' %}
<th class="text-end">Actions</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for r in requests %}
<tr>
<td class="text-muted small">{{ r.id }}</td>
<td><code>{{ r.mac_address }}</code></td>
<td>{{ r.proposed_device_name or '—' }}</td>
<td>{{ r.proposed_hostname or '—' }}</td>
<td>{{ r.proposed_device_ip or '—' }}</td>
<td class="text-muted small">{{ r.submitted_at.strftime('%Y-%m-%d %H:%M') }}</td>
<td class="text-muted small">{{ r.client_config_mtime or '—' }}</td>
<td>
<span class="badge badge-{{ r.status }} rounded-pill">{{ r.status }}</span>
{% if r.admin_reviewed_at %}
<br><small class="text-muted">{{ r.admin_reviewed_at.strftime('%Y-%m-%d %H:%M') }}</small>
{% endif %}
</td>
{% if status_filter == 'pending' or status_filter == 'all' %}
<td class="text-end">
{% if r.status == 'pending' %}
<!-- Accept -->
<form method="post" action="{{ url_for('wmt_web.accept_request', req_id=r.id) }}"
class="d-inline"
onsubmit="return confirm('Accept this request and update the device record?')">
<button type="submit" class="btn btn-sm btn-success">
<i class="fas fa-check"></i> Accept
</button>
</form>
<!-- Reject -->
<form method="post" action="{{ url_for('wmt_web.reject_request', req_id=r.id) }}"
class="d-inline ms-1"
onsubmit="return confirm('Reject this request?')">
<button type="submit" class="btn btn-sm btn-outline-danger">
<i class="fas fa-times"></i> Reject
</button>
</form>
{% else %}
<span class="text-muted small"></span>
{% endif %}
</td>
{% endif %}
</tr>
{% if r.admin_notes %}
<tr class="table-light">
<td colspan="9" class="small text-muted ps-4">
<i class="fas fa-comment me-1"></i> Admin note: {{ r.admin_notes }}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% else %}
<div class="text-center text-muted py-5">
<i class="fas fa-inbox fa-3x mb-3 opacity-25"></i>
<p>No {{ status_filter }} requests found.</p>
</div>
{% endif %}
{% endblock %}

109
templates/wmt/settings.html Normal file
View File

@@ -0,0 +1,109 @@
{% extends "base.html" %}
{% block title %}Global Settings WMT {{ app_name }}{% endblock %}
{% block page_title %}WMT Global Settings{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-lg-9">
<div class="card">
<div class="card-header">
<i class="fas fa-cog me-2"></i>
Global Configuration
<small class="text-muted ms-3">
Applied to all WMT devices on next sync.
{% if cfg and cfg.updated_at %}
Last saved: {{ cfg.updated_at.strftime('%Y-%m-%d %H:%M:%S') }} by {{ cfg.updated_by or 'admin' }}
{% endif %}
</small>
</div>
<div class="card-body">
<form method="post">
<h6 class="text-uppercase text-muted mb-3 mt-2">
<i class="fas fa-globe me-1"></i> Chrome Launch
</h6>
<div class="mb-3">
<label class="form-label fw-semibold">Production URL
<small class="text-muted fw-normal">(kiosk mode at startup)</small>
</label>
<input type="url" name="chrome_url" class="form-control"
value="{{ cfg.chrome_url if cfg else '' }}" required>
</div>
<div class="mb-3">
<label class="form-label fw-semibold">Local / Fallback URL
<small class="text-muted fw-normal">(optional)</small>
</label>
<input type="url" name="chrome_local_url" class="form-control"
value="{{ cfg.chrome_local_url or '' }}">
</div>
<div class="mb-4">
<label class="form-label fw-semibold">Insecure Origin to Trust
<small class="text-muted fw-normal">(--unsafely-treat-insecure-origin-as-secure)</small>
</label>
<input type="text" name="chrome_insecure_origin" class="form-control"
value="{{ cfg.chrome_insecure_origin if cfg else '' }}">
</div>
<hr>
<h6 class="text-uppercase text-muted mb-3">
<i class="fas fa-id-card me-1"></i> Card API
</h6>
<div class="mb-4">
<label class="form-label fw-semibold">Base URL
<small class="text-muted fw-normal">Format: {base_url}/{device_name}/{card_id}/{0or1}/{timestamp}</small>
</label>
<input type="url" name="card_api_base_url" class="form-control"
value="{{ cfg.card_api_base_url if cfg else '' }}" required>
</div>
<hr>
<h6 class="text-uppercase text-muted mb-3">
<i class="fas fa-server me-1"></i> Server / Network
</h6>
<div class="row g-3 mb-3">
<div class="col-md-6">
<label class="form-label fw-semibold">Log Server URL</label>
<input type="url" name="server_log_url" class="form-control"
value="{{ cfg.server_log_url if cfg else '' }}">
</div>
<div class="col-md-6">
<label class="form-label fw-semibold">Internet Check Host
<small class="text-muted fw-normal">(ping target)</small>
</label>
<input type="text" name="internet_check_host" class="form-control"
value="{{ cfg.internet_check_host if cfg else '' }}">
</div>
</div>
<div class="row g-3 mb-4">
<div class="col-md-6">
<label class="form-label fw-semibold">Auto-Update Host</label>
<input type="text" name="update_host" class="form-control"
value="{{ cfg.update_host if cfg else '' }}">
</div>
<div class="col-md-6">
<label class="form-label fw-semibold">Auto-Update SSH User</label>
<input type="text" name="update_user" class="form-control"
value="{{ cfg.update_user if cfg else '' }}">
</div>
</div>
<hr>
<div class="mb-3">
<label class="form-label fw-semibold">Admin Notes</label>
<textarea name="notes" class="form-control" rows="2">{{ cfg.notes or '' }}</textarea>
</div>
<div class="d-flex gap-2 mt-3">
<button type="submit" class="btn btn-primary">
<i class="fas fa-save me-1"></i> Save Settings
</button>
<a href="{{ url_for('wmt_web.index') }}" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}