Add home dashboard and Mithril rendering support
- Create new home route with comprehensive dashboard statistics - Implement Mithril rendering support with new `mithril_loader.html` template - Add new routes for home and test pages in `app.py` - Create `lib/mithril.py` with Mithril rendering and error handling utilities - Update dashboard template to use new home route - Add detailed dashboard view with timer and HTTP function statistics
This commit is contained in:
48
routes/test.py
Normal file
48
routes/test.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash, request, jsonify
|
||||
from jinja2_fragments import render_block
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from flask_login import current_user, login_required
|
||||
from extensions import db, htmx, environment
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from lib.mithril import Mithril
|
||||
import json
|
||||
|
||||
test = Blueprint('test', __name__)
|
||||
|
||||
@test.route('/mithril/<int:function_id>')
|
||||
@login_required
|
||||
def mithril(function_id):
|
||||
# Fetch the timer function to verify ownership
|
||||
timer_function = db.execute("""
|
||||
SELECT id, name, code, version_number
|
||||
FROM timer_functions
|
||||
WHERE id = %s AND user_id = %s
|
||||
""", [function_id, current_user.id], one=True)
|
||||
|
||||
if not timer_function:
|
||||
flash('Timer function not found', 'error')
|
||||
return redirect(url_for('timer.overview'))
|
||||
|
||||
# Fetch all versions
|
||||
versions = db.execute("""
|
||||
SELECT version_number, script, versioned_at
|
||||
FROM timer_function_versions
|
||||
WHERE timer_function_id = %s
|
||||
ORDER BY version_number DESC
|
||||
""", [function_id])
|
||||
|
||||
# Convert datetime objects to ISO format strings
|
||||
for version in versions:
|
||||
version['versioned_at'] = version['versioned_at'].isoformat() if version['versioned_at'] else None
|
||||
|
||||
args = {
|
||||
'user_id': current_user.id,
|
||||
'function_id': function_id,
|
||||
'timer_function': timer_function,
|
||||
'versions': versions
|
||||
}
|
||||
|
||||
return Mithril.render('DiffView', args)
|
||||
|
||||
#return render_template('mithril_loader.html', args=args)
|
||||
|
||||
Reference in New Issue
Block a user