Split the modularity patch into smaller pieces. Add the topbar and the navigation... 23/9323/4
authorMaxime Millette-Coulombe <mmcoulombe@inocybe.com>
Fri, 25 Jul 2014 15:24:08 +0000 (11:24 -0400)
committerMaxime Millette-Coulombe <mmcoulombe@inocybe.com>
Tue, 29 Jul 2014 15:08:37 +0000 (11:08 -0400)
Now that our base code is modular, we can add module. With the navigation bar and
the top bar, we can see something on the screen.

Improve the menu helper in the NavProvider and fix some CSS bugs

Change-Id: Id9983cc21bb45c13077a53d1587ee05b448b6d16
Signed-off-by: Maxime Millette-Coulombe <mmcoulombe@inocybe.com>
20 files changed:
Gruntfile.js
bower.json
build.config.js
src/app/app.controller.js [new file with mode: 0644]
src/app/app.module.js [new file with mode: 0644]
src/app/core/core.module.js [new file with mode: 0644]
src/app/core/core.services.js [new file with mode: 0644]
src/common/layout/index.tpl.html [new file with mode: 0644]
src/common/layout/layout.module.js [new file with mode: 0644]
src/common/navigation/nav_item_template.tpl.html
src/common/navigation/navigation.controller.js [new file with mode: 0644]
src/common/navigation/navigation.module.js [new file with mode: 0644]
src/common/navigation/navigation.tpl.html
src/common/topbar/topbar.controller.js [new file with mode: 0644]
src/common/topbar/topbar.directives.js [new file with mode: 0644]
src/common/topbar/topbar.module.js [new file with mode: 0644]
src/common/topbar/topbar.services.js [new file with mode: 0644]
src/common/topbar/topbar.tpl.html
src/index.html
src/main.js [new file with mode: 0644]

index cb2fd2c5aaa33fa1657c5a1038cd01b42c291ef5..672dc9e9ed9a8dcf70aec9f8a62b0e6b2764ced9 100644 (file)
@@ -15,10 +15,8 @@ module.exports = function ( grunt ) {
   grunt.loadNpmTasks('grunt-contrib-concat');\r
   grunt.loadNpmTasks('grunt-contrib-watch');\r
   grunt.loadNpmTasks('grunt-contrib-uglify');\r
-  grunt.loadNpmTasks('grunt-contrib-coffee');\r
   grunt.loadNpmTasks('grunt-conventional-changelog');\r
   grunt.loadNpmTasks('grunt-bump');\r
-  grunt.loadNpmTasks('grunt-coffeelint');\r
   //grunt.loadNpmTasks('grunt-recess');\r
   grunt.loadNpmTasks('grunt-karma');\r
   grunt.loadNpmTasks('grunt-ngmin');\r
@@ -137,6 +135,16 @@ module.exports = function ( grunt ) {
           }\r
         ]\r
       },\r
+      copy_template: {\r
+        files: [\r
+          {\r
+            src: ['<%= app_files.templates %>'],\r
+            dest: '<%= build_dir %>/',\r
+            cwd: '.',\r
+            expand: true\r
+          }\r
+        ]\r
+      },\r
       build_vendorjs: {\r
         files: [\r
           {\r
@@ -178,17 +186,6 @@ module.exports = function ( grunt ) {
         ]\r
       },\r
 \r
-     /* build_vendor_font: {\r
-        files: [\r
-          {\r
-            src: [ '<%= vendor_files.font %>' ],\r
-            dest: '<%= build_dir %>',\r
-            cwd: '.',\r
-            expand: true\r
-          }\r
-        ]\r
-      },*/\r
-\r
       compile_font: {\r
         files: [\r
           {\r
@@ -236,26 +233,6 @@ module.exports = function ( grunt ) {
       }\r
     },\r
 \r
-    /**\r
-     * `grunt coffee` compiles the CoffeeScript sources. To work well with the\r
-     * rest of the build, we have a separate compilation task for sources and\r
-     * specs so they can go to different places. For example, we need the\r
-     * sources to live with the rest of the copied JavaScript so we can include\r
-     * it in the final build, but we don't want to include our specs there.\r
-     */\r
-    coffee: {\r
-      source: {\r
-        options: {\r
-          bare: true\r
-        },\r
-        expand: true,\r
-        cwd: '.',\r
-        src: [ '<%= app_files.coffee %>' ],\r
-        dest: '<%= build_dir %>',\r
-        ext: '.js'\r
-      }\r
-    },\r
-\r
     /**\r
      * `ng-min` annotates the sources before minifying. That is, it allows us\r
      * to code without the array syntax.\r
@@ -286,37 +263,7 @@ module.exports = function ( grunt ) {
         }\r
       }\r
     },\r
-\r
-    /**\r
-     * `recess` handles our LESS compilation and uglification automatically.\r
-     * Only our `main.less` file is included in compilation; all other files\r
-     * must be imported from this file.\r
-     */\r
-   /**recess: {\r
-      build: {\r
-        src: [ '<%= app_files.less %>' ],\r
-        dest: '<%= build_dir %>/assets/<%= pkg.name %>-<%= pkg.version %>.css',\r
-        options: {\r
-          compile: true,\r
-          compress: false,\r
-          noUnderscores: false,\r
-          noIDs: false,\r
-          zeroUnits: false\r
-        }\r
-      },\r
-      compile: {\r
-        src: [ '<%= recess.build.dest %>' ],\r
-        dest: '<%= recess.build.dest %>',\r
-        options: {\r
-          compile: true,\r
-          compress: true,\r
-          noUnderscores: false,\r
-          noIDs: false,\r
-          zeroUnits: false\r
-        }\r
-      }\r
-    }, **/\r
-\r
+      \r
       /**\r
        * `less` less plugin handles the LESS compilation and minification automatically\r
        * this has been changed to the LESS plugin from recess plugin above because of\r
@@ -376,24 +323,7 @@ module.exports = function ( grunt ) {
       },\r
       globals: {}\r
     },\r
-\r
-    /**\r
-     * `coffeelint` does the same as `jshint`, but for CoffeeScript.\r
-     * CoffeeScript is not the default in ngBoilerplate, so we're just using\r
-     * the defaults here.\r
-     */\r
-    coffeelint: {\r
-      src: {\r
-        files: {\r
-          src: [ '<%= app_files.coffee %>' ]\r
-        }\r
-      },\r
-      test: {\r
-        files: {\r
-          src: [ '<%= app_files.coffeeunit %>' ]\r
-        }\r
-      }\r
-    },\r
+   \r
 \r
     /**\r
      * HTML2JS is a Grunt plugin that takes all of your template files and\r
@@ -457,8 +387,6 @@ module.exports = function ( grunt ) {
       build: {\r
         dir: '<%= build_dir %>',\r
         src: [\r
-          '<%= vendor_files.js %>',\r
-          '<%= build_dir %>/src/**/*.js',\r
           '<%= html2js.common.dest %>',\r
           '<%= html2js.app.dest %>',\r
           '<%= vendor_files.css %>',\r
@@ -578,17 +506,6 @@ module.exports = function ( grunt ) {
         tasks: [ 'jshint:src', 'karma:unit:run', 'copy:build_appjs' ]\r
       },\r
 \r
-      /**\r
-       * When our CoffeeScript source files change, we want to run lint them and\r
-       * run our unit tests.\r
-       */\r
-      coffeesrc: {\r
-        files: [ \r
-          '<%= app_files.coffee %>'\r
-        ],\r
-        tasks: [ 'coffeelint:src', 'coffee:source', 'karma:unit:run', 'copy:build_appjs' ]\r
-      },\r
-\r
       /**\r
        * When assets are changed, copy them. Note that this will *not* copy new\r
        * files, so this is probably not very useful.\r
@@ -639,20 +556,6 @@ module.exports = function ( grunt ) {
         options: {\r
           livereload: false\r
         }\r
-      },\r
-\r
-      /**\r
-       * When a CoffeeScript unit test file changes, we only want to lint it and\r
-       * run the unit tests. We don't want to do any live reloading.\r
-       */\r
-      coffeeunit: {\r
-        files: [\r
-          '<%= app_files.coffeeunit %>'\r
-        ],\r
-        tasks: [ 'coffeelint:test', 'karma:unit:run' ],\r
-        options: {\r
-          livereload: false\r
-        }\r
       }\r
     }\r
   };\r
@@ -679,10 +582,9 @@ module.exports = function ( grunt ) {
    * The `build` task gets your app ready to run for development and testing.\r
    */\r
   grunt.registerTask( 'build', [\r
-    'clean', 'html2js', 'jshint', 'coffeelint', 'coffee', 'less:development',\r
+    'clean', 'html2js', 'jshint', 'less:development',\r
     'concat:build_css', 'copy:build_app_assets', 'copy:build_vendor_assets',\r
-    'copy:build_appjs', 'copy:build_vendorimages', 'copy:build_vendorjs', 'copy:build_vendorcss', 'karmaconfig', /*'copy:build_vendor_font',*/ 'index:build'/*, \r
-    'karma:continuous'  */\r
+    'copy:build_appjs', 'copy:copy_template', 'copy:build_vendorimages', 'copy:build_vendorjs', 'copy:build_vendorcss', 'karmaconfig', 'index:build'\r
   ]);\r
 \r
   /**\r
index 61b16ad4d11df13dd8d431a53b812c10be589bb7..c32a2a41e8a2597d09d62575c33e4af350ba235a 100644 (file)
     "angular-cookies": "1.2.16",
     "angular-sanitize": "1.2.16",
     "angular-ui-date": "latest",
-    "requirejs": "2.1.9",
+    "requirejs": "2.1.14",
     "font-awesome": "~4.0.3",
     "bootstrap": "~3.0.2",
-    "angular-ui-router": "~0.0.1",
+    "angular-ui-router": "~0.2.10",
     "angular-ui-utils": "~0.0.3",
     "d3": "~3.3.2",
     "restangular": "1.2.1",
     "angular-mocks": "1.2.16",
     "bootstrap": "~3.0.2",
     "angular-bootstrap": "~0.7.0",
-    "ng-grid": "~2.0.7"
+    "ng-grid": "~2.0.7",
+    "angularAMD": "~0.1.1",
+    "requirejs-domready": "~2.0.1",
+    "ocLazyLoad": "0.3.0",
+    "angular-css-injector": "~1.0.3"
   }
 }
index 8271571e11b83ab67e1feba119bea4166e316914..d2d06b3b3585cfeec4e4cb246196bcdf78a2a345 100644 (file)
@@ -24,14 +24,13 @@ module.exports = {
     jsunit: [ 'src/**/*.spec.js' ],\r
     js_common: [ 'src/common/**/*.js', '!src/common/**/*.spec.js', '!src/common/assets/**/*.js'  ],\r
     js_app: [ 'src/app/**/*.js', '!src/app/**/*.spec.js', '!src/app/assets/**/*.js'  ],\r
-    coffee: [ 'src/**/*.coffee', '!src/**/*.spec.coffee' ],\r
-    coffeeunit: [ 'src/**/*.spec.coffee' ],\r
 \r
     atpl: [ 'src/app/**/*.tpl.html' ],\r
     ctpl: [ 'src/common/**/*.tpl.html' ],\r
 \r
     html: [ 'src/index.html',  'src/login.html'],\r
-    less: 'src/less/main.less'\r
+    less: 'src/less/main.less',\r
+    templates: ['src/**/*.tpl.html']\r
   },\r
 \r
   /**\r
@@ -64,6 +63,13 @@ module.exports = {
       'vendor/jquery-ui/ui/jquery-ui.js',\r
       'vendor/bootstrap/js/dropdown.js',\r
       'vendor/angular/angular.js',\r
+      'vendor/requirejs/requirejs.js',\r
+      'vendor/angularAMD/angularAMD.js',\r
+      'vendor/angularAMD/ngload.js',\r
+      'vendor/requirejs-domready/domReady.js',\r
+      'vendor/ocLazyLoad/dist/ocLazyLoad.js',\r
+      'vendor/angular-css-injector/angular-css-injector.js',\r
+      'vendor/angular-route/angular-route.js',\r
       'vendor/angular-bootstrap/ui-bootstrap-tpls.min.js',\r
       'vendor/placeholders/angular-placeholders-0.0.1-SNAPSHOT.min.js',\r
       'vendor/angular-ui-router/release/angular-ui-router.js',\r
diff --git a/src/app/app.controller.js b/src/app/app.controller.js
new file mode 100644 (file)
index 0000000..025f556
--- /dev/null
@@ -0,0 +1,23 @@
+define(['app/app.module'], function (app) {
+  'use strict';
+
+  app.register.controller('AppCtrl', function ($rootScope, $state, $scope, $location) {
+    $rootScope.useMobile =
+      function() {
+       if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) ||
+           navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) ||
+           navigator.userAgent.match(/Windows Phone/i) ) {
+         return true;
+       }
+       else {
+         return false;
+       }
+    };
+
+    $scope.isCollapse = false;
+    $scope.breadcrumbs = {};
+    $scope.isState = function(name) {
+      return $state.includes(name);
+    };
+  });
+});
diff --git a/src/app/app.module.js b/src/app/app.module.js
new file mode 100644 (file)
index 0000000..1247a68
--- /dev/null
@@ -0,0 +1,55 @@
+//----Temporary-------\\
+
+// This is provided by the server.
+// The path of all *.module.js go here. They are RequireJs module
+var module = [
+  'angularAMD',
+  'app/core/core.module',
+  'angular-translate',
+  'angular-translate-loader-static-files',
+  'angular-ui-router',
+  'ocLazyLoad',
+  'angular-css-injector',
+  'common/navigation/navigation.module',
+  'common/topbar/topbar.module',
+  'common/layout/layout.module']; //needed module
+
+// The name of all angularjs module
+var e = [
+  'ui.router',
+  'oc.lazyLoad',
+  'pascalprecht.translate',
+  'angular.css.injector',
+  'app.common.nav',
+  'app.common.topbar',
+  'app.common.layout'];
+//--------------------\\
+
+define(module, function(ng) {
+  'use strict';
+
+  var app = angular.module('app', e);
+
+
+  // The overal config he is done here.
+  app.config(function ($stateProvider, $urlRouterProvider,  $ocLazyLoadProvider, $translateProvider, cssInjectorProvider) {
+
+    $urlRouterProvider.otherwise("/"); // set the default route
+
+    cssInjectorProvider.setSinglePageMode(true); // remove all added CSS files when the page change
+
+    // set the ocLazyLoader to output error and use requirejs as loader
+    $ocLazyLoadProvider.config({
+      debug: true,
+      asyncLoader: require
+    });
+
+    $translateProvider.preferredLanguage('en_US');
+  });
+
+  ng.bootstrap(app);
+
+  console.log('bootstrap done (: ');
+
+  return app;
+});
diff --git a/src/app/core/core.module.js b/src/app/core/core.module.js
new file mode 100644 (file)
index 0000000..ff27ad8
--- /dev/null
@@ -0,0 +1,15 @@
+define(['angularAMD'], function() {
+  var core = angular.module('app.core', []);
+
+  core.config(function($controllerProvider, $compileProvider, $provide) {
+    core.register = {
+      controller: $controllerProvider.register,
+      directive: $compileProvider.directive,
+      factory : $provide.factory,
+      service : $provide.service
+    };
+  });
+
+  return core;
+
+});
diff --git a/src/app/core/core.services.js b/src/app/core/core.services.js
new file mode 100644 (file)
index 0000000..68479b3
--- /dev/null
@@ -0,0 +1,173 @@
+define(['app/core/core.module', 'jquery'], function(core, $) {
+  core.provider('TopBarHelper', function TopBarHelperProvider() {
+    var ids = [];
+    var ctrls = [];
+
+    this.addToView = function(url) {
+        $.ajax({
+          url : url,
+          method: 'GET',
+          async : false
+        }).done(function(data) {
+          ids.push(data);
+        });
+    };
+
+    this.getViews = function() {
+      var template = "";
+
+      for(var i = 0; i < ids.length; ++i) {
+        template += ids[i];
+      }
+
+      return template;
+    };
+
+    this.addControllerUrl = function(url) {
+      ctrls.push(url);
+    };
+
+    this.getControllers = function() {
+      return ctrls;
+    };
+
+    this.$get = ['apiToken', function TopBarHelper(apiToken) {
+      return new TopBarHelperProvider(apiToken);
+    }];
+
+  });
+
+  core.provider('NavHelper', function() {
+    var ids = [];
+    var ctrls = [];
+    var menu = [];
+
+    function NavHelperProvider() {
+      this.addToView = function(url) {
+          $.ajax({
+            url : url,
+            method: 'GET',
+            async : false
+          }).done(function(data) {
+            ids.push(data);
+          });
+      };
+
+      this.getViews = function() {
+        var template = "";
+
+        for(var i = 0; i < ids.length; ++i) {
+          template += ids[i];
+        }
+
+        return template;
+      };
+
+      this.addControllerUrl = function(url) {
+        ctrls.push(url);
+      };
+
+      this.getControllers = function() {
+        return ctrls;
+      };
+
+      getMenuWithId = function(menu, level) {
+        if(menu === undefined) {
+          return null;
+        }
+        var currentLevel = level[0];
+
+        var menuItem = $.grep(menu, function(item) {
+          return item.id == currentLevel;
+        })[0];
+
+        if (level.length === 1) {
+          return menuItem;
+        } else {
+          return getMenuWithId(menuItem.submenu, level.slice(1));
+        }
+      };
+
+      this.addToMenu = function(id, obj) {
+        var lvl = id.split(".");
+        obj["id"] = lvl.pop();
+
+        if (lvl.length === 0) {
+          menu.push(obj);
+        } else {
+          var menuItem = getMenuWithId(menu, lvl);
+
+        if(menuItem) {
+          if(!menuItem.submenu) {
+            menuItem.submenu = [];
+          }
+          menuItem.submenu.push(obj);
+        } else {
+           var submenu = {
+              "id" : lvl[0],
+              "title" : lvl[0],
+              "active" : "",
+              "submenu" : [obj]
+            };
+            menu.push(submenu);
+          }
+        }
+      };
+
+      this.getMenu = function() {
+        return menu;
+      };
+
+      this.$get =  function NavHelperFactory() {
+        return new NavHelperProvider();
+      };
+    }
+    var persistentProvider = new NavHelperProvider();
+
+    return persistentProvider;
+
+   });
+
+  core.provider('ContentHelper', function() {
+    var ids = [];
+    var ctrls = [];
+
+    function ContentHelperProvider() {
+      this.addToView = function(url) {
+          $.ajax({
+            url : url,
+            method: 'GET',
+            async : false
+          }).done(function(data) {
+            ids.push(data);
+          });
+      };
+
+      this.getViews = function() {
+        var template = "";
+
+        for(var i = 0; i < ids.length; ++i) {
+          template += ids[i];
+        }
+
+        return template;
+      };
+
+      this.addControllerUrl = function(url) {
+        ctrls.push(url);
+      };
+
+      this.getControllers = function() {
+        return ctrls;
+      };
+
+      this.$get =  function ContentHelperFactory() {
+        return new ContentHelperProvider();
+      };
+    }
+    var persistentProvider = new ContentHelperProvider();
+
+    return persistentProvider;
+
+   });
+});
diff --git a/src/common/layout/index.tpl.html b/src/common/layout/index.tpl.html
new file mode 100644 (file)
index 0000000..150f152
--- /dev/null
@@ -0,0 +1,28 @@
+
+      <div ui-view="topbar"></div>
+      <div id="red"></div>
+      <div id="gray"></div>
+      <div ui-view="navigation"></div>
+
+      <div id="page-wrapper">
+        <div class="row">
+          <div class="col-lg-12">
+            <div id="topology"></div>
+            <!--<h1 ng-bind="title">
+
+                  <small>
+                    <i class="icon-double-angle-right"></i>
+                    <span ng-bind="description"></span>
+                  </small>
+                </h1>-->
+          </div>
+        </div>
+        <div class="row content-row">
+
+          <div class="col-xs-12" style="margin-bottom: 50px" ui-view="content">
+            <!-- PAGE CONTENT BEGINS -->
+          </div><!-- /.col -->
+        </div><!-- /.row -->
+      </div><!-- /.page-content -->
+    </div><!-- /.main-content -->
+
diff --git a/src/common/layout/layout.module.js b/src/common/layout/layout.module.js
new file mode 100644 (file)
index 0000000..d35001f
--- /dev/null
@@ -0,0 +1,47 @@
+// This module is used to populate views from the index.tpl.html
+// Each module will register html pages with the appropriate HelperProvider's and this module will take everything from those Helpers and fill the view.
+define(['angularAMD' ,'angular-ui-router', 'ocLazyLoad', 'app/core/core.services'], function(app) {
+  var layout = angular.module('app.common.layout', ['ui.router.state', 'app.core']);
+
+  layout.config(function($stateProvider, $urlRouterProvider, $controllerProvider, $compileProvider, $provide, TopBarHelperProvider, NavHelperProvider, ContentHelperProvider) {
+    $urlRouterProvider.otherwise("/");
+
+    $stateProvider.state('main', {
+      url: '/',
+      views : {
+        'mainContent@' : {
+          controller: 'AppCtrl',
+          templateUrl : 'src/common/layout/index.tpl.html'
+        },
+        'navigation@main' : {
+          template: NavHelperProvider.getViews(),
+          controller: 'NavCtrl'
+        },
+        'topbar@main' : {
+          template : TopBarHelperProvider.getViews()
+        },
+        'content@main' : {
+          template : ContentHelperProvider.getViews()
+        }
+      },
+      resolve: {
+        loadCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
+          return $ocLazyLoad.load({
+            files: ['app/app.controller'].concat(TopBarHelperProvider.getControllers()).concat(NavHelperProvider.getControllers())
+          });
+        }]
+      }
+    });
+
+    layout.register = {
+      controller: $controllerProvider.register,
+      directive: $compileProvider.directive,
+      factory : $provide.factory,
+      service : $provide.service
+    };
+
+  });
+
+  return layout;
+
+});
index b4db84663293e77e7a6d965bc4827806c99cc385..ce23a23d9bdaaf44843ff116014f3061f20a891a 100644 (file)
@@ -1,4 +1,4 @@
-<a href="{{item.link}}" ng-if="isValid(item.submenu)" target="_self">
+<a href="{{item.link}}" ng-if="isValid(item.submenu)" target="_self" ng-click="updateTemplate($event, item)">
     <i class="{{item.icon}}"></i>
     {{item.title | translate}}
     <span ng-show="isValid(item.submenu)" class="arrow icon-angle-down"></span>
 
 <ul class="nav nav-second-level collapse" style="display: {{display}}">
 
-    <li ng-controller="navItemCtrl" ng-repeat="item in item.submenu"
-        ng-include="'navigation/nav_item_template.tpl.html'">
+  <li ng-class="{ active: (isState(item.active) && !isValid(item.submenu)) }" ng-controller="navItemCtrl" ng-repeat="item in item.submenu"
+        ng-include="'src/common/navigation/nav_item_template.tpl.html'">
 
     </li>
 
 
 </ul>
-
-
-  
-
-
diff --git a/src/common/navigation/navigation.controller.js b/src/common/navigation/navigation.controller.js
new file mode 100644 (file)
index 0000000..3e82aad
--- /dev/null
@@ -0,0 +1,33 @@
+define(['common/navigation/navigation.module', 'common/navigation/navigation.services', 'app/core/core.services'], function(nav, services) {
+  nav.register.controller('NavCtrl', function($scope, NavHelper) {
+    $scope.navList = NavHelper.getMenu();
+  });
+
+  nav.register.controller('navItemCtrl', function($scope, NavHelper) {
+    $scope.display = 'none';
+    $scope.isOpen = false;
+
+    $scope.isValid = function (value) {
+      if (angular.isUndefined(value) || value === null) {
+        return false;
+      }
+      else {
+        return true;
+      }
+    };
+
+    $scope.updateTemplate = function (e, item) {
+      e.stopPropagation();
+      e.preventDefault();
+
+      $scope.isOpen = !$scope.isOpen;
+      if ($scope.display == 'none') {
+        $scope.display = 'block';
+      }
+      else {
+        $scope.display = 'none';
+      }
+    };
+  });
+
+});
diff --git a/src/common/navigation/navigation.module.js b/src/common/navigation/navigation.module.js
new file mode 100644 (file)
index 0000000..5bea61f
--- /dev/null
@@ -0,0 +1,21 @@
+define(['angularAMD', 'app/core/core.module' ,'app/core/core.services'], function (ng) {
+  var nav = angular.module('app.common.nav', ['app.core']);
+
+  nav.config( function($stateProvider, $controllerProvider,$compileProvider, $provide, NavHelperProvider) {
+
+    // use the register because the app is already bootstraped
+    nav.register = {
+      directive: $compileProvider.directive,
+      controller: $controllerProvider.register,
+      factory: $provide.factory,
+      service: $provide.service
+    };
+
+    NavHelperProvider.addToView('src/common/navigation/navigation.tpl.html');
+    NavHelperProvider.addControllerUrl('common/navigation/navigation.controller');
+
+
+  });
+
+  return nav;
+});
index 5f15fcdca7e450e1bf6494a5fc1ac48b9cbe427f..af08b336fd025104d7640ce5c08df739ebafc574 100644 (file)
@@ -15,8 +15,8 @@
             </div>
         </li>          
                    --> 
-        <li ng-class="{ active: isState(item.active) }" class="{{item.class}}" ng-controller="navItemCtrl" ng-repeat="item in navList"
-            ng-include="'navigation/nav_item_template.tpl.html'">
+        <li ng-class="{ active: (isState(item.active) && !isValid(item.submenu))}" ng-controller="navItemCtrl" ng-repeat="item in navList"
+            ng-include="'src/common/navigation/nav_item_template.tpl.html'">
 
 
         </li>
diff --git a/src/common/topbar/topbar.controller.js b/src/common/topbar/topbar.controller.js
new file mode 100644 (file)
index 0000000..cf6fa60
--- /dev/null
@@ -0,0 +1,41 @@
+define(['common/topbar/topbar.module'], function(topbar) {
+
+    topbar.register.controller('topBarTasksCtrl',function ($scope, taskFactory) {
+        $scope.tasks = taskFactory.getTaskData();
+    });
+
+    topbar.register.controller('topBarNotifsCtrl',function ($scope, notifsFactory) {
+        $scope.notifs = notifsFactory.getNotifsData();
+        $scope.isValid = function (value) {
+            if (angular.isUndefined(value) || value === null) {
+                return false;
+            }
+            else {
+                return true;
+            }
+        };
+    });
+
+    topbar.register.controller('topBarMessagesCtrl',function ($scope, messageFactory) {
+        $scope.messages = messageFactory.getMessageData();
+        $scope.isValid = function (value) {
+            if (angular.isUndefined(value) || value === null) {
+                return false;
+            }
+            else {
+                return true;
+            }
+        };
+    });
+
+    // the authorization module is not converted yet
+    topbar.register.controller('topBarUserMenuCtrl', function ($scope, $cookieStore, /* Auth,*/ $window) {
+        $scope.logOut = function () {
+            /*Auth.logout(
+            function(res) {
+                $window.location.href = 'login.html'; 
+            });*/
+
+        };
+    });
+});
diff --git a/src/common/topbar/topbar.directives.js b/src/common/topbar/topbar.directives.js
new file mode 100644 (file)
index 0000000..6d2df52
--- /dev/null
@@ -0,0 +1,40 @@
+define(['common/topbar/topbar.module'], function(topbar) {
+   topbar.register.directive('mcTopBar', function () {
+        return {
+            replace: true,
+            templateUrl: 'topbar/topbar.tpl.html',
+        };
+    });
+
+    topbar.register.directive('mcTopBarTasks', function () {
+        return {
+            replace: true,
+            controller: 'topBarTasksCtrl',
+            templateUrl: 'topbar/tasks.tpl.html'
+        };
+    });
+
+    topbar.register.directive('mcTopBarNotifications', function () {
+        return {
+            replace: true,
+            controller: 'topBarNotifsCtrl',
+            templateUrl: 'topbar/notifications.tpl.html'
+        };
+    });
+
+    topbar.register.directive('mcTopBarMessages', function () {
+        return {
+            replace: true,
+            controller: 'topBarMessagesCtrl',
+            templateUrl: 'topbar/messages.tpl.html'
+        };
+    });
+
+    topbar.register.directive('mcTopBarUserMenu', function () {
+        return {
+            replace: true,
+            controller: 'topBarUserMenuCtrl',
+            templateUrl: 'topbar/user_menu.tpl.html'
+        };
+    });
+}); 
diff --git a/src/common/topbar/topbar.module.js b/src/common/topbar/topbar.module.js
new file mode 100644 (file)
index 0000000..fd7adc2
--- /dev/null
@@ -0,0 +1,17 @@
+define(['angularAMD', 'angular-cookies', 'app/core/core.services'], function(ng) {
+  var topbar = angular.module('app.common.topbar', ['ngCookies', 'app.core']);
+
+  topbar.config(function($compileProvider, $controllerProvider, $provide, TopBarHelperProvider) {
+    topbar.register = {
+      controller : $controllerProvider.register,
+      directive : $compileProvider.directive,
+      factory : $provide.factory,
+      service : $provide.service
+    };
+
+    TopBarHelperProvider.addToView('src/common/topbar/topbar.tpl.html');
+    TopBarHelperProvider.addControllerUrl('common/topbar/topbar.controller');
+  });
+
+  return topbar;
+});
diff --git a/src/common/topbar/topbar.services.js b/src/common/topbar/topbar.services.js
new file mode 100644 (file)
index 0000000..9c49bcd
--- /dev/null
@@ -0,0 +1,103 @@
+define(['common/topbar/topbar.module'], function(topbar) {
+    topbar.register.factory('taskFactory',function () {
+        var factory = {};
+        factory.getTaskData = function () {
+            return {
+                count: 4,
+                latest: [
+                    {
+                        title: "Software Update",
+                        percentage: 65
+                    },
+                    {
+                        title: "Hardware Upgrade" ,
+                        percentage: 35 ,
+                        progressBarClass: "progress-bar-danger"
+                    },
+                    {
+                        title: "Unit Testing" ,
+                        percentage: 15  ,
+                        progressBarClass: "progress-bar-warning"
+                    },
+                    {
+                        title: "Bug Fixes" ,
+                        percentage: 90 ,
+                        progressClass: "progress-striped active",
+                        progressBarClass: "progress-bar-success"
+                    }
+                ]
+            };
+
+        };
+        return factory;
+    });
+
+    topbar.register.factory('messageFactory', function () {
+        var factory = {};
+        factory.getMessageData = function () {
+            return {
+                count: 5,
+                latest: [
+                    {
+                        name: "Alex",
+                        img: "avatar.png",
+                        time: "a moment ago",
+                        summary: "Ciao sociis natoque penatibus et auctor ..."
+                    },
+                    {
+                        name: "Susan",
+                        img: "avatar3.png",
+                        time: "20 minutes ago",
+                        summary: "Vestibulum id ligula porta felis euismod ..."
+                    },
+                    {
+                        name: "Bob",
+                        img: "avatar4.png",
+                        time: "3:15 pm",
+                        summary: "Nullam quis risus eget urna mollis ornare ..."
+                    }
+                ]
+            };
+        };
+        return factory;
+    });
+
+    topbar.regiser.factory('notifsFactory', function () {
+        var factory = {};
+        factory.getNotifsData = function () {
+            return {
+                "count": 8,
+                "latest": [
+                    {
+                        title: "New Comments",
+                        icon: "icon-comment",
+                        iconClass: "btn-pink",
+                        badge: "+12",
+                        badgeClass: "badge-info"
+                    },
+                    {
+                        title: "Bob just signed up as an editor ...",
+                        icon: "icon-user",
+                        iconClass: "btn-primary"
+                    },
+                    {
+                        title: "New Orders",
+                        icon: "icon-shopping-cart",
+                        iconClass: "btn-success",
+                        badge: "+8",
+                        badgeClass: "badge-success"
+                    },
+                    {
+                        title: "Followers",
+                        icon: "icon-twitter",
+                        iconClass: "btn-info",
+                        badge: "+11",
+                        badgeClass: "badge-info"
+                    }
+                ]
+            };
+
+        };
+        return factory;
+    });
+});
index cfebbe897f3708f376d793b22161dd9fbe2562b5..bdf7da947b2201431bed513e74b8bb89e92e491f 100644 (file)
@@ -1,11 +1,11 @@
 <nav class="navbar navbar-default navbar-static-top" style="margin-bottom: 0" role="navigation">
  <!-- the script for the resizing was here -->
 
-   
-<img id="logo_opendaylight" src="assets/images/logo_opendaylight.gif" class="img-responsive-v1" border="0" alt="OpenDayLight" /><img id="logo_opendaylight_white" src="assets/images/logo_opendaylight_white.gif" class="img-responsive-v1" border="0" alt="OpenDayLight" /><img src="assets/images/{{logo}}.gif"  id="page_logo" class="img-responsive-v1" border="0" alt="OpenDayLight" />
+
+<img id="logo_opendaylight" src="assets/images/logo_opendaylight.gif" class="img-responsive-v1" border="0" alt="OpenDayLight" /><img id="logo_opendaylight_white" src="assets/images/logo_opendaylight_white.gif" class="img-responsive-v1" border="0" alt="OpenDayLight" /><img ng-src="assets/images/{{section_logo}}.gif"  id="page_logo" class="img-responsive-v1" border="0" alt="OpenDayLight" />
 
 <div style="background-color:red;display:inline;width:100%;"></div>
-    
+
       <ul class="nav navbar-top-links navbar-right">
        <!--<img src="assets/images/User.png" class="right-topbar" border="0" alt="OpenDayLight" />
        <img src="assets/images/Info.png" class="right-topbar" border="0" alt="OpenDayLight" />
@@ -22,4 +22,4 @@
       </ul><!-- /.ace-nav -->
 
 
-</nav>
\ No newline at end of file
+</nav>
index 783ce90fbce478318c926fc8b29648cb3f4a525c..788159e5806bc9d003f644860a0d1b5dd5831d9c 100644 (file)
@@ -7,8 +7,6 @@
     <meta name="description" content="overview &amp; stats" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 
-    <!-- To remove / convert to LESS -->
-    
 
     <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
 
 
     <!-- compiled CSS --><% styles.forEach( function ( file ) { %>
     <link rel="stylesheet" type="text/css" href="<%= file %>" /><% }); %>
+    <link rel="stylesheet" href="assets/css/sb-admin.css" />
 
-    <!-- compiled JavaScript --><% scripts.forEach( function ( file ) { %>
-    <script type="text/javascript" src="<%= file %>"></script><% }); %>
+    <script type="text/javascript" data-main="src/main.js" src="vendor/requirejs/require.js"></script>
 
     <link rel="stylesheet" href="assets/css/font-awesome.min.css" /> <!-- the font-awesome is different from the 'official' one -->
-    <!-- ACE DESIGN
-    <link rel="stylesheet" href="assets/css/ace-fonts.css" />
-    <link rel="stylesheet" href="assets/css/ace.min.css" />
-    <link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
-    <link rel="stylesheet" href="assets/css/ace-skins.min.css" />
-    <link rel="stylesheet" href="assets/css/ace-ie.min.css" /> -->
-    <link rel="stylesheet" href="assets/css/sb-admin.css" />
-    <!--<link rel="stylesheet" href="assets/css/footable.editable.css" />-->
   </head>
 
-  <body ng-app="console" ng-controller="AppCtrl" class="skin-3">
-    <div id="wrapper">
-      <div mc-top-bar></div>
-      <div id="red"></div>
-      <div id="gray"></div>
-      <div mc-navigation></div>
-
-      <div id="page-wrapper">
-        <div class="row">
-          <div class="col-lg-12">
-            <div id="topology"></div>
-            <!--<h1 ng-bind="title">
-                  
-                  <small>
-                    <i class="icon-double-angle-right"></i>
-                    <span ng-bind="description"></span>
-                  </small>
-                </h1>-->
-          </div>
-        </div>
-        <div class="row content-row">
-
-          <div class="col-xs-12" style="margin-bottom: 50px" ui-view>
-            <!-- PAGE CONTENT BEGINS -->
-          </div><!-- /.col -->
-        </div><!-- /.row -->
-      </div><!-- /.page-content -->
-    </div><!-- /.main-content -->
-
-      <script type="text/javascript">
-        if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
-      </script>
-      <!--<script src="assets/js/bootstrap.min.js"></script>-->
-      <!--  script src="assets/js/typeahead-bs2.min.js"></script-->
-
-      <!--
-      <script src="assets/js/ace-elements.min.js"></script>
-      <script src="assets/js/ace.min.js"></script> 
-      <script src="assets/js/ace-extra.min.js"></script><!-- for now put these script here since they make errors with jshintsrc ... -->
-      <script src="assets/js/sb-admin.js"></script>
-      <!--<script src="assets/js/footable.editable.js"></script>-->
-      <!-- inline scripts related to this page -->
-
-      <script type="text/javascript">
-        
-          
-          jQuery(function($) {
-          //Android's default browser somehow is confused when tapping on label which will lead to dragging the task
-          //so disable dragging when clicking on label
-          var agent = navigator.userAgent.toLowerCase();
-          if("ontouchstart" in document && /applewebkit/.test(agent) && /android/.test(agent))
-            $('#tasks').on('touchstart', function(e){
-            var li = $(e.target).closest('#tasks li');
-            if(li.length == 0)return;
-            var label = li.find('label.inline').get(0);
-            if(label == e.target || $.contains(label, e.target)) e.stopImmediatePropagation() ;
-          });
-        
-          $('#tasks').sortable({
-            opacity:0.8,
-            revert:true,
-            forceHelperSize:true,
-            placeholder: 'draggable-placeholder',
-            forcePlaceholderSize:true,
-            tolerance:'pointer',
-            stop: function( event, ui ) {//just for Chrome!!!! so that dropdowns on items don't appear below other items after being moved
-              $(ui.item).css('z-index', 'auto');
-            }
-            }
-          );
-          $('#tasks').disableSelection();
-          $('#tasks input:checkbox').removeAttr('checked').on('click', function(){
-            if(this.checked) $(this).closest('li').addClass('selected');
-            else $(this).closest('li').removeClass('selected');
-          });
-          
-        })
-      </script>
+  <body class="skin-3">
+  <div id="wrapper"  ui-view="mainContent"></div>
   </body>
 </html>
diff --git a/src/main.js b/src/main.js
new file mode 100644 (file)
index 0000000..b707e84
--- /dev/null
@@ -0,0 +1,45 @@
+require.config({
+  baseUrl : 'src',
+  paths : {
+    'angular' : '../vendor/angular/angular',
+    'angularAMD' : '../vendor/angularAMD/angularAMD',
+    'ngload' : '../vendor/angularAMD/ngload',
+    'ui-bootstrap' : '../vendor/angular-bootstrap/ui-bootstrap-tpls.min',
+    'domReady' : '../venddor/requirejs-domready/domReady',
+    'Restangular' : '../vendor/restangular/dist/restangular.min',
+    'underscore' : '../vendor/underscore/underscore',
+    'angular-ui-router' : '../vendor/angular-ui-router/release/angular-ui-router',
+    'angular-css-injector' : '../vendor/angular-css-injector/angular-css-injector',
+    'angular-cookies' : '../vendor/angular-cookies/angular-cookies.min',
+    'angular-translate' : '../vendor/angular-translate/angular-translate.min',
+    'angular-translate-loader-static-files' : '../vendor/angular-translate-loader-static-files/angular-translate-loader-static-files.min',
+    'jquery' : '../vendor/jquery/jquery',
+    'footable' : '../vendor/footable/dist/footable.min',
+    'd3' : '../vendor/d3/d3.min',
+    'vis' : '../vendor/vis/dist/vis.min',
+    'ocLazyLoad' : '../vendor/ocLazyLoad/dist/ocLazyLoad' 
+  },
+
+  shim : {
+    'angularAMD' : ['angular'],
+    'ocLazyLoad' : ['angular'],
+    'Restangular' : ['angular', 'underscore'],
+    'ui-bootstrap' : ['angular'],
+    'angular-css-injector' : ['angular'],
+    'angular-ui-router' : ['angular'],
+    'angular-cookies' : ['angular'],
+    'angular-translate': ['angular'],
+    'angular-translate-loader-static-files' : ['angular-translate'],
+    'ngload' : ['angularAMD'],
+    'jquery' : {
+      exports : '$'
+    },
+    'footable' : ['jquery'],
+    'undescore' : {
+      exports : '_'
+    }
+  },
+
+  deps : ['app/app.module']
+
+});