Initial commit - LEGO Instructions Manager v1.5.0
This commit is contained in:
260
app/templates/admin/bulk_import.html
Normal file
260
app/templates/admin/bulk_import.html
Normal file
@@ -0,0 +1,260 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Bulk Import Sets - Admin - {{ app_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<h1>
|
||||
<i class="bi bi-cloud-upload"></i> Bulk Import Sets from Brickset
|
||||
</h1>
|
||||
<p class="text-muted">Import multiple official LEGO sets at once using Brickset data</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="{{ url_for('admin.dashboard') }}" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left"></i> Back to Admin
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not brickset_configured %}
|
||||
<div class="alert alert-warning">
|
||||
<i class="bi bi-exclamation-triangle"></i>
|
||||
<strong>Brickset API Not Configured</strong>
|
||||
<p class="mb-0">
|
||||
Please add your Brickset API credentials to the <code>.env</code> file:
|
||||
</p>
|
||||
<pre class="mb-0 mt-2">
|
||||
BRICKSET_API_KEY=your_api_key_here
|
||||
BRICKSET_USERNAME=your_username
|
||||
BRICKSET_PASSWORD=your_password</pre>
|
||||
<p class="mb-0 mt-2">
|
||||
Get your API key at: <a href="https://brickset.com/tools/webservices/requestkey" target="_blank">https://brickset.com/tools/webservices/requestkey</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0"><i class="bi bi-list-ol"></i> Import Sets</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url_for('admin.bulk_import') }}">
|
||||
<!-- Set Numbers -->
|
||||
<div class="mb-3">
|
||||
<label for="set_numbers" class="form-label">
|
||||
<strong>Set Numbers</strong>
|
||||
<span class="text-muted">(one per line, or comma/space separated)</span>
|
||||
</label>
|
||||
<textarea class="form-control font-monospace"
|
||||
id="set_numbers"
|
||||
name="set_numbers"
|
||||
rows="10"
|
||||
placeholder="Example: 8860 10497 42100 21318"
|
||||
required
|
||||
{% if not brickset_configured %}disabled{% endif %}></textarea>
|
||||
<small class="form-text text-muted">
|
||||
Enter LEGO set numbers (e.g., 8860, 10497-1, 42100). Variants like -1 are supported.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- User Selection -->
|
||||
<div class="mb-3">
|
||||
<label for="user_id" class="form-label">
|
||||
<strong>Assign to User</strong>
|
||||
</label>
|
||||
<select class="form-select"
|
||||
id="user_id"
|
||||
name="user_id"
|
||||
required
|
||||
{% if not brickset_configured %}disabled{% endif %}>
|
||||
<option value="">Select a user...</option>
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" {% if user.id == current_user.id %}selected{% endif %}>
|
||||
{{ user.username }} ({{ user.email }})
|
||||
{% if user.is_admin %}👑 Admin{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<small class="form-text text-muted">
|
||||
Sets will be added to this user's collection
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Throttle Delay -->
|
||||
<div class="mb-3">
|
||||
<label for="throttle_delay" class="form-label">
|
||||
<strong>API Throttle Delay</strong>
|
||||
<span class="text-muted">(seconds between requests)</span>
|
||||
</label>
|
||||
<select class="form-select"
|
||||
id="throttle_delay"
|
||||
name="throttle_delay"
|
||||
{% if not brickset_configured %}disabled{% endif %}>
|
||||
<option value="0.3">0.3s - Fast (may hit rate limits)</option>
|
||||
<option value="0.5" selected>0.5s - Balanced (recommended)</option>
|
||||
<option value="1.0">1.0s - Safe (slower but reliable)</option>
|
||||
<option value="2.0">2.0s - Very Safe (for large batches)</option>
|
||||
</select>
|
||||
<small class="form-text text-muted">
|
||||
<i class="bi bi-info-circle"></i>
|
||||
Brickset has API rate limits. Increase delay if you get rate limit errors.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Submit -->
|
||||
<div class="d-grid gap-2">
|
||||
<button type="submit"
|
||||
class="btn btn-primary btn-lg"
|
||||
{% if not brickset_configured %}disabled{% endif %}>
|
||||
<i class="bi bi-cloud-download"></i>
|
||||
Import Sets from Brickset
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<!-- Info Card -->
|
||||
<div class="card bg-light mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="mb-0"><i class="bi bi-info-circle"></i> How It Works</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ol class="mb-0">
|
||||
<li class="mb-2">Enter set numbers (one per line)</li>
|
||||
<li class="mb-2">Select which user to assign them to</li>
|
||||
<li class="mb-2">Choose throttle delay</li>
|
||||
<li class="mb-2">Click "Import Sets"</li>
|
||||
<li class="mb-2">System fetches data from Brickset</li>
|
||||
<li class="mb-0">Sets are added to database!</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Rate Limit Warning -->
|
||||
<div class="card bg-warning text-dark mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="mb-0"><i class="bi bi-exclamation-triangle"></i> API Rate Limits</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="mb-2">
|
||||
<strong>Brickset has API rate limits!</strong>
|
||||
</p>
|
||||
<ul class="mb-0 small">
|
||||
<li class="mb-2">
|
||||
<strong>Recommended:</strong> Import 10-20 sets at a time
|
||||
</li>
|
||||
<li class="mb-2">
|
||||
<strong>Throttle:</strong> Use 0.5s-1.0s delay between requests
|
||||
</li>
|
||||
<li class="mb-2">
|
||||
<strong>If rate limited:</strong> Wait 5-10 minutes and retry
|
||||
</li>
|
||||
<li class="mb-0">
|
||||
<strong>Large batches:</strong> Split into multiple smaller imports
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- What Gets Imported -->
|
||||
<div class="card bg-info text-white mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="mb-0"><i class="bi bi-box-seam"></i> What Gets Imported</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="mb-0">
|
||||
<li>Set Number</li>
|
||||
<li>Set Name</li>
|
||||
<li>Theme</li>
|
||||
<li>Year Released</li>
|
||||
<li>Piece Count</li>
|
||||
<li>Cover Image (from Brickset)</li>
|
||||
</ul>
|
||||
<hr class="bg-white">
|
||||
<small>
|
||||
<i class="bi bi-lightbulb"></i>
|
||||
You can upload instructions separately later!
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tips -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6 class="mb-0"><i class="bi bi-stars"></i> Pro Tips</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="small mb-0">
|
||||
<li class="mb-2">
|
||||
<strong>Start Small:</strong> Try 5-10 sets first to test
|
||||
</li>
|
||||
<li class="mb-2">
|
||||
<strong>Duplicates:</strong> Sets already in database will be skipped
|
||||
</li>
|
||||
<li class="mb-2">
|
||||
<strong>Not Found:</strong> Invalid set numbers will be reported
|
||||
</li>
|
||||
<li class="mb-0">
|
||||
<strong>Formats:</strong> Works with variants like 10497-1
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Example Sets -->
|
||||
<div class="row mt-4">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6 class="mb-0"><i class="bi bi-clipboard-check"></i> Example Sets You Can Try</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-2">
|
||||
<strong>Technic:</strong><br>
|
||||
<code>8860, 8880, 42100, 42110</code>
|
||||
</div>
|
||||
<div class="col-md-3 mb-2">
|
||||
<strong>Creator Expert:</strong><br>
|
||||
<code>10497, 10294, 10283</code>
|
||||
</div>
|
||||
<div class="col-md-3 mb-2">
|
||||
<strong>Ideas:</strong><br>
|
||||
<code>21318, 21330, 21341</code>
|
||||
</div>
|
||||
<div class="col-md-3 mb-2">
|
||||
<strong>Star Wars:</strong><br>
|
||||
<code>75192, 75313, 75331</code>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<button class="btn btn-sm btn-outline-primary" onclick="fillExample()">
|
||||
<i class="bi bi-clipboard"></i> Fill Example Sets
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function fillExample() {
|
||||
const examples = `8860
|
||||
8880
|
||||
42100
|
||||
10497
|
||||
10294
|
||||
21318
|
||||
75192`;
|
||||
document.getElementById('set_numbers').value = examples;
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user