Upload files to "templates/admin"
This commit is contained in:
131
templates/admin/textures_view.html
Normal file
131
templates/admin/textures_view.html
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
{% extends 'admin/custom_base.html' %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="container-fluid mt-3">
|
||||||
|
<div class="d-flex align-items-center justify-content-between mb-3 flex-wrap" style="gap:.5rem">
|
||||||
|
<h3 class="mb-0">{{ categories[category].label }} <span class="badge badge-secondary" style="font-size:.7em">{{ total }}</span></h3>
|
||||||
|
<form method="get" class="d-flex" style="gap:.5rem">
|
||||||
|
<input type="hidden" name="cat" value="{{ category }}">
|
||||||
|
<input name="q" value="{{ search }}" class="form-control form-control-sm" placeholder="Search {{ categories[category].label|lower }}..." style="width:220px">
|
||||||
|
<button class="btn btn-sm btn-primary">Search</button>
|
||||||
|
{% if search %}<a href="?cat={{ category }}" class="btn btn-sm btn-outline-secondary">Clear</a>{% endif %}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3" style="display:flex;flex-wrap:wrap;gap:6px">
|
||||||
|
{% for cat_key, cat_info in categories.items() %}
|
||||||
|
<a href="?cat={{ cat_key }}"
|
||||||
|
class="btn btn-sm {% if cat_key == category %}btn-purple{% else %}btn-outline-secondary{% endif %}"
|
||||||
|
style="{% if cat_key == category %}background:var(--kr-purple);border-color:var(--kr-purple);color:#fff{% endif %}">
|
||||||
|
{{ cat_info.label }}
|
||||||
|
<span class="badge {% if cat_key == category %}badge-light{% else %}badge-secondary{% endif %}" style="font-size:.7em">{{ cat_counts.get(cat_key, 0) }}</span>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if not files %}
|
||||||
|
<p class="text-muted">No {{ categories[category].label|lower }} found{% if search %} matching "{{ search }}"{% endif %}.</p>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% if category in ('Texture2D', 'Sprite') %}
|
||||||
|
<div class="row" style="margin:0 -6px">
|
||||||
|
{% for f in files %}
|
||||||
|
{% set url = '/assets/' + category + '/' + f %}
|
||||||
|
<div class="col-6 col-sm-4 col-md-3 col-lg-2 mb-3 px-1">
|
||||||
|
<div class="card h-100" style="background:#1a1a2e;border-color:#333">
|
||||||
|
<a href="{{ url }}" target="_blank">
|
||||||
|
<img src="{{ url }}" class="card-img-top" alt="{{ f }}"
|
||||||
|
style="height:100px;object-fit:contain;background:#111;padding:4px;cursor:zoom-in"
|
||||||
|
loading="lazy" onerror="this.style.opacity='.2'">
|
||||||
|
</a>
|
||||||
|
<div class="card-body p-1 text-center">
|
||||||
|
<div style="font-size:.62rem;color:#aaa;word-break:break-all;line-height:1.2;max-height:2.4em;overflow:hidden" title="{{ f }}">
|
||||||
|
{{ f.rsplit('.', 1)[0] }}
|
||||||
|
</div>
|
||||||
|
<a href="{{ url }}" download="{{ f }}" class="btn btn-outline-light btn-sm mt-1 py-0 px-2" style="font-size:.65rem">Download</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% elif category == 'AudioClip' %}
|
||||||
|
<div class="row" style="margin:0 -6px">
|
||||||
|
{% for f in files %}
|
||||||
|
{% set url = '/assets/' + category + '/' + f %}
|
||||||
|
<div class="col-12 col-sm-6 col-md-4 col-lg-3 mb-2 px-1">
|
||||||
|
<div class="card" style="background:#1a1a2e;border-color:#333">
|
||||||
|
<div class="card-body p-2">
|
||||||
|
<div style="font-size:.75rem;color:#ccc;word-break:break-all;margin-bottom:4px" title="{{ f }}">{{ f }}</div>
|
||||||
|
<audio controls preload="none" style="width:100%;height:32px">
|
||||||
|
<source src="{{ url }}">
|
||||||
|
</audio>
|
||||||
|
<a href="{{ url }}" download="{{ f }}" class="btn btn-outline-light btn-sm mt-1 py-0 px-1" style="font-size:.6rem">Download</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% elif category == 'Font' %}
|
||||||
|
<div class="row" style="margin:0 -6px">
|
||||||
|
{% for f in files %}
|
||||||
|
{% set url = '/assets/' + category + '/' + f %}
|
||||||
|
<div class="col-12 col-sm-6 col-md-4 mb-3 px-1">
|
||||||
|
<div class="card" style="background:#1a1a2e;border-color:#333">
|
||||||
|
<div class="card-body p-2">
|
||||||
|
<style>@font-face { font-family: "preview-{{ loop.index }}"; src: url("{{ url }}"); }</style>
|
||||||
|
<div style="font-family:'preview-{{ loop.index }}';font-size:1.4rem;color:#eee;margin-bottom:6px">
|
||||||
|
The quick brown fox jumps over the lazy dog
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<small style="color:#aaa">{{ f }}</small>
|
||||||
|
<a href="{{ url }}" download="{{ f }}" class="btn btn-outline-light btn-sm py-0 px-2" style="font-size:.65rem">Download</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% elif category in ('TextAsset', 'Shader', 'MonoBehaviour') %}
|
||||||
|
<table class="table table-sm table-hover">
|
||||||
|
<thead><tr><th>Name</th><th class="text-right" style="width:120px">Actions</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
{% for f in files %}
|
||||||
|
{% set url = '/assets/' + category + '/' + f %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span style="font-size:.85rem">{{ f }}</span>
|
||||||
|
</td>
|
||||||
|
<td class="text-right">
|
||||||
|
<a href="{{ url }}" target="_blank" class="btn btn-outline-info btn-sm py-0 px-2" style="font-size:.65rem">View</a>
|
||||||
|
<a href="{{ url }}" download="{{ f }}" class="btn btn-outline-light btn-sm py-0 px-2" style="font-size:.65rem">Download</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if pages > 1 %}
|
||||||
|
<nav class="mt-2">
|
||||||
|
<ul class="pagination pagination-sm justify-content-center flex-wrap">
|
||||||
|
{% if page > 1 %}
|
||||||
|
<li class="page-item"><a class="page-link" href="?cat={{ category }}&q={{ search }}&page={{ page - 1 }}">«</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% for p in range([1, page-3]|max, [pages+1, page+4]|min) %}
|
||||||
|
<li class="page-item {% if p == page %}active{% endif %}">
|
||||||
|
<a class="page-link" href="?cat={{ category }}&q={{ search }}&page={{ p }}">{{ p }}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
{% if page < pages %}
|
||||||
|
<li class="page-item"><a class="page-link" href="?cat={{ category }}&q={{ search }}&page={{ page + 1 }}">»</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
175
templates/admin/ugc_items_view.html
Normal file
175
templates/admin/ugc_items_view.html
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
{% extends 'admin/custom_base.html' %}
|
||||||
|
{% block body %}
|
||||||
|
<div class="container-fluid mt-3">
|
||||||
|
<h4 class="mb-1">UGC Avatar Items</h4>
|
||||||
|
<p class="text-muted small mb-3">
|
||||||
|
Manage items served via <code>GET /api/ugc/OutfitItem/get</code>.
|
||||||
|
The client constructs <code>http://kittyrec.tabbycluster.net/{AssetbundleName}</code> for each entry.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% if error %}
|
||||||
|
<div class="alert alert-danger alert-dismissible">{{ error }}<button type="button" class="close" data-dismiss="alert">×</button></div>
|
||||||
|
{% endif %}
|
||||||
|
{% if success %}
|
||||||
|
<div class="alert alert-success alert-dismissible">{{ success }}<button type="button" class="close" data-dismiss="alert">×</button></div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if SCOPE_ADMIN in scopes %}
|
||||||
|
<div class="card mb-4">
|
||||||
|
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
|
||||||
|
<strong>+ Add UGC Outfit Item</strong>
|
||||||
|
<div class="custom-control custom-switch mb-0">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="cdn-toggle" checked>
|
||||||
|
<label class="custom-control-label text-white" for="cdn-toggle">Use CDN upload</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<form method="POST" id="add-form" enctype="multipart/form-data">
|
||||||
|
<input type="hidden" name="action_type" value="add">
|
||||||
|
<input type="hidden" name="use_cdn" id="use-cdn-hidden" value="1">
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-5 mb-2">
|
||||||
|
<label class="small font-weight-bold">Friendly Name <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="friendly_name" placeholder="e.g. Space Suit Pack" required maxlength="128">
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-2 mb-2">
|
||||||
|
<label class="small font-weight-bold">Version</label>
|
||||||
|
<input type="number" class="form-control" name="version" value="0" min="0">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="cdn-fields">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-5 mb-2">
|
||||||
|
<label class="small font-weight-bold">.assetbundle file <span class="text-danger">*</span></label>
|
||||||
|
<input type="file" class="form-control-file" name="assetbundle_file">
|
||||||
|
<small class="form-text text-muted">Max 10MB.</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-5 mb-2">
|
||||||
|
<label class="small font-weight-bold">.manifest file <span class="text-danger">*</span></label>
|
||||||
|
<input type="file" class="form-control-file" name="manifest_file">
|
||||||
|
<small class="form-text text-muted">Max 10MB. Make sure this matches the assetbundle you uploaded.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="direct-fields" style="display:none">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-5 mb-2">
|
||||||
|
<label class="small font-weight-bold">AssetbundleName path <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="bundle_url" placeholder="e.g. myitem.assetbundle">
|
||||||
|
<small class="form-text text-muted">Path appended to <code>http://kittyrec.tabbycluster.net/</code></small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-5 mb-2">
|
||||||
|
<label class="small font-weight-bold">ManifestName path <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" class="form-control" name="manifest_url" placeholder="e.g. myitem.manifest">
|
||||||
|
<small class="form-text text-muted">Stem must match the assetbundle path.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-success mt-1">Add Item</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<strong>Registered UGC Outfit Items</strong>
|
||||||
|
<span class="badge badge-secondary ml-1">{{ items|length }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="card-body p-0">
|
||||||
|
<table class="table table-sm table-hover mb-0">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th>Friendly Name</th>
|
||||||
|
<th>AssetbundleName</th>
|
||||||
|
<th>ManifestName</th>
|
||||||
|
<th>Ver</th>
|
||||||
|
{% if SCOPE_ADMIN in scopes %}<th>Actions</th>{% endif %}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% if not items %}
|
||||||
|
<tr><td colspan="5" class="text-center text-muted py-4">No UGC outfit items registered yet.</td></tr>
|
||||||
|
{% else %}
|
||||||
|
{% for item in items %}
|
||||||
|
<tr id="row-{{ item.id }}">
|
||||||
|
<td><strong>{{ item.friendly_name }}</strong></td>
|
||||||
|
<td>
|
||||||
|
<small class="text-monospace">{{ item.assetbundle_name }}</small>
|
||||||
|
{% if item.assetbundle_name.startswith('cdn_') %}
|
||||||
|
<a href="http://kittyrec.tabbycluster.net/{{ item.assetbundle_name }}" target="_blank" class="ml-1 small">↗</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<small class="text-monospace">{{ item.manifest_name }}</small>
|
||||||
|
{% if item.manifest_name.startswith('cdn_') %}
|
||||||
|
<a href="http://kittyrec.tabbycluster.net/{{ item.manifest_name }}" target="_blank" class="ml-1 small">↗</a>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>{{ item.get('version', 0) }}</td>
|
||||||
|
{% if SCOPE_ADMIN in scopes %}
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-xs btn-outline-secondary" onclick="toggleEdit('{{ item.id }}')">Edit</button>
|
||||||
|
<form method="POST" style="display:inline" onsubmit="return confirm('Delete this UGC item?')">
|
||||||
|
<input type="hidden" name="action_type" value="delete">
|
||||||
|
<input type="hidden" name="item_id" value="{{ item.id }}">
|
||||||
|
<button type="submit" class="btn btn-xs btn-outline-danger">Delete</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
<tr id="edit-{{ item.id }}" style="display:none" class="table-warning">
|
||||||
|
<td colspan="5">
|
||||||
|
<form method="POST" class="form-inline flex-wrap" style="gap:6px">
|
||||||
|
<input type="hidden" name="action_type" value="edit">
|
||||||
|
<input type="hidden" name="item_id" value="{{ item.id }}">
|
||||||
|
<input type="text" class="form-control form-control-sm" name="friendly_name" value="{{ item.friendly_name }}" placeholder="Friendly name" style="width:160px">
|
||||||
|
<input type="text" class="form-control form-control-sm" name="bundle_url" value="{{ item.assetbundle_name }}" placeholder="AssetbundleName" style="width:300px">
|
||||||
|
<input type="text" class="form-control form-control-sm" name="manifest_url" value="{{ item.manifest_name }}" placeholder="ManifestName" style="width:300px">
|
||||||
|
<input type="number" class="form-control form-control-sm" name="version" value="{{ item.get('version', 0) }}" min="0" style="width:70px">
|
||||||
|
<button type="submit" class="btn btn-sm btn-success">Save</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-secondary" onclick="toggleEdit('{{ item.id }}')">Cancel</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleEdit(id) {
|
||||||
|
var row = document.getElementById('edit-' + id);
|
||||||
|
row.style.display = row.style.display === 'none' ? '' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var toggle = document.getElementById('cdn-toggle');
|
||||||
|
var cdnFields = document.getElementById('cdn-fields');
|
||||||
|
var directFields = document.getElementById('direct-fields');
|
||||||
|
var hiddenCdn = document.getElementById('use-cdn-hidden');
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
if (toggle.checked) {
|
||||||
|
cdnFields.style.display = '';
|
||||||
|
directFields.style.display = 'none';
|
||||||
|
hiddenCdn.value = '1';
|
||||||
|
} else {
|
||||||
|
cdnFields.style.display = 'none';
|
||||||
|
directFields.style.display = '';
|
||||||
|
hiddenCdn.value = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toggle.addEventListener('change', update);
|
||||||
|
update();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
12
templates/admin/unauthorized.html
Normal file
12
templates/admin/unauthorized.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}Unauthorized — KittyRec Admin{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div style="text-align:center;padding:5rem 1rem">
|
||||||
|
<h1 style="font-size:2rem;margin-bottom:.5rem">Access Denied</h1>
|
||||||
|
<p style="color:var(--text2);margin-bottom:2rem">Your account doesn't have admin or moderator permissions for KittyRec.</p>
|
||||||
|
{% if account %}
|
||||||
|
<p style="color:var(--text3);font-size:.85rem;margin-bottom:2rem">Signed in as <strong style="color:var(--text)">{{ account.username }}</strong> — scopes: {{ scopes|join(', ') or 'none' }}</p>
|
||||||
|
{% endif %}
|
||||||
|
<a href="/admin/logout" class="btn btn-ghost">Sign out</a>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
184
templates/admin/videos.html
Normal file
184
templates/admin/videos.html
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
{% extends "admin/admin_base.html" %}
|
||||||
|
{% block title %}Videos — KittyRec Admin{% endblock %}
|
||||||
|
{% block head %}
|
||||||
|
<style>
|
||||||
|
.video-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:1rem; }
|
||||||
|
.video-card { background:var(--bg2); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
|
||||||
|
.video-card video { width:100%; display:block; max-height:180px; background:#000; }
|
||||||
|
.video-card-body { padding:.75rem; }
|
||||||
|
.video-name { font-size:.82rem; font-weight:600; color:var(--text); word-break:break-all; margin-bottom:.25rem; }
|
||||||
|
.video-meta { font-size:.72rem; color:var(--text3); margin-bottom:.6rem; }
|
||||||
|
.replace-panel { display:none; margin-top:.75rem; border-top:1px solid var(--border); padding-top:.75rem; }
|
||||||
|
.replace-panel.open { display:block; }
|
||||||
|
.replace-tabs { display:flex; gap:.35rem; margin-bottom:.6rem; }
|
||||||
|
.replace-tab { flex:1; padding:.3rem; border-radius:5px; border:1px solid var(--border); background:var(--bg3); color:var(--text2); font-size:.75rem; font-weight:600; cursor:pointer; text-align:center; }
|
||||||
|
.replace-tab.active { background:var(--purple); color:#fff; border-color:var(--purple); }
|
||||||
|
.replace-section { display:none; }
|
||||||
|
.replace-section.active { display:block; }
|
||||||
|
.replace-prog { height:4px; background:var(--bg3); border-radius:2px; margin-top:.5rem; display:none; }
|
||||||
|
.replace-prog-bar { height:100%; background:var(--purple); border-radius:2px; width:0%; transition:width .2s; }
|
||||||
|
.replace-drop { border:2px dashed var(--border); border-radius:7px; padding:1.25rem; text-align:center; color:var(--text3); font-size:.78rem; cursor:pointer; transition:border-color .15s,background .15s; }
|
||||||
|
.replace-drop.drag-over { border-color:var(--purple); background:rgba(124,58,237,.06); }
|
||||||
|
.replace-drop input[type=file] { display:none; }
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="page-header">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<h1>Videos</h1>
|
||||||
|
<span class="badge badge-purple ml-auto" id="video-count-badge">—</span>
|
||||||
|
</div>
|
||||||
|
<p>Game videos served at /Videos/ — replace existing files to update content</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="section-head">
|
||||||
|
<h2>Library</h2>
|
||||||
|
<button class="btn btn-ghost btn-sm" onclick="loadVideos()">Refresh</button>
|
||||||
|
</div>
|
||||||
|
<div style="padding:1rem" id="video-grid-wrap">
|
||||||
|
<div style="text-align:center;color:var(--text3);padding:2rem 0;font-size:.85rem">Loading…</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script>
|
||||||
|
function formatBytes(b) {
|
||||||
|
if (b >= 1048576) return (b/1048576).toFixed(1) + ' MB';
|
||||||
|
if (b >= 1024) return (b/1024).toFixed(0) + ' KB';
|
||||||
|
return b + ' B';
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildCard(f, idx) {
|
||||||
|
const nameEsc = KR.escapeHtml(f.name);
|
||||||
|
const urlEsc = KR.escapeHtml(f.url);
|
||||||
|
return `
|
||||||
|
<div class="video-card" id="vc-${idx}">
|
||||||
|
<video src="${urlEsc}" controls preload="metadata"></video>
|
||||||
|
<div class="video-card-body">
|
||||||
|
<div class="video-name">${nameEsc}</div>
|
||||||
|
<div class="video-meta">${formatBytes(f.size)}</div>
|
||||||
|
<div class="flex gap-1">
|
||||||
|
<a class="btn btn-ghost btn-sm" href="${urlEsc}" target="_blank">Open</a>
|
||||||
|
{% if SCOPE_ADMIN in scopes %}
|
||||||
|
<button class="btn btn-primary btn-sm" onclick="toggleReplace(${idx})">Replace</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="replace-panel" id="rp-${idx}">
|
||||||
|
<div class="replace-tabs">
|
||||||
|
<div class="replace-tab active" onclick="switchTab(${idx},'url')">URL</div>
|
||||||
|
<div class="replace-tab" onclick="switchTab(${idx},'file')">File</div>
|
||||||
|
</div>
|
||||||
|
<div class="replace-section active" id="rt-url-${idx}">
|
||||||
|
<div class="form-group" style="margin-bottom:.5rem">
|
||||||
|
<input type="text" class="url-input" id="ri-url-${idx}" placeholder="https://example.com/video.mp4">
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary btn-sm" onclick="doReplaceUrl(${idx})">Replace from URL</button>
|
||||||
|
</div>
|
||||||
|
<div class="replace-section" id="rt-file-${idx}">
|
||||||
|
<div class="replace-drop" id="rdrop-${idx}" onclick="document.getElementById('ri-file-${idx}').click()">
|
||||||
|
<input type="file" id="ri-file-${idx}" accept=".mp4,.webm,.mov,.avi,.mkv,.m4v" onchange="doReplaceFile(${idx},this.files[0])">
|
||||||
|
Drop file here or click to browse
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="replace-prog" id="rprog-${idx}"><div class="replace-prog-bar" id="rprogbar-${idx}"></div></div>
|
||||||
|
<div style="font-size:.72rem;color:var(--text3);margin-top:.35rem" id="rprog-label-${idx}"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const _videoNames = [];
|
||||||
|
|
||||||
|
async function loadVideos() {
|
||||||
|
const wrap = document.getElementById('video-grid-wrap');
|
||||||
|
wrap.innerHTML = '<div style="text-align:center;color:var(--text3);padding:2rem 0;font-size:.85rem">Loading…</div>';
|
||||||
|
const files = await KR.apiGet('/admin/api/videos');
|
||||||
|
if (!Array.isArray(files) || !files.length) {
|
||||||
|
wrap.innerHTML = '<div style="text-align:center;color:var(--text3);padding:2rem 0;font-size:.85rem">No videos found</div>';
|
||||||
|
document.getElementById('video-count-badge').textContent = '0 videos';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.getElementById('video-count-badge').textContent = files.length + ' video' + (files.length !== 1 ? 's' : '');
|
||||||
|
_videoNames.length = 0;
|
||||||
|
files.forEach((f, i) => _videoNames.push(f.name));
|
||||||
|
wrap.innerHTML = '<div class="video-grid">' + files.map((f, i) => buildCard(f, i)).join('') + '</div>';
|
||||||
|
files.forEach((f, i) => setupDrop(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleReplace(idx) {
|
||||||
|
const panel = document.getElementById('rp-' + idx);
|
||||||
|
if (!panel) return;
|
||||||
|
panel.classList.toggle('open');
|
||||||
|
}
|
||||||
|
|
||||||
|
function switchTab(idx, tab) {
|
||||||
|
const urlSec = document.getElementById('rt-url-' + idx);
|
||||||
|
const fileSec = document.getElementById('rt-file-' + idx);
|
||||||
|
const panel = document.getElementById('rp-' + idx);
|
||||||
|
if (!panel) return;
|
||||||
|
panel.querySelectorAll('.replace-tab').forEach((t, i) => t.classList.toggle('active', (i===0&&tab==='url')||(i===1&&tab==='file')));
|
||||||
|
if (urlSec) urlSec.classList.toggle('active', tab==='url');
|
||||||
|
if (fileSec) fileSec.classList.toggle('active', tab==='file');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doReplaceUrl(idx) {
|
||||||
|
const name = _videoNames[idx];
|
||||||
|
const urlEl = document.getElementById('ri-url-' + idx);
|
||||||
|
const url = urlEl ? urlEl.value.trim() : '';
|
||||||
|
if (!url) { KR.toast('Enter a URL', 'error'); return; }
|
||||||
|
setProgress(idx, 0, 'Fetching…', true);
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('target_name', name);
|
||||||
|
fd.append('url', url);
|
||||||
|
try {
|
||||||
|
const r = await fetch('/admin/api/videos/replace', { method: 'POST', body: fd });
|
||||||
|
const d = await r.json();
|
||||||
|
if (d.ok) { KR.toast('Replaced ' + name); setProgress(idx, 100, 'Done!', true); setTimeout(() => { setProgress(idx,0,'',false); loadVideos(); }, 1200); }
|
||||||
|
else { KR.toast(d.error || 'Error', 'error'); setProgress(idx,0,'',false); }
|
||||||
|
} catch(e) { KR.toast(String(e), 'error'); setProgress(idx,0,'',false); }
|
||||||
|
}
|
||||||
|
|
||||||
|
function doReplaceFile(idx, file) {
|
||||||
|
const name = _videoNames[idx];
|
||||||
|
if (!file || !name) return;
|
||||||
|
setProgress(idx, 0, 'Uploading ' + file.name + '…', true);
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('target_name', name);
|
||||||
|
fd.append('file', file);
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('POST', '/admin/api/videos/replace');
|
||||||
|
xhr.upload.onprogress = e => { if (e.lengthComputable) setProgress(idx, Math.round(e.loaded/e.total*100), null, true); };
|
||||||
|
xhr.onload = () => {
|
||||||
|
try {
|
||||||
|
const d = JSON.parse(xhr.responseText);
|
||||||
|
if (d.ok) { KR.toast('Replaced ' + name); setProgress(idx, 100, 'Done!', true); setTimeout(() => { setProgress(idx,0,'',false); loadVideos(); }, 1200); }
|
||||||
|
else { KR.toast(d.error || 'Error', 'error'); setProgress(idx,0,'',false); }
|
||||||
|
} catch(e) { KR.toast('Parse error', 'error'); setProgress(idx,0,'',false); }
|
||||||
|
};
|
||||||
|
xhr.onerror = () => { KR.toast('Network error', 'error'); setProgress(idx,0,'',false); };
|
||||||
|
xhr.send(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setProgress(idx, pct, label, show) {
|
||||||
|
const prog = document.getElementById('rprog-' + idx);
|
||||||
|
const bar = document.getElementById('rprogbar-' + idx);
|
||||||
|
const lbl = document.getElementById('rprog-label-' + idx);
|
||||||
|
if (prog) prog.style.display = show ? '' : 'none';
|
||||||
|
if (bar) bar.style.width = pct + '%';
|
||||||
|
if (lbl && label !== null) lbl.textContent = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupDrop(idx) {
|
||||||
|
const dz = document.getElementById('rdrop-' + idx);
|
||||||
|
if (!dz) return;
|
||||||
|
dz.addEventListener('dragover', e => { e.preventDefault(); dz.classList.add('drag-over'); });
|
||||||
|
dz.addEventListener('dragleave', () => dz.classList.remove('drag-over'));
|
||||||
|
dz.addEventListener('drop', e => { e.preventDefault(); dz.classList.remove('drag-over'); const f = e.dataTransfer.files[0]; if (f) doReplaceFile(idx, f); });
|
||||||
|
}
|
||||||
|
|
||||||
|
loadVideos();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
172
templates/admin/weekly_challenges.html
Normal file
172
templates/admin/weekly_challenges.html
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
{% extends 'admin/custom_base.html' %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<style>
|
||||||
|
.week-grid { display:grid; grid-template-columns:1fr 1fr; gap:1rem; margin-bottom:1.5rem; }
|
||||||
|
@media (max-width:900px) { .week-grid { grid-template-columns:1fr; } }
|
||||||
|
.week-card { background:var(--bg2); border:1px solid var(--border); border-radius:10px; overflow:hidden; transition:border-color .15s; }
|
||||||
|
.week-card:hover { border-color:var(--purple); }
|
||||||
|
.week-card.current { border-color:var(--purple); box-shadow:0 0 0 2px rgba(124,58,237,.18); }
|
||||||
|
.week-card.has-override { border-color:var(--yellow,#f59e0b); }
|
||||||
|
.week-head { display:flex; align-items:flex-start; gap:.75rem; padding:.85rem 1rem; cursor:pointer; user-select:none; }
|
||||||
|
.week-num { font-size:1.5rem; font-weight:800; color:var(--purple-l); min-width:2.2rem; line-height:1; margin-top:.05rem; }
|
||||||
|
.week-info { flex:1; min-width:0; }
|
||||||
|
.week-dates { font-size:.72rem; color:var(--text3); margin-top:.15rem; }
|
||||||
|
.week-challenge-title { font-weight:600; font-size:.88rem; color:var(--text); }
|
||||||
|
.week-challenge-meta { font-size:.75rem; color:var(--text2); margin-top:.15rem; }
|
||||||
|
.week-badges { display:flex; gap:.35rem; flex-wrap:wrap; margin-top:.45rem; }
|
||||||
|
.week-chevron { display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; margin-left:auto; transition:transform .22s; align-self:center; flex-shrink:0; }
|
||||||
|
.week-chevron::before { content:''; width:7px; height:7px; border-right:1.5px solid var(--text3); border-bottom:1.5px solid var(--text3); transform:rotate(45deg); display:block; margin-top:-3px; }
|
||||||
|
.week-card.expanded .week-chevron { transform:rotate(180deg); }
|
||||||
|
.week-form { display:none; border-top:1px solid var(--border); padding:.85rem 1rem 1rem; background:var(--bg3); }
|
||||||
|
.week-card.expanded .week-form { display:block; }
|
||||||
|
.week-form-row { display:flex; flex-wrap:wrap; gap:.5rem; align-items:flex-end; margin-bottom:.6rem; }
|
||||||
|
.week-form-row .form-group { margin:0; flex:1; min-width:80px; }
|
||||||
|
.week-form-row .form-group label { font-size:.72rem; }
|
||||||
|
.week-form-actions { display:flex; gap:.5rem; justify-content:flex-end; margin-top:.75rem; align-items:center; }
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="container-fluid mt-3">
|
||||||
|
<div class="page-header" style="margin-bottom:1.5rem">
|
||||||
|
<h1>Weekly Challenges</h1>
|
||||||
|
<p style="color:var(--text3);margin:0">Schedule challenges for the next 10 weeks. Click a week to expand and override.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% set rarity_names = {0:'Common',10:'Uncommon',20:'Rare',30:'Epic',50:'Legendary'} %}
|
||||||
|
{% set rarity_badge = {0:'badge-gray',10:'badge-green',20:'badge-teal',30:'badge-purple',50:'badge-yellow'} %}
|
||||||
|
|
||||||
|
<div class="week-grid">
|
||||||
|
{% for w in weeks %}
|
||||||
|
<div class="week-card {% if w.is_current %}current{% endif %} {% if w.override %}has-override{% endif %}" id="wc-{{ w.week_number }}">
|
||||||
|
<div class="week-head" onclick="toggleWeek('wc-{{ w.week_number }}')">
|
||||||
|
<div class="week-num">{{ '%02d' % w.week_number }}</div>
|
||||||
|
<div class="week-info">
|
||||||
|
<div class="week-challenge-title">
|
||||||
|
{% if w.override and w.override.custom_title %}{{ w.override.custom_title }}
|
||||||
|
{% elif w.override and w.override.challenge_id %}
|
||||||
|
{{ all_challenges | selectattr('id', 'equalto', w.override.challenge_id) | map(attribute='title') | first | default(w.rotation_challenge.title) }}
|
||||||
|
{% else %}{{ w.rotation_challenge.title }}{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="week-challenge-meta">
|
||||||
|
{% set eff_xp = w.override.custom_reward_xp if w.override and w.override.custom_reward_xp else w.rotation_challenge.reward_xp %}
|
||||||
|
{% set eff_target = w.override.custom_target if w.override and w.override.custom_target else w.rotation_challenge.target %}
|
||||||
|
{{ eff_target }} games • {{ eff_xp }} XP
|
||||||
|
</div>
|
||||||
|
<div class="week-badges">
|
||||||
|
{% if w.is_current %}<span class="badge badge-green">Current</span>{% endif %}
|
||||||
|
{% if w.override %}
|
||||||
|
{% set r = w.override.custom_reward_rarity if w.override.custom_reward_rarity is not none else 0 %}
|
||||||
|
<span class="badge {{ rarity_badge.get(r, 'badge-gray') }}">{{ rarity_names.get(r, r) }}</span>
|
||||||
|
<span class="badge badge-yellow">Override</span>
|
||||||
|
{% else %}
|
||||||
|
{% set r = w.rotation_challenge.reward_rarity %}
|
||||||
|
<span class="badge {{ rarity_badge.get(r, 'badge-gray') }}">{{ rarity_names.get(r, r) }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="week-dates">{{ w.week_start }} → {{ w.week_end }}</div>
|
||||||
|
</div>
|
||||||
|
<span class="week-chevron"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if SCOPE_ADMIN in scopes %}
|
||||||
|
<div class="week-form">
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="week_number" value="{{ w.week_number }}">
|
||||||
|
<input type="hidden" name="action_type" value="save">
|
||||||
|
<div class="week-form-row">
|
||||||
|
<div class="form-group" style="flex:2;min-width:160px">
|
||||||
|
<label>Challenge override</label>
|
||||||
|
<select name="challenge_id">
|
||||||
|
<option value="">— use rotation —</option>
|
||||||
|
{% for ch in all_challenges %}
|
||||||
|
<option value="{{ ch.id }}" {% if w.override and w.override.challenge_id == ch.id %}selected{% endif %}>{{ ch.title }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Target</label>
|
||||||
|
<input type="number" name="custom_target" placeholder="—"
|
||||||
|
value="{{ w.override.custom_target if w.override and w.override.custom_target else '' }}"
|
||||||
|
style="width:70px" min="1" max="99">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>XP</label>
|
||||||
|
<input type="number" name="custom_reward_xp" placeholder="—"
|
||||||
|
value="{{ w.override.custom_reward_xp if w.override and w.override.custom_reward_xp else '' }}"
|
||||||
|
style="width:80px" min="0">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="week-form-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Rarity</label>
|
||||||
|
<select name="custom_reward_rarity" style="width:130px">
|
||||||
|
<option value="0">Common</option>
|
||||||
|
<option value="10" {% if w.override and w.override.custom_reward_rarity == 10 %}selected{% endif %}>Uncommon</option>
|
||||||
|
<option value="20" {% if w.override and w.override.custom_reward_rarity == 20 %}selected{% endif %}>Rare</option>
|
||||||
|
<option value="30" {% if w.override and w.override.custom_reward_rarity == 30 %}selected{% endif %}>Epic</option>
|
||||||
|
<option value="50" {% if w.override and w.override.custom_reward_rarity == 50 %}selected{% endif %}>Legendary</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" style="flex:2;min-width:120px">
|
||||||
|
<label>Custom title</label>
|
||||||
|
<input type="text" name="custom_title" placeholder="Leave blank to use challenge title"
|
||||||
|
value="{{ w.override.custom_title if w.override and w.override.custom_title else '' }}"
|
||||||
|
maxlength="64">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="week-form-actions">
|
||||||
|
{% if w.override %}
|
||||||
|
<button type="submit" class="btn btn-red btn-sm" onclick="this.form.querySelector('[name=action_type]').value='clear'">Clear Override</button>
|
||||||
|
{% endif %}
|
||||||
|
<button type="submit" class="btn btn-primary btn-sm" onclick="this.form.querySelector('[name=action_type]').value='save'">Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="section-head"><h2>Available Challenges</h2></div>
|
||||||
|
<div class="table-wrap">
|
||||||
|
<table>
|
||||||
|
<thead><tr><th>ID</th><th>Title</th><th>Activity</th><th>Target</th><th>Reward XP</th><th>Rarity</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
{% for ch in all_challenges %}
|
||||||
|
<tr>
|
||||||
|
<td style="font-family:monospace;font-size:.78rem;color:var(--text3)">{{ ch.id }}</td>
|
||||||
|
<td style="font-weight:600;font-size:.82rem">{{ ch.title }}</td>
|
||||||
|
<td style="font-family:monospace;font-size:.72rem;color:var(--teal)">{{ ch.activity_guid[:8] }}…</td>
|
||||||
|
<td>{{ ch.target }} games</td>
|
||||||
|
<td style="color:var(--text2)">{{ ch.reward_xp }}</td>
|
||||||
|
<td><span class="badge {{ rarity_badge.get(ch.reward_rarity, 'badge-gray') }}">{{ rarity_names.get(ch.reward_rarity, ch.reward_rarity) }}</span></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% if messages %}
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
{% for cat, msg in messages %}
|
||||||
|
KR.toast({{ msg | tojson }}, '{{ 'success' if cat == 'success' else 'error' }}');
|
||||||
|
{% endfor %}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleWeek(id) {
|
||||||
|
const card = document.getElementById(id);
|
||||||
|
card.classList.toggle('expanded');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user