From 2cdba2aa651af08f9b078837f6e26d21b76b7f23 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 14 Jul 2017 14:27:05 +0200 Subject: [PATCH] Import and Sync: add description fields fixes #1018 --- application/forms/ImportSourceForm.php | 9 +++++++++ application/forms/SyncRuleForm.php | 9 +++++++++ application/tables/ImportsourceTable.php | 4 +++- application/tables/SyncruleTable.php | 4 +++- application/views/scripts/importsource/index.phtml | 1 + application/views/scripts/syncrule/index.phtml | 1 + library/Director/Objects/ImportSource.php | 1 + library/Director/Objects/SyncRule.php | 1 + schema/mysql-migrations/upgrade_137.sql | 9 +++++++++ schema/mysql.sql | 4 +++- schema/pgsql-migrations/upgrade_137.sql | 9 +++++++++ schema/pgsql.sql | 4 +++- 12 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 schema/mysql-migrations/upgrade_137.sql create mode 100644 schema/pgsql-migrations/upgrade_137.sql diff --git a/application/forms/ImportSourceForm.php b/application/forms/ImportSourceForm.php index 8798486a..381ca89d 100644 --- a/application/forms/ImportSourceForm.php +++ b/application/forms/ImportSourceForm.php @@ -20,6 +20,15 @@ class ImportSourceForm extends DirectorObjectForm 'required' => true, )); + $this->addElement('textarea', 'description', array( + 'label' => $this->translate('Description'), + 'description' => $this->translate( + 'An extended description for this Import Source. This should explain' + . " what kind of data you're going to import from this source." + ), + 'rows' => '3', + )); + $this->addElement('select', 'provider_class', array( 'label' => $this->translate('Source Type'), 'required' => true, diff --git a/application/forms/SyncRuleForm.php b/application/forms/SyncRuleForm.php index 2c478fa7..57b7e1ae 100644 --- a/application/forms/SyncRuleForm.php +++ b/application/forms/SyncRuleForm.php @@ -29,6 +29,15 @@ class SyncRuleForm extends DirectorObjectForm 'required' => true, )); + $this->addElement('textarea', 'description', array( + 'label' => $this->translate('Description'), + 'description' => $this->translate( + 'An extended description for this Sync Rule. This should explain' + . ' what this Rule is going to accomplish.' + ), + 'rows' => '3', + )); + $this->addElement('select', 'object_type', array( 'label' => $this->translate('Object Type'), 'description' => $this->translate('Choose an object type'), diff --git a/application/tables/ImportsourceTable.php b/application/tables/ImportsourceTable.php index 86a50177..4f134d2f 100644 --- a/application/tables/ImportsourceTable.php +++ b/application/tables/ImportsourceTable.php @@ -21,6 +21,8 @@ class ImportsourceTable extends QuickTable 'provider_class' => 's.provider_class', 'import_state' => 's.import_state', 'last_error_message' => 's.last_error_message', + 'description' => 'CASE WHEN s.description IS NULL THEN s.source_name' + . " ELSE s.source_name || ': ' || s.description END", ); } @@ -33,7 +35,7 @@ class ImportsourceTable extends QuickTable { $view = $this->view(); return array( - 'source_name' => $view->translate('Source name'), + 'description' => $view->translate('Source name'), ); } diff --git a/application/tables/SyncruleTable.php b/application/tables/SyncruleTable.php index 3ac73864..d6c12234 100644 --- a/application/tables/SyncruleTable.php +++ b/application/tables/SyncruleTable.php @@ -20,6 +20,8 @@ class SyncruleTable extends QuickTable 'purge_existing' => 's.purge_existing', 'filter_expression' => 's.filter_expression', 'last_error_message' => 's.last_error_message', + 'description' => 'CASE WHEN s.description IS NULL THEN s.rule_name' + . " ELSE s.rule_name || ': ' || s.description END", ); } @@ -46,7 +48,7 @@ class SyncruleTable extends QuickTable { $view = $this->view(); return array( - 'rule_name' => $view->translate('Rule name'), + 'description' => $view->translate('Rule name'), 'object_type' => $view->translate('Object type'), ); } diff --git a/application/views/scripts/importsource/index.phtml b/application/views/scripts/importsource/index.phtml index 854161b9..6aef65b6 100644 --- a/application/views/scripts/importsource/index.phtml +++ b/application/views/scripts/importsource/index.phtml @@ -4,6 +4,7 @@
+

escape($source->description) ?>

import_state === 'unknown'): ?>

translate( "It's currently unknown whether we are in sync with this Import Source." diff --git a/application/views/scripts/syncrule/index.phtml b/application/views/scripts/syncrule/index.phtml index 393f5ed3..79d759ad 100644 --- a/application/views/scripts/syncrule/index.phtml +++ b/application/views/scripts/syncrule/index.phtml @@ -4,6 +4,7 @@

+

escape($rule->description) ?>

hasSyncProperties()): ?>

'unknown', 'last_error_message' => null, 'last_attempt' => null, + 'description' => null, ); protected $settingsTable = 'import_source_setting'; diff --git a/library/Director/Objects/SyncRule.php b/library/Director/Objects/SyncRule.php index e7dd7579..a9e006bb 100644 --- a/library/Director/Objects/SyncRule.php +++ b/library/Director/Objects/SyncRule.php @@ -27,6 +27,7 @@ class SyncRule extends DbObject 'sync_state' => 'unknown', 'last_error_message' => null, 'last_attempt' => null, + 'description' => null, ); private $sync; diff --git a/schema/mysql-migrations/upgrade_137.sql b/schema/mysql-migrations/upgrade_137.sql new file mode 100644 index 00000000..535d2bc3 --- /dev/null +++ b/schema/mysql-migrations/upgrade_137.sql @@ -0,0 +1,9 @@ +ALTER TABLE import_source + ADD COLUMN description TEXT DEFAULT NULL; + +ALTER TABLE sync_rule + ADD COLUMN description TEXT DEFAULT NULL; + +INSERT INTO director_schema_migration +(schema_version, migration_time) +VALUES (137, NOW()); diff --git a/schema/mysql.sql b/schema/mysql.sql index 95cd16c3..e1616014 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -1246,6 +1246,7 @@ CREATE TABLE import_source ( ) NOT NULL DEFAULT 'unknown', last_error_message TEXT DEFAULT NULL, last_attempt DATETIME DEFAULT NULL, + description TEXT DEFAULT NULL, PRIMARY KEY (id), INDEX search_idx (key_column) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1390,6 +1391,7 @@ CREATE TABLE sync_rule ( ) NOT NULL DEFAULT 'unknown', last_error_message TEXT DEFAULT NULL, last_attempt DATETIME DEFAULT NULL, + description TEXT DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1559,4 +1561,4 @@ CREATE TABLE icinga_user_resolved_var ( INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (136, NOW()); + VALUES (137, NOW()); diff --git a/schema/pgsql-migrations/upgrade_137.sql b/schema/pgsql-migrations/upgrade_137.sql new file mode 100644 index 00000000..220c1c3e --- /dev/null +++ b/schema/pgsql-migrations/upgrade_137.sql @@ -0,0 +1,9 @@ +ALTER TABLE import_source + ADD COLUMN description text DEFAULT NULL; + +ALTER TABLE sync_rule + ADD COLUMN description text DEFAULT NULL; + +INSERT INTO director_schema_migration + (schema_version, migration_time) + VALUES (137, NOW()); diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 121c0d04..8fa9b280 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -1377,6 +1377,7 @@ CREATE TABLE import_source ( import_state enum_sync_state NOT NULL DEFAULT 'unknown', last_error_message text NULL DEFAULT NULL, last_attempt timestamp with time zone NULL DEFAULT NULL, + description text DEFAULT NULL, PRIMARY KEY (id) ); @@ -1529,6 +1530,7 @@ CREATE TABLE sync_rule ( sync_state enum_sync_state NOT NULL DEFAULT 'unknown', last_error_message text NULL DEFAULT NULL, last_attempt timestamp with time zone NULL DEFAULT NULL, + description text DEFAULT NULL, PRIMARY KEY (id) ); @@ -1836,4 +1838,4 @@ CREATE INDEX user_resolved_var_schecksum ON icinga_user_resolved_var (checksum); INSERT INTO director_schema_migration (schema_version, migration_time) - VALUES (136, NOW()); + VALUES (137, NOW());