[icinga-checkins] icinga.org: icinga-web/master: * Max search results 200 rows starting with minimum 4 chars (fixes #791)

git at icinga.org git at icinga.org
Thu Sep 16 17:56:26 CEST 2010


Module: icinga-web
Branch: master
Commit: e128947954273bf344d0f9f5e826c41197bd388f
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=e128947954273bf344d0f9f5e826c41197bd388f

Author: Marius Hein <marius.hein at netways.de>
Date:   Thu Sep 16 17:55:33 2010 +0200

* Max search results 200 rows starting with minimum 4 chars (fixes #791)
* Adding bin/clearcache.sh to gitignore

---

 .gitignore                                         |    1 +
 .../System/ObjectSearchResultModel.class.php       |   21 +++++++++++++------
 .../templates/System/ObjectSearchSuccess.php       |   14 ++++++++++++-
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore
index 801a678..72ba2ed 100755
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ app/data/log/
 app/config/icinga.xml
 app/config/databases.xml
 app/modules/Web/config/icinga-io.xml
+bin/clearcache.sh
 icinga-web.session
 icinga-web.webprj
 Makefile
diff --git a/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php b/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php
index 1572330..322e51a 100755
--- a/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php
+++ b/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php
@@ -1,7 +1,13 @@
 <?php
 
 class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
-
+	
+	/**
+	 * Limit search result to x rows
+	 * @var string
+	 */
+	const RESULT_LIMIT = 200;
+	
 	/**
 	 * 
 	 * @var IcingaApiConnectionIdo
@@ -38,9 +44,9 @@ class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
 		
 			'fields'		=> array (
 				'object_name'	=> 'HOST_NAME',
-				'object_id'	=> 'HOST_OBJECT_ID',
+				'object_id'		=> 'HOST_OBJECT_ID',
 				'description'	=> 'HOST_ALIAS',
-				'data1'		=> 'HOST_ADDRESS',
+				'data1'			=> 'HOST_ADDRESS',
 				'object_status'	=> 'HOST_CURRENT_STATE'
 			)
 		),
@@ -51,7 +57,7 @@ class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
 		
 			'fields'		=> array (
 				'object_name'	=> 'SERVICE_NAME',
-				'object_id'	=> 'SERVICE_OBJECT_ID',
+				'object_id'		=> 'SERVICE_OBJECT_ID',
 				'object_name2'	=> 'HOST_NAME',
 				'description'	=> 'SERVICE_DISPLAY_NAME',
 				'object_status'	=> 'SERVICE_CURRENT_STATE'
@@ -65,7 +71,7 @@ class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
 		
 			'fields'		=> array (
 				'object_name'	=> 'HOSTGROUP_NAME',
-				'object_id'	=> 'HOSTGROUP_OBJECT_ID',
+				'object_id'		=> 'HOSTGROUP_OBJECT_ID',
 				'description'	=> 'HOSTGROUP_ALIAS'
 			)
 		),
@@ -76,7 +82,7 @@ class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
 		
 			'fields'		=> array (
 				'object_name'	=> 'SERVICEGROUP_NAME',
-				'object_id'	=> 'SERVICEGROUP_OBJECT_ID',
+				'object_id'		=> 'SERVICEGROUP_OBJECT_ID',
 				'description'	=> 'SERVICEGROUP_ALIAS'
 			)
 		),
@@ -139,7 +145,8 @@ class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
 			->setSearchTarget($md['target'])
 			->setResultColumns(array_values($md['fields']))
 			->setSearchFilter($md['search'], $this->query, IcingaApi::MATCH_LIKE)
-			->setResultType(IcingaApi::RESULT_ARRAY);
+			->setResultType(IcingaApi::RESULT_ARRAY)
+			->setSearchLimit(0, self::RESULT_LIMIT);
 			
 			// Limiting results for security
 			IcingaPrincipalTargetTool::applyApiSecurityPrincipals($search);
diff --git a/app/modules/Cronks/templates/System/ObjectSearchSuccess.php b/app/modules/Cronks/templates/System/ObjectSearchSuccess.php
index 970b7aa..59964b8 100755
--- a/app/modules/Cronks/templates/System/ObjectSearchSuccess.php
+++ b/app/modules/Cronks/templates/System/ObjectSearchSuccess.php
@@ -3,6 +3,12 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 	
 	var oSearchHandler =  function() {
 		
+		/**
+		 * Start search if minimum x chars entered
+		 * @type Integer
+		 */	
+		var minCharacters = 4;
+		
 		var val;
 		var ctWindow;
 		var proxy;
@@ -192,7 +198,13 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 			 */
 			keyup : function(field, e) {
 				val = field.getValue();
-				if (val && val.length >= 1) {
+				
+				// 27 == ESC
+				if (e.getCharCode() == 27) {
+					field.setValue('');
+					oWindow().hide();
+				}
+				else if (!Ext.isEmpty(val) && val.length >= minCharacters) {
 					if (!oWindow().isVisible()) {
 						var xy = field.getPosition();
 						xy[0] += field.getSize().width + 55;





More information about the icinga-checkins mailing list