roundabout,
created on Sunday, 7 April 2024, 07:43:47 (1712475827),
received on Sunday, 7 April 2024, 12:44:08 (1712493848)
Author identity: vlad <vlad.muntoiu@gmail.com>
85736ee7cefe9d5c4420f5ab9f79ed611c4e02d8
.idea/workspace.xml
@@ -4,14 +4,13 @@
<option name="autoReloadType" value="SELECTIVE" /> </component> <component name="ChangeListManager"> <list default="true" id="411335b4-e813-41ad-9046-18b77b97ee46" name="Changes" comment="Fix minute recording bug"><change afterPath="$PROJECT_DIR$/static/bugs.svg" afterDir="false" /><change afterPath="$PROJECT_DIR$/static/logo.svg" afterDir="false" /><change afterPath="$PROJECT_DIR$/templates/my-apps.html" afterDir="false" /><list default="true" id="411335b4-e813-41ad-9046-18b77b97ee46" name="Changes" comment="Add better slicing and uptime management"><change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/static/style.css" beforeDir="false" afterPath="$PROJECT_DIR$/static/style.css" afterDir="false" /> <change beforePath="$PROJECT_DIR$/templates/app-editor.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/app-editor.html" afterDir="false" /><change beforePath="$PROJECT_DIR$/templates/app.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/app.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/templates/dashboard.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/dashboard.html" afterDir="false" /></list> <option name="SHOW_DIALOG" value="false" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -118,7 +117,15 @@
<option name="project" value="LOCAL" /> <updated>1712465435852</updated> </task> <option name="localTasksCounter" value="7" /><task id="LOCAL-00007" summary="Add better slicing and uptime management"> <option name="closed" value="true" /> <created>1712471462120</created> <option name="number" value="00007" /> <option name="presentableId" value="LOCAL-00007" /> <option name="project" value="LOCAL" /> <updated>1712471462120</updated> </task> <option name="localTasksCounter" value="8" /><servers /> </component> <component name="Vcs.Log.Tabs.Properties">
@@ -139,6 +146,7 @@
<MESSAGE value="Save ping results" /> <MESSAGE value="Do it" /> <MESSAGE value="Fix minute recording bug" /> <option name="LAST_COMMIT_MESSAGE" value="Fix minute recording bug" /><MESSAGE value="Add better slicing and uptime management" /> <option name="LAST_COMMIT_MESSAGE" value="Add better slicing and uptime management" /></component> </project>
app.py
@@ -70,6 +70,7 @@ with (app.app_context()):
owner = db.relationship("User", back_populates="applications") endpoints = db.relationship("Endpoint", back_populates="application") stability_threshold = db.Column(db.Integer, default=15)def __init__(self, name, owner): self.name = name
@@ -155,7 +156,9 @@ def default():
@app.route("/") def dashboard(): return flask.render_template("dashboard.html", apps=Application.query.all())current_user = db.session.get(User, flask.session.get("username")) return flask.render_template("dashboard.html", apps=Application.query.all(), bugs=Endpoint.query.filter_by(buggy=True).filter(Application.owner_name == current_user.username).all())@app.route("/my")
@@ -275,10 +278,9 @@ def app_info(app_id):
) ) for endpoint in app_.endpoints:all_results.extend(db.session.query(Status).filter( sqlalchemy.and_(Status.endpoint_id == endpoint.id, Status.time >= datetime.datetime.utcnow() - datetime.timedelta(minutes=10),Status.time >= datetime.datetime.utcnow() - datetime.timedelta(minutes=app_.stability_threshold),Status.time < datetime.datetime.utcnow())).all()) return flask.render_template("app.html", app=app_, sorted=sorted, list=list,
@@ -303,6 +305,27 @@ def app_editor(app_id):
return flask.render_template("app-editor.html", app=app_) @app.route("/app/<int:app_id>/edit/", methods=["POST"]) def app_editor_post(app_id): if flask.session.get("username") != db.session.get(Application, app_id).owner_name: flask.abort(403) app_ = db.session.get(Application, app_id) if flask.request.form.get("delete") == "delete": endpoints = db.session.query(Endpoint).filter_by(application_id=app_id).all() for endpoint in endpoints: statuses = db.session.query(Status).filter_by(endpoint_id=endpoint.id).all() for status in statuses: db.session.delete(status) db.session.delete(endpoint) db.session.delete(app_) db.session.commit() else: app_.name = flask.request.form["name"] app_.stability_threshold = min(300, int(flask.request.form["theshold"])) db.session.commit() return flask.redirect("/", code=303) @app.route("/app/<int:app_id>/edit/<int:endpoint_id>", methods=["POST"]) def endpoint_edit(app_id, endpoint_id): if flask.session.get("username") != db.session.get(Application, app_id).owner_name:
static/style.css
@@ -342,3 +342,13 @@ label > input {
background-repeat: no-repeat; background-position: center; } a { color: #00695C; text-decoration: none; } a:not(.quiet-link):hover { text-decoration: underline; }
templates/app-editor.html
@@ -3,7 +3,16 @@
{% block content %} <main> <h1>Editing {{ app.name }}</h1> <h2>General</h2> <form class="stacked-form" method="post" action="/app/{{ app.id }}/edit/"> <input type="text" name="name" placeholder="Name" value="{{ app.name }}"> <label> Stability threshold (minutes) <input type="number" name="threshold" value="{{ app.stability_threshold }}" step="1" min="1" max="300"> </label> <button type="submit">Apply changes</button> </form> <h2>Endpoints</h2><div id="endpoint-editor"> {% for endpoint in app.endpoints %} <form class="stacked-form" method="post" action="/app/{{ app.id }}/edit/{{ endpoint.id }}">
templates/app.html
@@ -11,6 +11,7 @@
{% else %} Down {% endif %} (last {{ app.stability_threshold }} minutes)</h2> <p>Owner: {{ app.owner_name }}</p> {% if session.get("username") == app.owner_name %}
templates/dashboard.html
@@ -5,6 +5,15 @@
<main> <h1>Dashboard</h1> {% if session.get("username") %} {% if bugs %} <h2>Endpoints with reported bugs</h2> {% endif %} {% for bug in bugs %} <div class="alert alert-{{ bug.level }}"> <a href="/app/{{ bug.application.id }}/">{{ bug.application.name }}</a> - {{ bug.name }} </div> {% endfor %}<a class="button" style="width:100%; margin: 1em 0;" tabindex="0" href="/new-app"> <iconify-icon icon="mdi:plus"></iconify-icon> Create an app