Add functionality to services in backend.

- Add functionallity to categorize a one or more services under one
  service group. Partial fix for #7 and #90. (Frontend code to be done)
- Add description field to service to be displayed as a help text
  on front page. Partial fix for #51 (Frontend code to be done)
This commit is contained in:
thnilsen
2020-09-27 14:01:54 +02:00
parent 48b9cbbc82
commit 93d1491aac
9 changed files with 515 additions and 42 deletions
+15 -14
View File
@@ -2,6 +2,7 @@
//DIR Because of include problems
require_once(__DIR__ . "/incident.php");
require_once(__DIR__ . "/service.php");
require_once(__DIR__ . "/service-group.php");
require_once(__DIR__ . "/user.php");
require_once(__DIR__ . "/token.php");
/**
@@ -20,7 +21,7 @@ class Constellation
public function render_incidents($future=false, $offset=0, $limit = 5, $admin = 0){
if ($offset<0)
{
$offset = 0;
$offset = 0;
}
$limit = (isset($_GET['limit'])?$_GET['limit']:5);
@@ -37,7 +38,7 @@ class Constellation
}
else if (count($incidents["incidents"]) &&!$ajax)
{
if ($offset)
if ($offset)
{
echo '<noscript><div class="centered"><a href="'.WEB_URL.'/?offset='.($offset-$limit).'&timestamp='.$timestamp.'" class="btn btn-default">'._("Back").'</a></div></noscript>';
}
@@ -66,11 +67,11 @@ class Constellation
/**
* Renders service status - in admin page it returns array so it can be processed further.
* @param boolean $admin
* @return array of services
* @return array of services
*/
public function render_status($admin = false, $heading = true){
global $mysqli;
$query = $mysqli->query("SELECT id, name FROM services");
$array = array();
if ($query->num_rows){
@@ -91,7 +92,7 @@ class Constellation
else{
$array[] = new Service($result['id'], $result['name']);
}
}
}
if ($heading)
{
echo Service::current_status($array);
@@ -131,14 +132,14 @@ class Constellation
$limit--;
$more = false;
if ($query->num_rows>$limit){
$more = true;
$more = true;
}
if ($query->num_rows){
while(($result = $query->fetch_assoc()) && $limit-- > 0)
{
// Add service id and service names to an array in the Incident class
$stmt_service = $mysqli->prepare("SELECT services.id,services.name FROM services
INNER JOIN services_status ON services.id = services_status.service_id
$stmt_service = $mysqli->prepare("SELECT services.id,services.name FROM services
INNER JOIN services_status ON services.id = services_status.service_id
WHERE services_status.status_id = ?");
$stmt_service->bind_param("i", $result['status_id']);
$stmt_service->execute();
@@ -156,17 +157,17 @@ class Constellation
"incidents" => $array
];
}
function render_warning($header, $message, $show_link = false, $url = null, $link_text = null)
{
$this->render_alert('alert-warning', $header, $message, $show_link, $url, $link_text);
$this->render_alert('alert-warning', $header, $message, $show_link, $url, $link_text);
}
function render_success($header, $message, $show_link = false, $url = null, $link_text = null)
{
$this->render_alert('alert-success', $header, $message, $show_link, $url, $link_text);
}
/**
* Renders an alert on screen with an optional button to return to a given URL
* @param string alert_type - Type of warning to render alert-danger, alert-warning, alert-success etc
@@ -188,8 +189,8 @@ class Constellation
if ( $show_link ) {
echo '<div class="clearfix"><a href="'.$url.'" class="btn btn-success" role="button">'.$link_text.'</a></div>';
}
}
}
$constellation = new Constellation();
$constellation = new Constellation();