changeset 175:e10e61e34baf

Convert jvm-list to component Reviewed-by: almac Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024763.html
author Andrew Azores <aazores@redhat.com>
date Thu, 31 Aug 2017 08:40:56 -0400
parents 62bcc6165e77
children 6c3ce29d353f
files src/app/components/jvm-list/jvm-list.component.js src/app/components/jvm-list/jvm-list.html src/app/components/jvm-list/jvm-list.module.js src/app/components/jvm-list/jvm-list.routing.js src/app/components/jvm-list/jvm-list.routing.spec.js
diffstat 5 files changed, 51 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/components/jvm-list/jvm-list.component.js	Thu Aug 31 08:40:56 2017 -0400
@@ -0,0 +1,42 @@
+/**
+ * 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 jvmListController from './jvm-list.controller.js';
+import jvmListService from './jvm-list.service.js';
+import systemInfoService from 'components/system-info/system-info.service.js';
+
+export default angular
+  .module('jvmListComponent', [
+    jvmListController,
+    jvmListService,
+    systemInfoService
+  ])
+  .component('jvmList', {
+    controller: 'JvmListController',
+    template: require('./jvm-list.html')
+  })
+  .name;
--- a/src/app/components/jvm-list/jvm-list.html	Fri Aug 25 10:10:30 2017 -0400
+++ b/src/app/components/jvm-list/jvm-list.html	Thu Aug 31 08:40:56 2017 -0400
@@ -3,11 +3,11 @@
     <li><a ui-sref="landing">Thermostat</a></li>
     <li><a ui-sref="jvmList" translate>jvmList.BREADCRUMB</a></li>
   </ol>
-  <div class="jvmList-container" ng-controller="JvmListController as controller">
+  <div class="jvmList-container">
     <div class="text-right">
       <label for="aliveOnlySwitch" class="label label-default" translate>jvmList.ALIVE_ONLY</label>
       <input class="bootstrap-switch pull-right" id="aliveOnlyState" name="aliveOnlySwitch" data-size="mini" type="checkbox" checked/>
-      <button type="button" class="btn btn-default" id="refreshButton" ng-click="controller.loadData()"><span class="fa fa-refresh"></span></button>
+      <button type="button" class="btn btn-default" id="refreshButton" ng-click="$ctrl.loadData()"><span class="fa fa-refresh"></span></button>
     </div>
     <div class="pfToolbar col-md-12">
       <pf-toolbar id="jvmListToolbar" config="toolbarConfig"></pf-toolbar>
--- a/src/app/components/jvm-list/jvm-list.module.js	Fri Aug 25 10:10:30 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/**
- * 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 JvmListController from './jvm-list.controller.js';
-import jvmListService from './jvm-list.service.js';
-import systemInfoService from 'components/system-info/system-info.service.js';
-
-export default angular
-  .module('jvmList', [
-    JvmListController,
-    jvmListService,
-    systemInfoService,
-  ])
-  .name;
--- a/src/app/components/jvm-list/jvm-list.routing.js	Fri Aug 25 10:10:30 2017 -0400
+++ b/src/app/components/jvm-list/jvm-list.routing.js	Thu Aug 31 08:40:56 2017 -0400
@@ -30,20 +30,13 @@
 
   $stateProvider.state('jvmList', {
     url: '/jvm-list',
-    templateProvider: $q => {
-      'ngInject';
-      return $q(resolve =>
-        require.ensure([], () => resolve(require('./jvm-list.html'))
-        )
-      );
-    },
-    controller: 'JvmListController as ctrl',
+    component: 'jvmList',
     resolve: {
-      loadJvmList: ($q, $ocLazyLoad) => {
+      lazyLoad: ($q, $ocLazyLoad) => {
         'ngInject';
         return $q(resolve => {
-          require.ensure(['./jvm-list.module.js'], () => {
-            let module = require('./jvm-list.module.js');
+          require.ensure(['./jvm-list.component.js'], () => {
+            let module = require('./jvm-list.component.js');
             $ocLazyLoad.load({ name: module.default });
             resolve(module);
           });
--- a/src/app/components/jvm-list/jvm-list.routing.spec.js	Fri Aug 25 10:10:30 2017 -0400
+++ b/src/app/components/jvm-list/jvm-list.routing.spec.js	Thu Aug 31 08:40:56 2017 -0400
@@ -55,24 +55,8 @@
       args[1].url.should.equal('/jvm-list');
     });
 
-    it('template provider should return jvm-list.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('./jvm-list.html'));
-        done();
-      });
-      deferred(resolve);
-    });
-
-    it('resolve should load jvm-list module', done => {
-      let resolveFn = args[1].resolve.loadJvmList[2];
+    it('resolve should load jvm-list component', done => {
+      let resolveFn = args[1].resolve.lazyLoad[2];
       resolveFn.should.be.a.Function();
       resolveFn(q, ocLazyLoad);
       q.should.be.calledOnce();
@@ -81,7 +65,7 @@
       deferred.should.be.a.Function();
 
       let resolve = sinon.stub().callsFake(val => {
-        let mod = require('./jvm-list.module.js');
+        let mod = require('./jvm-list.component.js');
         ocLazyLoad.load.should.be.calledWith({ name: mod.default });
         val.should.equal(mod);
         done();