Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some improvements #162

Open
wants to merge 16 commits into
base: cleanup
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 80 additions & 71 deletions src/admin/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if (isset($_GET['ajax'])) {
$constellation->render_incidents(false, $_GET['offset'], 5);
exit();
} elseif (isset($_GET['offset'])) {
} else if (isset($_GET['offset'])) {
$offset = $_GET['offset'];
}

Expand All @@ -14,92 +14,101 @@
if (isset($_GET['delete'])) {
Incident::delete($_GET['delete']);
}

if (isset($_GET['tasks'])) {
Queue::process_queue();
}

Template::render_header(_("Dashboard"), 'dashboard', true);
Template::render_header(_("Dashboard"), "dashboard", true);
?>

<div class="text-center">
<h1><?php echo _("Dashboard");?></h1>
<h3 class="mb-3"><?php echo _("Welcome");?> <?php echo $user->get_name();?></h3>
</div>
<div class="text-center">
<h1><?php echo _("Dashboard"); ?></h1>
<h3><?php echo _("Welcome"); ?> <?php echo $user->get_name(); ?></h3>
</div>

<div id="current">
<?php
$services = $constellation->render_status(true);
?>
</div>
<div id="timeline" class="timeline">
<div id="current">
<?php
$services = $constellation->render_status(true);
?>
</div>
<div id="timeline">
<div class="item">
<div class="timeline">
<div class="line text-muted"></div>
<h3><?php echo _("New incident");?></h3>
<form id="new-incident" action="<?php echo WEB_URL;?>/admin/?new=incident" method="POST" class="clearfix">
<?php if (isset($message)) {?>
<p class="alert alert-danger"><?php echo $message?></p>
<h3><?php echo _("New incident"); ?></h3>
<form id="new-incident" action="<?php echo WEB_URL; ?>/admin/?new=incident" method="POST">
<div class="servicelist">
<?php if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p>
<?php
} ?>
<ul class="list-group components" class="clearfix">
<?php
if (isset($_POST['services']) && !is_array($_POST['services'])) {
$post_services = array($_POST['services']);
} else {
$post_services = array();
}
} ?>
<div id="status-container">
<?php
if (isset($_POST['services']) && !is_array($_POST['services'])) {
$post_services = array($_POST['services']);
} else {
$post_services = array();
}

foreach ($services as $service) {
?>
<li class="list-group-item sub-component">
<strong><?php if ($service->get_status() != -1) {
?><input type="checkbox" name="services[]" value="<?php echo $service->get_id(); ?>" <?php echo (in_array($service->get_id(), $post_services)) ? "checked" : '';?> id="service-<?php echo $service->get_id(); ?>"><?php
} ?><label class="ms-2" for="service-<?php echo $service->get_id(); ?>"><?php echo $service->get_name(); ?></label></strong>
<div class="status float-end <?php if ($service->get_status() != -1) {
echo $classes[$service->get_status()];
}?>"><?php if ($service->get_status() != -1) {
echo $statuses[$service->get_status()];
}?></div>
</li>
<?php
}
?>
</ul>
<div class="card new card-primary">
<div class="card-header icon">
<i class="bi bi-info-sign"></i>
foreach ($services as $service) {
?>
<div class="input-group mb-2">
<?php if ($service->get_status() != -1) { ?>
<div class="input-group-text service">
<input type="checkbox" name="services[]" value="<?php echo $service->get_id(); ?>" <?php echo (in_array($service->get_id(), $post_services)) ? "checked" : ''; ?> id="service-<?php echo $service->get_id(); ?>">
</div>
<label id="name" class="input-group-text form-control" for="service-<?php echo $service->get_id(); ?>"><?php echo $service->get_name(); ?></label>
<label id="status" class="input-group-text btn-<?php if ($service->get_status() != -1) {
echo $classes[$service->get_status()];
} ?>" for="service-<?php echo $service->get_id(); ?>"><?php echo $statuses[$service->get_status()]; ?></label>
<?php } ?>
</div>
<?php
}
?>
</div>
<div class="card-header clearfix">
<input type="text" name="title" id="title" placeholder="<?php echo _("Title");?>" value="<?php echo (isset($_POST['title']) ? htmlspecialchars($_POST['title']) : ''); ?>" required> <span id="time"><input id="time_input" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="time" value="<?php echo (isset($_POST['time']) ? htmlspecialchars($_POST['time']) : ''); ?>" class="float-end" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" placeholder="<?php echo _("Time");?>">
<input id="time_input_js" name="time_js" type="hidden" class="float-end">
</div>
<article class="card new border-primary mb-3">
<div class="card-colore icon bg-primary"><i class="fa fa-info"></i></div>
<div class="card-colore card-header bg-primary border-primary">
<input type="text" name="title" id="title" placeholder="<?php echo _("Title"); ?>" value="<?php echo (isset($_POST['title']) ? htmlspecialchars($_POST['title']) : ''); ?>" required>
<span id="time" class="float-end">
<input id="time_input" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="time" value="<?php echo (isset($_POST['time']) ? htmlspecialchars($_POST['time']) : ''); ?>" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" placeholder="<?php echo _("Time"); ?>">
<input id="time_input_js" name="time_js" type="hidden">
</span>
</div>
<div class="card-body">
<textarea name="text" placeholder="<?php echo _("Here goes your text...");?>" required><?php echo (isset($_POST['text']) ? htmlspecialchars($_POST['text']) : ''); ?></textarea>
<div class="card-body text-primary">
<p class="card-text"><textarea name="text" placeholder="<?php echo _("Here goes your text..."); ?>" required><?php echo (isset($_POST['text']) ? htmlspecialchars($_POST['text']) : ''); ?></textarea></p>
</div>
<div class="card-footer clearfix">
<small><?php echo _("Posted by");?>: <?php echo $user->get_username();?> <span class="float-end" id="end_time_wrapper"><?php echo _("Ending");?>:&nbsp;<input id="end_time" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="end_time" class="float-end" placeholder="<?php echo _("End time");?>" value="<?php echo (isset($_POST['end_time']) ? htmlspecialchars($_POST['end_time']) : ''); ?>"></span></small>
<input id="end_time_js" name="end_time_js" type="hidden" class="float-end">
<div class="card-footer bg-transparent border-primary">
<small><?php echo _("Posted by"); ?>: <?php echo $user->get_username(); ?></small>
<span class="float-end" id="end_time_wrapper"><?php echo _("Ending"); ?>:&nbsp;
<input id="end_time" title="Use ISO 8601 format (e.g. 2017-11-23T19:50:51+00:00)" type="text" pattern="(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))" name="end_time" placeholder="<?php echo _("End time"); ?>" value="<?php echo (isset($_POST['end_time']) ? htmlspecialchars($_POST['end_time']) : ''); ?>">
<input id="end_time_js" name="end_time_js" type="hidden">
</span>
</div>
</div>
<select class="form-select float-start" id="type" name="type">
<?php
if (isset($_POST['type'])) {
$selected_status = $_POST['type'];
} else {
$selected_status = 2;
}
</article>
<div class="input-group">
<select class="form-select" id="type" name="type">
<?php
if (isset($_POST['type'])) {
$selected_status = $_POST['type'];
} else {
$selected_status = 2;
}

foreach ($statuses as $key => $value) {
echo '<option value="' . $key . '"' . (($key == $selected_status) ? ' selected' : '') . '>' . $value . '</option>';
}
?>
</select>
<button type="submit" class="btn btn-primary float-end"><?php echo _("Submit");?></button>
foreach ($statuses as $key => $value) {
echo '<option value="' . $key . '"' . (($key == $selected_status) ? ' selected' : '') . '>' . $value . '</option>';
}
?>
</select>
<button class="card-colore btn btn-secondary" type="submit"><?php echo _("Submit"); ?></button>
</div>
</form>
<?php
$constellation->render_incidents(true, $offset, 5, true);
$constellation->render_incidents(false, $offset, 5, true);
?>
</div>
<?php
$constellation->render_incidents(true, $offset, 5, true);
$constellation->render_incidents(false, $offset, 5, true);
?>
</div>
</div>
</div>
58 changes: 34 additions & 24 deletions src/admin/login-form.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
<?php
Template::render_header(_('Login'), 'login');
?>
<div class="text-center">
<h1><?php echo _('Login'); ?></h1>
</div>
<div id="login-form" class="center">
<?php if (isset($message)) { ?>
<div class="text-center">
<h1><?php echo _('Login'); ?></h1>
</div>
<div id="login-form" class="center">
<?php if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message; ?></p>
<?php } else { ?>
<?php } else { ?>
<p class="alert alert-info"><?php echo _('Please login to continue.'); ?></p>
<?php } ?>
<form action="<?php echo WEB_URL; ?>/admin/" method="post">
<div class="mb-3">
<label for="email"><?php echo _('Email'); ?></label>
<input placeholder="<?php echo _('Email'); ?>" class="form-control" name="email" id="email" type="email" tabindex="1" value="<?php echo htmlspecialchars((isset($_POST['email']) ? $_POST['email'] : ''), ENT_QUOTES); ?>" required>
<?php } ?>
<form action="<?php echo WEB_URL; ?>/admin/" method="post">
<div class="card">
<div class="card-header">
<h1><?php echo _("Login"); ?></h1>
</div>
<div class="card-body">
<div class="input-group mb-3">
<span class="input-group-text"><i class="fas fa-at"></i></span>
<input type="email" id="email" name="email" class="form-control" placeholder="<?php echo _("Email"); ?>" value="<?php echo htmlspecialchars((isset($_POST['email']) ? $_POST['email'] : ''), ENT_QUOTES); ?>" required>
</div>
<div class="input-group mb-3">
<span class="input-group-text"><i class="fas fa-key"></i></span>
<input type="password" id="pass" name="pass" class="form-control" placeholder="<?php echo _("Password"); ?>" required>
</div>
<a href="<?php echo WEB_URL; ?>/admin/?do=lost-password" class="float-end" tabindex="5"><?php echo _("Forgotten password?"); ?></a>
<div class="input-group mb-3">
<div class="input-group-text nrbr">
<input type="checkbox" name="remember" id="remember">
</div>
<div class="mb-3">
<label for="pass"><?php echo _('Password'); ?></label>
<input placeholder="<?php echo _('Password'); ?>" class="form-control" name="pass" id="pass" type="password" tabindex="2" required>
<div class="mt-3">
<a href="<?php echo WEB_URL; ?>/admin/?do=lost-password" class="float-end noselect" tabindex="5"><?php echo _('Forgotten password?'); ?></a>
<input name="remember" id="remember" type="checkbox" tabindex="3"> <label class="lbl-login noselect" style="color: black;" for="remember"><?php echo _('Remember me'); ?></label>
</div>
</div>
<div class=" clearfix">
<button type="submit" class="btn btn-success float-end" tabindex="4"><?php echo _('Login'); ?></button>
</div>
</form>
<label class="input-group-append input-group-text nlbr nobg" for="remember"><?php echo _("Remember me"); ?></label>
</div>
<div class="form-group">
<input type="submit" value="<?php echo _("Login"); ?>" class="btn btn-success float-end">
</div>
</div>
</div>
</form>
</div>
<?php
Template::render_footer();
Template::render_footer();
110 changes: 55 additions & 55 deletions src/admin/lost-password.php
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
<?php
Template::render_header(_("Lost password"), 'lost-password');
?>
<div class="text-center">
<h1><?php echo _("Lost password");?></h1>
</div>
<div id="login-form" class="center">

<div class="text-center">
<h1><?php echo _("Lost password"); ?></h1>
</div>
<div id="login-form" class="center">

<?php
if (isset($_POST['id'])) {
$user = new User($_POST['id']);
$user->change_password($_POST['token']);
if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p>
<a href="<?php echo WEB_URL; ?>/admin/?do=lost-password<?php echo "&id=" . $_POST['id'] . "&token=" . $_POST['token']; ?>"><?php echo _("Go back"); ?> </a>
<?php
if (isset($_POST['id'])) {
$user = new User($_POST['id']);
$user->change_password($_POST['token']);
if (isset($message)) {?>
<p class="alert alert-danger"><?php echo $message?></p>
<a href="<?php echo WEB_URL;?>/admin/?do=lost-password<?php echo "&id=" . $_POST['id'] . "&token=" . $_POST['token'];?>"><?php echo _("Go back");?> </a>
<?php
} else {?>
<p class="alert alert-success"><?php echo _("Password changed successfully!");?></p>
<a href="<?php echo WEB_URL;?>/admin/"><?php echo _("Go back to login page");?></a>
<?php
}
} elseif (isset($_POST['email'])) {
User::password_link();
if (isset($message)) {?>
<p class="alert alert-danger"><?php echo $message?></p>
<a href="<?php echo WEB_URL;?>/admin/?do=lost-password"><?php echo _("Go back to start");?></a>
<?php
} else {?>
<p class="alert alert-success"><?php echo _("Email with password reset link has been sent!");?></p>
<a href="<?php echo WEB_URL;?>/admin/"><?php echo _("Go back to login page");?></a>
<?php
}
} else {
if (isset($message)) {?>
<p class="alert alert-danger"><?php echo $message?></p>
<?php }?>
<form action="<?php echo WEB_URL;?>/admin/?do=lost-password" method="post">
<?php if (!isset($_GET['id']) || !isset($_GET['token'])) {?>
<label for="email"><?php echo _("Email");?>:</label>
<div class="float-end">
<input class="form-control" name="email" id="email" placeholder="<?php echo _("Email");?>" type="email" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-success float-end"><?php echo _("Submit request");?></button>
</span>
</div>
} else { ?>
<p class="alert alert-success"><?php echo _("Password changed successfully!"); ?></p>
<a href="<?php echo WEB_URL; ?>/admin/"><?php echo _("Go back to login page"); ?></a>
<?php
}
} elseif (isset($_POST['email'])) {
User::password_link();
if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p>
<a href="<?php echo WEB_URL; ?>/admin/?do=lost-password"><?php echo _("Go back to start"); ?></a>
<?php
} else { ?>
<p class="alert alert-success"><?php echo _("Email with password reset link has been sent!"); ?></p>
<a href="<?php echo WEB_URL; ?>/admin/"><?php echo _("Go back to login page"); ?></a>
<?php
}
} else {
if (isset($message)) { ?>
<p class="alert alert-danger"><?php echo $message ?></p>
<?php } ?>
<form action="<?php echo WEB_URL; ?>/admin/?do=lost-password" method="post">
<?php if (!isset($_GET['id']) || !isset($_GET['token'])) { ?>
<label for="email"><?php echo _("Email"); ?>:</label>
<div class="input-group float-end">
<input class="form-control" name="email" id="email" placeholder="<?php echo _("Email"); ?>" type="email" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-success float-end"><?php echo _("Submit request"); ?></button>
</span>
</div>
<?php } else {
$user = new User($_GET['id']);
?>
<p class="alert alert-info"><?php printf(_("Reset password for %s (%s)"), $user->get_name(), $user->get_username());?></p>
<input type="hidden" name="id" value="<?php echo $_GET['id'];?>" >
<input type="hidden" name="token" value="<?php echo $_GET['token'];?>" >
<label for="new_password"><?php echo _("New password");?></label>
<input id="new_password" placeholder="<?php echo _("New password");?>" type="password" class="form-control" name="password">
<label for="new_password_check"><?php echo _("Repeat password");?></label>
<input id="new_password_check" placeholder="<?php echo _("Repeat password");?>" type="password" class="form-control" name="password_repeat">
<button type="submit" class="btn btn-primary float-end margin-top"><?php echo _("Change password");?></button>
<?php
?>
<p class="alert alert-info"><?php printf(_("Reset password for %s (%s)"), $user->get_name(), $user->get_username()); ?></p>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="hidden" name="token" value="<?php echo $_GET['token']; ?>">
<label for="new_password"><?php echo _("New password"); ?></label>
<input id="new_password" placeholder="<?php echo _("New password"); ?>" type="password" class="form-control" name="password">
<label for="new_password_check"><?php echo _("Repeat password"); ?></label>
<input id="new_password_check" placeholder="<?php echo _("Repeat password"); ?>" type="password" class="form-control" name="password_repeat">
<button type="submit" class="btn btn-primary float-end margin-top"><?php echo _("Change password"); ?></button>
<?php
}
?>
</form>
<?php }?>
</div>
</form>
<?php } ?>
</div>
<?php
Template::render_footer();
Template::render_footer();
Loading