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,9 +487,8 @@ 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,
'', '',
@ -498,10 +497,8 @@ $tableAgent->data['primary_group'][0] .= html_print_div(
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,40 +528,59 @@ 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'),
html_print_select(
$ipsSelect, $ipsSelect,
'select_ips', 'select_ips',
$principal_ip, $principal_ip,
'', '',
'', '',
0, 0,
true 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', '1' => 'v1',
'2c' => 'v2c', '2c' => 'v2c',
@ -571,34 +590,41 @@ class ExternalTools extends HTML
'', '',
'', '',
0, 0,
true true,
false,
true,
'w100p',
false,
'width: 100%;'
),
['div_class' => 'snmpcolumn']
); );
$table->cellclass['captions'][3] = 'snmpcolumn'; $table->data[0][3] = html_print_label_input_block(
$table->cellclass['inputs'][3] = 'snmpcolumn'; __('SNMP Community'),
$table->data['captions'][3] = __('SNMP Community'); html_print_input_text(
$table->data['inputs'][3] = html_print_input_text(
'community', 'community',
$this->community, $this->community,
'', '',
50, 50,
255, 255,
true true,
false,
false,
'',
'w100p'
),
['div_class' => 'snmpcolumn']
); );
$table->data['inputs'][4] = html_print_div( $table->data[1][0] = html_print_submit_button(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Execute'), __('Execute'),
'submit', 'submit',
false, false,
[ [
'icon' => 'cog', 'icon' => 'cog',
'mode' => 'mini', 'mode' => 'mini',
], 'class' => 'float-right mrgn_right_10px',
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,9 +315,10 @@
$(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() {
$("img", config.spanPreview).remove();
jQuery.post( jQuery.post(
"ajax.php", "ajax.php",
{ {
@ -326,16 +327,16 @@
id_group: id_group id_group: id_group
}, },
function(data) { function(data) {
var img = $("<img />").attr("src", "images/" + data["icon"]); $("img", config.spanPreview).attr(
$(config.spanPreview) "src",
.append(img) "images/" + data["icon"]
.fadeIn("fast"); );
$("a", config.spanPreview).attr("href", hrefNew);
}, },
"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,10 +146,9 @@ 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[]',
'', '',
@ -161,20 +160,21 @@ function print_filters($sec)
true, true,
'', '',
false, false,
'min-width: 180px; max-width: 200px;' 'min-width: 200px; max-width: 250px; min-height: 70px;'
)
); );
$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>';
} }