portal/storage: expose storage information via the portal
This commit is contained in:
parent
1ee75fd37f
commit
293acba317
6 changed files with 121 additions and 7 deletions
|
@ -4,11 +4,12 @@ from typing import Optional
|
|||
from flask import render_template, flash, Response, Blueprint, current_app
|
||||
from flask.typing import ResponseReturnValue
|
||||
from flask_wtf import FlaskForm
|
||||
from sqlalchemy import exc
|
||||
from sqlalchemy import exc, desc
|
||||
from wtforms import SubmitField, BooleanField
|
||||
|
||||
from app.extensions import db
|
||||
from app.models.automation import Automation, AutomationLogs
|
||||
from app.models.tfstate import TerraformState
|
||||
from app.portal.util import view_lifecycle, response_404
|
||||
|
||||
bp = Blueprint("automation", __name__)
|
||||
|
@ -27,16 +28,17 @@ class EditAutomationForm(FlaskForm): # type: ignore
|
|||
|
||||
@bp.route("/list")
|
||||
def automation_list() -> ResponseReturnValue:
|
||||
automations = Automation.query.filter(
|
||||
Automation.destroyed.is_(None)).order_by(Automation.description).all()
|
||||
automations = list(filter(
|
||||
lambda a: a.short_name not in current_app.config.get('HIDDEN_AUTOMATIONS', []),
|
||||
automations
|
||||
Automation.query.filter(
|
||||
Automation.destroyed.is_(None)).order_by(Automation.description).all()
|
||||
))
|
||||
states = {tfs.key: tfs for tfs in TerraformState.query.all()}
|
||||
return render_template("list.html.j2",
|
||||
title="Automation Jobs",
|
||||
item="automation",
|
||||
items=automations,
|
||||
states=states,
|
||||
**_SECTION_TEMPLATE_VARS)
|
||||
|
||||
|
||||
|
@ -58,7 +60,8 @@ def automation_edit(automation_id: int) -> ResponseReturnValue:
|
|||
flash("Saved changes to bridge configuration.", "success")
|
||||
except exc.SQLAlchemyError:
|
||||
flash("An error occurred saving the changes to the bridge configuration.", "danger")
|
||||
logs = AutomationLogs.query.filter(AutomationLogs.automation_id == automation.id).order_by(AutomationLogs.added).all()
|
||||
logs = AutomationLogs.query.filter(AutomationLogs.automation_id == automation.id).order_by(
|
||||
desc(AutomationLogs.added)).limit(5).all()
|
||||
return render_template("automation.html.j2",
|
||||
automation=automation,
|
||||
logs=logs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue