From 4aff5411dfa7087381d3a33bf011d537f73e7bf3 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 17 Mar 2010 19:07:49 +0000 Subject: [PATCH] 2010-03-17 Miguel de Dios * include/config_process.php, install.php: change version number. * include/functions_ui.php: add in the function "print_page_header" a read boolean item "active" in array $buttons for paint disabled. * include/functions.php: add function "get_parameterBetweenListValues" this function get a parameter for a GET or POST but between a values. * godmode/reporting/visual_console_builder.php: added new editors for visual console, now it is developing, don't afray. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2511 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 + .../reporting/visual_console_builder.php | 688 ++++++++++++++++++ pandora_console/include/config_process.php | 2 +- pandora_console/include/functions.php | 30 + pandora_console/include/functions_ui.php | 18 +- pandora_console/install.php | 2 +- 6 files changed, 745 insertions(+), 5 deletions(-) create mode 100755 pandora_console/godmode/reporting/visual_console_builder.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b39d4d3b38..05182d6055 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2010-03-17 Miguel de Dios + + * include/config_process.php, install.php: change version number. + * include/functions_ui.php: add in the function "print_page_header" a + read boolean item "active" in array $buttons for paint disabled. + * include/functions.php: add function "get_parameterBetweenListValues" this + function get a parameter for a GET or POST but between a values. + * godmode/reporting/visual_console_builder.php: added new editors for visual + console, now it is developing, don't afray. + 2010-03-17 Junichi Satoh * operation/messages/message.php : Changed strings. diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php new file mode 100755 index 0000000000..cd1aeffc44 --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -0,0 +1,688 @@ + $visualConsoleName, 'id_group' => $idGroup, 'background' => $background); + switch ($action) { + case 'update': + $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.').'

'); + } + break; + case 'save': + $idVisualConsole = process_sql_insert('tlayout', $values); + if ($idVisualConsole !== false) { + $action = 'edit'; + $statusProcessInDB = array('flag' => true, 'message' => '

'.__('Successfully created.').'

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

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

'); + } + break; + } + $visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole)); + break; + case 'edit': + $visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole)); + $visualConsoleName = $visualConsole['name']; + $idGroup = $visualConsole['id_group']; + $background = $visualConsole['background']; + break; + } + break; + case 'list_elements': + switch ($action) { + case 'edit': + $visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole)); + $visualConsoleName = $visualConsole['name']; + break; + } + break; + case 'editor': + switch ($action) { + case 'edit': + $visualConsole = get_db_row_filter('tlayout', array('id' => $idVisualConsole)); + $visualConsoleName = $visualConsole['name']; + break; + } + break; +} + +$buttons = array( + 'data' => array('active' => false, + 'text' => '' . + print_image ("images/god9.png", true, array ("title" => __('Data'))) .''), + 'list_elements' => array('active' => false, + 'text' => '' . + print_image ("images/god6.png", true, array ("title" => __('List elements'))) .''), + 'wizard' => array('active' => false, + 'text' => '' . + print_image ("images/pill.png", true, array ("title" => __('Wizard'))) .''), + 'editor' => array('active' => false, + 'text' => '' . + print_image ("images/config.png", true, array ("title" => __('Editor'))) .'')); + +if ($action == 'new') $buttons = array('data' => $buttons['data']); //Show only the data tab +$buttons[$activeTab]['active'] = true; +print_page_header(__('Visual console builder') . " " . $visualConsoleName, "", false, "visual_console_editor_" . $activeTab . "_tab", false, $buttons); + +//The source code for PAINT THE PAGE +if ($statusProcessInDB !== null) { + echo $statusProcessInDB['message']; +} + +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 "
"; + 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; +} + +?> + + + + + + + + + + + + + + + + + + diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index f7fef04dcf..26bd6a028f 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 = 'PC100310'; // Remember is YYMMDD +$build_version = 'PC10317'; // 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 56a117b1f8..bdec4bd877 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -427,6 +427,36 @@ function render_time ($lapse) { return $output; } +/** + * Get a parameter from a request between values. + * + * It checks first on post request, if there were nothing defined, it + * would return get request + * + * @param string $name key of the parameter in the $_POST or $_GET array + * @param array $values The list of values that parameter to be. + * @param mixed $default default value if the key wasn't found + * + * @return mixed Whatever was in that parameter, cleaned however + */ +function get_parameterBetweenListValues ($name, $values, $default) { + $parameter = $default; + // POST has precedence + if (isset($_POST[$name])) + $parameter = get_parameter_post ($name, $default); + + if (isset($_GET[$name])) + $parameter = get_parameter_get ($name, $default); + + foreach($values as $value) { + if ($value == $parameter) { + return $value; + } + } + + return $default; +} + /** * Get a parameter from a request. * diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 66f5fa19a9..120e714ca7 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1400,9 +1400,21 @@ function print_page_header ($title, $icon = "", $return = false, $help = "", $go if (is_array($options)) { $buffer .= ''; } diff --git a/pandora_console/install.php b/pandora_console/install.php index 6f5fd6d09c..af2177cf16 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -35,7 +35,7 @@