2019-10-17 15:17:28 +02:00
|
|
|
/* global $ */
|
|
|
|
/* exported load_modal */
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
var ENTERPRISE_DIR = "enterprise";
|
2009-02-19 Esteban Sanchez <estebans@artica.es>
* include/functions_ui.php: Added require_css_file(),
require_javascript_file() and require_jquery_file() to add CSS,
javascript and jQuery files to the header easily without changing
config object. A path parameter is addded to allow the use on
enterprise code.
* include/functions_db.php: Added
get_db_value_filter(), get_db_all_rows_filter() and
process_sql_delete(). Fixed delete_agent() style and use these
functions. Added process_page_head() from functions_ui.php and changed
a bit the config javascript object part.
* include/functions_custom_graphs.php: Get results indexed by id on
get_user_custom_graphs().
* include/functions.php: Moved process_page_head to functions_ui.php.
* godmode/agentes/manage_delete.php: New interface to perform massive
agents deletion.
* godmode/menu.php: Added new option to massive agents deletion.
* general/main_menu.php, godmode/agentes/manage_config.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/planned_downtime.php,
godmode/alerts/alert_compounds.php, godmode/alerts/alert_list.php,
godmode/alerts/configure_alert_compound.php,
godmode/alerts/configure_alert_template.php,
godmode/reporting/map_builder.php, operation/agentes/networkmap.php,
operation/reporting/reporting_viewer.php,
operation/visual_console/render_view.php: Use new functions in include
CSS and javascript files.
* index.php: Bit of style when printing the header so the HTML can be
readed easily in a editor.
* include/javascript/pandora.js: Added a variable to determine the
enterprise directory.
* include/styles/pandora.css: Added style for manage_delete.php
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1467 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-19 17:10:04 +01:00
|
|
|
|
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
|
|
|
/* Function to hide/unhide a specific Div id */
|
2019-01-30 12:27:18 +01:00
|
|
|
function toggleDiv(divid) {
|
|
|
|
if (document.getElementById(divid).style.display == "none") {
|
|
|
|
document.getElementById(divid).style.display = "block";
|
|
|
|
} else {
|
|
|
|
document.getElementById(divid).style.display = "none";
|
|
|
|
}
|
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function winopeng(url, wid) {
|
|
|
|
open(
|
|
|
|
url,
|
|
|
|
wid,
|
|
|
|
"width=1000,height=550,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes"
|
|
|
|
);
|
|
|
|
// WARNING !! Internet Explorer DOESNT SUPPORT "-" CARACTERS IN WINDOW HANDLE VARIABLE
|
|
|
|
status = wid;
|
2012-12-09 23:31:29 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function winopeng_var(url, wid, width, height) {
|
|
|
|
open(
|
|
|
|
url,
|
|
|
|
wid,
|
|
|
|
"width=" +
|
|
|
|
width +
|
|
|
|
",height=" +
|
|
|
|
height +
|
|
|
|
",status=no,toolbar=no,menubar=no,scrollbar=yes"
|
|
|
|
);
|
|
|
|
// WARNING !! Internet Explorer DOESNT SUPPORT "-" CARACTERS IN WINDOW HANDLE VARIABLE
|
|
|
|
status = wid;
|
2008-03-06 Sancho Lerena <slerena@gmail.com>
Pandora FMS 2.0 development first commit. 1.4 version is now 2.0
* pandoradb_data.sql: Added correct tnetwork_components, fixed
ttipo_modulo (categoria values).
* include/styles/pandora.css: Added some server icons, tab style
for module editor has been improved.
* include/functions_db.php: added new functions, lang_string and
check_login, and a first review of several functions that currently
need change for new config session parameters in array $config[]
* include/javascript/pandora.js: Added a new global include for
spare javascript functions before included into a few pages.
* include/languages/language_en.php: New tokens.
* include/help*: New contextual help system.
* include/config_process.php: New way to manage config.
* include/functions.php: Added new functions to manage global
* operation/agentes/estado_ultimopaquete.php: removed old javascript
code from there.
* operation/agentes/estado_agente.php: Removed references to deprecated
field "agent_type".
* operation/agentes/tactical.php: Some code cleanup and progressbar
issues merged from 1.3.1 branch. Need to add support to new server
types and new module types.
* operation/servers/view_server.php: Added support to new servers, code
cleanup.
* reporting/fgraph.php: Code cleanup, changes to use new config method,
and a lot of style change.
* general/pandora_help.php: New source for contextual help in the way
of moodle.
* general/footer.php, general/noaccess.php: Code cleanup and uses of
new config.
* module_manager_editor: New editors for each module family. Need
finish and implement EDITION of data, now only inserts data.
* godmode/agentes/agent_manager.php: Implemented new server assigment
and edition.
* godmode/agentes/configurar_agente.php: Small changes that affects
module management, visualization and agent management.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@739 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-03-07 17:22:16 +01:00
|
|
|
}
|
|
|
|
|
2020-06-08 11:24:46 +02:00
|
|
|
function newTabjs(content) {
|
|
|
|
content = atob(content);
|
|
|
|
var printWindow = window.open("");
|
|
|
|
printWindow.document.body.innerHTML += "<div>" + content + "</div>";
|
|
|
|
}
|
|
|
|
|
2019-04-24 13:53:18 +02:00
|
|
|
function open_help(url) {
|
2019-05-07 11:34:09 +02:00
|
|
|
if (!navigator.onLine) {
|
|
|
|
alert(
|
|
|
|
"The help system could not be started. Please, check your network connection."
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (url == "") {
|
|
|
|
alert(
|
|
|
|
"The help system is currently under maintenance. Sorry for the inconvenience."
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
open(
|
2019-04-24 13:53:18 +02:00
|
|
|
url,
|
2019-01-30 12:27:18 +01:00
|
|
|
"pandorahelp",
|
|
|
|
"width=650,height=500,status=0,toolbar=0,menubar=0,scrollbars=1,location=0"
|
|
|
|
);
|
2008-06-17 Esteban Sanchez <estebans@artica.es>
* ajax.php: Added to repository. AJAX interface for Pandora. A new
time is coming...
* pandoradb.sql: Added id_group to treport. A report is now assigned
to a group of agents. Changes in treport_content to add an order
field, drop sla fields and use an enum for the type. NOTE: This will
break all your current defined reports, update under your
responsabillity. Added table treport_content_sla_combined to define
SLAs in the SLA types reports.
* godmode/reporting/graph_builder.php: Use Pandora functions. Adde
javascript code to display the module icon when changing from the
dropdown menu.
* godmode/reporting/reporting_builder.php: Almost complet rewritten to
use Pandora HTML functions. Style correction.
* include/functions.php: Added new report types. Style correction.
* include/functions_db.php: Use Pandora database functions to get
simple values. Added functions get_agents_in_group(),
get_modules_in_agent(), get_simple_alerts_in_agent(),
get_combined_alerts_in_agent(), get_alerts_in_agent(),
get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(),
get_alert_fires_in_period(),
get_alert_last_fire_timestamp_in_period(). Deleted debug output and
fixed calling to an inexistent function in
return_moduledata_sum_value().
* include/functions_html.php: Tab style correction. Thanks to Ramon
for the advice. Fixed some errors on print_table that was causing not
to work fine if rowclass or colspan was defined.
* include/functions_reporting.php: Adde date support to
return_module_SLA(), event_reporting(). Added alert_reporting(),
monitor_health_reporting(), general_group_reporting() and
agents_detailed_reporting() to implement new report types. Style
correction.
* include/javascript/pandora.js: Added html_entity_decode() function
to decode some AJAX results.
* javascript/jquery.js: Added to repository. jQuery version 1.2.4a
* include/javascript/jquery.timeentry.js: jQuery plugin to manage time
inputs.
* include/javascript/jquery.ui.datepicker.js: jQuery plugin to manage
date inputs in a dropdown calendar.
* include/languages/date_*.js, include/languages/time_*.js: Added to
repository. Translation of date and time strings for the new calendar
javascript support.
* include/languages/language_en.php: Added new strings relatives to
reports.
* include/languages/language_de.php,
include/languages/language_fr.php, include/languages/language_gl.php,
include/languages/language_pt_br.php: Fixed a variable name.
* godmode/groups/group_list.php: Avoid the use of an extra indentation
by returning if no success on comprueba_login().
* include/styles/pandora.css: Add some classes. Tab style correction.
* operation/agentes/ver_agente.php: Added AJAX support to agent
operations.
* operation/reporting/graph_viewer.php: Period dropdown selection
improved and printed with Pandora functions.
* operation/reporting/reporting_viewer.php: Massive rewritten.
Implemented date and time support, added new report types, use Pandora
functions...
* reporting/fgraph.php: Documentation fix. Added a new graphic to show
monitors health.
* godmode/agentes/agent_manager.php,
operation/reporting/custom_reporting.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@869 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-17 16:30:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decode HTML entities into characters. Useful when receiving something from AJAX
|
|
|
|
*
|
|
|
|
* @param str String to convert
|
|
|
|
*
|
|
|
|
* @retval str with entities decoded
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
function js_html_entity_decode(str) {
|
|
|
|
if (!str) return "";
|
|
|
|
|
|
|
|
str2 = str
|
|
|
|
.replace(/</g, "<")
|
|
|
|
.replace(/>/g, ">")
|
|
|
|
.replace(/</g, "<")
|
|
|
|
.replace(/>/g, ">")
|
|
|
|
.replace(/\/g, "\\")
|
|
|
|
.replace(/"/g, '"')
|
|
|
|
.replace(/'/g, "'")
|
|
|
|
.replace(/&/g, "&")
|
|
|
|
.replace(/ /g, " ")
|
|
|
|
.replace(/ /g, "\r")
|
|
|
|
.replace(/ /g, "\n");
|
|
|
|
|
|
|
|
return str2;
|
2008-06-17 Esteban Sanchez <estebans@artica.es>
* ajax.php: Added to repository. AJAX interface for Pandora. A new
time is coming...
* pandoradb.sql: Added id_group to treport. A report is now assigned
to a group of agents. Changes in treport_content to add an order
field, drop sla fields and use an enum for the type. NOTE: This will
break all your current defined reports, update under your
responsabillity. Added table treport_content_sla_combined to define
SLAs in the SLA types reports.
* godmode/reporting/graph_builder.php: Use Pandora functions. Adde
javascript code to display the module icon when changing from the
dropdown menu.
* godmode/reporting/reporting_builder.php: Almost complet rewritten to
use Pandora HTML functions. Style correction.
* include/functions.php: Added new report types. Style correction.
* include/functions_db.php: Use Pandora database functions to get
simple values. Added functions get_agents_in_group(),
get_modules_in_agent(), get_simple_alerts_in_agent(),
get_combined_alerts_in_agent(), get_alerts_in_agent(),
get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(),
get_alert_fires_in_period(),
get_alert_last_fire_timestamp_in_period(). Deleted debug output and
fixed calling to an inexistent function in
return_moduledata_sum_value().
* include/functions_html.php: Tab style correction. Thanks to Ramon
for the advice. Fixed some errors on print_table that was causing not
to work fine if rowclass or colspan was defined.
* include/functions_reporting.php: Adde date support to
return_module_SLA(), event_reporting(). Added alert_reporting(),
monitor_health_reporting(), general_group_reporting() and
agents_detailed_reporting() to implement new report types. Style
correction.
* include/javascript/pandora.js: Added html_entity_decode() function
to decode some AJAX results.
* javascript/jquery.js: Added to repository. jQuery version 1.2.4a
* include/javascript/jquery.timeentry.js: jQuery plugin to manage time
inputs.
* include/javascript/jquery.ui.datepicker.js: jQuery plugin to manage
date inputs in a dropdown calendar.
* include/languages/date_*.js, include/languages/time_*.js: Added to
repository. Translation of date and time strings for the new calendar
javascript support.
* include/languages/language_en.php: Added new strings relatives to
reports.
* include/languages/language_de.php,
include/languages/language_fr.php, include/languages/language_gl.php,
include/languages/language_pt_br.php: Fixed a variable name.
* godmode/groups/group_list.php: Avoid the use of an extra indentation
by returning if no success on comprueba_login().
* include/styles/pandora.css: Add some classes. Tab style correction.
* operation/agentes/ver_agente.php: Added AJAX support to agent
operations.
* operation/reporting/graph_viewer.php: Period dropdown selection
improved and printed with Pandora functions.
* operation/reporting/reporting_viewer.php: Massive rewritten.
Implemented date and time support, added new report types, use Pandora
functions...
* reporting/fgraph.php: Documentation fix. Added a new graphic to show
monitors health.
* godmode/agentes/agent_manager.php,
operation/reporting/custom_reporting.php: Style correction.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@869 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-17 16:30:44 +02:00
|
|
|
}
|
2008-06-26 Esteban Sanchez <estebans@artica.es>
* ajax.php: Sed id_user in config array.
* godmode/menu.php, general/header.php, operation/menu.php: Replaced
lang_label with lang_string().
* general/logon_ok.php: Reduced one indentation level.
* godmode/agentes/agent_manager.php: Replaced lang_label with
lang_string(). Use pandora functions.
* include/functions_html.php, godmode/agentes/configurar_agente.php:
Tab and blankspaces style correction.
* godmode/reporting/map_builder.php: Complete rewritten to provide an
intuitive way of build the maps. It's cool, useful and very simple.
* godmode/reporting/reporting_builder.php: Deleted an output debug.
* godmode/setup/setup.php: Rewritten to use pandora functions. Added a
colorpicker for color settings.
* include/config.php: Reset pandora password. We must solve things
with this file...
* include/functions.php: Check if input is an array on safe_input().
Use filename as id in array returned by list_files().
* include/functions_db.php: Renamed return_coordinate_* functions.
Style correction.
* include/javascript/jquery.js: Updated to 1.2.6.
* include/javascript/jquery.ui.datepicker.js: Code minimized.
* include/javascript/pandora.js: Style correction.
* include/javascript/wz_jsgraphics.js: Added a class to the elements
of a line, so it can be modified using javascript.
* /include/styles/pandora.css: Added style to some tables dropdowns.
Added new styles relative to visual map editor.
* operation/reporting/reporting_viewer.php: Style correction. Added
jQuery UI.
* operation/visual_console/index.php: Use Pandora functions.
* operation/visual_console/render_view.php: Drawing the map is now on
functions_visual_map.php. Added a countdown if a refresh time is set.
Use pandora functions. Style correction.
* reporting/fgraph.php: Style correction. Use graphic_error() if
there's no data on grafico_modulo_sparse().
* images/trash.png: Added to repository. Image used on trash area on
visual map editor.
* images/console/background/africa.jpg,
images/console/background/asia.jpg,
images/console/background/europe.jpg,
images/console/background/north_america.jpg,
images/console/background/oceania.jpg,
images/console/background/shouth_america.jpg,
images/console/background/world.jpg: Added to repository. Useful and
cool map backgrounds.
* include/functions_visual_map.php: Added to repository. Implements
visual map functions like drawing the map.
* include/javascript/jquery.colorpicker.js: Added to repository.
Implements a color picker widget.
* /include/javascript/jquery.countdown.js: Added to repository.
Implements a countdown widget.
* include/javascript/jquery.ui.core.js: Added to repository. jQuery UI
core.
* include/javascript/jquery.ui.draggable.js: Added to repository.
jQuery draggable plugin.
* include/javascript/jquery.ui.droppable.js: Added to repository.
jQuery droppable plugin.
* include/javascript/pandora_visual_console.js: Added to repository.
Function useful to visual map interface.
* include/languages/countdown_*.js: Added to repository. Countdown
localization.
* include/languages/date_es_la.js, include/languages/date_gl.js,
include/languages/time_es_la.js, include/languages/time_gl.js: Added
to repository. Missing localizations.
* include/styles/color-picker.css: Added to repository. Colorpicker
style sheet.
* include/styles/countdown.css: Added to repository. Countdown style
sheet.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@899 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-06-26 15:26:48 +02:00
|
|
|
|
2022-01-31 15:43:56 +01:00
|
|
|
function truncate_string(str, str_length, separator) {
|
|
|
|
if (str.length <= str_length) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
separator = separator || "...";
|
|
|
|
|
|
|
|
var separator_length = separator.length,
|
|
|
|
chars_to_show = str_length - separator_length,
|
|
|
|
front_chars = Math.ceil(chars_to_show / 2),
|
|
|
|
tail_chars = Math.floor(chars_to_show / 2);
|
|
|
|
|
|
|
|
return (
|
|
|
|
str.substr(0, front_chars) + separator + str.substr(str.length - tail_chars)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-02-02 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php,
godmode/agentes/module_manager.php,
godmode/agentes/module_manager_editor.php,
godmode/agentes/module_manager_editor_data.php,
godmode/agentes/module_manager_editor_network.php,
godmode/agentes/module_manager_editor_plugin.php,
godmode/agentes/module_manager_editor_prediction.php,
godmode/agentes/module_manager_editor_wmi.php: Agent module editions
rewritten. The interface should be clearer now and SNMP walking much
more faster, since it's done with AJAX. Some cleanup might be needed
yet.
* godmode/agentes/module_manager_editor_common.php: Added to
repository. Common part for agent module editors.
* images/edit.png, images/spinner.gif: Added to repository.
* include/javascript/jquery.form.js: Added to repository. jQuery form
plugin.
* include/javascript/jquery.pandora.js: Added to repository. Special
Pandora addons for jQuery library.
* include/javascript/pandora.js: Added an extension to Array
javascript objects to check if an array has an element.
* include/styles/pandora.css: Added styling for new module editors.
* include/functions_db.php: Added get_moduletype_description().
* index.php: Added Pandora jQuery extensions.
* pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text
useless field from talert_templates.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2009-02-02 16:40:31 +01:00
|
|
|
/**
|
|
|
|
* Function to search an element in an array.
|
|
|
|
*
|
|
|
|
* Extends the array object to use it like a method in an array object. Example:
|
|
|
|
* <code>
|
|
|
|
a = Array (4, 7, 9);
|
|
|
|
alert (a.in_array (4)); // true
|
|
|
|
alert (a.in_array (5)); // false
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
Array.prototype.in_array = function() {
|
|
|
|
for (var j in this) {
|
|
|
|
if (this[j] == arguments[0]) return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-06-09 13:07:01 +02:00
|
|
|
};
|
2009-03-09 21:47:42 +01:00
|
|
|
|
2011-02-15 20:07:23 +01:00
|
|
|
/**
|
|
|
|
* Util for check is empty object
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2011-02-15 20:07:23 +01:00
|
|
|
* @param obj the object to check
|
|
|
|
* @returns {Boolean} True it is empty
|
|
|
|
*/
|
|
|
|
function isEmptyObject(obj) {
|
2019-01-30 12:27:18 +01:00
|
|
|
for (var prop in obj) {
|
|
|
|
if (obj.hasOwnProperty(prop)) return false;
|
|
|
|
}
|
2011-02-15 20:07:23 +01:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-02-15 20:07:23 +01:00
|
|
|
|
2010-04-22 20:50:00 +02:00
|
|
|
/**
|
|
|
|
* Fill up select box with id "module" with modules after agent has been selected, but this not empty the select box.s
|
|
|
|
*
|
|
|
|
* @param event that has been triggered
|
|
|
|
* @param id_agent Agent ID that has been selected
|
|
|
|
* @param selected Which module(s) have to be selected
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
function agent_changed_by_multiple_agents(event, id_agent, selected) {
|
|
|
|
// Hack to avoid certain module types
|
|
|
|
var module_types_excluded = [];
|
|
|
|
if (typeof $("input.module_types_excluded") !== "undefined") {
|
|
|
|
try {
|
|
|
|
$("input.module_types_excluded").each(function(index, el) {
|
|
|
|
var module_type = parseInt($(el).val());
|
|
|
|
|
2021-10-18 15:47:22 +02:00
|
|
|
if (isNaN(module_type) == false)
|
|
|
|
module_types_excluded.push(module_type);
|
2019-01-30 12:27:18 +01:00
|
|
|
});
|
|
|
|
} catch (error) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
var module_status = -1;
|
|
|
|
if (typeof $("#status_module") !== "undefined") {
|
|
|
|
try {
|
|
|
|
module_status = $("#status_module").val();
|
|
|
|
} catch (error) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Module name
|
|
|
|
var module_name = $("#text-module_filter").val();
|
|
|
|
|
|
|
|
var idAgents = Array();
|
|
|
|
|
|
|
|
jQuery.each($("#id_agents option:selected"), function(i, val) {
|
|
|
|
//val() because the var is same <option val="NNN"></option>
|
|
|
|
idAgents.push($(val).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
var tags_to_search = $("#tags1").val();
|
|
|
|
|
|
|
|
//Hack to find only enabled modules
|
|
|
|
//Pass a flag as global var
|
|
|
|
find_modules = "all";
|
|
|
|
if (
|
|
|
|
typeof show_only_enabled_modules !== "undefined" &&
|
|
|
|
show_only_enabled_modules
|
|
|
|
) {
|
|
|
|
find_modules = "enabled";
|
|
|
|
}
|
|
|
|
|
|
|
|
var selection_mode = $("#modules_selection_mode").val();
|
|
|
|
if (typeof selection_mode === "undefined") {
|
|
|
|
selection_mode = "common";
|
|
|
|
}
|
|
|
|
|
|
|
|
var serialized = $("#hidden-serialized").val();
|
|
|
|
if (typeof serialized === "undefined") {
|
|
|
|
serialized = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#module")
|
|
|
|
.prop("disabled", true)
|
|
|
|
.empty()
|
|
|
|
.append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html("Loading...")
|
|
|
|
.attr("value", 0)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Check if homedir was received like a JSON
|
|
|
|
var homedir = ".";
|
|
|
|
var id_server = 0;
|
|
|
|
if (typeof event !== "undefined" && typeof event.data !== "undefined") {
|
|
|
|
if (event.data != null) {
|
|
|
|
if (typeof event.data !== "undefined") {
|
|
|
|
if (typeof event.data.homedir !== "undefined") {
|
|
|
|
homedir = event.data.homedir;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
typeof event.data.metaconsole !== "undefined" &&
|
|
|
|
event.data.metaconsole
|
|
|
|
) {
|
|
|
|
id_server = $("#" + event.data.id_server).val();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery.post(
|
|
|
|
homedir + "/ajax.php",
|
|
|
|
{
|
|
|
|
page: "operation/agentes/ver_agente",
|
|
|
|
get_agent_modules_json_for_multiple_agents: 1,
|
|
|
|
"id_agent[]": idAgents,
|
|
|
|
"tags[]": tags_to_search,
|
|
|
|
all: find_modules,
|
|
|
|
"module_types_excluded[]": module_types_excluded,
|
|
|
|
name: module_name,
|
|
|
|
selection_mode: selection_mode,
|
|
|
|
serialized: serialized,
|
|
|
|
id_server: id_server,
|
|
|
|
status_module: module_status
|
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
$("#module").empty();
|
|
|
|
|
|
|
|
if (isEmptyObject(data)) {
|
|
|
|
//Trick for catch the translate text.
|
|
|
|
var noneText =
|
|
|
|
$("#id_agents").val() === null
|
|
|
|
? $("#select_agent_first_text").html()
|
|
|
|
: $("#none_text").html();
|
|
|
|
if (noneText == null) {
|
|
|
|
noneText = "None";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(noneText)
|
|
|
|
.attr("None", "")
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof $(document).data("text_for_module") != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html($(document).data("text_for_module"))
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (typeof data["any_text"] != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(data["any_text"])
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
var anyText = $("#any_text").html(); //Trick for catch the translate text.
|
|
|
|
|
|
|
|
if (anyText == null) {
|
|
|
|
anyText = "Any";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(anyText)
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2021-02-25 16:08:02 +01:00
|
|
|
|
|
|
|
var all_common_modules = [];
|
|
|
|
|
|
|
|
$.each(data, function(i, val) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var s = js_html_entity_decode(val);
|
|
|
|
|
2021-06-11 08:52:10 +02:00
|
|
|
s = s.replace(/"/g, """).replace(/'/g, "'");
|
|
|
|
i = i.replace(/"/g, """).replace(/'/g, "'");
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#module").append(
|
2021-06-11 08:52:10 +02:00
|
|
|
$('<option value="' + i + '" title="' + s + '"></option>').text(val)
|
2019-01-30 12:27:18 +01:00
|
|
|
);
|
|
|
|
|
2021-02-25 16:08:02 +01:00
|
|
|
all_common_modules.push(i);
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#module").fadeIn("normal");
|
|
|
|
});
|
2021-02-25 16:08:02 +01:00
|
|
|
|
|
|
|
$("#hidden-all_common_modules").val(all_common_modules.toString());
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
if (typeof selected !== "undefined") $("#module").attr("value", selected);
|
|
|
|
|
|
|
|
$("#module")
|
|
|
|
.css("max-width", "")
|
|
|
|
.prop("disabled", false);
|
|
|
|
|
|
|
|
if (typeof function_hook_loaded_module_list == "function") {
|
|
|
|
function_hook_loaded_module_list();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2010-10-08 13:16:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill up select box with id "module" with modules with alerts of one template
|
|
|
|
* after agent has been selected, but this not empty the select box.s
|
|
|
|
*
|
|
|
|
* @param event that has been triggered
|
|
|
|
* @param id_agent Agent ID that has been selected
|
|
|
|
* @param selected Which module(s) have to be selected
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
function agent_changed_by_multiple_agents_with_alerts(
|
|
|
|
event,
|
|
|
|
id_agent,
|
|
|
|
selected
|
|
|
|
) {
|
|
|
|
var idAgents = Array();
|
|
|
|
|
|
|
|
jQuery.each($("#id_agents option:selected"), function(i, val) {
|
|
|
|
//val() because the var is same <option val="NNN"></option>
|
|
|
|
idAgents.push($(val).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
var selection_mode = $("#modules_selection_mode").val();
|
|
|
|
if (selection_mode == undefined) {
|
|
|
|
selection_mode = "common";
|
|
|
|
}
|
|
|
|
|
|
|
|
template = $("#id_alert_template option:selected").val();
|
|
|
|
|
|
|
|
$("#module").attr("disabled", 1);
|
|
|
|
$("#module").empty();
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html("Loading...")
|
|
|
|
.attr("value", 0)
|
|
|
|
);
|
|
|
|
jQuery.post(
|
|
|
|
"ajax.php",
|
|
|
|
{
|
|
|
|
page: "operation/agentes/ver_agente",
|
|
|
|
get_agent_modules_multiple_alerts_json_for_multiple_agents: 1,
|
|
|
|
template: template,
|
|
|
|
"id_agent[]": idAgents,
|
|
|
|
selection_mode: selection_mode
|
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
$("#module").empty();
|
|
|
|
|
|
|
|
if (typeof $(document).data("text_for_module") != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html($(document).data("text_for_module"))
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (typeof data["any_text"] != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(data["any_text"])
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
var anyText = $("#any_text").html(); //Trick for catch the translate text.
|
|
|
|
|
|
|
|
if (anyText == null) {
|
|
|
|
anyText = "Any";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(anyText)
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jQuery.each(data, function(i, val) {
|
2021-06-11 08:52:10 +02:00
|
|
|
var s = js_html_entity_decode(val);
|
|
|
|
|
|
|
|
s = s.replace(/"/g, """).replace(/'/g, "'");
|
|
|
|
|
|
|
|
$("#module").append($('<option value="' + s + '"></option>').text(val));
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#module").fadeIn("normal");
|
|
|
|
});
|
|
|
|
if (selected != undefined) $("#module").attr("value", selected);
|
|
|
|
$("#module").removeAttr("disabled");
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2017-01-12 15:51:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill up select box with id "module" with modules with alerts of one or more templates
|
|
|
|
* before agent has been selected, but this not empty the select box.s
|
|
|
|
*
|
|
|
|
* @param event that has been triggered
|
|
|
|
* @param id_agent Agent ID that has been selected
|
|
|
|
* @param selected Which module(s) have to be selected
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
function alert_templates_changed_by_multiple_agents_with_alerts(
|
|
|
|
event,
|
|
|
|
id_agent,
|
|
|
|
selected
|
|
|
|
) {
|
|
|
|
var idAgents = Array();
|
|
|
|
|
|
|
|
jQuery.each($("#id_agents option:selected"), function(i, val) {
|
|
|
|
//val() because the var is same <option val="NNN"></option>
|
|
|
|
idAgents.push($(val).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
var selection_mode = $("#modules_selection_mode").val();
|
|
|
|
if (selection_mode == undefined) {
|
|
|
|
selection_mode = "common";
|
|
|
|
}
|
|
|
|
|
|
|
|
templates = Array();
|
|
|
|
jQuery.each($("#id_alert_templates option:selected"), function(i, val) {
|
|
|
|
//val() because the var is same <option val="NNN"></option>
|
|
|
|
templates.push($(val).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#module").attr("disabled", 1);
|
|
|
|
$("#module").empty();
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html("Loading...")
|
|
|
|
.attr("value", 0)
|
|
|
|
);
|
|
|
|
jQuery.post(
|
|
|
|
"ajax.php",
|
|
|
|
{
|
|
|
|
page: "operation/agentes/ver_agente",
|
|
|
|
get_agent_modules_alerts_json_for_multiple_agents: 1,
|
|
|
|
"templates[]": templates,
|
|
|
|
"id_agent[]": idAgents,
|
|
|
|
selection_mode: selection_mode
|
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
$("#module").empty();
|
|
|
|
|
|
|
|
if (typeof $(document).data("text_for_module") != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html($(document).data("text_for_module"))
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (typeof data["any_text"] != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(data["any_text"])
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
var anyText = $("#any_text").html(); //Trick for catch the translate text.
|
|
|
|
|
|
|
|
if (anyText == null) {
|
|
|
|
anyText = "Any";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(anyText)
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jQuery.each(data, function(i, val) {
|
2021-06-11 08:52:10 +02:00
|
|
|
var decoded_val = js_html_entity_decode(val);
|
|
|
|
|
|
|
|
decoded_val = decoded_val
|
|
|
|
.replace(/"/g, """)
|
|
|
|
.replace(/'/g, "'");
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#module").append(
|
2021-06-11 08:52:10 +02:00
|
|
|
$(
|
|
|
|
'<option value="' +
|
|
|
|
decoded_val +
|
|
|
|
'" title="' +
|
|
|
|
decoded_val +
|
|
|
|
'"></option>'
|
|
|
|
).text(val)
|
2019-01-30 12:27:18 +01:00
|
|
|
);
|
2021-06-11 08:52:10 +02:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#module").fadeIn("normal");
|
|
|
|
});
|
|
|
|
if (selected != undefined) $("#module").attr("value", selected);
|
|
|
|
$("#module").removeAttr("disabled");
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2010-04-22 20:50:00 +02:00
|
|
|
}
|
|
|
|
|
2010-10-04 17:58:05 +02:00
|
|
|
/**
|
|
|
|
* Fill up select box with id "agent" with agents after module has been selected, but this not empty the select box.s
|
|
|
|
*
|
|
|
|
* @param event that has been triggered
|
|
|
|
* @param id_module Module ID that has been selected
|
|
|
|
* @param selected Which agent(s) have to be selected
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
function module_changed_by_multiple_modules(event, id_module, selected) {
|
|
|
|
var idModules = Array();
|
|
|
|
|
|
|
|
jQuery.each($("#module_name option:selected"), function(i, val) {
|
|
|
|
//val() because the var is same <option val="NNN"></option>
|
|
|
|
idModules.push($(val).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#agents").attr("disabled", 1);
|
|
|
|
$("#agents").empty();
|
|
|
|
$("#agents").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html("Loading...")
|
|
|
|
.attr("value", 0)
|
|
|
|
);
|
|
|
|
|
|
|
|
var status_module = -1;
|
|
|
|
if (typeof $("#status_module") !== "undefined") {
|
|
|
|
try {
|
|
|
|
status_module = $("#status_module").val();
|
|
|
|
} catch (error) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
var selection_mode = $("#agents_selection_mode").val();
|
|
|
|
if (selection_mode == undefined) {
|
|
|
|
selection_mode = "common";
|
|
|
|
}
|
|
|
|
|
2019-02-19 13:05:31 +01:00
|
|
|
var tags_selected = [];
|
|
|
|
|
|
|
|
var tags_to_search = $("#tags").val();
|
|
|
|
if (tags_to_search != null) {
|
|
|
|
if (tags_to_search[0] != -1) {
|
|
|
|
tags_selected = tags_to_search;
|
|
|
|
}
|
|
|
|
}
|
2019-01-30 12:27:18 +01:00
|
|
|
jQuery.post(
|
|
|
|
"ajax.php",
|
|
|
|
{
|
|
|
|
page: "operation/agentes/ver_agente",
|
|
|
|
get_agents_json_for_multiple_modules: 1,
|
2022-01-27 17:30:20 +01:00
|
|
|
truncate_agent_names: 1,
|
2019-01-30 12:27:18 +01:00
|
|
|
status_module: status_module,
|
|
|
|
"module_name[]": idModules,
|
2019-02-19 13:05:31 +01:00
|
|
|
selection_mode: selection_mode,
|
|
|
|
tags: tags_selected
|
2019-01-30 12:27:18 +01:00
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
$("#agents").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html("Loading...")
|
|
|
|
.attr("value", 0)
|
|
|
|
);
|
|
|
|
|
|
|
|
$("#agents").empty();
|
|
|
|
|
|
|
|
if (isEmptyObject(data)) {
|
|
|
|
var noneText = $("#none_text").html(); //Trick for catch the translate text.
|
|
|
|
|
|
|
|
if (noneText == null) {
|
|
|
|
noneText = "None";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#agents").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(noneText)
|
|
|
|
.attr("None", "")
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof $(document).data("text_for_module") != "undefined") {
|
|
|
|
$("#agents").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html($(document).data("text_for_module"))
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (typeof data["any_text"] != "undefined") {
|
|
|
|
$("#agents").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(data["any_text"])
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
var anyText = $("#any_text").html(); //Trick for catch the translate text.
|
|
|
|
|
|
|
|
if (anyText == null) {
|
|
|
|
anyText = "Any";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#agents").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(anyText)
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jQuery.each(data, function(i, val) {
|
|
|
|
s = js_html_entity_decode(val);
|
|
|
|
$("#agents").append(
|
|
|
|
$("<option></option>")
|
2022-01-31 15:43:56 +01:00
|
|
|
.html(truncate_string(s, 30, "..."))
|
2022-01-31 13:18:26 +01:00
|
|
|
.attr({ value: i, title: s })
|
2019-01-30 12:27:18 +01:00
|
|
|
);
|
|
|
|
$("#agents").fadeIn("normal");
|
|
|
|
});
|
|
|
|
|
|
|
|
if (selected != undefined) $("#agents").attr("value", selected);
|
|
|
|
$("#agents").removeAttr("disabled");
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2010-10-04 17:58:05 +02:00
|
|
|
}
|
2010-04-19 09:47:55 +02:00
|
|
|
|
2010-05-18 12:03:06 +02:00
|
|
|
/**
|
|
|
|
* Fill up select box with id "module" with modules after agent has been selected, but this not empty the select box.s
|
|
|
|
*
|
|
|
|
* @param event that has been triggered
|
|
|
|
* @param id_agent Agent ID that has been selected
|
|
|
|
* @param selected Which module(s) have to be selected
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
function agent_changed_by_multiple_agents_id(event, id_agent, selected) {
|
|
|
|
var idAgents = Array();
|
|
|
|
|
|
|
|
jQuery.each($("#id_agents option:selected"), function(i, val) {
|
|
|
|
//val() because the var is same <option val="NNN"></option>
|
|
|
|
idAgents.push($(val).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#module").attr("disabled", 1);
|
|
|
|
$("#module").empty();
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html("Loading...")
|
|
|
|
.attr("value", 0)
|
|
|
|
);
|
|
|
|
jQuery.post(
|
|
|
|
"ajax.php",
|
|
|
|
{
|
|
|
|
page: "operation/agentes/ver_agente",
|
|
|
|
get_agent_modules_json_for_multiple_agents_id: 1,
|
|
|
|
"id_agent[]": idAgents
|
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
$("#module").empty();
|
|
|
|
|
|
|
|
if (typeof $(document).data("text_for_module") != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html($(document).data("text_for_module"))
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (typeof data["any_text"] != "undefined") {
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(data["any_text"])
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
var anyText = $("#any_text").html(); //Trick for catch the translate text.
|
|
|
|
|
|
|
|
if (anyText == null) {
|
|
|
|
anyText = "Any";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(anyText)
|
|
|
|
.attr("value", 0)
|
|
|
|
.prop("selected", true)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery.each(data, function(i, val) {
|
|
|
|
s = js_html_entity_decode(val["nombre"]);
|
|
|
|
//$('#module').append ($('<option></option>').html (s).attr ("value", val));
|
|
|
|
$("#module").append(
|
|
|
|
$("<option></option>")
|
|
|
|
.html(s)
|
|
|
|
.attr("value", val["id_agente_modulo"])
|
|
|
|
);
|
|
|
|
$("#module").fadeIn("normal");
|
|
|
|
});
|
|
|
|
if (selected != undefined) $("#module").attr("value", selected);
|
|
|
|
$("#module").removeAttr("disabled");
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
2010-05-18 12:03:06 +02:00
|
|
|
}
|
|
|
|
|
2015-02-09 19:34:36 +01:00
|
|
|
function post_process_select_init(name) {
|
2019-01-30 12:27:18 +01:00
|
|
|
// Manual mode is hidden by default
|
2017-09-14 12:10:41 +02:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#" + name + "_manual").hide();
|
|
|
|
$("#" + name + "_default").show();
|
2017-09-14 12:10:41 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function post_process_select_init_unit(name, selected) {
|
|
|
|
// Manual mode is hidden by default
|
|
|
|
|
|
|
|
$("#" + name + "_manual").hide();
|
|
|
|
$("#" + name + "_default").show();
|
|
|
|
|
|
|
|
if (selected != "") {
|
|
|
|
var select_or_text = false;
|
|
|
|
$("#" + name + "_select option").each(function(i, item) {
|
|
|
|
if ($(item).val() == selected) {
|
|
|
|
select_or_text = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (select_or_text) {
|
2020-01-15 16:00:33 +01:00
|
|
|
$("#" + name + "_select option[value='" + selected + "']").attr(
|
2019-01-30 12:27:18 +01:00
|
|
|
"selected",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$("#text-" + name + "_text").val("");
|
|
|
|
} else {
|
2020-12-04 12:32:38 +01:00
|
|
|
$("#" + name + "_select option[value=0]").attr("selected", true);
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#" + name + "_default").hide();
|
|
|
|
$("#" + name + "_manual").show();
|
|
|
|
}
|
|
|
|
} else {
|
2020-12-04 12:32:38 +01:00
|
|
|
$("#" + name + "_select option[value=0]").attr("selected", true);
|
|
|
|
$("#" + name + "_default").hide();
|
|
|
|
$("#" + name + "_manual").show();
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$("#" + name + "_select").change(function() {
|
|
|
|
var value = $("#" + name + "_select").val();
|
2020-01-15 16:00:33 +01:00
|
|
|
$("#" + name + "_select option[value='" + value + "']").attr(
|
2019-01-30 12:27:18 +01:00
|
|
|
"selected",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
});
|
2017-09-14 12:10:41 +02:00
|
|
|
}
|
2015-02-09 19:34:36 +01:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function post_process_select_events_unit(name, selected) {
|
|
|
|
$("." + name + "_toggler").click(function() {
|
|
|
|
var value = $("#text-" + name + "_text").val();
|
|
|
|
|
|
|
|
var count = $("#" + name + "_select option").filter(function(i, item) {
|
|
|
|
if ($(item).val() == value) return true;
|
|
|
|
else return false;
|
|
|
|
}).length;
|
|
|
|
|
|
|
|
if (count != 1) {
|
|
|
|
$("#" + name + "_select").append(
|
|
|
|
$("<option>")
|
|
|
|
.val(value)
|
|
|
|
.text(value)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#" + name + "_select option")
|
|
|
|
.filter(function(i, item) {
|
|
|
|
if ($(item).val() == value) return true;
|
|
|
|
else return false;
|
|
|
|
})
|
|
|
|
.prop("selected", true);
|
|
|
|
|
|
|
|
toggleBoth(name);
|
|
|
|
$("#text-" + name + "_text").focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
// When select a default period, is setted in seconds
|
|
|
|
$("#" + name + "_select").change(function() {
|
|
|
|
var value = $("#" + name + "_select").val();
|
|
|
|
|
|
|
|
$("." + name).val(value);
|
|
|
|
$("#text-" + name + "_text").val(value);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#text-" + name + "_text").keyup(function() {
|
|
|
|
var value = $("#text-" + name + "_text").val();
|
|
|
|
$("." + name).val(value);
|
|
|
|
});
|
|
|
|
}
|
2018-10-30 10:20:31 +01:00
|
|
|
|
2015-02-09 19:34:36 +01:00
|
|
|
function post_process_select_events(name) {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("." + name + "_toggler").click(function() {
|
|
|
|
var value = $("#text-" + name + "_text").val();
|
|
|
|
var count = $("#" + name + "_select option").filter(function(i, item) {
|
|
|
|
if (Number($(item).val()) == Number(value)) return true;
|
|
|
|
else return false;
|
|
|
|
}).length;
|
|
|
|
|
2020-10-29 18:20:33 +01:00
|
|
|
if (count < 1) {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#" + name + "_select").append(
|
|
|
|
$("<option>")
|
|
|
|
.val(value)
|
|
|
|
.text(value)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#" + name + "_select option")
|
|
|
|
.filter(function(i, item) {
|
|
|
|
if (Number($(item).val()) == Number(value)) return true;
|
|
|
|
else return false;
|
|
|
|
})
|
|
|
|
.prop("selected", true);
|
|
|
|
|
|
|
|
//~ $('#' + name + '_select').val(value);
|
|
|
|
|
|
|
|
toggleBoth(name);
|
|
|
|
$("#text-" + name + "_text").focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
// When select a default period, is setted in seconds
|
|
|
|
$("#" + name + "_select").change(function() {
|
|
|
|
var value = $("#" + name + "_select").val();
|
|
|
|
|
|
|
|
$("." + name).val(value);
|
|
|
|
$("#text-" + name + "_text").val(value);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#text-" + name + "_text").keyup(function() {
|
|
|
|
var value = $("#text-" + name + "_text").val();
|
|
|
|
|
|
|
|
if (isNaN(value)) {
|
|
|
|
value = 0;
|
|
|
|
$("#text-" + name + "_text").val(value);
|
|
|
|
} else {
|
|
|
|
$("." + name).val(value);
|
|
|
|
}
|
|
|
|
});
|
2015-02-09 19:34:36 +01:00
|
|
|
}
|
|
|
|
|
2012-03-15 17:03:51 +01:00
|
|
|
/**
|
2012-03-22 12:22:07 +01:00
|
|
|
* Init values for html_extended_select_for_time
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-22 12:22:07 +01:00
|
|
|
* This function initialize the values of the control
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-15 17:03:51 +01:00
|
|
|
* @param name string with the name of the select for time
|
2020-01-16 13:50:39 +01:00
|
|
|
* @param allow_zero bool Allow the use of the value zero
|
2012-03-15 17:03:51 +01:00
|
|
|
*/
|
2020-01-16 13:50:39 +01:00
|
|
|
function period_select_init(name, allow_zero) {
|
2019-01-30 12:27:18 +01:00
|
|
|
// Manual mode is hidden by default
|
2020-03-30 19:44:44 +02:00
|
|
|
$("#" + name + "_manual").css("display", "none");
|
2020-05-26 11:26:49 +02:00
|
|
|
$("#" + name + "_default").css("display", "inline");
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
// If the text input is empty, we put on it 5 minutes by default
|
|
|
|
if ($("#text-" + name + "_text").val() == "") {
|
|
|
|
$("#text-" + name + "_text").val(300);
|
|
|
|
// Set the value in the hidden field too
|
|
|
|
$("." + name).val(300);
|
|
|
|
if ($("#" + name + "_select option:eq(0)").val() == 0) {
|
|
|
|
$("#" + name + "_select option:eq(2)").prop("selected", true);
|
|
|
|
} else {
|
|
|
|
$("#" + name + "_select option:eq(1)").prop("selected", true);
|
|
|
|
}
|
2020-01-16 13:50:39 +01:00
|
|
|
} else if ($("#text-" + name + "_text").val() == 0 && allow_zero != true) {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#" + name + "_units option:last").prop("selected", false);
|
2020-05-26 11:26:49 +02:00
|
|
|
$("#" + name + "_manual").css("display", "inline");
|
2020-03-30 19:44:44 +02:00
|
|
|
$("#" + name + "_default").css("display", "none");
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
2012-03-22 12:22:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manage events into html_extended_select_for_time
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-22 12:22:07 +01:00
|
|
|
* This function has all the events to manage the extended select
|
|
|
|
* for time
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-22 12:22:07 +01:00
|
|
|
* @param name string with the name of the select for time
|
|
|
|
*/
|
|
|
|
function period_select_events(name) {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("." + name + "_toggler").click(function() {
|
|
|
|
toggleBoth(name);
|
|
|
|
$("#text-" + name + "_text").focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
adjustTextUnits(name);
|
|
|
|
|
|
|
|
// When select a default period, is setted in seconds
|
|
|
|
$("#" + name + "_select").change(function() {
|
|
|
|
var value = $("#" + name + "_select").val();
|
|
|
|
|
|
|
|
if (value == -1) {
|
|
|
|
value = 300;
|
|
|
|
toggleBoth(name);
|
|
|
|
$("#text-" + name + "_text").focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
$("." + name).val(value);
|
|
|
|
$("#text-" + name + "_text").val(value);
|
|
|
|
adjustTextUnits(name);
|
|
|
|
});
|
|
|
|
|
|
|
|
// When select a custom units, the default period changes to
|
|
|
|
// 'custom' and the time in seconds is calculated into hidden input
|
|
|
|
$("#" + name + "_units").change(function() {
|
|
|
|
selectFirst(name);
|
|
|
|
calculateSeconds(name);
|
|
|
|
});
|
|
|
|
|
|
|
|
// When write any character into custom input, it check to convert
|
|
|
|
// it to integer and calculate in seconds into hidden input
|
|
|
|
$("#text-" + name + "_text").keyup(function() {
|
|
|
|
var cleanValue = parseInt($("#text-" + name + "_text").val());
|
|
|
|
if (isNaN(cleanValue)) {
|
|
|
|
cleanValue = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#text-" + name + "_text").val(cleanValue);
|
|
|
|
|
|
|
|
selectFirst(name + "_select");
|
|
|
|
calculateSeconds(name);
|
|
|
|
});
|
2012-03-22 12:22:07 +01:00
|
|
|
}
|
|
|
|
|
2015-02-23 13:43:26 +01:00
|
|
|
function period_set_value(name, value) {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#text-" + name + "_text").val(value);
|
|
|
|
adjustTextUnits(name);
|
|
|
|
calculateSeconds(name);
|
|
|
|
selectFirst(name + "_select");
|
|
|
|
$("#" + name + "_manual").hide();
|
|
|
|
$("#" + name + "_default").show();
|
2015-02-23 13:43:26 +01:00
|
|
|
}
|
|
|
|
|
2012-04-10 13:28:36 +02:00
|
|
|
/**
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-04-10 13:28:36 +02:00
|
|
|
* Select first option of a select if is not value=0
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-04-10 13:28:36 +02:00
|
|
|
*/
|
|
|
|
function selectFirst(name) {
|
2019-01-30 12:27:18 +01:00
|
|
|
if ($("#" + name + " option:eq(0)").val() == 0) {
|
|
|
|
$("#" + name + " option:eq(1)").prop("selected", true);
|
|
|
|
} else {
|
|
|
|
$("#" + name + " option:eq(0)").prop("selected", true);
|
|
|
|
}
|
2012-04-10 13:28:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-04-10 13:28:36 +02:00
|
|
|
* Toggle default and manual controls of period control
|
|
|
|
* It is done with css function because hide and show do not
|
|
|
|
* work properly when the divs are into a hiden div
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-04-10 13:28:36 +02:00
|
|
|
*/
|
|
|
|
function toggleBoth(name) {
|
2019-01-30 12:27:18 +01:00
|
|
|
if ($("#" + name + "_default").css("display") == "none") {
|
|
|
|
$("#" + name + "_default").css("display", "inline");
|
|
|
|
} else {
|
|
|
|
$("#" + name + "_default").css("display", "none");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($("#" + name + "_manual").css("display") == "none") {
|
|
|
|
$("#" + name + "_manual").css("display", "inline");
|
|
|
|
} else {
|
|
|
|
$("#" + name + "_manual").css("display", "none");
|
|
|
|
}
|
2012-04-10 13:28:36 +02:00
|
|
|
}
|
|
|
|
|
2012-03-22 12:22:07 +01:00
|
|
|
/**
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-22 12:22:07 +01:00
|
|
|
* Calculate the custom time in seconds into hidden input
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-22 12:22:07 +01:00
|
|
|
*/
|
|
|
|
function calculateSeconds(name) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var calculated =
|
|
|
|
$("#text-" + name + "_text").val() * $("#" + name + "_units").val();
|
|
|
|
|
|
|
|
$("." + name).val(calculated);
|
2012-03-20 11:03:22 +01:00
|
|
|
}
|
|
|
|
|
2012-07-05 11:16:57 +02:00
|
|
|
/**
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-07-05 11:16:57 +02:00
|
|
|
* Update via Javascript an advance selec for time
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-07-05 11:16:57 +02:00
|
|
|
*/
|
|
|
|
function period_select_update(name, seconds) {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#text-" + name + "_text").val(seconds);
|
|
|
|
adjustTextUnits(name);
|
|
|
|
calculateSeconds(name);
|
|
|
|
$("#" + name + "_manual").show();
|
|
|
|
$("#" + name + "_default").hide();
|
2012-07-05 11:16:57 +02:00
|
|
|
}
|
|
|
|
|
2012-03-20 11:03:22 +01:00
|
|
|
/**
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-20 11:03:22 +01:00
|
|
|
* Adjust units in the advanced select for time
|
2019-01-30 12:27:18 +01:00
|
|
|
*
|
2012-03-20 11:03:22 +01:00
|
|
|
*/
|
|
|
|
function adjustTextUnits(name) {
|
2019-01-30 12:27:18 +01:00
|
|
|
var restPrev;
|
|
|
|
var unitsSelected = false;
|
|
|
|
$("#" + name + "_units option").each(function() {
|
|
|
|
if ($(this).val() < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var rest = $("#text-" + name + "_text").val() / $(this).val();
|
|
|
|
var restInt = parseInt(rest).toString();
|
|
|
|
|
|
|
|
if (rest != restInt && unitsSelected == false) {
|
|
|
|
$("#" + name + "_units option:eq(" + ($(this).index() - 1) + ")").prop(
|
|
|
|
"selected",
|
|
|
|
true
|
|
|
|
);
|
2022-04-25 10:33:33 +02:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#text-" + name + "_text").val(restPrev);
|
|
|
|
unitsSelected = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
restPrev = rest;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (unitsSelected == false) {
|
|
|
|
$("#" + name + "_units option:last").prop("selected", true);
|
|
|
|
$("#text-" + name + "_text").val(restPrev);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($("#text-" + name + "_text").val() == 0) {
|
|
|
|
selectFirst(name + "_units");
|
|
|
|
}
|
2013-02-22 14:48:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sidebar function
|
|
|
|
* params:
|
|
|
|
* menuW: $params['width']
|
|
|
|
* icon_width: $params['icon_width']
|
|
|
|
* position: $params['position']
|
|
|
|
* top_dist: $params['top']
|
|
|
|
* autotop: $params['autotop']
|
|
|
|
* icon_closed: $params['icon_closed']
|
|
|
|
* icon_open: $params['icon_open']
|
|
|
|
* homeurl: $config['homeurl']
|
|
|
|
*
|
2019-01-30 12:27:18 +01:00
|
|
|
**/
|
|
|
|
function hidded_sidebar(
|
|
|
|
position,
|
|
|
|
menuW,
|
|
|
|
menuH,
|
|
|
|
icon_width,
|
|
|
|
top_dist,
|
|
|
|
autotop,
|
|
|
|
right_dist,
|
|
|
|
autoright,
|
|
|
|
icon_closed,
|
|
|
|
icon_open,
|
|
|
|
homeurl,
|
|
|
|
vertical_mode
|
|
|
|
) {
|
|
|
|
var defSlideTime = 220;
|
|
|
|
var visibleMargin = icon_width + 10;
|
|
|
|
var hiddenMarginW = menuW - visibleMargin;
|
|
|
|
menuH = parseInt(menuH);
|
|
|
|
var hiddenMarginH = menuH - visibleMargin;
|
|
|
|
var windowWidth = $(window).width();
|
|
|
|
var sideClosed = 1;
|
|
|
|
|
|
|
|
if (top_dist == "auto_over") {
|
|
|
|
top_dist = $("#" + autotop).offset().top;
|
|
|
|
} else if (top_dist == "auto_below") {
|
|
|
|
top_dist = $("#" + autotop).offset().top + $("#" + autotop).height();
|
|
|
|
switch (position) {
|
|
|
|
case "bottom":
|
|
|
|
if (vertical_mode == "in") {
|
|
|
|
top_dist -= visibleMargin + 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (right_dist == "auto_right") {
|
|
|
|
right_dist = $("#" + autoright).offset().left + $("#" + autoright).width();
|
|
|
|
} else if (right_dist == "auto_left") {
|
|
|
|
right_dist = $("#" + autoright).offset().left;
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
// SET INITIAL POSITION AND SHOW LAYER
|
|
|
|
$("#side_layer").css("top", top_dist);
|
|
|
|
switch (position) {
|
|
|
|
case "left":
|
|
|
|
$("#side_layer").css("left", -hiddenMarginW);
|
|
|
|
break;
|
|
|
|
case "right":
|
|
|
|
$("#side_layer").css("left", windowWidth - visibleMargin - 1);
|
|
|
|
$("#side_layer").css("width", visibleMargin + "px");
|
|
|
|
break;
|
|
|
|
case "bottom":
|
|
|
|
$("#side_layer").css("left", right_dist - menuW);
|
|
|
|
$("#side_layer").css("height", visibleMargin + "px");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$("#side_layer").show();
|
|
|
|
|
|
|
|
$("#graph_menu_arrow").click(function() {
|
|
|
|
switch (position) {
|
|
|
|
case "right":
|
|
|
|
if (sideClosed == 0) {
|
|
|
|
$("#side_layer").animate(
|
|
|
|
{
|
|
|
|
width: "-=" + hiddenMarginW + "px",
|
|
|
|
left: "+=" + hiddenMarginW + "px"
|
|
|
|
},
|
|
|
|
defSlideTime
|
|
|
|
);
|
|
|
|
$("#graph_menu_arrow").attr("src", homeurl + icon_closed);
|
|
|
|
} else {
|
|
|
|
$("#side_layer").animate(
|
|
|
|
{
|
|
|
|
width: "+=" + hiddenMarginW + "px",
|
|
|
|
left: "-=" + hiddenMarginW + "px"
|
|
|
|
},
|
|
|
|
defSlideTime
|
|
|
|
);
|
|
|
|
$("#graph_menu_arrow").attr("src", homeurl + icon_open);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "left":
|
|
|
|
if (sideClosed == 1) {
|
|
|
|
$("#side_layer").animate(
|
|
|
|
{ left: "+=" + hiddenMarginW + "px" },
|
|
|
|
defSlideTime
|
|
|
|
);
|
|
|
|
|
|
|
|
$("#graph_menu_arrow").attr("src", homeurl + icon_closed);
|
|
|
|
} else {
|
|
|
|
$("#side_layer").animate(
|
|
|
|
{ left: "-=" + hiddenMarginW + "px" },
|
|
|
|
defSlideTime
|
|
|
|
);
|
|
|
|
$("#graph_menu_arrow").attr("src", homeurl + icon_open);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "bottom":
|
|
|
|
if (sideClosed == 0) {
|
|
|
|
$("#side_layer").animate(
|
|
|
|
{
|
|
|
|
height: "-=" + (hiddenMarginH + 10) + "px",
|
|
|
|
top: "+=" + hiddenMarginH + "px"
|
|
|
|
},
|
|
|
|
defSlideTime
|
|
|
|
);
|
|
|
|
$("#graph_menu_arrow").attr("src", homeurl + icon_closed);
|
|
|
|
} else {
|
|
|
|
$("#side_layer").animate(
|
|
|
|
{
|
|
|
|
height: "+=" + (hiddenMarginH - 10) + "px",
|
|
|
|
top: "-=" + hiddenMarginH + "px"
|
|
|
|
},
|
|
|
|
defSlideTime
|
|
|
|
);
|
|
|
|
$("#graph_menu_arrow").attr("src", homeurl + icon_open);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sideClosed == 0) {
|
|
|
|
//$('#side_top_text').hide();
|
|
|
|
//$('#side_body_text').hide();
|
|
|
|
//$('#side_bottom_text').hide();
|
|
|
|
sideClosed = 1;
|
|
|
|
} else {
|
|
|
|
$("#side_top_text").show();
|
|
|
|
$("#side_body_text").show();
|
|
|
|
$("#side_bottom_text").show();
|
|
|
|
sideClosed = 0;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
switch (position) {
|
|
|
|
case "right":
|
|
|
|
case "bottom":
|
|
|
|
// Move the right menu if window is resized
|
|
|
|
$(window).resize(function() {
|
|
|
|
var newWindowWidth = $(window).width();
|
|
|
|
var widthVariation = newWindowWidth - windowWidth;
|
|
|
|
$("#side_layer").animate({ left: "+=" + widthVariation + "px" }, 0);
|
|
|
|
|
|
|
|
windowWidth = newWindowWidth;
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
2013-02-22 14:48:10 +01:00
|
|
|
}
|
2013-04-29 10:59:03 +02:00
|
|
|
|
|
|
|
// Function that recover a previously stored value from php code
|
|
|
|
function get_php_value(value) {
|
2019-01-30 12:27:18 +01:00
|
|
|
return $.parseJSON($("#php_to_js_value_" + value).html());
|
2013-04-29 10:59:03 +02:00
|
|
|
}
|
2014-05-30 12:51:33 +02:00
|
|
|
|
|
|
|
function paint_qrcode(text, where, width, height) {
|
2019-01-30 12:27:18 +01:00
|
|
|
if (typeof text == "undefined") {
|
|
|
|
text = window.location.href;
|
|
|
|
} else {
|
|
|
|
//null value
|
|
|
|
if (isEmptyObject(text)) {
|
|
|
|
text = window.location.href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof where == "undefined") {
|
|
|
|
where = $("#qrcode_container_image").get(0);
|
|
|
|
} else if (typeof where == "string") {
|
|
|
|
where = $(where).get(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof where == "undefined") {
|
|
|
|
where = $("#qrcode_container_image").get(0);
|
|
|
|
} else if (typeof where == "string") {
|
|
|
|
where = $(where).get(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof width == "undefined") {
|
|
|
|
width = 256;
|
|
|
|
} else {
|
|
|
|
if (typeof width == "object")
|
|
|
|
if (isEmptyObject(width)) {
|
|
|
|
//null value
|
|
|
|
width = 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof height == "undefined") {
|
|
|
|
height = 256;
|
|
|
|
} else {
|
|
|
|
if (typeof height == "object")
|
|
|
|
if (isEmptyObject(height)) {
|
|
|
|
//null value
|
|
|
|
height = 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(where).empty();
|
|
|
|
|
|
|
|
var qrcode = new QRCode(where, {
|
|
|
|
text: text,
|
|
|
|
width: width,
|
|
|
|
height: height,
|
2019-05-27 14:12:53 +02:00
|
|
|
colorDark: "#343434",
|
2019-01-30 12:27:18 +01:00
|
|
|
colorLight: "#ffffff",
|
|
|
|
correctLevel: QRCode.CorrectLevel.M
|
|
|
|
});
|
2014-05-30 12:51:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_dialog_qrcode(dialog, text, where, width, height) {
|
2019-01-30 12:27:18 +01:00
|
|
|
if (typeof dialog == "undefined") {
|
|
|
|
dialog = "#qrcode_container";
|
|
|
|
} else {
|
|
|
|
if (typeof dialog == "object")
|
|
|
|
if (isEmptyObject(dialog)) {
|
|
|
|
//null value
|
|
|
|
dialog = "#qrcode_container";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof where == "undefined") {
|
|
|
|
where = $("#qrcode_container_image").get(0);
|
|
|
|
} else if (typeof where == "string") {
|
|
|
|
where = $(where).get(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof width == "undefined") {
|
|
|
|
width = 256;
|
|
|
|
} else {
|
|
|
|
if (typeof width == "object")
|
|
|
|
if (isEmptyObject(width)) {
|
|
|
|
//null value
|
|
|
|
width = 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof height == "undefined") {
|
|
|
|
height = 256;
|
|
|
|
} else {
|
|
|
|
if (typeof height == "object")
|
|
|
|
if (isEmptyObject(height)) {
|
|
|
|
//null value
|
|
|
|
height = 256;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
paint_qrcode(text, where, 256, 256);
|
|
|
|
|
|
|
|
$(dialog)
|
|
|
|
.dialog({ autoOpen: false, modal: true })
|
|
|
|
.dialog("open");
|
2014-10-20 13:11:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function openURLTagWindow(url) {
|
2019-01-30 12:27:18 +01:00
|
|
|
window.open(
|
|
|
|
url,
|
|
|
|
"",
|
|
|
|
"width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no"
|
|
|
|
);
|
2015-02-04 16:20:20 +01:00
|
|
|
}
|
|
|
|
|
2019-11-26 13:19:28 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Inicialize tinyMCE with customized parameters
|
|
|
|
*
|
|
|
|
* @param added_config Associative Array. Config to add adding default.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function defineTinyMCE(added_config) {
|
|
|
|
// Default values
|
|
|
|
var buttons1 =
|
|
|
|
"bold,italic,underline,|,link,image,|,cut,copy,paste,|,undo,redo,|,forecolor,fontselect,fontsizeselect,|,justifyleft,justifycenter,justifyright";
|
|
|
|
var elements = added_config["elements"];
|
|
|
|
var plugins = added_config["plugins"];
|
|
|
|
// Initialize with fixed parameters. Some parameters must be initialized too.
|
|
|
|
tinyMCE.init({
|
|
|
|
mode: "exact",
|
|
|
|
theme: "advanced",
|
|
|
|
elements: elements,
|
|
|
|
plugins: plugins,
|
|
|
|
theme_advanced_buttons1: buttons1,
|
|
|
|
theme_advanced_toolbar_location: "top",
|
|
|
|
theme_advanced_toolbar_align: "left",
|
2021-08-31 11:47:36 +02:00
|
|
|
theme_advanced_statusbar_location: "bottom",
|
|
|
|
theme_advanced_resizing: true,
|
2019-11-26 13:19:28 +01:00
|
|
|
convert_urls: false,
|
2021-08-31 11:47:36 +02:00
|
|
|
element_format: "html",
|
|
|
|
object_resizing: true,
|
|
|
|
autoresize_bottom_margin: 50,
|
2022-04-07 17:24:06 +02:00
|
|
|
autoresize_on_init: true,
|
|
|
|
extended_valid_elements: "img[*]"
|
2019-11-26 13:19:28 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!isEmptyObject(added_config)) {
|
|
|
|
// If use asterisk mask, you can add at end of buttons new buttons.
|
|
|
|
for (var key in added_config) {
|
|
|
|
switch (key) {
|
|
|
|
case "theme_advanced_buttons1*":
|
|
|
|
tinyMCE.settings.theme_advanced_buttons1 =
|
|
|
|
buttons1 + ",|," + added_config[key];
|
|
|
|
break;
|
|
|
|
case "theme_advanced_font_sizes":
|
|
|
|
tinyMCE.settings.theme_advanced_font_sizes =
|
|
|
|
"4pt=.visual_font_size_4pt, " +
|
|
|
|
"6pt=.visual_font_size_6pt, " +
|
|
|
|
"8pt=.visual_font_size_8pt, " +
|
|
|
|
"10pt=.visual_font_size_10pt, " +
|
|
|
|
"12pt=.visual_font_size_12pt, " +
|
|
|
|
"14pt=.visual_font_size_14pt, " +
|
|
|
|
"18pt=.visual_font_size_18pt, " +
|
|
|
|
"24pt=.visual_font_size_24pt, " +
|
|
|
|
"28pt=.visual_font_size_28pt, " +
|
|
|
|
"36pt=.visual_font_size_36pt, " +
|
|
|
|
"48pt=.visual_font_size_48pt, " +
|
|
|
|
"60pt=.visual_font_size_60pt, " +
|
|
|
|
"72pt=.visual_font_size_72pt, " +
|
|
|
|
"84pt=.visual_font_size_84pt, " +
|
|
|
|
"96pt=.visual_font_size_96pt, " +
|
|
|
|
"116pt=.visual_font_size_116pt, " +
|
|
|
|
"128pt=.visual_font_size_128pt, " +
|
|
|
|
"140pt=.visual_font_size_140pt, " +
|
|
|
|
"154pt=.visual_font_size_154pt, " +
|
|
|
|
"196pt=.visual_font_size_196pt";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tinyMCE.settings[key] = added_config[key];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 10:41:30 +02:00
|
|
|
function removeTinyMCE(elementID) {
|
2019-01-30 12:27:18 +01:00
|
|
|
if (elementID.length > 0 && !isEmptyObject(tinyMCE))
|
|
|
|
tinyMCE.EditorManager.execCommand("mceRemoveControl", true, elementID);
|
2015-02-04 16:20:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function addTinyMCE(elementID) {
|
2019-01-30 12:27:18 +01:00
|
|
|
if (elementID.length > 0 && !isEmptyObject(tinyMCE))
|
|
|
|
tinyMCE.EditorManager.execCommand("mceAddControl", true, elementID);
|
2021-08-31 11:47:36 +02:00
|
|
|
tinyMCE.EditorManager.execCommand("mceAutoResize");
|
|
|
|
tinymce.EditorManager.execCommand("mceTableSizingMode", false, "responsive");
|
2015-02-04 16:20:20 +01:00
|
|
|
}
|
2016-01-18 16:58:24 +01:00
|
|
|
|
|
|
|
function toggle_full_value(id) {
|
2019-01-30 12:27:18 +01:00
|
|
|
$("#hidden_value_module_" + id).dialog({
|
|
|
|
resizable: true,
|
|
|
|
draggable: true,
|
|
|
|
modal: true,
|
|
|
|
height: 200,
|
|
|
|
width: 400,
|
|
|
|
overlay: {
|
|
|
|
opacity: 0.5,
|
|
|
|
background: "black"
|
|
|
|
}
|
|
|
|
});
|
2016-05-24 16:33:32 +02:00
|
|
|
}
|
2016-09-15 13:33:42 +02:00
|
|
|
|
|
|
|
function autoclick_profile_users(actual_level, firts_level, second_level) {
|
2019-01-30 12:27:18 +01:00
|
|
|
if ($("#checkbox-" + actual_level).is(":checked")) {
|
|
|
|
if (typeof firts_level !== "undefined") {
|
|
|
|
var is_checked_firts = $("#checkbox-" + firts_level).is(":checked");
|
|
|
|
if (!is_checked_firts) {
|
|
|
|
$("#checkbox-" + firts_level).prop("checked", true);
|
|
|
|
}
|
|
|
|
if (second_level !== false) {
|
|
|
|
if (!$("#checkbox-" + second_level).is(":checked")) {
|
|
|
|
$("#checkbox-" + second_level).prop("checked", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-31 15:23:05 +02:00
|
|
|
}
|
2016-05-24 16:21:56 +02:00
|
|
|
/**
|
|
|
|
* Auto hides an element and shows it
|
|
|
|
* when the user moves the mouse over the body.
|
|
|
|
*
|
|
|
|
* @param element [Element object] Element object to hide.
|
|
|
|
* @param hideTime [integer] ms of the hide timeout.
|
|
|
|
*
|
|
|
|
* @retval void
|
|
|
|
*/
|
2019-01-30 12:27:18 +01:00
|
|
|
var autoHideElement = function(element, hideTime) {
|
|
|
|
hideTime = hideTime || 3000;
|
|
|
|
var timerRef;
|
|
|
|
var isHoverElement = false;
|
|
|
|
|
|
|
|
var showElement = function() {
|
|
|
|
$(element).show();
|
|
|
|
};
|
|
|
|
var hideElement = function() {
|
|
|
|
$(element).fadeOut();
|
|
|
|
};
|
|
|
|
var startHideTimeout = function(msec) {
|
|
|
|
showElement();
|
|
|
|
timerRef = setTimeout(hideElement, msec);
|
|
|
|
};
|
|
|
|
var cancelHideTimeout = function() {
|
|
|
|
clearTimeout(timerRef);
|
|
|
|
timerRef = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
var handleBodyMove = function(event) {
|
|
|
|
if (isHoverElement) return;
|
|
|
|
if (timerRef) cancelHideTimeout();
|
|
|
|
startHideTimeout(hideTime);
|
|
|
|
};
|
|
|
|
var handleElementEnter = function(event) {
|
|
|
|
isHoverElement = true;
|
|
|
|
cancelHideTimeout();
|
|
|
|
};
|
|
|
|
var handleElementLeave = function(event) {
|
|
|
|
isHoverElement = false;
|
|
|
|
startHideTimeout(hideTime);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Bind event handlers
|
|
|
|
$(element)
|
|
|
|
.mouseenter(handleElementEnter)
|
|
|
|
.mouseleave(handleElementLeave);
|
|
|
|
$("body").mousemove(handleBodyMove);
|
|
|
|
|
|
|
|
// Start hide
|
|
|
|
startHideTimeout(hideTime);
|
|
|
|
};
|
2017-06-05 12:50:22 +02:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function htmlEncode(value) {
|
2017-06-05 12:50:22 +02:00
|
|
|
// Create a in-memory div, set its inner text (which jQuery automatically encodes)
|
|
|
|
// Then grab the encoded contents back out. The div never exists on the page.
|
2019-01-30 12:27:18 +01:00
|
|
|
return $("<div/>")
|
|
|
|
.text(value)
|
|
|
|
.html();
|
2017-06-05 12:50:22 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function htmlDecode(value) {
|
|
|
|
return $("<div/>")
|
|
|
|
.html(value)
|
|
|
|
.text();
|
2017-08-30 16:09:11 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function pagination_show_more(params, message) {
|
|
|
|
//value input hidden for save limit
|
|
|
|
var value_offset = $("#hidden-offset").val();
|
|
|
|
//For each execution offset + limit
|
|
|
|
var offset = parseInt(value_offset) + params["limit"];
|
|
|
|
//save new value innput hidden
|
|
|
|
$("#hidden-offset").val(offset);
|
|
|
|
//add array value offset
|
|
|
|
params["offset"] = offset;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "ajax.php",
|
|
|
|
data: params,
|
|
|
|
success: function(data) {
|
|
|
|
if (data == "") {
|
|
|
|
$("#container_error").empty();
|
|
|
|
$("#container_error").append("<h4>" + message + "</h4>");
|
|
|
|
} else {
|
|
|
|
$("#container_pag").append(data);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
datatype: "html"
|
|
|
|
});
|
2017-10-23 14:05:21 +02:00
|
|
|
}
|
2018-07-17 11:26:25 +02:00
|
|
|
|
2017-10-23 14:05:21 +02:00
|
|
|
/*
|
2019-01-30 12:27:18 +01:00
|
|
|
*function use d3.js for paint graph
|
|
|
|
*/
|
|
|
|
function paint_graph_status(
|
|
|
|
min_w,
|
|
|
|
max_w,
|
|
|
|
min_c,
|
|
|
|
max_c,
|
|
|
|
inverse_w,
|
|
|
|
inverse_c,
|
|
|
|
error_w,
|
|
|
|
error_c,
|
|
|
|
legend_normal,
|
|
|
|
legend_warning,
|
|
|
|
legend_critical,
|
|
|
|
message_error_warning,
|
|
|
|
message_error_critical
|
|
|
|
) {
|
|
|
|
//Check if they are numbers
|
|
|
|
if (isNaN(min_w)) {
|
|
|
|
min_w = 0;
|
|
|
|
}
|
|
|
|
if (isNaN(max_w)) {
|
|
|
|
max_w = 0;
|
|
|
|
}
|
|
|
|
if (isNaN(min_c)) {
|
|
|
|
min_c = 0;
|
|
|
|
}
|
|
|
|
if (isNaN(max_c)) {
|
|
|
|
max_c = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//if haven't errors
|
|
|
|
if (error_w == 0 && error_c == 0) {
|
|
|
|
//parse element
|
|
|
|
min_w = parseFloat(min_w);
|
|
|
|
min_c = parseFloat(min_c);
|
|
|
|
max_w = parseFloat(max_w);
|
|
|
|
max_c = parseFloat(max_c);
|
|
|
|
|
|
|
|
//inicialize var
|
|
|
|
var range_min = 0;
|
|
|
|
var range_max = 0;
|
|
|
|
var range_max_min = 0;
|
|
|
|
var range_max_min = 0;
|
|
|
|
|
|
|
|
//Find the lowest possible value
|
|
|
|
if (min_w < 0 || min_c < 0) {
|
|
|
|
if (min_w < min_c) {
|
|
|
|
range_min = min_w - 100;
|
|
|
|
} else {
|
|
|
|
range_min = min_c - 100;
|
|
|
|
}
|
|
|
|
} else if (min_w > 0 || min_c > 0) {
|
|
|
|
if (min_w > min_c) {
|
|
|
|
range_max_min = min_w;
|
|
|
|
} else {
|
|
|
|
range_max_min = min_c;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (min_w < min_c) {
|
|
|
|
range_min = min_w - 100;
|
|
|
|
} else {
|
|
|
|
range_min = min_c - 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Find the maximum possible value
|
|
|
|
if (max_w > max_c) {
|
|
|
|
range_max = max_w + 100 + range_max_min;
|
|
|
|
} else {
|
|
|
|
range_max = max_c + 100 + range_max_min;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Controls whether the maximum = 0 is infinite
|
|
|
|
if ((max_w == 0 || max_w == 0.0) && min_w != 0) {
|
|
|
|
max_w = range_max;
|
|
|
|
}
|
|
|
|
if ((max_c == 0 || max_c == 0.0) && min_c != 0) {
|
|
|
|
max_c = range_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Scale according to the position
|
|
|
|
position = 200 / (range_max - range_min);
|
|
|
|
|
|
|
|
//axes
|
|
|
|
var yScale = d3.scale
|
|
|
|
.linear()
|
|
|
|
.domain([range_min, range_max])
|
|
|
|
.range([100, -100]);
|
|
|
|
|
|
|
|
var yAxis = d3.svg
|
|
|
|
.axis()
|
|
|
|
.scale(yScale)
|
|
|
|
.orient("left");
|
|
|
|
|
|
|
|
//create svg
|
|
|
|
var svg = d3.select("#svg_dinamic");
|
|
|
|
//delete elements
|
|
|
|
svg.selectAll("g").remove();
|
|
|
|
|
2020-02-07 14:01:59 +01:00
|
|
|
var width_x = 101;
|
|
|
|
var height_x = 50;
|
2020-02-11 10:10:03 +01:00
|
|
|
var legend_width_x = 135;
|
2020-02-07 14:01:59 +01:00
|
|
|
var legend_height_x = 80;
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.attr("transform", "translate(100, 150)")
|
2021-04-05 11:41:36 +02:00
|
|
|
.attr("class", "invert_filter")
|
2019-01-30 12:27:18 +01:00
|
|
|
.call(yAxis);
|
|
|
|
|
|
|
|
//legend Normal text
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.attr("width", 300)
|
|
|
|
.attr("height", 300)
|
|
|
|
.append("text")
|
2020-02-07 13:59:50 +01:00
|
|
|
.attr("x", legend_width_x + 15)
|
|
|
|
.attr("y", legend_height_x - 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("fill", "black")
|
|
|
|
.style("font-weight", "bold")
|
|
|
|
.style("font-size", "8pt")
|
2021-04-05 11:41:36 +02:00
|
|
|
.attr("class", "invert_filter")
|
2019-01-30 12:27:18 +01:00
|
|
|
.html(legend_normal)
|
|
|
|
.style("text-anchor", "first")
|
|
|
|
.attr("width", 300)
|
|
|
|
.attr("height", 300);
|
|
|
|
|
|
|
|
//legend Normal rect
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.attr("id", "legend_normal")
|
2020-02-07 13:59:50 +01:00
|
|
|
.attr("x", legend_width_x)
|
|
|
|
.attr("y", legend_height_x - 30)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("width", 10)
|
|
|
|
.attr("height", 10)
|
|
|
|
.style("fill", "#82B92E");
|
|
|
|
|
|
|
|
//legend Warning text
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("text")
|
2020-02-07 13:59:50 +01:00
|
|
|
.attr("x", legend_width_x + 15)
|
|
|
|
.attr("y", legend_height_x + 5)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("fill", "black")
|
|
|
|
.style("font-weight", "bold")
|
|
|
|
.style("font-size", "8pt")
|
2021-04-05 11:41:36 +02:00
|
|
|
.attr("class", "invert_filter")
|
2019-01-30 12:27:18 +01:00
|
|
|
.html(legend_warning)
|
|
|
|
.style("text-anchor", "first");
|
|
|
|
|
|
|
|
//legend Warning rect
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.attr("id", "legend_warning")
|
2020-02-07 13:59:50 +01:00
|
|
|
.attr("x", legend_width_x)
|
|
|
|
.attr("y", legend_height_x - 5)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("width", 10)
|
|
|
|
.attr("height", 10)
|
|
|
|
.style("fill", "#ffd731");
|
|
|
|
|
|
|
|
//legend Critical text
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("text")
|
2020-02-07 13:59:50 +01:00
|
|
|
.attr("x", legend_width_x + 15)
|
|
|
|
.attr("y", legend_height_x + 30)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("fill", "black")
|
|
|
|
.style("font-weight", "bold")
|
|
|
|
.style("font-size", "8pt")
|
2021-04-05 11:41:36 +02:00
|
|
|
.attr("class", "invert_filter")
|
2019-01-30 12:27:18 +01:00
|
|
|
.html(legend_critical)
|
|
|
|
.style("text-anchor", "first");
|
|
|
|
|
|
|
|
//legend critical rect
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.attr("id", "legend_critical")
|
2020-02-07 13:59:50 +01:00
|
|
|
.attr("x", legend_width_x)
|
|
|
|
.attr("y", legend_height_x + 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("width", 10)
|
|
|
|
.attr("height", 10)
|
2019-06-04 14:08:07 +02:00
|
|
|
.style("fill", "#e63c52");
|
2019-01-30 12:27:18 +01:00
|
|
|
|
|
|
|
//styles for number and axes
|
|
|
|
svg
|
|
|
|
.selectAll("g .domain")
|
|
|
|
.style("stroke-width", 2)
|
|
|
|
.style("fill", "none")
|
|
|
|
.style("stroke", "black");
|
|
|
|
|
|
|
|
svg
|
|
|
|
.selectAll("g .tick text")
|
|
|
|
.style("font-size", "9pt")
|
|
|
|
.style("font-weight", "initial");
|
|
|
|
|
|
|
|
//estatus normal
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.attr("id", "status_rect")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr("y", height_x)
|
2020-02-11 10:10:03 +01:00
|
|
|
.attr("width", 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("height", 200)
|
|
|
|
.style("fill", "#82B92E");
|
|
|
|
|
|
|
|
//controls the inverse warning
|
|
|
|
if (inverse_w == 0) {
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.transition()
|
|
|
|
.duration(600)
|
|
|
|
.attr("id", "warning_rect")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr(
|
|
|
|
"y",
|
|
|
|
height_x + (range_max - min_w) * position - (max_w - min_w) * position
|
|
|
|
)
|
2020-02-11 10:10:03 +01:00
|
|
|
.attr("width", 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("height", (max_w - min_w) * position)
|
|
|
|
.style("fill", "#ffd731");
|
|
|
|
} else {
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.transition()
|
|
|
|
.duration(600)
|
|
|
|
.attr("id", "warning_rect")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr("y", height_x + 200 - (min_w - range_min) * position)
|
2020-02-11 10:10:03 +01:00
|
|
|
.attr("width", 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("height", (min_w - range_min) * position)
|
|
|
|
.style("fill", "#ffd731");
|
|
|
|
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.transition()
|
|
|
|
.duration(600)
|
|
|
|
.attr("id", "warning_inverse_rect")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr("y", height_x)
|
2020-02-11 10:10:03 +01:00
|
|
|
.attr("width", 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr(
|
|
|
|
"height",
|
|
|
|
(range_max - min_w) * position - (max_w - min_w) * position
|
|
|
|
)
|
|
|
|
.style("fill", "#ffd731");
|
|
|
|
}
|
|
|
|
//controls the inverse critical
|
|
|
|
if (inverse_c == 0) {
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.transition()
|
|
|
|
.duration(600)
|
|
|
|
.attr("id", "critical_rect")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr(
|
|
|
|
"y",
|
|
|
|
height_x + (range_max - min_c) * position - (max_c - min_c) * position
|
|
|
|
)
|
2020-02-11 10:10:03 +01:00
|
|
|
.attr("width", 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("height", (max_c - min_c) * position)
|
2019-06-04 14:08:07 +02:00
|
|
|
.style("fill", "#e63c52");
|
2019-01-30 12:27:18 +01:00
|
|
|
} else {
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.transition()
|
|
|
|
.duration(600)
|
|
|
|
.attr("id", "critical_rect")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr("y", height_x + 200 - (min_c - range_min) * position)
|
2020-02-11 10:10:03 +01:00
|
|
|
.attr("width", 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr("height", (min_c - range_min) * position)
|
2019-06-04 14:08:07 +02:00
|
|
|
.style("fill", "#e63c52");
|
2019-01-30 12:27:18 +01:00
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("rect")
|
|
|
|
.transition()
|
|
|
|
.duration(600)
|
|
|
|
.attr("id", "critical_inverse_rect")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr("y", height_x)
|
2020-02-11 10:10:03 +01:00
|
|
|
.attr("width", 20)
|
2019-01-30 12:27:18 +01:00
|
|
|
.attr(
|
|
|
|
"height",
|
|
|
|
(range_max - min_c) * position - (max_c - min_c) * position
|
|
|
|
)
|
2019-06-04 14:08:07 +02:00
|
|
|
.style("fill", "#e63c52");
|
2019-01-30 12:27:18 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
d3.select("#svg_dinamic rect").remove();
|
|
|
|
//create svg
|
|
|
|
var svg = d3.select("#svg_dinamic");
|
|
|
|
svg.selectAll("g").remove();
|
|
|
|
|
|
|
|
width_x = 10;
|
|
|
|
height_x = 50;
|
|
|
|
|
|
|
|
//message error warning
|
|
|
|
if (error_w == 1) {
|
|
|
|
$("#text-max_warning").addClass("input_error");
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("text")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr("y", height_x)
|
|
|
|
.attr("fill", "black")
|
|
|
|
.style("font-weight", "bold")
|
|
|
|
.style("font-size", 14)
|
|
|
|
.style("fill", "red")
|
|
|
|
.html(message_error_warning)
|
|
|
|
.style("text-anchor", "first");
|
|
|
|
}
|
|
|
|
//message error critical
|
|
|
|
if (error_c == 1) {
|
|
|
|
$("#text-max_critical").addClass("input_error");
|
|
|
|
svg
|
|
|
|
.append("g")
|
|
|
|
.append("text")
|
|
|
|
.attr("x", width_x)
|
|
|
|
.attr("y", height_x)
|
|
|
|
.attr("fill", "black")
|
|
|
|
.style("font-weight", "bold")
|
|
|
|
.style("font-size", 14)
|
|
|
|
.style("fill", "red")
|
|
|
|
.html(message_error_critical)
|
|
|
|
.style("text-anchor", "first");
|
|
|
|
}
|
|
|
|
}
|
2018-04-17 11:54:52 +02:00
|
|
|
}
|
|
|
|
|
2018-06-06 11:18:39 +02:00
|
|
|
function round_with_decimals(value, multiplier) {
|
2019-01-30 12:27:18 +01:00
|
|
|
// Default values
|
|
|
|
if (typeof multiplier === "undefined") multiplier = 1;
|
2018-06-06 11:18:39 +02:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
// Return non numeric types without modification
|
2019-12-13 09:06:54 +01:00
|
|
|
if (typeof value !== "number" || isNaN(value)) {
|
2019-04-17 12:29:38 +02:00
|
|
|
return value;
|
|
|
|
}
|
2018-04-19 19:17:04 +02:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
if (value * multiplier == 0) return 0;
|
|
|
|
if (Math.abs(value) * multiplier >= 1) {
|
|
|
|
return Math.round(value * multiplier) / multiplier;
|
|
|
|
}
|
|
|
|
return round_with_decimals(value, multiplier * 10);
|
2018-05-10 11:46:49 +02:00
|
|
|
}
|
|
|
|
|
2018-04-25 12:32:58 +02:00
|
|
|
/**
|
|
|
|
* Display a confirm dialog box
|
|
|
|
*
|
|
|
|
* @param string Text to display
|
|
|
|
* @param string Ok button text
|
|
|
|
* @param string Cancel button text
|
|
|
|
* @param function Callback to action when ok button is pressed
|
2019-01-30 12:27:18 +01:00
|
|
|
*/
|
|
|
|
function display_confirm_dialog(message, ok_text, cancel_text, ok_function) {
|
|
|
|
// Clean function to close the dialog
|
|
|
|
var clean_function = function() {
|
|
|
|
$("#pandora_confirm_dialog_text").hide();
|
|
|
|
$("#pandora_confirm_dialog_text").remove();
|
|
|
|
};
|
|
|
|
|
|
|
|
// Modify the ok function to close the dialog too
|
|
|
|
var ok_function_clean = function() {
|
|
|
|
ok_function();
|
|
|
|
clean_function();
|
|
|
|
};
|
|
|
|
|
|
|
|
var buttons_obj = {};
|
|
|
|
buttons_obj[cancel_text] = clean_function;
|
|
|
|
buttons_obj[ok_text] = ok_function_clean;
|
|
|
|
|
|
|
|
// Display the dialog
|
|
|
|
$("body").append(
|
|
|
|
'<div id="pandora_confirm_dialog_text"><h3>' + message + "</h3></div>"
|
|
|
|
);
|
|
|
|
$("#pandora_confirm_dialog_text").dialog({
|
|
|
|
resizable: false,
|
|
|
|
draggable: true,
|
|
|
|
modal: true,
|
|
|
|
dialogClass: "pandora_confirm_dialog",
|
|
|
|
overlay: {
|
|
|
|
opacity: 0.5,
|
|
|
|
background: "black"
|
|
|
|
},
|
|
|
|
closeOnEscape: true,
|
|
|
|
modal: true,
|
|
|
|
buttons: buttons_obj
|
|
|
|
});
|
2018-05-10 12:41:28 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
function ellipsize(str, max, ellipse) {
|
|
|
|
if (max == null) max = 140;
|
|
|
|
if (ellipse == null) ellipse = "…";
|
2018-05-10 11:46:49 +02:00
|
|
|
|
2019-01-30 12:27:18 +01:00
|
|
|
return str.trim().length > max ? str.substr(0, max).trim() + ellipse : str;
|
2018-05-10 11:46:49 +02:00
|
|
|
}
|
2018-05-24 12:50:24 +02:00
|
|
|
|
2019-11-21 18:21:46 +01:00
|
|
|
function uniqId() {
|
|
|
|
var randomStr =
|
|
|
|
Math.random()
|
|
|
|
.toString(36)
|
|
|
|
.substring(2, 15) +
|
|
|
|
Math.random()
|
|
|
|
.toString(36)
|
|
|
|
.substring(2, 15);
|
|
|
|
|
|
|
|
return randomStr;
|
|
|
|
}
|
|
|
|
|
2019-10-17 15:17:28 +02:00
|
|
|
/**
|
|
|
|
* Function for AJAX request.
|
|
|
|
*
|
|
|
|
* @param {string} id Id container append data.
|
|
|
|
* @param {json} settings Json with settings.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
function ajaxRequest(id, settings) {
|
|
|
|
$.ajax({
|
|
|
|
type: settings.type,
|
|
|
|
dataType: settings.html,
|
|
|
|
url: settings.url,
|
|
|
|
data: settings.data,
|
|
|
|
success: function(data) {
|
|
|
|
$("#" + id).append(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-03-25 16:50:24 +01:00
|
|
|
|
|
|
|
function progressBarSvg(option) {
|
|
|
|
var svgNS = "http://www.w3.org/2000/svg";
|
|
|
|
// SVG container.
|
|
|
|
var svg = document.createElementNS(svgNS, "svg");
|
|
|
|
|
|
|
|
var backgroundRect = document.createElementNS(svgNS, "rect");
|
|
|
|
backgroundRect.setAttribute("fill", option.color);
|
|
|
|
backgroundRect.setAttribute("fill-opacity", "0.5");
|
|
|
|
backgroundRect.setAttribute("width", "100%");
|
|
|
|
backgroundRect.setAttribute("height", "100%");
|
|
|
|
backgroundRect.setAttribute("rx", "5");
|
|
|
|
backgroundRect.setAttribute("ry", "5");
|
|
|
|
var progressRect = document.createElementNS(svgNS, "rect");
|
|
|
|
progressRect.setAttribute("fill", option.colorfill);
|
|
|
|
progressRect.setAttribute("fill-opacity", "1");
|
|
|
|
progressRect.setAttribute("width", option.start + "%");
|
|
|
|
progressRect.setAttribute("height", "100%");
|
|
|
|
progressRect.setAttribute("rx", "5");
|
|
|
|
progressRect.setAttribute("ry", "5");
|
|
|
|
var text = document.createElementNS(svgNS, "text");
|
|
|
|
text.setAttribute("text-anchor", "middle");
|
|
|
|
text.setAttribute("alignment-baseline", "middle");
|
|
|
|
text.setAttribute("font-size", "15");
|
|
|
|
text.setAttribute("font-family", "arial");
|
|
|
|
text.setAttribute("font-weight", "bold");
|
|
|
|
text.setAttribute("transform", `translate(10, 17.5)`);
|
|
|
|
text.setAttribute("fill", "green");
|
|
|
|
|
|
|
|
//if (this.props.valueType === "value") {
|
|
|
|
// text.style.fontSize = "6pt";
|
|
|
|
//
|
|
|
|
// text.textContent = this.props.unit
|
|
|
|
// ? `${formatValue} ${this.props.unit}`
|
|
|
|
// : `${formatValue}`;
|
|
|
|
//} else {
|
|
|
|
// text.textContent = `${progress}%`;
|
|
|
|
//}
|
|
|
|
|
|
|
|
svg.setAttribute("width", "100%");
|
|
|
|
svg.setAttribute("height", "100%");
|
|
|
|
svg.append(backgroundRect, progressRect, text);
|
|
|
|
|
|
|
|
return svg;
|
|
|
|
}
|
2022-03-10 20:06:45 +01:00
|
|
|
|
|
|
|
function inArray(needle, haystack) {
|
|
|
|
var length = haystack.length;
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
if (haystack[i] == needle) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|