mirror of
https://github.com/sstent/foodplanner.git
synced 2026-01-25 19:21:37 +00:00
added alembic database migrations, json import/export
This commit is contained in:
39
templates/admin/backups.html
Normal file
39
templates/admin/backups.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{% extends "admin/index.html" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Database Backups</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>
|
||||
Create a snapshot of the database or restore from a previous backup. Backups are stored in the <code>/backups</code> directory.
|
||||
</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<form action="/admin/backups/create" method="post" class="d-inline">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-cloud-download"></i> Backup Now
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<h5>Restore from Backup</h5>
|
||||
<form action="/admin/backups/restore" method="post" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label for="backup-file" class="form-label">Select backup file to restore</label>
|
||||
<select class="form-select" id="backup-file" name="backup_file">
|
||||
{% for backup in backups %}
|
||||
<option value="{{ backup }}">{{ backup }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">
|
||||
<i class="bi bi-cloud-upload"></i> Restore
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
35
templates/admin/imports.html
Normal file
35
templates/admin/imports.html
Normal file
@@ -0,0 +1,35 @@
|
||||
{% extends "admin/index.html" %}
|
||||
|
||||
{% block admin_content %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Import/Export All Data</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>
|
||||
This section allows you to export all your data (foods, meals, plans, etc.) into a single JSON file.
|
||||
You can also import this data back, which will overwrite any existing data.
|
||||
This is useful for backups or migrating to a new instance.
|
||||
</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<a href="/export/all" class="btn btn-primary" download="meal_planner_backup.json">
|
||||
<i class="bi bi-download"></i> Export All Data
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<h5>Import Data</h5>
|
||||
<form id="import-form" action="/import/all" method="post" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label for="import-file" class="form-label">Select JSON file to import</label>
|
||||
<input class="form-control" type="file" id="import-file" name="file" accept=".json">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">
|
||||
<i class="bi bi-upload"></i> Import and Overwrite
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
18
templates/admin/index.html
Normal file
18
templates/admin/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2 class="mb-4">Admin</h2>
|
||||
|
||||
<ul class="nav nav-tabs" id="adminTab" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" id="imports-tab" href="/admin/imports">Imports</a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link" id="backups-tab" href="/admin/backups">Backups</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content mt-3">
|
||||
{% block admin_content %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user