Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
kazet committed Jan 12, 2024
1 parent 42e74bd commit 7ed1f39
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
6 changes: 4 additions & 2 deletions karton/dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ class KartonDashboard(KartonBase):
graph_folder = app_path / "graph"
app = Flask(__name__, static_folder=None)
blueprint = Blueprint(
"karton-dashboard", __name__, template_folder=str(app_path / "templates")
"dashboard", __name__, template_folder=str(app_path / "templates")
)
app.register_blueprint(blueprint, url_prefix=base_path)


markdown = mistune.create_markdown(
Expand Down Expand Up @@ -405,3 +404,6 @@ def generate_graph():
raw_graph = graph.generate_graph()

return raw_graph


app.register_blueprint(blueprint, url_prefix=base_path)
4 changes: 2 additions & 2 deletions karton/dashboard/templates/analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ <h4>Tasks</h4>
{% for task in queue.pending_tasks %}
<tr>
<td>
<a href="{{ url_for("get_queue", queue_name=identity) }}">{{identity}}</a>
<a href="{{ url_for('dashboard.get_queue', queue_name=identity) }}">{{identity}}</a>
</td>
<td>
<a href="{{ url_for("get_task", task_id=task.uid) }}">{{ task.uid }}</a>
<a href="{{ url_for('dashboard.get_task', task_id=task.uid) }}">{{ task.uid }}</a>
</td>
<td>
{% if task.priority.value != 'normal' %}
Expand Down
10 changes: 5 additions & 5 deletions karton/dashboard/templates/crashed.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ <h4>
<span class="align-middle">Crashed tasks</span>
{% if queue.crashed_tasks %}
<div class="btn-group float-right">
<form action={{url_for("restart_crashed_queue_tasks", queue_name=name)}} method="POST">
<form action={{url_for('dashboard.restart_crashed_queue_tasks', queue_name=name)}} method="POST">
<button class="btn btn-sm btn-danger mx-1" type="submit" value="Submit" title="restart all tasks">Restart all</button>
</form>
<div class="divider"></div>
<form action={{url_for("cancel_crashed_queue_tasks", queue_name=name)}} method="POST" id="cancelQueue">
<form action={{url_for('dashboard.cancel_crashed_queue_tasks', queue_name=name)}} method="POST" id="cancelQueue">
<button class="btn btn-sm btn-danger" type="submit" form="cancelQueue" value="Submit" title="cancel all tasks">Cancel all</button>
</form>
</div>
Expand All @@ -28,7 +28,7 @@ <h4>
{% for task in queue.crashed_tasks|sort(attribute='last_update', reverse=True) %}
<tr>
<td>
<a href="{{url_for("get_task", task_id=task.uid)}}">{{ task.uid }}</a>
<a href="{{url_for('dashboard.get_task', task_id=task.uid)}}">{{ task.uid }}</a>
</td>
<td><pre>{{ task.last_update|render_timestamp }}</pre></td>
<td>
Expand All @@ -54,15 +54,15 @@ <h4>
</td>
<td>
<div class="btn-group">
<form action={{url_for("restart_task", task_id=task.uid)}} method="POST">
<form action={{url_for('dashboard.restart_task', task_id=task.uid)}} method="POST">
<button class="btn btn-info mx-1" type="submit" value="Submit" title="restart task">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"/>
<path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z"/>
</svg>
</button>
</form>
<form action={{url_for("cancel_task", task_id=task.uid)}} method="POST">
<form action={{url_for('dashboard.cancel_task', task_id=task.uid)}} method="POST">
<button class="btn btn-danger" type="submit" value="Submit" title="cancel task">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16">
<path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1H2.5zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zM8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5zm3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0z"/>
Expand Down
4 changes: 2 additions & 2 deletions karton/dashboard/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h3 class="text-center">binds</h3>
{% for (queue_name, queue) in queues|dictsort %}
<tr>
<td>
<a href="{{url_for("get_queue", queue_name=queue_name)}}">{{ queue_name }}</a>
<a href="{{url_for('dashboard.get_queue', queue_name=queue_name)}}">{{ queue_name }}</a>
<div>
<span class="badge bg-info" title="karton-core library version">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-seam" viewBox="0 0 16 16">
Expand Down Expand Up @@ -67,7 +67,7 @@ <h3 class="text-center">binds</h3>
</td>
<td>
{% set length = queue.crashed_tasks | length %}
{% set url = url_for("get_crashed_queue", queue_name=queue_name) %}
{% set url = url_for('dashboard.get_crashed_queue', queue_name=queue_name) %}
{% set badgeClass = "bg-success" if length == 0 else "bg-danger" %}
<span class="badge {{badgeClass}}">
<a class="text-decoration-none" href={{url}} style="color: inherit">{{length}}</a>
Expand Down
12 changes: 6 additions & 6 deletions karton/dashboard/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>{% block title %}karton-dashboard{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', path='bootstrap.css') }}">
<link rel="shortcut icon" href="{{ url_for('static', path='favicon.ico') }}">
<link rel="stylesheet" href="{{ url_for('dashboard.static', path='bootstrap.css') }}">
<link rel="shortcut icon" href="{{ url_for('dashboard.static', path='favicon.ico') }}">
</head>

<body>
<div class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a href="{{ url_for("get_queues") }}" class="navbar-brand">karton</a>
<a href="{{ url_for('dashboard.get_queues') }}" class="navbar-brand">karton</a>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{{ url_for("get_queues") }}">home</a>
<a class="nav-link" href="{{ url_for('dashboard.get_queues') }}">home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for("get_services") }}">services</a>
<a class="nav-link" href="{{ url_for('dashboard.get_services') }}">services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for("get_graph") }}">graph</a>
<a class="nav-link" href="{{ url_for('dashboard.get_graph') }}">graph</a>
</li>
</ul>
</div>
Expand Down
6 changes: 3 additions & 3 deletions karton/dashboard/templates/queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h4>
<span class="align-middle">Tasks</span>
{% if queue.pending_tasks %}
<div class="btn-group float-right">
<form action={{url_for("cancel_pending_queue_tasks", queue_name=name)}} method="POST" id="cancelQueue">
<form action={{url_for('dashboard.cancel_pending_queue_tasks', queue_name=name)}} method="POST" id="cancelQueue">
<button class="btn btn-sm btn-secondary" type="submit" form="cancelQueue" value="Submit" title="cancel all tasks">Cancel all</button>
</form>
</div>
Expand All @@ -23,7 +23,7 @@ <h4>
{% for task in queue.pending_tasks|sort(attribute='last_update', reverse=True) %}
<tr>
<td>
<a href="{{ url_for("get_task", task_id=task.uid) }}">{{ task.uid }}</a>
<a href="{{ url_for('dashboard.get_task', task_id=task.uid) }}">{{ task.uid }}</a>
</td>
<td><pre>{{ task.last_update|render_timestamp }}</pre></td>
<td>
Expand All @@ -46,7 +46,7 @@ <h4>
</td>
<td>
<div class="btn-group">
<form action={{url_for("cancel_task", task_id=task.uid)}} method="POST">
<form action={{url_for('dashboard.cancel_task', task_id=task.uid)}} method="POST">
<button class="btn btn-dark" type="submit" value="Submit" title="cancel task"></button>
</form>
</div>
Expand Down
4 changes: 2 additions & 2 deletions karton/dashboard/templates/queue_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h3 class="text-center">queue {{ name }}</h3>
<span class="badge bg-danger">no</span>
{% endif %}
</dd>
<dt class="col-3"><a href={{url_for("get_queue", queue_name=name)}}>Spawned tasks</a></dt>
<dt class="col-3"><a href={{url_for('dashboard.get_queue', queue_name=name)}}>Spawned tasks</a></dt>
<dd class="col-9">
{% set length = queue.pending_tasks | length %}
{% if length == 0 %}
Expand All @@ -57,7 +57,7 @@ <h3 class="text-center">queue {{ name }}</h3>
<span class="badge bg-danger">{{length}}</span>
{% endif %}
</dd>
<dt class="col-3"><a href={{url_for("get_crashed_queue", queue_name=name)}}>Crashed tasks</a></dt>
<dt class="col-3"><a href={{url_for('dashboard.get_crashed_queue', queue_name=name)}}>Crashed tasks</a></dt>
<dd class="col-9">
{% if queue.crashed_tasks | length > 0 %}
<span class="badge bg-danger">{{queue.crashed_tasks | length}}</span>
Expand Down
6 changes: 3 additions & 3 deletions karton/dashboard/templates/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ <h3 class="text-center">task <code>{{ task.uid }}</code></h3>
<dd class="col-9">{{task.parent_uid}}</dd>
<dt class="col-3">Root UID</dt>
<dd class="col-9">
<a href="{{url_for('get_analysis', root_id=task.root_uid)}}">
<a href="{{url_for('dashboard.get_analysis', root_id=task.root_uid)}}">
{{task.root_uid}}
</a>
</dd>
<dt class="col-3">Origin</dt>
<dd class="col-9">
<a href="{{url_for("get_queue", queue_name=task.headers['origin'])}}">{{task.headers['origin']}}</a>
<a href="{{url_for('dashboard.get_queue', queue_name=task.headers['origin'])}}">{{task.headers['origin']}}</a>
</dd>
<dt class="col-3">Receiver</dt>
<dd class="col-9">
<a href="{{url_for("get_queue", queue_name=task.headers['receiver'])}}">{{task.headers['receiver']}}</a>
<a href="{{url_for('dashboard.get_queue', queue_name=task.headers['receiver'])}}">{{task.headers['receiver']}}</a>
</dd>
<dt class="col-3">Xrefs</dt>
<dd class="col-9">
Expand Down

0 comments on commit 7ed1f39

Please sign in to comment.