FreeSTAR-Status-Engine/admin/dashboard.php

108 lines
4.9 KiB
PHP
Raw Normal View History

<?php
2017-11-23 18:09:36 -05:00
$offset = 0;
if (isset($_GET['ajax']))
{
$constellation->render_incidents(false,$_GET['offset'],5);
exit();
}else if (isset($_GET['offset']))
{
$offset = $_GET['offset'];
}
2018-01-03 08:15:45 -05:00
if (isset($_GET['new']) && $_GET['new']=="incident")
2017-11-23 18:09:36 -05:00
{
Incident::add();
}
if (isset($_GET['delete']))
{
Incident::delete($_GET['delete']);
}
Template::render_header(_("Dashboard"), true);
2017-11-23 18:09:36 -05:00
?>
<div class="text-center">
2017-12-30 18:41:58 -05:00
<h1><?php echo _("Dashboard");?></h1>
<h3><?php echo _("Welcome");?> <?php echo $user->get_name();?></h3>
2017-11-23 18:09:36 -05:00
</div>
<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>
2017-12-30 18:41:58 -05:00
<h3><?php echo _("New incident");?></h3>
<form id="new-incident" action="<?php echo WEB_URL;?>/admin/?new=incident" method="POST" class="clearfix">
2018-01-12 18:57:13 -05:00
<div class="panel">
2017-11-23 18:09:36 -05:00
<?php if (isset($message))
{?>
<p class="alert alert-danger"><?php echo $message?></p>
<?php
} ?>
<div id="status-container" class="clearfix">
<?php
2018-01-03 08:15:45 -05:00
if (isset($_POST['services']) && !is_array($_POST['services']))
2017-11-23 18:09:36 -05:00
{
2018-01-03 08:15:45 -05:00
$post_services = array($_POST['services']);
}else{
$post_services = array();
2017-11-23 18:09:36 -05:00
}
2017-11-23 18:09:36 -05:00
foreach($services as $service){
?>
<div class="item clearfix">
2018-01-03 08:15:45 -05:00
<div class="service"><?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 for="service-<?php echo $service->get_id(); ?>"><?php echo $service->get_name(); ?></label></div>
<div class="status <?php if ($service->get_status()!=-1){echo $classes[$service->get_status()];}?>"><?php if ($service->get_status()!=-1){echo $statuses[$service->get_status()];}?></div>
2017-11-23 18:09:36 -05:00
</div>
<?php
}
?>
</div>
2018-01-12 18:57:13 -05:00
</div>
<div class="panel new panel-primary">
2017-11-23 18:09:36 -05:00
<div class="panel-heading icon">
<i class="glyphicon glyphicon-info-sign"></i>
</div>
<div class="panel-heading clearfix">
2018-04-13 17:41:05 -04:00
<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="pull-right" 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="pull-right">
</span>
2017-11-23 18:09:36 -05:00
</div>
<div class="panel-body">
2018-01-18 16:59:34 -05:00
<textarea name="text" placeholder="<?php echo _("Here goes your text...");?>" required><?php echo (isset($_POST['text'])?htmlspecialchars($_POST['text']):''); ?></textarea>
2017-11-23 18:09:36 -05:00
</div>
2017-12-12 08:17:10 -05:00
<div class="panel-footer clearfix">
2018-01-03 08:15:45 -05:00
<small><?php echo _("Posted by");?>: <?php echo $user->get_username();?> <span class="pull-right" 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="pull-right" placeholder="<?php echo _("End time");?>" value="<?php echo (isset($_POST['end_time'])?htmlspecialchars($_POST['end_time']):''); ?>"></span></small>
2018-04-13 17:41:05 -04:00
<input id="end_time_js" name="end_time_js" type="hidden" class="pull-right">
2017-11-23 18:09:36 -05:00
</div>
2018-01-12 18:57:13 -05:00
</div>
2017-11-23 18:09:36 -05:00
<select class="form-control pull-left" id="type" name="type">
<?php
2017-11-23 18:09:36 -05:00
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>
2017-12-30 18:41:58 -05:00
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Submit");?></button>
2017-11-23 18:09:36 -05:00
</form>
<?php
$constellation->render_incidents(true,$offset,5,true);
$constellation->render_incidents(false,$offset,5,true);
?>
</div>
</div>
</div>