Files
lego-instructions-manager/app/templates/admin/bulk_import_results.html

256 lines
8.9 KiB
HTML

{% extends "base.html" %}
{% block title %}Import Results - Admin - {{ app_name }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col">
<h1>
<i class="bi bi-clipboard-check"></i> Bulk Import Results
</h1>
</div>
<div class="col-auto">
<a href="{{ url_for('admin.bulk_import') }}" class="btn btn-primary">
<i class="bi bi-plus-circle"></i> Import More Sets
</a>
<a href="{{ url_for('admin.dashboard') }}" class="btn btn-outline-secondary">
<i class="bi bi-speedometer2"></i> Dashboard
</a>
</div>
</div>
<!-- Summary Cards -->
<div class="row mb-4">
<div class="col-md-3 mb-3">
<div class="card bg-success text-white h-100">
<div class="card-body text-center">
<h1 class="display-3">{{ results.success|length }}</h1>
<h5>Successfully Imported</h5>
</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="card bg-warning text-dark h-100">
<div class="card-body text-center">
<h1 class="display-3">{{ results.already_exists|length }}</h1>
<h5>Already Existed</h5>
</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="card bg-danger text-white h-100">
<div class="card-body text-center">
<h1 class="display-3">{{ results.failed|length }}</h1>
<h5>Failed to Import</h5>
</div>
</div>
</div>
<div class="col-md-3 mb-3">
<div class="card bg-info text-white h-100">
<div class="card-body text-center">
<h1 class="display-3">{{ results.rate_limited|length }}</h1>
<h5>Rate Limited</h5>
</div>
</div>
</div>
</div>
<!-- Successful Imports -->
{% if results.success %}
<div class="card mb-4">
<div class="card-header bg-success text-white">
<h5 class="mb-0">
<i class="bi bi-check-circle"></i>
Successfully Imported ({{ results.success|length }})
</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Set Number</th>
<th>Name</th>
<th>Theme</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for set in results.success %}
<tr>
<td><strong>{{ set.set_number }}</strong></td>
<td>{{ set.name }}</td>
<td><span class="badge bg-primary">{{ set.theme }}</span></td>
<td>
<!-- We need to find the actual set ID -->
<a href="{{ url_for('sets.list_sets') }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i> View
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
<!-- Already Exists -->
{% if results.already_exists %}
<div class="card mb-4">
<div class="card-header bg-warning text-dark">
<h5 class="mb-0">
<i class="bi bi-info-circle"></i>
Already in Database ({{ results.already_exists|length }})
</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Set Number</th>
<th>Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for set in results.already_exists %}
<tr>
<td><strong>{{ set.set_number }}</strong></td>
<td>{{ set.name }}</td>
<td><span class="badge bg-info">Skipped - Already exists</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
<!-- Failed Imports -->
{% if results.failed %}
<div class="card mb-4">
<div class="card-header bg-danger text-white">
<h5 class="mb-0">
<i class="bi bi-x-circle"></i>
Failed to Import ({{ results.failed|length }})
</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Set Number</th>
<th>Reason</th>
</tr>
</thead>
<tbody>
{% for set in results.failed %}
<tr>
<td><strong>{{ set.set_number }}</strong></td>
<td>
<span class="badge bg-danger">{{ set.reason }}</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<small class="text-muted">
<i class="bi bi-lightbulb"></i>
<strong>Common reasons for failure:</strong>
Invalid set number, set doesn't exist in Brickset, or API connection issue.
</small>
</div>
</div>
{% endif %}
<!-- Rate Limited Sets -->
{% if results.rate_limited %}
<div class="card mb-4">
<div class="card-header bg-info text-white">
<h5 class="mb-0">
<i class="bi bi-exclamation-triangle"></i>
Rate Limited ({{ results.rate_limited|length }})
</h5>
</div>
<div class="card-body">
<div class="alert alert-info mb-3">
<h6><i class="bi bi-info-circle"></i> API Rate Limit Reached</h6>
<p class="mb-2">
Brickset's API has rate limits to prevent abuse. Your import was stopped after
{{ results.success|length }} successful import(s) to avoid hitting the limit.
</p>
<p class="mb-0">
<strong>To import these remaining sets:</strong>
</p>
<ol class="mb-0">
<li>Wait 5-10 minutes for the rate limit to reset</li>
<li>Use a longer throttle delay (1.0s or 2.0s)</li>
<li>Import in smaller batches (10-15 sets at a time)</li>
</ol>
</div>
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light">
<tr>
<th>Set Number</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for set in results.rate_limited %}
<tr>
<td><strong>{{ set.set_number }}</strong></td>
<td><span class="badge bg-info">{{ set.reason }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<strong>Quick Retry:</strong> Copy the set numbers below and try again in a few minutes with a longer delay.
<div class="mt-2">
<textarea class="form-control font-monospace" rows="3" readonly>{{ results.rate_limited|map(attribute='set_number')|join('\n') }}</textarea>
</div>
</div>
</div>
{% endif %}
<!-- Actions -->
<div class="card">
<div class="card-body text-center">
<h5>What's Next?</h5>
<div class="btn-group mt-3" role="group">
<a href="{{ url_for('sets.list_sets') }}" class="btn btn-primary">
<i class="bi bi-box-seam"></i> View All Sets
</a>
<a href="{{ url_for('admin.bulk_import') }}" class="btn btn-success">
<i class="bi bi-plus-circle"></i> Import More
</a>
<a href="{{ url_for('admin.dashboard') }}" class="btn btn-outline-secondary">
<i class="bi bi-speedometer2"></i> Admin Dashboard
</a>
</div>
{% if results.success %}
<div class="mt-3">
<p class="text-muted">
<i class="bi bi-info-circle"></i>
Don't forget to upload instructions for the newly imported sets!
</p>
</div>
{% endif %}
</div>
</div>
{% endblock %}