This commit is contained in:
marcos.alconada 2019-06-13 17:27:49 +02:00
parent 47ce0f97ef
commit 2fe0d22d7d
1 changed files with 88 additions and 9 deletions

View File

@ -1,3 +1,5 @@
/* globals $ */
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
@ -31,6 +33,8 @@ var SIZE_GRID = 16; //Const the size (for width and height) of grid.
var img_handler_start;
var img_handler_end;
var default_cache_expiration = null;
function toggle_advance_options_palette(close) {
if ($("#advance_options").css("display") == "none") {
$("#advance_options").css("display", "");
@ -679,12 +683,17 @@ function update_button_palette_callback() {
return false;
}
}
if (values["module"] == 0) {
var radio_value = $("input[name='radio_choice']:checked").val();
if (values["agent"] == "" && radio_value == "module_graph") {
dialog_message("#message_alert_no_agent");
return false;
}
if (values["module"] == 0 && radio_value == "module_graph") {
dialog_message("#message_alert_no_module");
return false;
}
if (values["agent"] == "") {
dialog_message("#message_alert_no_agent");
if (values["id_custom_graph"] == 0 && radio_value == "custom_graph") {
dialog_message("#message_alert_no_custom_graph");
return false;
}
if ($("input[name=width_module_graph]").val() == "") {
@ -1095,10 +1104,11 @@ function readFields() {
var text = tinymce.get("text-label").getContent();
values["label"] = text;
if ($("input[name=percentile_label]").val().length > 0) {
values["percentile_label_color"] = $(
"input[name=percentile_label_color]"
).val();
if ($("input[name=percentile_label]").val().length > 0) {
values["label"] =
"<span style='color:" +
values["percentile_label_color"] +
@ -1182,6 +1192,10 @@ function readFields() {
values["timezone"] = $("select[name=timezone]").val();
values["clock_animation"] = $("select[name=clock_animation]").val();
values["show_last_value"] = $("select[name=last_value]").val();
values["cache_expiration"] =
typeof $("#hidden-cache_expiration").val() !== "undefined"
? $("#hidden-cache_expiration").val()
: $("#cache_expiration").val();
// Color Cloud values
if (selectedItem == "color_cloud" || creationItem == "color_cloud") {
@ -1225,7 +1239,6 @@ function readFields() {
function create_button_palette_callback() {
var values = readFields();
//VALIDATE DATA
var validate = true;
switch (creationItem) {
@ -1436,11 +1449,12 @@ function create_button_palette_callback() {
break;
case "module_graph":
if (values["module"] == 0) {
var radio_value = $("input[name='radio_choice']:checked").val();
if (values["module"] == 0 && radio_value == "module_graph") {
dialog_message("#message_alert_no_module");
validate = false;
}
if (values["id_custom_graph"] == 0) {
if (values["id_custom_graph"] == 0 && radio_value == "module_graph") {
if (values["agent"] == "") {
dialog_message("#message_alert_no_agent");
validate = false;
@ -1450,6 +1464,10 @@ function create_button_palette_callback() {
validate = false;
}
}
if (values["id_custom_graph"] == 0 && radio_value == "custom_graph") {
dialog_message("#message_alert_no_custom_graph");
validate = false;
}
if (
values["height_module_graph"] == "" ||
values["height_module_graph"] == 0
@ -2220,6 +2238,26 @@ function loadFieldsFromDB(item) {
});
}
if (key == "cache_expiration") {
var intoCacheExpSelect = false;
var cacheExpId = $("#hidden-cache_expiration").attr("class");
$("#" + cacheExpId + "_select option").each(function() {
if ($(this).val() == val) {
$(this).prop("selected", true);
$(this).trigger("change");
intoCacheExpSelect = true;
}
});
if (intoCacheExpSelect == false) {
$("#" + cacheExpId + "_select").val(0);
$("#" + cacheExpId + "_units").val(1);
$("#hidden-cache_expiration").val(val);
$("#text-" + cacheExpId + "_text").val(val);
$("#" + cacheExpId + "_default").hide();
$("#" + cacheExpId + "_manual").show();
}
}
if (key == "value_show") {
$("select[name=value_show]").val(val);
}
@ -2596,6 +2634,9 @@ function hiddenFields(item) {
$("#line_case").css("display", "none");
$("#line_case." + item).css("display", "");
$("#cache_expiration_row").css("display", "none");
$("#cache_expiration_row." + item).css("display", "");
// Color cloud rows
$("#color_cloud_diameter_row").hide();
$("#color_cloud_diameter_row." + item).show();
@ -2669,6 +2710,44 @@ function cleanFields(item) {
$("table.color-range-creation input[type=color]").val("#FFFFFF");
$("table.color-range:not(table.color-range-creation)").remove();
// Clean the cache expiration selection.
if (default_cache_expiration === null) {
var cacheExpVal = $("#hidden-cache_expiration").val();
if (!Number.isNaN(Number.parseInt(cacheExpVal))) {
cacheExpVal = Number.parseInt(cacheExpVal);
} else {
cacheExpVal = 0;
}
default_cache_expiration = cacheExpVal;
}
var cacheExpId = $("#hidden-cache_expiration").attr("class");
$("#hidden-cache_expiration").val(default_cache_expiration);
var intoCacheExpSelect = false;
$("#" + cacheExpId + "_select option").each(function() {
if ($(this).val() == default_cache_expiration) {
$(this).prop("selected", true);
$(this).trigger("change");
intoCacheExpSelect = true;
}
});
if (!intoCacheExpSelect) {
// Show input.
$("#" + cacheExpId + "_select").val(0);
$("#" + cacheExpId + "_units").val(1);
$("#text-" + cacheExpId + "_text").val(default_cache_expiration);
$("#" + cacheExpId + "_default").hide();
$("#" + cacheExpId + "_manual").show();
} else {
// Show select.
$("#" + cacheExpId + "_select").val(default_cache_expiration);
$("#" + cacheExpId + "_units").val(0);
$("#text-" + cacheExpId + "_text").val("");
$("#" + cacheExpId + "_default").show();
$("#" + cacheExpId + "_manual").hide();
}
$("#preview").empty();
if (item == "simple_value") {