Better panel stuff.

master
Manager Bot 3 years ago
parent c22b6d85a1
commit 936f13c102
  1. 4
      Web/lib/MJB/Web.pm
  2. 50
      Web/lib/MJB/Web/Controller/Admin.pm
  3. 5
      Web/templates/_svg/envelope-open.html.ep
  4. 5
      Web/templates/_svg/envelope.html.ep
  5. 23
      Web/templates/admin/_nav.html.ep
  6. 66
      Web/templates/admin/alerts.html.ep

@ -226,7 +226,9 @@ sub startup ($self) {
$admin->post( '/admin/invite' )->to('Admin#do_invite' )->name('do_admin_invite' );
$admin->post( '/admin/invite/remove' )->to('Admin#do_invite_remove' )->name('do_admin_invite_remove' );
$admin->get ( '/admin/alerts' )->to('Admin#alerts' )->name('show_admin_alerts' );
$admin->post( '/admin/alert/:id' )->to('Admin#do_alert_read' )->name('do_admin_alert_read' );
$admin->post( '/admin/alert/unread' )->to('Admin#do_alert_unread' )->name('do_admin_alert_unread' );
$admin->post( '/admin/alert/read' )->to('Admin#do_alert_read' )->name('do_admin_alert_read' );
$admin->post( '/admin/alert/remove' )->to('Admin#do_alert_remove' )->name('do_admin_alert_remove' );
$admin->get ( '/admin/jobs' )->to('Admin#jobs' )->name('show_admin_jobs' );
$admin->post( '/admin/update_ssl' )->to('Admin#do_update_ssl' )->name('do_admin_update_ssl' );

@ -198,4 +198,54 @@ sub do_update_ssl ( $c ) {
$c->redirect_to( $c->url_for( 'show_admin_jobs' ) );
}
sub do_alert_read ( $c ) {
my $note = $c->db->system_note( $c->param('nid') );
if ( ! $note ) {
$c->flash( error_message => "Note could not be marked as read, because it doesn't exist?" );
$c->redirect_to( $c->url_for( 'show_admin_alerts' ) );
return;
}
$note->is_read( 1 );
$note->update;
$c->flash( confirmation => "Note marked as read." );
$c->redirect_to( $c->url_for( 'show_admin_alerts' ) );
}
sub do_alert_unread ( $c ) {
my $note = $c->db->system_note( $c->param('nid') );
if ( ! $note ) {
$c->flash( error_message => "Note could not be marked as unread, because it doesn't exist?" );
$c->redirect_to( $c->url_for( 'show_admin_alerts' ) );
return;
}
$note->is_read( 0 );
$note->update;
$c->flash( confirmation => "Note marked as read." );
$c->redirect_to( $c->url_for( 'show_admin_alerts' ) );
}
sub do_alert_remove ( $c ) {
my $note = $c->db->system_note( $c->param('nid') );
if ( ! $note ) {
$c->flash( error_message => "Note could not be removed, because it doesn't exist?" );
$c->redirect_to( $c->url_for( 'show_admin_alerts' ) );
return;
}
$note->delete;
$c->flash( confirmation => "Note removed" );
$c->redirect_to( $c->url_for( 'show_admin_alerts' ) );
}
1;

@ -0,0 +1,5 @@
<!-- Start envelope-open.svg -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-envelope-open" viewBox="0 0 16 16">
<path d="M8.47 1.318a1 1 0 0 0-.94 0l-6 3.2A1 1 0 0 0 1 5.4v.817l5.75 3.45L8 8.917l1.25.75L15 6.217V5.4a1 1 0 0 0-.53-.882l-6-3.2ZM15 7.383l-4.778 2.867L15 13.117V7.383Zm-.035 6.88L8 10.082l-6.965 4.18A1 1 0 0 0 2 15h12a1 1 0 0 0 .965-.738ZM1 13.116l4.778-2.867L1 7.383v5.734ZM7.059.435a2 2 0 0 1 1.882 0l6 3.2A2 2 0 0 1 16 5.4V14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V5.4a2 2 0 0 1 1.059-1.765l6-3.2Z"/>
</svg>
<!-- End envelope-open.svg -->

After

Width:  |  Height:  |  Size: 602 B

@ -0,0 +1,5 @@
<!-- Start envelope.svg -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-envelope" viewBox="0 0 16 16">
<path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4Zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2Zm13 2.383-4.708 2.825L15 11.105V5.383Zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741ZM1 11.105l4.708-2.897L1 5.383v5.722Z"/>
</svg>
<!-- End envelope.svg -->

After

Width:  |  Height:  |  Size: 493 B

@ -31,10 +31,25 @@
<div class="flex-grow-1 text-right"></div>
<li class="nav-item">
<a class="nav-link <%= $page eq 'jobs' ? 'active' : '' %>" href="<%= $c->url_for( 'show_admin_jobs' ) %>">Jobs</a>
</li>
<li class="nav-item">
<a class="nav-link <%= $page eq 'alerts' ? 'active' : '' %>" href="<%= $c->url_for( 'show_admin_alerts' ) %>">Alerts</a>
<a class="nav-link <%= $page eq 'jobs' ? 'active' : '' %>" href="<%= $c->url_for( 'show_admin_jobs' ) %>">
% if ( $page ne 'jobs' && $c->minion->jobs({ states => [ 'inactive', 'active' ], notes => [ '_bid_0' ] } )->total >= 1 ) {
<div class="spinner-grow spinner-grow-sm text-warning" role="status">
<span class="visually-hidden">Jobs Running</span>
</div>
% }
Jobs
</a>
</li>
<li class="nav-item">
<a class="nav-link <%= $page eq 'alerts' ? 'active' : '' %>" href="<%= $c->url_for( 'show_admin_alerts' ) %>">
% my $unread_count = $c->db->system_notes( { is_read => 0 } )->count;
% if ( $unread_count ) {
<span class="badge rounded-pill bg-danger">
<%= $unread_count %>
</span>
% }
Alerts
</a>
</li>
<li class="nav-item">
<a class="nav-link <%= $page eq 'servers' ? 'active' : '' %>" href="<%= $c->url_for( 'show_admin_servers' ) %>">Servers</a>

@ -4,10 +4,68 @@
%= include '_base/status_window';
% for my $alert ( $c->db->system_notes( { is_read => 0 } )->all ) {
<div class="mt-3 alert alert-success" role="alert">
<%= $alert->content %>
<%= $alert->source %>
% for my $alert ( $c->db->system_notes( { }, { order_by => { -desc => 'created_at' } } )->all ) {
<div class="card mt-4">
<div class="card-header alert-primary">
% if ( $alert->is_read == 1 ) {
%= include '_svg/envelope-open'
% } else {
%= include '_svg/envelope'
% }
Message from <span class="fw-bold"><%= $alert->source %></span> on <%= $alert->created_at->strftime( "%F %T" ) %>
<button class="btn" data-bs-toggle="collapse" data-bs-target="#alert_window_<%= $alert->id %>">
%= include '_svg/chevron'
</button>
</div>
<div id="alert_window_<%= $alert->id %>" class="card-body <%= $alert->is_read == 1 ? 'collapse' : '' %>">
<div class="row">
% if ( $alert->is_read ) {
<div class="col-auto">
<form style="margin-top: 1.5em; display: inline;" method="POST" action="<%= $c->url_for( 'do_admin_alert_unread' ) %>">
<input type="hidden" name="nid" value="<%= $alert->id %>">
<button type="submit" class="btn btn-sm btn-outline-danger">Mark Unread</button>
</form>
</div>
% } else {
<div class="col-auto">
<form style="margin-top: 1.5em; display: inline;" method="POST" action="<%= $c->url_for( 'do_admin_alert_read' ) %>">
<input type="hidden" name="nid" value="<%= $alert->id %>">
<button type="submit" class="btn btn-sm btn-outline-danger">Mark Read</button>
</form>
</div>
% }
<div class="col-auto">
<form style="margin-top: 1.5em; display: inline;" method="POST" action="<%= $c->url_for( 'do_admin_alert_remove' ) %>">
<input type="hidden" name="nid" value="<%= $alert->id %>">
<button type="submit" class="btn btn-sm btn-outline-danger">Remove</button>
</form>
</div>
</div>
<div class="mt-3 row">
<div class="col">
<table class="table table-borderless">
<tr>
<th>From</th>
<td><%= $alert->source %></td>
</tr>
<tr>
<th>Date</th>
<td><%= $alert->created_at->strftime( "%F %T" ) %></td>
</tr>
<tr>
<th>Status</th>
<td><%= $alert->is_read ? 'Read' : 'Unread' %></td>
</tr>
</table>
<hr />
<p><%= $alert->content %></p>
</div>
</div>
</div>
</div>
% }

Loading…
Cancel
Save