From fcf6eb59bd3deb3d0c6d170027b592ae6fb7d83d Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 23 Mar 2010 17:46:08 +0000 Subject: [PATCH] 2010-03-23 Miguel de Dios * 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 --- pandora_console/ChangeLog | 22 + .../reporting/visual_console_builder.data.php | 71 +++ .../visual_console_builder.editor.js | 569 +++++++++++++++++ .../visual_console_builder.editor.php | 266 ++++++++ .../visual_console_builder.elements.php | 173 ++++++ .../reporting/visual_console_builder.php | 581 +----------------- .../ajax/visual_console_builder.ajax.php | 164 +++++ pandora_console/include/config_process.php | 2 +- pandora_console/include/functions.php | 33 +- .../include/functions_visual_map.php | 55 ++ .../include/javascript/jquery.ui.resizable.js | 1 + 11 files changed, 1361 insertions(+), 576 deletions(-) create mode 100644 pandora_console/godmode/reporting/visual_console_builder.data.php create mode 100644 pandora_console/godmode/reporting/visual_console_builder.editor.js create mode 100644 pandora_console/godmode/reporting/visual_console_builder.editor.php create mode 100644 pandora_console/godmode/reporting/visual_console_builder.elements.php create mode 100644 pandora_console/include/ajax/visual_console_builder.ajax.php create mode 100755 pandora_console/include/javascript/jquery.ui.resizable.js diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 74f122af1f..ad82030e50 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,25 @@ +2010-03-23 Miguel de Dios + + * 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 * include/help/en/check_other_languages.sh: Moved from include/help diff --git a/pandora_console/godmode/reporting/visual_console_builder.data.php b/pandora_console/godmode/reporting/visual_console_builder.data.php new file mode 100644 index 0000000000..e7245bd0a7 --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_builder.data.php @@ -0,0 +1,71 @@ +"; + print_input_hidden('action', 'save'); + break; + case 'update': + case 'save': + echo "
"; + print_input_hidden('action', 'update'); + break; + case 'edit': + echo ""; + 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 "
"; +?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js new file mode 100644 index 0000000000..306e0f1abb --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -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 = $('
' + + '
' + + '' + values['label'] + '' + + '
' + ); + 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(""); + $("#preview").append(""); + $("#preview").append(""); + $("#preview").append(""); + } +} \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php new file mode 100644 index 0000000000..3d140042b7 --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -0,0 +1,266 @@ +'; + echo '
'; + 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 '
'; +echo ''; +echo '
'; + +echo "
"; +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 ''; +echo '
'; +echo '
'; + +foreach ($layoutDatas as $layoutData) { + printItemInVisualConsole($layoutData); +} + +echo '
'; +echo '
'; + +print_input_hidden('background_width', $widthBackground); +print_input_hidden('background_height', $heightBackground); +echo "
"; + +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 '
'; + if ($disabled) { + echo ''; + } + else { + echo ''; + } + echo $label; + echo ''; + echo '
'; +} + +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 '
'; + echo '
'; + echo '' . $label . ''; + echo "
"; +} +?> + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php new file mode 100644 index 0000000000..141e50c03e --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -0,0 +1,173 @@ +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] = ''; + $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'); +?> + \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index cd1aeffc44..4b63ae04c0 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -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' => '

'.__('Successfully update.').'

'); + } + else { + $statusProcessInDB = array('flag' => false, 'message' => '

'.__('Could not be update.').'

'); + } + $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 "
"; - print_input_hidden('action', 'save'); - break; - case 'update': - case 'save': - echo ""; - print_input_hidden('action', 'update'); - break; - case 'edit': - echo ""; - 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 "
"; + 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] = ''; - $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'); - ?> - - "; - 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 '

'.__('Successfully created').'

'; - } - else { - echo '

'.__('Could not be created').'

'; - } - - $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 '
'; - 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"'); - //' . __('New') . ' ' . __('Properties') . ' - echo '
'; - echo '
'; - echo ''; - echo '
'; - //echo '
'; - echo '
'; - - foreach ($layoutDatas as $layoutData) { - printItemInVisualConsole($layoutData); - } - - echo '
'; - echo '
'; - - echo ""; - - print_input_hidden('background_width', $widthBackground); - print_input_hidden('background_height', $heightBackground); - echo ""; - debugPrint($layoutDatas); - echo ''; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - ?> - - '; - //echo '
'; - echo ''; - //echo '
'; - echo ''; - echo ""; -} - -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; -} - -?> - - - - - - - - - - - - - - - - - - +?> \ No newline at end of file diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php new file mode 100644 index 0000000000..cb3cc10468 --- /dev/null +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -0,0 +1,164 @@ + $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; +} +?> \ No newline at end of file diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index f5b30cb777..9ef4810867 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -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 */ diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index a48499925d..95614ffb1e 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -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; } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 09414b9b6b..4b1056f8b6 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -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 * diff --git a/pandora_console/include/javascript/jquery.ui.resizable.js b/pandora_console/include/javascript/jquery.ui.resizable.js new file mode 100755 index 0000000000..423328ee32 --- /dev/null +++ b/pandora_console/include/javascript/jquery.ui.resizable.js @@ -0,0 +1 @@ +(function(A){A.widget("ui.resizable",A.extend({},A.ui.mouse,{init:function(){var M=this,N=this.options;var Q=this.element.css("position");this.originalElement=this.element;this.element.addClass("ui-resizable").css({position:/static/.test(Q)?"relative":Q});A.extend(N,{_aspectRatio:!!(N.aspectRatio),helper:N.helper||N.ghost||N.animate?N.helper||"proxy":null,knobHandles:N.knobHandles===true?"ui-resizable-knob-handle":N.knobHandles});var H="1px solid #DEDEDE";N.defaultTheme={"ui-resizable":{display:"block"},"ui-resizable-handle":{position:"absolute",background:"#F2F2F2",fontSize:"0.1px"},"ui-resizable-n":{cursor:"n-resize",height:"4px",left:"0px",right:"0px",borderTop:H},"ui-resizable-s":{cursor:"s-resize",height:"4px",left:"0px",right:"0px",borderBottom:H},"ui-resizable-e":{cursor:"e-resize",width:"4px",top:"0px",bottom:"0px",borderRight:H},"ui-resizable-w":{cursor:"w-resize",width:"4px",top:"0px",bottom:"0px",borderLeft:H},"ui-resizable-se":{cursor:"se-resize",width:"4px",height:"4px",borderRight:H,borderBottom:H},"ui-resizable-sw":{cursor:"sw-resize",width:"4px",height:"4px",borderBottom:H,borderLeft:H},"ui-resizable-ne":{cursor:"ne-resize",width:"4px",height:"4px",borderRight:H,borderTop:H},"ui-resizable-nw":{cursor:"nw-resize",width:"4px",height:"4px",borderLeft:H,borderTop:H}};N.knobTheme={"ui-resizable-handle":{background:"#F2F2F2",border:"1px solid #808080",height:"8px",width:"8px"},"ui-resizable-n":{cursor:"n-resize",top:"0px",left:"45%"},"ui-resizable-s":{cursor:"s-resize",bottom:"0px",left:"45%"},"ui-resizable-e":{cursor:"e-resize",right:"0px",top:"45%"},"ui-resizable-w":{cursor:"w-resize",left:"0px",top:"45%"},"ui-resizable-se":{cursor:"se-resize",right:"0px",bottom:"0px"},"ui-resizable-sw":{cursor:"sw-resize",left:"0px",bottom:"0px"},"ui-resizable-nw":{cursor:"nw-resize",left:"0px",top:"0px"},"ui-resizable-ne":{cursor:"ne-resize",right:"0px",top:"0px"}};N._nodeName=this.element[0].nodeName;if(N._nodeName.match(/canvas|textarea|input|select|button|img/i)){var B=this.element;if(/relative/.test(B.css("position"))&&A.browser.opera){B.css({position:"relative",top:"auto",left:"auto"})}B.wrap(A('
').css({position:B.css("position"),width:B.outerWidth(),height:B.outerHeight(),top:B.css("top"),left:B.css("left")}));var J=this.element;this.element=this.element.parent();this.element.data("resizable",this);this.element.css({marginLeft:J.css("marginLeft"),marginTop:J.css("marginTop"),marginRight:J.css("marginRight"),marginBottom:J.css("marginBottom")});J.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});if(A.browser.safari&&N.preventDefault){J.css("resize","none")}N.proportionallyResize=J.css({position:"static",zoom:1,display:"block"});this.element.css({margin:J.css("margin")});this._proportionallyResize()}if(!N.handles){N.handles=!A(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}}if(N.handles.constructor==String){N.zIndex=N.zIndex||1000;if(N.handles=="all"){N.handles="n,e,s,w,se,sw,ne,nw"}var O=N.handles.split(",");N.handles={};var G={handle:"position: absolute; display: none; overflow:hidden;",n:"top: 0pt; width:100%;",e:"right: 0pt; height:100%;",s:"bottom: 0pt; width:100%;",w:"left: 0pt; height:100%;",se:"bottom: 0pt; right: 0px;",sw:"bottom: 0pt; left: 0px;",ne:"top: 0pt; right: 0px;",nw:"top: 0pt; left: 0px;"};for(var R=0;R'].join("")).css(K);N.handles[S]=".ui-resizable-"+S;this.element.append(E.css(C?T:{}).css(N.knobHandles?D:{}).addClass(N.knobHandles?"ui-resizable-knob-handle":"").addClass(N.knobHandles))}if(N.knobHandles){this.element.addClass("ui-resizable-knob").css(!A.ui.css("ui-resizable-knob")?{}:{})}}this._renderAxis=function(Y){Y=Y||this.element;for(var V in N.handles){if(N.handles[V].constructor==String){N.handles[V]=A(N.handles[V],this.element).show()}if(N.transparent){N.handles[V].css({opacity:0})}if(this.element.is(".ui-wrapper")&&N._nodeName.match(/textarea|input|select|button/i)){var W=A(N.handles[V],this.element),X=0;X=/sw|ne|nw|se|n|s/.test(V)?W.outerHeight():W.outerWidth();var U=["padding",/ne|nw|n/.test(V)?"Top":/se|sw|s/.test(V)?"Bottom":/^e$/.test(V)?"Right":"Left"].join("");if(!N.transparent){Y.css(U,X)}this._proportionallyResize()}if(!A(N.handles[V]).length){continue}}};this._renderAxis(this.element);N._handles=A(".ui-resizable-handle",M.element);if(N.disableSelection){N._handles.each(function(U,V){A.ui.disableSelection(V)})}N._handles.mouseover(function(){if(!N.resizing){if(this.className){var U=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}M.axis=N.axis=U&&U[1]?U[1]:"se"}});if(N.autoHide){N._handles.hide();A(M.element).addClass("ui-resizable-autohide").hover(function(){A(this).removeClass("ui-resizable-autohide");N._handles.show()},function(){if(!N.resizing){A(this).addClass("ui-resizable-autohide");N._handles.hide()}})}this.mouseInit()},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,options:this.options,originalSize:this.originalSize,originalPosition:this.originalPosition}},propagate:function(C,B){A.ui.plugin.call(this,C,[B,this.ui()]);if(C!="resize"){this.element.triggerHandler(["resize",C].join(""),[B,this.ui()],this.options[C])}},destroy:function(){var D=this.element,C=D.children(".ui-resizable").get(0);this.mouseDestroy();var B=function(E){A(E).removeClass("ui-resizable ui-resizable-disabled").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};B(D);if(D.is(".ui-wrapper")&&C){D.parent().append(A(C).css({position:D.css("position"),width:D.outerWidth(),height:D.outerHeight(),top:D.css("top"),left:D.css("left")})).end().remove();B(C)}},mouseStart:function(K){if(this.options.disabled){return false}var J=false;for(var H in this.options.handles){if(A(this.options.handles[H])[0]==K.target){J=true}}if(!J){return false}var C=this.options,B=this.element.position(),D=this.element,I=function(O){return parseInt(O,10)||0},G=A.browser.msie&&A.browser.version<7;C.resizing=true;C.documentScroll={top:A(document).scrollTop(),left:A(document).scrollLeft()};if(D.is(".ui-draggable")||(/absolute/).test(D.css("position"))){var M=A.browser.msie&&!C.containment&&(/absolute/).test(D.css("position"))&&!(/relative/).test(D.parent().css("position"));var L=M?C.documentScroll.top:0,F=M?C.documentScroll.left:0;D.css({position:"absolute",top:(B.top+L),left:(B.left+F)})}if(A.browser.opera&&/relative/.test(D.css("position"))){D.css({position:"relative",top:"auto",left:"auto"})}this._renderProxy();var N=I(this.helper.css("left")),E=I(this.helper.css("top"));if(C.containment){N+=A(C.containment).scrollLeft()||0;E+=A(C.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:N,top:E};this.size=C.helper||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalSize=C.helper||G?{width:D.outerWidth(),height:D.outerHeight()}:{width:D.width(),height:D.height()};this.originalPosition={left:N,top:E};this.sizeDiff={width:D.outerWidth()-D.width(),height:D.outerHeight()-D.height()};this.originalMousePosition={left:K.pageX,top:K.pageY};C.aspectRatio=(typeof C.aspectRatio=="number")?C.aspectRatio:((this.originalSize.height/this.originalSize.width)||1);if(C.preserveCursor){A("body").css("cursor",this.axis+"-resize")}this.propagate("start",K);return true},mouseDrag:function(I){var D=this.helper,C=this.options,J={},M=this,F=this.originalMousePosition,K=this.axis;var N=(I.pageX-F.left)||0,L=(I.pageY-F.top)||0;var E=this._change[K];if(!E){return false}var H=E.apply(this,[I,N,L]),G=A.browser.msie&&A.browser.version<7,B=this.sizeDiff;if(C._aspectRatio||I.shiftKey){H=this._updateRatio(H,I)}H=this._respectSize(H,I);this.propagate("resize",I);D.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!C.helper&&C.proportionallyResize){this._proportionallyResize()}this._updateCache(H);this.element.triggerHandler("resize",[I,this.ui()],this.options["resize"]);return false},mouseStop:function(I){this.options.resizing=false;var E=this.options,H=function(M){return parseInt(M,10)||0},K=this;if(E.helper){var D=E.proportionallyResize,B=D&&(/textarea/i).test(D.get(0).nodeName),C=B&&A.ui.hasScroll(D.get(0),"left")?0:K.sizeDiff.height,G=B?0:K.sizeDiff.width;var L={width:(K.size.width-G),height:(K.size.height-C)},F=(parseInt(K.element.css("left"),10)+(K.position.left-K.originalPosition.left))||null,J=(parseInt(K.element.css("top"),10)+(K.position.top-K.originalPosition.top))||null;if(!E.animate){this.element.css(A.extend(L,{top:J,left:F}))}if(E.helper&&!E.animate){this._proportionallyResize()}}if(E.preserveCursor){A("body").css("cursor","auto")}this.propagate("stop",I);if(E.helper){this.helper.remove()}return false},_updateCache:function(B){var C=this.options;this.offset=this.helper.offset();if(B.left){this.position.left=B.left}if(B.top){this.position.top=B.top}if(B.height){this.size.height=B.height}if(B.width){this.size.width=B.width}},_updateRatio:function(D,E){var F=this.options,G=this.position,C=this.size,B=this.axis;if(D.height){D.width=(C.height/F.aspectRatio)}else{if(D.width){D.height=(C.width*F.aspectRatio)}}if(B=="sw"){D.left=G.left+(C.width-D.width);D.top=null}if(B=="nw"){D.top=G.top+(C.height-D.height);D.left=G.left+(C.width-D.width)}return D},_respectSize:function(H,I){var F=this.helper,E=this.options,N=E._aspectRatio||I.shiftKey,M=this.axis,P=H.width&&E.maxWidth&&E.maxWidthH.width,O=H.height&&E.minHeight&&E.minHeight>H.height;if(D){H.width=E.minWidth}if(O){H.height=E.minHeight}if(P){H.width=E.maxWidth}if(J){H.height=E.maxHeight}var C=this.originalPosition.left+this.originalSize.width,L=this.position.top+this.size.height;var G=/sw|nw|w/.test(M),B=/nw|ne|n/.test(M);if(D&&G){H.left=C-E.minWidth}if(P&&G){H.left=C-E.maxWidth}if(O&&B){H.top=L-E.minHeight}if(J&&B){H.top=L-E.maxHeight}var K=!H.width&&!H.height;if(K&&!H.left&&H.top){H.top=null}else{if(K&&!H.top&&H.left){H.left=null}}return H},_proportionallyResize:function(){var F=this.options;if(!F.proportionallyResize){return }var D=F.proportionallyResize,C=this.helper||this.element;if(!F.borderDif){var B=[D.css("borderTopWidth"),D.css("borderRightWidth"),D.css("borderBottomWidth"),D.css("borderLeftWidth")],E=[D.css("paddingTop"),D.css("paddingRight"),D.css("paddingBottom"),D.css("paddingLeft")];F.borderDif=A.map(B,function(G,I){var H=parseInt(G,10)||0,J=parseInt(E[I],10)||0;return H+J})}D.css({height:(C.height()-F.borderDif[0]-F.borderDif[2])+"px",width:(C.width()-F.borderDif[1]-F.borderDif[3])+"px"})},_renderProxy:function(){var C=this.element,F=this.options;this.elementOffset=C.offset();if(F.helper){this.helper=this.helper||A('
');var B=A.browser.msie&&A.browser.version<7,D=(B?1:0),E=(B?2:-1);this.helper.addClass(F.helper).css({width:C.outerWidth()+E,height:C.outerHeight()+E,position:"absolute",left:this.elementOffset.left-D+"px",top:this.elementOffset.top-D+"px",zIndex:++F.zIndex});this.helper.appendTo("body");if(F.disableSelection){A.ui.disableSelection(this.helper.get(0))}}else{this.helper=C}},_change:{e:function(D,C,B){return{width:this.originalSize.width+C}},w:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{left:E.left+C,width:D.width-C}},n:function(F,C,B){var G=this.options,D=this.originalSize,E=this.originalPosition;return{top:E.top+B,height:D.height-B}},s:function(D,C,B){return{height:this.originalSize.height+B}},se:function(D,C,B){return A.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[D,C,B]))},sw:function(D,C,B){return A.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[D,C,B]))},ne:function(D,C,B){return A.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[D,C,B]))},nw:function(D,C,B){return A.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[D,C,B]))}}}));A.extend(A.ui.resizable,{defaults:{cancel:":input",distance:1,delay:0,preventDefault:true,transparent:false,minWidth:10,minHeight:10,aspectRatio:false,disableSelection:true,preserveCursor:true,autoHide:false,knobHandles:false}});A.ui.plugin.add("resizable","containment",{start:function(I,K){var E=K.options,M=A(this).data("resizable"),G=M.element;var C=E.containment,F=(C instanceof A)?C.get(0):(/parent/.test(C))?G.parent().get(0):C;if(!F){return }M.containerElement=A(F);if(/document/.test(C)||C==document){M.containerOffset={left:0,top:0};M.containerPosition={left:0,top:0};M.parentData={element:A(document),left:0,top:0,width:A(document).width(),height:A(document).height()||document.body.parentNode.scrollHeight}}else{M.containerOffset=A(F).offset();M.containerPosition=A(F).position();M.containerSize={height:A(F).innerHeight(),width:A(F).innerWidth()};var J=M.containerOffset,B=M.containerSize.height,H=M.containerSize.width,D=(A.ui.hasScroll(F,"left")?F.scrollWidth:H),L=(A.ui.hasScroll(F)?F.scrollHeight:B);M.parentData={element:F,left:J.left,top:J.top,width:D,height:L}}},resize:function(H,K){var E=K.options,N=A(this).data("resizable"),C=N.containerSize,J=N.containerOffset,G=N.size,I=N.position,L=E._aspectRatio||H.shiftKey,B={top:0,left:0},D=N.containerElement;if(D[0]!=document&&/static/.test(D.css("position"))){B=N.containerPosition}if(I.left<(E.helper?J.left:B.left)){N.size.width=N.size.width+(E.helper?(N.position.left-J.left):(N.position.left-B.left));if(L){N.size.height=N.size.width*E.aspectRatio}N.position.left=E.helper?J.left:B.left}if(I.top<(E.helper?J.top:0)){N.size.height=N.size.height+(E.helper?(N.position.top-J.top):N.position.top);if(L){N.size.width=N.size.height/E.aspectRatio}N.position.top=E.helper?J.top:0}var F=(E.helper?N.offset.left-J.left:(N.position.left-B.left))+N.sizeDiff.width,M=(E.helper?N.offset.top-J.top:N.position.top)+N.sizeDiff.height;if(F+N.size.width>=N.parentData.width){N.size.width=N.parentData.width-F;if(L){N.size.height=N.size.width*E.aspectRatio}}if(M+N.size.height>=N.parentData.height){N.size.height=N.parentData.height-M;if(L){N.size.width=N.size.height/E.aspectRatio}}},stop:function(G,J){var C=J.options,L=A(this).data("resizable"),H=L.position,I=L.containerOffset,B=L.containerPosition,D=L.containerElement;var E=A(L.helper),M=E.offset(),K=E.innerWidth(),F=E.innerHeight();if(C.helper&&!C.animate&&/relative/.test(D.css("position"))){A(this).css({left:(M.left-I.left),top:(M.top-I.top),width:K,height:F})}if(C.helper&&!C.animate&&/static/.test(D.css("position"))){A(this).css({left:B.left+(M.left-I.left),top:B.top+(M.top-I.top),width:K,height:F})}}});A.ui.plugin.add("resizable","grid",{resize:function(H,J){var D=J.options,L=A(this).data("resizable"),G=L.size,E=L.originalSize,F=L.originalPosition,K=L.axis,I=D._aspectRatio||H.shiftKey;D.grid=typeof D.grid=="number"?[D.grid,D.grid]:D.grid;var C=Math.round((G.width-E.width)/(D.grid[0]||1))*(D.grid[0]||1),B=Math.round((G.height-E.height)/(D.grid[1]||1))*(D.grid[1]||1);if(/^(se|s|e)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B}else{if(/^(ne)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B}else{if(/^(sw)$/.test(K)){L.size.width=E.width+C;L.size.height=E.height+B;L.position.left=F.left-C}else{L.size.width=E.width+C;L.size.height=E.height+B;L.position.top=F.top-B;L.position.left=F.left-C}}}}});A.ui.plugin.add("resizable","animate",{stop:function(I,K){var F=K.options,L=A(this).data("resizable");var E=F.proportionallyResize,B=E&&(/textarea/i).test(E.get(0).nodeName),C=B&&A.ui.hasScroll(E.get(0),"left")?0:L.sizeDiff.height,H=B?0:L.sizeDiff.width;var D={width:(L.size.width-H),height:(L.size.height-C)},G=(parseInt(L.element.css("left"),10)+(L.position.left-L.originalPosition.left))||null,J=(parseInt(L.element.css("top"),10)+(L.position.top-L.originalPosition.top))||null;L.element.animate(A.extend(D,J&&G?{top:J,left:G}:{}),{duration:F.animateDuration||"slow",easing:F.animateEasing||"swing",step:function(){var M={width:parseInt(L.element.css("width"),10),height:parseInt(L.element.css("height"),10),top:parseInt(L.element.css("top"),10),left:parseInt(L.element.css("left"),10)};if(E){E.css({width:M.width,height:M.height})}L._updateCache(M);L.propagate("animate",I)}})}});A.ui.plugin.add("resizable","ghost",{start:function(E,D){var F=D.options,B=A(this).data("resizable"),G=F.proportionallyResize,C=B.size;if(!G){B.ghost=B.element.clone()}else{B.ghost=G.clone()}B.ghost.css({opacity:0.25,display:"block",position:"relative",height:C.height,width:C.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof F.ghost=="string"?F.ghost:"");B.ghost.appendTo(B.helper)},resize:function(D,C){var E=C.options,B=A(this).data("resizable"),F=E.proportionallyResize;if(B.ghost){B.ghost.css({position:"relative",height:B.size.height,width:B.size.width})}},stop:function(D,C){var E=C.options,B=A(this).data("resizable"),F=E.proportionallyResize;if(B.ghost&&B.helper){B.helper.get(0).removeChild(B.ghost.get(0))}}});A.ui.plugin.add("resizable","alsoResize",{start:function(E,C){var F=C.options,B=A(this).data("resizable"),D=function(G){A(G).each(function(){A(this).data("resizable-alsoresize",{width:parseInt(A(this).width(),10),height:parseInt(A(this).height(),10),left:parseInt(A(this).css("left"),10),top:parseInt(A(this).css("top"),10)})})};if(typeof (F.alsoResize)=="object"){if(F.alsoResize.length){F.alsoResize=F.alsoResize[0];D(F.alsoResize)}else{A.each(F.alsoResize,function(G,H){D(G)})}}else{D(F.alsoResize)}},resize:function(F,E){var G=E.options,C=A(this).data("resizable"),D=C.originalSize,I=C.originalPosition;var H={height:(C.size.height-D.height)||0,width:(C.size.width-D.width)||0,top:(C.position.top-I.top)||0,left:(C.position.left-I.left)||0},B=function(J,K){A(J).each(function(){var N=A(this).data("resizable-alsoresize"),M={},L=K&&K.length?K:["width","height","top","left"];A.each(L||["width","height","top","left"],function(O,Q){var P=(N[Q]||0)+(H[Q]||0);if(P&&P>=0){M[Q]=P||null}});A(this).css(M)})};if(typeof (G.alsoResize)=="object"){A.each(G.alsoResize,function(J,K){B(J,K)})}else{B(G.alsoResize)}},stop:function(C,B){A(this).removeData("resizable-alsoresize-start")}})})(jQuery) \ No newline at end of file