qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eal...@apache.org
Subject [qpid-dispatch] 02/02: DISPATCH-1376 Read product name from config file
Date Mon, 05 Aug 2019 17:12:33 GMT
This is an automated email from the ASF dual-hosted git repository.

eallen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit b6828b55256428ab5077727591fded82f6002504
Author: Ernest Allen <eallen@redhat.com>
AuthorDate: Mon Aug 5 13:11:35 2019 -0400

    DISPATCH-1376 Read product name from config file
---
 console/CMakeLists.txt                      |  1 +
 console/stand-alone/index.html              |  4 +-
 console/stand-alone/main.js                 | 14 ++++-
 console/stand-alone/plugin/css/dispatch.css |  3 +
 console/stand-alone/plugin/js/qdrAbout.js   | 89 +++++++++++++++++------------
 console/stand-alone/plugin/js/qdrGlobals.js | 63 +++++++++++++++-----
 6 files changed, 119 insertions(+), 55 deletions(-)

diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt
index 7bdb481..efc4992 100644
--- a/console/CMakeLists.txt
+++ b/console/CMakeLists.txt
@@ -79,6 +79,7 @@ if(CONSOLE_INSTALL)
             ${CONSOLE_SOURCE_DIR}/index.html
             ${CONSOLE_SOURCE_DIR}/main.js
             ${CONSOLE_SOURCE_DIR}/favicon-32x32.png
+            ${CONSOLE_SOURCE_DIR}/console-config.json
           )
           ## Files copied to the img/ dir
           set(IMAGES
diff --git a/console/stand-alone/index.html b/console/stand-alone/index.html
index c4fb2ab..6c7b50d 100644
--- a/console/stand-alone/index.html
+++ b/console/stand-alone/index.html
@@ -23,7 +23,7 @@ under the License.
     <meta charset="utf-8" />
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Apache Qpid Dispatch Console</title>
+    <title></title>
 
     <link rel="shortcut icon" type="image/png" href="favicon-32x32.png" sizes="32x32"
/>
 
@@ -55,7 +55,7 @@ under the License.
                 <span class="icon-bar"></span>
                 <span class="icon-bar"></span>
             </button>
-            <span class="logo"><img src="img/console_logo.png" /></span>
+            <span class="logo">{{console_logo}}</span>
             <div class="masthead-icons">
                 <div class="about" ng-controller="QDR.AboutController" title="About this
console">
                     <span class="fa fa-question-circle-o" ng-click="open()"></span>
diff --git a/console/stand-alone/main.js b/console/stand-alone/main.js
index ce9759d..474349b 100644
--- a/console/stand-alone/main.js
+++ b/console/stand-alone/main.js
@@ -30,7 +30,9 @@ under the License.
 import {
   QDRLogger,
   QDRTemplatePath,
-  QDR_LAST_LOCATION
+  QDR_LAST_LOCATION,
+  QDR_CONSOLE_TITLE,
+  getConfigVars
 } from "./plugin/js/qdrGlobals.js";
 import { QDRService } from "./plugin/js/qdrService.js";
 import { QDRChartService } from "./plugin/js/qdrChartService.js";
@@ -276,8 +278,8 @@ import { posint } from "./plugin/js/posintDirective.js";
       $scope.topLevelTabs = [];
       $scope.topLevelTabs.push({
         id: "qdr",
-        content: "Qpid Dispatch Router Console",
-        title: "Dispatch Router Console",
+        content: document.title,
+        title: document.title,
         isValid: function() {
           return true;
         },
@@ -297,6 +299,12 @@ import { posint } from "./plugin/js/posintDirective.js";
     $timeout,
     QDRService
   ) {
+    $scope.console_logo = "";
+    getConfigVars().then(response => {
+      $timeout(function() {
+        $scope.console_logo = `${response.company} ${response.product} Console`;
+      });
+    });
     $scope.alerts = [];
     $scope.breadcrumb = {};
     $scope.closeAlert = function(index) {
diff --git a/console/stand-alone/plugin/css/dispatch.css b/console/stand-alone/plugin/css/dispatch.css
index 0c79e1b..8e66859 100644
--- a/console/stand-alone/plugin/css/dispatch.css
+++ b/console/stand-alone/plugin/css/dispatch.css
@@ -1663,6 +1663,9 @@ svg {
   span.logo {
     letter-spacing: 2px;
     font-weight: bold;
+    color: white;
+    margin: 8px;
+    display: inline-block;
   }
   
   /* using fancytree instead of treeview */
diff --git a/console/stand-alone/plugin/js/qdrAbout.js b/console/stand-alone/plugin/js/qdrAbout.js
index 9d72138..c81b2ab 100644
--- a/console/stand-alone/plugin/js/qdrAbout.js
+++ b/console/stand-alone/plugin/js/qdrAbout.js
@@ -17,54 +17,73 @@ specific language governing permissions and limitations
 under the License.
 */
 
+import { QDR_CONSOLE_TITLE, QDR_CONSOLE_COPYRIGHT } from "./qdrGlobals.js";
+
 export class AboutController {
   constructor($scope, QDRService, $timeout) {
-    this.controllerName = 'QDR.AboutController';
+    this.controllerName = "QDR.AboutController";
 
-    $scope.additionalInfo = "Console for the Apache Qpid dispatch router: A high-performance,
lightweight AMQP 1.0 message router, written in C and built on Qpid Proton. It provides flexible
and scalable interconnect between any AMQP endpoints, whether they be clients, brokers or
other AMQP-enabled services.";
-    $scope.copyright = "Apache License, Version 2.0";
-    $scope.imgAlt = "Qpid Dispatch Router Logo";
+    $scope.additionalInfo = `Console for the ${QDR_CONSOLE_TITLE}: A high-performance, lightweight
AMQP 1.0 message router, written in C and built on Qpid Proton. It provides flexible and scalable
interconnect between any AMQP endpoints, whether they be clients, brokers or other AMQP-enabled
services.`;
+    $scope.copyright = QDR_CONSOLE_COPYRIGHT;
+    $scope.imgAlt = QDR_CONSOLE_TITLE;
     $scope.imgSrc = "img/logo-alt.svg";
-    $scope.title = "Apache Qpid Dispatch Router Console";
+    $scope.title = QDR_CONSOLE_TITLE;
     $scope.productInfo = [
-      { name: 'Version', value: '<not connected>' },
-      { name: 'Server Name', value: window.location.host },
-      { name: 'User Name', value: '<not connected>' },
-      { name: 'User Role', value: 'Administrator' }];
-    $scope.open = function () {
+      { name: "Version", value: "<not connected>" },
+      { name: "Server Name", value: window.location.host },
+      { name: "User Name", value: "<not connected>" },
+      { name: "User Role", value: "Administrator" }
+    ];
+    $scope.open = function() {
       if (QDRService.management.connection.is_connected()) {
-        let parts = QDRService.management.connection.getReceiverAddress().split("/");
+        let parts = QDRService.management.connection
+          .getReceiverAddress()
+          .split("/");
         parts[parts.length - 1] = "$management";
-        let router = parts.join('/');
-        QDRService.management.topology.fetchEntity(router, "router", ["version"], function
(nodeId, entity, response) {
-          $timeout(function () {
-            let r = QDRService.utilities.flatten(response.attributeNames, response.results[0]);
-            $scope.productInfo[0].value = r.version;
-          });
-        });
-        QDRService.management.topology.fetchEntity(router, "connection", [], function (nodeId,
entity, response) {
-          $timeout(function () {
-            let user = '<unknown>';
-            response.results.some(result => {
-              let c = QDRService.utilities.flatten(response.attributeNames, result);
-              if (QDRService.utilities.isConsole(c)) {
-                user = c.user;
-                return true;
-              }
-              return false;
+        let router = parts.join("/");
+        QDRService.management.topology.fetchEntity(
+          router,
+          "router",
+          ["version"],
+          function(nodeId, entity, response) {
+            $timeout(function() {
+              let r = QDRService.utilities.flatten(
+                response.attributeNames,
+                response.results[0]
+              );
+              $scope.productInfo[0].value = r.version;
             });
-            $scope.productInfo[2].value = user;
-          });
-        });
-
+          }
+        );
+        QDRService.management.topology.fetchEntity(
+          router,
+          "connection",
+          [],
+          function(nodeId, entity, response) {
+            $timeout(function() {
+              let user = "<unknown>";
+              response.results.some(result => {
+                let c = QDRService.utilities.flatten(
+                  response.attributeNames,
+                  result
+                );
+                if (QDRService.utilities.isConsole(c)) {
+                  user = c.user;
+                  return true;
+                }
+                return false;
+              });
+              $scope.productInfo[2].value = user;
+            });
+          }
+        );
       }
       $scope.isOpen = true;
     };
-    $scope.onClose = function () {
+    $scope.onClose = function() {
       $scope.isOpen = false;
     };
-
   }
 }
 
-AboutController.$inject = ['$scope', 'QDRService', '$timeout'];
+AboutController.$inject = ["$scope", "QDRService", "$timeout"];
diff --git a/console/stand-alone/plugin/js/qdrGlobals.js b/console/stand-alone/plugin/js/qdrGlobals.js
index 42f5ee3..e599b6d 100644
--- a/console/stand-alone/plugin/js/qdrGlobals.js
+++ b/console/stand-alone/plugin/js/qdrGlobals.js
@@ -17,7 +17,8 @@ specific language governing permissions and limitations
 under the License.
 */
 
-export var QDRFolder = (function () {
+/* globals Promise */
+export var QDRFolder = (function() {
   function Folder(title) {
     this.title = title;
     this.children = [];
@@ -25,7 +26,7 @@ export var QDRFolder = (function () {
   }
   return Folder;
 })();
-export var QDRLeaf = (function () {
+export var QDRLeaf = (function() {
   function Leaf(title) {
     this.title = title;
   }
@@ -33,27 +34,59 @@ export var QDRLeaf = (function () {
 })();
 
 export var QDRCore = {
-  notification: function (severity, msg) {
+  notification: function(severity, msg) {
     $.notify(msg, severity);
   }
 };
 
 export class QDRLogger {
   constructor($log, source) {
-    this.log = function (msg) { $log.log(`QDR-${source}: ${msg}`); };
-    this.debug = function (msg) { $log.debug(`QDR-${source}: ${msg}`); };
-    this.error = function (msg) { $log.error(`QDR-${source}: ${msg}`); };
-    this.info = function (msg) { $log.info(`QDR-${source}: ${msg}`); };
-    this.warn = function (msg) { $log.warn(`QDR-${source}: ${msg}`); };
+    this.log = function(msg) {
+      $log.log(`QDR-${source}: ${msg}`);
+    };
+    this.debug = function(msg) {
+      $log.debug(`QDR-${source}: ${msg}`);
+    };
+    this.error = function(msg) {
+      $log.error(`QDR-${source}: ${msg}`);
+    };
+    this.info = function(msg) {
+      $log.info(`QDR-${source}: ${msg}`);
+    };
+    this.warn = function(msg) {
+      $log.warn(`QDR-${source}: ${msg}`);
+    };
   }
 }
 
-export const QDRTemplatePath = 'html/';
-export const QDR_SETTINGS_KEY = 'QDRSettings';
-export const QDR_LAST_LOCATION = 'QDRLastLocation';
-export const QDR_INTERVAL = 'QDRInterval';
+export const QDRTemplatePath = "html/";
+export const QDR_SETTINGS_KEY = "QDRSettings";
+export const QDR_LAST_LOCATION = "QDRLastLocation";
+export const QDR_INTERVAL = "QDRInterval";
 
-export var QDRRedirectWhenConnected = function ($location, org) {
-  $location.path('/connect');
-  $location.search('org', org);
+export var QDRRedirectWhenConnected = function($location, org) {
+  $location.path("/connect");
+  $location.search("org", org);
 };
+
+export var QDR_CONSOLE_TITLE = "Console";
+export var QDR_ROUTER_NAME = "Router";
+export var QDR_CONSOLE_COPYRIGHT = "Copyright 2019";
+
+export var getConfigVars = () =>
+  new Promise((resolve, reject) => {
+    $.getJSON("console-config.json", function() {}).done(function(s) {
+      console.log(
+        `got x-stream text ${s.title} - ${s.router} - ${s.copyright}`
+      );
+      document.title = s.title;
+      QDR_CONSOLE_TITLE = `${s.company} ${s.product} Console`;
+      QDR_ROUTER_NAME = `${s.company} ${s.product} Router`;
+      QDR_CONSOLE_COPYRIGHT = `Copyright 2019 ${s.company}`;
+      resolve(s);
+    });
+  });
+
+$(document).ready(function(e) {
+  getConfigVars();
+});


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message