From c1685e188d265042ff69734f6e3f63b9557d6697 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Thu, 19 Jul 2012 14:32:34 +0000 Subject: [PATCH] 2012-07-19 Sergio Martin * pandoradb.sql pandoradb.postgreSQL.sql pandoradb.oracle.sql extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql godmode/modules/manage_network_components_form.php godmode/modules/manage_network_components.php godmode/modules/manage_network_components_form_plugin.php: Added to plugin components the macro fields and modify database schemma git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6791 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 +++++ .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql | 13 +---- .../pandoradb_migrate_4.0.x_to_5.0.oracle.sql | 14 +---- ...doradb_migrate_4.0.x_to_5.0.postgreSQL.sql | 13 +---- .../modules/manage_network_components.php | 27 ++++++++- .../manage_network_components_form.php | 1 + .../manage_network_components_form_plugin.php | 56 +++++++++++++++++++ pandora_console/pandoradb.oracle.sql | 14 +---- pandora_console/pandoradb.postgreSQL.sql | 16 +----- pandora_console/pandoradb.sql | 14 +---- 10 files changed, 107 insertions(+), 74 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 163cd8f6cb..cd95f588a2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2012-07-19 Sergio Martin + + * pandoradb.sql + pandoradb.postgreSQL.sql + pandoradb.oracle.sql + extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql + extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql + extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql + godmode/modules/manage_network_components_form.php + godmode/modules/manage_network_components.php + godmode/modules/manage_network_components_form_plugin.php: Added + to plugin components the macro fields and modify database schemma + 2012-07-19 Miguel de Dios * include/javascript/pandora.js: fixed the doc header for the diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql index c861e63243..07bfb707b0 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql @@ -274,18 +274,7 @@ WHERE `token`= 'prominent_time'; ALTER TABLE tnetwork_component ADD `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard'; ALTER TABLE tnetwork_component ADD `only_metaconsole` tinyint(1) unsigned default '0'; -ALTER TABLE tnetwork_component ADD `field1_desc` text; -ALTER TABLE tnetwork_component ADD `field1_help` text; -ALTER TABLE tnetwork_component ADD `field2_desc` text; -ALTER TABLE tnetwork_component ADD `field2_help` text; -ALTER TABLE tnetwork_component ADD `field3_desc` text; -ALTER TABLE tnetwork_component ADD `field3_help` text; -ALTER TABLE tnetwork_component ADD `field4_desc` text; -ALTER TABLE tnetwork_component ADD `field4_help` text; -ALTER TABLE tnetwork_component ADD `field5_desc` text; -ALTER TABLE tnetwork_component ADD `field5_help` text; -ALTER TABLE tnetwork_component ADD `field6_desc` text; -ALTER TABLE tnetwork_component ADD `field6_help` text; +ALTER TABLE tnetwork_component ADD `macros` text; -- ----------------------------------------------------- -- Table `tagente_modulo` diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql index b2f784a263..7fa3619169 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql @@ -277,18 +277,8 @@ WHERE token='prominent_time'; ALTER TABLE tnetwork_component ADD (wizard_level VARCHAR2(100) default 'custom' NOT NULL); ALTER TABLE tnetwork_component ADD CONSTRAINT t_network_component_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','custom','nowizard')); ALTER TABLE tnetwork_component ADD (only_metaconsole NUMBER(5, 0) default 0 NOT NULL); -ALTER TABLE tnetwork_component ADD (field1_desc CLOB default ''); -ALTER TABLE tnetwork_component ADD (field1_help CLOB default ''); -ALTER TABLE tnetwork_component ADD (field2_desc CLOB default ''); -ALTER TABLE tnetwork_component ADD (field2_help CLOB default ''); -ALTER TABLE tnetwork_component ADD (field3_desc CLOB default ''); -ALTER TABLE tnetwork_component ADD (field3_help CLOB default ''); -ALTER TABLE tnetwork_component ADD (field4_desc CLOB default ''); -ALTER TABLE tnetwork_component ADD (field4_help CLOB default ''); -ALTER TABLE tnetwork_component ADD (field5_desc CLOB default ''); -ALTER TABLE tnetwork_component ADD (field5_help CLOB default ''); -ALTER TABLE tnetwork_component ADD (field6_desc CLOB default ''); -ALTER TABLE tnetwork_component ADD (field6_help CLOB default ''); +ALTER TABLE tnetwork_component ADD (macros CLOB default ''); + -- ----------------------------------------------------- -- Table `tagente_modulo` diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql index 0b9cbc1727..0e92a8b0d8 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql @@ -266,18 +266,7 @@ WHERE "token"='prominent_time'; CREATE TYPE type_tnetwork_component_wizard_level AS ENUM ('basic','advanced','custom','nowizard'); ALTER TABLE "tnetwork_component" ADD COLUMN "wizard_level" type_tnetwork_component_wizard_level default 'nowizard'; ALTER TABLE "tnetwork_component" ADD COLUMN "only_metaconsole" INTEGER default '0'; -ALTER TABLE "tnetwork_component" ADD COLUMN "field1_desc" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field1_help" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field2_desc" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field2_help" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field3_desc" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field3_help" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field4_desc" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field4_help" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field5_desc" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field5_help" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field6_desc" TEXT default ''; -ALTER TABLE "tnetwork_component" ADD COLUMN "field6_help" TEXT default ''; +ALTER TABLE "tnetwork_component" ADD COLUMN "macros" TEXT default ''; -- ----------------------------------------------------- -- Table `tagente_modulo` diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index d529127728..eef80103cb 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -46,6 +46,28 @@ $id_group = (int) get_parameter ('id_group'); $plugin_user = (string) get_parameter ('plugin_user'); $plugin_pass = (string) get_parameter ('plugin_pass'); $plugin_parameter = (string) get_parameter ('plugin_parameter'); + +$i = 1; +$macros = array(); +while(1) { + $macro = (string)get_parameter ('field'.$i.'_macro'); + if($macro == '') { + break; + } + + $desc = (string)get_parameter ('field'.$i.'_desc'); + $help = (string)get_parameter ('field'.$i.'_help'); + $value = (string)get_parameter ('field'.$i.'_value'); + + $macros[$i]['macro'] = $macro; + $macros[$i]['desc'] = $desc; + $macros[$i]['help'] = $help; + $macros[$i]['value'] = $value; + $i++; +} + +$macros = json_encode($macros); + $max_timeout = (int) get_parameter ('max_timeout'); $id_modulo = (int) get_parameter ('id_component_type'); $id_plugin = (int) get_parameter ('id_plugin'); @@ -129,6 +151,7 @@ if ($create_component) { 'plugin_user' => $plugin_user, 'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter, + 'macros' => $macros, 'max_timeout' => $max_timeout, 'history_data' => $history_data, 'min_warning' => $min_warning, @@ -199,6 +222,7 @@ if ($update_component) { 'plugin_user' => $plugin_user, 'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter, + 'macros' => $macros, 'max_timeout' => $max_timeout, 'history_data' => $history_data, 'min_warning' => $min_warning, @@ -312,6 +336,7 @@ $url = ui_get_url_refresh (array ('offset' => false, 'plugin_user' => false, 'plugin_pass' => false, 'plugin_parameter' => false, + 'macros' => false, 'max_timeout' => false, 'id_modulo' => false, 'id_plugin' => false, @@ -444,4 +469,4 @@ function check_all_checkboxes() { $(".check_delete").attr('checked', false); } } - \ No newline at end of file + diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index cc9637b775..b3414ce6a3 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -47,6 +47,7 @@ if (isset ($id)) { $plugin_user = $component["plugin_user"]; $plugin_pass = $component["plugin_pass"]; $plugin_parameter = $component["plugin_parameter"]; + $macros = $component["macros"]; $max_timeout = $component["max_timeout"]; $min_warning = $component["min_warning"]; $max_warning = $component["max_warning"]; diff --git a/pandora_console/godmode/modules/manage_network_components_form_plugin.php b/pandora_console/godmode/modules/manage_network_components_form_plugin.php index a8cba43847..9885e48521 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_plugin.php +++ b/pandora_console/godmode/modules/manage_network_components_form_plugin.php @@ -52,5 +52,61 @@ $data[3] = html_print_input_text ('post_process', $post_process, '', 12, 25, tru push_table_row ($data, 'plugin_3'); + +$data = array (); +$data[0] = __('Plugin macros'); +$data[0] .= ui_print_help_icon ('plugin_macros', true); +$data[1] = $data[2] = $data[3] = ''; + +push_table_row ($data, 'plugin_4'); + +$macros = json_decode($macros,true); +// The next row number is plugin_5 +$next_name_number = 5; +for($i=1;$i<=6;$i++) { + $macro_desc_name = 'field'.$i.'_desc'; + $macro_desc_value = ''; + $macro_help_name = 'field'.$i.'_help'; + $macro_help_value = ''; + $macro_value_name = 'field'.$i.'_value'; + $macro_value_value = ''; + $macro_name_name = 'field'.$i.'_macro'; + $macro_name = '_field'.$i.'_'; + + if(isset($macros[$i]['desc'])) { + $macro_desc_value = $macros[$i]['desc']; + } + + if(isset($macros[$i]['help'])) { + $macro_help_value = $macros[$i]['help']; + } + + if(isset($macros[$i]['value'])) { + $macro_value_value = $macros[$i]['value']; + } + + $data = array (); + $data[0] = sprintf(__('Macro %s description'),$macro_name); + $data[0] .= ui_print_help_tip (sprintf(__('Field that will replace the macro %s in Plug-in parameters'),$macro_name), true); + $data[0] .= html_print_input_hidden($macro_name_name, $macro_name, true); + $data[1] = html_print_input_text ($macro_desc_name, $macro_desc_value, '', 30, 255, true); + $data[2] = sprintf(__('Macro %s default value'),$macro_name); + $data[2] .= ui_print_help_tip (sprintf(__('Default value for the macro %s'),$macro_name), true); + $data[3] = html_print_input_text ($macro_value_name, $macro_value_value, '', 30, 255, true); + + push_table_row ($data, 'plugin_'.$next_name_number); + $next_name_number++; + + $table->colspan['plugin_'.$next_name_number][1] = 3; + + $data = array (); + $data[0] = sprintf(__('Macro %s help'),$macro_name); + $data[0] .= ui_print_help_tip (sprintf(__('Help that will appear near %s'),$macro_name), true); + $data[1] = html_print_input_text ($macro_help_name, $macro_help_value, '', 100, 255, true); + + push_table_row ($data, 'plugin_'.$next_name_number); + $next_name_number++; +} + ?> diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 87cf077d82..71a9fef796 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -209,6 +209,7 @@ CREATE TABLE tagente_modulo ( custom_integer_1 NUMBER(10, 0) default 0, custom_integer_2 NUMBER(10, 0) default 0, wizard_level VARCHAR2(100) default 'nowizard' NOT NULL, + macros CLOB default '', CONSTRAINT t_agente_modulo_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','custom','nowizard')) ); CREATE INDEX tagente_modulo_id_agente_idx ON tagente_modulo(id_agente); @@ -651,18 +652,7 @@ CREATE TABLE tnetwork_component ( unit CLOB default '', wizard_level VARCHAR2(100) default 'nowizard' NOT NULL, only_metaconsole NUMBER(5, 0) default 0 NOT NULL, - field1_desc CLOB default '', - field1_help CLOB default '', - field2_desc CLOB default '', - field2_help CLOB default '', - field3_desc CLOB default '', - field3_help CLOB default '', - field4_desc CLOB default '', - field4_help CLOB default '', - field5_desc CLOB default '', - field5_help CLOB default '', - field6_desc CLOB default '', - field6_help CLOB default '', + macros CLOB default '', CONSTRAINT t_network_component_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','custom','nowizard')) ); diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index dd38635023..7e25003099 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -188,7 +188,8 @@ CREATE TABLE "tagente_modulo" ( "custom_string_3" text default '', "custom_integer_1" INTEGER default 0, "custom_integer_2" INTEGER default 0, - "wizard_level" type_tagente_modulo_wizard_level default 'nowizard' + "wizard_level" type_tagente_modulo_wizard_level default 'nowizard', + "macros" TEXT default '' ); CREATE INDEX "tagente_modulo_id_agente_idx" ON "tagente_modulo"("id_agente"); CREATE INDEX "tagente_modulo_id_tipo_modulo_idx" ON "tagente_modulo"("id_tipo_modulo"); @@ -519,18 +520,7 @@ CREATE TABLE "tnetwork_component" ( "unit" TEXT default '', "wizard_level" type_tlocal_component_wizard_level default 'nowizard', "only_metaconsole" INTEGER default '0', - "field1_desc" TEXT default '', - "field1_help" TEXT default '', - "field2_desc" TEXT default '', - "field2_help" TEXT default '', - "field3_desc" TEXT default '', - "field3_help" TEXT default '', - "field4_desc" TEXT default '', - "field4_help" TEXT default '', - "field5_desc" TEXT default '', - "field5_help" TEXT default '', - "field6_desc" TEXT default '', - "field6_help" TEXT default '' + "macros" TEXT default '' ); CREATE TABLE "tnetwork_component_group" ( diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index e717707123..7a0ee31922 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -190,6 +190,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` ( `custom_integer_1` int(10) default 0, `custom_integer_2` int(10) default 0, `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard', + `macros` text, PRIMARY KEY (`id_agente_modulo`), KEY `main_idx` (`id_agente_modulo`,`id_agente`), KEY `tam_agente` (`id_agente`), @@ -571,18 +572,7 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` ( `unit` text, `wizard_level` enum('basic','advanced','custom','nowizard') default 'nowizard', `only_metaconsole` tinyint(1) unsigned default '0', - `field1_desc` text, - `field1_help` text, - `field2_desc` text, - `field2_help` text, - `field3_desc` text, - `field3_help` text, - `field4_desc` text, - `field4_help` text, - `field5_desc` text, - `field5_help` text, - `field6_desc` text, - `field6_help` text, + `macros` text, PRIMARY KEY (`id_nc`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;