WIP: Inventory grid redesign (unfinished - do not use)
This commit is contained in:
1 parent
f8e08608e2
commit
3453a1ebde
7 files changed
+805
-28
No files matched your search
@@ -29,6 +29,11 @@ If you're testing this project, grab builds from nightly for the latest features
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
### ⚠️ Experimental Features (Use at Your Own Risk)
|
||||||
|
- **Inventory Grid View** — New visual inventory display with grid slots, equipped items, durability bars, ammo counts, and click-to-edit. **This feature is very unfinished and has known issues.** Do not use for critical inventory management. Do not report issues with this feature until it is marked stable.
|
||||||
|
|
||||||
|
### Stable Features
|
||||||
|
|
||||||
- **Map Features**: Interactive maps with real-world coordinate calibration for Hagga Basin and The Deep Desert. Default view centers on Hagga Basin at 15% zoom. Zoom range: 15%–100%.
|
- **Map Features**: Interactive maps with real-world coordinate calibration for Hagga Basin and The Deep Desert. Default view centers on Hagga Basin at 15% zoom. Zoom range: 15%–100%.
|
||||||
- **Player Management**: View, search, and filter players. Track online status, factions, guilds, and locations.
|
- **Player Management**: View, search, and filter players. Track online status, factions, guilds, and locations.
|
||||||
- **Chat Logs**: Parsed from text-router pod logs with channel filtering and auto-refresh.
|
- **Chat Logs**: Parsed from text-router pod logs with channel filtering and auto-refresh.
|
||||||
|
|||||||
+27
-2
@@ -42,12 +42,21 @@ def register_routes(app, services, settings):
|
|||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_globals():
|
def inject_globals():
|
||||||
conn_ok = db.check_health()
|
conn_ok = db.check_health()
|
||||||
|
from app.utils.constants import (
|
||||||
|
INVENTORY_HIDDEN_TYPES, INVENTORY_UNKNOWN_TYPES, INVENTORY_PRIMARY_TYPES,
|
||||||
|
EQUIPPED_SLOT_LABELS, QUALITY_TIERS,
|
||||||
|
)
|
||||||
return dict(
|
return dict(
|
||||||
nav_pages=NAV_PAGES,
|
nav_pages=NAV_PAGES,
|
||||||
current_path=request.path if request else '/',
|
current_path=request.path if request else '/',
|
||||||
fmt_role=fmt_role,
|
fmt_role=fmt_role,
|
||||||
conn_ok=conn_ok,
|
conn_ok=conn_ok,
|
||||||
current_user=current_user,
|
current_user=current_user,
|
||||||
|
inv_hidden_types=INVENTORY_HIDDEN_TYPES,
|
||||||
|
inv_unknown_types=INVENTORY_UNKNOWN_TYPES,
|
||||||
|
inv_primary_types=INVENTORY_PRIMARY_TYPES,
|
||||||
|
equipped_slot_labels=EQUIPPED_SLOT_LABELS,
|
||||||
|
quality_tiers=QUALITY_TIERS,
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.template_filter('inv_label')
|
@app.template_filter('inv_label')
|
||||||
@@ -97,6 +106,12 @@ def register_routes(app, services, settings):
|
|||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
return str(val)
|
return str(val)
|
||||||
|
|
||||||
|
@app.template_filter('escapejs')
|
||||||
|
def escapejs_filter(s):
|
||||||
|
if not s:
|
||||||
|
return ''
|
||||||
|
return s.replace('\\', '\\\\').replace("'", "\\'").replace('"', '\\"').replace('\n', '\\n').replace('\r', '\\r')
|
||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
@app.route('/health')
|
@app.route('/health')
|
||||||
def health_check():
|
def health_check():
|
||||||
@@ -192,19 +207,29 @@ def register_routes(app, services, settings):
|
|||||||
|
|
||||||
is_online = player_svc.is_online(player_controller_id) if player_controller_id else False
|
is_online = player_svc.is_online(player_controller_id) if player_controller_id else False
|
||||||
|
|
||||||
|
from app.utils.constants import INVENTORY_HIDDEN_TYPES, INVENTORY_UNKNOWN_TYPES, INVENTORY_PRIMARY_TYPES
|
||||||
|
primary_inventories = [inv for inv in inventories if inv['inventory_type'] in INVENTORY_PRIMARY_TYPES and inv['inventory_type'] not in INVENTORY_HIDDEN_TYPES]
|
||||||
|
unknown_inventories = [inv for inv in inventories if inv['inventory_type'] in INVENTORY_UNKNOWN_TYPES]
|
||||||
|
other_inventories = [inv for inv in inventories if inv['inventory_type'] not in INVENTORY_PRIMARY_TYPES and inv['inventory_type'] not in INVENTORY_UNKNOWN_TYPES and inv['inventory_type'] not in INVENTORY_HIDDEN_TYPES]
|
||||||
|
|
||||||
static_data = get_static_data()
|
static_data = get_static_data()
|
||||||
|
|
||||||
return render_template('player_detail.html',
|
return render_template('player_detail.html',
|
||||||
player=player, guild=guild, vehicles=player_vehicles,
|
player=player, guild=guild, vehicles=player_vehicles,
|
||||||
buildings=buildings_result, currency=currency,
|
buildings=buildings_result, currency=currency,
|
||||||
inventories=inventories, landclaims=landclaims,
|
inventories=inventories, primary_inventories=primary_inventories,
|
||||||
|
unknown_inventories=unknown_inventories, other_inventories=other_inventories,
|
||||||
|
landclaims=landclaims,
|
||||||
specialization=specialization, tech_knowledge=tech_knowledge,
|
specialization=specialization, tech_knowledge=tech_knowledge,
|
||||||
purchased_keystones=purchased_keystones, all_keystones=static_data['keystones'],
|
purchased_keystones=purchased_keystones, all_keystones=static_data['keystones'],
|
||||||
faction_reputation=faction_reputation, landsraad_info=landsraad_info,
|
faction_reputation=faction_reputation, landsraad_info=landsraad_info,
|
||||||
vitals=vitals, is_online=is_online)
|
vitals=vitals, is_online=is_online)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Error in player_detail route")
|
logger.exception("Error in player_detail route")
|
||||||
return render_template('player_detail.html', db_error=f"{type(e).__name__}: {e}")
|
return render_template('player_detail.html',
|
||||||
|
player=None, inventories=[], primary_inventories=[],
|
||||||
|
unknown_inventories=[], other_inventories=[],
|
||||||
|
db_error=f"{type(e).__name__}: {e}")
|
||||||
|
|
||||||
# Vehicles
|
# Vehicles
|
||||||
@app.route('/vehicles')
|
@app.route('/vehicles')
|
||||||
|
|||||||
+18
-1
@@ -578,7 +578,7 @@ class AdminService:
|
|||||||
def edit_item(self, item_id, field, value):
|
def edit_item(self, item_id, field, value):
|
||||||
if item_id is None or field is None or value is None:
|
if item_id is None or field is None or value is None:
|
||||||
return False, "Missing parameters"
|
return False, "Missing parameters"
|
||||||
allowed_fields = ('stack_size', 'quality_level', 'is_new')
|
allowed_fields = ('stack_size', 'quality_level', 'is_new', 'durability', 'max_durability', 'ammo')
|
||||||
if field not in allowed_fields:
|
if field not in allowed_fields:
|
||||||
return False, f"Invalid field. Allowed: {', '.join(allowed_fields)}"
|
return False, f"Invalid field. Allowed: {', '.join(allowed_fields)}"
|
||||||
|
|
||||||
@@ -593,6 +593,23 @@ class AdminService:
|
|||||||
"UPDATE dune.items SET is_new = %s WHERE id = %s RETURNING id, stack_size, quality_level, is_new",
|
"UPDATE dune.items SET is_new = %s WHERE id = %s RETURNING id, stack_size, quality_level, is_new",
|
||||||
[bool(value), item_id]
|
[bool(value), item_id]
|
||||||
)
|
)
|
||||||
|
elif field in ('durability', 'max_durability', 'ammo'):
|
||||||
|
stats_path = {
|
||||||
|
'durability': '{FItemStackAndDurabilityStats,CurrentDurability}',
|
||||||
|
'max_durability': '{FItemStackAndDurabilityStats,DecayedMaxDurability}',
|
||||||
|
'ammo': '{FWeaponItemStats,CurrentAmmo}',
|
||||||
|
}[field]
|
||||||
|
cur.execute(
|
||||||
|
"UPDATE dune.items SET stats = jsonb_set(stats, %s, %s::jsonb, true) WHERE id = %s RETURNING id",
|
||||||
|
[stats_path.split(','), str(value), item_id]
|
||||||
|
)
|
||||||
|
row = cur.fetchone()
|
||||||
|
if not row:
|
||||||
|
conn.rollback()
|
||||||
|
return False, "Item not found"
|
||||||
|
conn.commit()
|
||||||
|
audit_logger.info(f"EDIT_ITEM: item_id={item_id} field={field} value={value}")
|
||||||
|
return True, {"item_id": item_id, "field": field, "value": value}
|
||||||
else:
|
else:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"UPDATE dune.items SET {} = %s WHERE id = %s RETURNING id, stack_size, quality_level, is_new".format(field),
|
"UPDATE dune.items SET {} = %s WHERE id = %s RETURNING id, stack_size, quality_level, is_new".format(field),
|
||||||
|
|||||||
+49
-3
@@ -274,7 +274,7 @@ class PlayerService:
|
|||||||
def get_player_inventories(self, player_id):
|
def get_player_inventories(self, player_id):
|
||||||
try:
|
try:
|
||||||
inventories = self.db.query("""
|
inventories = self.db.query("""
|
||||||
SELECT i.id, i.actor_id, i.inventory_type,
|
SELECT i.id, i.actor_id, i.inventory_type, i.max_item_count, i.max_item_volume,
|
||||||
COALESCE(json_agg(
|
COALESCE(json_agg(
|
||||||
json_build_object(
|
json_build_object(
|
||||||
'id', items.id,
|
'id', items.id,
|
||||||
@@ -282,20 +282,66 @@ class PlayerService:
|
|||||||
'stack_size', items.stack_size,
|
'stack_size', items.stack_size,
|
||||||
'quality_level', items.quality_level,
|
'quality_level', items.quality_level,
|
||||||
'is_new', items.is_new,
|
'is_new', items.is_new,
|
||||||
|
'position_index', items.position_index,
|
||||||
'stats_text', items.stats::text
|
'stats_text', items.stats::text
|
||||||
) ORDER BY items.position_index
|
) ORDER BY items.position_index
|
||||||
) FILTER (WHERE items.id IS NOT NULL), '[]') as item_list
|
) FILTER (WHERE items.id IS NOT NULL), '[]') as item_list
|
||||||
FROM dune.inventories i
|
FROM dune.inventories i
|
||||||
LEFT JOIN dune.items ON i.id = items.inventory_id
|
LEFT JOIN dune.items ON i.id = items.inventory_id
|
||||||
WHERE i.actor_id = %s
|
WHERE i.actor_id = %s
|
||||||
GROUP BY i.id, i.actor_id, i.inventory_type
|
GROUP BY i.id, i.actor_id, i.inventory_type, i.max_item_count, i.max_item_volume
|
||||||
ORDER BY i.inventory_type
|
ORDER BY i.inventory_type
|
||||||
""", [player_id]) or []
|
""", [player_id]) or []
|
||||||
for inv in inventories:
|
for inv in inventories:
|
||||||
inv['item_list'] = inv.get('item_list', []) or []
|
if not isinstance(inv, dict):
|
||||||
|
logger.warning(f"Inventory row is not a dict: {type(inv)}")
|
||||||
|
continue
|
||||||
|
raw_items = inv.get('item_list', []) or []
|
||||||
|
if isinstance(raw_items, str):
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
raw_items = json.loads(raw_items)
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
raw_items = []
|
||||||
|
parsed_items = []
|
||||||
|
for item in raw_items:
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
logger.warning(f"Item is not a dict: {type(item)}, value: {repr(item)[:100]}")
|
||||||
|
continue
|
||||||
|
new_item = dict(item)
|
||||||
|
stats_text = new_item.pop('stats_text', None)
|
||||||
|
stats = {}
|
||||||
|
if stats_text:
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
stats = json.loads(stats_text)
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
stats = {}
|
||||||
|
new_item['stats'] = stats
|
||||||
|
dur_stats = stats.get('FItemStackAndDurabilityStats')
|
||||||
|
if isinstance(dur_stats, dict):
|
||||||
|
new_item['durability'] = dur_stats.get('CurrentDurability')
|
||||||
|
new_item['max_durability'] = dur_stats.get('DecayedMaxDurability')
|
||||||
|
elif isinstance(dur_stats, list) and dur_stats:
|
||||||
|
new_item['durability'] = dur_stats[0].get('CurrentDurability') if isinstance(dur_stats[0], dict) else None
|
||||||
|
new_item['max_durability'] = dur_stats[0].get('DecayedMaxDurability') if isinstance(dur_stats[0], dict) else None
|
||||||
|
else:
|
||||||
|
new_item['durability'] = None
|
||||||
|
new_item['max_durability'] = None
|
||||||
|
weapon_stats = stats.get('FWeaponItemStats')
|
||||||
|
if isinstance(weapon_stats, dict):
|
||||||
|
new_item['ammo'] = weapon_stats.get('CurrentAmmo')
|
||||||
|
elif isinstance(weapon_stats, list) and weapon_stats:
|
||||||
|
new_item['ammo'] = weapon_stats[0].get('CurrentAmmo') if isinstance(weapon_stats[0], dict) else None
|
||||||
|
else:
|
||||||
|
new_item['ammo'] = None
|
||||||
|
parsed_items.append(new_item)
|
||||||
|
inv['item_list'] = parsed_items
|
||||||
return inventories
|
return inventories
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to get inventories: {e}")
|
logger.warning(f"Failed to get inventories: {e}")
|
||||||
|
import traceback
|
||||||
|
logger.warning(traceback.format_exc())
|
||||||
inventories = self.db.query(
|
inventories = self.db.query(
|
||||||
"SELECT i.* FROM dune.inventories i WHERE i.actor_id = %s ORDER BY i.inventory_type",
|
"SELECT i.* FROM dune.inventories i WHERE i.actor_id = %s ORDER BY i.inventory_type",
|
||||||
[player_id]
|
[player_id]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"""Shared data constants and helpers"""
|
"""Shared data constants and helpers"""
|
||||||
|
import json
|
||||||
|
|
||||||
INVENTORY_TYPE_LABELS = {
|
INVENTORY_TYPE_LABELS = {
|
||||||
0: 'Main Inventory',
|
0: 'Main Inventory',
|
||||||
@@ -17,6 +18,48 @@ INVENTORY_TYPE_LABELS = {
|
|||||||
33: 'Augment Slots',
|
33: 'Augment Slots',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Inventory types to hide from display
|
||||||
|
INVENTORY_HIDDEN_TYPES = {14, 27}
|
||||||
|
|
||||||
|
# Inventory types to show in the collapsible "Unknown" section
|
||||||
|
INVENTORY_UNKNOWN_TYPES = {12, 20, 25, 29, 30, 31, 32, 33}
|
||||||
|
|
||||||
|
# Primary inventory types shown as main sections
|
||||||
|
INVENTORY_PRIMARY_TYPES = {0, 1, 5, 15}
|
||||||
|
|
||||||
|
# Equipped item slot labels (by position_index 0-9)
|
||||||
|
EQUIPPED_SLOT_LABELS = {
|
||||||
|
0: 'Head',
|
||||||
|
1: 'Chest',
|
||||||
|
2: 'Legs',
|
||||||
|
3: 'Gloves',
|
||||||
|
4: 'Feet',
|
||||||
|
5: 'Unknown Spare Slot',
|
||||||
|
6: 'Portable Light',
|
||||||
|
7: 'Suspensor Belt',
|
||||||
|
8: 'Power Pack',
|
||||||
|
9: 'Shield',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Quality tier colors
|
||||||
|
QUALITY_TIERS = {
|
||||||
|
0: {'label': 'Common', 'color': '#9a8a7a'},
|
||||||
|
1: {'label': 'Uncommon', 'color': '#27ae60'},
|
||||||
|
2: {'label': 'Rare', 'color': '#3498db'},
|
||||||
|
3: {'label': 'Epic', 'color': '#9b59b6'},
|
||||||
|
4: {'label': 'Legendary', 'color': '#f39c12'},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def parse_stats(stats_text):
|
||||||
|
"""Parse item stats JSONB text into a dict."""
|
||||||
|
if not stats_text:
|
||||||
|
return {}
|
||||||
|
try:
|
||||||
|
return json.loads(stats_text)
|
||||||
|
except (json.JSONDecodeError, TypeError):
|
||||||
|
return {}
|
||||||
|
|
||||||
CURRENCY_ID_LABELS = {
|
CURRENCY_ID_LABELS = {
|
||||||
0: 'Solari Credits',
|
0: 'Solari Credits',
|
||||||
1: 'House Script',
|
1: 'House Script',
|
||||||
|
|||||||
@@ -407,6 +407,359 @@ td a:hover { text-decoration: underline; }
|
|||||||
|
|
||||||
.inv-type:first-child { margin-top: 0; }
|
.inv-type:first-child { margin-top: 0; }
|
||||||
|
|
||||||
|
.inv-section-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin: 16px 0 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-section-header .inv-meta {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main Inventory Grid */
|
||||||
|
.inv-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
gap: 6px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-grid-slot {
|
||||||
|
aspect-ratio: 1;
|
||||||
|
border: 2px dashed var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
transition: all 0.15s;
|
||||||
|
background: var(--card-bg);
|
||||||
|
min-height: 80px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-grid-slot:hover {
|
||||||
|
border-color: var(--primary);
|
||||||
|
background: var(--hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-grid-slot.has-item {
|
||||||
|
border-style: solid;
|
||||||
|
border-color: var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-grid-slot.has-item:hover {
|
||||||
|
border-color: var(--primary);
|
||||||
|
box-shadow: 0 0 0 2px rgba(201,162,78,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-icon {
|
||||||
|
font-size: 22px;
|
||||||
|
line-height: 1;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
color: var(--text-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-name {
|
||||||
|
font-size: 8px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.1;
|
||||||
|
max-width: 90%;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-stack {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 2px;
|
||||||
|
right: 4px;
|
||||||
|
font-size: 9px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text);
|
||||||
|
background: rgba(255,255,255,0.8);
|
||||||
|
padding: 0 3px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-ammo {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
right: 4px;
|
||||||
|
font-size: 9px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #e67e22;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-durability-bar {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
height: 3px;
|
||||||
|
background: var(--border);
|
||||||
|
border-radius: 0 0 4px 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-durability-fill {
|
||||||
|
height: 100%;
|
||||||
|
background: var(--success);
|
||||||
|
transition: width 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-durability-fill.medium { background: #f39c12; }
|
||||||
|
.inv-slot-durability-fill.low { background: var(--danger); }
|
||||||
|
|
||||||
|
.inv-slot-quality {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 4px;
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-slot-empty-icon {
|
||||||
|
color: var(--text-muted);
|
||||||
|
opacity: 0.3;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Equipped Items Grid */
|
||||||
|
.inv-equipped-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-equipped-slot {
|
||||||
|
border: 2px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
transition: all 0.15s;
|
||||||
|
background: var(--card-bg);
|
||||||
|
min-height: 80px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-equipped-slot:hover {
|
||||||
|
border-color: var(--primary);
|
||||||
|
background: var(--hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-equipped-slot.has-item {
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-equipped-label {
|
||||||
|
font-size: 10px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-equipped-slot .inv-slot-icon {
|
||||||
|
font-size: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-equipped-slot .inv-slot-name {
|
||||||
|
font-size: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Key Items List */
|
||||||
|
.inv-key-items {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-key-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s;
|
||||||
|
background: var(--card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-key-item:hover {
|
||||||
|
border-color: var(--primary);
|
||||||
|
background: var(--hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-key-item .inv-slot-icon {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-key-item .inv-slot-name {
|
||||||
|
font-size: 12px;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unknown Section */
|
||||||
|
.inv-unknown-section {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 8px 12px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text);
|
||||||
|
transition: all 0.15s;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-toggle:hover {
|
||||||
|
border-color: var(--primary);
|
||||||
|
background: var(--hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-toggle .arrow {
|
||||||
|
transition: transform 0.2s;
|
||||||
|
font-size: 10px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-toggle .arrow.open {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-content {
|
||||||
|
display: none;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-content.open {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-sub {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-sub-header {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-light);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inv-unknown-grid .inv-grid-slot {
|
||||||
|
min-height: 56px;
|
||||||
|
border-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Item Edit Modal */
|
||||||
|
.item-edit-modal .item-preview {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
background: var(--hover);
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-modal .item-preview .item-icon {
|
||||||
|
font-size: 32px;
|
||||||
|
color: var(--text-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-modal .item-preview .item-info {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-modal .item-preview .item-name {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-modal .item-preview .item-id {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-form .form-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-form .form-row label {
|
||||||
|
min-width: 80px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--text-light);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-form .form-row input {
|
||||||
|
flex: 1;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 13px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-form .form-row input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--primary);
|
||||||
|
box-shadow: 0 0 0 2px rgba(201,162,78,0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-edit-actions .btn-save { flex: 1; }
|
||||||
|
.item-edit-actions .btn-cancel { flex: 1; }
|
||||||
|
.item-edit-actions .btn-danger { flex: 0 0 auto; }
|
||||||
|
|
||||||
/* Info box */
|
/* Info box */
|
||||||
.info-box {
|
.info-box {
|
||||||
background: #eaf2f8;
|
background: #eaf2f8;
|
||||||
|
|||||||
+310
-22
@@ -293,31 +293,215 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{% for inv in inventories %}
|
{% for inv in primary_inventories %}
|
||||||
<div class="inv-type">{{ inv.inventory_type | inv_label }} (ID: {{ inv.id }}, Slots: {{ inv.max_item_count or '?' }}, Volume: {{ inv.max_item_volume or '?' }})
|
{% if inv.inventory_type == 0 %}
|
||||||
|
<div class="inv-section-header">
|
||||||
|
<span>{{ inv.inventory_type | inv_label }}<span class="inv-meta">(ID: {{ inv.id }}, Slots: {{ inv.max_item_count or '?' }}, Volume: {{ inv.max_item_volume or '?' }})</span></span>
|
||||||
|
{% if not is_online %}
|
||||||
|
<button onclick="openAddItemModal({{ inv.id }})" class="btn-edit" style="font-size:11px;padding:2px 8px;">+ Add Item</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="inv-grid">
|
||||||
|
{% for item in inv.item_list %}
|
||||||
|
<div class="inv-grid-slot has-item" onclick="openItemEditModal({{ item.id }}, '{{ item.template_id | escapejs }}', {{ item.stack_size }}, {{ item.quality_level or 0 }}, {{ item.durability | default('null') }}, {{ item.max_durability | default('null') }}, {{ item.ammo | default('null') }}, {{ inv.id }})">
|
||||||
|
<div class="inv-slot-icon">📦</div>
|
||||||
|
<div class="inv-slot-name" title="{{ item.template_id }}">{{ item.template_id | truncate(20) }}</div>
|
||||||
|
{% if item.stack_size and item.stack_size > 1 %}
|
||||||
|
<div class="inv-slot-stack">{{ item.stack_size }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.ammo %}
|
||||||
|
<div class="inv-slot-ammo">🔥{{ item.ammo }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.durability and item.max_durability and item.max_durability > 0 %}
|
||||||
|
{% set dur_pct = (item.durability / item.max_durability * 100) | int %}
|
||||||
|
{% set dur_class = 'low' if dur_pct < 30 else ('medium' if dur_pct < 70 else '') %}
|
||||||
|
<div class="inv-slot-durability-bar"><div class="inv-slot-durability-fill {{ dur_class }}" style="width:{{ dur_pct }}%"></div></div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.quality_level and item.quality_level > 0 %}
|
||||||
|
{% set tier_color = quality_tiers[item.quality_level].color if item.quality_level in quality_tiers else '#9a8a7a' %}
|
||||||
|
<div class="inv-slot-quality" style="background:{{ tier_color }}"></div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% set item_count = inv.item_list | length %}
|
||||||
|
{% set max_slots = inv.max_item_count or 35 %}
|
||||||
|
{% for i in range(item_count, max_slots) %}
|
||||||
|
<div class="inv-grid-slot" onclick="openAddItemModal({{ inv.id }})">
|
||||||
|
<div class="inv-slot-empty-icon">+</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% elif inv.inventory_type == 1 %}
|
||||||
|
<div class="inv-section-header">
|
||||||
|
<span>{{ inv.inventory_type | inv_label }}<span class="inv-meta">(ID: {{ inv.id }})</span></span>
|
||||||
|
{% if not is_online %}
|
||||||
|
<button onclick="openAddItemModal({{ inv.id }})" class="btn-edit" style="font-size:11px;padding:2px 8px;">+ Add Item</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="inv-equipped-grid">
|
||||||
|
{% for slot_idx in range(10) %}
|
||||||
|
{% set slot_label = equipped_slot_labels[slot_idx] if slot_idx in equipped_slot_labels else 'Slot ' ~ slot_idx %}
|
||||||
|
{% set slot_item = inv.item_list | selectattr('position_index', 'equalto', slot_idx) | first %}
|
||||||
|
{% if slot_item %}
|
||||||
|
<div class="inv-equipped-slot has-item" onclick="openItemEditModal({{ slot_item.id }}, '{{ slot_item.template_id | escapejs }}', {{ slot_item.stack_size }}, {{ slot_item.quality_level or 0 }}, {{ slot_item.durability | default('null') }}, {{ slot_item.max_durability | default('null') }}, {{ slot_item.ammo | default('null') }}, {{ inv.id }})">
|
||||||
|
<div class="inv-equipped-label">{{ slot_label }}</div>
|
||||||
|
<div class="inv-slot-icon">📦</div>
|
||||||
|
<div class="inv-slot-name" title="{{ slot_item.template_id }}">{{ slot_item.template_id | truncate(15) }}</div>
|
||||||
|
{% if slot_item.stack_size and slot_item.stack_size > 1 %}
|
||||||
|
<div class="inv-slot-stack">{{ slot_item.stack_size }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if slot_item.ammo %}
|
||||||
|
<div class="inv-slot-ammo">🔥{{ slot_item.ammo }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if slot_item.durability and slot_item.max_durability and slot_item.max_durability > 0 %}
|
||||||
|
{% set dur_pct = (slot_item.durability / slot_item.max_durability * 100) | int %}
|
||||||
|
{% set dur_class = 'low' if dur_pct < 30 else ('medium' if dur_pct < 70 else '') %}
|
||||||
|
<div class="inv-slot-durability-bar"><div class="inv-slot-durability-fill {{ dur_class }}" style="width:{{ dur_pct }}%"></div></div>
|
||||||
|
{% endif %}
|
||||||
|
{% if slot_item.quality_level and slot_item.quality_level > 0 %}
|
||||||
|
{% set tier_color = quality_tiers[slot_item.quality_level].color if slot_item.quality_level in quality_tiers else '#9a8a7a' %}
|
||||||
|
<div class="inv-slot-quality" style="background:{{ tier_color }}"></div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="inv-equipped-slot" onclick="openAddItemModal({{ inv.id }})">
|
||||||
|
<div class="inv-equipped-label">{{ slot_label }}</div>
|
||||||
|
<div style="color:var(--text-muted);opacity:0.3;font-size:20px;">+</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% elif inv.inventory_type == 15 %}
|
||||||
|
<div class="inv-section-header">
|
||||||
|
<span>{{ inv.inventory_type | inv_label }}<span class="inv-meta">(ID: {{ inv.id }})</span></span>
|
||||||
{% if not is_online %}
|
{% if not is_online %}
|
||||||
<button onclick="openAddItemModal({{ inv.id }})" class="btn-edit" style="font-size:11px;padding:2px 8px;">+ Add Item</button>
|
<button onclick="openAddItemModal({{ inv.id }})" class="btn-edit" style="font-size:11px;padding:2px 8px;">+ Add Item</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if inv.item_list %}
|
{% if inv.item_list %}
|
||||||
<div class="table-wrap" style="margin-bottom:12px;">
|
<div class="inv-key-items">
|
||||||
<table>
|
|
||||||
<thead><tr><th>Template</th><th>Stack</th><th>Quality</th><th>New</th>{% if not is_online %}<th>Actions</th>{% endif %}</tr></thead>
|
|
||||||
<tbody>
|
|
||||||
{% for item in inv.item_list %}
|
{% for item in inv.item_list %}
|
||||||
<tr id="item-row-{{ item.id }}">
|
<div class="inv-key-item" onclick="openItemEditModal({{ item.id }}, '{{ item.template_id | escapejs }}', {{ item.stack_size }}, {{ item.quality_level or 0 }}, {{ item.durability | default('null') }}, {{ item.max_durability | default('null') }}, {{ item.ammo | default('null') }}, {{ inv.id }})">
|
||||||
<td style="font-size:11px;max-width:300px;word-break:break-all;" id="item-template-{{ item.id }}">{{ item.template_id }}</td>
|
<div class="inv-slot-icon">📦</div>
|
||||||
<td><span id="item-stack-{{ item.id }}">{{ item.stack_size }}</span> {% if not is_online %}<button onclick="editItem({{ item.id }}, 'stack_size', {{ item.stack_size }})" class="btn-edit" style="font-size:10px;padding:1px 5px;">✎</button>{% endif %}</td>
|
<div class="inv-slot-name">{{ item.template_id }}</div>
|
||||||
<td><span id="item-quality-{{ item.id }}">{{ item.quality_level or 0 }}</span> {% if not is_online %}<button onclick="editItem({{ item.id }}, 'quality_level', {{ item.quality_level or 0 }})" class="btn-edit" style="font-size:10px;padding:1px 5px;">✎</button>{% endif %}</td>
|
{% if item.stack_size and item.stack_size > 1 %}
|
||||||
<td>{{ item.is_new or False }}</td>
|
<span style="font-size:11px;color:var(--text-muted);">x{{ item.stack_size }}</span>
|
||||||
{% if not is_online %}<td><button onclick="deleteItem({{ item.id }}, '{{ item.template_id }}')" class="btn-danger" style="font-size:10px;padding:1px 5px;">Del</button></td>{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p style="color:var(--text-muted);font-size:13px;margin-bottom:12px;">(empty)</p>
|
<p style="color:var(--text-muted);font-size:13px;">(empty)</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<div class="inv-section-header">
|
||||||
|
<span>{{ inv.inventory_type | inv_label }} (ID: {{ inv.id }})</span>
|
||||||
|
{% if not is_online %}
|
||||||
|
<button onclick="openAddItemModal({{ inv.id }})" class="btn-edit" style="font-size:11px;padding:2px 8px;">+ Add Item</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if inv.item_list %}
|
||||||
|
<div class="inv-grid" style="grid-template-columns:repeat(auto-fill, minmax(64px, 1fr));">
|
||||||
|
{% for item in inv.item_list %}
|
||||||
|
<div class="inv-grid-slot has-item" onclick="openItemEditModal({{ item.id }}, '{{ item.template_id | escapejs }}', {{ item.stack_size }}, {{ item.quality_level or 0 }}, {{ item.durability | default('null') }}, {{ item.max_durability | default('null') }}, {{ item.ammo | default('null') }}, {{ inv.id }})">
|
||||||
|
<div class="inv-slot-icon">📦</div>
|
||||||
|
<div class="inv-slot-name" title="{{ item.template_id }}">{{ item.template_id | truncate(15) }}</div>
|
||||||
|
{% if item.stack_size and item.stack_size > 1 %}
|
||||||
|
<div class="inv-slot-stack">{{ item.stack_size }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.ammo %}
|
||||||
|
<div class="inv-slot-ammo">🔥{{ item.ammo }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.durability and item.max_durability and item.max_durability > 0 %}
|
||||||
|
{% set dur_pct = (item.durability / item.max_durability * 100) | int %}
|
||||||
|
{% set dur_class = 'low' if dur_pct < 30 else ('medium' if dur_pct < 70 else '') %}
|
||||||
|
<div class="inv-slot-durability-bar"><div class="inv-slot-durability-fill {{ dur_class }}" style="width:{{ dur_pct }}%"></div></div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p style="color:var(--text-muted);font-size:13px;">(empty)</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if unknown_inventories %}
|
||||||
|
<div class="inv-unknown-section">
|
||||||
|
<button class="inv-unknown-toggle" onclick="toggleUnknownSection(this)">
|
||||||
|
<span>Other / Unknown Items ({{ unknown_inventories|map(attribute='item_list')|map('length')|sum }})</span>
|
||||||
|
<span class="arrow">▶</span>
|
||||||
|
</button>
|
||||||
|
<div class="inv-unknown-content">
|
||||||
|
{% for inv in unknown_inventories %}
|
||||||
|
<div class="inv-unknown-sub">
|
||||||
|
<div class="inv-unknown-sub-header">{{ inv.inventory_type | inv_label }} (ID: {{ inv.id }})</div>
|
||||||
|
{% if inv.item_list %}
|
||||||
|
<div class="inv-unknown-grid">
|
||||||
|
{% for item in inv.item_list %}
|
||||||
|
<div class="inv-grid-slot has-item" onclick="openItemEditModal({{ item.id }}, '{{ item.template_id | escapejs }}', {{ item.stack_size }}, {{ item.quality_level or 0 }}, {{ item.durability | default('null') }}, {{ item.max_durability | default('null') }}, {{ item.ammo | default('null') }}, {{ inv.id }})">
|
||||||
|
<div class="inv-slot-icon">📦</div>
|
||||||
|
<div class="inv-slot-name" title="{{ item.template_id }}">{{ item.template_id | truncate(20) }}</div>
|
||||||
|
{% if item.stack_size and item.stack_size > 1 %}
|
||||||
|
<div class="inv-slot-stack">{{ item.stack_size }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.ammo %}
|
||||||
|
<div class="inv-slot-ammo">🔥{{ item.ammo }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.durability and item.max_durability and item.max_durability > 0 %}
|
||||||
|
{% set dur_pct = (item.durability / item.max_durability * 100) | int %}
|
||||||
|
{% set dur_class = 'low' if dur_pct < 30 else ('medium' if dur_pct < 70 else '') %}
|
||||||
|
<div class="inv-slot-durability-bar"><div class="inv-slot-durability-fill {{ dur_class }}" style="width:{{ dur_pct }}%"></div></div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.quality_level and item.quality_level > 0 %}
|
||||||
|
{% set tier_color = quality_tiers[item.quality_level].color if item.quality_level in quality_tiers else '#9a8a7a' %}
|
||||||
|
<div class="inv-slot-quality" style="background:{{ tier_color }}"></div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p style="color:var(--text-muted);font-size:11px;">(empty)</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for inv in other_inventories %}
|
||||||
|
<div class="inv-section-header">
|
||||||
|
<span>{{ inv.inventory_type | inv_label }} (ID: {{ inv.id }})</span>
|
||||||
|
{% if not is_online %}
|
||||||
|
<button onclick="openAddItemModal({{ inv.id }})" class="btn-edit" style="font-size:11px;padding:2px 8px;">+ Add Item</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if inv.item_list %}
|
||||||
|
<div class="inv-grid" style="grid-template-columns:repeat(auto-fill, minmax(64px, 1fr));">
|
||||||
|
{% for item in inv.item_list %}
|
||||||
|
<div class="inv-grid-slot has-item" onclick="openItemEditModal({{ item.id }}, '{{ item.template_id | escapejs }}', {{ item.stack_size }}, {{ item.quality_level or 0 }}, {{ item.durability | default('null') }}, {{ item.max_durability | default('null') }}, {{ item.ammo | default('null') }}, {{ inv.id }})">
|
||||||
|
<div class="inv-slot-icon">📦</div>
|
||||||
|
<div class="inv-slot-name" title="{{ item.template_id }}">{{ item.template_id | truncate(15) }}</div>
|
||||||
|
{% if item.stack_size and item.stack_size > 1 %}
|
||||||
|
<div class="inv-slot-stack">{{ item.stack_size }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.ammo %}
|
||||||
|
<div class="inv-slot-ammo">🔥{{ item.ammo }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.durability and item.max_durability and item.max_durability > 0 %}
|
||||||
|
{% set dur_pct = (item.durability / item.max_durability * 100) | int %}
|
||||||
|
{% set dur_class = 'low' if dur_pct < 30 else ('medium' if dur_pct < 70 else '') %}
|
||||||
|
<div class="inv-slot-durability-bar"><div class="inv-slot-durability-fill {{ dur_class }}" style="width:{{ dur_pct }}%"></div></div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p style="color:var(--text-muted);font-size:13px;">(empty)</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@@ -453,6 +637,49 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Item Edit Modal -->
|
||||||
|
<div id="item-edit-modal" class="modal-overlay item-edit-modal" style="display:none;" onclick="if(event.target===this)closeModal('item-edit-modal')">
|
||||||
|
<div class="modal" style="max-width:450px;">
|
||||||
|
<h3>Edit Item</h3>
|
||||||
|
<div class="item-preview">
|
||||||
|
<div class="item-icon">📦</div>
|
||||||
|
<div class="item-info">
|
||||||
|
<div class="item-name" id="item-edit-name"></div>
|
||||||
|
<div class="item-id" id="item-edit-id"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form id="item-edit-form" class="item-edit-form">
|
||||||
|
<input type="hidden" id="item-edit-item-id" value="">
|
||||||
|
<input type="hidden" id="item-edit-inv-id" value="">
|
||||||
|
<div class="form-row">
|
||||||
|
<label>Stack Size:</label>
|
||||||
|
<input type="number" id="item-edit-stack" min="1" value="1">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label>Quality:</label>
|
||||||
|
<input type="number" id="item-edit-quality" min="0" max="4" value="0">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label>Durability:</label>
|
||||||
|
<input type="number" id="item-edit-durability" step="0.1" min="0" placeholder="auto">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label>Max Durability:</label>
|
||||||
|
<input type="number" id="item-edit-max-durability" step="0.1" min="0" placeholder="auto">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label>Ammo:</label>
|
||||||
|
<input type="number" id="item-edit-ammo" min="0" placeholder="auto">
|
||||||
|
</div>
|
||||||
|
<div class="item-edit-actions">
|
||||||
|
<button type="button" onclick="submitItemEdit()" class="btn-save">Save</button>
|
||||||
|
<button type="button" onclick="submitItemDelete()" class="btn-danger">Delete</button>
|
||||||
|
<button type="button" onclick="closeModal('item-edit-modal')" class="btn-cancel">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@@ -557,6 +784,13 @@ async function submitVitalsEdit() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleUnknownSection(btn) {
|
||||||
|
const content = btn.nextElementSibling;
|
||||||
|
const arrow = btn.querySelector('.arrow');
|
||||||
|
content.classList.toggle('open');
|
||||||
|
arrow.classList.toggle('open');
|
||||||
|
}
|
||||||
|
|
||||||
async function editItem(itemId, field, currentValue) {
|
async function editItem(itemId, field, currentValue) {
|
||||||
const newValue = prompt(`Edit ${field} for item ${itemId}:`, currentValue);
|
const newValue = prompt(`Edit ${field} for item ${itemId}:`, currentValue);
|
||||||
if (newValue === null || newValue === currentValue) return;
|
if (newValue === null || newValue === currentValue) return;
|
||||||
@@ -568,9 +802,7 @@ async function editItem(itemId, field, currentValue) {
|
|||||||
const resp = await csrfFetch('/api/edit_item', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/edit_item', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const span = document.getElementById('item-' + field.replace('_', '-') + '-' + itemId);
|
location.reload();
|
||||||
if (span) span.textContent = result.value;
|
|
||||||
else location.reload();
|
|
||||||
} else {
|
} else {
|
||||||
alert('Error: ' + (result.error || 'Unknown error'));
|
alert('Error: ' + (result.error || 'Unknown error'));
|
||||||
}
|
}
|
||||||
@@ -579,7 +811,63 @@ async function editItem(itemId, field, currentValue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteItem(itemId, templateName) {
|
function openItemEditModal(itemId, templateName, stackSize, quality, durability, maxDurability, ammo, invId) {
|
||||||
|
document.getElementById('item-edit-item-id').value = itemId;
|
||||||
|
document.getElementById('item-edit-inv-id').value = invId;
|
||||||
|
document.getElementById('item-edit-name').textContent = templateName;
|
||||||
|
document.getElementById('item-edit-id').textContent = 'ID: ' + itemId;
|
||||||
|
document.getElementById('item-edit-stack').value = stackSize || 1;
|
||||||
|
document.getElementById('item-edit-quality').value = quality || 0;
|
||||||
|
document.getElementById('item-edit-durability').value = durability !== null ? durability : '';
|
||||||
|
document.getElementById('item-edit-max-durability').value = maxDurability !== null ? maxDurability : '';
|
||||||
|
document.getElementById('item-edit-ammo').value = ammo !== null ? ammo : '';
|
||||||
|
openModal('item-edit-modal');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitItemEdit() {
|
||||||
|
const itemId = document.getElementById('item-edit-item-id').value;
|
||||||
|
const invId = document.getElementById('item-edit-inv-id').value;
|
||||||
|
const stackSize = document.getElementById('item-edit-stack').value;
|
||||||
|
const quality = document.getElementById('item-edit-quality').value;
|
||||||
|
const durability = document.getElementById('item-edit-durability').value;
|
||||||
|
const maxDurability = document.getElementById('item-edit-max-durability').value;
|
||||||
|
const ammo = document.getElementById('item-edit-ammo').value;
|
||||||
|
|
||||||
|
const fields = { stack_size: stackSize, quality_level: quality };
|
||||||
|
if (durability) fields.durability = parseFloat(durability);
|
||||||
|
if (maxDurability) fields.max_durability = parseFloat(maxDurability);
|
||||||
|
if (ammo) fields.ammo = parseInt(ammo);
|
||||||
|
|
||||||
|
let allSuccess = true;
|
||||||
|
for (const [field, value] of Object.entries(fields)) {
|
||||||
|
const data = new FormData();
|
||||||
|
data.append('item_id', itemId);
|
||||||
|
data.append('field', field);
|
||||||
|
data.append('value', value);
|
||||||
|
try {
|
||||||
|
const resp = await csrfFetch('/api/edit_item', { method: 'POST', body: data });
|
||||||
|
const result = await resp.json();
|
||||||
|
if (!result.success) {
|
||||||
|
alert('Error updating ' + field + ': ' + (result.error || 'Unknown error'));
|
||||||
|
allSuccess = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
alert('Error: ' + e.message);
|
||||||
|
allSuccess = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSuccess) {
|
||||||
|
closeModal('item-edit-modal');
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitItemDelete() {
|
||||||
|
const itemId = document.getElementById('item-edit-item-id').value;
|
||||||
|
const templateName = document.getElementById('item-edit-name').textContent;
|
||||||
if (!confirm(`Delete item "${templateName}" (ID: ${itemId})? This cannot be undone.`)) return;
|
if (!confirm(`Delete item "${templateName}" (ID: ${itemId})? This cannot be undone.`)) return;
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
data.append('item_id', itemId);
|
data.append('item_id', itemId);
|
||||||
@@ -587,8 +875,8 @@ async function deleteItem(itemId, templateName) {
|
|||||||
const resp = await csrfFetch('/api/delete_item', { method: 'POST', body: data });
|
const resp = await csrfFetch('/api/delete_item', { method: 'POST', body: data });
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const row = document.getElementById('item-row-' + itemId);
|
closeModal('item-edit-modal');
|
||||||
if (row) row.remove();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
alert('Error: ' + (result.error || 'Unknown error'));
|
alert('Error: ' + (result.error || 'Unknown error'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user