[icinga-checkins] icinga.org: icinga-web/mfriedrich/default: Added field displaying current servertime to indicate timezone errors to menu

git at icinga.org git at icinga.org
Fri Aug 26 13:13:30 CEST 2011


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

Author: Jannis Moßhanner <jannis.mosshammer at netways.de>
Date:   Fri Aug 26 12:42:06 2011 +0200

Added field displaying current servertime to indicate timezone errors to menu

---

 .../AppKit/actions/ServertimeAction.class.php      |   16 +++++++++
 app/modules/AppKit/cache/Servertime.xml            |   11 ++++++
 app/modules/AppKit/config/javascript.xml           |    2 +
 app/modules/AppKit/config/routing.xml              |    2 +-
 app/modules/AppKit/lib/js/AppKitErrorHandler.js    |    2 +-
 app/modules/AppKit/lib/js/AppKitNavBar.js          |   19 +++++++++--
 .../AppKit/lib/js/utils/AppKitServertime.js        |   33 ++++++++++++++++++++
 app/modules/AppKit/templates/ServertimeSuccess.php |    6 +++
 app/modules/AppKit/validate/Servertime.xml         |   15 +++++++++
 .../AppKit/views/ServertimeSuccessView.class.php   |   13 ++++++++
 10 files changed, 113 insertions(+), 6 deletions(-)

diff --git a/app/modules/AppKit/actions/ServertimeAction.class.php b/app/modules/AppKit/actions/ServertimeAction.class.php
new file mode 100644
index 0000000..752083b
--- /dev/null
+++ b/app/modules/AppKit/actions/ServertimeAction.class.php
@@ -0,0 +1,16 @@
+<?php
+
+class AppKit_ServertimeAction extends AppKitBaseAction
+{
+	
+	public function getDefaultViewName()
+	{
+		return 'Success';
+	}
+    
+    public function isSimple() {
+        return true;
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/app/modules/AppKit/cache/Servertime.xml b/app/modules/AppKit/cache/Servertime.xml
new file mode 100644
index 0000000..058a8ee
--- /dev/null
+++ b/app/modules/AppKit/cache/Servertime.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ae:configurations xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0" xmlns="http://agavi.org/agavi/config/parts/caching/1.0">
+	
+	<ae:configuration>
+		
+		<caching enabled="false">
+		</caching>
+		
+	</ae:configuration>
+	
+</ae:configurations>
\ No newline at end of file
diff --git a/app/modules/AppKit/config/javascript.xml b/app/modules/AppKit/config/javascript.xml
index 32393e8..14fcaea 100644
--- a/app/modules/AppKit/config/javascript.xml
+++ b/app/modules/AppKit/config/javascript.xml
@@ -11,6 +11,8 @@
             <ae:parameter>%core.module_dir%/AppKit/lib/js/AppKit.js</ae:parameter>
             <ae:parameter>%core.module_dir%/AppKit/lib/js/AppKitUtil.js</ae:parameter>
             <ae:parameter>%core.module_dir%/AppKit/lib/js/utils/stacktrace.js</ae:parameter>
+            <ae:parameter>%core.module_dir%/AppKit/lib/js/utils/AppKitServertime.js</ae:parameter>
+
             <ae:parameter>%core.module_dir%/AppKit/lib/js/AppKitErrorHandler.js</ae:parameter>
 
             <ae:parameter>%core.module_dir%/AppKit/lib/js/Layout.js</ae:parameter>
diff --git a/app/modules/AppKit/config/routing.xml b/app/modules/AppKit/config/routing.xml
index 543fadb..92d5ae0 100644
--- a/app/modules/AppKit/config/routing.xml
+++ b/app/modules/AppKit/config/routing.xml
@@ -6,7 +6,7 @@
 
 			<!-- * AppKit routes -->
 			<route name=".appkit" pattern="^/appkit" module="%actions.default_module%">
-				<!-- check if the webserver is dead -->
+                <route name="servertime" pattern="^/servertime" action="Servertime"  output_type="simple"/>
 				<route name="ping" pattern="^/ping" action="Ping" />
                 <route name=".dispatcher" pattern="^/dispatch" action="Dispatcher" output_type="json" /> 
 				<route name=".login" pattern="^/login" action="%actions.login_action%">
diff --git a/app/modules/AppKit/lib/js/AppKitErrorHandler.js b/app/modules/AppKit/lib/js/AppKitErrorHandler.js
index 347a4fb..0ce8f7d 100755
--- a/app/modules/AppKit/lib/js/AppKitErrorHandler.js
+++ b/app/modules/AppKit/lib/js/AppKitErrorHandler.js
@@ -296,7 +296,7 @@ Ext.ns("AppKit.errorHandler");
 					break;
 				case 404:
 					AppKit.AjaxErrorHandler.error_404(proxy.url);
-					break;
+					break;new E
 				case 401:
 					AppKit.AjaxErrorHandler.error_401(proxy.url);
 					break;
diff --git a/app/modules/AppKit/lib/js/AppKitNavBar.js b/app/modules/AppKit/lib/js/AppKitNavBar.js
index 2618bc5..ba75ec6 100644
--- a/app/modules/AppKit/lib/js/AppKitNavBar.js
+++ b/app/modules/AppKit/lib/js/AppKitNavBar.js
@@ -15,13 +15,13 @@ AppKit.util.AppKitNavBar = Ext.extend(Ext.Container,{
         layout: 'column',
 	    id: 'menu',
 	    border: false,
-	    defaults: { style: { borderLeft: '1px #d0d0d0 solid' }, border: false, height: 40 }
+	    defaults: {style: {borderLeft: '1px #d0d0d0 solid'}, border: false, height: 40}
     },
 
     // default config for the menubar field
     tbarCfg: {
     	id: 'menu-navigation',
-		defaults: { border: false, style: 'margin:2px' },
+		defaults: {border: false, style: 'margin:2px'},
 		style: 'border: none',	
         height: 35,
         items: {},
@@ -48,6 +48,7 @@ AppKit.util.AppKitNavBar = Ext.extend(Ext.Container,{
         if(Ext.getCmp(this.defaultCfg.id))
             throw("Menubar is already loaded");   
         Ext.apply(this,cfg); 
+       
         this.buildNavBar();
         this.buildIconField();
         Ext.apply(cfg,this.defaultCfg);
@@ -102,9 +103,18 @@ AppKit.util.AppKitNavBar = Ext.extend(Ext.Container,{
     initMenuItems : function(cfg) {
         cfg.items = [];
         this.addMenuFields(cfg.items,this.menuData); 
+        cfg.items.push({xtype : 'tbfill'});
+        this.addClock(cfg.items);
+
         this.addUserFields(cfg.items);
     },
 
+    addClock : function(itemsCfg) {
+        var item = new AppKit.util.Servertime();
+        AppKit.log(item)
+        itemsCfg.push({xtype: 'container',items:item});
+    },
+
     addMenuFields : function(itemsCfg,menuData) {
        
         for(var i=0;i<menuData.length;i++) {
@@ -145,7 +155,7 @@ AppKit.util.AppKitNavBar = Ext.extend(Ext.Container,{
                     }
                 }
 
-            case 'window': 
+            case 'window':
                 target.bodyStyle = target.style || "background-color: #ffffff";
                 return Ext.createDelegate(AppKit.util.contentWindow, this, [{
                     url: target.url
@@ -154,12 +164,13 @@ AppKit.util.AppKitNavBar = Ext.extend(Ext.Container,{
     },
 
     addUserFields : function(itemsCfg) { 
-        itemsCfg.push({xtype : 'tbfill'});
+        
         var userField = {
             iconCls: this.hasAuth ? 'icinga-icon-user' : 'icinga-icon-user-delete',
             text: this.username
         }
         if(this.hasAuth) {
+            
             userField.menu = {};
             userField.menu.items = {
                 xtype: 'buttongroup',
diff --git a/app/modules/AppKit/lib/js/utils/AppKitServertime.js b/app/modules/AppKit/lib/js/utils/AppKitServertime.js
new file mode 100644
index 0000000..8f14f0b
--- /dev/null
+++ b/app/modules/AppKit/lib/js/utils/AppKitServertime.js
@@ -0,0 +1,33 @@
+/* 
+ * Little widget that displays the currents servertime
+ * 
+ */
+Ext.ns('AppKit.util');
+
+AppKit.util.Servertime = Ext.extend(Ext.menu.BaseItem, {
+    TIME_URL: '/modules/appkit/servertime',
+    updateClock: function () {
+        this.getEl().getUpdater().showLoadIndicator = false;
+       
+        this.getEl().load({
+            url:AppKit.c.path+this.TIME_URL
+        });
+    },
+    constructor: function(cfg) {
+        cfg = cfg || {};
+        Ext.TaskMgr.start({
+            run: this.updateClock,
+            interval: 10000,
+            scope:this
+        });
+        cfg.style = {margin : "3px"};
+        Ext.menu.BaseItem.prototype.constructor.call(this,cfg);
+        
+   },
+   // private
+   onRender : function(container, position){
+        Ext.menu.BaseItem.superclass.onRender.apply(this, arguments);
+    }
+    
+});
+
diff --git a/app/modules/AppKit/templates/ServertimeSuccess.php b/app/modules/AppKit/templates/ServertimeSuccess.php
new file mode 100644
index 0000000..258f7e0
--- /dev/null
+++ b/app/modules/AppKit/templates/ServertimeSuccess.php
@@ -0,0 +1,6 @@
+<div>
+Servertime:
+<?php
+    echo date("H:i:s");
+?>
+</div>
\ No newline at end of file
diff --git a/app/modules/AppKit/validate/Servertime.xml b/app/modules/AppKit/validate/Servertime.xml
new file mode 100644
index 0000000..c75f597
--- /dev/null
+++ b/app/modules/AppKit/validate/Servertime.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ae:configurations
+	xmlns="http://agavi.org/agavi/config/parts/validators/1.0"
+	xmlns:ae="http://agavi.org/agavi/config/global/envelope/1.0"
+	parent="%core.module_dir%/AppKit/config/validators.xml"
+>
+	
+	<ae:configuration>
+		
+		<validators>
+		</validators>
+		
+	</ae:configuration>
+	
+</ae:configurations>
\ No newline at end of file
diff --git a/app/modules/AppKit/views/ServertimeSuccessView.class.php b/app/modules/AppKit/views/ServertimeSuccessView.class.php
new file mode 100644
index 0000000..56c8792
--- /dev/null
+++ b/app/modules/AppKit/views/ServertimeSuccessView.class.php
@@ -0,0 +1,13 @@
+<?php
+
+class AppKit_ServertimeSuccessView extends AppKitBaseView
+{
+	public function executeSimple(AgaviRequestDataHolder $rd)
+	{
+		$this->setupHtml($rd);
+		
+		$this->setAttribute('_title', 'Servertime');
+	}
+}
+
+?>
\ No newline at end of file





More information about the icinga-checkins mailing list