Add links to spoolman

This commit is contained in:
Filip Bednárik 2024-12-15 19:34:45 +01:00
parent 32f90cfe84
commit 890eaf9725
4 changed files with 11 additions and 5 deletions

View File

@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.1.1'

12
app.py
View File

@ -4,7 +4,7 @@ import uuid
from flask import Flask, request, render_template, redirect, url_for
from config import BASE_URL, AUTO_SPEND
from config import BASE_URL, AUTO_SPEND, SPOOLMAN_BASE_URL
from filament import generate_filament_brand_code, generate_filament_temperatures
from frontend_utils import color_is_dark
from messages import AMS_FILAMENT_SETTING
@ -14,6 +14,10 @@ from spoolman_service import augmentTrayDataWithSpoolMan, trayUid
app = Flask(__name__)
@app.context_processor
def fronted_utilities():
return dict(SPOOLMAN_BASE_URL=SPOOLMAN_BASE_URL, AUTO_SPEND=AUTO_SPEND, color_is_dark=color_is_dark, BASE_URL=BASE_URL)
@app.route("/spool_info")
def spool_info():
try:
@ -40,7 +44,7 @@ def spool_info():
current_spool = spool
# TODO: missing current_spool
return render_template('spool_info.html', tag_id=tag_id, current_spool=current_spool, ams_data=ams_data, vt_tray_data=vt_tray_data, color_is_dark=color_is_dark, AUTO_SPEND=AUTO_SPEND)
return render_template('spool_info.html', tag_id=tag_id, current_spool=current_spool, ams_data=ams_data, vt_tray_data=vt_tray_data)
except Exception as e:
traceback.print_exc()
return render_template('error.html', exception=str(e))
@ -116,7 +120,7 @@ def home():
augmentTrayDataWithSpoolMan(spool_list, tray, trayUid(ams["id"], tray["id"]))
issue |= tray["issue"]
return render_template('index.html', success_message=success_message, ams_data=ams_data, vt_tray_data=vt_tray_data, color_is_dark=color_is_dark, AUTO_SPEND=AUTO_SPEND, issue=issue)
return render_template('index.html', success_message=success_message, ams_data=ams_data, vt_tray_data=vt_tray_data, issue=issue)
except Exception as e:
traceback.print_exc()
return render_template('error.html', exception=str(e))
@ -144,7 +148,7 @@ def write_tag():
patchExtraTags(spool_id, {}, {
"tag": json.dumps(myuuid),
})
return render_template('write_tag.html', myuuid=myuuid, BASE_URL=BASE_URL)
return render_template('write_tag.html', myuuid=myuuid)
except Exception as e:
traceback.print_exc()
return render_template('error.html', exception=str(e))

View File

@ -28,6 +28,7 @@
<ul class="nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0">
<li><a href="{{ url_for('home') }}" class="nav-link px-2 link-body-emphasis">Home</a></li>
<li><a href="{{ url_for('assign_tag') }}" class="nav-link px-2 link-body-emphasis">Assign NFC Tag</a></li>
<li><a href="{{ SPOOLMAN_BASE_URL }}" target="_blank" class="nav-link px-2 link-body-emphasis">SpoolMan</a></li>
</ul>
</div>
</div>

View File

@ -28,6 +28,7 @@
</div>
<div class="col-6">
<p class="mb-1"><strong>Nozzle Temp:</strong> {{ current_spool.filament.extra.nozzle_temperature }}</p>
<p class="mb-1"><a href="{{ SPOOLMAN_BASE_URL }}/spool/show/{{ current_spool.id }}" target="_blank">view in spoolman <i class="bi bi-box-arrow-up-right"></i></a></p>
</div>
</div>
</div>