#13059 new view widget agent module dashboard
This commit is contained in:
parent
02d6dbdcdb
commit
7cdca7e622
|
@ -1854,6 +1854,272 @@ function html_print_select_multiple_modules_filtered(array $data):string
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Form multiple inputs for slect groups.
|
||||
*
|
||||
* @param array $data Data inputs.
|
||||
*
|
||||
* @return string Html output.
|
||||
*/
|
||||
function html_print_select_multiple_modules_filtered_formated(array $data):string
|
||||
{
|
||||
if (is_ajax() === true) {
|
||||
ui_require_javascript_file(
|
||||
'multiselect_filtered',
|
||||
'include/javascript/',
|
||||
true
|
||||
);
|
||||
ui_require_css_file(
|
||||
'multiselect_filtered',
|
||||
'include/styles/',
|
||||
true
|
||||
);
|
||||
} else {
|
||||
ui_require_javascript_file('multiselect_filtered');
|
||||
ui_require_css_file('multiselect_filtered');
|
||||
}
|
||||
|
||||
$uniqId = $data['uniqId'];
|
||||
|
||||
$return_all_group = isset($data['mReturnAllGroup']) ? $data['mReturnAllGroup'] : true;
|
||||
|
||||
// Group.
|
||||
$output = '<div class="w98p">';
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Group'),
|
||||
'label_class' => 'font-title-font',
|
||||
'name' => 'filtered-module-group-'.$uniqId,
|
||||
'returnAllGroup' => $return_all_group,
|
||||
'privilege' => 'AR',
|
||||
'type' => 'select_groups',
|
||||
'return' => true,
|
||||
'script' => 'fmAgentChange(\''.$uniqId.'\')',
|
||||
'selected' => $data['mGroup'],
|
||||
]
|
||||
);
|
||||
|
||||
// Groups module.
|
||||
$module_groups = db_get_all_rows_sql(
|
||||
'SELECT * FROM tmodule_group ORDER BY name'
|
||||
);
|
||||
$module_groups = array_reduce(
|
||||
$module_groups,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['id_mg']] = $item['name'];
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Module group'),
|
||||
'label_class' => 'font-title-font',
|
||||
'type' => 'select',
|
||||
'fields' => $module_groups,
|
||||
'name' => 'filtered-module-module-group-'.$uniqId,
|
||||
'selected' => $data['mModuleGroup'],
|
||||
'return' => true,
|
||||
'nothing' => __('All'),
|
||||
'nothing_value' => 0,
|
||||
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
|
||||
]
|
||||
);
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="recursive-modules">';
|
||||
|
||||
// Recursion.
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Recursion'),
|
||||
'label_class' => 'font-title-font',
|
||||
'type' => 'switch',
|
||||
'name' => 'filtered-module-recursion-'.$uniqId,
|
||||
'value' => (empty($data['mRecursion']) === true) ? false : true,
|
||||
'checked' => (empty($data['mRecursion']) === true) ? false : true,
|
||||
'return' => true,
|
||||
'id' => 'filtered-module-recursion-'.$uniqId,
|
||||
'onchange' => 'fmAgentChange(\''.$uniqId.'\')',
|
||||
]
|
||||
);
|
||||
|
||||
$commonModules = 0;
|
||||
if (empty($data['mShowCommonModules']) === false) {
|
||||
$commonModules = 1;
|
||||
}
|
||||
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Only common modules'),
|
||||
'label_class' => 'font-title-font',
|
||||
'type' => 'switch',
|
||||
'checked' => $commonModules,
|
||||
'value' => $commonModules,
|
||||
'name' => 'filtered-module-show-common-modules-'.$uniqId,
|
||||
'id' => 'filtered-module-show-common-modules-'.$uniqId,
|
||||
'return' => true,
|
||||
'onchange' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
|
||||
]
|
||||
);
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
if (empty($data['searchBar']) === false && $data['searchBar'] === true) {
|
||||
$output .= '<div>';
|
||||
|
||||
$output .= '<div>';
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'type' => 'text',
|
||||
'name' => 'agent-searchBar-'.$uniqId,
|
||||
'onKeyUp' => 'searchAgent(\''.$uniqId.'\')',
|
||||
'placeholder' => __('Type to search agents'),
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<div>';
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'type' => 'text',
|
||||
'name' => 'module-searchBar-'.$uniqId,
|
||||
'onKeyUp' => 'searchModule(\''.$uniqId.'\')',
|
||||
'return' => true,
|
||||
'placeholder' => __('Type to search modules'),
|
||||
]
|
||||
);
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
||||
$output .= '<div class="w98p">';
|
||||
// Agent.
|
||||
$agents = agents_get_group_agents(
|
||||
// Id_group.
|
||||
$data['mGroup'],
|
||||
// Search.
|
||||
false,
|
||||
// Case.
|
||||
'lower',
|
||||
// NoACL.
|
||||
false,
|
||||
// ChildGroups.
|
||||
false,
|
||||
// Serialized.
|
||||
false,
|
||||
// Separator.
|
||||
'|',
|
||||
// Add_alert_bulk_op.
|
||||
false,
|
||||
// Force_serialized.
|
||||
false,
|
||||
// Meta_fields.
|
||||
($data['mMetaFields'] ?? is_metaconsole())
|
||||
);
|
||||
|
||||
if ((empty($agents)) === true || $agents == -1) {
|
||||
$agents = [];
|
||||
}
|
||||
|
||||
if ($data['mShowSelectedOtherGroups']) {
|
||||
$selected_agents = explode(',', $data['mAgents']);
|
||||
foreach ($selected_agents as $agent_id) {
|
||||
if (!array_key_exists($agent_id, $agents)) {
|
||||
$agents[$agent_id] = agents_get_alias($agent_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_metaconsole() === true) {
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Agents'),
|
||||
'label_class' => 'font-title-font',
|
||||
'type' => 'select',
|
||||
'fields' => $agents,
|
||||
'name' => 'filtered-module-agents-'.$uniqId,
|
||||
'selected' => explode(',', $data['mAgents']),
|
||||
'return' => true,
|
||||
'multiple' => true,
|
||||
'style' => 'min-width: 200px;max-width:200px;',
|
||||
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
|
||||
'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '',
|
||||
]
|
||||
);
|
||||
} else {
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Agents'),
|
||||
'label_class' => 'font-title-font',
|
||||
'type' => 'select_from_sql',
|
||||
'sql' => 'SELECT `id_agente`,`alias` FROM tagente',
|
||||
'name' => 'filtered-module-agents-'.$uniqId,
|
||||
'selected' => explode(',', $data['mAgents']),
|
||||
'return' => true,
|
||||
'multiple' => true,
|
||||
'style' => 'min-width: 200px;max-width:200px;',
|
||||
'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')',
|
||||
'placeholder' => (isset($data['placeholderAgents']) === true) ? $data['placeholderAgents'] : '',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($data['mAgents']) === false
|
||||
&& empty($data['mModuleGroup'] === false)
|
||||
) {
|
||||
$all_modules = get_modules_agents(
|
||||
$data['mModuleGroup'],
|
||||
explode(',', $data['mAgents']),
|
||||
!$commonModules,
|
||||
false,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$all_modules = [];
|
||||
}
|
||||
|
||||
$mModules = $data['mModules'];
|
||||
if (is_array($data['mModules']) === false) {
|
||||
$mModules = explode(
|
||||
',',
|
||||
$data['mModules']
|
||||
);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
// Clean double safe input.
|
||||
foreach ($mModules as $name) {
|
||||
$result[] = io_safe_output($name);
|
||||
}
|
||||
|
||||
$output .= html_print_input(
|
||||
[
|
||||
'label' => __('Modules'),
|
||||
'label_class' => 'font-title-font',
|
||||
'type' => 'select',
|
||||
'fields' => $all_modules,
|
||||
'name' => 'filtered-module-modules-'.$uniqId,
|
||||
'selected' => $result,
|
||||
'return' => true,
|
||||
'multiple' => true,
|
||||
'style' => 'max-width:98%;',
|
||||
'input_class' => 'flex-colum-center-important',
|
||||
]
|
||||
);
|
||||
|
||||
$output .= '</div>';
|
||||
if ($data['return'] === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints an array of fields in a popup menu of a form based on a SQL query.
|
||||
* The first and second columns of the query will be used.
|
||||
|
@ -6108,6 +6374,10 @@ function html_print_input($data, $wrapper='div', $input_only=false)
|
|||
$output .= html_print_select_multiple_modules_filtered($data);
|
||||
break;
|
||||
|
||||
case 'select_multiple_modules_filtered_formated':
|
||||
$output .= html_print_select_multiple_modules_filtered_formated($data);
|
||||
break;
|
||||
|
||||
case 'datalist':
|
||||
$output .= html_print_datalist(
|
||||
$data['name'],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* globals $, GridStack, load_modal, TreeController, forced_title_callback, createVisualConsole, UndefineTinyMCE*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function show_option_dialog(settings) {
|
||||
$("#modal-config-widget").html("");
|
||||
load_modal({
|
||||
target: $("#modal-update-dashboard"),
|
||||
form: "form-update-dashboard",
|
||||
|
|
|
@ -297,10 +297,10 @@ class AgentModuleWidget extends Widget
|
|||
}
|
||||
|
||||
$inputs[] = [
|
||||
'class' => 'flex flex-row',
|
||||
'id' => 'select_multiple_modules_filtered',
|
||||
'class' => 'flex flex-column',
|
||||
'id' => 'select_multiple_modules_filtered_formated',
|
||||
'arguments' => [
|
||||
'type' => 'select_multiple_modules_filtered',
|
||||
'type' => 'select_multiple_modules_filtered_formated',
|
||||
'uniqId' => $this->cellId,
|
||||
'mGroup' => (isset($this->values['mGroup']) === true) ? $this->values['mGroup'] : $mgroup,
|
||||
'mRecursion' => (isset($this->values['mRecursion']) === true) ? $this->values['mRecursion'] : '',
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
#select_multiple_modules_filtered_formated {
|
||||
border: 1px solid #c1c1c1;
|
||||
border-radius: 10px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered_formated > div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered_formated > div > div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered_formated .recursive-modules {
|
||||
flex: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered_formated .recursive-modules > div {
|
||||
flex-direction: row-reverse;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered_formated .recursive-modules > div > label {
|
||||
max-width: unset;
|
||||
font-weight: unset;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered_formated > div > div > select {
|
||||
min-width: 250px !important;
|
||||
}
|
||||
|
||||
#select_multiple_modules_filtered_formated > div > div > .select2 {
|
||||
min-width: 250px !important;
|
||||
}
|
||||
|
||||
form.modal-dashboard ul.wizard li {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
form.modal-dashboard ul.wizard li label {
|
||||
max-width: 100% !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.flex-colum-center-important > select {
|
||||
width: 95%;
|
||||
height: 119px;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
.wizard > li:nth-of-type(1) {
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
grid-area: titulo;
|
||||
}
|
||||
|
||||
.wizard > li:nth-of-type(1) > input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wizard > li:nth-of-type(2) {
|
||||
grid-area: color;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
}
|
||||
|
||||
.wizard > li:nth-of-type(3) {
|
||||
grid-area: show;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
}
|
||||
|
||||
ul.wizard > li.flex-row > label {
|
||||
width: 100%;
|
||||
max-width: 100% !important;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.wizard > li:nth-of-type(4) {
|
||||
grid-area: todo;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
ul.wizard {
|
||||
display: grid;
|
||||
grid-template:
|
||||
"titulo show color"
|
||||
"todo todo todo";
|
||||
grid-template-columns: 40% 40% 20%;
|
||||
}
|
||||
|
||||
#wr_background > input {
|
||||
background-color: #f6f7fb;
|
||||
padding: 5px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #8a96a6;
|
||||
}
|
|
@ -12034,10 +12034,20 @@ div[role="dialog"] {
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
.flex-colum-center-important {
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
align-items: center !important;
|
||||
}
|
||||
|
||||
.flex-colum-center > img {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.flex-none {
|
||||
flex: none !important;
|
||||
}
|
||||
|
||||
.space-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/', true);
|
|||
ui_require_javascript_file('pandora', 'include/javascript/', true);
|
||||
|
||||
$output = '';
|
||||
$widgetId = json_decode(io_safe_output(get_parameter('extradata')), true)['widgetId'];
|
||||
|
||||
$form = [
|
||||
'action' => '#',
|
||||
|
@ -64,4 +65,8 @@ HTML::printForm(
|
|||
]
|
||||
);
|
||||
|
||||
if ($widgetId == '10') {
|
||||
$output .= ui_require_css_file('agent_module_view', 'include/styles/', true, true);
|
||||
}
|
||||
|
||||
echo $output;
|
||||
|
|
Loading…
Reference in New Issue