new modal planned_downtime resume agents/modules pandora_enterprise#5886
This commit is contained in:
parent
625438c1c3
commit
b56c9e6529
|
@ -61,6 +61,98 @@ require_once 'include/functions_events.php';
|
|||
require_once 'include/functions_planned_downtimes.php';
|
||||
require_once 'include/functions_reporting.php';
|
||||
|
||||
if (is_ajax() === true) {
|
||||
$show_info_agents_modules_affected = (bool) get_parameter(
|
||||
'show_info_agents_modules_affected',
|
||||
false
|
||||
);
|
||||
|
||||
$get_info_agents_modules_affected = (bool) get_parameter(
|
||||
'get_info_agents_modules_affected',
|
||||
false
|
||||
);
|
||||
|
||||
if ($show_info_agents_modules_affected === true) {
|
||||
$id = (int) get_parameter('id', 0);
|
||||
|
||||
$columns = [
|
||||
'agent_name',
|
||||
'module_name',
|
||||
];
|
||||
|
||||
$column_names = [
|
||||
__('Agents'),
|
||||
__('Modules'),
|
||||
];
|
||||
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => 'agent_modules_affected_planned_downtime',
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => 'godmode/agentes/planned_downtime.list',
|
||||
'ajax_data' => [
|
||||
'get_info_agents_modules_affected' => 1,
|
||||
'id' => $id,
|
||||
],
|
||||
'order' => [
|
||||
'field' => 'agent_name',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Agents'),
|
||||
'type' => 'text',
|
||||
'class' => 'w200px',
|
||||
'id' => 'filter_agents',
|
||||
'name' => 'filter_agents',
|
||||
],
|
||||
[
|
||||
'label' => __('Modules'),
|
||||
'type' => 'text',
|
||||
'class' => 'w200px',
|
||||
'id' => 'filter_modules',
|
||||
'name' => 'filter_modules',
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_info_agents_modules_affected === true) {
|
||||
$id = (int) get_parameter('id', 0);
|
||||
|
||||
// Catch post parameters.
|
||||
$options = [
|
||||
'limit' => get_parameter('start', 0),
|
||||
'offset' => get_parameter('length', $config['block_size']),
|
||||
'order' => get_datatable_order(),
|
||||
'filters' => get_parameter('filter', []),
|
||||
];
|
||||
|
||||
$modules = get_agents_modules_planned_dowtime($id, $options);
|
||||
$count = get_agents_modules_planned_dowtime($id, $options, $count);
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $modules,
|
||||
'recordsTotal' => $count[0]['total'],
|
||||
'recordsFiltered' => $count[0]['total'],
|
||||
]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$malformed_downtimes = planned_downtimes_get_malformed();
|
||||
$malformed_downtimes_exist = (empty($malformed_downtimes) === false) ? true : false;
|
||||
$migrate_malformed = (bool) get_parameter('migrate_malformed');
|
||||
|
@ -297,7 +389,7 @@ if (empty($groups) === false) {
|
|||
if (empty($search_text) === false) {
|
||||
$filter_performed = true;
|
||||
$where_values .= sprintf(
|
||||
' AND (name LIKE "%%s%" OR description LIKE "%%s%")',
|
||||
' AND (name LIKE "%%%s%%" OR description LIKE "%%%s%%")',
|
||||
$search_text,
|
||||
$search_text
|
||||
);
|
||||
|
@ -522,6 +614,7 @@ if ($downtimes === false && $filter_performed === false) {
|
|||
$table->head['execution'] = __('Execution');
|
||||
$table->head['configuration'] = __('Configuration');
|
||||
$table->head['running'] = __('Running');
|
||||
$table->head['agents_modules'] = __('Affected');
|
||||
|
||||
if ($write_permisson === true
|
||||
|| $manage_permisson === true
|
||||
|
@ -597,6 +690,24 @@ if ($downtimes === false && $filter_performed === false) {
|
|||
);
|
||||
}
|
||||
|
||||
$settings = [
|
||||
'url' => ui_get_full_url('ajax.php', false, false, false),
|
||||
'loadingText' => __('Loading, this operation might take several minutes...'),
|
||||
'title' => __('Agents / Modules affected'),
|
||||
'id' => $downtime['id'],
|
||||
];
|
||||
|
||||
$data['agents_modules'] = '<a href="#" onclick=\'dialogAgentModulesAffected('.json_encode($settings).')\'>';
|
||||
$data['agents_modules'] .= html_print_image(
|
||||
'images/search_big.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Agents and modules affected'),
|
||||
'style' => 'width:22px; height: 22px;',
|
||||
]
|
||||
);
|
||||
$data['agents_modules'] .= '</a>';
|
||||
|
||||
// If user have writting permissions.
|
||||
if (in_array($downtime['id_group'], $groupsAD) === true) {
|
||||
// Stop button.
|
||||
|
@ -775,6 +886,7 @@ ui_require_jquery_file(
|
|||
'include/javascript/i18n/'
|
||||
);
|
||||
|
||||
ui_require_javascript_file('pandora_planned_downtimes');
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
||||
|
|
|
@ -989,7 +989,7 @@ function planned_downtimes_copy($id_downtime)
|
|||
foreach ($planned_modules as $planned_module) {
|
||||
// Unset id.
|
||||
unset($planned_module['id']);
|
||||
// Set id_planned downtime
|
||||
// Set id_planned downtime.
|
||||
$planned_module['id_downtime'] = $result['id_downtime'];
|
||||
$result['id_modules'][] = db_process_sql_insert(
|
||||
'tplanned_downtime_moduless',
|
||||
|
@ -1004,3 +1004,82 @@ function planned_downtimes_copy($id_downtime)
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get agentts and modules for planned_downtime.
|
||||
*
|
||||
* @param [type] $id Id planned.
|
||||
*
|
||||
* @return array Result array data.
|
||||
*/
|
||||
function get_agents_modules_planned_dowtime($id, $options, $count=false)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$filters_agent = '';
|
||||
if (isset($options['filters']['filter_agents']) === true
|
||||
&& empty($options['filters']['filter_agents']) === false
|
||||
) {
|
||||
$filters_agent = sprintf(
|
||||
' AND (tagente.alias LIKE "%%%s%%")',
|
||||
$options['filters']['filter_agents']
|
||||
);
|
||||
}
|
||||
|
||||
$filters_module = '';
|
||||
if (isset($options['filters']['filter_modules']) === true
|
||||
&& empty($options['filters']['filter_modules']) === false
|
||||
) {
|
||||
$filters_module = sprintf(
|
||||
' AND (tagente_modulo.nombre LIKE "%%%s%%")',
|
||||
$options['filters']['filter_modules']
|
||||
);
|
||||
}
|
||||
|
||||
if ($count === false) {
|
||||
$query = sprintf(
|
||||
'SELECT tplanned_downtime_modules.*,
|
||||
tagente.alias as agent_name,
|
||||
tagente_modulo.nombre as module_name
|
||||
FROM tplanned_downtime_modules
|
||||
INNER JOIN tagente
|
||||
ON tplanned_downtime_modules.id_agent = tagente.id_agente
|
||||
INNER JOIN tagente_modulo
|
||||
ON tplanned_downtime_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
WHERE id_downtime = %d
|
||||
%s
|
||||
%s
|
||||
ORDER BY %s
|
||||
LIMIT %d, %d',
|
||||
$id,
|
||||
$filters_agent,
|
||||
$filters_module,
|
||||
$options['order'],
|
||||
$options['limit'],
|
||||
$options['offset']
|
||||
);
|
||||
} else {
|
||||
$query = sprintf(
|
||||
'SELECT count(tplanned_downtime_modules.id) as total
|
||||
FROM tplanned_downtime_modules
|
||||
INNER JOIN tagente
|
||||
ON tplanned_downtime_modules.id_agent = tagente.id_agente
|
||||
INNER JOIN tagente_modulo
|
||||
ON tplanned_downtime_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
WHERE id_downtime = %d
|
||||
%s
|
||||
%s',
|
||||
$id,
|
||||
$filters_agent,
|
||||
$filters_module
|
||||
);
|
||||
}
|
||||
|
||||
$result = db_get_all_rows_sql($query);
|
||||
if ($result === false) {
|
||||
$result = [];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -3618,6 +3618,15 @@ function ui_print_datatable(array $parameters)
|
|||
ui_require_javascript_file('buttons.html5.min');
|
||||
ui_require_javascript_file('buttons.print.min');
|
||||
} else {
|
||||
// Load datatable.min.css.
|
||||
$output .= '<link rel="stylesheet" href="';
|
||||
$output .= ui_get_full_url(
|
||||
'include/styles/js/datatables.min.css',
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
$output .= '"/>';
|
||||
// Load tables.css.
|
||||
$output .= '<link rel="stylesheet" href="';
|
||||
$output .= ui_get_full_url(
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* globals $, uniqId, confirmDialog*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function dialogAgentModulesAffected(settings) {
|
||||
confirmDialog({
|
||||
title: settings.title,
|
||||
size: 500,
|
||||
message: function() {
|
||||
var id = "div-" + uniqId();
|
||||
var loading = settings.loadingText;
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: settings.url,
|
||||
data: {
|
||||
page: "godmode/agentes/planned_downtime.list",
|
||||
show_info_agents_modules_affected: 1,
|
||||
id: settings.id
|
||||
},
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#" + id)
|
||||
.empty()
|
||||
.append(data);
|
||||
},
|
||||
error: function(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
return "<div id ='" + id + "'>" + loading + "</div>";
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue