Better dashboard with collapsable blocks

This commit is contained in:
Axel 2021-01-09 13:32:04 +01:00
parent 566b30f47d
commit 5a0fd488e6
3 changed files with 165 additions and 78 deletions

View file

@ -70,17 +70,19 @@ td {
width: 100%; width: 100%;
} }
#task { .task {
margin: 3rem auto; margin: 3rem auto;
max-width: 80%; max-width: 1000px;
padding: 1rem; padding: 1rem;
-webkit-box-shadow: 5px 5px 15px 0px rgba(0,0,0,0.3); -webkit-box-shadow: 5px 5px 15px 0px rgba(0,0,0,0.3);
-moz-box-shadow: 5px 5px 15px 0px rgba(0,0,0,0.3); -moz-box-shadow: 5px 5px 15px 0px rgba(0,0,0,0.3);
box-shadow: 5px 5px 15px 0px rgba(0,0,0,0.3); box-shadow: 5px 5px 15px 0px rgba(0,0,0,0.3);
border-radius: 5px; border-radius: 5px;
position: relative;
} }
.highlight { .highlight {
background-color: #000; background-color: #000;
padding: 0px 1rem; padding: 0px 1rem;
@ -89,3 +91,53 @@ td {
font-size: 1rem; font-size: 1rem;
vertical-align: middle; vertical-align: middle;
} }
.hidden {
display: none;
}
.task.show .task-overlay {
display: none;
}
.exp-icon {
position: absolute;
right: 1rem;
top: 1rem;
width: 20px;
min-height: 27px;
height: 27px;
background-repeat: no-repeat;
cursor: pointer;
animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
transform: translate3d(0, 0, 0);
backface-visibility: hidden;
animation-iteration-count: 3;
animation-delay: 3s;
}
.task .exp-icon {
background-image: url('../img/expand.png');
}
.task.active .exp-icon {
background-image: url('../img/collapse.png');
}
@keyframes shake {
10%, 90% {
transform: translate3d(-1px, 0, 0);
}
20%, 80% {
transform: translate3d(2px, 0, 0);
}
30%, 50%, 70% {
transform: translate3d(-4px, 0, 0);
}
40%, 60% {
transform: translate3d(4px, 0, 0);
}
}

View file

@ -1,7 +1,15 @@
<?php require_once __DIR__.'/DB.php'; ?> <?php require_once __DIR__.'/DB.php'; ?>
<!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>MonitoLite - Network monitoring tool</title>
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous">
</script>
<script type="text/javascript" src="js/scripts.js"></script> <script type="text/javascript" src="js/scripts.js"></script>
<link type="text/css" rel="stylesheet" href="css/styles.css" /> <link type="text/css" rel="stylesheet" href="css/styles.css" />
</head> </head>
@ -12,8 +20,9 @@
<?php if ($tasks = $db->get_all_tasks()): ?> <?php if ($tasks = $db->get_all_tasks()): ?>
<?php foreach ($tasks as $task): ?> <?php foreach ($tasks as $task): ?>
<div class="task">
<div id="task"> <p class="exp-icon" title="Click here to expand/collapse the task">&nbsp;</p>
<!--<p class="task-overlay"><img src="img/expand.png" width="32"></p>-->
<h2>Task <small>#</small><?php echo $task['id']; ?> » <span class="highlight"><?php echo $task['type']; ?></span> for host <span class="highlight"><?php echo $task['host']; ?></span></h2> <h2>Task <small>#</small><?php echo $task['id']; ?> » <span class="highlight"><?php echo $task['type']; ?></span> for host <span class="highlight"><?php echo $task['host']; ?></span></h2>
<table id="tasks_tbl"> <table id="tasks_tbl">
@ -52,7 +61,7 @@
</tbody> </tbody>
</table> </table>
<div class="hidden">
<div id="history"> <div id="history">
<h3>Task history</h3> <h3>Task history</h3>
<?php if ($histories = $db->get_all_history($task['id'], 5)): ?> <?php if ($histories = $db->get_all_history($task['id'], 5)): ?>
@ -126,6 +135,7 @@
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </div>
</div>
<?php endforeach; ?> <?php endforeach; ?>

View file

@ -0,0 +1,25 @@
$(document).ready(function() {
$('.task .exp-icon').on('click', function() {
var el = $(this).parent('.task');
if (el.hasClass('active')) {
el.removeClass('active');
el.children('.hidden').slideUp();
}
else {
$('.task').removeClass('active');
$('.task').children('.hidden').slideUp();
el.addClass('active');
el.children('.hidden').slideDown();
}
});
$('.task').not('.active').on('mouseover', function() {
$(this).children('.task-overlay').show();
});
$('.task').not('.active').on('mouseout', function() {
$(this).children('.task-overlay').hide();
});
})