layout things.

This commit is contained in:
archon0ne 2024-07-03 17:11:02 +02:00
parent be92411568
commit c80534ad20
4 changed files with 11244 additions and 135 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
# Ignore specific JSON files
/assort.json
/questassort.json
# Ignore the log file
/log.log
# Ignore the backup directory
/bkp/

9
app.py
View File

@ -4,6 +4,7 @@ import requests
import logging
import os
import traceback
import time
app = Flask(__name__)
@ -202,6 +203,14 @@ def save_assort_data():
if 'details' in part:
del part['details']
# Backup the existing assort.json
if not os.path.exists('./bkp'):
os.makedirs('./bkp')
backup_file_path = os.path.join('./bkp', f"assort_backup_{int(time.time())}.json")
if os.path.exists(ASSORT_FILE_PATH):
os.rename(ASSORT_FILE_PATH, backup_file_path)
logging.debug(f"Backup of assort data created at {backup_file_path}")
with open(ASSORT_FILE_PATH, 'w') as f:
json.dump(cleaned_assort_data, f, indent=2) # Use 2 spaces for indentation
logging.debug("Assort data saved successfully")

11071
item_cache.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="UTF-8">
<title>Trader Assort</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
@ -15,47 +15,58 @@
border-radius: 5px;
margin-bottom: 15px;
}
.price-box img {
width: 30px;
margin-right: 10px;
}
.price-box span {
font-size: 1.2em;
font-weight: bold;
}
.price-box small {
font-size: 0.8em;
color: #888;
}
.card {
margin-bottom: 15px;
}
.card-header img {
width: 45px;
margin-right: 10px;
}
.barter-list {
list-style-type: none;
padding-left: 0;
display: flex;
flex-direction: row;
}
.barter-list li {
display: flex;
align-items: center;
}
.barter-list li img {
width: 45px;
margin-right: 10px;
}
.parts-tree {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.parts-tree > li {
.parts-tree>li {
margin-right: 10px;
}
.part-item {
display: flex;
flex-direction: row;
@ -65,78 +76,87 @@
border-radius: 5px;
margin-bottom: 5px;
}
.part-item img {
width: 30px;
margin-right: 5px;
}
.card-body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.barter-section {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
.left-section {
display: flex;
flex-direction: column;
}
</style>
</head>
<body>
</head>
<body>
<div class="container">
<h1>Trader Assort</h1>
<div class="list-group">
{% for item in items %}
<div class="card">
<div class="list-group"> {% for item in items %} <div class="card">
<div class="card-header d-flex align-items-center">
<img src="{{ item.details.image512pxLink }}" alt="{{ item.details.name }}">
<strong>{{ item.details.name }}</strong>
<div class="ml-2 text-muted">{{ item.offer_name }}</div> <!-- Add offer name here -->
<div class="ml-2 text-muted">{{ item.offer_name }}</div>
<!-- Add offer name here -->
<div class="price-box ml-auto">
<div><img src="{{ ruble_image.image512pxLink }}" alt="RUB"><span>{{ item.details.basePrice }} RUB</span></div>
<div>
<img src="{{ ruble_image.image512pxLink }}" alt="RUB">
<span>{{ item.details.basePrice }} RUB</span>
</div>
<small>Base Price (for reference)</small>
</div>
</div>
<div class="card-body">
<a href="{{ url_for('edit_item', item_id=item._id) }}" class="btn btn-primary btn-sm float-right">Edit</a>
{% if item.parts|length > 0 %}
<h2>
<button class="btn btn-outline-primary" type="button" data-toggle="collapse" data-target="#parts-{{ item._id }}" aria-expanded="false" aria-controls="parts-{{ item._id }}">
Parts
</button>
</h2>
<div id="parts-{{ item._id }}" class="collapse">
<ul class="parts-tree">
{% include 'parts.html' with context %}
</ul>
</div>
{% endif %}
<div class="barter-section">
<div class="left-section">
{% if item.barter_scheme|length > 0 %}
<div><strong>Barter Requirements:</strong></div>
<ul class="barter-list">
{% for scheme in item.barter_scheme %}
{% for req in scheme %}
<li>
<div>
<strong>Barter Requirements:</strong>
</div>
<ul class="barter-list"> {% for scheme in item.barter_scheme %} {% for req in scheme %} <li>
<span>{{ req.count }} ×</span>
<img src="{{ req.details.image512pxLink }}" alt="{{ req.details.name }}">
</li>
{% endfor %}
{% endfor %}
</ul>
</li> {% endfor %} {% endfor %} </ul>
{% endif %}
{% if item.quest_requirement %}
<p>
<strong>Quest Requirement:</strong>
{{ item.quest_requirement.quest }}
{% if item.quest_requirement.type == 'success' %}
<i class="fas fa-check-circle text-success"></i>
{% elif item.quest_requirement.type == 'fail' %}
<i class="fas fa-times-circle text-danger"></i>
{% elif item.quest_requirement.type == 'started' %}
<i class="fas fa-question-circle text-primary"></i>
{% endif %}
{{ item.quest_requirement.quest }} {% if item.quest_requirement.type == 'success' %} <i class="fas fa-check-circle text-success"></i> {% elif item.quest_requirement.type == 'fail' %} <i class="fas fa-times-circle text-danger"></i> {% elif item.quest_requirement.type == 'started' %} <i class="fas fa-question-circle text-primary"></i> {% endif %}
</p>
{% endif %}
</div>
<a href="{{ url_for('edit_item', item_id=item._id) }}" class="btn btn-primary btn-sm">Edit</a>
</div>
{% endfor %}
{% if item.parts|length > 0 %}
<h2>
<button class="btn btn-outline-primary" type="button" data-toggle="collapse" data-target="#parts-{{ item._id }}" aria-expanded="false" aria-controls="parts-{{ item._id }}"> Parts </button>
</h2>
<div>
<div id="parts-{{ item._id }}" class="collapse">
<ul class="parts-tree"> {% include 'parts.html' with context %} </ul>
</div>
</div>
{% endif %}
</div>
</div> {% endfor %}
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</body>
</html>