Added images to settings page.
This commit is contained in:
parent
c9b86e846b
commit
79276d9255
2 changed files with 25 additions and 3 deletions
|
@ -5,8 +5,8 @@ from flask import request, flash, redirect, url_for, render_template, jsonify
|
|||
|
||||
from . import main
|
||||
from .. import db
|
||||
from ..models import Brand, Item, Area, RoomFunction, Room
|
||||
from ..utils.load import eager_load_room_relationships
|
||||
from ..models import Brand, Item, Area, RoomFunction, Room, Image
|
||||
from ..utils.load import eager_load_room_relationships, chunk_list
|
||||
|
||||
@main.route('/settings', methods=['GET', 'POST'])
|
||||
def settings():
|
||||
|
@ -66,6 +66,7 @@ def settings():
|
|||
sections = db.session.query(Area).order_by(Area.name).all()
|
||||
functions = db.session.query(RoomFunction).order_by(RoomFunction.description).all()
|
||||
rooms = eager_load_room_relationships(db.session.query(Room).order_by(Room.name)).all()
|
||||
images = chunk_list(db.session.query(Image).order_by(Image.timestamp).all(), 6)
|
||||
|
||||
return render_template('settings.html',
|
||||
title="Settings",
|
||||
|
@ -73,7 +74,8 @@ def settings():
|
|||
types=[{"id": t.id, "name": t.description} for t in types],
|
||||
sections=[s.serialize() for s in sections],
|
||||
functions=[f.serialize() for f in functions],
|
||||
rooms=[r.serialize() for r in rooms]
|
||||
rooms=[r.serialize() for r in rooms],
|
||||
image_list=images
|
||||
)
|
||||
|
||||
@main.route("/api/settings", methods=["POST"])
|
||||
|
|
|
@ -119,6 +119,10 @@
|
|||
<button class="nav-link" id="location-tab" data-bs-toggle="tab" data-bs-target="#location-tab-pane"
|
||||
type="button">Location</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="nav-link" id="photo-tab" data-bs-toggle="tab" data-bs-target="#images-tab-pane"
|
||||
type="button">Images</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="tabContent">
|
||||
<div class="tab-pane fade show active border border-top-0 p-3" id="inventory-tab-pane">
|
||||
|
@ -195,6 +199,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade border border-top-0 p-3" id="images-tab-pane">
|
||||
<div class="container border rounded" style="max-height: 60vh; overflow-y: auto;">
|
||||
{% for chunk in image_list %}
|
||||
<div class="row my-3">
|
||||
{% for image in chunk %}
|
||||
<div class="col mx-3">
|
||||
{{ images.render_image(
|
||||
id=image.id,
|
||||
image=image
|
||||
) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="roomEditor" data-bs-backdrop="static" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue