RPU v2, promo/bank система, админка, оптимизации
— RPU v2: бюджет удачи, потолок (ceiling), комбек после проигрышей, hot/cold анализ, интеграция с promo-фазами — Bank API: mock-банк для карты (депозит/вывод с балансом 1000₽) — Promo-сервис: автогенерация промокодов каждый час, типы (card_to_site, luck_boost, ceiling_boost, free_case, reset_streak) — Promo-фазы: LUCKY/NEUTRAL/UNLUCKY, переключение каждые 1-6ч — Admin: история транзакций (user_history), управление промокодами, управление promo-фазами, API фильтров/коллекций, RPU info — Database: WAL mode, новые поля RPU v2, TransactionLog, карточный баланс, статистики (streaks, ceiling, budget) — Frontend: /deposit, /promo/activate, /withdraw, /card-balance, /online-count, /rpu-info, lifespan вместо startup event — UI: user_history.html, улучшения профиля, кейсов, навигации — Cases: обновление cases.json (1892 строки новых данных) — Achievements: кэш коллекций, оптимизация is_custom проверок — Sounds: дополнительные звуковые эффекты — Upgrade: интеграция с RPU (множители, streaks) — .gitignore: исключены .db, .bak, __pycache__
This commit is contained in:
+266
-99
@@ -53,6 +53,32 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="a-table-card-view">
|
||||
{% for c in cases %}
|
||||
<div class="a-table-card">
|
||||
<div class="tc-row">
|
||||
<span class="tc-label">Название</span>
|
||||
<span class="tc-value"><strong>{{ c.name }}</strong></span>
|
||||
</div>
|
||||
<div class="tc-row">
|
||||
<span class="tc-label">Цена</span>
|
||||
<span class="tc-value">{{ c.price_open }} ₽</span>
|
||||
</div>
|
||||
<div class="tc-row">
|
||||
<span class="tc-label">Тип</span>
|
||||
<span class="tc-value">{{ c.display_name|default('') }}</span>
|
||||
</div>
|
||||
<div class="tc-row">
|
||||
<span class="tc-label">Предметов</span>
|
||||
<span class="tc-value">{{ c.items_count }}</span>
|
||||
</div>
|
||||
<div class="tc-actions">
|
||||
<button class="a-btn a-btn-sm" onclick="openEditCaseModal('{{ c.name }}')">✏️ Редактировать</button>
|
||||
<button class="a-btn a-btn-danger a-btn-sm" onclick="deleteCase('{{ c.name }}')">🗑️</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -60,57 +86,90 @@
|
||||
{% block modals %}
|
||||
<!-- Create/Edit Case Modal -->
|
||||
<div class="a-overlay" id="caseModal">
|
||||
<div class="a-modal" style="max-width:600px">
|
||||
<div class="a-modal a-modal-wide" style="max-height:95vh;display:flex;flex-direction:column">
|
||||
<div class="a-modal-title" id="caseModalTitle">🎲 Создать кейс</div>
|
||||
<input type="hidden" id="editCaseName">
|
||||
<div class="a-row a-gap-sm">
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Название кейса (ID)</label>
|
||||
<input type="text" id="caseNameInput" class="a-input" placeholder="my_case">
|
||||
<div style="padding:0 1.5rem;flex:1;overflow-y:auto">
|
||||
<div class="a-row a-gap-sm">
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Название кейса (ID)</label>
|
||||
<input type="text" id="caseNameInput" class="a-input" placeholder="my_case">
|
||||
</div>
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Отображаемое название</label>
|
||||
<input type="text" id="caseDisplayName" class="a-input" placeholder="Мой кейс">
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Отображаемое название</label>
|
||||
<input type="text" id="caseDisplayName" class="a-input" placeholder="Мой кейс">
|
||||
<div class="a-row a-gap-sm">
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Цена открытия</label>
|
||||
<input type="number" id="casePrice" class="a-input" value="250">
|
||||
</div>
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Ссылка на изображение</label>
|
||||
<input type="text" id="caseImage" class="a-input" placeholder="/static/cases/default.png">
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-mb">
|
||||
<label class="a-label">Описание (необязательно)</label>
|
||||
<input type="text" id="caseDescription" class="a-input" placeholder="Описание кейса...">
|
||||
</div>
|
||||
|
||||
<!-- Item browser section -->
|
||||
<div class="a-card" style="background:rgba(0,0,0,0.2);padding:0.75rem;margin-bottom:1rem">
|
||||
<div class="a-card-header" style="margin-bottom:0.5rem">📋 Предметы кейса <span id="itemCount" style="font-size:0.75rem;color:rgba(255,255,255,0.4)">(0)</span></div>
|
||||
|
||||
<!-- Selected items list -->
|
||||
<div id="caseItemsList" style="max-height:200px;overflow-y:auto;margin-bottom:0.75rem"></div>
|
||||
|
||||
<!-- Search + filters + add controls -->
|
||||
<div class="a-row a-gap-sm" style="margin-bottom:0.5rem">
|
||||
<input type="text" id="caseItemSearch" class="a-input a-input-sm" style="flex:2;min-width:120px" placeholder="🔍 Поиск..." oninput="searchCaseItems()">
|
||||
<select id="rarityFilter" class="a-input a-input-sm" style="flex:1;min-width:90px" onchange="searchCaseItems()">
|
||||
<option value="">Редкость</option>
|
||||
<option value="Consumer Grade">Consumer</option>
|
||||
<option value="Industrial Grade">Industrial</option>
|
||||
<option value="Mil-Spec">Mil-Spec</option>
|
||||
<option value="Restricted">Restricted</option>
|
||||
<option value="Classified">Classified</option>
|
||||
<option value="Covert">Covert</option>
|
||||
<option value="Rare Special Item">Rare Special</option>
|
||||
<option value="Contraband">Contraband</option>
|
||||
</select>
|
||||
<select id="collectionFilter" class="a-input a-input-sm" style="flex:1.2;min-width:100px" onchange="searchCaseItems()">
|
||||
<option value="">Коллекция</option>
|
||||
</select>
|
||||
<select id="sortBy" class="a-input a-input-sm" style="flex:0.7;min-width:80px" onchange="searchCaseItems()">
|
||||
<option value="">Сортировка</option>
|
||||
<option value="price_rub">Цена ↑</option>
|
||||
<option value="price_rub&desc">Цена ↓</option>
|
||||
<option value="name">Имя ↑</option>
|
||||
<option value="rarity">Редкость ↑</option>
|
||||
<option value="rarity&desc">Редкость ↓</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="a-row a-gap-sm" style="margin-bottom:0.5rem">
|
||||
<select id="typeFilter" class="a-input a-input-sm" style="flex:1;min-width:70px" onchange="searchCaseItems()">
|
||||
<option value="">Тип</option>
|
||||
</select>
|
||||
<select id="weaponFilter" class="a-input a-input-sm" style="flex:1;min-width:80px" onchange="searchCaseItems()">
|
||||
<option value="">Оружие</option>
|
||||
</select>
|
||||
<input type="number" id="minPrice" class="a-input a-input-sm" style="flex:0.6;min-width:60px" placeholder="Цена от" oninput="searchCaseItems()" value="0">
|
||||
<input type="number" id="maxPrice" class="a-input a-input-sm" style="flex:0.6;min-width:60px" placeholder="Цена до" oninput="searchCaseItems()" value="0">
|
||||
</div>
|
||||
|
||||
<!-- Search results -->
|
||||
<div id="caseItemResults" style="max-height:220px;overflow-y:auto;border:1px solid rgba(255,255,255,0.06);border-radius:6px;padding:0.25rem"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-row a-gap-sm">
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Цена открытия</label>
|
||||
<input type="number" id="casePrice" class="a-input" value="250">
|
||||
</div>
|
||||
<div class="a-mb" style="flex:1">
|
||||
<label class="a-label">Ссылка на изображение</label>
|
||||
<input type="text" id="caseImage" class="a-input" placeholder="/static/cases/default.png">
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-mb">
|
||||
<label class="a-label">Описание (необязательно)</label>
|
||||
<input type="text" id="caseDescription" class="a-input" placeholder="Описание кейса...">
|
||||
</div>
|
||||
<div class="a-card" style="background:rgba(0,0,0,0.2);padding:0.75rem">
|
||||
<div class="a-card-header" style="margin-bottom:0.5rem">📋 Предметы кейса</div>
|
||||
<div id="caseItemsList"></div>
|
||||
<div class="a-flex a-mt" style="flex-wrap:wrap">
|
||||
<input type="text" id="caseItemSearch" class="a-input a-input-sm" style="flex:1;min-width:120px" placeholder="Поиск предмета..." oninput="searchCaseItems()">
|
||||
<button class="a-btn a-btn-sm" onclick="openAllItemsModal()">📦 Все предметы</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="a-modal-actions">
|
||||
<div class="a-modal-actions" style="padding:0.75rem 1.5rem;border-top:1px solid rgba(255,255,255,0.06)">
|
||||
<button class="a-btn" onclick="closeModal('caseModal')">Отмена</button>
|
||||
<button class="a-btn a-btn-primary" id="saveCaseBtn" onclick="saveCase()">💾 Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- All items browser modal -->
|
||||
<div class="a-overlay" id="allItemsModal">
|
||||
<div class="a-modal" style="max-width:700px;max-height:80vh;display:flex;flex-direction:column">
|
||||
<div class="a-modal-title">📦 Все предметы</div>
|
||||
<input type="text" id="allItemsSearch" class="a-input a-input-sm a-mb" placeholder="Поиск..." oninput="searchAllItems()">
|
||||
<div id="allItemsGrid" style="flex:1;overflow-y:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:0.5rem"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add case to section modal -->
|
||||
<div class="a-overlay" id="addCaseModal">
|
||||
<div class="a-modal" style="max-width:400px">
|
||||
@@ -145,13 +204,26 @@
|
||||
|
||||
{% block extra_styles %}
|
||||
<style>
|
||||
.ci-item { display:flex; align-items:center; gap:0.5rem; padding:0.35rem 0; border-bottom:1px solid rgba(255,255,255,0.03); font-size:0.78rem; }
|
||||
.ci-item img { width:32px; height:24px; object-fit:contain; }
|
||||
.ci-item .ci-info { flex:1; }
|
||||
.ci-item {
|
||||
display:flex; align-items:center; gap:0.5rem;
|
||||
padding:0.3rem 0.5rem; border-bottom:1px solid rgba(255,255,255,0.04);
|
||||
font-size:0.78rem; transition:background 0.15s;
|
||||
}
|
||||
.ci-item:hover { background:rgba(255,255,255,0.03); }
|
||||
.ci-item img { width:36px; height:28px; object-fit:contain; border-radius:3px; }
|
||||
.ci-item .ci-info { flex:1; line-height:1.3; }
|
||||
.ci-item .ci-rarity { font-size:0.65rem; color:rgba(255,255,255,0.35); }
|
||||
.all-item-card { background:rgba(0,0,0,0.15); border-radius:6px; padding:0.35rem; cursor:pointer; text-align:center; font-size:0.7rem; transition:all 0.15s; border:1px solid transparent; }
|
||||
.all-item-card:hover { border-color:rgba(245,158,11,0.3); background:rgba(245,158,11,0.05); }
|
||||
.all-item-card img { width:100%; height:40px; object-fit:contain; }
|
||||
.ci-result {
|
||||
display:flex; align-items:center; gap:0.5rem;
|
||||
padding:0.3rem 0.5rem; cursor:pointer;
|
||||
border-bottom:1px solid rgba(255,255,255,0.03);
|
||||
font-size:0.78rem; transition:all 0.12s; border-radius:3px;
|
||||
}
|
||||
.ci-result:hover { background:rgba(245,158,11,0.08); }
|
||||
.ci-result img { width:36px; height:28px; object-fit:contain; border-radius:3px; }
|
||||
.ci-result .ci-info { flex:1; line-height:1.3; }
|
||||
.ci-result .ci-meta { font-size:0.65rem; color:rgba(255,255,255,0.35); }
|
||||
.ci-result .ci-add { font-size:0.7rem; color:#f59e0b; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
@@ -159,17 +231,42 @@
|
||||
<script>
|
||||
let currentCaseItems = [];
|
||||
let editingCaseName = null;
|
||||
let searchDebounce = null;
|
||||
|
||||
// ─── Modals ──────────────────────────────────────────────────────────────────
|
||||
function closeModal(id) { document.getElementById(id).classList.remove('open'); }
|
||||
function openModal(id) { document.getElementById(id).classList.add('open'); }
|
||||
|
||||
// ─── Load page data ──────────────────────────────────────────────────────────
|
||||
let allCasesList = [];
|
||||
// ─── Load filter options ─────────────────────────────────────────────────────
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
const r = await fetch('/admin/api/cases/list');
|
||||
const d = await r.json();
|
||||
allCasesList = d.cases || [];
|
||||
allCasesList = await r.json();
|
||||
|
||||
// Load collections
|
||||
const cr = await fetch('/admin/api/collections');
|
||||
const cd = await cr.json();
|
||||
const colSel = document.getElementById('collectionFilter');
|
||||
(cd.collections || []).forEach(c => {
|
||||
const o = document.createElement('option');
|
||||
o.value = c; o.textContent = c;
|
||||
colSel.appendChild(o);
|
||||
});
|
||||
|
||||
// Load weapons + types
|
||||
const fr = await fetch('/admin/api/items/filters');
|
||||
const fd = await fr.json();
|
||||
const typeSel = document.getElementById('typeFilter');
|
||||
(fd.types || []).forEach(t => {
|
||||
const o = document.createElement('option');
|
||||
o.value = t; o.textContent = t;
|
||||
typeSel.appendChild(o);
|
||||
});
|
||||
const weaponSel = document.getElementById('weaponFilter');
|
||||
(fd.weapons || []).forEach(w => {
|
||||
const o = document.createElement('option');
|
||||
o.value = w; o.textContent = w;
|
||||
weaponSel.appendChild(o);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Create / Edit Case ──────────────────────────────────────────────────────
|
||||
@@ -185,6 +282,8 @@ function openCreateCaseModal() {
|
||||
document.getElementById('caseDescription').value = '';
|
||||
currentCaseItems = [];
|
||||
renderCaseItems();
|
||||
document.getElementById('caseItemSearch').value = '';
|
||||
document.getElementById('caseItemResults').innerHTML = '';
|
||||
openModal('caseModal');
|
||||
}
|
||||
|
||||
@@ -200,21 +299,34 @@ function openEditCaseModal(caseName) {
|
||||
document.getElementById('casePrice').value = c.price_open || 250;
|
||||
document.getElementById('caseImage').value = c.image_url || '';
|
||||
document.getElementById('caseDescription').value = c.description || '';
|
||||
currentCaseItems = (c.items || []).filter(i => typeof i === 'object');
|
||||
currentCaseItems = (c.items || []).filter(i => typeof i === 'object').map(i => {
|
||||
if (typeof i.id === 'number' && !i.market_hash_name) {
|
||||
return { id: i.id, name: i.name || 'Item #' + i.id, market_hash_name: i.name || '' };
|
||||
}
|
||||
return i;
|
||||
});
|
||||
renderCaseItems();
|
||||
document.getElementById('caseItemSearch').value = '';
|
||||
document.getElementById('caseItemResults').innerHTML = '';
|
||||
openModal('caseModal');
|
||||
}
|
||||
|
||||
function renderCaseItems() {
|
||||
const div = document.getElementById('caseItemsList');
|
||||
const count = currentCaseItems.length;
|
||||
document.getElementById('itemCount').textContent = `(${count})`;
|
||||
if (count === 0) {
|
||||
div.innerHTML = '<div style="font-size:0.75rem;color:rgba(255,255,255,0.3);padding:0.5rem 0">Нет предметов — добавьте через поиск выше</div>';
|
||||
return;
|
||||
}
|
||||
div.innerHTML = currentCaseItems.map((item, i) => `
|
||||
<div class="ci-item">
|
||||
<div class="ci-item" onclick="removeCaseItem(${i})" style="cursor:pointer">
|
||||
<img src="${item.image_url || '/static/placeholder.png'}" onerror="this.src='/static/placeholder.png'">
|
||||
<div class="ci-info">
|
||||
<div>${item.market_hash_name || item.name || '???'}</div>
|
||||
<div class="ci-rarity">${item.rarity || ''} • ${item.weapon || ''}</div>
|
||||
<div class="ci-rarity">${item.rarity || ''}${item.collection ? ' • ' + item.collection : ''}</div>
|
||||
</div>
|
||||
<button class="a-btn a-btn-danger a-btn-sm" onclick="removeCaseItem(${i})">✕</button>
|
||||
<span style="font-size:0.65rem;color:#ef4444;opacity:0.6">✕</span>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
@@ -225,31 +337,105 @@ function removeCaseItem(idx) {
|
||||
}
|
||||
|
||||
function addCaseItem(item) {
|
||||
if (currentCaseItems.some(i => (i.market_hash_name || i.name) === (item.market_hash_name || item.name))) return;
|
||||
const key = (item.market_hash_name || item.name || '');
|
||||
if (currentCaseItems.some(i => (i.market_hash_name || i.name) === key)) return;
|
||||
currentCaseItems.push(item);
|
||||
renderCaseItems();
|
||||
}
|
||||
|
||||
function addAllFromCollection() {
|
||||
const sel = document.getElementById('collectionFilter');
|
||||
const coll = sel.value;
|
||||
if (!coll) { Notify.error('Выберите коллекцию'); return; }
|
||||
const rarity = document.getElementById('rarityFilter').value;
|
||||
const typeF = document.getElementById('typeFilter').value;
|
||||
const weaponF = document.getElementById('weaponFilter').value;
|
||||
let url = `/admin/api/items/by-collection?collection=${encodeURIComponent(coll)}`;
|
||||
if (rarity) url += `&rarity_filter=${encodeURIComponent(rarity)}`;
|
||||
if (typeF) url += `&type_filter=${encodeURIComponent(typeF)}`;
|
||||
if (weaponF) url += `&weapon_filter=${encodeURIComponent(weaponF)}`;
|
||||
fetch(url)
|
||||
.then(r => r.json())
|
||||
.then(items => {
|
||||
let added = 0;
|
||||
let skipped = 0;
|
||||
const alreadyIds = new Set(currentCaseItems.map(i => i.id));
|
||||
items.forEach(item => {
|
||||
if (alreadyIds.has(item.id)) {
|
||||
skipped++;
|
||||
return;
|
||||
}
|
||||
const key = (item.name || '');
|
||||
if (!currentCaseItems.some(i => (i.market_hash_name || i.name) === key)) {
|
||||
currentCaseItems.push(item);
|
||||
added++;
|
||||
}
|
||||
});
|
||||
renderCaseItems();
|
||||
let msg = `Добавлено ${added} предметов из "${coll}"`;
|
||||
if (skipped) msg += ` (${skipped} уже были в кейсе)`;
|
||||
Notify.success(msg);
|
||||
});
|
||||
}
|
||||
|
||||
async function searchCaseItems() {
|
||||
const q = document.getElementById('caseItemSearch').value;
|
||||
if (q.length < 2) return;
|
||||
const r = await fetch(`/admin/api/items/search?q=${encodeURIComponent(q)}`);
|
||||
const items = await r.json();
|
||||
// show as dropdown
|
||||
let html = '<div style="margin-top:0.5rem;max-height:200px;overflow-y:auto">';
|
||||
items.forEach(item => {
|
||||
html += `<div class="ci-item" style="cursor:pointer" onclick="addCaseItem(${JSON.stringify(item).replace(/"/g,'"')})">
|
||||
<img src="${item.image_url || '/static/placeholder.png'}" onerror="this.src='/static/placeholder.png'">
|
||||
<div class="ci-info"><div>${item.name}</div><div class="ci-rarity">${item.rarity} • ${item.price_rub||0} ₽</div></div>
|
||||
</div>`;
|
||||
});
|
||||
html += '</div>';
|
||||
const existing = document.getElementById('caseItemSearchResults');
|
||||
if (!existing) {
|
||||
const d = document.createElement('div'); d.id = 'caseItemSearchResults';
|
||||
document.getElementById('caseItemSearch').parentNode.appendChild(d);
|
||||
}
|
||||
document.getElementById('caseItemSearchResults').innerHTML = html;
|
||||
const rarity = document.getElementById('rarityFilter').value;
|
||||
const collection = document.getElementById('collectionFilter').value;
|
||||
const typeF = document.getElementById('typeFilter').value;
|
||||
const weaponF = document.getElementById('weaponFilter').value;
|
||||
const minP = document.getElementById('minPrice').value;
|
||||
const maxP = document.getElementById('maxPrice').value;
|
||||
const sortV = document.getElementById('sortBy').value;
|
||||
clearTimeout(searchDebounce);
|
||||
searchDebounce = setTimeout(async () => {
|
||||
const params = new URLSearchParams();
|
||||
if (q.length >= 2) params.set('q', q);
|
||||
if (rarity) params.set('rarity_filter', rarity);
|
||||
if (collection) params.set('collection_filter', collection);
|
||||
if (typeF) params.set('type_filter', typeF);
|
||||
if (weaponF) params.set('weapon_filter', weaponF);
|
||||
if (minP > 0) params.set('min_price', minP);
|
||||
if (maxP > 0) params.set('max_price', maxP);
|
||||
if (sortV) {
|
||||
const [field, order] = sortV.split('&');
|
||||
params.set('sort_by', field);
|
||||
if (order) params.set('sort_order', 'desc');
|
||||
}
|
||||
params.set('limit', '100');
|
||||
const r = await fetch(`/admin/api/items/search?${params.toString()}`);
|
||||
const items = await r.json();
|
||||
const div = document.getElementById('caseItemResults');
|
||||
if (items.length === 0) {
|
||||
div.innerHTML = '<div style="font-size:0.75rem;color:rgba(255,255,255,0.3);padding:0.5rem">Ничего не найдено</div>';
|
||||
return;
|
||||
}
|
||||
let html = '';
|
||||
if (collection) {
|
||||
html += `<div style="padding:0.3rem 0.5rem;font-size:0.7rem;color:rgba(255,255,255,0.4);display:flex;justify-content:space-between">
|
||||
<span>Найдено: ${items.length} предметов</span>
|
||||
<span onclick="addAllFromCollection()" style="cursor:pointer;color:#f59e0b">➕ Добавить все из коллекции</span>
|
||||
</div>`;
|
||||
}
|
||||
const alreadyIds = new Set(currentCaseItems.map(i => i.id));
|
||||
html += items.filter(item => !alreadyIds.has(item.id)).map(item => {
|
||||
const priceStr = item.price_rub > 0 ? item.price_rub.toLocaleString('ru') + '₽' : '';
|
||||
return `
|
||||
<div class="ci-result" onclick="addCaseItem(${JSON.stringify(item).replace(/"/g,'"')})">
|
||||
<img src="${item.image_url || '/static/placeholder.png'}" onerror="this.src='/static/placeholder.png'">
|
||||
<div class="ci-info">
|
||||
<div>${item.name}</div>
|
||||
<div class="ci-meta">${item.rarity}${item.weapon ? ' • ' + item.weapon : ''}${priceStr ? ' • ' + priceStr : ''}</div>
|
||||
</div>
|
||||
<div class="ci-add">+</div>
|
||||
</div>`;
|
||||
}).join('');
|
||||
const hidden = items.filter(item => alreadyIds.has(item.id)).length;
|
||||
if (hidden > 0) {
|
||||
html += `<div style="font-size:0.65rem;color:rgba(255,255,255,0.25);padding:0.3rem 0.5rem">${hidden} предмет(ов) уже в кейсе</div>`;
|
||||
}
|
||||
div.innerHTML = html;
|
||||
}, q.length >= 2 ? 200 : 300);
|
||||
}
|
||||
|
||||
async function saveCase() {
|
||||
@@ -263,11 +449,15 @@ async function saveCase() {
|
||||
fd.append('description', document.getElementById('caseDescription').value);
|
||||
fd.append('items_json', JSON.stringify(currentCaseItems));
|
||||
|
||||
const isEdit = editingCaseName !== null && editingCaseName !== name;
|
||||
const isEdit = editingCaseName !== null;
|
||||
const url = isEdit
|
||||
? `/admin/api/cases/update/${encodeURIComponent(editingCaseName)}`
|
||||
: '/admin/api/cases/create';
|
||||
|
||||
|
||||
if (isEdit && editingCaseName !== name) {
|
||||
fd.append('new_name', name);
|
||||
}
|
||||
|
||||
const r = await fetch(url, { method:'POST', body:fd });
|
||||
const d = await r.json();
|
||||
if (d.success) { window.location.reload(); }
|
||||
@@ -285,29 +475,6 @@ async function deleteCase(name) {
|
||||
});
|
||||
}
|
||||
|
||||
// ─── All Items Browser ───────────────────────────────────────────────────────
|
||||
async function openAllItemsModal() {
|
||||
openModal('allItemsModal');
|
||||
document.getElementById('allItemsSearch').value = '';
|
||||
await searchAllItems();
|
||||
}
|
||||
async function searchAllItems() {
|
||||
const q = document.getElementById('allItemsSearch').value;
|
||||
const r = await fetch(`/admin/api/items/search?q=${encodeURIComponent(q)}&limit=200`);
|
||||
const items = await r.json();
|
||||
document.getElementById('allItemsGrid').innerHTML = items.map(item => `
|
||||
<div class="all-item-card" onclick="addCaseItemFromAll(${JSON.stringify(item).replace(/"/g,'"')})">
|
||||
<img src="${item.image_url || '/static/placeholder.png'}" onerror="this.src='/static/placeholder.png'">
|
||||
<div style="margin-top:0.2rem;line-height:1.15">${item.name}</div>
|
||||
<div style="font-size:0.6rem;color:rgba(255,255,255,0.35)">${item.rarity}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
function addCaseItemFromAll(item) {
|
||||
addCaseItem(item);
|
||||
closeModal('allItemsModal');
|
||||
}
|
||||
|
||||
// ─── Mainpage Sections ───────────────────────────────────────────────────────
|
||||
function openAddSectionModal() {
|
||||
document.getElementById('newSectionName').value = '';
|
||||
@@ -336,7 +503,7 @@ async function deleteSection(tab) {
|
||||
function openAddCaseModal(tab) {
|
||||
document.getElementById('addCaseSectionName').textContent = tab;
|
||||
const sel = document.getElementById('addCaseSelect');
|
||||
sel.innerHTML = allCasesList.map(c => `<option value="${c}">${c}</option>`).join('');
|
||||
sel.innerHTML = allCasesList.map(c => `<option value="${c.name}">${c.display_name || c.name}</option>`).join('');
|
||||
sel.dataset.tab = tab;
|
||||
openModal('addCaseModal');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user