changeset 166:1c97d42f787f

Add "Help > About" navbar menu Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024639.html
author Andrew Azores <aazores@redhat.com>
date Wed, 23 Aug 2017 10:12:01 -0400
parents d805dbe67564
children 9726d75909c1
files src/app/components/about/about.controller.js src/app/components/about/about.controller.spec.js src/app/components/about/about.html src/app/components/about/about.module.js src/app/components/about/about.routing.js src/app/components/about/about.routing.spec.js src/app/components/about/en.locale.yaml src/app/en.locale.yaml src/app/index.html
diffstat 9 files changed, 330 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/about/about.controller.js	Wed Aug 23 10:12:01 2017 -0400
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * Thermostat is distributed under the GNU General Public License,
+ * version 2 or any later version (with a special exception described
+ * below, commonly known as the "Classpath Exception").
+ *
+ * A copy of GNU General Public License (GPL) is included in this
+ * distribution, in the file COPYING.
+ *
+ * Linking Thermostat code with other modules is making a combined work
+ * based on Thermostat.  Thus, the terms and conditions of the GPL
+ * cover the whole combination.
+ *
+ * As a special exception, the copyright holders of Thermostat give you
+ * permission to link this code with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on Thermostat code.  If you modify Thermostat, you may
+ * extend this exception to your version of the software, but you are
+ * not obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+import services from 'shared/services/services.module.js';
+
+class AboutController {
+  constructor ($scope, authService) {
+    $scope.username = authService.username;
+  }
+}
+
+export default angular
+  .module('about.controller', [
+    services
+  ])
+  .controller('AboutController', AboutController)
+  .name;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/about/about.controller.spec.js	Wed Aug 23 10:12:01 2017 -0400
@@ -0,0 +1,59 @@
+/**
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * Thermostat is distributed under the GNU General Public License,
+ * version 2 or any later version (with a special exception described
+ * below, commonly known as the "Classpath Exception").
+ *
+ * A copy of GNU General Public License (GPL) is included in this
+ * distribution, in the file COPYING.
+ *
+ * Linking Thermostat code with other modules is making a combined work
+ * based on Thermostat.  Thus, the terms and conditions of the GPL
+ * cover the whole combination.
+ *
+ * As a special exception, the copyright holders of Thermostat give you
+ * permission to link this code with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on Thermostat code.  If you modify Thermostat, you may
+ * extend this exception to your version of the software, but you are
+ * not obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+import controllerModule from './about.controller.js';
+
+describe('AboutController', () => {
+
+  let ctrl, authSvc, scope;
+  beforeEach(() => {
+    angular.mock.module(controllerModule);
+    angular.mock.inject(($controller, $rootScope) => {
+      'ngInject';
+
+      authSvc = {
+        username: 'fake-username'
+      };
+      scope = $rootScope.$new();
+
+      ctrl = $controller('AboutController', {
+        authService: authSvc,
+        $scope: scope
+      });
+    });
+  });
+
+  it('should exist', () => {
+    should.exist(ctrl);
+  });
+
+  it('should set username from authService', () => {
+    scope.should.have.ownProperty('username');
+    scope.username.should.equal(authSvc.username);
+  });
+
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/about/about.html	Wed Aug 23 10:12:01 2017 -0400
@@ -0,0 +1,22 @@
+<div class="container container-cards-pf">
+  <div class="col-md-12">
+    <div class="row">
+      <div class="col-md-3 hidden-sm hidden-xs">
+        <img src="~images/landing-image.png"/>
+      </div>
+      <div class="col-md-9">
+        <h1><a ui-sref="landing">Thermostat</a></h1>
+        <h2 translate>about.ABOUT</h2>
+        <p translate>about.OVERVIEW</p>
+        <h2 translate>about.VERSION</h2>
+        <dl class="dl-horizontal">
+          <dt translate>about.WEB_CLIENT</dt>
+          <dd translate>CLIENT_VERSION</dd>
+        </dl>
+        <p translate>about.DOCUMENTATION</p>
+        <h2 translate>about.ACCOUNT</h2>
+        <p translate="about.ACCOUNT_DETAIL" translate-values="{ username: username }"></p>
+      </div>
+    </div>
+  </div>
+</div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/about/about.module.js	Wed Aug 23 10:12:01 2017 -0400
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * Thermostat is distributed under the GNU General Public License,
+ * version 2 or any later version (with a special exception described
+ * below, commonly known as the "Classpath Exception").
+ *
+ * A copy of GNU General Public License (GPL) is included in this
+ * distribution, in the file COPYING.
+ *
+ * Linking Thermostat code with other modules is making a combined work
+ * based on Thermostat.  Thus, the terms and conditions of the GPL
+ * cover the whole combination.
+ *
+ * As a special exception, the copyright holders of Thermostat give you
+ * permission to link this code with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on Thermostat code.  If you modify Thermostat, you may
+ * extend this exception to your version of the software, but you are
+ * not obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+import controller from './about.controller.js';
+
+export default angular
+  .module('aboutModule', [
+    controller
+  ])
+  .name;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/about/about.routing.js	Wed Aug 23 10:12:01 2017 -0400
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * Thermostat is distributed under the GNU General Public License,
+ * version 2 or any later version (with a special exception described
+ * below, commonly known as the "Classpath Exception").
+ *
+ * A copy of GNU General Public License (GPL) is included in this
+ * distribution, in the file COPYING.
+ *
+ * Linking Thermostat code with other modules is making a combined work
+ * based on Thermostat.  Thus, the terms and conditions of the GPL
+ * cover the whole combination.
+ *
+ * As a special exception, the copyright holders of Thermostat give you
+ * permission to link this code with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on Thermostat code.  If you modify Thermostat, you may
+ * extend this exception to your version of the software, but you are
+ * not obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+function config ($stateProvider) {
+  'ngInject';
+
+  $stateProvider.state('about', {
+    url: '/about',
+    templateProvider: $q => {
+      'ngInject';
+      return $q(resolve =>
+        require.ensure([], () => resolve(require('./about.html'))
+        )
+      );
+    },
+    controller: 'AboutController as ctrl',
+    resolve: {
+      loadAbout: ($q, $ocLazyLoad) => {
+        'ngInject';
+        return $q(resolve => {
+          require.ensure(['./about.module.js'], () => {
+            let module = require('./about.module.js');
+            $ocLazyLoad.load({ name: module.default });
+            resolve(module);
+          });
+        });
+      }
+    }
+  });
+}
+
+export { config };
+
+export default angular
+  .module('aboutRouter', [
+    'ui.router',
+    'ui.bootstrap'
+  ])
+  .config(config)
+  .name;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/about/about.routing.spec.js	Wed Aug 23 10:12:01 2017 -0400
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * Thermostat is distributed under the GNU General Public License,
+ * version 2 or any later version (with a special exception described
+ * below, commonly known as the "Classpath Exception").
+ *
+ * A copy of GNU General Public License (GPL) is included in this
+ * distribution, in the file COPYING.
+ *
+ * Linking Thermostat code with other modules is making a combined work
+ * based on Thermostat.  Thus, the terms and conditions of the GPL
+ * cover the whole combination.
+ *
+ * As a special exception, the copyright holders of Thermostat give you
+ * permission to link this code with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under
+ * terms of your choice, provided that you also meet, for each linked
+ * independent module, the terms and conditions of the license of that
+ * module.  An independent module is a module which is not derived from
+ * or based on Thermostat code.  If you modify Thermostat, you may
+ * extend this exception to your version of the software, but you are
+ * not obligated to do so.  If you do not wish to do so, delete this
+ * exception statement from your version.
+ */
+
+describe('AboutRouting', () => {
+
+  let module = require('./about.routing.js');
+
+  let stateProvider, args, q, ocLazyLoad;
+  beforeEach(() => {
+    stateProvider = {
+      state: sinon.spy()
+    };
+    module.config(stateProvider);
+    args = stateProvider.state.args[0];
+    q = sinon.spy();
+    ocLazyLoad = {
+      load: sinon.spy()
+    };
+  });
+
+  describe('stateProvider', () => {
+    it('should call $stateProvider.state', () => {
+      stateProvider.state.should.be.calledOnce();
+    });
+
+    it('should define a \'about\' state', () => {
+      args[0].should.equal('about');
+    });
+
+    it('should map to /about', () => {
+      args[1].url.should.equal('/about');
+    });
+
+    it('template provider should return about.html', done => {
+      let providerFn = args[1].templateProvider[1];
+      providerFn.should.be.a.Function();
+      providerFn(q);
+      q.should.be.calledOnce();
+
+      let deferred = q.args[0][0];
+      deferred.should.be.a.Function();
+
+      let resolve = sinon.stub().callsFake(val => {
+        val.should.equal(require('./about.html'));
+        done();
+      });
+      deferred(resolve);
+    });
+
+    it('resolve should load about module', done => {
+      let resolveFn = args[1].resolve.loadAbout[2];
+      resolveFn.should.be.a.Function();
+      resolveFn(q, ocLazyLoad);
+      q.should.be.calledOnce();
+
+      let deferred = q.args[0][0];
+      deferred.should.be.a.Function();
+
+      let resolve = sinon.stub().callsFake(val => {
+        ocLazyLoad.load.should.be.calledWith({ name: require('./about.module.js').default});
+        val.should.equal(require('./about.module.js'));
+        done();
+      });
+      deferred(resolve);
+    });
+  });
+
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/about/en.locale.yaml	Wed Aug 23 10:12:01 2017 -0400
@@ -0,0 +1,13 @@
+about:
+  ABOUT: About
+
+  OVERVIEW: <a href="http://icedtea.classpath.org/thermostat">Thermostat</a> is a free and open source distributed instrumentation tool for the Hotspot JVM.
+
+  VERSION: Version
+
+  WEB_CLIENT: Web Client
+
+  DOCUMENTATION: The <a href="http://icedtea.classpath.org/thermostat/documentation">documentation</a> helps you learn about Thermostat and start exploring its features.
+
+  ACCOUNT: Account
+  ACCOUNT_DETAIL: You are currently logged in under the user account <strong>{{username}}</strong>.
--- a/src/app/en.locale.yaml	Wed Aug 23 10:06:42 2017 -0400
+++ b/src/app/en.locale.yaml	Wed Aug 23 10:12:01 2017 -0400
@@ -1,8 +1,12 @@
+CLIENT_VERSION: 0.1.0
+
 navbar:
   TOGGLE_NAV: Toggle Navigation
 
   HELP: Help
   HELP_URL: http://icedtea.classpath.org/thermostat/documentation
 
+  ABOUT: About
+
   USERNAME: Username
   LOGOUT: Log Out
--- a/src/app/index.html	Wed Aug 23 10:06:42 2017 -0400
+++ b/src/app/index.html	Wed Aug 23 10:12:01 2017 -0400
@@ -27,6 +27,7 @@
             </a>
             <ul class="dropdown-menu" aria-labelledby="infoDropdown">
               <li><a translate-attr="{href: 'navbar.HELP_URL'}" translate>navbar.HELP</a></li>
+              <li><a ui-sref="about" translate>navbar.ABOUT</a></li>
             </ul>
           </li>