9555-New view: Services
This commit is contained in:
parent
d144d77128
commit
3a80923de9
|
@ -813,6 +813,7 @@ define('AUDIT_LOG_SERVICE_MANAGEMENT', 'Service management');
|
|||
define('AUDIT_LOG_INCIDENT_MANAGEMENT', 'Incident management');
|
||||
define('AUDIT_LOG_UMC', 'Warp Manager');
|
||||
define('AUDIT_LOG_NMS_VIOLATION', 'NMS Violation');
|
||||
define('AUDIT_LOG_ENTERPRISE_VIOLATION', 'Enterprise Violation');
|
||||
|
||||
// MIMEs.
|
||||
define(
|
||||
|
|
|
@ -892,14 +892,16 @@ table.event_details td.cell_event_name {
|
|||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
table#list_servers tr {
|
||||
table#list_servers tr,
|
||||
table[id^="service-table-"] tr {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
table#list_servers b.ui-table-cell-label {
|
||||
table#list_servers b.ui-table-cell-label,
|
||||
table[id^="service-table-"] b.ui-table-cell-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -912,9 +914,20 @@ table.event_details td.cell_event_name {
|
|||
table#list_servers tr td.cell_2 {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
table[id^="service-table-"] tr td.cell_0 {
|
||||
width: 10%;
|
||||
}
|
||||
table[id^="service-table-"] tr td.cell_1 {
|
||||
width: 80%;
|
||||
}
|
||||
table[id^="service-table-"] tr td.cell_2 {
|
||||
width: 10%;
|
||||
}
|
||||
}
|
||||
|
||||
table#list_servers tr td.cell_0 {
|
||||
table#list_servers tr td.cell_0,
|
||||
table[id^="service-table-"] td.cell_0 {
|
||||
border-top: 0px;
|
||||
}
|
||||
|
||||
|
@ -1286,12 +1299,26 @@ table.tactical_bars {
|
|||
background-size: 18px 18px !important;
|
||||
}
|
||||
|
||||
.ui-icon-server-status {
|
||||
background-image: url(../../../images/server-status.menu.png) !important;
|
||||
background-color: #333 !important;
|
||||
background-size: 18px 18px !important;
|
||||
}
|
||||
|
||||
.ui-icon-services {
|
||||
background-image: url(../../../images/services.menu.png) !important;
|
||||
background-color: #333 !important;
|
||||
background-size: 18px 18px !important;
|
||||
}
|
||||
|
||||
.ui-icon-tactical_view,
|
||||
.ui-icon-events,
|
||||
.ui-icon-groups,
|
||||
.ui-icon-alerts,
|
||||
.ui-icon-agents,
|
||||
.ui-icon-modules,
|
||||
.ui-icon-server-status,
|
||||
.ui-icon-services,
|
||||
.ui-icon-network_maps,
|
||||
.ui-icon-visual_console,
|
||||
.ui-icon-dashboard {
|
||||
|
@ -1323,6 +1350,8 @@ table.tactical_bars {
|
|||
.ui-icon-alerts,
|
||||
.ui-icon-agents,
|
||||
.ui-icon-modules,
|
||||
.ui-icon-server-status,
|
||||
.ui-icon-services,
|
||||
.ui-icon-network_maps,
|
||||
.ui-icon-visual_console,
|
||||
.ui-icon-dashboard {
|
||||
|
@ -1339,6 +1368,8 @@ table.tactical_bars {
|
|||
.ui-icon-alerts,
|
||||
.ui-icon-agents,
|
||||
.ui-icon-modules,
|
||||
.ui-icon-server-status,
|
||||
.ui-icon-services,
|
||||
.ui-icon-network_maps,
|
||||
.ui-icon-visual_console,
|
||||
.ui-icon-dashboard {
|
||||
|
@ -1776,3 +1807,35 @@ span.agents-counter {
|
|||
float: right;
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
span.agents-counter span {
|
||||
padding-left: 1px;
|
||||
padding-right: 1px;
|
||||
}
|
||||
|
||||
div.border-collapsible
|
||||
> h4.ui-collapsible-heading
|
||||
+ div.ui-collapsible-content {
|
||||
border-width: 1px !important;
|
||||
border-top: 0px !important;
|
||||
border-left: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
table[id^="service-table-"] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table[id^="service-table-"] > tbody > tr:nth-child(even) {
|
||||
background-color: #ebebeb;
|
||||
}
|
||||
|
||||
table[id^="service-table-"] a strong {
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
.mt15px {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
|
|
@ -151,10 +151,35 @@ class System
|
|||
}
|
||||
|
||||
|
||||
public function checkEnterprise($page='')
|
||||
{
|
||||
if ((int) $this->getConfig('enterprise_installed', false) === 1) {
|
||||
return true;
|
||||
} else {
|
||||
if (empty($this->getRequest('page', false)) === false && $page === '') {
|
||||
$page = $this->getRequest('page', false);
|
||||
}
|
||||
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_ENTERPRISE_VIOLATION,
|
||||
'Trying to access to Mobile Page: '.$page
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getDefaultACLFailText()
|
||||
{
|
||||
return __('Access to this page is restricted to authorized users only, please contact your system administrator if you should need help.').'<br><br>'.__('Please remember that any attempts to access this page will be recorded on the %s System Database.', get_product_name());
|
||||
}
|
||||
|
||||
|
||||
public static function getDefaultLicenseFailText()
|
||||
{
|
||||
return __('Invalid license, please contact your system administrator if you should need help.').'<br><br>'.__('Please remember that any attempts to access this page will be recorded on the %s System Database.', get_product_name());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ require_once 'operation/agent.php';
|
|||
require_once 'operation/visualmaps.php';
|
||||
require_once 'operation/visualmap.php';
|
||||
require_once 'operation/server_status.php';
|
||||
require_once 'operation/services.php';
|
||||
$enterpriseHook = enterprise_include('mobile/include/enterprise.class.php');
|
||||
$enterpriseHook = enterprise_include('mobile/operation/home.php');
|
||||
|
||||
|
@ -183,6 +184,11 @@ switch ($action) {
|
|||
$server_status->ajax($parameter2);
|
||||
break;
|
||||
|
||||
case 'services':
|
||||
$services = new Services();
|
||||
$services->ajax($parameter2);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (class_exists('Enterprise')) {
|
||||
$enterprise->enterpriseAjax($parameter1, $parameter2);
|
||||
|
@ -418,6 +424,11 @@ switch ($action) {
|
|||
$server_status = new ServerStatus();
|
||||
$server_status->show();
|
||||
break;
|
||||
|
||||
case 'services':
|
||||
$services = new Services();
|
||||
$services->show();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class Home
|
|||
|
||||
$items = [];
|
||||
|
||||
// In home
|
||||
// In home.
|
||||
$items['tactical'] = [
|
||||
'name' => __('Tactical view'),
|
||||
'filename' => 'tactical.php',
|
||||
|
@ -95,9 +95,18 @@ class Home
|
|||
'name' => __('Server status'),
|
||||
'filename' => 'server_status.php',
|
||||
'menu_item' => true,
|
||||
'icon' => 'ui-icon- ui-widget-icon-floatbeginning',
|
||||
'icon' => 'ui-icon-server-status ui-widget-icon-floatbeginning',
|
||||
];
|
||||
|
||||
if ((int) $system->getConfig('enterprise_installed', false) === 1) {
|
||||
$items['services'] = [
|
||||
'name' => __('Services'),
|
||||
'filename' => 'services.php',
|
||||
'menu_item' => true,
|
||||
'icon' => 'ui-icon-services ui-widget-icon-floatbeginning',
|
||||
];
|
||||
}
|
||||
|
||||
// Not in home.
|
||||
$items['agent'] = [
|
||||
'name' => __('Agent'),
|
||||
|
|
|
@ -0,0 +1,536 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
use PandoraFMS\Enterprise\Service;
|
||||
|
||||
require_once '../include/functions_users.php';
|
||||
enterprise_include_once('meta/include/functions_ui_meta.php');
|
||||
require_once '../include/functions_groupview.php';
|
||||
|
||||
class Services
|
||||
{
|
||||
|
||||
private $correct_acl = false;
|
||||
|
||||
private $enterprise = false;
|
||||
|
||||
private $acl = 'AR';
|
||||
|
||||
private $services = [];
|
||||
|
||||
private $idTable = '';
|
||||
|
||||
private $serviceId = '';
|
||||
|
||||
private $rows = [];
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$system = System::getInstance();
|
||||
|
||||
if ($system->checkACL($this->acl)) {
|
||||
$this->correct_acl = true;
|
||||
|
||||
$this->services = enterprise_hook('services_get_services');
|
||||
} else {
|
||||
$this->correct_acl = false;
|
||||
}
|
||||
|
||||
if ($system->checkEnterprise() === false) {
|
||||
$this->show_fail_enterprise();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function show()
|
||||
{
|
||||
if (!$this->correct_acl) {
|
||||
$this->show_fail_acl();
|
||||
} else {
|
||||
$this->show_services();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function show_fail_acl()
|
||||
{
|
||||
$error['type'] = 'onStart';
|
||||
$error['title_text'] = __('You don\'t have access to this page');
|
||||
$error['content_text'] = System::getDefaultACLFailText();
|
||||
if (class_exists('HomeEnterprise')) {
|
||||
$home = new HomeEnterprise();
|
||||
} else {
|
||||
$home = new Home();
|
||||
}
|
||||
|
||||
$home->show($error);
|
||||
}
|
||||
|
||||
|
||||
private function show_fail_enterprise()
|
||||
{
|
||||
$error['type'] = 'onStart';
|
||||
$error['title_text'] = __('You don\'t have access to this page');
|
||||
$error['content_text'] = System::getDefaultLicenseFailText();
|
||||
if (class_exists('HomeEnterprise')) {
|
||||
$home = new HomeEnterprise();
|
||||
} else {
|
||||
$home = new Home();
|
||||
}
|
||||
|
||||
$home->show($error);
|
||||
}
|
||||
|
||||
|
||||
public function ajax($parameter2=false)
|
||||
{
|
||||
$system = System::getInstance();
|
||||
|
||||
if (!$this->correct_acl) {
|
||||
return;
|
||||
} else {
|
||||
switch ($parameter2) {
|
||||
case 'get_services':
|
||||
$this->serviceId = $system->getRequest('service_id', 0);
|
||||
$rows = $this->getListServices();
|
||||
|
||||
$this->rows = $rows;
|
||||
$table = $this->getTable();
|
||||
|
||||
echo $table;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function show_services()
|
||||
{
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
$ui->createPage();
|
||||
$ui->createDefaultHeader(
|
||||
__('Services'),
|
||||
$ui->createHeaderButton(
|
||||
[
|
||||
'icon' => 'ui-icon-back',
|
||||
'pos' => 'left',
|
||||
'text' => __('Back'),
|
||||
'href' => 'index.php?page=home',
|
||||
'class' => 'header-button-left',
|
||||
]
|
||||
)
|
||||
);
|
||||
$ui->showFooter(false);
|
||||
$ui->beginContent();
|
||||
|
||||
$ui->contentAddHtml('<div class="list_services" data-role="collapsible-set" data-theme="a" data-content-theme="d">');
|
||||
$count = 0;
|
||||
$url_agent = 'index.php?page=agents&group=%s&status=%s';
|
||||
$url_modules = 'index.php?page=modules&group=%s&status=%s';
|
||||
|
||||
foreach ($this->services as $service) {
|
||||
switch ($service['status']) {
|
||||
case SERVICE_STATUS_NORMAL:
|
||||
$color = COL_NORMAL;
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_CRITICAL:
|
||||
$color = COL_CRITICAL;
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_WARNING:
|
||||
$color = COL_WARNING;
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_UNKNOWN:
|
||||
default:
|
||||
$color = COL_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
$group_icon = ui_print_group_icon($service['id_group'], true, '../images/groups_small_white', '', false);
|
||||
|
||||
$ui->contentAddHtml(
|
||||
'
|
||||
<style type="text/css">
|
||||
.ui-icon-group_'.$count.' {
|
||||
background-color: '.$color.' !important;
|
||||
}
|
||||
</style>
|
||||
'
|
||||
);
|
||||
$ui->contentAddHtml('<div class="border-collapsible" data-collapsed-icon="group_'.$count.'" data-expanded-icon="group_'.$count.'" data-iconpos="right" data-role="collapsible" data-collapsed="true" data-content-theme="d">');
|
||||
$ui->contentAddHtml('<h4 id="service-'.$service['id'].'" onclick="loadTable(\''.$service['id'].'\')">'.$group_icon.' '.$service['description'].'</h4>');
|
||||
|
||||
$spinner = '
|
||||
<div class="spinner mt15px" id="spinner-'.$service['id'].'">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
';
|
||||
|
||||
$ui->contentAddHtml($spinner);
|
||||
$ui->contentAddHtml('</div>');
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
$ui->contentAddHtml('</div>');
|
||||
$this->addJavascriptAddBottom();
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
|
||||
|
||||
public function getListServices()
|
||||
{
|
||||
$ui = Ui::getInstance();
|
||||
$this->idTable = 'service-table-'.$this->serviceId;
|
||||
$rows = [];
|
||||
|
||||
$elements_list = new Service($this->serviceId);
|
||||
$elements = $elements_list->getElements(true);
|
||||
|
||||
if (empty($elements) === false) {
|
||||
foreach ($elements as $item) {
|
||||
$name = '';
|
||||
// Icon.
|
||||
switch ($item->type()) {
|
||||
case SERVICE_ELEMENT_AGENT:
|
||||
$element_icon = html_print_image(
|
||||
'images/agents@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Agent'),
|
||||
'class' => 'main_menu_icon',
|
||||
]
|
||||
);
|
||||
|
||||
if ($item->exists() !== true) {
|
||||
$name .= '<strong class="red">'.__('Nonexistent. This element should be deleted').'</strong>';
|
||||
} else {
|
||||
$url = ui_get_full_url(
|
||||
'index.php?sec=eventos&sec2=operation/events/events&event_view_hr=8&severity=4&id_agent='.$item->agent()->id_agente()
|
||||
);
|
||||
$name = '<a target="_blank" href="'.$url.'">';
|
||||
if (((bool) $item->agent()->disabled()) === true) {
|
||||
$disabled_element = true;
|
||||
if (is_metaconsole() === true) {
|
||||
$name .= '<em class="grey_disabled">';
|
||||
} else {
|
||||
$name .= '<em class="disabled_module">';
|
||||
}
|
||||
}
|
||||
|
||||
$name .= '<strong>';
|
||||
if (is_metaconsole()
|
||||
&& ((int) $item->id_server_meta()) !== 0
|
||||
) {
|
||||
$name .= $item->nodeName().' » ';
|
||||
}
|
||||
|
||||
$name .= $item->agent()->alias();
|
||||
$name .= '</strong>';
|
||||
$name .= '</a>';
|
||||
|
||||
if (((bool) $item->agent()->disabled()) === true) {
|
||||
$name .= ui_print_help_tip(
|
||||
__('This element does not affect service weigth because is disabled.'),
|
||||
true
|
||||
).'</em>';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SERVICE_ELEMENT_SERVICE:
|
||||
$element_icon = html_print_image(
|
||||
'images/item-service.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Service'),
|
||||
'class' => 'main_menu_icon',
|
||||
]
|
||||
);
|
||||
if ($item->exists() !== true) {
|
||||
$name .= '<strong class="red">'.__('Nonexistent. This element should be deleted').'</strong>';
|
||||
} else {
|
||||
if (is_metaconsole()
|
||||
&& (((int) $item->id_server_meta()) !== 0 )
|
||||
) {
|
||||
$server = db_get_row(
|
||||
'tmetaconsole_setup',
|
||||
'id',
|
||||
$item->id_server_meta()
|
||||
);
|
||||
|
||||
$url = ui_meta_get_url_console_child(
|
||||
$server,
|
||||
'estado',
|
||||
'enterprise/operation/services/services',
|
||||
[
|
||||
'tab' => 'service',
|
||||
'action' => 'view',
|
||||
'id_service' => $item->id_service_child(),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$url = ui_get_full_url(
|
||||
'index.php?sec=network&sec2=enterprise/operation/services/services&tab=service&action=view&id_service='.$item->id_service_child()
|
||||
);
|
||||
}
|
||||
|
||||
$name = '<a target="_blank" href="'.$url.'">';
|
||||
if (((bool) $item->service()->disabled()) === true) {
|
||||
$disabled_element = true;
|
||||
if (is_metaconsole() === true) {
|
||||
$name .= '<em class="grey_disabled">';
|
||||
} else {
|
||||
$name .= '<em class="disabled_module">';
|
||||
}
|
||||
}
|
||||
|
||||
$name .= '<strong>';
|
||||
if (is_metaconsole()
|
||||
&& ((int) $item->id_server_meta()) !== 0
|
||||
) {
|
||||
$name .= $item->nodeName().' » ';
|
||||
}
|
||||
|
||||
$name .= $item->service()->name();
|
||||
$name .= '</strong>';
|
||||
$name .= '</a>';
|
||||
|
||||
if (((bool) $item->service()->disabled()) === true) {
|
||||
$name .= ui_print_help_tip(
|
||||
__('This element does not affect service weigth because is disabled.'),
|
||||
true
|
||||
).'</em>';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SERVICE_ELEMENT_MODULE:
|
||||
$element_icon = html_print_image(
|
||||
'images/modules@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Module'),
|
||||
'class' => 'main_menu_icon',
|
||||
]
|
||||
);
|
||||
|
||||
if ($item->exists() !== true) {
|
||||
$name .= '<strong class="red">'.__('Nonexistent. This element should be deleted').'</strong>';
|
||||
} else {
|
||||
$url = ui_get_full_url(
|
||||
'index.php?sec=eventos&sec2=operation/events/events&event_view_hr=8&severity=4&id_agent='.$item->module()->id_agente().'&id_agent_module='.$item->id_agente_modulo()
|
||||
);
|
||||
$name = '<a target="_blank" href="'.$url.'">';
|
||||
$name .= '<strong>';
|
||||
|
||||
if (((bool) $item->module()->disabled()) === true) {
|
||||
$disabled_element = true;
|
||||
if (is_metaconsole()) {
|
||||
$name .= '<em class="grey_disabled">';
|
||||
} else {
|
||||
$name .= '<em class="disabled_module">';
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole()
|
||||
&& ((int) $item->id_server_meta()) !== 0
|
||||
) {
|
||||
$name .= $item->nodeName().' » ';
|
||||
}
|
||||
|
||||
$name .= $item->module()->agent()->alias();
|
||||
$name .= ' » '.$item->module()->nombre();
|
||||
|
||||
if (((bool) $item->module()->disabled()) === true) {
|
||||
$name .= ui_print_help_tip(
|
||||
__('This element does not affect service weigth because is disabled.'),
|
||||
true
|
||||
).'</em>';
|
||||
}
|
||||
|
||||
$name .= '</strong>';
|
||||
$name .= '</a>';
|
||||
}
|
||||
break;
|
||||
|
||||
case SERVICE_ELEMENT_DYNAMIC:
|
||||
$element_icon = html_print_image(
|
||||
'images/modules-group@svg.svg',
|
||||
true,
|
||||
[
|
||||
'title' => __('Dynamic element'),
|
||||
'class' => 'main_menu_icon',
|
||||
]
|
||||
);
|
||||
|
||||
try {
|
||||
if (empty($item->getMatches(true)) === true) {
|
||||
ui_print_warning_message(
|
||||
__(
|
||||
'Dynamic element (%d) \'%s\' does not match any target',
|
||||
$item->id(),
|
||||
$item->description()
|
||||
)
|
||||
);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
ui_print_warning_message(
|
||||
__(
|
||||
'Dynamic element (%d) \'%s\' causes an error: %s',
|
||||
$item->id(),
|
||||
$item->description(),
|
||||
$e->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($item->rules()->dynamic_type === 'agent') {
|
||||
$name = '<i>'.__(
|
||||
'agents like "%s"',
|
||||
$item->rules()->agent_name
|
||||
).'</i>';
|
||||
} else if ($item->rules()->dynamic_type === 'module') {
|
||||
$name = '<i>'.__(
|
||||
'modules like "%s"',
|
||||
$item->rules()->module_name
|
||||
).'</i>';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$element_icon = '';
|
||||
break;
|
||||
}
|
||||
|
||||
// Status.
|
||||
switch ($item->lastStatus(true)) {
|
||||
case SERVICE_STATUS_NORMAL:
|
||||
case AGENT_STATUS_NORMAL:
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
$status_element = STATUS_MODULE_OK;
|
||||
$title_element = __('NORMAL');
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_CRITICAL:
|
||||
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$status_element = STATUS_MODULE_CRITICAL;
|
||||
$title_element = __('CRITICAL');
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_WARNING:
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
case AGENT_STATUS_WARNING:
|
||||
$status_element = STATUS_MODULE_WARNING;
|
||||
$title_element = __('WARNING');
|
||||
break;
|
||||
|
||||
case SERVICE_STATUS_ALERT:
|
||||
case AGENT_MODULE_STATUS_NOT_INIT:
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
$status_element = STATUS_MODULE_NO_DATA;
|
||||
$title_element = __('NOT INITIALIZED');
|
||||
break;
|
||||
|
||||
case AGENT_MODULE_STATUS_UNKNOWN:
|
||||
case SERVICE_STATUS_UNKNOWN:
|
||||
case AGENT_STATUS_UNKNOWN:
|
||||
default:
|
||||
$status_element = STATUS_MODULE_UNKNOWN;
|
||||
$title_element = __('UNKNOWN');
|
||||
break;
|
||||
}
|
||||
|
||||
$row = [];
|
||||
$row[0] = $element_icon;
|
||||
$row[1] = $name;
|
||||
$row[2] = ui_print_status_image($status_element, $title_element, true);
|
||||
|
||||
array_push($rows, $row);
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
|
||||
public function getTable()
|
||||
{
|
||||
$html = '';
|
||||
|
||||
$html = "<table data-role='table' id=service-table-".$this->serviceId."' data-mode='reflow' class='ui-responsive table-stroke'>";
|
||||
|
||||
// $html .= '<thead>';
|
||||
// $html .= '<tr>';
|
||||
// $html .= '<th class="head_horizontal">'.__('Type').'</th>';
|
||||
// $html .= '<th class="head_horizontal">'.__('Name').'</th>';
|
||||
// $html .= '<th class="head_horizontal">'.__('Status').'</th>';
|
||||
// $html .= '</tr>';
|
||||
// $html .= '</thead>';
|
||||
$html .= '<tbody>';
|
||||
foreach ($this->rows as $key => $row) {
|
||||
$html .= "<tr class=''>";
|
||||
|
||||
foreach ($row as $key_cell => $cell) {
|
||||
$html .= "<td class='cell_".$key_cell."'>".$cell.'</td>';
|
||||
}
|
||||
|
||||
$html .= '</tr>';
|
||||
}
|
||||
|
||||
$html .= '</tbody>';
|
||||
$html .= '</table>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
private function addJavascriptAddBottom()
|
||||
{
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
$ui->contentAddHtml(
|
||||
"<script type=\"text/javascript\">
|
||||
function loadTable(id) {
|
||||
|
||||
postvars = {};
|
||||
postvars[\"action\"] = \"ajax\";
|
||||
postvars[\"parameter1\"] = \"services\";
|
||||
postvars[\"parameter2\"] = \"get_services\";
|
||||
postvars[\"service_id\"] = id;
|
||||
|
||||
$.post(
|
||||
\"index.php\",
|
||||
postvars,
|
||||
function (data) {
|
||||
$('h4#service-'+id+' + div.ui-collapsible-content').html(data);
|
||||
},
|
||||
\"html\");
|
||||
}
|
||||
</script>"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue