Dashboards widgets

This commit is contained in:
Pablo Aragon 2023-03-15 15:58:28 +01:00
parent 00a5e8e84b
commit bed1e34fd2
5 changed files with 152 additions and 117 deletions

View File

@ -487,21 +487,18 @@ if (isset($groups[$grupo]) === true || $new_agent === true) {
$tableAgent->data['primary_group'][0] .= html_print_input_hidden('grupo', $grupo, true); $tableAgent->data['primary_group'][0] .= html_print_input_hidden('grupo', $grupo, true);
} }
$tableAgent->data['primary_group'][0] .= html_print_div( $tableAgent->data['primary_group'][0] .= '<span id="group_preview">';
[ $tableAgent->data['primary_group'][0] .= ui_print_group_icon(
'content' => ui_print_group_icon( $grupo,
$grupo, true,
true, '',
'', ($id_agente === 0) ? 'display: none;' : '',
($id_agente === 0) ? 'display: none;' : '', true,
true, false,
false, false,
false, 'after_input_icon'
'after_input_icon'
),
],
true
); );
$tableAgent->data['primary_group'][0] .= '</span>';
$tableAgent->data['caption_interval'][0] = __('Interval'); $tableAgent->data['caption_interval'][0] = __('Interval');
// $tableAgent->rowstyle['interval'] = 'width: 260px'; // $tableAgent->rowstyle['interval'] = 'width: 260px';

View File

@ -528,77 +528,103 @@ class ExternalTools extends HTML
// Form table. // Form table.
$table = new StdClass(); $table = new StdClass();
$table->class = 'fixed_filter_bar'; $table->class = 'fixed_filter_bar filter-table-adv pdd_15px';
$table->id = 'externalToolTable'; $table->id = 'externalToolTable';
$table->cellstyle['captions'][0] = 'width: 0'; $table->size[0] = '25%';
$table->cellstyle['captions'][1] = 'width: 0'; $table->size[1] = '25%';
$table->cellstyle['captions'][2] = 'width: 0'; $table->size[2] = '25%';
$table->size[3] = '25%';
$table->colspan = [];
$table->colspan[1][0] = 4;
// $table->cellclass[0][2] = 'snmpcolumn';
// $table->cellclass[0][2] = 'snmpcolumn';
// $table->cellclass[0][3] = 'snmpcolumn';
// $table->cellclass[0][3] = 'snmpcolumn';
$table->data = []; $table->data = [];
$table->data['captions'][0] = __('Operation'); $table->data[0][0] = html_print_label_input_block(
__('Operation'),
$table->data['inputs'][0] = html_print_select( html_print_select(
$commandList, $commandList,
'operation', 'operation',
$this->operation, $this->operation,
'mostrarColumns(this.value)', 'mostrarColumns(this.value)',
__('Please select'), __('Please select'),
0, 0,
true true,
false,
true,
'w100p',
false,
'width: 100%;'
)
); );
$table->data['captions'][1] = __('IP Adress'); $table->data[0][1] = html_print_label_input_block(
$table->data['inputs'][1] = html_print_select( __('IP Adress'),
$ipsSelect, html_print_select(
'select_ips', $ipsSelect,
$principal_ip, 'select_ips',
'', $principal_ip,
'', '',
0, '',
true 0,
true,
false,
true,
'w100p',
false,
'width: 100%;'
)
); );
$table->cellclass['captions'][2] = 'snmpcolumn'; $table->data[0][2] = html_print_label_input_block(
$table->cellclass['inputs'][2] = 'snmpcolumn'; __('SNMP Version'),
$table->data['captions'][2] = __('SNMP Version'); html_print_select(
$table->data['inputs'][2] = html_print_select( [
'1' => 'v1',
'2c' => 'v2c',
],
'select_version',
$this->snmp_version,
'',
'',
0,
true,
false,
true,
'w100p',
false,
'width: 100%;'
),
['div_class' => 'snmpcolumn']
);
$table->data[0][3] = html_print_label_input_block(
__('SNMP Community'),
html_print_input_text(
'community',
$this->community,
'',
50,
255,
true,
false,
false,
'',
'w100p'
),
['div_class' => 'snmpcolumn']
);
$table->data[1][0] = html_print_submit_button(
__('Execute'),
'submit',
false,
[ [
'1' => 'v1', 'icon' => 'cog',
'2c' => 'v2c', 'mode' => 'mini',
], 'class' => 'float-right mrgn_right_10px',
'select_version',
$this->snmp_version,
'',
'',
0,
true
);
$table->cellclass['captions'][3] = 'snmpcolumn';
$table->cellclass['inputs'][3] = 'snmpcolumn';
$table->data['captions'][3] = __('SNMP Community');
$table->data['inputs'][3] = html_print_input_text(
'community',
$this->community,
'',
50,
255,
true
);
$table->data['inputs'][4] = html_print_div(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Execute'),
'submit',
false,
[
'icon' => 'cog',
'mode' => 'mini',
],
true
),
], ],
true true
); );
@ -716,7 +742,7 @@ class ExternalTools extends HTML
*/ */
private function performExecution(string $command='', string $caption='') private function performExecution(string $command='', string $caption='')
{ {
$output = ''; $output = '<div class="white_box max_floating_element_size no_border">';
try { try {
// If caption is not added, don't show anything. // If caption is not added, don't show anything.
@ -736,7 +762,7 @@ class ExternalTools extends HTML
$output .= __('Command not response'); $output .= __('Command not response');
} }
$output .= '</pre>'; $output .= '</pre></div>';
if ($resultCode !== 0) { if ($resultCode !== 0) {
throw new Exception( throw new Exception(
@ -774,6 +800,8 @@ class ExternalTools extends HTML
{ {
$output = ''; $output = '';
echo '<div class="white_box max_floating_element_size no_border pdd_15px">';
if (validate_address($ip) === false) { if (validate_address($ip) === false) {
$output .= ui_print_error_message( $output .= ui_print_error_message(
__('The ip or dns name entered cannot be resolved'), __('The ip or dns name entered cannot be resolved'),
@ -938,6 +966,7 @@ class ExternalTools extends HTML
} }
} }
echo '</div>';
return $output; return $output;
} }

View File

@ -296,7 +296,7 @@
$.extend({ $.extend({
pandoraSelectGroupIcon: new (function() { pandoraSelectGroupIcon: new (function() {
this.defaults = { this.defaults = {
alertSelect: "select#id_group", alertSelect: "select#grupo",
spanPreview: "#group_preview", spanPreview: "#group_preview",
debug: false debug: false
}; };
@ -315,25 +315,26 @@
$(this).change(function() { $(this).change(function() {
var id_group = this.value; var id_group = this.value;
let href = $("a", config.spanPreview).attr("href");
let hrefPosition = href.search("group_id=");
let hrefNew = href.slice(0, hrefPosition) + "group_id=" + id_group;
$(config.spanPreview).fadeOut("fast", function() { jQuery.post(
$("img", config.spanPreview).remove(); "ajax.php",
jQuery.post( {
"ajax.php", page: "godmode/groups/group_list",
{ get_group_json: 1,
page: "godmode/groups/group_list", id_group: id_group
get_group_json: 1, },
id_group: id_group function(data) {
}, $("img", config.spanPreview).attr(
function(data) { "src",
var img = $("<img />").attr("src", "images/" + data["icon"]); "images/" + data["icon"]
$(config.spanPreview) );
.append(img) $("a", config.spanPreview).attr("href", hrefNew);
.fadeIn("fast"); },
}, "json"
"json" );
);
});
}); });
}); });
}; };

View File

@ -843,3 +843,11 @@ div.widget-mrgn-0px > div.parent_graph {
div.widget-mrgn-0px > div.parent_graph > div[id^="graph_"] { div.widget-mrgn-0px > div.parent_graph > div[id^="graph_"] {
width: calc(100% + 14px) !important; width: calc(100% + 14px) !important;
} }
div.content-widget
> div.container-center
> div.centered.w90p
> div#container_show_stats
> canvas {
height: 310px;
}

View File

@ -146,35 +146,35 @@ function print_filters($sec)
$filters .= '</form>'; $filters .= '</form>';
} else { } else {
$table->style[0] = 'font-weight: bold;'; $table->data[0][0] = html_print_label_input_block(
__('Interfaces'),
$table->data[0][0] = '<b>'.__('Interfaces').'</b>'; html_print_select(
$table->data[0][1] = html_print_select( [],
[], 'selected_interfaces[]',
'selected_interfaces[]', '',
'', '',
'', '',
'', 0,
0, true,
true, true,
true, true,
true, '',
'', false,
false, 'min-width: 200px; max-width: 250px; min-height: 70px;'
'min-width: 180px; max-width: 200px;' )
); );
$filters = '<form method="post" action="'.ui_get_url_refresh().'">'; $filters = '<form method="post" action="'.ui_get_url_refresh().'">';
$filters .= html_print_table($table, true); $filters .= html_print_table($table, true);
$filters .= "<div class='height_100p right'>".html_print_submit_button( $filters .= html_print_submit_button(
__('Show'), __('Show'),
'uptbutton', 'uptbutton',
false, false,
'class="sub search mgn_tp_0"', ['class' => 'float-right mini'],
true true
).'</div>'; );
$filters .= '</form>'; $filters .= '</form>';
} }