mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
Merge branch 'autorefresh' into 'main'
✨ — Add autorefresh feature on dashboard
See merge request framasoft/framaspace/argos!21
This commit is contained in:
commit
20062fc683
4 changed files with 75 additions and 12 deletions
|
@ -18,7 +18,12 @@ templates = Jinja2Templates(directory="argos/server/templates")
|
||||||
|
|
||||||
|
|
||||||
@route.get("/")
|
@route.get("/")
|
||||||
async def get_severity_counts(request: Request, db: Session = Depends(get_db)):
|
async def get_severity_counts(
|
||||||
|
request: Request,
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
refresh: bool = False,
|
||||||
|
delay: int = 15
|
||||||
|
):
|
||||||
"""Shows the number of results per severity"""
|
"""Shows the number of results per severity"""
|
||||||
counts_dict = await queries.get_severity_counts(db)
|
counts_dict = await queries.get_severity_counts(db)
|
||||||
|
|
||||||
|
@ -30,6 +35,8 @@ async def get_severity_counts(request: Request, db: Session = Depends(get_db)):
|
||||||
"request": request,
|
"request": request,
|
||||||
"counts_dict": counts_dict,
|
"counts_dict": counts_dict,
|
||||||
"agents": agents,
|
"agents": agents,
|
||||||
|
"refresh": refresh,
|
||||||
|
"delay": delay,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -15,3 +15,13 @@ code {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.inline-label {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.initial-width {
|
||||||
|
width: initial !important;
|
||||||
|
}
|
||||||
|
#refresh-form {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,12 @@
|
||||||
<title>Argos</title>
|
<title>Argos</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||||
<link href="{{ url_for('static', path='/styles.css') }}" rel="stylesheet">
|
{% if refresh %}
|
||||||
|
<meta http-equiv="refresh"
|
||||||
|
content="{{ delay }}">
|
||||||
|
{% endif %}
|
||||||
|
<link href="{{ url_for('static', path='/styles.css') }}"
|
||||||
|
rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main class="container">
|
<main class="container">
|
||||||
|
|
|
@ -1,27 +1,68 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
{% block title %}<h2>Dashboard</h2>{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="domains" class="frame">
|
<div id="domains" class="frame">
|
||||||
<p>
|
<nav>
|
||||||
<a href="/agents">{{ agents | length }} agent{% if agents| length > 1 %}s{% endif %}</a>
|
<ul>
|
||||||
</p>
|
<li>
|
||||||
|
<a href="{{ url_for('get_agents_view') }}">
|
||||||
|
{{ agents | length }} agent{{ 's' if agents | length > 1 }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<input id="auto-refresh"
|
||||||
|
type="checkbox"
|
||||||
|
form="refresh-form"
|
||||||
|
{{ 'checked' if refresh }}>
|
||||||
|
<label for="auto-refresh" class="inline-label">Auto-refresh</label>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label class="inline-label">
|
||||||
|
Every <input id="refresh-delay"
|
||||||
|
class="initial-width"
|
||||||
|
type="number"
|
||||||
|
form="refresh-form"
|
||||||
|
min="1"
|
||||||
|
value="{{ delay }}"> seconds
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<form id="refresh-form"
|
||||||
|
method="get"
|
||||||
|
action="{{ url_for('get_severity_counts_view') }}">
|
||||||
|
<input type="Submit">
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="grid grid-index">
|
<div class="grid grid-index">
|
||||||
<article>
|
<article>
|
||||||
<header>✅ OK </header>
|
<header title="Unknown">❔</header>
|
||||||
{{ counts_dict['ok'] }}
|
<span id="sev-unknown">{{ counts_dict['unknown'] }}</span>
|
||||||
</article>
|
</article>
|
||||||
<article>
|
<article>
|
||||||
<header>⚠️ Warning</header>
|
<header title="OK">✅</header>
|
||||||
{{ counts_dict['warning'] }}
|
<span id="sev-ok">{{ counts_dict['ok'] }}</span>
|
||||||
</article>
|
</article>
|
||||||
<article>
|
<article>
|
||||||
<header>❌ Critical</header>
|
<header title="Warning">⚠️</header>
|
||||||
{{ counts_dict['critical'] }}
|
<span id="sev-warning">{{ counts_dict['warning'] }}</span>
|
||||||
|
</article>
|
||||||
|
<article>
|
||||||
|
<header title="Critical">❌</header>
|
||||||
|
<span id="sev-critical">{{ counts_dict['critical'] }}</span>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-center">
|
<p class="text-center">
|
||||||
<a href="/details" role="button">Details</a>
|
<a href="{{ url_for('get_domains_view') }}"
|
||||||
|
class="outline"
|
||||||
|
role="button">
|
||||||
|
Domains
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue