fix #4275 - custom title

This commit is contained in:
crcro
2016-09-06 02:44:55 +03:00
parent 7a5f9d5a41
commit 4e5bd343b5

View File

@@ -18,33 +18,51 @@ $select_modes = array(
'2' => 'devices and services', '2' => 'devices and services',
); );
require_once 'includes/object-cache.inc.php'; if (defined('SHOW_SETTINGS')) {
$common_output[] = '
$sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1')); <form class="form" onsubmit="widget_settings(this); return false;">
$widget_mode = json_decode($sql['settings']); <div class="form-group">
<div class="col-sm-2">
if (isset($_SESSION["map_view"])) { <label for="title" class="control-label">Title: </label>
$mode = $_SESSION["map_view"]; </div>
<div class="col-sm-10">
<input type="text" class="form-control" name="title" placeholder="Custom title for widget" value="'.htmlspecialchars($widget_settings['title']).'">
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" class="btn btn-default">Set</button>
</div>
</div>
</form>';
} else { } else {
require_once 'includes/object-cache.inc.php';
$sql = dbFetchRow('SELECT `settings` FROM `users_widgets` WHERE `user_id` = ? AND `widget_id` = ?', array($_SESSION["user_id"], '1'));
$widget_mode = json_decode($sql['settings']);
if (isset($_SESSION["map_view"])) {
$mode = $_SESSION["map_view"];
} else {
$mode = $widget_mode->{'mode'}; $mode = $widget_mode->{'mode'};
} }
$host_up_count = 0; $host_up_count = 0;
$host_warn_count = 0; $host_warn_count = 0;
$host_down_count = 0; $host_down_count = 0;
$service_up_count = 0; $service_up_count = 0;
$service_warn_count = 0; $service_warn_count = 0;
$service_down_count = 0; $service_down_count = 0;
if ($config['webui']['availability_map_sort_status'] == 1) { if ($config['webui']['availability_map_sort_status'] == 1) {
$deviceOrderBy = 'status'; $deviceOrderBy = 'status';
$serviceOrderBy = '`S`.`service_status` DESC'; $serviceOrderBy = '`S`.`service_status` DESC';
} else { } else {
$deviceOrderBy = 'hostname'; $deviceOrderBy = 'hostname';
$serviceOrderBy = '`D`.`hostname`'; $serviceOrderBy = '`D`.`hostname`';
} }
if ($mode == 0 || $mode == 2) { if ($mode == 0 || $mode == 2) {
// Only show devices if mode is 0 or 2 (Only Devices or both) // Only show devices if mode is 0 or 2 (Only Devices or both)
if ($config['webui']['availability_map_use_device_groups'] != 0) { if ($config['webui']['availability_map_use_device_groups'] != 0) {
$device_group = 'SELECT `D`.`device_id` FROM `device_group_device` AS `D` WHERE `device_group_id` = ?'; $device_group = 'SELECT `D`.`device_id` FROM `device_group_device` AS `D` WHERE `device_group_id` = ?';
@@ -117,9 +135,9 @@ if ($mode == 0 || $mode == 2) {
$temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '"><div class="' . $deviceLabelOld . '" style="width:' . $config['webui']['availability_map_old_widget_tile_size'] . 'px;"></div></a>'; $temp_output[] = '<a href="' . generate_url(array('page' => 'device', 'device' => $device['device_id'])) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '"><div class="' . $deviceLabelOld . '" style="width:' . $config['webui']['availability_map_old_widget_tile_size'] . 'px;"></div></a>';
} }
} }
} }
if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
$service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id` ORDER BY ' . $serviceOrderBy . ';'; $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id` ORDER BY ' . $serviceOrderBy . ';';
$services = dbFetchRows($service_query); $services = dbFetchRows($service_query);
if (count($services) > 0) { if (count($services) > 0) {
@@ -166,9 +184,9 @@ if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
} else { } else {
$temp_output [] = ''; $temp_output [] = '';
} }
} }
if ($directpage == "yes") { if ($directpage == "yes") {
$temp_header[] = ' $temp_header[] = '
<div class="page-availability-title-left"> <div class="page-availability-title-left">
<span class="page-availability-title">Availability map for</span> <span class="page-availability-title">Availability map for</span>
@@ -217,17 +235,17 @@ if ($directpage == "yes") {
} }
$temp_header[] = '</select>'; $temp_header[] = '</select>';
} }
} }
if ($directpage == "yes") { if ($directpage == "yes") {
$deviceClass = 'page-availability-report-host'; $deviceClass = 'page-availability-report-host';
$serviceClass = 'page-availability-report-host'; $serviceClass = 'page-availability-report-host';
} else { } else {
$deviceClass = 'widget-availability-host'; $deviceClass = 'widget-availability-host';
$serviceClass = 'widget-availability-service'; $serviceClass = 'widget-availability-service';
} }
if ($mode == 0 || $mode == 2) { if ($mode == 0 || $mode == 2) {
$temp_header[] = ' $temp_header[] = '
<div class="' . $deviceClass . '"> <div class="' . $deviceClass . '">
<span>Total hosts</span> <span>Total hosts</span>
@@ -235,9 +253,9 @@ if ($mode == 0 || $mode == 2) {
<span class="label label-warning label-font-border label-border">warn: ' . $host_warn_count . '</span> <span class="label label-warning label-font-border label-border">warn: ' . $host_warn_count . '</span>
<span class="label label-danger label-font-border label-border">down: ' . $host_down_count . '</span> <span class="label label-danger label-font-border label-border">down: ' . $host_down_count . '</span>
</div>'; </div>';
} }
if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) { if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
$temp_header[] = ' $temp_header[] = '
<div class="' . $serviceClass . '"> <div class="' . $serviceClass . '">
<span>Total services</span> <span>Total services</span>
@@ -245,9 +263,10 @@ if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
<span class="label label-warning label-font-border label-border">warn: ' . $service_warn_count . '</span> <span class="label label-warning label-font-border label-border">warn: ' . $service_warn_count . '</span>
<span class="label label-danger label-font-border label-border">down: ' . $service_down_count . '</span> <span class="label label-danger label-font-border label-border">down: ' . $service_down_count . '</span>
</div>'; </div>';
}
$temp_header[] = '</div>';
$temp_header[] = '<br style="clear:both;">';
$common_output = array_merge($temp_header, $temp_output);
} }
$temp_header[] = '</div>';
$temp_header[] = '<br style="clear:both;">';
$common_output = array_merge($temp_header, $temp_output);