Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cbec23c49 | |||
| c315066264 | |||
| 945574906b | |||
| ee10a0f35a | |||
| 1ae54a46e7 |
@@ -3,10 +3,14 @@
|
|||||||
"build": {
|
"build": {
|
||||||
"dockerfile": "Dockerfile"
|
"dockerfile": "Dockerfile"
|
||||||
},
|
},
|
||||||
"settings": {},
|
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
"extensions": ["ms-python.python"]
|
"settings": {},
|
||||||
|
"extensions": [
|
||||||
|
"ms-python.python",
|
||||||
|
"vivaxy.vscode-conventional-commits",
|
||||||
|
"esbenp.prettier-vscode"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"postCreateCommand": "pip install -r requirements.txt; curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64; chmod +x tailwindcss-linux-x64; mv tailwindcss-linux-x64 tailwindcss",
|
"postCreateCommand": "pip install -r requirements.txt; curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64; chmod +x tailwindcss-linux-x64; mv tailwindcss-linux-x64 tailwindcss",
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
types: [closed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'v')
|
||||||
|
runs-on: build-htz-01
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Extract Version
|
||||||
|
id: get_version
|
||||||
|
run: echo "VERSION=${{ github.head_ref }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Generate Changelog
|
||||||
|
id: changelog
|
||||||
|
uses: https://github.com/metcalfc/changelog-generator@v4.6.2
|
||||||
|
with:
|
||||||
|
myToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
|
docker build -t cr.jdbnet.co.uk/public/opnsense-sftp:$VERSION \
|
||||||
|
-t cr.jdbnet.co.uk/public/opnsense-sftp:latest \
|
||||||
|
--build-arg VERSION=$VERSION \
|
||||||
|
.
|
||||||
|
docker push cr.jdbnet.co.uk/public/opnsense-sftp:$VERSION
|
||||||
|
docker push cr.jdbnet.co.uk/public/opnsense-sftp:latest
|
||||||
|
|
||||||
|
- name: Create Gitea Release
|
||||||
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.get_version.outputs.VERSION }}
|
||||||
|
name: ${{ steps.get_version.outputs.VERSION }}
|
||||||
|
body: ${{ steps.changelog.outputs.changelog }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: Deploy to Kubernetes
|
||||||
|
needs: release
|
||||||
|
runs-on: k3s-internal-htz-01
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Deploy to Kubernetes
|
||||||
|
run: |
|
||||||
|
sudo kubectl replace -f deployment.yml --grace-period=60 --force
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
name: Release Please
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release-please:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
release_created: ${{ steps.release.outputs.release_created }}
|
|
||||||
steps:
|
|
||||||
- uses: googleapis/release-please-action@v4
|
|
||||||
id: release
|
|
||||||
with:
|
|
||||||
manifest-file: .release-please-manifest.json
|
|
||||||
config-file: .release-please-config.json
|
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to GitHub Container Registry
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Read version
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION=$(cat VERSION)
|
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
if: ${{ steps.release.outputs.release_created }}
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
ghcr.io/jdb-net/opnsense-sftp:${{ env.VERSION }}
|
|
||||||
ghcr.io/jdb-net/opnsense-sftp:latest
|
|
||||||
build-args: |
|
|
||||||
VERSION=${{ env.VERSION }}
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
name: Deploy to Kubernetes
|
|
||||||
needs: release-please
|
|
||||||
if: ${{ needs.release-please.outputs.release_created }}
|
|
||||||
runs-on: [ k3s-lan-01 ]
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Apply manifests
|
|
||||||
run: |
|
|
||||||
sudo kubectl replace -f deployment.yml --grace-period=60 --force
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"packages": {
|
|
||||||
".": {
|
|
||||||
"release-type": "simple",
|
|
||||||
"version-file": "VERSION"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
".": "1.2.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
## [1.2.0](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.2...v1.2.0) (2025-11-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* :sparkles: latest backup api endpoint - /api/backups/latest ([703ab3b](https://github.com/JDB-NET/opnsense-sftp/commit/703ab3b07da0b60f91d674fd6f4a39d3c45ae1e6))
|
|
||||||
|
|
||||||
## [1.1.2](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.1...v1.1.2) (2025-11-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* :bug: k3s character limit ([2b91c19](https://github.com/JDB-NET/opnsense-sftp/commit/2b91c19afbf95f9192b43b46ebdc7816bb407db9))
|
|
||||||
|
|
||||||
## [1.1.1](https://github.com/JDB-NET/opnsense-sftp/compare/v1.1.0...v1.1.1) (2025-11-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* :bug: allow writing packages ([dbdeacd](https://github.com/JDB-NET/opnsense-sftp/commit/dbdeacdf7de133a0db4c44c13828458ff08a028a))
|
|
||||||
|
|
||||||
## [1.1.0](https://github.com/JDB-NET/opnsense-sftp/compare/v1.0.0...v1.1.0) (2025-11-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* :sparkles: initial commit ([07fc785](https://github.com/JDB-NET/opnsense-sftp/commit/07fc78592bc83e500ae0f3312d8a7bae9b0bf1f9))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* :bug: public host ip ([6dd09cf](https://github.com/JDB-NET/opnsense-sftp/commit/6dd09cf147f7a20856af1cfa68390586f6acc2e5))
|
|
||||||
* :bug: release please config ([89e1231](https://github.com/JDB-NET/opnsense-sftp/commit/89e12315fe69a64849068645048b01c871165532))
|
|
||||||
+3
-5
@@ -1,11 +1,9 @@
|
|||||||
FROM python:3.13-slim
|
FROM python:3.13-slim
|
||||||
|
LABEL org.opencontainers.image.vendor="JDB-NET"
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Build argument for version
|
|
||||||
ARG VERSION=dev
|
|
||||||
ENV APP_VERSION=${VERSION}
|
|
||||||
|
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
ARG VERSION=unknown
|
||||||
|
ENV APP_VERSION=${VERSION}
|
||||||
RUN pip install -r requirements.txt \
|
RUN pip install -r requirements.txt \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install curl -y \
|
&& apt-get install curl -y \
|
||||||
|
|||||||
@@ -36,17 +36,15 @@ docker run -d \
|
|||||||
-e SFTP_PUBLIC_PORT=30222 \
|
-e SFTP_PUBLIC_PORT=30222 \
|
||||||
-v /path/to/keys:/app/keys \
|
-v /path/to/keys:/app/keys \
|
||||||
-v /path/to/backups:/app/backups \
|
-v /path/to/backups:/app/backups \
|
||||||
ghcr.io/jdb-net/opnsense-sftp:latest
|
cr.jdbnet.co.uk/public/opnsense-sftp:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker Compose
|
### Docker Compose
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
opnsense-sftp:
|
opnsense-sftp:
|
||||||
image: ghcr.io/jdb-net/opnsense-sftp:latest
|
image: cr.jdbnet.co.uk/public/opnsense-sftp:latest
|
||||||
container_name: opnsense-sftp
|
container_name: opnsense-sftp
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -22,22 +22,8 @@ load_dotenv()
|
|||||||
setup_logging()
|
setup_logging()
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
# Read version from VERSION file or environment
|
|
||||||
def get_version():
|
def get_version():
|
||||||
"""Get application version from VERSION file or environment variable."""
|
return os.getenv('APP_VERSION', 'dev')
|
||||||
# Check environment variable first (set during Docker build)
|
|
||||||
env_version = os.getenv('APP_VERSION')
|
|
||||||
if env_version and env_version != 'dev':
|
|
||||||
return env_version
|
|
||||||
|
|
||||||
# Fall back to VERSION file
|
|
||||||
try:
|
|
||||||
version_path = Path(__file__).parent / 'VERSION'
|
|
||||||
if version_path.exists():
|
|
||||||
return version_path.read_text().strip()
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return 'dev'
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = os.getenv('SECRET_KEY', 'change-this-secret-key-in-production')
|
app.secret_key = os.getenv('SECRET_KEY', 'change-this-secret-key-in-production')
|
||||||
@@ -246,17 +232,74 @@ def instance_detail(instance_id):
|
|||||||
@app.route('/backups')
|
@app.route('/backups')
|
||||||
@login_required
|
@login_required
|
||||||
def backups():
|
def backups():
|
||||||
"""List all backups."""
|
"""List all backups with pagination and filtering."""
|
||||||
all_backups = db.get_all_backups()
|
all_backups = db.get_all_backups()
|
||||||
|
|
||||||
# Add instance info to each backup
|
# Add instance info to each backup
|
||||||
|
instances_map = {}
|
||||||
for backup in all_backups:
|
for backup in all_backups:
|
||||||
|
if backup['instance_id'] not in instances_map:
|
||||||
instance = db.get_instance_by_id(backup['instance_id'])
|
instance = db.get_instance_by_id(backup['instance_id'])
|
||||||
|
instances_map[backup['instance_id']] = instance
|
||||||
|
|
||||||
|
instance = instances_map.get(backup['instance_id'])
|
||||||
if instance:
|
if instance:
|
||||||
backup['instance_name'] = instance['name']
|
backup['instance_name'] = instance['name']
|
||||||
backup['instance_identifier'] = instance['identifier']
|
backup['instance_identifier'] = instance['identifier']
|
||||||
|
|
||||||
return render_template('backups.html', backups=all_backups)
|
# Get unique instances for filter dropdown
|
||||||
|
all_instances = []
|
||||||
|
seen_ids = set()
|
||||||
|
for backup in all_backups:
|
||||||
|
instance_id = backup['instance_id']
|
||||||
|
if instance_id not in seen_ids and backup.get('instance_name'):
|
||||||
|
all_instances.append({
|
||||||
|
'id': instance_id,
|
||||||
|
'name': backup['instance_name'],
|
||||||
|
'identifier': backup['instance_identifier']
|
||||||
|
})
|
||||||
|
seen_ids.add(instance_id)
|
||||||
|
|
||||||
|
# Sort instances by name
|
||||||
|
all_instances.sort(key=lambda x: x['name'])
|
||||||
|
|
||||||
|
# Get filter parameter from query string
|
||||||
|
filter_instance_id = request.args.get('instance_id', type=int)
|
||||||
|
|
||||||
|
# Filter backups if instance filter is applied
|
||||||
|
if filter_instance_id:
|
||||||
|
filtered_backups = [b for b in all_backups if b['instance_id'] == filter_instance_id]
|
||||||
|
else:
|
||||||
|
filtered_backups = all_backups
|
||||||
|
|
||||||
|
# Sort by upload date descending (newest first)
|
||||||
|
filtered_backups.sort(key=lambda x: x['uploaded_at'] or datetime.min, reverse=True)
|
||||||
|
|
||||||
|
# Pagination
|
||||||
|
page = request.args.get('page', 1, type=int)
|
||||||
|
per_page = 10
|
||||||
|
total_backups = len(filtered_backups)
|
||||||
|
total_pages = (total_backups + per_page - 1) // per_page
|
||||||
|
|
||||||
|
# Ensure page is valid
|
||||||
|
if page < 1:
|
||||||
|
page = 1
|
||||||
|
elif page > total_pages and total_pages > 0:
|
||||||
|
page = total_pages
|
||||||
|
|
||||||
|
# Get backups for current page
|
||||||
|
start_idx = (page - 1) * per_page
|
||||||
|
end_idx = start_idx + per_page
|
||||||
|
paginated_backups = filtered_backups[start_idx:end_idx]
|
||||||
|
|
||||||
|
return render_template('backups.html',
|
||||||
|
backups=paginated_backups,
|
||||||
|
all_instances=all_instances,
|
||||||
|
current_page=page,
|
||||||
|
total_pages=total_pages,
|
||||||
|
total_backups=total_backups,
|
||||||
|
filter_instance_id=filter_instance_id,
|
||||||
|
per_page=per_page)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/backups/<int:backup_id>/download')
|
@app.route('/backups/<int:backup_id>/download')
|
||||||
|
|||||||
+7
-7
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: opnsense-sftp
|
- name: opnsense-sftp
|
||||||
image: ghcr.io/jdb-net/opnsense-sftp:latest
|
image: cr.jdbnet.co.uk/public/opnsense-sftp:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
@@ -24,7 +24,7 @@ spec:
|
|||||||
name: "opnsense-sftp"
|
name: "opnsense-sftp"
|
||||||
env:
|
env:
|
||||||
- name: DB_HOST
|
- name: DB_HOST
|
||||||
value: "10.10.2.27"
|
value: "10.10.25.4"
|
||||||
- name: DB_PORT
|
- name: DB_PORT
|
||||||
value: "3306"
|
value: "3306"
|
||||||
- name: DB_NAME
|
- name: DB_NAME
|
||||||
@@ -38,7 +38,7 @@ spec:
|
|||||||
- name: ADMIN_PASSWORD
|
- name: ADMIN_PASSWORD
|
||||||
value: "CVk7QKIB3MjZ8mt6MxES"
|
value: "CVk7QKIB3MjZ8mt6MxES"
|
||||||
- name: SFTP_PUBLIC_HOST
|
- name: SFTP_PUBLIC_HOST
|
||||||
value: "10.10.2.29"
|
value: "10.10.25.8"
|
||||||
- name: SFTP_PUBLIC_PORT
|
- name: SFTP_PUBLIC_PORT
|
||||||
value: "30222"
|
value: "30222"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
@@ -49,12 +49,12 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: keys-volume
|
- name: keys-volume
|
||||||
nfs:
|
nfs:
|
||||||
server: 10.10.2.5
|
server: 10.10.25.2
|
||||||
path: /srv/Backups/OPNsense/keys
|
path: /srv/k3s/opnsense/keys
|
||||||
- name: backups-volume
|
- name: backups-volume
|
||||||
nfs:
|
nfs:
|
||||||
server: 10.10.2.5
|
server: 10.10.25.2
|
||||||
path: /srv/Backups/OPNsense/backups
|
path: /srv/k3s/opnsense/backups
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|||||||
+91
-1
@@ -9,9 +9,40 @@
|
|||||||
<p class="text-neutral-400">View and download your backup files</p>
|
<p class="text-neutral-400">View and download your backup files</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Filter Section -->
|
||||||
|
<div class="bg-neutral-800 rounded-lg border border-neutral-700 p-6">
|
||||||
|
<h2 class="text-lg font-bold text-neutral-100 mb-4">Filters</h2>
|
||||||
|
<form method="get" class="flex flex-col sm:flex-row gap-4">
|
||||||
|
<div class="flex-1">
|
||||||
|
<label for="instance_id" class="block text-sm font-medium text-neutral-300 mb-2">Instance</label>
|
||||||
|
<select id="instance_id" name="instance_id" class="w-full px-4 py-2 bg-neutral-700 border border-neutral-600 rounded-md text-neutral-100 focus:outline-none focus:border-orange-500 transition-colors">
|
||||||
|
<option value="">All Instances</option>
|
||||||
|
{% for instance in all_instances %}
|
||||||
|
<option value="{{ instance.id }}" {% if filter_instance_id == instance.id %}selected{% endif %}>
|
||||||
|
{{ instance.name }}
|
||||||
|
</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2 sm:self-end">
|
||||||
|
<button type="submit" class="px-4 py-2 bg-orange-600 hover:bg-orange-500 text-white rounded-md text-sm font-medium transition-colors hover:cursor-pointer">
|
||||||
|
Apply Filter
|
||||||
|
</button>
|
||||||
|
{% if filter_instance_id %}
|
||||||
|
<a href="{{ url_for('backups') }}" class="px-4 py-2 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded-md text-sm font-medium transition-colors">
|
||||||
|
Clear Filter
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="bg-neutral-800 rounded-lg border border-neutral-700 overflow-hidden">
|
<div class="bg-neutral-800 rounded-lg border border-neutral-700 overflow-hidden">
|
||||||
<div class="px-6 py-4 border-b border-neutral-700">
|
<div class="px-6 py-4 border-b border-neutral-700 flex justify-between items-center">
|
||||||
<h2 class="text-xl font-bold text-neutral-100">Backup Files</h2>
|
<h2 class="text-xl font-bold text-neutral-100">Backup Files</h2>
|
||||||
|
{% if total_backups > 0 %}
|
||||||
|
<span class="text-sm text-neutral-400">{{ total_backups }} backup{% if total_backups != 1 %}s{% endif %}</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<table class="w-full">
|
<table class="w-full">
|
||||||
@@ -51,7 +82,11 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="px-6 py-8 text-center text-neutral-400">
|
<td colspan="5" class="px-6 py-8 text-center text-neutral-400">
|
||||||
|
{% if filter_instance_id %}
|
||||||
|
No backups found for the selected instance.
|
||||||
|
{% else %}
|
||||||
No backups found. Configure your OPNsense instances to start receiving backups.
|
No backups found. Configure your OPNsense instances to start receiving backups.
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -59,6 +94,61 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Pagination -->
|
||||||
|
{% if total_pages > 1 %}
|
||||||
|
<div class="bg-neutral-800 rounded-lg border border-neutral-700 p-6">
|
||||||
|
<div class="flex flex-col sm:flex-row gap-4 items-center justify-between">
|
||||||
|
<div class="text-sm text-neutral-400">
|
||||||
|
Page <span class="font-bold text-neutral-100">{{ current_page }}</span> of <span class="font-bold text-neutral-100">{{ total_pages }}</span>
|
||||||
|
({{ (current_page - 1) * per_page + 1 }}-{{ [current_page * per_page, total_backups]|min }} of {{ total_backups }} backups)
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-2 flex-wrap justify-center">
|
||||||
|
{% if current_page > 1 %}
|
||||||
|
<a href="{{ url_for('backups', page=1, instance_id=filter_instance_id or '') }}" class="px-3 py-2 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded-md text-sm transition-colors">
|
||||||
|
First
|
||||||
|
</a>
|
||||||
|
<a href="{{ url_for('backups', page=current_page - 1, instance_id=filter_instance_id or '') }}" class="px-3 py-2 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded-md text-sm transition-colors">
|
||||||
|
Previous
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Page Numbers -->
|
||||||
|
{% set start_page = [current_page - 2, 1]|max %}
|
||||||
|
{% set end_page = [current_page + 2, total_pages]|min %}
|
||||||
|
|
||||||
|
{% if start_page > 1 %}
|
||||||
|
<span class="px-3 py-2 text-neutral-400">...</span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for page_num in range(start_page, end_page + 1) %}
|
||||||
|
{% if page_num == current_page %}
|
||||||
|
<button class="px-3 py-2 bg-orange-600 text-white rounded-md text-sm font-medium">
|
||||||
|
{{ page_num }}
|
||||||
|
</button>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ url_for('backups', page=page_num, instance_id=filter_instance_id or '') }}" class="px-3 py-2 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded-md text-sm transition-colors">
|
||||||
|
{{ page_num }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if end_page < total_pages %}
|
||||||
|
<span class="px-3 py-2 text-neutral-400">...</span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if current_page < total_pages %}
|
||||||
|
<a href="{{ url_for('backups', page=current_page + 1, instance_id=filter_instance_id or '') }}" class="px-3 py-2 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded-md text-sm transition-colors">
|
||||||
|
Next
|
||||||
|
</a>
|
||||||
|
<a href="{{ url_for('backups', page=total_pages, instance_id=filter_instance_id or '') }}" class="px-3 py-2 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded-md text-sm transition-colors">
|
||||||
|
Last
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
+48
-5
@@ -7,18 +7,19 @@
|
|||||||
<link rel="icon" type="image/png" href="{{ url_for('static', filename='opnsense.png') }}">
|
<link rel="icon" type="image/png" href="{{ url_for('static', filename='opnsense.png') }}">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-neutral-900 text-neutral-100 min-h-screen">
|
<body class="bg-neutral-900 text-neutral-100 min-h-screen flex flex-col">
|
||||||
<nav class="bg-neutral-800 border-b border-neutral-700">
|
<nav class="bg-neutral-800 border-b border-neutral-700">
|
||||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||||
<div class="flex justify-between h-16">
|
<div class="flex justify-between h-16">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<a href="{{ url_for('dashboard') }}" class="flex items-center space-x-4">
|
<a href="{{ url_for('dashboard') }}" class="flex items-center space-x-4">
|
||||||
<img src="{{ url_for('static', filename='opnsense.png') }}" alt="OPNsense" class="h-8 w-8">
|
<img src="{{ url_for('static', filename='opnsense.png') }}" alt="OPNsense" class="h-8 w-8">
|
||||||
<span class="text-neutral-400">Backup Manager</span>
|
<span class="text-neutral-400 hidden sm:inline">Backup Manager</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% if session.user_id %}
|
{% if session.user_id %}
|
||||||
<div class="flex items-center space-x-4">
|
<!-- Desktop Navigation -->
|
||||||
|
<div class="hidden md:flex items-center space-x-4">
|
||||||
<a href="{{ url_for('dashboard') }}" class="text-neutral-300 hover:text-orange-500 px-3 py-2 rounded-md text-sm font-medium transition-colors">
|
<a href="{{ url_for('dashboard') }}" class="text-neutral-300 hover:text-orange-500 px-3 py-2 rounded-md text-sm font-medium transition-colors">
|
||||||
Dashboard
|
Dashboard
|
||||||
</a>
|
</a>
|
||||||
@@ -34,12 +35,42 @@
|
|||||||
Logout
|
Logout
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Mobile Menu Button -->
|
||||||
|
<div class="md:hidden flex items-center">
|
||||||
|
<button id="mobile-menu-btn" class="inline-flex items-center justify-center p-2 rounded-md text-neutral-300 hover:text-orange-500 hover:bg-neutral-700 focus:outline-none transition-colors">
|
||||||
|
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Mobile Navigation Menu -->
|
||||||
|
{% if session.user_id %}
|
||||||
|
<div id="mobile-menu" class="hidden md:hidden pb-4 space-y-1">
|
||||||
|
<a href="{{ url_for('dashboard') }}" class="block text-neutral-300 hover:text-orange-500 px-3 py-2 rounded-md text-sm font-medium transition-colors hover:bg-neutral-700">
|
||||||
|
Dashboard
|
||||||
|
</a>
|
||||||
|
<a href="{{ url_for('instances') }}" class="block text-neutral-300 hover:text-orange-500 px-3 py-2 rounded-md text-sm font-medium transition-colors hover:bg-neutral-700">
|
||||||
|
Instances
|
||||||
|
</a>
|
||||||
|
<a href="{{ url_for('backups') }}" class="block text-neutral-300 hover:text-orange-500 px-3 py-2 rounded-md text-sm font-medium transition-colors hover:bg-neutral-700">
|
||||||
|
Backups
|
||||||
|
</a>
|
||||||
|
<div class="border-t border-neutral-700 pt-2 mt-2">
|
||||||
|
<div class="px-3 py-2 text-sm text-neutral-400">{{ session.username }}</div>
|
||||||
|
<a href="{{ url_for('logout') }}" class="block text-neutral-300 hover:text-orange-500 px-3 py-2 rounded-md text-sm font-medium transition-colors hover:bg-neutral-700">
|
||||||
|
Logout
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
<main class="flex-grow max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 w-full">
|
||||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
<div class="mb-6 space-y-2">
|
<div class="mb-6 space-y-2">
|
||||||
@@ -60,11 +91,23 @@
|
|||||||
<p class="text-center text-neutral-400 text-sm">
|
<p class="text-center text-neutral-400 text-sm">
|
||||||
OPNsense Backup Manager
|
OPNsense Backup Manager
|
||||||
{% if version %}
|
{% if version %}
|
||||||
<span class="text-neutral-500">v{{ version }}</span>
|
<span class="text-neutral-500">{{ version }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Mobile menu toggle
|
||||||
|
const mobileMenuBtn = document.getElementById('mobile-menu-btn');
|
||||||
|
const mobileMenu = document.getElementById('mobile-menu');
|
||||||
|
|
||||||
|
if (mobileMenuBtn && mobileMenu) {
|
||||||
|
mobileMenuBtn.addEventListener('click', function() {
|
||||||
|
mobileMenu.classList.toggle('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user