[icinga-checkins] icinga.org: icinga-web/master: * Fixed Portlet view. Maybe persistence problems can occur

git at icinga.org git at icinga.org
Fri Jul 16 11:08:07 CEST 2010


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

Author: jmosshammer <jmosshammer at ws-jmosshammer.(none)>
Date:   Thu Jul 15 12:21:19 2010 +0200

* Fixed Portlet view. Maybe persistence problems can occur

---

 .../data/xml/icinga-host-history-template.xml      |    4 +-
 app/modules/Cronks/lib/js/grid/MetaGridCreator.js  |    9 +-
 .../System/ObjectSearchResultModel.class.php       |    3 +-
 .../Cronks/templates/System/PortalViewSuccess.php  |   93 ++++++++++++++------
 .../System/ViewProc/AjaxGridLayoutSuccess.php      |    4 +-
 5 files changed, 75 insertions(+), 38 deletions(-)

diff --git a/app/modules/Cronks/data/xml/icinga-host-history-template.xml b/app/modules/Cronks/data/xml/icinga-host-history-template.xml
index f29ff15..009c6e5 100644
--- a/app/modules/Cronks/data/xml/icinga-host-history-template.xml
+++ b/app/modules/Cronks/data/xml/icinga-host-history-template.xml
@@ -103,11 +103,11 @@
             <filter>
                 <parameter name="enabled">true</parameter>
 
-				 Filter configuration 
+<!--				 Filter configuration -->
                 <parameter name="type">extjs</parameter>
 				<parameter name="subtype">appkit.ext.filter.api</parameter>
 
-				 Operator type is needed because we don't know which type returned
+<!--				 Operator type is needed because we don't know which type returned-->
 				<parameter name="operator_type">text</parameter>
 
 				<parameter name="api_target">instance</parameter>
diff --git a/app/modules/Cronks/lib/js/grid/MetaGridCreator.js b/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
index 043ae47..d7016d0 100755
--- a/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
+++ b/app/modules/Cronks/lib/js/grid/MetaGridCreator.js
@@ -145,14 +145,14 @@ Cronk.grid.MetaGridCreator.prototype = {
 			border:				false,
 			emptyText:			"No data was found ...",
 			layout:				'fit',
-						
+
 			// Custom properties for our custom
 			// object
 			meta:				this.meta,
 			filter:				this.filter_array,
 			parentCmp:			this
 		};
-		
+
 		// Stateful handling
 		if (this.stateuid) {
 			var lmg = this;
@@ -174,7 +174,6 @@ Cronk.grid.MetaGridCreator.prototype = {
 					for (var i in o.filter_params) { e=false; break; }
 					for (var i in o.filter_types) { e=false; break; }
 					for (var i in o.store_origin_params) { e=false; break; }
-					
 					if (e == false) {
 						return o;
 					}
@@ -200,11 +199,11 @@ Cronk.grid.MetaGridCreator.prototype = {
 					
 					(reload == true) && (store.reload());
 					
-//					log(store.originParams);
-					
+//					log(store.originParams);			
 					return true;
 				}
 			});
+
 		}
 		
 		// Add the selection model:
diff --git a/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php b/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php
index ff980f7..1572330 100755
--- a/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php
+++ b/app/modules/Cronks/models/System/ObjectSearchResultModel.class.php
@@ -145,7 +145,7 @@ class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
 			IcingaPrincipalTargetTool::applyApiSecurityPrincipals($search);
 			
 			$result = $search->fetch();
-			
+
 			$count[$mapping] = $result->getResultCount();
 			$data[$mapping] = $this->resultToArray($result, $fields, $mapping);
 		}
@@ -198,6 +198,7 @@ class Cronks_System_ObjectSearchResultModel extends CronksBaseModel {
 	
 	private function resultToArray(IcingaApiResult &$res, array $fieldDef, $type) {
 		$array = array ();
+
 		foreach ($res as $oRow) {
 			$row = $oRow->getRow();
 			$tmp = array ('type' => $type);
diff --git a/app/modules/Cronks/templates/System/PortalViewSuccess.php b/app/modules/Cronks/templates/System/PortalViewSuccess.php
index c442105..640cdcf 100755
--- a/app/modules/Cronks/templates/System/PortalViewSuccess.php
+++ b/app/modules/Cronks/templates/System/PortalViewSuccess.php
@@ -36,13 +36,52 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 
 				        this.resizer.on('resize', function(oResizable, iWidth, iHeight, e) {
 				        	this.setHeight(iHeight);
-				        }, this);
+				        	
+				        }, this,{buffer:true});
 
 				        Ext.Element.prototype.createProxy=createProxyProtoType;
 
 					});
+					portlet.on('resize',function() {
+						Ext.each(portlet.findByType('container'),function(item) {
+			        		var bottomMargin = 15;
+			        		item.setHeight(portlet.getInnerHeight()-bottomMargin);
+			        	})	
+						
+					},this)
+				
+					
 				},
-
+				initPortlet : function(portlet) {
+					Cronk.Registry.add(portlet.initialConfig);
+					portlet.on('afterlayout',function(ct) {
+						AppKit.log(ct);
+				
+						var params = ct.initialConfig.params;
+						params["stateuid"] = ct.stateuid;
+						params["p[stateuid]"] = ct.stateuid,
+						params["p[parentid]"] = ct.id;
+						
+						portlet.getUpdater().setDefaultUrl({
+							url: "<?php echo $ro->gen('cronks.crloader', array('cronk' => null)); ?>"+ct.crname,
+							params: params,
+							scripts: true							
+						});
+						
+						portlet.getUpdater().refresh();
+					},this,{single:true})
+					portlet.on("add",function(el,resp) {
+						Ext.each(portlet.findByType('container'),function(item) {
+        					var bottomMargin = 8;
+        					item.setHeight(portlet.getInnerHeight()-bottomMargin);
+        					item.staef
+        				})	
+					})
+
+				
+					PortalHandler.createResizer(portlet);
+				},
+				
 				createPortletDragZone : function (p) {
 						var cdz = new Ext.dd.DropTarget(p.getEl(), {
 							ddGroup: 'cronk',
@@ -85,53 +124,50 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 
 							notifyDrop: function(dd, e, data) {
 								var params = {
-									'p[parentid]': id
+									'p[parentid]': id,
 								};
-
+								
 								if (data.dragData.parameter) {
 									for (var k in data.dragData.parameter) {
 										params['p[' + k + ']'] = data.dragData.parameter[k];
 									}
 								}
-
+								
 								var portlet  = Cronk.factory({
-									id: id,
+									id: Ext.id(),
 
-									params: data.dragData.parameter,
+									params: params,
 									crname: data.dragData.id,
-
+									stateuid: Ext.id('cronk-sid'),
 									title: data.dragData.name,
 									closable: true,
+									stateful:true,
 									xtype: 'portlet',
 									tools: tools,
 									height: 200,
 									border: true,
-
 									// Resizer properties
 									heightIncrement:16,
 								    pinned:true,
 								    duration: .6,
 								    transparent:false
+								   
 								});
-
-								PortalHandler.createResizer(portlet);
+								
+								PortalHandler.initPortlet(portlet);
 
 								// Add them to the portal
+							
 								p.items.get(this.ac || 0).add(portlet);
-
+							
 								// Bubbling render event
+
 								portlet.show();	// Needed for webkit
 								portal.doLayout();
-
-								// Redefine the updater to held default properties
-								/* portlet.getUpdater().setDefaultUrl({
-									url: "<?php echo $ro->gen('cronks.crloader', array('cronk' => null)); ?>" + data.dragData.id,
-									params: params,
-									scripts: true
-								});
-
+							
+								
 								// initial refresh
-								portlet.getUpdater().refresh(); */
+//								portlet.getUpdater().refresh();
 							}
 						});
 				},
@@ -207,7 +243,7 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 		// is a good choice
 		if (CE.stateuid) {
 			Ext.apply(portal_config, {
-				id: CE.cmpid,
+				id: Ext.id(),
 				stateId: CE.cmpid,
 				stateful: true,
 
@@ -215,7 +251,7 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 				stateEvents: ['add', 'remove', 'titlechange', 'resize'],
 
 				getState: function () {
-
+					
 					var d = new Array();
 
 					this.items.each(function (col, cindex, l1) {
@@ -225,6 +261,7 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 						col.items.each(function (cr, crindex, l2) {
 							if (Cronk.Registry.get(cr.getId())) {
 								var c = Cronk.Registry.get(cr.getId());
+							
 								c.height = cr.getHeight();
 								crlist[cr.getId()] = c;
 							}
@@ -233,7 +270,6 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 						d[cindex] = crlist;
 
 					}, this);
-
 					return {
 						col: d,
 						title: this.title
@@ -241,18 +277,18 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 				},
 
 				applyState: function (state) {
-
+				
 					// Defered execution
 					(function() {
-					
 						if (state.col) {
 							Ext.each(state.col, function (item, index, arry) {
 								Ext.iterate(item, function (key, citem, o) {
 									var c = citem;
 									c.tools = tools;
-
+									c.id = Ext.id(); // create new id, otherwise it might get ugly
 									var cronk = Cronk.factory(c);
-									PortalHandler.createResizer(cronk);
+						
+									PortalHandler.initPortlet(cronk);
 									
 									this.get(index).add(cronk);
 									cronk.show();
@@ -274,5 +310,6 @@ Cronk.util.initEnvironment("<?php echo $parentid = $rd->getParameter('parentid')
 
 		CE.insert(0, portal);
 		CE.doLayout();
+
 	});	
 </script>
\ No newline at end of file
diff --git a/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php b/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php
index 4cccc86..c30137a 100755
--- a/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php
+++ b/app/modules/Cronks/templates/System/ViewProc/AjaxGridLayoutSuccess.php
@@ -9,10 +9,10 @@ Cronk.util.initEnvironment("<?php echo $rd->getParameter('parentid'); ?>", funct
 		meta.baseURL = '<? echo $_SERVER['SERVER_NAME'].$ro->gen("icinga.home") ?>';
 		
 		var MetaGrid = new Cronk.grid.MetaGridCreator(meta);
-		MetaGrid.setStateUid(CE.stateuid);
-		
+		MetaGrid.setStateUid(CE.stateuid);	
 		MetaGrid.setStoreUrl("<?php echo $ro->gen('cronks.viewProc.json', array('template' => $rd->getParameter('template'))); ?>");
 		MetaGrid.setParameters(<?php echo json_encode($rd->getParameters()); ?>);
+
 		MetaGrid.setParameters({storeDisableAutoload: true});
 		var grid = MetaGrid.createGrid();
 		





More information about the icinga-checkins mailing list