[icinga-checkins] icinga.org: icinga-web/mhein/extlayout: * Moved and cleaned up libs and namespaces 5

git at icinga.org git at icinga.org
Mon Apr 19 17:51:28 CEST 2010


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Apr 19 17:18:42 2010 +0200

* Moved and cleaned up libs and namespaces 5

---

 app/modules/AppKit/lib/js/Layout.js                |   10 +---
 app/modules/Cronks/lib/js/Cronk.js                 |   57 ++++++++++++++++---
 app/modules/Cronks/lib/js/CronkTabpanel.js         |   17 +++---
 app/modules/Cronks/lib/js/Tabhelper.js             |    4 +-
 .../Cronks/templates/System/PortalViewSuccess.php  |   32 +++--------
 .../System/ViewProc/js/IcingaGridFilterHandler.js  |    3 +-
 6 files changed, 73 insertions(+), 50 deletions(-)

diff --git a/app/modules/AppKit/lib/js/Layout.js b/app/modules/AppKit/lib/js/Layout.js
index 8018cc6..c75a4b2 100644
--- a/app/modules/AppKit/lib/js/Layout.js
+++ b/app/modules/AppKit/lib/js/Layout.js
@@ -99,18 +99,14 @@ Ext.onReady(function() {
 						columnWidth: 1,
 						border: false
 					}, {
-						html: 'TEST1',
+						html: 'User',
 						width: 100,
 						border: false
-					}, {
-						html: 'TEST2',
+					}, { 
 						width: 25,
 						height: 25,
 						border: false,
-						autoEl: {
-							tag: 'img',
-							src: '/icinga-web/images/icinga/idot-small.png'
-						}
+						autoEl: {tag: 'img', src: '/icinga-web/images/icinga/idot-small.png'}
 					}]
 				});
 				
diff --git a/app/modules/Cronks/lib/js/Cronk.js b/app/modules/Cronks/lib/js/Cronk.js
index 558ccf9..b33cb3e 100644
--- a/app/modules/Cronks/lib/js/Cronk.js
+++ b/app/modules/Cronks/lib/js/Cronk.js
@@ -23,7 +23,7 @@
 			
 			removeCci : function(config, items) {
 				Ext.each(items, function(item, index, l) {
-					if (item in config) {
+					if (Ext.isDefined(config[item])) {
 						delete(config[item]);
 					}
 				})
@@ -37,8 +37,17 @@
 			},
 			
 			factory : function(config) {
-				config.xtype = 'cronk';
-				return Ext.create(config);
+				// Apply the needed config to our cronk
+				if (Ext.isDefined(config['xtype']) && config.xtype !== 'cronk') {
+					var p = Ext.ComponentMgr.types[ config.xtype ];
+					Ext.iterate(p.prototype, function(key, val) {
+						if (Ext.isPrimitive(val)) {
+							config[key] = val;
+						}
+					})
+				}
+				
+				return new Cronk.Container(config);
 			}
 			
 		});
@@ -51,7 +60,23 @@
 	 */
 	Ext.ns('Cronk.defaults');
 	
-	Cronk.Registry = new Ext.util.MixedCollection(false);
+	Cronk.RegistryClass = function() {
+		Cronk.RegistryClass.superclass.constructor.call(this, false);
+	}
+	
+	Ext.extend(Cronk.RegistryClass, Ext.util.MixedCollection, {
+		get : function(key) {
+			var i = Cronk.RegistryClass.superclass.get.call(this, key);
+			var cronk = Ext.getCmp(i.id);
+			if (cronk) {
+				Ext.apply(i, cronk.initialCronkConfig());
+				this.replace(key, i);
+			}
+			return i;
+		}
+	});
+	
+	Cronk.Registry = new Cronk.RegistryClass();
 	
 	Cronk.defaults.SETTINGS = {
 		loaderUrl:	'web/cronks/cloader',
@@ -67,6 +92,11 @@
 		'autoLayout', 'autoRefresh'
 	];
 	
+	Cronk.defaults.CONFIG_COPY = [
+		'title', 'id', 'xtype',
+		'closable', 'draggable', 'resizable'
+	];
+	
 	/*
 	 * Cronk implementation as extjs element
 	 */
@@ -86,7 +116,9 @@
 		
 		Cronk.Container.superclass.constructor.call(this, config);
 		
-		Cronk.Registry.add(this.initialCronkConfig());
+		Cronk.Registry.add(this.initialCronkConfig(Cronk.defaults.CONFIG_COPY));
+
+		this.iscronk = true;
 
 		this.on('destroy', function(c) {
 			Cronk.Registry.removeKey(c.id);
@@ -98,10 +130,17 @@
 		cronkConfig : {},
 		cronkParams : {},
 		
-		initialCronkConfig : function() {
-			var l = {};
-			Ext.apply(l, this.orgConfig, this.cronkConfig);
-			delete(l.ownerCt);
+		initialCronkConfig : function(items) {
+			var l = this.cronkConfig;
+			
+			items = (items || Cronk.defaults.CONFIG_COPY);
+			
+			if (Ext.isArray(items)) {
+				Ext.copyTo(l, this, items);
+			}
+			
+			delete(l.loaderUrl);
+			
 			return l;
 		},
 		
diff --git a/app/modules/Cronks/lib/js/CronkTabpanel.js b/app/modules/Cronks/lib/js/CronkTabpanel.js
index 935e687..5380697 100644
--- a/app/modules/Cronks/lib/js/CronkTabpanel.js
+++ b/app/modules/Cronks/lib/js/CronkTabpanel.js
@@ -14,15 +14,17 @@ Ext.extend(Cronk.util.Tabpanel, Ext.ux.SlidingTabPanel, {
 		var cout = {};
 	
 		this.items.each(function(item, index, l) {
-			if (item.getXType() == 'cronk' && Cronk.Registry.get(item.getId())) {
+			if (Cronk.Registry.get(item.getId())) {
 				cout[item.getId()] = Cronk.Registry.get(item.getId());
 			}
 		});
 		
+		var t = this.getActiveTab();
+		
 		return {
 			cronks: cout,
 			items: this.items.getCount(),
-			active: this.getActiveTab().id
+			active: ( (t) ? t.getId() : null )
 		}
 	},
 	
@@ -32,14 +34,13 @@ Ext.extend(Cronk.util.Tabpanel, Ext.ux.SlidingTabPanel, {
 			if (state.cronks) {
 				// Adding all cronks
 				Ext.iterate(state.cronks, function(index, item, o) {
-					var c = Ext.apply({}, item);
-					delete(c.loaderUrl);
-					this.add(c);
-					
+					this.add(item);
 				}, this);
 
-				// Sets tehe active tab
-				this.setActiveTab(state.active);
+				// Sets the active tab
+				this.setActiveTab(state.active || 0);
+				
+				this.getActiveTab().doLayout();
 			}
 			
 						
diff --git a/app/modules/Cronks/lib/js/Tabhelper.js b/app/modules/Cronks/lib/js/Tabhelper.js
index 7589430..978317a 100644
--- a/app/modules/Cronks/lib/js/Tabhelper.js
+++ b/app/modules/Cronks/lib/js/Tabhelper.js
@@ -83,8 +83,8 @@ Cronk.util.CronkTabHelper = Ext.extend(Object, {
 								title: data.dragData['name'],
 								crname: data.dragData.id,
 								closable: true,
-								layout: 'fit',
-								params: data.dragData.parameter
+								params: data.dragData.parameter,
+								xtype: 'cronk'
 							});
 							
 							// Set active
diff --git a/app/modules/Cronks/templates/System/PortalViewSuccess.php b/app/modules/Cronks/templates/System/PortalViewSuccess.php
index f286b87..601985a 100644
--- a/app/modules/Cronks/templates/System/PortalViewSuccess.php
+++ b/app/modules/Cronks/templates/System/PortalViewSuccess.php
@@ -99,11 +99,9 @@
 								}
 								
 								var portlet  = Cronk.factory({
-									parentid: id,
 									id: id,
 									
 									params: data.dragData.parameter,
-									loaderUrl: "<?php echo $ro->gen('icinga.cronks.crloader', array('cronk' => null)); ?>",
 									crname: data.dragData.id,
 									
 									title: data.dragData.name,
@@ -223,33 +221,24 @@
 				
 				getState: function () {
 					
-					var d = new Array(this.items.getCount());
+					var d = new Array();
 					
 					this.items.each(function (col, cindex, l1) {
 						
-						d[cindex] = {};
+						crlist = {};
 						
 						col.items.each(function (cr, crindex, l2) {
-							
-							if (cr.iscronk && cr.iscronk == true) {
-								var c = Cronk.Registry.get(cr.cronkkey);
-								var cronk = Ext.getCmp(cr.cronkkey);
-								
-								console.log(c,cronk);
-
-								c.config.title = cronk.title;
-								c.config.height = cronk.getHeight();
-								c.config.collapsed = cronk.collapsed;
-//								console.log("COL: " + cronk.collapsed);
-								d[cindex][cronk.getId()] = c;
+							if (Cronk.Registry.get(cr.getId())) {
+								var c = Cronk.Registry.get(cr.getId());
+								c.height = cr.getHeight();
+								crlist[cr.getId()] = c;
 							}
-							
 						}, this);
 						
+						d[cindex] = crlist;
+						
 					}, this);
 					
-	//				console.log(d);
-					
 					return {
 						col: d,
 						title: this.title
@@ -264,13 +253,10 @@
 						if (state.col) {
 							Ext.each(state.col, function (item, index, arry) {
 								Ext.iterate(item, function (key, citem, o) {
-									var c = {}
-									Ext.apply(c, citem.config, citem.crconf);
-//									console.log(c);
+									var c = citem;
 									c.tools = tools;
 									
 									var cronk = Cronk.factory(c);
-									
 									PortalHandler.createResizer(cronk);
 									
 									this.get(index).add(cronk);
diff --git a/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js b/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
index 47f2df3..9868677 100644
--- a/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
+++ b/app/modules/Cronks/templates/System/ViewProc/js/IcingaGridFilterHandler.js
@@ -64,6 +64,7 @@ var IcingaGridFilterWindow = function() {
 				
 				listeners: {
 					render: function(oc) {
+						console.log(oGrid);
 						if (oGrid.filter_types) {
 							var i = 0;
 							Ext.iterate(oGrid.filter_types, function(key, item) {
@@ -214,7 +215,7 @@ var IcingaGridFilterWindow = function() {
 		
 		var tmp = oGrid.filter_types || {};
 		tmp[ record.data['fType'] ] = record.data;
-		oGrid.filter_tyes = tmp;
+		oGrid.filter_types = tmp;
 	}
 	
 	function addResctriction(type) {





More information about the icinga-checkins mailing list