Major update to code structure
* Split files into independent files based on functionality.
* Switch to bower/gulp for build.
Change-Id: Ibc775dd9b7f6a0a49f63c22162b7582e781e2d9c
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
diff --git a/app/index.js b/app/index.js
new file mode 100644
index 0000000..f5c2692
--- /dev/null
+++ b/app/index.js
@@ -0,0 +1,83 @@
+/**
+ * A module which contains the definition of the application and the base of configuration
+ *
+ * @module app/index/services/index
+ * @exports app/index
+ *
+ * @author Developer Developer
+ * @version 0.10.0
+ * @since 0.0.1
+ */
+
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app', [
+ // Dependencies
+ 'ngRoute',
+ // Basic resources
+ 'app.constants',
+ 'app.templates',
+ 'app.vendors',
+ 'app.common.services',
+ 'app.common.directives',
+ 'app.common.filters',
+ // Model resources
+ 'app.login',
+ 'app.overview'
+ ])
+ // Route configuration
+ .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
+ $locationProvider.hashPrefix('');
+ $routeProvider
+ .otherwise({
+ 'redirectTo': '/login'
+ });
+ }])
+ .config(['$httpProvider', function($httpProvider){
+ //console.log($httpProvider.interceptors);
+ $httpProvider.interceptors.push('apiInterceptor');
+ }])
+ .run(['$rootScope', '$location', 'dataService', 'userModel',
+ function($rootScope, $location, dataService, userModel){
+ $rootScope.dataService = dataService;
+ dataService.path = $location.path();
+ $rootScope.$on('$routeChangeStart', function(event, next, current){
+
+ if(next.$$route == null || next.$$route == undefined) return;
+ if(next.$$route.authenticated){
+ if(!userModel.isLoggedIn()){
+ $location.path('/login');
+ }
+ }
+
+ if(next.$$route.originalPath == '/' ||
+ next.$$route.originalPath == '/login'){
+ if(userModel.isLoggedIn()){
+ if(current && current.$$route){
+ $location.path(current.$$route.originalPath);
+ }else{
+ $location.path('/overview/system');
+ }
+ }
+ }
+ });
+ $rootScope.$on('$locationChangeSuccess', function(event){
+ var path = $location.path();
+ dataService.path = path;
+ if(['/','/login','/logout'].indexOf(path) == -1){
+ dataService.showNavigation = true;
+ }else{
+ dataService.showNavigation = false;
+ }
+ });
+
+ $rootScope.$on('timedout-user', function(){
+ sessionStorage.removeItem('LOGIN_ID');
+ $location.path('/login');
+ });
+ }
+ ]);
+
+})(window.angular);