2010-03-23 Miguel de Dios <miguel.dedios@artica.es>

* include/javascript/jquery.ui.resizable.js: add library of jQuery.ui for
	resizable elements.
	
	* include/functions_visual_map.php
	
	*include/ajax, include/ajax/visual_console_builder.ajax.php: add the
	file for ajax request from visual console builder editor.
	
	* include/config_process.php: change $build_version.
	
	* include/functions.php: in function "safe_url_extraclean" fix to pages
	with '.' character.
	
	* godmode/reporting/visual_console_builder.php,
	godmode/reporting/visual_console_builder.editor.php,
	godmode/reporting/visual_console_builder.data.php,
	godmode/reporting/visual_console_builder.editor.js,
	godmode/reporting/visual_console_builder.elements.php: worked about the
	new visual console builder editor, now it is developing, don't afray.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2521 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-03-23 17:46:08 +00:00
parent 7932ff9239
commit 2a6b2c553e
11 changed files with 1361 additions and 576 deletions

View File

@ -1,3 +1,25 @@
2010-03-23 Miguel de Dios <miguel.dedios@artica.es>
* include/javascript/jquery.ui.resizable.js: add library of jQuery.ui for
resizable elements.
* include/functions_visual_map.php
*include/ajax, include/ajax/visual_console_builder.ajax.php: add the
file for ajax request from visual console builder editor.
* include/config_process.php: change $build_version.
* include/functions.php: in function "safe_url_extraclean" fix to pages
with '.' character.
* godmode/reporting/visual_console_builder.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/visual_console_builder.data.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php: worked about the
new visual console builder editor, now it is developing, don't afray.
2010-03-21 Sancho Lerena <slerena@gmail.com>
* include/help/en/check_other_languages.sh: Moved from include/help

View File

@ -0,0 +1,71 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Login check
global $config;
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
require_once ('include/functions_visual_map.php');
switch ($action) {
case 'new':
echo "<form method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "'>";
print_input_hidden('action', 'save');
break;
case 'update':
case 'save':
echo "<form method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
print_input_hidden('action', 'update');
break;
case 'edit':
echo "<form method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
print_input_hidden('action', 'update');
break;
}
$table->width = '70%';
$table->data = array ();
$table->data[0][0] = __('Name:');
$table->data[0][1] = print_input_text ('name', $visualConsoleName, '', 15, 50, true);
$table->data[1][0] = __('Group:');
$groups = get_user_groups ($config['id_user']);
$table->data[1][1] = print_select ($groups, 'id_group', $idGroup, '', '', '', true);
$table->data[2][0] = '';
$backgrounds_list = list_files ('images/console/background/', "jpg", 1, 0);
$backgrounds_list = array_merge ($backgrounds_list, list_files ('images/console/background/', "png", 1, 0));
$table->data[3][0] = __('Background');
$table->data[3][1] = print_select ($backgrounds_list, 'background', $background, '', 'None', '', true);
if ($action == 'new') {
$textButtonSubmit = __('Save');
$classButtonSubmit = 'sub wand';
}
else {
$textButtonSubmit = __('Update');
$classButtonSubmit = 'sub upd';
}
$table->rowstyle[4] = "text-align: right;";
$table->data[4][0] = '';
$table->data[4][1] = print_submit_button ($textButtonSubmit, 'update_layout', false, 'class="' . $classButtonSubmit . '"', true);
print_table($table);
echo "</form>";
?>

View File

@ -0,0 +1,569 @@
var creationItem = null;
var openPropertiesPanel = false;
var idItem = 0;
var selectedItem = null;
function showAdvanceOptions(close) {
if ($("#advance_options").css('display') == 'none') {
$("#advance_options").css('display', 'inline');
}
else {
$("#advance_options").css('display', 'none');
}
if (close == false) {
$("#advance_options").css('display', 'none');
}
}
// Main function, execute in event documentReady
function editorMain2() {
$("#background").resizable();
eventsBackground();
eventsButtonsToolbox();
eventsItems();
}
function updateAction() {
var values = {};
values = readFields();
// TODO VALIDATE DATA
updateDB(selectedItem, idElement , values);
switch (selectedItem) {
case 'background':
$("#background").css('width', values['width']);
$("#background").css('height', values['height']);
$("#background").css('background', 'url(images/console/background/' + values['background'] + ')');
var idElement = 0;
break;
case 'static_graph':
$("#text_" + idItem).html(values['label']);
$("#image_" + idItem).attr('src', getImageElement(idItem));
break;
}
actionClick();
}
function readFields() {
var values = {};
values['label'] = $("input[name=label]").val();
values['image'] = $("select[name=image]").val();
values['left'] = $("input[name=left]").val();
values['top'] = $("input[name=top]").val();
values['agent'] = $("input[name=agent]").val();
values['module'] = $("select[name=module]").val();
values['background'] = $("#background_image").val();
values['period'] = $("select[name=period]").val();
values['width'] = $("input[name=width]").val();
values['height'] = $("input[name=height]").val();
values['parent'] = $("select[name=parent]").val();
values['map_linked'] = $("select[name=map_linked]").val();
values['label_color'] = $("input[name=label_color]").val();
return values;
}
function createAction() {
var values = readFields();
// TODO VALIDATE DATA
insertDB(creationItem, values);
actionClick();
}
function actionClick() {
var item = null;
if (openPropertiesPanel) {
activeToolboxButton('static_graph', true);
activeToolboxButton('percentile_bar', true);
activeToolboxButton('module_graph', true);
activeToolboxButton('simple_value', true);
activeToolboxButton('delete_item', true);
$(".item").draggable("enable");
$("#background").resizable('enable');
$("#properties_panel").hide("fast");
showAdvanceOptions(false);
openPropertiesPanel = false
return;
}
openPropertiesPanel = true;
$(".item").draggable("disable");
$("#background").resizable('disable');
activeToolboxButton('static_graph', false);
activeToolboxButton('percentile_bar', false);
activeToolboxButton('module_graph', false);
activeToolboxButton('simple_value', false);
activeToolboxButton('delete_item', false);
if (creationItem != null) {
activeToolboxButton(creationItem, true);
item = creationItem;
$("#button_update_div").css('display', 'none');
$("#button_create_div").css('display', 'block');
cleanFields();
unselectAll();
}
else if (selectedItem != null) {
item = selectedItem;
$("#button_create_div").css('display', 'none');
$("#button_update_div").css('display', 'block');
cleanFields();
console.log(item);
loadFieldsFromDB(item);
}
hiddenFields(item);
$("#properties_panel").show("fast");
}
function loadFieldsFromDB(item) {
parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "load"});
parameter.push ({name: "id_visual_console", value: id_visual_console});
parameter.push ({name: "type", value: item});
parameter.push ({name: "id_element", value: idItem});
jQuery.ajax({
async: false,
url: "ajax.php",
data: parameter,
type: "POST",
dataType: 'json',
success: function (data)
{
jQuery.each(data, function(key, val) {
if (key == 'background') $("#background_image").val(val);
if (key == 'width') $("input[name=width]").val(val);
if (key == 'height') $("input[name=height]").val(val);
if (key == 'label') $("input[name=label]").val(val);
if (key == 'image') {
$("select[name=image]").val(val);
showPreviewStaticGraph(val);
}
if (key == 'pos_x') $("input[name=left]").val(val);
if (key == 'pos_y') $("input[name=top]").val(val);
if (key == 'agent') {
$("input[name=agent]").val(val);
//Reload no-sincrone the select of modules
}
if (key == 'module') $("select[name=module]").val(val);
if (key == 'period') $("select[name=period]").val(val);
if (key == 'width') $("input[name=width]").val(val);
if (key == 'height') $("input[name=height]").val(val);
if (key == 'parent') $("select[name=parent]").val(val);
if (key == 'map_linked') $("select[name=map_linked]").val(val);
if (key == 'label_color') $("input[name=label_color]").val(val);
});
}
});
}
function hiddenFields(item) {
$(".tittle_panel_span").css('display', 'none');
$("#tittle_panel_span_" + item).css('display', 'inline');
$("#label_div").css('display', 'none');
$("#label_div." + item).css('display', 'block');
$("#image_div").css('display', 'none');
$("#image_div." + item).css('display', 'block');
$("#position_div").css('display', 'none');
$("#position_div." + item).css('display', 'block');
$("#agent_div").css('display', 'none');
$("#agent_div." + item).css('display', 'block');
$("#module_div").css('display', 'none');
$("#module_div." + item).css('display', 'block');
$("#background_div").css('display', 'none');
$("#background_div." + item).css('display', 'block');
$("#period_div").css('display', 'none');
$("#period_div." + item).css('display', 'block');
$("#parent_div").css('display', 'none');
$("#parent_div." + item).css('display', 'block');
$("#map_linked_div").css('display', 'none');
$("#map_linked_div." + item).css('display', 'block');
$("#label_color_div").css('display', 'none');
$("#label_color_div." + item).css('display', 'block');
}
function cleanFields() {
$("input[name=label]").val('');
$("select[name=image]").val('');
$("input[name=left]").val(0);
$("input[name=top]").val(0);
$("input[name=agent]").val('');
$("select[name=module]").val('');
$("select[name=background_image]").val('');
$("select[name=period]").val('');
$("input[name=width]").val(0);
$("input[name=height]").val(0);
$("select[name=parent]").val('');
$("select[name=map_linked]").val('');
$("input[name=label_color]").val('#000000');
$("#preview").empty();
}
function getImageElement(id_data) {
var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_image"});
parameter.push ({name: "id_element", value: id_data});
var img = null;
jQuery.ajax({
async: false,
url: "ajax.php",
data: parameter,
type: "POST",
dataType: 'json',
success: function (data)
{
img = data['image'];
}
});
console.log(img);
return img;
}
function createItem(type, values, id_data) {
if ((values['width'] == 0) && (values['height'] == 0)) {
var sizeStyle = '';
}
else {
var sizeStyle = 'width: ' + values['width'] + 'px; height: ' + values['height'] + 'px;';
}
switch (type) {
case 'static_graph':
var item = $('<div id="' + id_data + '" class="item static_graph" style="color: ' + values['label_color'] + '; text-align: center; position: absolute; ' + sizeStyle + ' margin-top: ' + values['top'] + 'px; margin-left: ' + values['left'] + 'px;">' +
'<img id="image_' + id_data + '" class="image" src="' + getImageElement(id_data) + '" /><br />' +
'<span id="text_' + id_data + '" class="text">' + values['label'] + '</span>' +
'</div>'
);
break;
}
$("#background").append(item);
}
function insertDB(type, values) {
parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "insert"});
parameter.push ({name: "id_visual_console", value: id_visual_console});
parameter.push ({name: "type", value: type});
jQuery.each(values, function(key, val) {
parameter.push ({name: key, value: val});
});
jQuery.ajax({
url: "ajax.php",
async: false,
data: parameter,
type: "POST",
dataType: 'json',
success: function (data)
{
if (data['correct']) {
createItem(type, values, data['id_data']);
eventsItems();
}
else {
//TODO
}
}
});
}
function updateDB(type, idElement , values) {
parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "update"});
parameter.push ({name: "id_visual_console", value: id_visual_console});
parameter.push ({name: "type", value: type});
parameter.push ({name: "id_element", value: idElement});
jQuery.each(values, function(key, val) {
parameter.push ({name: key, value: val});
});
jQuery.ajax({
url: "ajax.php",
data: parameter,
type: "POST",
dataType: 'text',
success: function (data)
{
// TODO
}
});
}
function deleteDB(idElement) {
parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "delete"});
parameter.push ({name: "id_visual_console", value: id_visual_console});
parameter.push ({name: "id_element", value: idElement});
jQuery.ajax({
url: "ajax.php",
async: false,
data: parameter,
type: "POST",
dataType: 'json',
success: function (data)
{
if (data['correct']) {
$('#' + idElement).remove();
activeToolboxButton('delete_item', false);
}
else {
//TODO
}
}
});
}
function activeToolboxButton(id, active) {
if (active) {
$("#" + id).attr('class', 'button_toolbox');
$(".label", $("#" + id)).css('color','#000000');
}
else {
$("#" + id).attr('class', 'button_toolbox disabled');
$(".label", $("#" + id)).css('color','#aaaaaa');
}
}
function deleteItem() {
deleteDB(idItem);
}
function eventsItems() {
$('.item').unbind('click');
$('.item').unbind('dragstop');
$('.item').unbind('dragstart');
$(".item").draggable('destroy');
$('.item').bind('click', function(event, ui) {
event.stopPropagation();
if (!openPropertiesPanel) {
divParent = $(event.target).parent();
unselectAll()
$(divParent).css('border', '2px blue dotted');
if ($(divParent).hasClass('static_graph')) {
creationItem = null;
selectedItem = 'static_graph';
idItem = $(divParent).attr('id');
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
}
});
$(".item").draggable();
$('.item').bind('dragstart', function(event, ui) {
event.stopPropagation();
if (!openPropertiesPanel) {
divParent = $(event.target).parent();
unselectAll()
$(divParent).css('border', '2px blue dotted');
if ($(divParent).hasClass('static_graph')) {
creationItem = null;
selectedItem = 'static_graph';
idItem = $(divParent).attr('id');
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
}
});
$('.item').bind('dragstop', function(event, ui) {
event.stopPropagation();
var values = {};
values['left'] = ui.position.left;
values['top'] = ui.position.top;
updateDB(selectedItem, idItem, values);
});
}
function eventsBackground() {
$('#background').bind('resizestart', function(event, ui) {
if (!openPropertiesPanel) {
$("#background").css('border', '2px red solid');
}
});
$('#background').bind('resizestop', function(event, ui) {
if (!openPropertiesPanel) {
unselectAll();
var values = {};
values['width'] = $('#background').css('width').replace('px', '');
values['height'] = $('#background').css('height').replace('px', '');
updateDB('background', 0, values);
}
});
// Event click for background
$("#background").click(function(event) {
event.stopPropagation();
if (!openPropertiesPanel) {
unselectAll();
$("#background").css('border', '2px blue dotted');
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', false);
idItem = 0;
creationItem = null;
selectedItem = 'background';
}
});
}
function unselectAll() {
$("#background").css('border', '2px black solid');
$(".item").css('border', '');
}
function eventsButtonsToolbox() {
$('.button_toolbox').mouseover(function(event) {
event.stopPropagation();
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
if ($("#" + id).hasClass('disabled') == false) {
$("#" + id).css('background', '#f5f5f5');
}
});
$('.button_toolbox').mouseout(function(event) {
event.stopPropagation();
id = $(event.target).attr('id');
if ($("#" + id).hasClass('disabled') == false) {
$("#" + id).css('background', '#e5e5e5');
}
});
$('.button_toolbox').mousedown(function(event) {
event.stopPropagation();
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
if ($("#" + id).hasClass('disabled') == false) {
$("#" + id).css('border', '4px inset black');
}
});
$('.button_toolbox').mouseup(function(event) {
event.stopPropagation();
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
$("#" + id).css('border', '4px outset black');
});
$('.button_toolbox').click(function(event) {
event.stopPropagation();
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
if ($("#" + id).hasClass('disabled') == false) {
switch (id) {
case 'edit_item':
actionClick();
break;
case 'static_graph':
creationItem = 'static_graph';
actionClick();
break;
case 'percentile_bar':
break;
case 'module_graph':
break;
case 'simple_value':
break;
case 'save_visual_console':
break;
case 'edit_item':
break;
case 'delete_item':
deleteItem();
break;
}
}
});
}
function showPreviewStaticGraph(staticGraph) {
$("#preview").empty();
if (staticGraph != '') {
imgBase = "images/console/icons/" + staticGraph;
$("#preview").append("<img src='" + imgBase + "_bad.png' />");
$("#preview").append("<img src='" + imgBase + "_ok.png' />");
$("#preview").append("<img src='" + imgBase + "_warning.png' />");
$("#preview").append("<img src='" + imgBase + ".png' />");
}
}

View File

@ -0,0 +1,266 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Login check
global $config;
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
require_once ('include/functions_visual_map.php');
//Arrays for select box.
$backgrounds_list = list_files('images/console/background/', "jpg", 1, 0);
$backgrounds_list = array_merge($backgrounds_list, list_files ('images/console/background/', "png", 1, 0));
$images_list = array ();
$all_images = list_files ('images/console/icons/', "png", 1, 0);
foreach ($all_images as $image_file) {
if (strpos ($image_file, "_bad"))
continue;
if (strpos ($image_file, "_ok"))
continue;
if (strpos ($image_file, "_warning"))
continue;
$image_file = substr ($image_file, 0, strlen ($image_file) - 4);
$images_list[$image_file] = $image_file;
}
debugPrint($_POST);
echo '<div id="editor">';
echo '<div id="toolbox">';
printButtonEditorVisualConsole('static_graph', __('Static Graph'));
printButtonEditorVisualConsole('percentile_bar', __('Percentile Bar'));
printButtonEditorVisualConsole('module_graph', __('Module Graph'));
printButtonEditorVisualConsole('simple_value', __('Simple Value'));
printButtonEditorVisualConsole('edit_item', __('Edit item'), 'right', true);
printButtonEditorVisualConsole('delete_item', __('Delete item'), 'right', true);
echo '</div>';
echo '</div>';
echo '<div style="clear:both;"></div>';
echo "<form id='form_visual_map' method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
print_input_hidden('action', 'update');
$background = $visualConsole['background'];
$widthBackground = $visualConsole['width'];
$heightBackground = $visualConsole['height'];
if (($widthBackground == 0) && ($heightBackground == 0)) {
$backgroundSizes = getimagesize('images/console/background/' . $background);
$widthBackground = $backgroundSizes[0];
$heightBackground = $backgroundSizes[1];
}
$layoutDatas = get_db_all_rows_field_filter ('tlayout_data', 'id_layout', $idVisualConsole);
if ($layoutDatas === false)
$layoutDatas = array();
/* Layout_data editor form */
$intervals = array ();
$intervals[3600] = "1 ".__('hour');
$intervals[7200] = "2 ".__('hours');
$intervals[10800] = "3 ".__('hours');
$intervals[21600] = "6 ".__('hours');
$intervals[43200] = "12 ".__('hours');
$intervals[86400] = __('Last day');
$intervals[172800] = "2 ". __('days');
$intervals[1209600] = __('Last week');
$intervals[2419200] = "15 ".__('days');
$intervals[4838400] = __('Last month');
$intervals[9676800] = "2 ".__('months');
$intervals[29030400] = "6 ".__('months');
echo '<div id="properties_panel" style="display: none; position: absolute; border: 2px solid #114105; padding: 5px; background: white; z-index: 1;">';
//----------------------------Hiden Form----------------------------------------
echo '<div id="hidden_panel_properties"">';
echo '<div id="basic_options" style="width: 300px">';
echo '<span id="tittle_panel_span_background" class="tittle_panel_span" style="display: none; font-weight: bolder;">' . __('Background') . '</span><br /><br />';
echo '<span id="tittle_panel_span_static_graph" class="tittle_panel_span" style="display: none; font-weight: bolder;">' . __('Static Graph') . '</span><br /><br />';
echo '<div id="label_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Label') . ':';
print_input_text ('label', '', '', 20, 200);
echo '</div>';
echo '<div id="image_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Image') . ':';
print_select ($images_list, 'image', '', 'showPreviewStaticGraph(this.value);', 'None', '');
echo '<div id="preview"></div>';
echo '</div>';
echo '<div id="position_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Position') . ':';
echo '(';
print_input_text('left', '0', '', 3, 5);
echo ' , ';
print_input_text('top', '0', '', 3, 5);
echo ')';
echo '<br />';
echo '</div>';
echo '<div id="agent_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Agent') . '<a href="#" class="tip">&nbsp;<span>' . __("Type at least two characters to search") . '</span></a>' . ':';
print_input_text_extended ('agent', '', 'text-agent', '', 25, 100, false, '',
array('style' => 'background: #ffffff url(images/lightning.png) no-repeat right;'), false);
echo '<br />';
echo '</div>';
echo '<div id="module_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Module') . ':';
print_select (array (), 'module', '', '', __('Any'), 0);
echo '<br />';
echo '</div>';
echo '<div id="background_div" class="background" style="display: block; margin-bottom: 5px;">';
echo __('Background') . ':';
print_select($backgrounds_list, 'background_image', $background, '', 'None', '');
echo '</div>';
echo '<div id="button_update_div" style="text-align: right; margin-top: 20px;">';
print_button(__('Update'), 'update_button', false, 'updateAction();', 'class="sub"');
echo '</div>';
echo '<div id="button_create_div" style="text-align: right; margin-top: 20px;">';
print_button(__('Create'), 'create_button', false, 'createAction();', 'class="create sub"');
echo '</div>';
echo '</div>';
echo '<div id="line" style="width: 300px; border-bottom: 1px solid black; text-align: right; margin-top: 20px;">';
echo '<a href="javascript: showAdvanceOptions()">' . __('Advance options') . '</a>';
echo '</div>';
echo '<div id="advance_options" style="width: 300px; display: none;">';
echo '<div style="margin-top: 20px;"></div>';
echo '<div id="period_div" class="" style="display: block; margin-bottom: 5px;">';
echo __('Period') . ':';
print_select ($intervals, 'period', '', '', '--', 0);
echo '</div>';
echo '<div id="size_div" class="background static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Size') . ':';
print_input_text('width', 0, '', 3, 5);
echo ' X ';
print_input_text('height', 0, '', 3, 5);
echo '<br />';
echo '</div>';
echo '<div id="parent_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Parent') . ':';
print_select (array (), 'parent', '', '', __('None'), 0);
echo '<br />';
echo '</div>';
echo '<div id="map_linked_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Map linked') . ':';
print_select_from_sql ('SELECT id, name FROM tlayout WHERE id != ' . $idVisualConsole,
'map_linked', '', '', 'None', '');
echo '</div>';
echo '<div id="label_color_div" class="static_graph" style="display: block; margin-bottom: 5px;">';
echo __('Label color') . ':';
print_input_text_extended ('label_color', '#000000', 'text-'.'label_color',
'', 7, 7, false, '', 'class="label_color"', false);
echo '</div>';
echo '</div>';
echo "</div>";
//------------------------------------------------------------------------------
echo '</div>';
echo '<div id="frame_view" style="width: 100%; height: 500px; overflow: scroll;">';
echo '<div id="background" class="ui-widget-content" style="background: url(images/console/background/' . $background . ');
border: 2px black solid; width: ' . $widthBackground . 'px; height: ' . $heightBackground . 'px;">';
foreach ($layoutDatas as $layoutData) {
printItemInVisualConsole($layoutData);
}
echo '</div>';
echo '</div>';
print_input_hidden('background_width', $widthBackground);
print_input_hidden('background_height', $heightBackground);
echo "</form>";
require_css_file ('color-picker');
require_jquery_file ('ui.core');
require_jquery_file ('ui.resizable');
require_jquery_file ('colorpicker');
require_jquery_file ('ui.draggable');
require_javascript_file('visual_console_builder.editor', 'godmode/reporting/');
function printButtonEditorVisualConsole($idDiv, $label, $float = 'left', $disabled = false) {
if (!$disabled) $disableClass = '';
else $disableClass = 'disabled';
if ($float == 'left') {
$margin = 'margin-right';
}
else {
$margin = 'margin-left';
}
echo '<div class="button_toolbox ' . $disableClass . '" id="' . $idDiv . '"
style="font-weight: bolder; text-align: center; float: ' . $float . ';' .
'width: 80px; height: 50px; background: #e5e5e5; border: 4px outset black; ' . $margin . ': 5px;">';
if ($disabled) {
echo '<span class="label" style="color: #aaaaaa;">';
}
else {
echo '<span class="label" style="color: #000000;">';
}
echo $label;
echo '</span>';
echo '</div>';
}
function printItemInVisualConsole($layoutData) {
$width = $layoutData['width'];
$height = $layoutData['height'];
$top = $layoutData['pos_y'];
$left = $layoutData['pos_x'];
$id = $layoutData['id'];
$color = $layoutData['label_color'];
$label = $layoutData['label'];
$img = getImageStatusElement($layoutData);
$imgSizes = getimagesize($img);
//debugPrint($imgSizes);
if (($width == 0) && ($height == 0)) {
$sizeStyle = '';
}
else {
$sizeStyle = 'width: ' . $width . 'px; height: ' . $height . 'px;';
}
echo '<div id="' . $id . '" class="item static_graph" style="text-align: center; color: ' . $color . '; position: absolute; ' . $sizeStyle . ' margin-top: ' . $top . 'px; margin-left: ' . $left . 'px;">';
echo '<img class="image" id="image_' . $id . '" src="' . $img . '" /><br />';
echo '<span id="text_' . $id . '" class="text">' . $label . '</span>';
echo "</div>";
}
?>
<script type="text/javascript">
id_visual_console = <?php echo $visualConsole['id']; ?>;
$(document).ready (editorMain2);
</script>

View File

@ -0,0 +1,173 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Login check
global $config;
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
require_once ('include/functions_visual_map.php');
//Arrays for select box.
$backgrounds_list = list_files('images/console/background/', "jpg", 1, 0);
$backgrounds_list = array_merge($backgrounds_list, list_files ('images/console/background/', "png", 1, 0));
$images_list = array ();
$all_images = list_files ('images/console/icons/', "png", 1, 0);
foreach ($all_images as $image_file) {
if (strpos ($image_file, "_bad"))
continue;
if (strpos ($image_file, "_ok"))
continue;
if (strpos ($image_file, "_warning"))
continue;
$image_file = substr ($image_file, 0, strlen ($image_file) - 4);
$images_list[$image_file] = $image_file;
}
/* Layout_data editor form */
$intervals = array ();
$intervals[3600] = "1 ".__('hour');
$intervals[7200] = "2 ".__('hours');
$intervals[10800] = "3 ".__('hours');
$intervals[21600] = "6 ".__('hours');
$intervals[43200] = "12 ".__('hours');
$intervals[86400] = __('Last day');
$intervals[172800] = "2 ". __('days');
$intervals[1209600] = __('Last week');
$intervals[2419200] = "15 ".__('days');
$intervals[4838400] = __('Last month');
$intervals[9676800] = "2 ".__('months');
$intervals[29030400] = "6 ".__('months');
$table->width = '100%';
$table->head = array ();
$table->head[0] = __('Label') . ' / ' . __('Type') . ' / ' . __('Parent');
$table->head[1] = __('Image') . ' / ' . __('Agent') . ' / ' . __('Map linked');
$table->head[2] = __('Height') . ' / ' . __('Module') . ' / ' . __('Label color');
$table->head[3] = __('Width') . ' / ' . __('Period');
$table->head[4] = __('Left');
$table->head[5] = __('Top');
$table->head[6] = __('Action');
$table->data = array();
//Background
$table->data[0][0] = __('Background');
$table->data[0][1] = print_select($backgrounds_list, 'background', $visualConsole['background'], '', 'None', '', true);
$table->data[0][2] = print_input_text('width', $visualConsole['width'], '', 3, 5, true);
$table->data[0][3] = print_input_text('height', $visualConsole['height'], '', 3, 5, true);
$table->data[0][4] = '';
$table->data[0][5] = '';
$table->data[0][6] = '';
$table->data[1][0] = __('Background');
$table->data[1][1] = '';
$table->data[1][2] = '';
$table->data[1][3] = '';
$table->data[1][4] = '';
$table->data[1][5] = '';
$table->data[1][6] = '';
$table->data[2][0] = '';
$table->data[2][1] = '';
$table->data[2][2] = '';
$table->data[2][3] = '';
$table->data[2][4] = '';
$table->data[2][5] = '';
$table->data[2][6] = '';
$i = 2;
$layoutDatas = get_db_all_rows_field_filter ('tlayout_data', 'id_layout', $idVisualConsole);
if ($layoutDatas === false)
$layoutDatas = array();
$alternativeStyle = true;
foreach ($layoutDatas as $layoutData) {
$idLayoutData = $layoutData['id'];
$table->data[$i][0] = print_input_text ('label_' . $idLayoutData, $layoutData['label'], '', 20, 200, true);
if ($layoutData['type'] == 0) {
$table->data[$i][1] = print_select ($images_list, 'image', $layoutData['image'], '', 'None', '', true);
}
else {
$table->data[$i][1] = '';
}
$table->data[$i][2] = print_input_text('width_' . $idLayoutData, $layoutData['width'], '', 3, 5, true);
$table->data[$i][3] = print_input_text('height_' . $idLayoutData, $layoutData['height'], '', 3, 5, true);
$table->data[$i][4] = print_input_text('left_' . $idLayoutData, $layoutData['pos_x'], '', 3, 5, true);
$table->data[$i][5] = print_input_text('top_' . $idLayoutData, $layoutData['pos_y'], '', 3, 5, true);
$table->data[$i][6] = '<a href=""><img src="images/cross.png" /></a>';
$table->data[$i + 1][0] = print_select (get_layout_data_types(), 'type_' . $idLayoutData, $layoutData['type'], '', '', 0, true, false, false);
$table->data[$i + 1][1] = print_input_text_extended ('agent_' . $idLayoutData, get_agent_name($layoutData['id_agent']), 'text-agent', '', 25, 100, false, '',
array('style' => 'background: #ffffff url(images/lightning.png) no-repeat right;'), true);
$table->data[$i + 1][2] = print_select_from_sql('SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE id_agente = ' . $layoutData['id_agent'],
'module_' . $idLayoutData, $layoutData['id_agente_modulo'], '', '---', 0, true);
$table->data[$i + 1][3] = print_select ($intervals, 'period_' . $idLayoutData, $layoutData['period'], '', '--', 0, true);
$table->data[$i + 1][4] = '';
$table->data[$i + 1][5] = '';
$table->data[$i + 1][6] = '';
$table->data[$i + 2][0] = print_select_from_sql ('SELECT id, label FROM tlayout_data WHERE id_layout = '. $idVisualConsole,
'parent_' . $idLayoutData, $layoutData['parent_item'], '', 'None', '', true);
$table->data[$i + 2][1] = print_select_from_sql ('SELECT id, name FROM tlayout WHERE id != ' . $idVisualConsole,
'map_linked_' . $idLayoutData, $layoutData['id_layout_linked'], '', 'None', '', true);
//$table->data[$i + 2][2] = print_input_text ('label_color_' . $idLayoutData, '#000000', $layoutData['label_color'], 7, 7, true);
$table->data[$i + 2][2] = print_input_text_extended ('label_color_' . $idLayoutData, $layoutData['label_color'], 'text-'.'label_color_' . $idLayoutData
, '', 7, 7, false, '', 'class="label_color"', true);
$table->data[$i + 2][3] = '';
$table->data[$i + 2][4] = '';
$table->data[$i + 2][5] = '';
$table->data[$i + 2][6] = '';
if ($alternativeStyle) {
$table->rowclass[$i] = 'rowOdd';
$table->rowclass[$i + 1] = 'rowOdd';
$table->rowclass[$i + 2] = 'rowOdd';
}
else {
$table->rowclass[$i] = 'rowPair';
$table->rowclass[$i + 1] = 'rowPair';
$table->rowclass[$i + 2] = 'rowPair';
}
$alternativeStyle = !$alternativeStyle;
//$table->data[5][1] = print_input_text_extended ('agent', '', 'text-agent', '', 30, 100, false, '',
$i = $i + 3;
}
print_table($table);
require_css_file ('color-picker');
require_jquery_file ('ui.core');
require_jquery_file ('ui.draggable');
require_jquery_file ('ui.droppable');
require_jquery_file ('colorpicker');
require_jquery_file ('pandora.controls');
require_javascript_file ('wz_jsgraphics');
require_javascript_file ('pandora_visual_console');
require_jquery_file('ajaxqueue');
require_jquery_file('bgiframe');
require_jquery_file('autocomplete');
?>
<script type="text/javascript">
$(document).ready (function () {
$(".label_color").attachColorPicker();
});
</script>

View File

@ -90,6 +90,23 @@ switch ($activeTab) {
case 'editor':
switch ($action) {
case 'edit':
$visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole));
$visualConsoleName = $visualConsole['name'];
break;
case 'update':
$values = array('background' => get_parameter('background_image'),
'height' => get_parameter('height_background'),
'width' => get_parameter('width_background'));
$result = process_sql_update('tlayout', $values, array('id' => $idVisualConsole));
if ($result !== false) {
$action = 'edit';
$statusProcessInDB = array('flag' => true, 'message' => '<h3 class="suc">'.__('Successfully update.').'</h3>');
}
else {
$statusProcessInDB = array('flag' => false, 'message' => '<h3 class="error">'.__('Could not be update.').'</h3>');
}
$visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole));
$visualConsoleName = $visualConsole['name'];
break;
@ -122,567 +139,13 @@ if ($statusProcessInDB !== null) {
switch ($activeTab) {
case 'data':
switch ($action) {
case 'new':
echo "<form method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "'>";
print_input_hidden('action', 'save');
break;
case 'update':
case 'save':
echo "<form method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
print_input_hidden('action', 'update');
break;
case 'edit':
echo "<form method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
print_input_hidden('action', 'update');
break;
}
$table->width = '70%';
$table->data = array ();
$table->data[0][0] = __('Name:');
$table->data[0][1] = print_input_text ('name', $visualConsoleName, '', 15, 50, true);
$table->data[1][0] = __('Group:');
$groups = get_user_groups ($config['id_user']);
$table->data[1][1] = print_select ($groups, 'id_group', $idGroup, '', '', '', true);
$table->data[2][0] = '';
$backgrounds_list = list_files ('images/console/background/', "jpg", 1, 0);
$backgrounds_list = array_merge ($backgrounds_list, list_files ('images/console/background/', "png", 1, 0));
$table->data[3][0] = __('Background');
$table->data[3][1] = print_select ($backgrounds_list, 'background', $background, '', 'None', '', true);
if ($action == 'new') {
$textButtonSubmit = __('Save');
$classButtonSubmit = 'sub wand';
}
else {
$textButtonSubmit = __('Update');
$classButtonSubmit = 'sub upd';
}
$table->rowstyle[4] = "text-align: right;";
$table->data[4][0] = '';
$table->data[4][1] = print_submit_button ($textButtonSubmit, 'update_layout', false, 'class="' . $classButtonSubmit . '"', true);
print_table($table);
echo "</form>";
require_once('godmode/reporting/visual_console_builder.data.php');
break;
case 'list_elements':
//Arrays for select box.
$backgrounds_list = list_files('images/console/background/', "jpg", 1, 0);
$backgrounds_list = array_merge($backgrounds_list, list_files ('images/console/background/', "png", 1, 0));
$images_list = array ();
$all_images = list_files ('images/console/icons/', "png", 1, 0);
foreach ($all_images as $image_file) {
if (strpos ($image_file, "_bad"))
continue;
if (strpos ($image_file, "_ok"))
continue;
if (strpos ($image_file, "_warning"))
continue;
$image_file = substr ($image_file, 0, strlen ($image_file) - 4);
$images_list[$image_file] = $image_file;
}
/* Layout_data editor form */
$intervals = array ();
$intervals[3600] = "1 ".__('hour');
$intervals[7200] = "2 ".__('hours');
$intervals[10800] = "3 ".__('hours');
$intervals[21600] = "6 ".__('hours');
$intervals[43200] = "12 ".__('hours');
$intervals[86400] = __('Last day');
$intervals[172800] = "2 ". __('days');
$intervals[1209600] = __('Last week');
$intervals[2419200] = "15 ".__('days');
$intervals[4838400] = __('Last month');
$intervals[9676800] = "2 ".__('months');
$intervals[29030400] = "6 ".__('months');
$table->width = '100%';
$table->head = array ();
$table->head[0] = __('Label') . ' / ' . __('Type') . ' / ' . __('Parent');
$table->head[1] = __('Image') . ' / ' . __('Agent') . ' / ' . __('Map linked');
$table->head[2] = __('Height') . ' / ' . __('Module') . ' / ' . __('Label color');
$table->head[3] = __('Width') . ' / ' . __('Period');
$table->head[4] = __('Left');
$table->head[5] = __('Top');
$table->head[6] = __('Action');
$table->data = array();
//Background
$table->data[0][0] = __('Background');
$table->data[0][1] = print_select($backgrounds_list, 'background', $visualConsole['background'], '', 'None', '', true);
$table->data[0][2] = print_input_text('width', $visualConsole['width'], '', 3, 5, true);
$table->data[0][3] = print_input_text('height', $visualConsole['height'], '', 3, 5, true);
$table->data[0][4] = '';
$table->data[0][5] = '';
$table->data[0][6] = '';
$table->data[1][0] = __('Background');
$table->data[1][1] = '';
$table->data[1][2] = '';
$table->data[1][3] = '';
$table->data[1][4] = '';
$table->data[1][5] = '';
$table->data[1][6] = '';
$table->data[2][0] = '';
$table->data[2][1] = '';
$table->data[2][2] = '';
$table->data[2][3] = '';
$table->data[2][4] = '';
$table->data[2][5] = '';
$table->data[2][6] = '';
$i = 2;
$layoutDatas = get_db_all_rows_field_filter ('tlayout_data', 'id_layout', $idVisualConsole);
if ($layoutDatas === false)
$layoutDatas = array();
$alternativeStyle = true;
foreach ($layoutDatas as $layoutData) {
$idLayoutData = $layoutData['id'];
$table->data[$i][0] = print_input_text ('label_' . $idLayoutData, $layoutData['label'], '', 20, 200, true);
if ($layoutData['type'] == 0) {
$table->data[$i][1] = print_select ($images_list, 'image', $layoutData['image'], '', 'None', '', true);
}
else {
$table->data[$i][1] = '';
}
$table->data[$i][2] = print_input_text('width_' . $idLayoutData, $layoutData['width'], '', 3, 5, true);
$table->data[$i][3] = print_input_text('height_' . $idLayoutData, $layoutData['height'], '', 3, 5, true);
$table->data[$i][4] = print_input_text('left_' . $idLayoutData, $layoutData['pos_x'], '', 3, 5, true);
$table->data[$i][5] = print_input_text('top_' . $idLayoutData, $layoutData['pos_y'], '', 3, 5, true);
$table->data[$i][6] = '<a href=""><img src="images/cross.png" /></a>';
$table->data[$i + 1][0] = print_select (get_layout_data_types(), 'type_' . $idLayoutData, $layoutData['type'], '', '', 0, true, false, false);
$table->data[$i + 1][1] = print_input_text_extended ('agent_' . $idLayoutData, get_agent_name($layoutData['id_agent']), 'text-agent', '', 25, 100, false, '',
array('style' => 'background: #ffffff url(images/lightning.png) no-repeat right;'), true);
$table->data[$i + 1][2] = print_select_from_sql('SELECT id_agente_modulo, nombre FROM tagente_modulo WHERE id_agente = ' . $layoutData['id_agent'],
'module_' . $idLayoutData, $layoutData['id_agente_modulo'], '', '---', 0, true);
$table->data[$i + 1][3] = print_select ($intervals, 'period_' . $idLayoutData, $layoutData['period'], '', '--', 0, true);
$table->data[$i + 1][4] = '';
$table->data[$i + 1][5] = '';
$table->data[$i + 1][6] = '';
$table->data[$i + 2][0] = print_select_from_sql ('SELECT id, label FROM tlayout_data WHERE id_layout = '. $idVisualConsole,
'parent_' . $idLayoutData, $layoutData['parent_item'], '', 'None', '', true);
$table->data[$i + 2][1] = print_select_from_sql ('SELECT id, name FROM tlayout WHERE id != ' . $idVisualConsole,
'map_linked_' . $idLayoutData, $layoutData['id_layout_linked'], '', 'None', '', true);
//$table->data[$i + 2][2] = print_input_text ('label_color_' . $idLayoutData, '#000000', $layoutData['label_color'], 7, 7, true);
$table->data[$i + 2][2] = print_input_text_extended ('label_color_' . $idLayoutData, $layoutData['label_color'], 'text-'.'label_color_' . $idLayoutData
, '', 7, 7, false, '', 'class="label_color"', true);
$table->data[$i + 2][3] = '';
$table->data[$i + 2][4] = '';
$table->data[$i + 2][5] = '';
$table->data[$i + 2][6] = '';
if ($alternativeStyle) {
$table->rowclass[$i] = 'rowOdd';
$table->rowclass[$i + 1] = 'rowOdd';
$table->rowclass[$i + 2] = 'rowOdd';
}
else {
$table->rowclass[$i] = 'rowPair';
$table->rowclass[$i + 1] = 'rowPair';
$table->rowclass[$i + 2] = 'rowPair';
}
$alternativeStyle = !$alternativeStyle;
//$table->data[5][1] = print_input_text_extended ('agent', '', 'text-agent', '', 30, 100, false, '',
$i = $i + 3;
}
print_table($table);
require_css_file ('color-picker');
require_jquery_file ('ui.core');
require_jquery_file ('ui.draggable');
require_jquery_file ('ui.droppable');
require_jquery_file ('colorpicker');
require_jquery_file ('pandora.controls');
require_javascript_file ('wz_jsgraphics');
require_javascript_file ('pandora_visual_console');
require_jquery_file('ajaxqueue');
require_jquery_file('bgiframe');
require_jquery_file('autocomplete');
?>
<script type="text/javascript">
$(document).ready (function () {
$(".label_color").attachColorPicker();
});
</script>
<?php
case 'list_elements':
require_once('godmode/reporting/visual_console_builder.elements.php');
break;
case 'editor':
//Arrays for select box.
$backgrounds_list = list_files('images/console/background/', "jpg", 1, 0);
$backgrounds_list = array_merge($backgrounds_list, list_files ('images/console/background/', "png", 1, 0));
echo "<form method='post' action='index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=" . $activeTab . "&id_visual_console=" . $idVisualConsole . "'>";
debugPrint($_POST);
debugPrint(get_parameter('action'));
switch($action) {
case 'edit':
$visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole));
print_input_hidden('action', 'update');
break;
case 'update':
$values = array('background' => get_parameter('background_image'),
'height' => get_parameter('height_background'),
'width' => get_parameter('width_background'));
$correctUpdate = process_sql_update('tlayout', $values, array('id' => $idVisualConsole));
if ($correctUpdate !== false) {
echo '<h3 class="suc">'.__('Successfully created').'</h3>';
}
else {
echo '<h3 class="error">'.__('Could not be created').'</h3>';
}
$visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole));
print_input_hidden('action', 'update');
break;
}
$background = $visualConsole['background'];
$widthBackground = $visualConsole['width'];
$heightBackground = $visualConsole['height'];
$layoutDatas = get_db_all_rows_field_filter ('tlayout_data', 'id_layout', $idVisualConsole);
if ($layoutDatas === false)
$layoutDatas = array();
echo '<div id="toolbox" style="width: 100%">';
print_button(__('New element'), 'new_button', false, 'alert(666);', 'class="sub add"');
print_button(__('Properties'), 'properties_button', true, 'togglePropertiesPanel();', 'class="sub"');
print_submit_button(__('Save'), 'save_button', false, 'class="sub next"');
//<a href="">' . __('New') . '</a> <a href="">' . __('Properties') . '</a>
echo '</div>';
echo '<div id="new_panel"></div>';
echo '<div id="properties_panel" style="display: none; position: absolute; border: 2px solid #114105; padding: 5px; background: white; z-index: 1;">ZZZZ<br />ZZZZZ<br />ZZZZ</div>';
echo '<div id="frame_view" style="width: 100%; height: 500px; overflow: scroll;">';
//echo '<div id="test" style="background: red; width: 1000px; height: 50px; border: 2px solid black;"></div>';
echo '<div id="background" class="ui-widget-content" style="background: url(images/console/background/' . $background . ');
border: 2px black solid; width: ' . $widthBackground . 'px; height: ' . $heightBackground . 'px;">';
foreach ($layoutDatas as $layoutData) {
printItemInVisualConsole($layoutData);
}
echo '</div>';
echo '</div>';
echo "<div id='hidden_panel_properties_background' style='display: none'>";
$table = null;
$table->width = '300px';
$table->colspan[0][0] = 2;
$table->data = array();
$table->data[0][0] = '<b>' . __('Background') . '</b>';
$table->data[1][0] = __('Width') . ':';
$table->data[1][1] = print_input_text('width_background', $widthBackground, '', 3, 5, true);
$table->data[2][0] = __('Height') . ':';
$table->data[2][1] = print_input_text('height_background', $heightBackground, '', 3, 5, true);
$table->data[3][0] = __('Background') . ':';
$table->data[3][1] = print_select($backgrounds_list, 'background_image', $background, '', 'None', '', true);
print_table($table);
echo "</div>";
print_input_hidden('background_width', $widthBackground);
print_input_hidden('background_height', $heightBackground);
echo "</form>";
debugPrint($layoutDatas);
echo '<link type="text/css" href="include/javascript/jquery.ui/base/jquery.ui.all.css" rel="stylesheet" />';
echo "<script type='text/javascript' src='include/javascript/jquery.ui/jquery.ui.core.min.js'></script>";
echo "<script type='text/javascript' src='include/javascript/jquery.ui/jquery-ui-1.8rc3.custom.min.js'></script>";
echo "<script type='text/javascript' src='include/javascript/jquery.ui/jquery.ui.mouse.min.js'></script>";
echo "<script type='text/javascript' src='include/javascript/jquery.ui/jquery.ui.resizable.min.js'></script>";
echo "<script type='text/javascript' src='include/javascript/jquery.ui/jquery.ui.widget.min.js'></script>";
?>
<script type="text/javascript">
var selectedItem = null;
var selectedItemData = null;
var openPropertiesPanel = false;
$(document).ready (function () {
$("#background").resizable();
//$('.item').resizable();
$('#background').bind('resizestart', function(event, ui) {
if (!openPropertiesPanel) {
$("#background").css('border', '2px red solid');
}
});
$('#background').bind('resizestop', function(event, ui) {
if (!openPropertiesPanel) {
unselectAll();
$("#text-width_background").val($('#background').css('width').replace('px', ''));
$("#text-height_background").val($('#background').css('height').replace('px', ''));
}
});
//Event click for background
$("#background").click(function(event) {
event.stopPropagation();
if (!openPropertiesPanel) {
$("#background").css('border', '2px blue dotted');
$("input[name=properties_button]").removeAttr('disabled');
selectedItem = 'background';
}
});
$(".item").click(function(event) {
event.stopPropagation();
if (!openPropertiesPanel) {
unselectAll();
dataItem_serialize = $(event.target).attr('id');
dataItem = dataItem_serialize.split('_');
type = dataItem[1];
indb = dataItem[2];
id = dataItem[3];
selectedItem = 'layoutItem';
selectedItemData = {};
selectedItemData['id'] = id;
selectedItemData['type'] = type;
if (indb == 'indb') {
selectedItemData['indb'] = true;
}
else {
selectedItemData['indb'] = false;
}
$(event.target).css('border', '2px blue dotted');
$("input[name=properties_button]").removeAttr('disabled');
}
});
});
//function change style of all selectable items
function unselectAll() {
$("#background").css('border', '2px black solid');
// console.log(321);
// $(".item").css().each(function(i, val) {
// console.log(888);
// });
// console.log(123);
//
// console.log(666);console.log($(".item"));
// console.log($(".item").css());
// console.log(999);
$(".item").css('border', '');
}
function togglePropertiesPanel() {
if (!openPropertiesPanel) {
$("#submit-save_button").attr('disabled', 'disabled');
$("#background").resizable('disable');
switch (selectedItem) {
case 'background':
chunkPanelPropertiesBackground = $("#hidden_panel_properties_background").clone();
width = $("#text-width_background").val();
height = $("#text-height_background").val();
background_image = $("select[name=background_image]").val();
$("input[name=width_background]", chunkPanelPropertiesBackground).attr('id', 'edition_width_background');
$("input[name=height_background]", chunkPanelPropertiesBackground).attr('id', 'edition_height_background');
$("select[name=background_image]", chunkPanelPropertiesBackground).attr('id', 'edition_background_image');
$("#properties_panel").empty().append(chunkPanelPropertiesBackground.html());
chunkPanelPropertiesBackground = null;
$("#edition_width_background").val(width);
$("#edition_height_background").val(height);
$("#edition_background_image").val(background_image);
$("#edition_width_background").change(function() {
width = $("#edition_width_background").val();
$("#background").css('width', width + 'px');
$("input[name=width_background]").val(width);
});
$("#edition_height_background").change(function() {
height = $("#edition_height_background").val();
$("#background").css('height', height + 'px');
$("input[name=height_background]").val($("#edition_height_background").val());
});
$("#edition_background_image").change(function() {
background_image = $("#edition_background_image").val();
$("#background").css('background', 'url(images/console/background/' + background_image + ')');
$("select[name=background_image]").val(background_image);
});
break;
case 'layoutItem':
chunkPanelPropertiesBackground = $("#layoutItem_hidden_fields_" + selectedItemData['id']).clone();
width = $("input[name=width_indb_" + selectedItemData['id'] + "]").val();
height = $("input[name=height_indb_" + selectedItemData['id'] + "]").val();
left = $("input[name=left_indb_" + selectedItemData['id'] + "]").val();
top = $("input[name=top_indb_" + selectedItemData['id'] + "]").val();
$("input[name=left_indb_" + selectedItemData['id'] + "]", chunkPanelPropertiesBackground).attr('id', 'edition_left_item');
$("input[name=top_indb_" + selectedItemData['id'] + "]", chunkPanelPropertiesBackground).attr('id', 'edition_top_item');
$("input[name=width_indb_" + selectedItemData['id'] + "]", chunkPanelPropertiesBackground).attr('id', 'edition_width_item');
$("input[name=height_indb_" + selectedItemData['id'] + "]", chunkPanelPropertiesBackground).attr('id', 'edition_height_item');
$("#properties_panel").empty().append(chunkPanelPropertiesBackground.html());
chunkPanelPropertiesBackground = null;
$("#edition_left_item").val(left);
$("#edition_top_item").val(top);
$("#edition_width_item").val(width);
$("#edition_height_item").val(height);
$("#edition_left_item").change(function() {
left = $("#edition_left_item").val();
$("#DivLayoutItem_image_indb_" + selectedItemData['id']).css('margin-left', left + 'px');
$("input[name=left_indb_" + selectedItemData['id'] + "]").val(left);
});
$("#edition_top_item").change(function() {
top = $("#edition_top_item").val();
$("#DivLayoutItem_image_indb_" + selectedItemData['id']).css('margin-top', left + 'px');
$("input[name=top_indb_" + selectedItemData['id'] + "]").val(top);
});
$("#edition_width_item").change(function() {
width = $("#edition_width_item").val();
alert($("#layoutItem_image_indb_" + selectedItemData['id']).attr('width'));
$("#layoutItem_image_indb_" + selectedItemData['id']).attr('width', width);
$("input[name=width_indb_" + selectedItemData['id'] + "]").val(width);
});
break;
}
$("#properties_panel").show("fast");
}
else {
$("#background").resizable('enable');
$("#properties_panel").hide("fast");
$("input[name=save_button]").removeAttr('disabled');
}
openPropertiesPanel = !openPropertiesPanel;
}
</script>
<?php
require_once('godmode/reporting/visual_console_builder.editor.php');
break;
}
function printItemInVisualConsole($layoutData) {
$width = $layoutData['width'];
$height = $layoutData['height'];
$top = $layoutData['pos_y'];
$left = $layoutData['pos_x'];
$id = $layoutData['id'];
$img = getImageStatusElement($layoutData);
$imgSizes = getimagesize($img);
//debugPrint($imgSizes);
//TODO set type now image by default
echo '<div id="DivLayoutItem_image_indb_' . $id . '" style="position: absolute; width: ' . $width . 'px; height: ' . $height . 'px; margin-top: ' . $top . 'px; margin-left: ' . $left . 'px;">';
//echo '<div style="width: ' . $imgSizes[0] . 'px; height: ' . $imgSizes[1] . 'px;">';
echo '<img class="item" id="layoutItem_image_indb_' . $id . '" src="' . $img . '" />';
//echo '</div>';
echo '<div id="layoutItem_hidden_fields_' . $id . '" style="display: none">';
$table = null;
$table->width = '300px';
$table->colspan[0][0] = 2;
$table->data = array();
//TODO set type now image by default
$table->data[0][0] = '<b>' . __('Image') . '</b>';
$table->data[1][0] = __('left') . ':';
$table->data[1][1] = print_input_text('left_indb_' . $id, $layoutData['pos_x'], '', 3, 5, true);
$table->data[2][0] = __('Top') . ':';
$table->data[2][1] = print_input_text('top_indb_' . $id, $layoutData['pos_y'], '', 3, 5, true);
$table->data[3][0] = __('Width') . ':';
$table->data[3][1] = print_input_text('width_indb_' . $id, $layoutData['width'], '', 3, 5, true);
$table->data[4][0] = __('Height') . ':';
$table->data[4][1] = print_input_text('height_indb_' . $id, $layoutData['height'], '', 3, 5, true);
print_table($table);
//TODO more fields
echo '</div>';
echo "</div>";
}
function getImageStatusElement($layoutData) {
$img = "images/console/icons/" . $layoutData["image"];
switch (getStatusElement($layoutData)) {
case 1:
case 4:
//Critical (BAD or ALERT)
$img .= "_bad.png";
break;
case 0:
//Normal (OK)
$img .= "_ok.png";
break;
case 2:
//Warning
$img .= "_warning.png";
break;
default:
$img .= ".png";
// Default is Grey (Other)
}
return $img;
}
function getStatusElement($layoutData) {
//Linked to other layout ?? - Only if not module defined
if ($layoutData['id_layout_linked'] != 0) {
$status = get_layout_status ($layout_data['id_layout_linked']);
}
else if ($layoutData["type"] == 0) { //Single object
//Status for a simple module
if ($layoutData['id_agente_modulo'] != 0) {
$status = get_agentmodule_status ($layoutData['id_agente_modulo']);
//Status for a whole agent, if agente_modulo was == 0
}
else if ($layoutData['id_agent'] != 0) {
$status = get_agent_status ($layoutData["id_agent"]);
if ($status == -1) // get_agent_status return -1 for unknown!
$status = 3;
}
else {
$status = 3;
$id_agent = 0;
}
}
else {
//If it's a graph, a progress bar or a data tag, ALWAYS report status OK
//(=0) to avoid confussions here.
$status = 0;
}
return $status;
}
?>
?>

View File

@ -0,0 +1,164 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Login check
global $config;
check_login ();
if (! give_acl ($config['id_user'], 0, "IW")) {
audit_db ($config['id_user'], $_SERVER['REMOTE_ADDR'], "ACL Violation",
"Trying to access report builder");
require ("general/noaccess.php");
exit;
}
require_once ('include/functions_visual_map.php');
$action = get_parameter('action');
$type = get_parameter('type');
$id_visual_console = get_parameter('id_visual_console', null);
$id_element = get_parameter('id_element', null);
$image = get_parameter('image', null);
$background = get_parameter('background', null);
$label = get_parameter('label', null);
$left = get_parameter('left', null);
$top = get_parameter('top', null);
$agent = get_parameter('agent', null);
$module = get_parameter('module', null);
$period = get_parameter('period', null);
$width = get_parameter('width', null);
$height = get_parameter('height', null);
$parent = get_parameter('parent', null);
$map_linked = get_parameter('map_linked', null);
$label_color = get_parameter('label_color', null);
switch ($action) {
case 'get_image':
$layoutData = get_db_row_filter('tlayout_data', array('id' => $id_element));
$return = array();
$return['image'] = getImageStatusElement($layoutData);
echo json_encode($return);
break;
case 'update':
switch ($type) {
case 'background':
$values = array();
if ($background !== null)
$values['background'] = $background;
if ($width !== null)
$values['width'] = $width;
if ($height !== null)
$values['height'] = $height;
process_sql_update('tlayout', $values, array('id' => $id_visual_console));
break;
case 'static_graph':
$values = array();
if ($label !== null) {
$values['label'] = $label;
}
if ($image !== null) {
$values['image'] = $image;
}
if ($left !== null) {
$values['pos_x'] = $left;
}
if ($top !== null) {
$values['pos_y'] = $top;
}
//TODO $agent -> $id_agent
$id_agent = 0;
//TODO
$values['id_agent'] = $id_agent;
if ($module !== null) {
$values['id_agente_modulo'] = $module;
}
if ($period !== null) {
$values['period'] = $period;
}
if ($width !== null) {
$values['width'] = $width;
}
if ($height !== null) {
$values['height'] = $height;
}
if ($parent !== null) {
$values['parent_item'] = $parent;
}
if ($map_linked !== null) {
$values['id_layout_linked'] = $map_linked;
}
if ($label_color !== null) {
$values['label_color'] = $label_color;
}
process_sql_update('tlayout_data', $values, array('id' => $id_element));
break;
}
break;
case 'load':
switch ($type) {
case 'background':
$backgroundFields = get_db_row_filter('tlayout', array('id' => $id_visual_console), array('background', 'height', 'width'));
echo json_encode($backgroundFields);
break;
case 'static_graph':
$elementFields = get_db_row_filter('tlayout_data', array('id' => $id_element));
echo json_encode($elementFields);
break;
}
break;
case 'insert':
switch ($type) {
case 'static_graph':
$values = array();
$values['id_layout'] = $id_visual_console;
$values['label'] = $label;
$values['image'] = $image;
$values['pos_x'] = $left;
$values['pos_y'] = $top;
$values['label_color'] = $label_color;
if ($agent != '')
$values['id_agent'] = get_agent_id($agent);
else
$values['id_agent'] = 0;
$values['id_agente_modulo'] = $module;
$idData = process_sql_insert('tlayout_data', $values);
$return = array();
if ($idData === false) {
$return['correct'] = 0;
}
else {
$return['correct'] = 1;
$return['id_data'] = $idData;
}
echo json_encode($return);
break;
}
break;
case 'delete':
if (process_sql_delete('tlayout_data', array('id' => $id_element, 'id_layout' => $id_visual_console)) === false) {
$return['correct'] = 0;
}
else {
$return['correct'] = 1;
}
echo json_encode($return);
break;
}
?>

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC10317'; // Remember is YYMMDD
$build_version = 'PC10323'; // Remember is YYMMDD
$pandora_version = 'v3.1-dev';
/* Help to debug problems. Override global PHP configuration */

View File

@ -103,7 +103,7 @@ function safe_url_extraclean ($string) {
$string = substr ($string, 0, 125);
}
/* Strip the string to 125 characters */
return preg_replace ('/[^a-z0-9_\/]/i', '', $string);
return preg_replace ('/[^a-z0-9_\/\.]/i', '', $string);
}
/**
@ -980,21 +980,22 @@ function index_array ($array, $index = 'id', $value = 'name') {
function return_graphtype ($id_module_type){
switch($id_module_type){
case 3:
case 10:
case 17:
case 23:
return "string";
case 2:
case 6:
case 21:
case 18:
case 9:
return "boolean";
case 30:
return "log4x";
case 3:
case 10:
case 17:
case 23:
return "string";
break;
case 2:
case 6:
case 21:
case 18:
case 9:
return "boolean";
break;
case 30:
return "log4x";
break;
}

View File

@ -19,6 +19,61 @@
* @subpackage Reporting
*/
function getImageStatusElement($layoutData) {
$img = "images/console/icons/" . $layoutData["image"];
switch (getStatusElement($layoutData)) {
case 1:
case 4:
//Critical (BAD or ALERT)
$img .= "_bad.png";
break;
case 0:
//Normal (OK)
$img .= "_ok.png";
break;
case 2:
//Warning
$img .= "_warning.png";
break;
default:
$img .= ".png";
// Default is Grey (Other)
}
return $img;
}
function getStatusElement($layoutData) {
//Linked to other layout ?? - Only if not module defined
if ($layoutData['id_layout_linked'] != 0) {
$status = get_layout_status ($layout_data['id_layout_linked']);
}
else if ($layoutData["type"] == 0) { //Single object
//Status for a simple module
if ($layoutData['id_agente_modulo'] != 0) {
$status = get_agentmodule_status ($layoutData['id_agente_modulo']);
//Status for a whole agent, if agente_modulo was == 0
}
else if ($layoutData['id_agent'] != 0) {
$status = get_agent_status ($layoutData["id_agent"]);
if ($status == -1) // get_agent_status return -1 for unknown!
$status = 3;
}
else {
$status = 3;
$id_agent = 0;
}
}
else {
//If it's a graph, a progress bar or a data tag, ALWAYS report status OK
//(=0) to avoid confussions here.
$status = 0;
}
return $status;
}
/**
* Prints visual map
*

File diff suppressed because one or more lines are too long