[icinga-checkins] icinga.org: icinga-web/jmosshammer/default: * Added new api options for GET Request, enabled CORS Requests

git at icinga.org git at icinga.org
Mon Sep 20 17:58:13 CEST 2010


Module: icinga-web
Branch: jmosshammer/default
Commit: 74c3dd2eba4ea5ec3281ba8b603cef56d040c105
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=74c3dd2eba4ea5ec3281ba8b603cef56d040c105

Author: jmosshammer <jmosshammer at ws-jmosshammer.(none)>
Date:   Mon Sep 20 17:57:41 2010 +0200

* Added new api options for GET Request, enabled CORS Requests

---

 app/config/routing.xml                             |   12 +++--
 .../AppKit/lib/menu/AppKitMenuCreator.class.php    |   40 ++++++++++----------
 app/modules/Cronks/lib/js/grid/ColumnRenderer.js   |    3 +-
 app/modules/Web/validate/Icinga/ApiSearch.xml      |   13 +++---
 pub/index.php                                      |    8 ++++
 5 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/app/config/routing.xml b/app/config/routing.xml
index b8d8963..8c0c03b 100755
--- a/app/config/routing.xml
+++ b/app/config/routing.xml
@@ -74,7 +74,7 @@
 				<route pattern="^$" action="User.Index"/>
 
 				<route name=".preferences" pattern="^/preferences">
-					<route pattern="^$" action="User.Preferences" output_type="simple" />
+					<route pattern="^$" action="User.Preferences" output_type="simple"/>
 				</route>
 			</route>
 			<!-- END: My -->
@@ -90,14 +90,14 @@
 				<route name=".about" pattern="^/about$" action="Icinga.Help" output_type="html"/>
 
 				<!-- The main view -->
-				<route name=".portalView" pattern="^/portal$" action="Icinga.PortalView" />
+				<route name=".portalView" pattern="^/portal$" action="Icinga.PortalView"/>
 				<route name=".customPortal" pattern="^/customPortal" action="Icinga.PortalView" stop="true">
-					<route name=".crbase"  pattern="/cr_base=(cr_base:[^/]*)" stop="false"/>
+					<route name=".crbase" pattern="/cr_base=(cr_base:[^/]*)" stop="false"/>
 					<route name=".groupDir" pattern="/groupDir=(groupDir:(ASC|DESC))" stop="false"/>
 					<route name=".groupField" pattern="/groupField=(groupField:[^/]*)" stop="false"/>
 					<route name=".template" pattern="/template=(template:[^/]*)" stop="false"/>
 					<route name=".crname" pattern="/crname=(crname:[^/]*)" stop="false"/>
-					<route name=".title" pattern="/title=(title:[^/]*)" stop="false" />
+					<route name=".title" pattern="/title=(title:[^/]*)" stop="false"/>
 				
 				</route>
 				<!-- TestPage -->
@@ -116,6 +116,8 @@
 						<route name=".column" stop="false" pattern="columns[(columns:(.*?))]"/>
 						<route name=".order" stop="false" pattern="order[(order_col:\w*);(order_dir:\w*)]"/>
 						<route name=".limit" stop="false" pattern="limit[({limit_start:\d*};)?(limit:\d*)]"/>												
+						<route name=".countcolumn" stop="false" pattern="countColumn=(countColumn:\w*)"/>
+						<route name=".withMeta" stop="false" pattern="withMeta=(withMeta:\d)"/>
 						<route name=".output" stop="true" pattern="(output:json|xml|soap)$" output_type="${output}">
 						<ignores>
 							<ignore>output</ignore>
@@ -174,7 +176,7 @@
 			</route>
 			<!-- END: Cronk -->
 
-		 </routes>
+		</routes>
 	</ae:configuration>
 	
 	<ae:configuration context="soap">
diff --git a/app/modules/AppKit/lib/menu/AppKitMenuCreator.class.php b/app/modules/AppKit/lib/menu/AppKitMenuCreator.class.php
index 6d50e5f..e173f4d 100755
--- a/app/modules/AppKit/lib/menu/AppKitMenuCreator.class.php
+++ b/app/modules/AppKit/lib/menu/AppKitMenuCreator.class.php
@@ -70,10 +70,10 @@ class AppKitMenuCreator extends AppKitEventHandler implements AppKitEventHandler
 
 			$user = self::getUser();
 
-			$nav->getContainer()->addItem(AppKitNavItem::create('appkit', 'index_page')
-			->setCaption('Home')
-			->addAttributes('extjs-iconcls', 'icinga-icon-application')
-			);
+//			$nav->getContainer()->addItem(AppKitNavItem::create('appkit', 'index_page')
+//			->setCaption('Home')
+//			->addAttributes('extjs-iconcls', 'icinga-icon-application')
+//			);
 
 			//Add more homelinks
 			if (is_array($home_links = AgaviConfig::get('org.icinga.appkit.home_links'))) {
@@ -83,22 +83,22 @@ class AppKitMenuCreator extends AppKitEventHandler implements AppKitEventHandler
 					);
 				}
 			}
-
-			// Display only if we do not trust apache
-			// if (!AppKitFactories::getInstance()->getFactory('AuthProvider') instanceof AppKitAuthProviderHttpBasic) {
-				if ($user->isAuthenticated()) {
-					$nav->getContainer()->addSubItem('appkit', AppKitNavItem::create('appkit.logout', 'appkit.logout')
-					->setCaption('Logout')
-					->addAttributes('extjs-iconcls', 'icinga-icon-lock-open')
-					);
-				}
-				else {
-					$nav->getContainer()->addSubItem('appkit', AppKitNavItem::create('appkit.login', 'appkit.login')
-					->setCaption('Login')
-					->addAttributes('extjs-iconcls', 'icinga-icon-lock')
-					);
-				}
-			// }
+//
+//			// Display only if we do not trust apache
+//			// if (!AppKitFactories::getInstance()->getFactory('AuthProvider') instanceof AppKitAuthProviderHttpBasic) {
+//				if ($user->isAuthenticated()) {
+//					$nav->getContainer()->addSubItem('appkit', AppKitNavItem::create('appkit.logout', 'appkit.logout')
+//					->setCaption('Logout')
+//					->addAttributes('extjs-iconcls', 'icinga-icon-lock-open')
+//					);
+//				}
+//				else {
+//					$nav->getContainer()->addSubItem('appkit', AppKitNavItem::create('appkit.login', 'appkit.login')
+//					->setCaption('Login')
+//					->addAttributes('extjs-iconcls', 'icinga-icon-lock')
+//					);
+//				}
+//			// }
 
 			if ($user->isAuthenticated()) {
 				
diff --git a/app/modules/Cronks/lib/js/grid/ColumnRenderer.js b/app/modules/Cronks/lib/js/grid/ColumnRenderer.js
index 91047e3..d46ce8c 100755
--- a/app/modules/Cronks/lib/js/grid/ColumnRenderer.js
+++ b/app/modules/Cronks/lib/js/grid/ColumnRenderer.js
@@ -96,7 +96,8 @@ Cronk.grid.ColumnRenderer = {
 				return '[no image defined (attr=image)]';
 			}
 			else {
-				return String.format('<img src="{0}/{1}"{1} />', AppKit.c.path, my.image, (flat_attr && " " + flat_attr + " "));
+				var imgName = new Ext.XTemplate(my.image).apply(record.data);
+				return String.format('<img src="{0}/{1}"{1} />', AppKit.c.path, imgName, (flat_attr && " " + flat_attr + " "));
 			}
 		}
 	},
diff --git a/app/modules/Web/validate/Icinga/ApiSearch.xml b/app/modules/Web/validate/Icinga/ApiSearch.xml
index e818f08..3aff89e 100755
--- a/app/modules/Web/validate/Icinga/ApiSearch.xml
+++ b/app/modules/Web/validate/Icinga/ApiSearch.xml
@@ -106,8 +106,12 @@
 					<error></error>
 				</errors>
 				<ae:parameter name="export">filters</ae:parameter>
-			</validator>	
-				
+			</validator>
+			
+			<validator name="withMeta" class="set" required="false">
+				<argument>withMeta</argument>
+
+			</validator>
 		</validators>
 		
 		<validators method="read">
@@ -181,10 +185,7 @@
 				<arguments base="idProperty" />
 			</validator>
 			
-			<validator name="withMeta" class="set" required="false">
-				<argument>withMeta</argument>
-
-			</validator>	
+			
 		</validators>
 		
 	</ae:configuration>
diff --git a/pub/index.php b/pub/index.php
index 413276c..a94bc33 100755
--- a/pub/index.php
+++ b/pub/index.php
@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * Allow XHR access from other domains (response for cors preflight requests)
+ */
+header("Access-Control-Allow-Origin: *");
+header("Access-Control-Allow-Methods:POST GET UPDATE");
+header("Access-Control-Allow-Headers: x-requested-with");
+header("Access-Control-Max-Age: 720000");
+
 // +---------------------------------------------------------------------------+
 // | An absolute filesystem path to the agavi/agavi.php script.                |
 // +---------------------------------------------------------------------------+





More information about the icinga-checkins mailing list