v0.10.0 - Add session archive/activate feature with access controls

This commit is contained in:
Javier
2026-01-25 02:23:18 -06:00
parent ca368cbbfb
commit 672591c736
8 changed files with 190 additions and 22 deletions

View File

@@ -23,18 +23,34 @@
</script>
<div class="dashboard-header">
<h1 class="page-title">Admin Dashboard</h1>
<div class="header-left">
<h1 class="page-title">Admin Dashboard</h1>
<label class="filter-toggle">
<input type="checkbox" id="showArchived" {% if show_archived %}checked{% endif %} onchange="toggleArchived()">
<span class="filter-label">Show Archived</span>
</label>
</div>
<a href="{{ url_for('sessions.create_session') }}" class="btn btn-primary">
<span class="btn-icon">+</span> New Session
</a>
</div>
<script>
function toggleArchived() {
const checked = document.getElementById('showArchived').checked;
window.location.href = '{{ url_for("dashboard") }}' + (checked ? '?show_archived=1' : '');
}
</script>
{% if sessions %}
<div class="sessions-grid">
{% for session in sessions %}
<div class="session-card">
<div class="session-card {% if session.status == 'archived' %}session-archived{% endif %}">
<div class="session-card-header">
<h3 class="session-name">{{ session.session_name }}</h3>
<h3 class="session-name">
{{ session.session_name }}
{% if session.status == 'archived' %}<span class="archived-badge">ARCHIVED</span>{% endif %}
</h3>
<span class="session-type-badge session-type-{{ session.session_type }}">
{{ 'Full Physical' if session.session_type == 'full_physical' else 'Cycle Count' }}
</span>

View File

@@ -6,13 +6,22 @@
<div class="session-detail-container">
<div class="session-detail-header">
<div>
<a href="{{ url_for('dashboard') }}" class="breadcrumb">← Back to Dashboard</a>
<h1 class="page-title">{{ count_session.session_name }}</h1>
<!-- Fixed variable name from session.session_type to count_session.session_type -->
<a href="{{ url_for('dashboard') }}{% if count_session.status == 'archived' %}?show_archived=1{% endif %}" class="breadcrumb">← Back to Dashboard</a>
<h1 class="page-title">
{{ count_session.session_name }}
{% if count_session.status == 'archived' %}<span class="archived-badge">ARCHIVED</span>{% endif %}
</h1>
<span class="session-type-badge session-type-{{ count_session.session_type }}">
{{ 'Full Physical' if count_session.session_type == 'full_physical' else 'Cycle Count' }}
</span>
</div>
<div class="session-actions-header">
{% if count_session.status == 'archived' %}
<button class="btn btn-success" onclick="activateSession()">✓ Activate Session</button>
{% else %}
<button class="btn btn-secondary" onclick="archiveSession()">📦 Archive Session</button>
{% endif %}
</div>
</div>
<!-- Baseline Upload Section -->
@@ -675,5 +684,38 @@ document.addEventListener('keydown', function(e) {
closeReopenConfirm();
}
});
function archiveSession() {
if (!confirm('Archive this session? It will be hidden from the main dashboard but can be reactivated later.')) return;
fetch('{{ url_for("sessions.archive_session", session_id=count_session.session_id) }}', {
method: 'POST',
headers: {'Content-Type': 'application/json'}
})
.then(r => r.json())
.then(data => {
if (data.success) {
window.location.href = '{{ url_for("dashboard") }}';
} else {
alert(data.message || 'Error archiving session');
}
});
}
function activateSession() {
if (!confirm('Reactivate this session? It will appear on the main dashboard again.')) return;
fetch('{{ url_for("sessions.activate_session", session_id=count_session.session_id) }}', {
method: 'POST',
headers: {'Content-Type': 'application/json'}
})
.then(r => r.json())
.then(data => {
if (data.success) {
location.reload();
} else {
alert(data.message || 'Error activating session');
}
});
}
</script>
{% endblock %}