cover for bulk service operations in mc/node
This commit is contained in:
parent
fc0b605cee
commit
390bf14761
|
@ -12,20 +12,19 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
global $config;
|
||||
global $agent_w;
|
||||
|
||||
check_login();
|
||||
ui_require_css_file('first_task');
|
||||
?>
|
||||
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no services defined yet.') ]); ?>
|
||||
|
||||
<?php if ($agent_w) { ?>
|
||||
<?php if ((bool) $agent_w === true) { ?>
|
||||
<div class="new_task">
|
||||
<div class="image_task">
|
||||
<?php echo html_print_image('images/first_task/icono_grande_servicios.png', true, ['title' => __('Services')]); ?>
|
||||
</div>
|
||||
<div class="text_task">
|
||||
<h3> <?php echo __('Create Services'); ?></h3><p id="description_task">
|
||||
<h3> <?php echo __('Create Services'); ?></h3>
|
||||
<p id="description_task">
|
||||
<?php
|
||||
echo __(
|
||||
"A service is a way to group your IT resources based on their functionalities.
|
||||
|
@ -36,8 +35,7 @@ ui_require_css_file('first_task');
|
|||
His company consists of three big departments: A management, an on-line shop and support."
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
</p>
|
||||
<form action="index.php?sec=estado&sec2=enterprise/godmode/services/services.service&action=new_service" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Create Services'); ?>" />
|
||||
</form>
|
||||
|
|
|
@ -1552,9 +1552,14 @@ function enterprise_hook($function_name, $parameters=false)
|
|||
|
||||
|
||||
/**
|
||||
* TODO: Document enterprise functions
|
||||
* Include an enterprise file.
|
||||
*
|
||||
* @param string $filename Enterprise file to be included.
|
||||
* @param array $variables Variables to be exported, as [varname => value].
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function enterprise_include($filename)
|
||||
function enterprise_include($filename, $variables=[])
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -1576,6 +1581,10 @@ function enterprise_include($filename)
|
|||
}
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
if (is_array($variables) === true) {
|
||||
extract($variables);
|
||||
}
|
||||
|
||||
include $filepath;
|
||||
return true;
|
||||
}
|
||||
|
@ -1587,11 +1596,12 @@ function enterprise_include($filename)
|
|||
/**
|
||||
* Includes a file from enterprise section.
|
||||
*
|
||||
* @param string $filename Target file.
|
||||
* @param string $filename Enterprise file to be included.
|
||||
* @param array $variables Variables to be exported, as [varname => value].
|
||||
*
|
||||
* @return mixed Result code.
|
||||
*/
|
||||
function enterprise_include_once($filename)
|
||||
function enterprise_include_once($filename, $variables=[])
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -1613,6 +1623,10 @@ function enterprise_include_once($filename)
|
|||
}
|
||||
|
||||
if (file_exists($filepath)) {
|
||||
if (is_array($variables) === true) {
|
||||
extract($variables);
|
||||
}
|
||||
|
||||
include_once $filepath;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1488,12 +1488,16 @@ function html_print_select_multiple_modules_filtered(array $data):string
|
|||
]
|
||||
);
|
||||
|
||||
$all_modules = select_modules_for_agent_group(
|
||||
$data['mModuleGroup'],
|
||||
explode(',', $data['mAgents']),
|
||||
$data['mShowCommonModules'],
|
||||
false
|
||||
);
|
||||
if ($data['mAgents'] !== null) {
|
||||
$all_modules = select_modules_for_agent_group(
|
||||
$data['mModuleGroup'],
|
||||
explode(',', $data['mAgents']),
|
||||
$data['mShowCommonModules'],
|
||||
false
|
||||
);
|
||||
} else {
|
||||
$all_modules = [];
|
||||
}
|
||||
|
||||
if ($data['mShowSelectedOtherGroups']) {
|
||||
$selected_modules_ids = explode(',', $data['mModules']);
|
||||
|
|
|
@ -217,7 +217,12 @@ function fmModuleChange(uniqId) {
|
|||
if (data) {
|
||||
jQuery.each(data, function(id, value) {
|
||||
var option = $("<option></option>")
|
||||
.attr("value", value["id_agente_modulo"])
|
||||
.attr(
|
||||
"value",
|
||||
value["id_node"]
|
||||
? value["id_node"] + "|" + value["id_agente_modulo"]
|
||||
: value["id_agente_modulo"]
|
||||
)
|
||||
.html(value["nombre"]);
|
||||
$("#filtered-module-modules-" + uniqId).append(option);
|
||||
});
|
||||
|
|
|
@ -388,7 +388,7 @@ function initialiceLayout(data) {
|
|||
dashboardId: data.dashboardId,
|
||||
widgetId: widgetId
|
||||
},
|
||||
width: widgetId == 14 ? 750 : 450,
|
||||
width: widgetId == 14 || widgetId == 2 ? 750 : 450,
|
||||
maxHeight: 600,
|
||||
minHeight: 400
|
||||
},
|
||||
|
|
|
@ -299,10 +299,28 @@ class AgentModuleWidget extends Widget
|
|||
$values['mShowCommonModules'] = \get_parameter(
|
||||
'filtered-module-show-common-modules-'.$this->cellId
|
||||
);
|
||||
$values['mModules'] = \get_parameter(
|
||||
'filtered-module-modules-'.$this->cellId
|
||||
$values['mModules'] = explode(
|
||||
',',
|
||||
\get_parameter(
|
||||
'filtered-module-modules-'.$this->cellId
|
||||
)
|
||||
);
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$values['mModules'] = implode(
|
||||
',',
|
||||
array_reduce(
|
||||
$values['mModules'],
|
||||
function ($carry, $item) {
|
||||
$d = explode('|', $item);
|
||||
$carry[] = $d[1];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
@ -620,6 +638,10 @@ class AgentModuleWidget extends Widget
|
|||
$reduceAllModules = array_reduce(
|
||||
$all_modules,
|
||||
function ($carry, $item) {
|
||||
if ($item === null) {
|
||||
return $carry;
|
||||
}
|
||||
|
||||
$carry[$item->name()] = null;
|
||||
return $carry;
|
||||
}
|
||||
|
@ -659,6 +681,10 @@ class AgentModuleWidget extends Widget
|
|||
|
||||
$visualData[$agent_id]['modules'] = $reduceAllModules;
|
||||
foreach ($modules as $module) {
|
||||
if ($module === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((bool) is_metaconsole() === true) {
|
||||
$reduceAllModules[$module->name()] = null;
|
||||
}
|
||||
|
|
|
@ -161,13 +161,24 @@ class Module extends Entity
|
|||
$obj->{$k}($v);
|
||||
}
|
||||
|
||||
if ($obj->nombre() === 'delete_pending') {
|
||||
if ($obj->nombre() === 'delete_pending'
|
||||
|| $obj->nombre() === 'pendingdelete'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Customize certain fields.
|
||||
$obj->status = new ModuleStatus($obj->id_agente_modulo());
|
||||
$obj->moduleType = new ModuleType($obj->id_tipo_modulo());
|
||||
try {
|
||||
$obj->status = new ModuleStatus($obj->id_agente_modulo());
|
||||
} catch (\Exception $e) {
|
||||
$obj->status = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$obj->moduleType = new ModuleType($obj->id_tipo_modulo());
|
||||
} catch (\Exception $e) {
|
||||
$obj->moduleType = null;
|
||||
}
|
||||
|
||||
// Include some enterprise dependencies.
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
div#page {
|
||||
width: auto;
|
||||
}
|
||||
li#select_multiple_modules_filtered {
|
||||
width: 650px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.networkconsole {
|
||||
height: 100%;
|
||||
}
|
||||
|
|
|
@ -31,12 +31,20 @@ ul.wizard.inline li {
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
ul.wizard li > label:not(.p-switch) {
|
||||
ul.wizard li > label:not(.p-switch):first-of-type {
|
||||
width: 250px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ul.wizard li > label:not(.p-switch):not(:first-of-type) {
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.select2.select2-container {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
ul.wizard li > textarea {
|
||||
width: 600px;
|
||||
height: 15em;
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
* ============================================================================
|
||||
*/
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
global $config;
|
||||
|
||||
require_once 'include/functions_gis.php';
|
||||
|
@ -192,9 +194,14 @@ if (is_ajax()) {
|
|||
|
||||
if ($get_modules_group_json) {
|
||||
$id_group = (int) get_parameter('id_module_group', 0);
|
||||
$id_agents = get_parameter('id_agents');
|
||||
$id_agents = get_parameter('id_agents', null);
|
||||
$selection = get_parameter('selection');
|
||||
|
||||
if ($id_agents === null) {
|
||||
echo '[]';
|
||||
return;
|
||||
}
|
||||
|
||||
if ((bool) is_metaconsole() === true) {
|
||||
if (count($id_agents) > 0) {
|
||||
$rows = db_get_all_rows_sql(
|
||||
|
@ -270,8 +277,14 @@ if (is_ajax()) {
|
|||
// All modules.
|
||||
$modules = array_reduce(
|
||||
$modules[$tserver],
|
||||
function ($carry, $item) {
|
||||
$carry[] = $item;
|
||||
function ($carry, $item) use ($tserver) {
|
||||
$t = [];
|
||||
foreach ($item as $k => $v) {
|
||||
$t[$k] = $v;
|
||||
}
|
||||
|
||||
$t['id_node'] = $tserver;
|
||||
$carry[] = $t;
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
|
@ -290,10 +303,21 @@ if (is_ajax()) {
|
|||
|
||||
foreach ($modules as $def) {
|
||||
$data = explode('|', $def);
|
||||
$id_agent = $data[0];
|
||||
$module_name = $data[1];
|
||||
if (is_metaconsole() === true) {
|
||||
$id_node = (int) $data[0];
|
||||
$id_agent = (int) $data[1];
|
||||
$module_name = $data[2];
|
||||
} else {
|
||||
$id_agent = $data[0];
|
||||
$module_name = $data[1];
|
||||
}
|
||||
|
||||
try {
|
||||
if (is_metaconsole() === true) {
|
||||
$node = new Node($id_node);
|
||||
$node->connect();
|
||||
}
|
||||
|
||||
$module = PandoraFMS\Module::search(
|
||||
[
|
||||
'id_agente' => $id_agent,
|
||||
|
@ -303,14 +327,30 @@ if (is_ajax()) {
|
|||
);
|
||||
|
||||
if ($module !== null) {
|
||||
$text = '';
|
||||
if ($node !== null) {
|
||||
$text = $node->server_name().' » ';
|
||||
$id = $node->id().'|';
|
||||
}
|
||||
|
||||
$text .= $module->agent()->alias().' » '.$module->nombre();
|
||||
|
||||
$id .= $module->id_agente_modulo();
|
||||
$existing_modules[] = [
|
||||
'id' => $module->id_agente_modulo(),
|
||||
'text' => io_safe_output(
|
||||
$module->agent()->alias().' » '.$module->nombre()
|
||||
),
|
||||
'id' => $id,
|
||||
'text' => io_safe_output($text),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$node->disconnect();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if ($node !== null) {
|
||||
$node->disconnect();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue