[icinga-checkins] icinga.org: icinga-web/next: Info Box - Add Hostname in the title

git at icinga.org git at icinga.org
Mon Apr 8 17:34:43 CEST 2013


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

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Apr  8 17:32:50 2013 +0200

Info Box - Add Hostname in the title

Add title suffix creation based on host / service attributes and
add suffix function to ObjectInfo component.

fixes #3174

---

 .../lib/js/Cronk/grid/components/ObjectInfo.js     |   20 ++++++++-
 .../Cronks/lib/js/Cronk/grid/handler/Info.js       |   43 +++++++++++++++++--
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/app/modules/Cronks/lib/js/Cronk/grid/components/ObjectInfo.js b/app/modules/Cronks/lib/js/Cronk/grid/components/ObjectInfo.js
index 8458716..6665856 100644
--- a/app/modules/Cronks/lib/js/Cronk/grid/components/ObjectInfo.js
+++ b/app/modules/Cronks/lib/js/Cronk/grid/components/ObjectInfo.js
@@ -37,6 +37,8 @@ Ext.ns('Cronk.grid.components');
         width: '80%',
         height: 400,
         title: _('Object information'),
+        defaultTitle: _('Object information'),
+        prefixTitle: _('Object information for {0}'),
         closeAction: 'hide',
         layout: 'fit',
         modal: true,
@@ -149,12 +151,26 @@ Ext.ns('Cronk.grid.components');
             this.tabs.setActiveTab(this.tabItems[type].information);
             
         },
+
+        /**
+         * Sets suffix to title
+         *
+         * @param {String} suffix
+         */
+        setTitleSuffix: function(suffix) {
+            if (!suffix) {
+                this.setTitle(this.defaultTitle);
+            } else {
+                this.setTitle(String.format(this.prefixTitle, suffix));
+            }
+        },
         
         /**
          * Interface method to show the window (Event)
          */
-        showObjectInfo : function(type, oid,connection) {
-            this.fireEvent('showobjectinfo', type, oid,connection);
+        showObjectInfo : function(type, oid, connection, titleSuffix) {
+            this.fireEvent('showobjectinfo', type, oid, connection);
+            this.setTitleSuffix(titleSuffix);
         }
     }))();
 })();
\ No newline at end of file
diff --git a/app/modules/Cronks/lib/js/Cronk/grid/handler/Info.js b/app/modules/Cronks/lib/js/Cronk/grid/handler/Info.js
index d4dae03..590eb7a 100644
--- a/app/modules/Cronks/lib/js/Cronk/grid/handler/Info.js
+++ b/app/modules/Cronks/lib/js/Cronk/grid/handler/Info.js
@@ -24,22 +24,50 @@
 Ext.ns("Cronk.grid.handler");
 
 (function () {
-    
+    "use strict";
+
+    /**
+     * Static handler function
+     * @class
+     * @static
+     */
     Cronk.grid.handler.Info = {
+
+        /**
+         * Show info box for host
+         */
         host: function() {
             this.setHandlerArgs({type: "host"});
             Cronk.grid.handler.Info.show.apply(this, arguments);
         },
-        
+
+        /**
+         * Show info box for service
+         */
         service: function() {
             this.setHandlerArgs({type: "service"});
             Cronk.grid.handler.Info.show.apply(this, arguments);
         },
-        
+
+        /**
+         * Abstract show call
+         *
+         * @private
+         */
         show: function() {
             var field = this.getHandlerArgs().objectid_field || "object_id";
-            var object_id = this.getRecord().get(field);
             var type = this.getHandlerArgs().type;
+            var record = this.getRecord();
+            var object_id = record.get(field);
+            var titleSuffix = "";
+
+            if (record.get('host_name')) {
+                titleSuffix += record.get('host_name');
+            }
+
+            if (record.get('service_name') && type === 'service') {
+                titleSuffix += ' / ' + record.get('service_name');
+            }
             
             if (Ext.isEmpty(type)) {
                 throw new Error("type must be one of host or service");
@@ -49,7 +77,12 @@ Ext.ns("Cronk.grid.handler");
                 throw new Error("Could not get object_id, please configure objectid_field properly");
             }
             
-            Cronk.grid.components.ObjectInfo.showObjectInfo(type, object_id, this.getGrid().selectedConnection);
+            Cronk.grid.components.ObjectInfo.showObjectInfo(
+                type,
+                object_id,
+                this.getGrid().selectedConnection,
+                titleSuffix
+            );
         }
     };
     





More information about the icinga-checkins mailing list