Merge remote-tracking branch 'origin/develop' into ent-8621-copiando-a-grafana-4-color-tabs-como-widget-en-dashboard

Conflicts:
	pandora_console/include/javascript/pandora.js
This commit is contained in:
Daniel Barbero Martin 2022-06-28 17:02:01 +02:00
commit 867c6a1415
59 changed files with 1208 additions and 405 deletions

View File

@ -135,6 +135,7 @@ $current_month = true;
// Only avg is selected by default for the simple graphs.
$fullscale = false;
$percentil = false;
$image_threshold = false;
$time_compare_overlapped = false;
// Added for events items.
@ -307,6 +308,7 @@ switch ($action) {
case 'simple_graph':
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
$percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0;
$image_threshold = (isset($style['image_threshold']) === true) ? (bool) $style['image_threshold'] : false;
$graph_render = $item['graph_render'];
// The break hasn't be forgotten.
case 'simple_baseline_graph':
@ -2504,6 +2506,23 @@ $class = 'databox filters';
</td>
</tr>
<tr id="row_image_threshold" class="datos">
<td class="bolder">
<?php
echo __('Show threshold');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'image_threshold',
1,
$image_threshold
);
?>
</td>
</tr>
<tr id="row_time_compare_overlapped" class="datos">
<td class="bolder">
<?php
@ -5965,6 +5984,7 @@ function chooseType() {
$("#row_show_graph").hide();
$("#row_max_min_avg").hide();
$("#row_fullscale").hide();
$("#row_image_threshold").hide();
$("#row_graph_render").hide();
$("#row_macros_definition").hide();
$("#row_render_definition").hide();
@ -6099,6 +6119,7 @@ function chooseType() {
case 'simple_graph':
$("#row_time_compare_overlapped").show();
$("#row_fullscale").show();
$("#row_image_threshold").show();
$("#row_graph_render").show();
$("#row_percentil").show();

View File

@ -2255,6 +2255,9 @@ switch ($action) {
$style['fullscale'] = (int) get_parameter(
'fullscale'
);
$style['image_threshold'] = (int) get_parameter(
'image_threshold'
);
if ($label != '') {
$style['label'] = $label;
} else {
@ -3006,6 +3009,9 @@ switch ($action) {
$style['fullscale'] = (int) get_parameter(
'fullscale'
);
$style['image_threshold'] = (int) get_parameter(
'image_threshold'
);
if ($label != '') {
$style['label'] = $label;
} else {

View File

@ -410,7 +410,7 @@ if (check_login()) {
$table_modules->head = [];
$table_modules->head[0] = __('Module name');
$table_modules->head[1] = __('Data');
$table_modules->head[2] = __('Treshold');
$table_modules->head[2] = __('Threshold');
$table_modules->head[3] = __('Current interval');
$table_modules->head[4] = __('Timestamp');
$table_modules->head[5] = __('Status');

View File

@ -2227,121 +2227,77 @@ if ($process_buffers === true) {
if ($get_events_fired) {
global $config;
$id = get_parameter('id_row');
$idGroup = get_parameter('id_group');
$agents = get_parameter('agents', null);
$filter_id = (int) get_parameter('filter_id', 0);
$interval = (int) get_parameter('interval', 10);
$query = ' AND id_evento > '.$id;
$type = [];
$alert = get_parameter('alert_fired');
if ($alert == 'true') {
$resultAlert = alerts_get_event_status_group(
$idGroup,
[
'alert_fired',
'alert_ceased',
],
$query,
$agents
);
}
$critical = get_parameter('critical');
if ($critical == 'true') {
$resultCritical = alerts_get_event_status_group(
$idGroup,
[
'going_up_critical',
'going_down_critical',
],
$query,
$agents
);
}
$warning = get_parameter('warning');
if ($warning == 'true') {
$resultWarning = alerts_get_event_status_group(
$idGroup,
[
'going_up_warning',
'going_down_warning',
],
$query,
$agents
);
}
$unknown = get_parameter('unknown');
if ($unknown == 'true') {
$resultUnknown = alerts_get_event_status_group(
$idGroup,
'going_unknown',
$query,
$agents
);
}
if ($resultAlert) {
$return = [
'fired' => $resultAlert,
'sound' => $config['sound_alert'],
if (empty($filter_id) === true) {
$filter = [
'id_group' => 0,
'event_type' => '',
'severity' => -1,
'status' => -1,
'search' => '',
'text_agent' => '',
'id_agent' => 0,
'id_agent_module' => 0,
'pagination' => 0,
'id_user_ack' => 0,
'group_rep' => 0,
'tag_with' => [],
'tag_without' => [],
'filter_only_alert' => -1,
'source' => '',
'id_extra' => '',
'user_comment' => '',
'id_source_event' => 0,
'server_id' => 0,
'custom_data' => '',
'custom_data_filter_type' => 0,
];
$event = events_get_event($resultAlert);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Alert fired in module ');
$return['message'] .= io_safe_output($module_name).' - ';
$return['message'] .= $event['timestamp'];
} else if ($resultCritical) {
$return = [
'fired' => $resultCritical,
'sound' => $config['sound_critical'],
];
$event = events_get_event($resultCritical);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Module ').io_safe_output($module_name);
$return['message'] .= __(' is going to critical').' - ';
$return['message'] .= $event['timestamp'];
} else if ($resultWarning) {
$return = [
'fired' => $resultWarning,
'sound' => $config['sound_warning'],
];
$event = events_get_event($resultWarning);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Module ').io_safe_output($module_name);
$return['message'] .= __(' is going to warning').' - ';
$return['message'] .= $event['timestamp'];
} else if ($resultUnknown) {
$return = [
'fired' => $resultUnknown,
'sound' => $config['sound_alert'],
];
$event = events_get_event($resultUnknown);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Module ').io_safe_output($module_name);
$return['message'] .= __(' is going to unknown').' - ';
$return['message'] .= $event['timestamp'];
} else {
$return = ['fired' => 0];
$filter = events_get_event_filter($filter_id);
}
// Set time.
$filter['event_view_hr'] = 0;
$start = (time() - $interval);
$end = time();
$filter['date_from'] = date('Y-m-d', $start);
$filter['date_to'] = date('Y-m-d', $end);
$filter['time_from'] = date('H:i:s', $start);
$filter['time_to'] = date('H:i:s', $end);
$data = events_get_all(
['te.*'],
$filter
);
$return = [];
if (empty($data) === false) {
foreach ($data as $event) {
$return[] = [
'fired' => $event['id_evento'],
'message' => ui_print_string_substr(
strip_tags(io_safe_output($event['evento'])),
75,
true,
'9'
),
'priority' => ui_print_event_priority($event['criticity'], true, true),
'type' => events_print_type_img(
$event['event_type'],
true
),
'timestamp' => ui_print_timestamp(
$event['timestamp'],
true,
['style' => 'font-size: 9pt; letter-spacing: 0.3pt;']
),
];
}
}
echo io_json_mb_encode($return);
return;
}

View File

@ -1196,7 +1196,7 @@ class AgentWizard extends HTML
$table->head[1] = '<b>'.__('Server').'</b>';
$table->head[2] = '<b>'.__('Type').'</b>';
$table->head[3] = '<b>'.__('Description').'</b>';
$table->head[4] = '<b>'.__('Treshold').'</b>';
$table->head[4] = '<b>'.__('Threshold').'</b>';
$table->data = [];

View File

@ -260,6 +260,8 @@ class CalendarManager
*/
public function deleteCalendar()
{
global $config;
$id = (int) get_parameter('id');
try {
$calendar = new Calendar($id);
@ -278,6 +280,22 @@ class CalendarManager
return;
}
if (is_numeric($id) === true) {
if ((bool) check_acl(
$config['id_user'],
$calendar->id_group(),
'LM'
) === false
) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access calendar delete'
);
include 'general/noaccess.php';
exit;
}
}
// Remove.
$calendar->delete();
$this->message = \ui_print_success_message(
@ -480,6 +498,35 @@ class CalendarManager
$new = true;
}
$group_id = null;
if ($new === true) {
if (is_numeric(get_parameter('id_group')) === true) {
$group_id = get_parameter('id_group');
}
} else {
if (is_numeric($calendar->id_group()) === true) {
$group_id = $calendar->id_group();
}
}
if (is_numeric($group_id) === true) {
// Check for permissions before rendering edit view or performing save action.
if ((bool) check_acl(
$config['id_user'],
$group_id,
'LM'
) === false
) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access calendar editor'
);
include 'general/noaccess.php';
exit;
}
}
$action = get_parameter('action');
if ($action === 'save') {
$success = false;
@ -604,19 +651,23 @@ class CalendarManager
$is_management_allowed = \is_management_allowed();
if ((bool) $data === true) {
$manage = check_acl(
$config['id_user'],
0,
'LM',
true
);
$user_id = $config['id_user'];
$data = array_reduce(
$data,
function ($carry, $item) use ($manage, $is_management_allowed) {
function ($carry, $item) use ($user_id, $is_management_allowed) {
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
// Users must only be able to manage items that belong to their groups.
// IMPORTANT: if user does not have permission over 'All' group, items belonging to such
// group must be listed but they must not allow for edition.
$manage = check_acl_restricted_all(
$user_id,
$item['id_group'],
'LM'
);
$tmp = (object) $item;
if ((bool) $manage === true) {

View File

@ -777,6 +777,7 @@ class HTML
) {
$form = ($data['form'] ?? null);
$inputs = ($data['inputs'] ?? []);
$blocks = ($data['blocks'] ?? []);
$rawInputs = ($data['rawInputs'] ?? null);
$js = ($data['js'] ?? null);
$rawjs = ($data['js_block'] ?? null);
@ -843,36 +844,59 @@ class HTML
$output_submit = '';
$output = '';
if ($print_white_box === true) {
$output .= '<div class="white_box">';
}
if (empty($blocks) === false) {
$output .= '<div class="container-block-column">';
foreach ($blocks as $valueblock) {
$output .= '<ul class="wizard">';
foreach ($inputs[$valueblock] as $input) {
if (is_array(($input['arguments'] ?? null)) === true
&& isset($input['arguments']) === true
&& isset($input['arguments']['type']) === true
&& $input['arguments']['type'] === 'submit'
) {
$output_submit .= self::printBlock($input, true);
} else {
$output .= self::printBlock($input, true);
}
}
$output .= '<ul class="wizard">';
foreach ($inputs as $input) {
if (is_array(($input['arguments'] ?? null)) === true
&& isset($input['arguments']) === true
&& isset($input['arguments']['type']) === true
&& $input['arguments']['type'] === 'submit'
) {
$output_submit .= self::printBlock($input, true);
} else {
$output .= self::printBlock($input, true);
$output .= '</ul>';
}
}
$output .= '</ul>';
// There is possible add raw inputs for this form.
if (empty($rawInputs) === false) {
$output .= $rawInputs;
}
if ($print_white_box === true) {
$output .= '</div>';
} else {
if ($print_white_box === true) {
$output .= '<div class="white_box">';
}
$output .= '<ul class="wizard">';
foreach ($inputs as $input) {
if (is_array(($input['arguments'] ?? null)) === true
&& isset($input['arguments']) === true
&& isset($input['arguments']['type']) === true
&& $input['arguments']['type'] === 'submit'
) {
$output_submit .= self::printBlock($input, true);
} else {
$output .= self::printBlock($input, true);
}
}
$output .= '</ul>';
// There is possible add raw inputs for this form.
if (empty($rawInputs) === false) {
$output .= $rawInputs;
}
if ($print_white_box === true) {
$output .= '</div>';
}
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
}
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
$output .= html_print_csrf_hidden(true);
$output .= '</form>';
$output .= '<script>'.$js.'</script>';

View File

@ -2399,9 +2399,9 @@ function check_acl_one_of_groups($id_user, $groups, $access, $cache=true)
* LM - Alert Management
* PM - Pandora Management
*
* @param integer $id_user User id
* @param integer $id_group Agents group id to check from
* @param string $access Access privilege
* @param integer $id_user User id.
* @param integer $id_group Agents group id to check from.
* @param string $access Access privilege.
* @param boolean $onlyOneGroup Flag to check acl for specified group only (not to roots up, or check acl for 'All' group when $id_group is 0).
*
* @return boolean 1 if the user has privileges, 0 if not.
@ -2409,7 +2409,7 @@ function check_acl_one_of_groups($id_user, $groups, $access, $cache=true)
function check_acl_restricted_all($id_user, $id_group, $access, $onlyOneGroup=false)
{
if (empty($id_user)) {
// User ID needs to be specified
// User ID needs to be specified.
trigger_error('Security error: check_acl got an empty string for user id', E_USER_WARNING);
return 0;
} else if (is_user_admin($id_user)) {

View File

@ -14699,7 +14699,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4)
'type_graph' => $config['type_module_charts'],
'fullscale' => false,
'return_img_base_64' => true,
'image_treshold' => $graph_threshold,
'image_threshold' => $graph_threshold,
'graph_font_size' => $graph_font_size,
];

View File

@ -626,7 +626,7 @@ function grafico_modulo_sparse_data(
* 'show_legend' => true,
* 'show_overview' => true,
* 'return_img_base_64' => false,
* 'image_treshold' => false,
* 'image_threshold' => false,
* 'graph_combined' => false,
* 'graph_render' => 0,
* 'zoom' => 1,
@ -782,8 +782,8 @@ function grafico_modulo_sparse($params)
$params['return_img_base_64'] = false;
}
if (isset($params['image_treshold']) === false) {
$params['image_treshold'] = false;
if (isset($params['image_threshold']) === false) {
$params['image_threshold'] = false;
}
if (isset($params['graph_combined']) === false) {
@ -1305,8 +1305,8 @@ function graphic_combined_module(
$params['return_img_base_64'] = false;
}
if (isset($params['image_treshold']) === false) {
$params['image_treshold'] = false;
if (isset($params['image_threshold']) === false) {
$params['image_threshold'] = false;
}
if (isset($params['show_unknown']) === false) {

View File

@ -1685,7 +1685,9 @@ function html_print_select_multiple_modules_filtered(array $data):string
);
}
if ($data['mAgents'] !== null) {
if (empty($data['mAgents']) === false
&& empty($data['mModuleGroup'] === false)
) {
$all_modules = get_modules_agents(
$data['mModuleGroup'],
explode(',', $data['mAgents']),

View File

@ -10159,6 +10159,11 @@ function reporting_simple_graph(
$fullscale = (bool) $content['style']['fullscale'];
}
$image_threshold = false;
if (isset($content['style']['image_threshold'])) {
$image_threshold = (bool) $content['style']['image_threshold'];
}
$return['chart'] = '';
// Get chart.
@ -10213,6 +10218,7 @@ function reporting_simple_graph(
'backgroundColor' => 'transparent',
'return_img_base_64' => true,
'graph_render' => $content['graph_render'],
'image_threshold' => $image_threshold,
];
if ($only_image === false) {

View File

@ -1017,7 +1017,7 @@ function pandoraFlotArea(
var max_x = date_array["final_date"] * 1000;
var type = parseInt(params.stacked);
var show_legend = params.show_legend;
var image_treshold = params.image_treshold;
var image_threshold = params.image_threshold;
var short_data = params.short_data != "" ? params.short_data : 3;
var grid_color = params.grid_color;
var background_color = params.backgroundColor;
@ -2212,7 +2212,7 @@ function pandoraFlotArea(
}
if (thresholded) {
var data_base_treshold = add_threshold(
var data_base_threshold = add_threshold(
data_base,
threshold_data,
ranges.yaxis.from,
@ -2225,7 +2225,7 @@ function pandoraFlotArea(
plot = $.plot(
$("#" + graph_id),
data_base_treshold,
data_base_threshold,
$.extend(true, {}, options, {
grid: {
borderWidth: 1,
@ -2611,7 +2611,7 @@ function pandoraFlotArea(
$("#overview_" + graph_id).bind("mouseout", resetInteractivity);
}
if (image_treshold) {
if (image_threshold) {
var y_recal = plot.getAxes().yaxis.max;
if (!thresholded) {
// Recalculate the y axis
@ -2625,7 +2625,7 @@ function pandoraFlotArea(
);
}
var datas_treshold = add_threshold(
var datas_threshold = add_threshold(
data_base,
threshold_data,
plot.getAxes().yaxis.min,
@ -2638,7 +2638,7 @@ function pandoraFlotArea(
plot = $.plot(
$("#" + graph_id),
datas_treshold,
datas_threshold,
$.extend(true, {}, options, {
yaxis: {
max: y_recal.max
@ -2772,7 +2772,7 @@ function pandoraFlotArea(
);
}
datas_treshold = add_threshold(
datas_threshold = add_threshold(
data_base,
threshold_data,
plot.getAxes().yaxis.min,
@ -2785,7 +2785,7 @@ function pandoraFlotArea(
plot = $.plot(
$("#" + graph_id),
datas_treshold,
datas_threshold,
$.extend(true, {}, options, {
yaxis: {
min: max_draw["min"],
@ -3096,7 +3096,7 @@ function axis_thresholded(
return y;
}
//add treshold
//add threshold
function add_threshold(
data_base,
threshold_data,
@ -3216,13 +3216,13 @@ function add_threshold(
}
});
var extreme_treshold_array = [];
var extreme_threshold_array = [];
var i = 0;
var flag = true;
$.each(threshold_array, function(index, value) {
flag = true;
extreme_treshold_array[i] = {
extreme_threshold_array[i] = {
below: value["max"],
color: value["color"]
};
@ -3233,7 +3233,7 @@ function add_threshold(
}
});
if (flag) {
extreme_treshold_array[i] = {
extreme_threshold_array[i] = {
below: value["min"],
color: datas[0].color
};
@ -3241,7 +3241,7 @@ function add_threshold(
}
});
datas[0].threshold = extreme_treshold_array;
datas[0].threshold = extreme_threshold_array;
return datas;
}

View File

@ -2090,6 +2090,60 @@ function selection_multiple_change(info) {
);
}
/*
* Creates a progressbar.
* @param id the id of the div we want to transform in a progressbar.
* @param duration the duration of the timer example: '10s'.
* @param iteration.
* @param callback, optional function which is called when the progressbar reaches 0.
*/
function createProgressTimeBar(id, duration, iteration, callback) {
// We select the div that we want to turn into a progressbar
var progressbar = document.getElementById(id);
progressbar.className = "progressbar";
// We create the div that changes width to show progress
var progressbarinner = document.createElement("div");
progressbarinner.className = "inner";
// Now we set the animation parameters
progressbarinner.style.animationDuration = duration;
progressbarinner.style.animationIterationCount = iteration;
// Eventually couple a callback
if (typeof callback === "function") {
if (iteration === "infinite") {
progressbarinner.addEventListener("animationiteration", callback);
} else {
progressbarinner.addEventListener("animationend", callback);
}
}
// Append the progressbar to the main progressbardiv
progressbar.appendChild(progressbarinner);
// When everything is set up we start the animation
progressbarinner.style.animationPlayState = "running";
return progressbarinner;
}
function progressTimeBar(id, interval, iteration, callback) {
var progress = createProgressTimeBar(id, interval + "s", iteration, callback);
var controls = {
start: function() {
progress.style.animationPlayState = "running";
},
paused: function() {
progress.style.animationPlayState = "paused";
}
};
return controls;
}
/**
* Filter selector item by text based on a text input.
*

View File

@ -254,7 +254,7 @@ function initialiceLayout(data) {
confirmDialog({
title: "Are you sure?",
message:
"<h4 style='text-align: center;padding-top: 20px;'>All changes made to this widget will be lost</h4>",
"<h3 style='text-align: center;padding-top: 20px;'>All changes made to this widget will be lost</h3>",
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
@ -266,7 +266,7 @@ function initialiceLayout(data) {
});
$("#configure-widget-" + id).click(function() {
configurationWidget(id, widgetId);
getSizeModalConfiguration(id, widgetId);
});
},
error: function(error) {
@ -275,6 +275,29 @@ function initialiceLayout(data) {
});
}
function getSizeModalConfiguration(cellId, widgetId) {
$.ajax({
method: "post",
url: data.url,
data: {
page: data.page,
method: "getSizeModalConfiguration",
dashboardId: data.dashboardId,
cellId: cellId,
widgetId: widgetId
},
dataType: "json",
success: function(size) {
configurationWidget(cellId, widgetId, size);
},
error: function(error) {
console.log(error);
return [];
}
});
return false;
}
function saveLayout() {
var items = $(".grid-stack > .grid-stack-item:visible")
.map(function(i, el) {
@ -370,7 +393,7 @@ function initialiceLayout(data) {
});
}
function configurationWidget(cellId, widgetId) {
function configurationWidget(cellId, widgetId, size) {
load_modal({
target: $("#modal-config-widget"),
form: "form-config-widget",
@ -388,12 +411,9 @@ function initialiceLayout(data) {
dashboardId: data.dashboardId,
widgetId: widgetId
},
width:
widgetId == 14 || widgetId == 2 || widgetId == 23 || widgetId == 16
? 750
: 450,
maxHeight: 650,
minHeight: widgetId == 16 ? 450 : 400
width: size.width,
maxHeight: size.height,
minHeight: size.height
},
onsubmit: {
page: data.page,
@ -698,7 +718,7 @@ function initialiceLayout(data) {
confirmDialog({
title: "Are you sure?",
message:
"<h4 style='text-align: center;padding-top: 20px;'>All changes made to this widget will be lost</h4>",
"<h3 style='text-align: center;padding-top: 20px;'>All changes made to this widget will be lost</h3>",
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
@ -710,7 +730,7 @@ function initialiceLayout(data) {
});
$("#configure-widget-" + cellId).click(function() {
configurationWidget(cellId, widgetId);
getSizeModalConfiguration(cellId, widgetId);
});
saveLayout();

View File

@ -186,6 +186,9 @@ class Calendar extends Entity
$order_by = '';
$pagination = '';
$user_groups = users_get_groups();
$user_groups_ids = implode(',', array_keys($user_groups));
if (isset($filter['free_search']) === true
&& empty($filter['free_search']) === false
) {
@ -196,6 +199,8 @@ class Calendar extends Entity
);
}
$sql_filters[] = ' AND id_group IN ('.$user_groups_ids.')';
if (isset($order) === true) {
$dir = 'asc';
if ($order === 'desc') {

View File

@ -180,6 +180,7 @@ class Manager implements PublicLogin
'imageIconDashboardAjax',
'formSlides',
'callWidgetMethod',
'getSizeModalConfiguration',
];
@ -1374,7 +1375,14 @@ class Manager implements PublicLogin
global $config;
$instance = $this->instanceWidget();
$blocks = [];
$htmlInputs = $instance->getFormInputs([]);
if (isset($htmlInputs['blocks']) === true) {
$blocks = $htmlInputs['blocks'];
$htmlInputs = $htmlInputs['inputs'];
}
$js = $instance->getFormJS();
View::render(
@ -1382,6 +1390,7 @@ class Manager implements PublicLogin
[
'dashboardId' => $this->dashboardId,
'cellId' => $this->cellId,
'blocks' => $blocks,
'htmlInputs' => $htmlInputs,
'js' => $js,
]
@ -1524,4 +1533,22 @@ class Manager implements PublicLogin
}
/**
* Size configuration modal (ajax only).
*
* @return void.
*/
public function getSizeModalConfiguration():void
{
$result = [];
$widget = $this->instanceWidget();
$result = $widget->getSizeModalConfiguration();
echo json_encode($result);
return;
}
}

View File

@ -521,7 +521,9 @@ class Widget
if (empty($values['background']) === true) {
$values['background'] = '#ffffff';
if ($config['style'] === 'pandora_black' && !is_metaconsole()) {
if ($config['style'] === 'pandora_black'
&& is_metaconsole() === false
) {
$values['background'] = '#222222';
}
}
@ -768,4 +770,20 @@ class Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration():array
{
$size = [
'width' => 400,
'height' => 650,
];
return $size;
}
}

View File

@ -285,12 +285,12 @@ class AgentModuleWidget extends Widget
'arguments' => [
'type' => 'select_multiple_modules_filtered',
'uniqId' => $this->cellId,
'mGroup' => $this->values['mGroup'],
'mRecursion' => $this->values['mRecursion'],
'mModuleGroup' => $this->values['mModuleGroup'],
'mAgents' => $this->values['mAgents'],
'mShowCommonModules' => $this->values['mShowCommonModules'],
'mModules' => $this->values['mModules'],
'mGroup' => (isset($this->values['mGroup']) === true) ? $this->values['mGroup'] : '',
'mRecursion' => (isset($this->values['mRecursion']) === true) ? $this->values['mRecursion'] : '',
'mModuleGroup' => (isset($this->values['mModuleGroup']) === true) ? $this->values['mModuleGroup'] : '',
'mAgents' => (isset($this->values['mAgents']) === true) ? $this->values['mAgents'] : '',
'mShowCommonModules' => (isset($this->values['mShowCommonModules']) === true) ? $this->values['mShowCommonModules'] : '',
'mModules' => (isset($this->values['mModules']) === true) ? $this->values['mModules'] : '',
'mShowSelectedOtherGroups' => true,
'mReturnAllGroup' => $return_all_group,
'mMetaFields' => ((bool) is_metaconsole()),
@ -852,4 +852,20 @@ class AgentModuleWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 800,
'height' => 580,
];
return $size;
}
}

View File

@ -372,4 +372,20 @@ class AlertsFiredWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => (is_metaconsole() === true) ? 330 : 260,
];
return $size;
}
}

View File

@ -322,4 +322,20 @@ class ClockWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 270,
];
return $size;
}
}

View File

@ -533,4 +533,20 @@ class CustomGraphWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 440,
];
return $size;
}
}

View File

@ -289,8 +289,19 @@ class EventsListWidget extends Widget
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
$blocks = [
'row1',
'row2',
];
$inputs['blocks'] = $blocks;
foreach ($inputs as $kInput => $vInput) {
$inputs['inputs']['row1'][] = $vInput;
}
// Select pre built filter.
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => \__('Custom filters'),
'arguments' => [
'type' => 'select',
@ -317,7 +328,7 @@ class EventsListWidget extends Widget
}
// Event Type.
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => \__('Event type'),
'arguments' => [
'type' => 'select',
@ -332,7 +343,7 @@ class EventsListWidget extends Widget
];
// Max. hours old. Default 8.
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => \__('Max. hours old'),
'arguments' => [
'name' => 'maxHours',
@ -355,7 +366,7 @@ class EventsListWidget extends Widget
($config['block_size'] * 3) => ($config['block_size'] * 3),
];
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => \__('Limit'),
'arguments' => [
'type' => 'select',
@ -374,7 +385,7 @@ class EventsListWidget extends Widget
0 => \__('Only pending'),
];
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => \__('Event status'),
'arguments' => [
'type' => 'select',
@ -389,7 +400,7 @@ class EventsListWidget extends Widget
// Severity.
$fields = \get_priorities();
$inputs[] = [
$inputs['inputs']['row1'][] = [
'label' => \__('Severity'),
'arguments' => [
'type' => 'select',
@ -416,7 +427,7 @@ class EventsListWidget extends Widget
}
// Groups.
$inputs[] = [
$inputs['inputs']['row2'][] = [
'label' => \__('Groups'),
'arguments' => [
'type' => 'select_groups',
@ -432,7 +443,7 @@ class EventsListWidget extends Widget
];
// Group recursion.
$inputs[] = [
$inputs['inputs']['row2'][] = [
'label' => \__('Group recursion'),
'arguments' => [
'type' => 'switch',
@ -446,7 +457,7 @@ class EventsListWidget extends Widget
// Tags.
$fields = \tags_get_user_tags($config['id_user'], 'AR');
$inputs[] = [
$inputs['inputs']['row2'][] = [
'label' => \__('Tags'),
'arguments' => [
'type' => 'select',
@ -668,7 +679,6 @@ class EventsListWidget extends Widget
'columns' => $fields,
'ajax_return_operation' => 'buffers',
'ajax_return_operation_function' => 'process_buffers',
// 'drawCallback' => 'process_datatables_callback(this, settings)',
'return' => true,
'csv' => 0,
]
@ -700,4 +710,20 @@ class EventsListWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 800,
'height' => (is_metaconsole() === true) ? 600 : 550,
];
return $size;
}
}

View File

@ -289,4 +289,20 @@ class WelcomeWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 500,
'height' => 220,
];
return $size;
}
}

View File

@ -443,4 +443,20 @@ class GraphModuleHistogramWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 480,
];
return $size;
}
}

View File

@ -493,4 +493,20 @@ class GroupsStatusWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 270,
];
return $size;
}
}

View File

@ -535,4 +535,20 @@ class MapsMadeByUser extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => (is_metaconsole() === true) ? 330 : 270,
];
return $size;
}
}

View File

@ -400,4 +400,20 @@ class MapsStatusWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 425,
];
return $size;
}
}

View File

@ -552,4 +552,20 @@ class ModuleIconWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 700,
];
return $size;
}
}

View File

@ -550,4 +550,20 @@ class ModuleStatusWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 650,
];
return $size;
}
}

View File

@ -409,4 +409,20 @@ class ModuleTableValueWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 430,
];
return $size;
}
}

View File

@ -378,7 +378,7 @@ class ModuleValueWidget extends Widget
{
global $config;
$output .= '';
$output = '';
$id_agent = $this->values['agentId'];
$id_group = agents_get_agent_group($id_agent);
@ -445,4 +445,20 @@ class ModuleValueWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 490,
];
return $size;
}
}

View File

@ -319,7 +319,7 @@ class MonitorHealthWidget extends Widget
20
);
$output = '<div class="container-center mw200px min-height-320px">';
$output = '<div>';
$output .= \html_print_table($table, true);
$output .= '</div>';
@ -349,4 +349,20 @@ class MonitorHealthWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 220,
];
return $size;
}
}

View File

@ -490,4 +490,20 @@ class NetworkMapWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 430,
];
return $size;
}
}

View File

@ -347,4 +347,20 @@ class OsQuickReportWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 205,
];
return $size;
}
}

View File

@ -288,4 +288,20 @@ class PostWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 500,
'height' => 500,
];
return $size;
}
}

View File

@ -499,4 +499,20 @@ class ReportsWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => (is_metaconsole() === true) ? 330 : 260,
];
return $size;
}
}

View File

@ -258,6 +258,9 @@ class ServiceMapWidget extends Widget
$inputs = parent::getFormInputs();
$services_res = services_get_services();
if ($services_res === false) {
$services_res = [];
}
// If currently selected report is not included in fields array (it belongs to a group over which user has no permissions), then add it to fields array.
// This is aimed to avoid overriding this value when a user with narrower permissions edits widget configuration.
@ -358,6 +361,7 @@ class ServiceMapWidget extends Widget
$size = parent::getSize();
$output = '';
if (check_acl($config['id_user'], 0, 'AR') === 0) {
$output .= '<div class="container-center">';
$output .= \ui_print_error_message(
@ -449,4 +453,20 @@ class ServiceMapWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 320,
];
return $size;
}
}

View File

@ -468,4 +468,20 @@ class ServiceViewWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 270,
];
return $size;
}
}

View File

@ -405,4 +405,20 @@ class SingleGraphWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 430,
];
return $size;
}
}

View File

@ -494,4 +494,20 @@ class SLAPercentWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 550,
];
return $size;
}
}

View File

@ -634,4 +634,20 @@ class SystemGroupStatusWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 520,
];
return $size;
}
}

View File

@ -494,4 +494,20 @@ class TacticalWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 370,
];
return $size;
}
}

View File

@ -540,4 +540,20 @@ class TopNWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 530,
];
return $size;
}
}

View File

@ -514,4 +514,20 @@ class TopNEventByGroupWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 520,
];
return $size;
}
}

View File

@ -549,4 +549,20 @@ class TopNEventByModuleWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 400,
'height' => 540,
];
return $size;
}
}

View File

@ -726,4 +726,20 @@ class TreeViewWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => (is_metaconsole() === true) ? 500 : 590,
];
return $size;
}
}

View File

@ -298,4 +298,20 @@ class UrlWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 270,
];
return $size;
}
}

View File

@ -176,7 +176,7 @@ class WuxWidget extends Widget
// Must be configured before using.
$this->configurationRequired = false;
if (empty($this->options) === true) {
$this->configuration_required = true;
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
@ -430,4 +430,20 @@ class WuxWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 330,
];
return $size;
}
}

View File

@ -390,4 +390,20 @@ class WuxStatsWidget extends Widget
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => 450,
'height' => 370,
];
return $size;
}
}

View File

@ -206,7 +206,7 @@ class SpecialDay extends Entity
&& empty($filter['id_group']) === false
) {
$sql_filters[] = sprintf(
' AND `talert_special_days`.`id_group` IN ("%s")',
' AND `talert_special_days`.`id_group` IN (%s)',
implode(',', $filter['id_group'])
);
}

View File

@ -668,3 +668,17 @@ form.modal-dashboard
width: 98%;
margin-top: 5px;
}
.ui-dialog .ui-dialog-title {
top: 0px !important;
}
.ui-dialog .ui-dialog-content {
padding: 0em 1em !important;
margin-bottom: 0 !important;
}
.ui-dialog .ui-dialog-buttonpane {
margin-top: 0px !important;
padding: 0.5em 1em 0em 0em !important;
}

View File

@ -289,6 +289,19 @@ ul.wizard li > textarea {
display: inline-block;
}
.container-block-column {
display: flex;
flex-direction: row;
width: 100%;
height: 100%;
align-items: center;
justify-content: space-around;
}
.container-block-column ul.wizard {
width: 100%;
}
.hidden {
display: none;
}

View File

@ -6256,7 +6256,7 @@ div.graph div.legend table {
.sound_events {
background-color: #494949;
margin: 40px 2em 0;
margin: 1em 2em;
min-height: auto;
}

View File

@ -1475,12 +1475,20 @@ if ($pure) {
?>
<script type="text/javascript">
function openSoundEventWindow() {
url = "<?php echo ui_get_full_url('operation/events/sound_events.php'); ?>";
url = '<?php echo ui_get_full_url('operation/events/sound_events.php'); ?>';
// devicePixelRatio knows how much zoom browser applied.
var windowScale = parseFloat(window.devicePixelRatio);
var defaultWidth = 630;
var defaultHeight = 630;
// If the scale is 1, no zoom has been applied.
var windowWidth = windowScale <= 1 ? defaultWidth : windowScale*defaultWidth;
var windowHeight = windowScale <= 1 ? defaultHeight : windowScale*defaultHeight + (defaultHeight*0.1);
window.open(
url,
'<?php __('Sound Alerts'); ?>',
'width=600, height=450, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no'
);
'width='+windowWidth+', height='+windowHeight+', resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no'
);
}
</script>
<?php

View File

@ -55,13 +55,14 @@ if (check_acl($config['id_user'], 0, 'ER') === false
return;
}
$agents = agents_get_group_agents(0, false, 'none', false, true);
ob_start('ui_process_page_head');
ob_start();
echo '<html>';
echo '<head>';
echo '<title>'.__('Sound Events').'</title>';
ui_require_css_file('wizard');
ui_require_css_file('discovery');
?>
<style type='text/css'>
* {
@ -72,6 +73,83 @@ echo '<title>'.__('Sound Events').'</title>';
img {
border: 0;
}
ul.wizard li > label:not(.p-switch):first-of-type {
width: inherit;
}
form {
margin-top: -3px;
margin-bottom: 10px;
}
table {
margin-top: 5px;
}
.events_fired {
background: white;
padding: 20px;
overflow: auto;
height: 200px;
margin-bottom: 5px;
}
.events_fired li {
padding: 5px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.events_fired li div {
margin-right: 10px;
}
.events_fired li div.flex0 {
flex: 0;
}
.events_fired li div.flex-time {
flex: 0 1 100px;
text-align: end;
}
.events_fired li div.mess {
width: 100%;
}
.forced_title.mini-criticity {
width: 10px;
height: 30px;
}
.progressbar {
width: 100%;
margin: 5px 0px;
}
.progressbar .inner {
height: 10px;
animation: progressbar-countdown;
/* Placeholder, this will be updated using javascript */
animation-duration: 40s;
/* We stop in the end */
animation-iteration-count: 1;
/* Stay on pause when the animation is finished finished */
animation-fill-mode: forwards;
/* We start paused, we start the animation using javascript */
animation-play-state: paused;
/* We want a linear animation, ease-out is standard */
animation-timing-function: linear;
}
@keyframes progressbar-countdown {
0% {
width: 100%;
background: #82b92e;
}
100% {
width: 0%;
background: #e63c52;
}
}
</style>
<?php
echo '<link rel="icon" href="../../'.ui_get_favicon().'" type="image/ico" />';
@ -98,106 +176,121 @@ ui_print_message_dialog(
'/images/error_1.png'
);
$table = new StdClass;
$table->width = '100%';
$table->class = 'w16px sound_div_background ';
$table->size[0] = '10%';
$table->rowclass[0] = 'bold_top';
$table->rowclass[1] = 'bold_top';
$table->rowclass[2] = 'bold_top';
$inputs = [];
$table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(
false,
$access,
true,
'group',
'',
'changeGroup();',
'',
0,
true,
false,
true,
'',
false,
'max-width:200px;'
).'<br /><br />';
// Load filter.
$fields = \events_get_event_filter_select();
$inputs[] = [
'label' => \__('Load filter'),
'class' => 'flex-row',
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'filter_id',
'selected' => 0,
'return' => true,
'nothing' => \__('All new events'),
'nothing_value' => 0,
'class' => 'fullwidth',
],
];
$table->data[0][2] = __('Type');
$table->data[0][3] = html_print_checkbox(
'alert_fired',
'alert_fired',
true,
true,
false,
'changeType();'
);
$table->data[0][3] .= __('Alert fired').'<br />';
$table->data[0][3] .= html_print_checkbox(
'critical',
'critical',
true,
true,
false,
'changeType();'
);
$table->data[0][3] .= __('Monitor critical').'<br />';
$table->data[0][3] .= html_print_checkbox(
'unknown',
'unknown',
true,
true,
false,
'changeType();'
);
$table->data[0][3] .= __('Monitor unknown').'<br />';
$table->data[0][3] .= html_print_checkbox(
'warning',
'warning',
true,
true,
false,
'changeType();'
);
$table->data[0][3] .= __('Monitor warning').'<br />';
$times_interval = [
10 => '10 '.__('seconds'),
15 => '15 '.__('seconds'),
30 => '30 '.__('seconds'),
60 => '60 '.__('seconds'),
];
$table->data[1][0] = __('Agent');
$table->data[1][1] = html_print_select(
$agents,
'id_agents[]',
true,
$times_sound = [
2 => '2 '.__('seconds'),
5 => '5 '.__('seconds'),
10 => '10 '.__('seconds'),
15 => '15 '.__('seconds'),
30 => '30 '.__('seconds'),
60 => '60 '.__('seconds'),
];
$inputs[] = [
'class' => 'flex-row flex-row-center',
'direct' => 1,
'block_content' => [
[
'label' => __('Interval'),
'arguments' => [
'type' => 'select',
'fields' => $times_interval,
'name' => 'interval',
'selected' => 10,
'return' => true,
],
],
[
'label' => __('Time Sound'),
'arguments' => [
'type' => 'select',
'fields' => $times_sound,
'name' => 'time_sound',
'selected' => 10,
'return' => true,
],
],
],
];
$sounds = [
'aircraftalarm.wav' => 'Air craft alarm',
'air_shock_alarm.wav' => 'Air shock alarm',
'alien_alarm.wav' => 'Alien alarm',
'alien_beacon.wav' => 'Alien beacon',
'bell_school_ringing.wav' => 'Bell school ringing',
'Door_Alarm.wav' => 'Door alarm',
'EAS_beep.wav' => 'EAS beep',
'Firewarner.wav' => 'Fire warner',
'HardPCMAlarm.wav' => 'Hard PCM Alarm',
'negativebeep.wav' => 'Negative beep',
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
];
$inputs[] = [
'label' => \__('Sounds'),
'class' => 'flex-row',
'arguments' => [
'type' => 'select',
'fields' => $sounds,
'name' => 'sound_id',
'selected' => 'Star_Trek_emergency_simulation.wav',
'return' => true,
'class' => 'fullwidth',
],
];
// Print form.
HTML::printForm(
[
'form' => [
'action' => '',
'method' => 'POST',
],
'inputs' => $inputs,
],
false,
'',
'',
true,
true,
'',
'',
'',
'max-width:200px; height:100px',
'',
false,
'',
'',
true
);
$table->data[1][2] = __('Event');
$table->data[1][3] = html_print_textarea(
'events_fired',
200,
20,
'',
'readonly="readonly" style="max-height:100px; resize:none;"',
true
);
$result = '<div><ul class="events_fired">';
$result .= '<li class="events_fired_li_empty">';
$result .= ui_print_info_message(__('Events not found'), '', true);
$result .= '</li>';
$result .= '</ul></div>';
html_print_table($table);
$result .= '<div id="progressbar_time"></div>';
echo $result;
$table = new StdClass;
$table->width = '100%';
$table->class = 'w16px sound_div_background text_center';
$table->class = 'sound_div_background text_center';
$table->data[0][0] = '<a href="javascript: toggleButton();">';
$table->data[0][0] .= html_print_image(
@ -239,18 +332,11 @@ html_print_table($table);
?>
<script type="text/javascript">
var group = 0;
var alert_fired = true;
var critical = true;
var warning = true;
var unknown = true;
var control = false;
var running = false;
var id_row = 0;
var button_play_status = "play";
var test_sound = false;
function test_sound_button() {
@ -258,64 +344,18 @@ function test_sound_button() {
$("#button_try").attr('src', '../../images/icono_test.png');
$('body').append("<audio src='../../include/sounds/Star_Trek_emergency_simulation.wav' autoplay='true' hidden='true' loop='false'>");
test_sound = true;
}
else {
} else {
$("#button_try").attr('src', '../../images/icono_test.png');
$('body audio').remove();
test_sound = false;
}
}
function changeGroup() {
group = $("#group").val();
jQuery.post ("../../ajax.php",
{"page" : "include/ajax/agent",
"get_agents_group": 1,
"id_group": group
},
function (data) {
$("#id_agents").empty();
jQuery.each (data, function (id, value) {
if (value != "") {
$("#id_agents")
.append(
'<option value="' + id + '">' + value + '</option>'
);
}
});
},
"json"
);
}
function changeType() {
alert_fired = false;
critical = false;
warning = false;
unknown = false;
if($("input[name=alert_fired]").is(':checked') ) {
alert_fired = true;
}
if($("input[name=critical]").is(':checked') ) {
critical = true;
}
if($("input[name=warning]").is(':checked') ) {
warning = true;
}
if($("input[name=unknown]").is(':checked') ) {
unknown = true;
}
}
function toggleButton() {
if (button_play_status == 'pause') {
$("#button").attr('src', '../../images/play.button.png');
stopSound();
control.paused();
button_play_status = 'play';
}
@ -331,7 +371,7 @@ function toggleButton() {
function ok() {
$('#button_status').attr('src','../../images/tick_sound_events.png');
$('audio').remove();
$('#textarea_events_fired').val("");
$('.events_fired').empty();
}
function stopSound() {
@ -345,66 +385,77 @@ function startSound() {
}
function forgetPreviousEvents() {
var agents = $("#id_agents").val();
jQuery.post ("../../ajax.php",
{"page" : "include/ajax/events",
"get_events_fired": 1,
"id_group": group,
"alert_fired": alert_fired,
"critical": critical,
"warning": warning,
"unknown": unknown,
"id_row": id_row,
"agents[]" : agents
},
function (data) {
firedId = parseInt(data['fired']);
if (firedId != 0) {
id_row = firedId;
if(control === false) {
running = true;
control = progressTimeBar(
"progressbar_time",
$("#interval").val(),
'infinite',
function() {
check_event();
}
running = true;
},
"json"
);
);
} else {
control.start();
}
}
function check_event() {
var agents = $("#id_agents").val();
if (running) {
var sound = '../../include/sounds/' + $('#sound_id').val();
jQuery.post ("../../ajax.php",
{"page" : "include/ajax/events",
{
"page" : "include/ajax/events",
"get_events_fired": 1,
"id_group": group,
"alert_fired": alert_fired,
"critical": critical,
"warning": warning,
"unknown": unknown,
"id_row": id_row,
"agents[]" : agents,
"filter_id": $('#filter_id').val(),
"interval": $('#interval').val(),
"time_sound": $('#time_sound').val(),
},
function (data) {
firedId = parseInt(data['fired']);
if (firedId != 0) {
id_row = firedId;
var actual_text = $('#textarea_events_fired').val();
if (actual_text == "") {
$('#textarea_events_fired').val(data['message'] + "\n");
} else {
$('#textarea_events_fired')
.val(actual_text + "\n" + data['message'] + "\n");
}
if(data != false) {
$('.events_fired_li_empty').remove();
$('#button_status')
.attr(
'src','../../images/sound_events_console_alert.gif'
);
$('audio').remove();
if(data['sound'] == '') {
data['sound'] = 'include/sounds/Star_Trek_emergency_simulation.wav';
}
$('body')
.append("<audio src='../../" + data['sound'] + "' autoplay='true' hidden='true' loop='true'>");
.append(
"<audio id='audio-boom' src='" + sound + "' autoplay='true' hidden='true' loop='true' >"
);
data.forEach(function (element) {
var li = document.createElement('li');
li.insertAdjacentHTML(
'beforeend',
'<div class="flex0">'+element.priority+'</div>'
);
li.insertAdjacentHTML(
'beforeend',
'<div class="flex0">'+element.type+'</div>'
);
li.insertAdjacentHTML(
'beforeend',
'<div class="mess">'+element.message+'</div>'
);
li.insertAdjacentHTML(
'beforeend',
'<div class="flex-time">'+element.timestamp+'</div>'
);
$('.events_fired').append(li);
});
function removeAudio() {
$('audio').remove();
}
// -100 delay sound.
setTimeout(
removeAudio,
(parseInt($('#time_sound').val()) * 1000) - 100
);
}
},
"json"
@ -412,11 +463,6 @@ function check_event() {
}
}
$(document).ready (function () {
//10 seconds between ajax request
setInterval("check_event()", (10 * 1000));
});
</script>
<?php

View File

@ -420,7 +420,6 @@ if (check_acl($config['id_user'], 0, 'ER')
// Sound Events.
$javascript = "javascript: window.open('operation/events/sound_events.php');";
$javascript = 'javascript: alert(111);';
$javascript = 'javascript: openSoundEventWindow();';
$sub[$javascript]['text'] = __('Sound Events');
$sub[$javascript]['id'] = 'Sound Events';
@ -432,12 +431,12 @@ if (check_acl($config['id_user'], 0, 'ER')
url = '<?php echo ui_get_full_url('operation/events/sound_events.php'); ?>';
// devicePixelRatio knows how much zoom browser applied.
var windowScale = parseFloat(window.devicePixelRatio);
var defaultWidth = 600;
var defaultHeight = 450;
var defaultWidth = 630;
var defaultHeight = 630;
// If the scale is 1, no zoom has been applied.
var windowWidth = windowScale <= 1 ? defaultWidth : windowScale*defaultWidth;
var windowHeight = windowScale <= 1 ? defaultHeight : windowScale*defaultHeight + (defaultHeight*0.1);
window.open(
url,
'<?php __('Sound Alerts'); ?>',

View File

@ -73,6 +73,12 @@ if (empty($message) === false) {
echo $message;
}
$return_all_group = false;
if (users_can_manage_group_all('LM') === true) {
$return_all_group = true;
}
$inputs = [];
// Name.
@ -91,7 +97,7 @@ $inputs[] = [
'label' => __('Group'),
'arguments' => [
'type' => 'select_groups',
'returnAllGroup' => true,
'returnAllGroup' => $return_all_group,
'name' => 'id_group',
'selected' => $calendar->id_group(),
'required' => true,

View File

@ -50,6 +50,7 @@ $form = [
HTML::printForm(
[
'form' => $form,
'blocks' => $blocks,
'inputs' => $htmlInputs,
'js' => $js,
]