kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [32/39] incubator-kylin git commit: KYLIN-722 format local js
Date Sun, 26 Apr 2015 04:18:04 GMT
KYLIN-722 format local js


Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/ba9592c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/ba9592c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/ba9592c8

Branch: refs/heads/staging
Commit: ba9592c8b041def201fe8b816c9cc0203e2f09fc
Parents: ccc0981
Author: jiazhong <jiazhong@ebay.com>
Authored: Fri Apr 24 13:25:07 2015 +0800
Committer: jiazhong <jiazhong@ebay.com>
Committed: Fri Apr 24 13:31:45 2015 +0800

----------------------------------------------------------------------
 webapp/app/js/app.js                            |    4 +-
 webapp/app/js/config.js                         |  232 ++--
 webapp/app/js/controllers/access.js             |  184 ++--
 webapp/app/js/controllers/admin.js              |  372 +++----
 webapp/app/js/controllers/auth.js               |   48 +-
 webapp/app/js/controllers/cube.js               |  147 ++-
 webapp/app/js/controllers/cubeAdvanceSetting.js |   34 +-
 webapp/app/js/controllers/cubeDimensions.js     |  611 +++++-----
 webapp/app/js/controllers/cubeEdit.js           | 1042 +++++++++---------
 webapp/app/js/controllers/cubeFilter.js         |    4 +-
 webapp/app/js/controllers/cubeModel.js          |  260 ++---
 webapp/app/js/controllers/cubeRefresh.js        |    4 +-
 webapp/app/js/controllers/cubes.js              |  787 ++++++-------
 webapp/app/js/controllers/index.js              |   44 +-
 webapp/app/js/controllers/job.js                |  349 +++---
 webapp/app/js/controllers/page.js               |  462 ++++----
 webapp/app/js/controllers/projectMeta.js        |  131 ++-
 webapp/app/js/controllers/projects.js           |  192 ++--
 webapp/app/js/controllers/query.js              |  877 ++++++++-------
 webapp/app/js/controllers/sourceMeta.js         |  268 ++---
 webapp/app/js/directives/directives.js          |  334 +++---
 webapp/app/js/factories/graph.js                |   96 +-
 webapp/app/js/filters/filter.js                 |  252 ++---
 webapp/app/js/listeners.js                      |  128 +--
 webapp/app/js/model/cubeConfig.js               |  148 +--
 webapp/app/js/model/cubeDescModel.js            |  147 +--
 webapp/app/js/model/cubeListModel.js            |   80 +-
 webapp/app/js/model/cubesManager.js             |    2 +-
 webapp/app/js/model/jobConfig.js                |   32 +-
 webapp/app/js/model/jobListModel.js             |   64 +-
 webapp/app/js/model/metaModel.js                |  168 +--
 webapp/app/js/model/projectConfig.js            |   14 +-
 webapp/app/js/model/projectModel.js             |  140 +--
 webapp/app/js/model/tableConfig.js              |   14 +-
 webapp/app/js/model/tableModel.js               |  170 +--
 webapp/app/js/services/access.js                |   14 +-
 webapp/app/js/services/admin.js                 |   14 +-
 webapp/app/js/services/auth.js                  |   12 +-
 webapp/app/js/services/cache.js                 |    8 +-
 webapp/app/js/services/cubeDesc.js              |    8 +-
 webapp/app/js/services/cubes.js                 |   32 +-
 webapp/app/js/services/graph.js                 |   44 +-
 webapp/app/js/services/jobs.js                  |   16 +-
 webapp/app/js/services/kylinProperties.js       |  156 +--
 webapp/app/js/services/message.js               |   60 +-
 webapp/app/js/services/model.js                 |    8 +-
 webapp/app/js/services/ngLoading.js             |   54 +-
 webapp/app/js/services/projects.js              |   14 +-
 webapp/app/js/services/query.js                 |   18 +-
 webapp/app/js/services/tables.js                |   18 +-
 webapp/app/js/services/tree.js                  |  547 +++++----
 webapp/app/js/services/users.js                 |   70 +-
 webapp/app/js/utils/utils.js                    |   82 +-
 webapp/app/less/app.less                        |    5 +-
 54 files changed, 4546 insertions(+), 4475 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/app.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/app.js b/webapp/app/js/app.js
index ba24cb1..59d679e 100644
--- a/webapp/app/js/app.js
+++ b/webapp/app/js/app.js
@@ -14,7 +14,7 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 //Kylin Application Module
-KylinApp = angular.module('kylin', ['ngRoute', 'ngResource', 'ngGrid', 'ui.bootstrap', 'ui.ace', 'base64', 'angularLocalStorage', 'localytics.directives', 'treeControl', 'nvd3ChartDirectives','ngLoadingRequest','oitozero.ngSweetAlert','ngCookies','angular-underscore', 'ngAnimate', 'ui.sortable']);
+KylinApp = angular.module('kylin', ['ngRoute', 'ngResource', 'ngGrid', 'ui.bootstrap', 'ui.ace', 'base64', 'angularLocalStorage', 'localytics.directives', 'treeControl', 'nvd3ChartDirectives', 'ngLoadingRequest', 'oitozero.ngSweetAlert', 'ngCookies', 'angular-underscore', 'ngAnimate', 'ui.sortable']);

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/config.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/config.js b/webapp/app/js/config.js
index fa61fef..cf3ea6d 100644
--- a/webapp/app/js/config.js
+++ b/webapp/app/js/config.js
@@ -14,144 +14,144 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 // # dh.config
 //
-// This module loads the configuration and routes files, as well as bootstraps the application. At 
+// This module loads the configuration and routes files, as well as bootstraps the application. At
 // runtime it adds uri based on application location.
 
 // Config variable.
 var Config = {
-    name:'kylin',
-    service:{
-        base:'/kylin/',
-        url:'/kylin/api/'
-    },
-    documents:[],
-    reference_links:{
-        hadoop: {name:"hadoop", link: null},
-        diagnostic: {name:"diagnostic", "link": null}
-    },
-    contact_mail:''
+  name: 'kylin',
+  service: {
+    base: '/kylin/',
+    url: '/kylin/api/'
+  },
+  documents: [],
+  reference_links: {
+    hadoop: {name: "hadoop", link: null},
+    diagnostic: {name: "diagnostic", "link": null}
+  },
+  contact_mail: ''
 };
 
 // Angular module to load routes.
 KylinApp.config(function ($routeProvider, $httpProvider, $locationProvider, $logProvider) {
 
-    // Set debug to true by default.
-    if (angular.isUndefined(Config.debug) || Config.debug !== false) {
-        Config.debug = true;
-    }
+  // Set debug to true by default.
+  if (angular.isUndefined(Config.debug) || Config.debug !== false) {
+    Config.debug = true;
+  }
+
+  // Set development to true by default.
+  if (angular.isUndefined(Config.development) || Config.development !== false) {
+    Config.development = true;
+  }
+
+  // Disable logging if debug is off.
+  if (Config.debug === false) {
+    $logProvider.debugEnabled(false);
+  }
+
+  // Loop over routes and add to router.
+  angular.forEach(Config.routes, function (route) {
+    $routeProvider.when(route.url, route.params);
+  });
+
+  // Set to use HTML5 mode, which removes the #! from modern browsers.
+  $locationProvider.html5Mode(true);
+
+  //configure $http to view a login whenever a 401 unauthorized response arrives
+  $httpProvider.responseInterceptors.push(function ($rootScope, $q) {
+    return function (promise) {
+      return promise.then(
+        //success -> don't intercept
+        function (response) {
+          return response;
+        },
+        //error -> if 401 save the request and broadcast an event
+        function (response) {
+          if (response.status === 401 && !(response.config.url.indexOf("user/authentication") !== -1 && response.config.method === 'POST')) {
+            var deferred = $q.defer(),
+              req = {
+                config: response.config,
+                deferred: deferred
+              };
+            $rootScope.requests401.push(req);
+            $rootScope.$broadcast('event:loginRequired');
+            return deferred.promise;
+          }
+
+          if (response.status === 403) {
+            $rootScope.$broadcast('event:forbidden', response.data.exception);
+          }
+
+          return $q.reject(response);
+        }
+      );
+    };
+  });
+  httpHeaders = $httpProvider.defaults.headers;
+})
+  .run(function ($location) {
 
-    // Set development to true by default.
-    if (angular.isUndefined(Config.development) || Config.development !== false) {
-        Config.development = true;
+    if (angular.isUndefined(Config.uri)) {
+      Config.uri = {};
     }
 
-    // Disable logging if debug is off.
-    if (Config.debug === false) {
-        $logProvider.debugEnabled(false);
+    // Add uri details at runtime based on environment.
+    var uri = {
+      host: $location.protocol() + '://' + $location.host() + '/'
+    };
+    // Setup values for development or production.
+    if (Config.development) {
+      uri.api = $location.protocol() + '://' + $location.host() + '/devapi/';
+    } else {
+      uri.api = $location.protocol() + '://' + $location.host() + '/api/';
     }
 
-    // Loop over routes and add to router.
-    angular.forEach(Config.routes, function (route) {
-        $routeProvider.when(route.url, route.params);
-    });
-
-    // Set to use HTML5 mode, which removes the #! from modern browsers.
-    $locationProvider.html5Mode(true);
-
-    //configure $http to view a login whenever a 401 unauthorized response arrives
-    $httpProvider.responseInterceptors.push(function ($rootScope, $q) {
-        return function (promise) {
-            return promise.then(
-                //success -> don't intercept
-                function (response) {
-                    return response;
-                },
-                //error -> if 401 save the request and broadcast an event
-                function (response) {
-                    if (response.status === 401 && !(response.config.url.indexOf("user/authentication") !== -1 && response.config.method === 'POST')) {
-                        var deferred = $q.defer(),
-                            req = {
-                                config: response.config,
-                                deferred: deferred
-                            };
-                        $rootScope.requests401.push(req);
-                        $rootScope.$broadcast('event:loginRequired');
-                        return deferred.promise;
-                    }
-
-                    if (response.status === 403) {
-                        $rootScope.$broadcast('event:forbidden', response.data.exception);
-                    }
-
-                    return $q.reject(response);
-                }
-            );
-        };
-    });
-    httpHeaders = $httpProvider.defaults.headers;
-})
-    .run(function ($location) {
-
-        if (angular.isUndefined(Config.uri)) {
-            Config.uri = {};
-        }
-
-        // Add uri details at runtime based on environment.
-        var uri = {
-            host: $location.protocol() + '://' + $location.host() + '/'
-        };
-        // Setup values for development or production.
-        if (Config.development) {
-            uri.api = $location.protocol() + '://' + $location.host() + '/devapi/';
-        } else {
-            uri.api = $location.protocol() + '://' + $location.host() + '/api/';
-        }
-
-        // Extend uri config with any declared uri values.
-        Config.uri = angular.extend(uri, Config.uri);
-    });
+    // Extend uri config with any declared uri values.
+    Config.uri = angular.extend(uri, Config.uri);
+  });
 
 // This runs when all code has loaded, and loads the config and route json manifests, before bootstrapping angular.
 window.onload = function () {
 
-    // Files to load initially.
-    var files = [
-        {property: 'routes', file: 'routes.json'}
-    ];
-    var loaded = 0;
-
-    // Request object
-    var Request = function (item, file) {
-        var loader = new XMLHttpRequest();
-        // onload event for when the file is loaded
-        loader.onload = function () {
-
-            loaded++;
-
-            if(item === 'routes') {
-                Config[item] = JSON.parse(this.responseText);
-            }
-            // We've loaded all dependencies, lets bootstrap the application.
-            if (loaded === files.length) {
-                // Declare error if we are missing a name.
-                if (angular.isUndefined(Config.name)) {
-                    console.error('Config.name is undefined, please update this property.');
-                }
-                // Bootstrap the application.
-                angular.bootstrap(document, [Config.name]);
-            }
-        };
-
-        loader.open('get', file, true);
-        loader.send();
+  // Files to load initially.
+  var files = [
+    {property: 'routes', file: 'routes.json'}
+  ];
+  var loaded = 0;
+
+  // Request object
+  var Request = function (item, file) {
+    var loader = new XMLHttpRequest();
+    // onload event for when the file is loaded
+    loader.onload = function () {
+
+      loaded++;
+
+      if (item === 'routes') {
+        Config[item] = JSON.parse(this.responseText);
+      }
+      // We've loaded all dependencies, lets bootstrap the application.
+      if (loaded === files.length) {
+        // Declare error if we are missing a name.
+        if (angular.isUndefined(Config.name)) {
+          console.error('Config.name is undefined, please update this property.');
+        }
+        // Bootstrap the application.
+        angular.bootstrap(document, [Config.name]);
+      }
     };
 
-    for (var index in files) {
-        var load = new Request(files[index].property, files[index].file);
-    }
+    loader.open('get', file, true);
+    loader.send();
+  };
+
+  for (var index in files) {
+    var load = new Request(files[index].property, files[index].file);
+  }
 
 };

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/controllers/access.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/access.js b/webapp/app/js/controllers/access.js
index 7b9c987..4cfd833 100644
--- a/webapp/app/js/controllers/access.js
+++ b/webapp/app/js/controllers/access.js
@@ -14,115 +14,115 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 'use strict';
 
-KylinApp.controller('AccessCtrl', function ($scope,AccessService, MessageService, AuthenticationService,SweetAlert) {
+KylinApp.controller('AccessCtrl', function ($scope, AccessService, MessageService, AuthenticationService, SweetAlert) {
 
-    $scope.accessTooltip = "<div style='text-align: left'>" +
-        "<label>What does access mean to cube?</label>" +
-        "<ul><li>CUBE QUERY: Access to query cube</li>" +
-        "<li>CUBE OPERATION: Access to rebuild, resume and cancel jobs. Also include access of CUBE QUERY.</li>" +
-        "<li>CUBE MANAGEMENT: Access to edit/delete cube. Also include access of CUBE OPERATION.</li>" +
-        "<li>CUBE ADMIN: Full access to cube and jobs, including access management.</li></ul></div>";
+  $scope.accessTooltip = "<div style='text-align: left'>" +
+  "<label>What does access mean to cube?</label>" +
+  "<ul><li>CUBE QUERY: Access to query cube</li>" +
+  "<li>CUBE OPERATION: Access to rebuild, resume and cancel jobs. Also include access of CUBE QUERY.</li>" +
+  "<li>CUBE MANAGEMENT: Access to edit/delete cube. Also include access of CUBE OPERATION.</li>" +
+  "<li>CUBE ADMIN: Full access to cube and jobs, including access management.</li></ul></div>";
 
-    $scope.authorities = null;
+  $scope.authorities = null;
 
-    AuthenticationService.authorities({}, function (authorities) {
-        $scope.authorities = authorities.stringList;
-    });
+  AuthenticationService.authorities({}, function (authorities) {
+    $scope.authorities = authorities.stringList;
+  });
 
-    $scope.resetNewAcess = function () {
-        $scope.newAccess = null;
-    }
+  $scope.resetNewAcess = function () {
+    $scope.newAccess = null;
+  }
 
-    $scope.renewAccess = function (entity) {
-        $scope.newAccess = {
-            uuid: entity.uuid,
-            sid: null,
-            principal: true,
-            permission: 'READ'
-        };
-    }
+  $scope.renewAccess = function (entity) {
+    $scope.newAccess = {
+      uuid: entity.uuid,
+      sid: null,
+      principal: true,
+      permission: 'READ'
+    };
+  }
 
-    $scope.grant = function (type, entity, grantRequst) {
-        var uuid = grantRequst.uuid;
-        delete grantRequst.uuid;
-        AccessService.grant({type: type, uuid: uuid}, grantRequst, function (accessEntities) {
-            entity.accessEntities = accessEntities;
-            $scope.resetNewAcess();
+  $scope.grant = function (type, entity, grantRequst) {
+    var uuid = grantRequst.uuid;
+    delete grantRequst.uuid;
+    AccessService.grant({type: type, uuid: uuid}, grantRequst, function (accessEntities) {
+      entity.accessEntities = accessEntities;
+      $scope.resetNewAcess();
 //            MessageService.sendMsg('Access granted!', 'success', {});
-            SweetAlert.swal('Success!', 'Access granted!', 'success');
-        }, function (e) {
-            if (e.status == 404) {
+      SweetAlert.swal('Success!', 'Access granted!', 'success');
+    }, function (e) {
+      if (e.status == 404) {
 //                MessageService.sendMsg('User not found!', 'error', {});
-                SweetAlert.swal('Oops...', 'User not found!!', 'error');
-            }
-            else{
-                if(e.data&& e.data.exception){
-                    var message =e.data.exception;
-                    var msg = !!(message) ? message : 'Failed to take action.';
-                    SweetAlert.swal('Oops...', msg, 'error');
-                }else{
-                    SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                }
+        SweetAlert.swal('Oops...', 'User not found!!', 'error');
+      }
+      else {
+        if (e.data && e.data.exception) {
+          var message = e.data.exception;
+          var msg = !!(message) ? message : 'Failed to take action.';
+          SweetAlert.swal('Oops...', msg, 'error');
+        } else {
+          SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+        }
 
-            }
-        });
-    }
+      }
+    });
+  }
 
-    $scope.update = function (type, entity, access, permission) {
-        var updateRequst = {
-            accessEntryId: access.id,
-            permission: permission
-        };
-        AccessService.update({type: type, uuid: entity.uuid}, updateRequst, function (accessEntities) {
-            entity.accessEntities = accessEntities;
+  $scope.update = function (type, entity, access, permission) {
+    var updateRequst = {
+      accessEntryId: access.id,
+      permission: permission
+    };
+    AccessService.update({type: type, uuid: entity.uuid}, updateRequst, function (accessEntities) {
+      entity.accessEntities = accessEntities;
 //            MessageService.sendMsg('Access granted!', 'success', {});
-            SweetAlert.swal('', 'Access granted!', 'success');
-        },function(e){
-            if(e.data&& e.data.exception){
-                var message =e.data.exception;
-                var msg = !!(message) ? message : 'Failed to take action.';
-                SweetAlert.swal('Oops...', msg, 'error');
-            }else{
-                SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-            }
-        });
+      SweetAlert.swal('', 'Access granted!', 'success');
+    }, function (e) {
+      if (e.data && e.data.exception) {
+        var message = e.data.exception;
+        var msg = !!(message) ? message : 'Failed to take action.';
+        SweetAlert.swal('Oops...', msg, 'error');
+      } else {
+        SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+      }
+    });
 
-    }
+  }
 
-    $scope.revoke = function (type, access, entity) {
-        SweetAlert.swal({
-            title: '',
-            text: 'Are you sure to revoke the access?',
-            type: '',
-            showCancelButton: true,
-            confirmButtonColor: '#DD6B55',
-            confirmButtonText: "Yes",
-            closeOnConfirm: true
-        }, function() {
-            var revokeRequst = {
-                type: type,
-                uuid: entity.uuid,
-                accessEntryId: access.id
-            };
-            AccessService.revoke(revokeRequst, function (accessEntities) {
-                entity.accessEntities = accessEntities.accessEntryResponseList;
-                SweetAlert.swal('Success!', 'The access has been revoked.', 'success');
-            },function(e){
-                if(e.data&& e.data.exception){
-                    var message =e.data.exception;
-                    var msg = !!(message) ? message : 'Failed to take action.';
-                    SweetAlert.swal('Oops...', msg, 'error');
-                }else{
-                    SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                }
-            });
+  $scope.revoke = function (type, access, entity) {
+    SweetAlert.swal({
+      title: '',
+      text: 'Are you sure to revoke the access?',
+      type: '',
+      showCancelButton: true,
+      confirmButtonColor: '#DD6B55',
+      confirmButtonText: "Yes",
+      closeOnConfirm: true
+    }, function () {
+      var revokeRequst = {
+        type: type,
+        uuid: entity.uuid,
+        accessEntryId: access.id
+      };
+      AccessService.revoke(revokeRequst, function (accessEntities) {
+        entity.accessEntities = accessEntities.accessEntryResponseList;
+        SweetAlert.swal('Success!', 'The access has been revoked.', 'success');
+      }, function (e) {
+        if (e.data && e.data.exception) {
+          var message = e.data.exception;
+          var msg = !!(message) ? message : 'Failed to take action.';
+          SweetAlert.swal('Oops...', msg, 'error');
+        } else {
+          SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+        }
+      });
 
-        });
+    });
 
-    }
+  }
 });
 

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/controllers/admin.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/admin.js b/webapp/app/js/controllers/admin.js
index a15411a..e5d2a67 100644
--- a/webapp/app/js/controllers/admin.js
+++ b/webapp/app/js/controllers/admin.js
@@ -14,202 +14,204 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 'use strict';
 
-KylinApp.controller('AdminCtrl', function ($scope,AdminService, CacheService, TableService,loadingRequest, MessageService, $modal,SweetAlert) {
-    $scope.configStr = "";
-    $scope.envStr = "";
+KylinApp.controller('AdminCtrl', function ($scope, AdminService, CacheService, TableService, loadingRequest, MessageService, $modal, SweetAlert) {
+  $scope.configStr = "";
+  $scope.envStr = "";
 
-    $scope.getEnv = function(){
-        AdminService.env({}, function(env){
-            $scope.envStr = env.env;
-            MessageService.sendMsg('Server environment get successfully', 'success', {});
+  $scope.getEnv = function () {
+    AdminService.env({}, function (env) {
+      $scope.envStr = env.env;
+      MessageService.sendMsg('Server environment get successfully', 'success', {});
 //            SweetAlert.swal('Success!', 'Server environment get successfully', 'success');
-        },function(e){
-            if(e.data&& e.data.exception){
-                var message =e.data.exception;
-                var msg = !!(message) ? message : 'Failed to take action.';
-                SweetAlert.swal('Oops...', msg, 'error');
-            }else{
-                SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-            }
+    }, function (e) {
+      if (e.data && e.data.exception) {
+        var message = e.data.exception;
+        var msg = !!(message) ? message : 'Failed to take action.';
+        SweetAlert.swal('Oops...', msg, 'error');
+      } else {
+        SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+      }
+    });
+  }
+
+  $scope.getConfig = function () {
+    AdminService.config({}, function (config) {
+      $scope.configStr = config.config;
+      MessageService.sendMsg('Server config get successfully', 'success', {});
+    }, function (e) {
+      if (e.data && e.data.exception) {
+        var message = e.data.exception;
+        var msg = !!(message) ? message : 'Failed to take action.';
+        SweetAlert.swal('Oops...', msg, 'error');
+      } else {
+        SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+      }
+    });
+  }
+
+  $scope.reloadMeta = function () {
+    SweetAlert.swal({
+      title: '',
+      text: 'Are you sure to reload metadata and clean cache?',
+      type: '',
+      showCancelButton: true,
+      confirmButtonColor: '#DD6B55',
+      confirmButtonText: "Yes",
+      closeOnConfirm: true
+    }, function (isConfirm) {
+      if (isConfirm) {
+        CacheService.clean({}, function () {
+          SweetAlert.swal('Success!', 'Cache reload successfully', 'success');
+        }, function (e) {
+          if (e.data && e.data.exception) {
+            var message = e.data.exception;
+            var msg = !!(message) ? message : 'Failed to take action.';
+            SweetAlert.swal('Oops...', msg, 'error');
+          } else {
+            SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+          }
         });
-    }
-
-    $scope.getConfig = function(){
-        AdminService.config({}, function(config){
-            $scope.configStr = config.config;
-            MessageService.sendMsg('Server config get successfully', 'success', {});
-        },function(e){
-            if(e.data&& e.data.exception){
-                var message =e.data.exception;
-                var msg = !!(message) ? message : 'Failed to take action.';
-                SweetAlert.swal('Oops...', msg, 'error');
-            }else{
-                SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-            }
-        });
-    }
-
-    $scope.reloadMeta = function(){
-        SweetAlert.swal({
-            title: '',
-            text: 'Are you sure to reload metadata and clean cache?',
-            type: '',
-            showCancelButton: true,
-            confirmButtonColor: '#DD6B55',
-            confirmButtonText: "Yes",
-            closeOnConfirm: true
-        }, function(isConfirm) {
-            if(isConfirm){
-                CacheService.clean({}, function () {
-                    SweetAlert.swal('Success!', 'Cache reload successfully', 'success');
-                },function(e){
-                    if(e.data&& e.data.exception){
-                        var message =e.data.exception;
-                        var msg = !!(message) ? message : 'Failed to take action.';
-                        SweetAlert.swal('Oops...', msg, 'error');
-                    }else{
-                        SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                    }
-                });
-            }
-
-        });
-    }
-
-    $scope.calCardinality = function (tableName) {
-        $modal.open({
-            templateUrl: 'calCardinality.html',
-            controller: CardinalityGenCtrl,
-            resolve: {
-                tableName: function () {
-                    return tableName;
-                },
-                scope: function () {
-                    return $scope;
-                }
-            }
-        });
-    }
-
-    $scope.cleanStorage = function(){
-        SweetAlert.swal({
-            title: '',
-            text: 'Are you sure to clean up unused HDFS and HBase space?',
-            type: '',
-            showCancelButton: true,
-            confirmButtonColor: '#DD6B55',
-            confirmButtonText: "Yes",
-            closeOnConfirm: true
-        }, function(isConfirm) {
-            if(isConfirm){
-            AdminService.cleanStorage({}, function () {
-                SweetAlert.swal('Success!', 'Storage cleaned successfully!', 'success');
-            },function(e){
-                if(e.data&& e.data.exception){
-                    var message =e.data.exception;
-                    var msg = !!(message) ? message : 'Failed to take action.';
-                    SweetAlert.swal('Oops...', msg, 'error');
-                }else{
-                    SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                }
-            });
-            }
-        });
-    }
-
-    $scope.disableCache = function(){
-        SweetAlert.swal({
-            title: '',
-            text: 'Are you sure to disable query cache?',
-            type: '',
-            showCancelButton: true,
-            confirmButtonColor: '#DD6B55',
-            confirmButtonText: "Yes",
-            closeOnConfirm: true
-        }, function(isConfirm) {
-            if(isConfirm){
-            AdminService.updateConfig({}, {key: 'kylin.query.cache.enabled',value:false}, function () {
-                SweetAlert.swal('Success!', 'Cache disabled successfully!', 'success');
-            },function(e){
-                if(e.data&& e.data.exception){
-                    var message =e.data.exception;
-                    var msg = !!(message) ? message : 'Failed to take action.';
-                    SweetAlert.swal('Oops...', msg, 'error');
-                }else{
-                    SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                }
-            });
-            }
-
+      }
+
+    });
+  }
+
+  $scope.calCardinality = function (tableName) {
+    $modal.open({
+      templateUrl: 'calCardinality.html',
+      controller: CardinalityGenCtrl,
+      resolve: {
+        tableName: function () {
+          return tableName;
+        },
+        scope: function () {
+          return $scope;
+        }
+      }
+    });
+  }
+
+  $scope.cleanStorage = function () {
+    SweetAlert.swal({
+      title: '',
+      text: 'Are you sure to clean up unused HDFS and HBase space?',
+      type: '',
+      showCancelButton: true,
+      confirmButtonColor: '#DD6B55',
+      confirmButtonText: "Yes",
+      closeOnConfirm: true
+    }, function (isConfirm) {
+      if (isConfirm) {
+        AdminService.cleanStorage({}, function () {
+          SweetAlert.swal('Success!', 'Storage cleaned successfully!', 'success');
+        }, function (e) {
+          if (e.data && e.data.exception) {
+            var message = e.data.exception;
+            var msg = !!(message) ? message : 'Failed to take action.';
+            SweetAlert.swal('Oops...', msg, 'error');
+          } else {
+            SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+          }
         });
-
-    }
-
-    $scope.toSetConfig = function(){
-        $modal.open({
-            templateUrl: 'updateConfig.html',
-            controller: updateConfigCtrl,
-            resolve: {
-            }
+      }
+    });
+  }
+
+  $scope.disableCache = function () {
+    SweetAlert.swal({
+      title: '',
+      text: 'Are you sure to disable query cache?',
+      type: '',
+      showCancelButton: true,
+      confirmButtonColor: '#DD6B55',
+      confirmButtonText: "Yes",
+      closeOnConfirm: true
+    }, function (isConfirm) {
+      if (isConfirm) {
+        AdminService.updateConfig({}, {key: 'kylin.query.cache.enabled', value: false}, function () {
+          SweetAlert.swal('Success!', 'Cache disabled successfully!', 'success');
+        }, function (e) {
+          if (e.data && e.data.exception) {
+            var message = e.data.exception;
+            var msg = !!(message) ? message : 'Failed to take action.';
+            SweetAlert.swal('Oops...', msg, 'error');
+          } else {
+            SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+          }
         });
+      }
+
+    });
+
+  }
+
+  $scope.toSetConfig = function () {
+    $modal.open({
+      templateUrl: 'updateConfig.html',
+      controller: updateConfigCtrl,
+      resolve: {}
+    });
+  }
+
+  var CardinalityGenCtrl = function ($scope, $modalInstance, tableName, MessageService) {
+    $scope.tableName = tableName;
+    $scope.delimiter = 0;
+    $scope.format = 0;
+    $scope.cancel = function () {
+      $modalInstance.dismiss('cancel');
+    };
+    $scope.calculate = function () {
+      $modalInstance.dismiss();
+      loadingRequest.show();
+      TableService.genCardinality({tableName: $scope.tableName}, {
+        delimiter: $scope.delimiter,
+        format: $scope.format
+      }, function (result) {
+        loadingRequest.hide();
+        SweetAlert.swal('Success!', 'Cardinality job was calculated successfully. . Click Refresh button ...', 'success');
+      }, function (e) {
+        loadingRequest.hide();
+        if (e.data && e.data.exception) {
+          var message = e.data.exception;
+          var msg = !!(message) ? message : 'Failed to take action.';
+          SweetAlert.swal('Oops...', msg, 'error');
+        } else {
+          SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+        }
+      });
     }
+  };
 
-    var CardinalityGenCtrl = function ($scope, $modalInstance, tableName, MessageService) {
-        $scope.tableName = tableName;
-        $scope.delimiter = 0;
-        $scope.format = 0;
-        $scope.cancel = function () {
-            $modalInstance.dismiss('cancel');
-        };
-        $scope.calculate = function () {
-            $modalInstance.dismiss();
-            loadingRequest.show();
-            TableService.genCardinality({tableName: $scope.tableName}, {delimiter: $scope.delimiter, format: $scope.format}, function (result) {
-                loadingRequest.hide();
-                SweetAlert.swal('Success!', 'Cardinality job was calculated successfully. . Click Refresh button ...', 'success');
-            },function(e){
-                loadingRequest.hide();
-                if(e.data&& e.data.exception){
-                    var message =e.data.exception;
-                    var msg = !!(message) ? message : 'Failed to take action.';
-                    SweetAlert.swal('Oops...', msg, 'error');
-                }else{
-                    SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                }
-            });
-        }
+  var updateConfigCtrl = function ($scope, $modalInstance, AdminService, MessageService) {
+    $scope.state = {
+      key: null,
+      value: null
     };
-
-    var updateConfigCtrl = function ($scope, $modalInstance, AdminService, MessageService) {
-        $scope.state = {
-            key:null,
-            value:null
-        };
-        $scope.cancel = function () {
-            $modalInstance.dismiss('cancel');
-        };
-        $scope.update = function () {
-
-
-                AdminService.updateConfig({}, {key: $scope.state.key, value: $scope.state.value}, function (result) {
-                    SweetAlert.swal('Success!', 'Config updated successfully!', 'success');
-                    $modalInstance.dismiss();
-                },function(e){
-                    if(e.data&& e.data.exception){
-                        var message =e.data.exception;
-                        var msg = !!(message) ? message : 'Failed to take action.';
-                        SweetAlert.swal('Oops...', msg, 'error');
-                    }else{
-                        SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                    }
-                });
-                }
+    $scope.cancel = function () {
+      $modalInstance.dismiss('cancel');
     };
+    $scope.update = function () {
+
+
+      AdminService.updateConfig({}, {key: $scope.state.key, value: $scope.state.value}, function (result) {
+        SweetAlert.swal('Success!', 'Config updated successfully!', 'success');
+        $modalInstance.dismiss();
+      }, function (e) {
+        if (e.data && e.data.exception) {
+          var message = e.data.exception;
+          var msg = !!(message) ? message : 'Failed to take action.';
+          SweetAlert.swal('Oops...', msg, 'error');
+        } else {
+          SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+        }
+      });
+    }
+  };
 
-    $scope.getEnv();
-    $scope.getConfig();
+  $scope.getEnv();
+  $scope.getConfig();
 });

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/controllers/auth.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/auth.js b/webapp/app/js/controllers/auth.js
index f7fbfea..2e5dc75 100644
--- a/webapp/app/js/controllers/auth.js
+++ b/webapp/app/js/controllers/auth.js
@@ -14,34 +14,34 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 'use strict';
 
 KylinApp.controller('LoginCtrl', function ($scope, $rootScope, $location, $base64, AuthenticationService, UserService) {
-    $scope.username = null;
-    $scope.password = null;
-    $scope.loading = false;
+  $scope.username = null;
+  $scope.password = null;
+  $scope.loading = false;
 
-    $scope.login = function () {
-        // set the basic authentication header that will be parsed in the next request and used to authenticate
-        httpHeaders.common['Authorization'] = 'Basic ' + $base64.encode($scope.username + ':' + $scope.password);
-        $scope.loading = true;
-        //verify project
-        if($scope.projectModel.projects.length&&!$scope.projectModel.selectedProject){
-            $scope.loading = false;
-            $scope.error = "Unable to login, please select a project";
-            return;
-        }
+  $scope.login = function () {
+    // set the basic authentication header that will be parsed in the next request and used to authenticate
+    httpHeaders.common['Authorization'] = 'Basic ' + $base64.encode($scope.username + ':' + $scope.password);
+    $scope.loading = true;
+    //verify project
+    if ($scope.projectModel.projects.length && !$scope.projectModel.selectedProject) {
+      $scope.loading = false;
+      $scope.error = "Unable to login, please select a project";
+      return;
+    }
 
-        AuthenticationService.login({}, {}, function (data) {
-            $scope.loading = false;
-            $rootScope.$broadcast('event:loginConfirmed');
-            UserService.setCurUser(data);
-            $location.path(UserService.getHomePage());
-        }, function (error) {
-            $scope.loading = false;
-            $scope.error = "Unable to login, please check your username/password.";
-        });
-    };
+    AuthenticationService.login({}, {}, function (data) {
+      $scope.loading = false;
+      $rootScope.$broadcast('event:loginConfirmed');
+      UserService.setCurUser(data);
+      $location.path(UserService.getHomePage());
+    }, function (error) {
+      $scope.loading = false;
+      $scope.error = "Unable to login, please check your username/password.";
+    });
+  };
 });

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/controllers/cube.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cube.js b/webapp/app/js/controllers/cube.js
index 607706d..5e1d3b5 100755
--- a/webapp/app/js/controllers/cube.js
+++ b/webapp/app/js/controllers/cube.js
@@ -14,92 +14,91 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 'use strict';
 
-KylinApp.controller('CubeCtrl', function ($scope, AccessService, MessageService, CubeService, TableService, CubeGraphService, UserService,SweetAlert) {
-    $scope.newAccess = null;
-    $scope.state = {jsonEdit: false};
+KylinApp.controller('CubeCtrl', function ($scope, AccessService, MessageService, CubeService, TableService, CubeGraphService, UserService, SweetAlert) {
+  $scope.newAccess = null;
+  $scope.state = {jsonEdit: false};
 
-    $scope.buildGraph = function (cube) {
-        CubeGraphService.buildTree(cube);
-    };
+  $scope.buildGraph = function (cube) {
+    CubeGraphService.buildTree(cube);
+  };
 
-    $scope.getCubeSql = function (cube) {
-        CubeService.getSql({cubeId: cube.name, propValue: "null"}, function (sql) {
-            cube.sql = sql.sql;
-        },function(e){
-            if(e.data&& e.data.exception){
-                var message =e.data.exception;
-                var msg = !!(message) ? message : 'Failed to take action.';
-                SweetAlert.swal('Oops...', msg, 'error');
-            }else{
-                SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-            }
-        });
-    };
+  $scope.getCubeSql = function (cube) {
+    CubeService.getSql({cubeId: cube.name, propValue: "null"}, function (sql) {
+      cube.sql = sql.sql;
+    }, function (e) {
+      if (e.data && e.data.exception) {
+        var message = e.data.exception;
+        var msg = !!(message) ? message : 'Failed to take action.';
+        SweetAlert.swal('Oops...', msg, 'error');
+      } else {
+        SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+      }
+    });
+  };
 
-    $scope.getNotifyListString = function (cube) {
-        if (cube.detail.notify_list) {
-            cube.notifyListString = cube.detail.notify_list.join(",");
-        }
-        else {
-            cube.notifyListString = "";
-        }
-    };
+  $scope.getNotifyListString = function (cube) {
+    if (cube.detail.notify_list) {
+      cube.notifyListString = cube.detail.notify_list.join(",");
+    }
+    else {
+      cube.notifyListString = "";
+    }
+  };
 
-    $scope.cleanStatus = function(cube){
+  $scope.cleanStatus = function (cube) {
 
-        if (!cube)
-        {
-            return;
-        }
-        var newCube = jQuery.extend(true, {}, cube);
-        delete newCube.project;
+    if (!cube) {
+      return;
+    }
+    var newCube = jQuery.extend(true, {}, cube);
+    delete newCube.project;
 
-        angular.forEach(newCube.dimensions, function(dimension, index){
-            delete dimension.status;
-        });
+    angular.forEach(newCube.dimensions, function (dimension, index) {
+      delete dimension.status;
+    });
 
-        return newCube;
-    };
+    return newCube;
+  };
 
-    $scope.updateNotifyList = function (cube) {
-        cube.detail.notify_list = cube.notifyListString.split(",");
-        CubeService.updateNotifyList({cubeId: cube.name}, cube.detail.notify_list, function () {
-            SweetAlert.swal('Success!', 'Notify List updated successfully!', 'success');
-        },function(e){
-            if(e.data&& e.data.exception){
-                var message =e.data.exception;
-                var msg = !!(message) ? message : 'Failed to take action.';
-                SweetAlert.swal('Oops...', msg, 'error');
-            }else{
-                SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-            }
-        });
-    };
+  $scope.updateNotifyList = function (cube) {
+    cube.detail.notify_list = cube.notifyListString.split(",");
+    CubeService.updateNotifyList({cubeId: cube.name}, cube.detail.notify_list, function () {
+      SweetAlert.swal('Success!', 'Notify List updated successfully!', 'success');
+    }, function (e) {
+      if (e.data && e.data.exception) {
+        var message = e.data.exception;
+        var msg = !!(message) ? message : 'Failed to take action.';
+        SweetAlert.swal('Oops...', msg, 'error');
+      } else {
+        SweetAlert.swal('Oops...', "Failed to take action.", 'error');
+      }
+    });
+  };
 
-    $scope.getHbaseInfo = function (cube) {
-        if (!cube.hbase) {
-            CubeService.getHbaseInfo({cubeId: cube.name, propValue: null, action: null}, function (hbase) {
-                cube.hbase = hbase;
+  $scope.getHbaseInfo = function (cube) {
+    if (!cube.hbase) {
+      CubeService.getHbaseInfo({cubeId: cube.name, propValue: null, action: null}, function (hbase) {
+        cube.hbase = hbase;
 
-                // Calculate cube total size based on each htable.
-                var totalSize = 0;
-                hbase.forEach(function(t) {
-                    totalSize += t.tableSize;
-                });
-                cube.totalSize = totalSize;
-            },function(e){
-                if(e.data&& e.data.exception){
-                    var message =e.data.exception;
-                    var msg = !!(message) ? message : 'Failed to take action.';
-                    SweetAlert.swal('Oops...', msg, 'error');
-                }else{
-                    SweetAlert.swal('Oops...', "Failed to take action.", 'error');
-                }
-            });
+        // Calculate cube total size based on each htable.
+        var totalSize = 0;
+        hbase.forEach(function (t) {
+          totalSize += t.tableSize;
+        });
+        cube.totalSize = totalSize;
+      }, function (e) {
+        if (e.data && e.data.exception) {
+          var message = e.data.exception;
+          var msg = !!(message) ? message : 'Failed to take action.';
+          SweetAlert.swal('Oops...', msg, 'error');
+        } else {
+          SweetAlert.swal('Oops...', "Failed to take action.", 'error');
         }
-    };
+      });
+    }
+  };
 });

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/controllers/cubeAdvanceSetting.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeAdvanceSetting.js b/webapp/app/js/controllers/cubeAdvanceSetting.js
index f1bd991..7e3d346 100644
--- a/webapp/app/js/controllers/cubeAdvanceSetting.js
+++ b/webapp/app/js/controllers/cubeAdvanceSetting.js
@@ -14,29 +14,29 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 'use strict';
 
-KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfig,ModelService,MetaModel) {
+KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal, cubeConfig, ModelService, MetaModel) {
 
-    //convert some undefined or null value
-    angular.forEach($scope.cubeMetaFrame.rowkey.rowkey_columns,function(rowkey){
-            if(!rowkey.dictionary){
-                rowkey.dictionary = "false";
-            }
-        }
-    );
-    //edit model
-    if($scope.state.mode==="edit") {
-        $scope.metaModel = MetaModel;
+  //convert some undefined or null value
+  angular.forEach($scope.cubeMetaFrame.rowkey.rowkey_columns, function (rowkey) {
+      if (!rowkey.dictionary) {
+        rowkey.dictionary = "false";
+      }
     }
+  );
+  //edit model
+  if ($scope.state.mode === "edit") {
+    $scope.metaModel = MetaModel;
+  }
 
 
-    $scope.dictionaryUpdated = function(rowkey_column){
-        if(rowkey_column.dictionary==="true"){
-            rowkey_column.length=0;
-        }
-
+  $scope.dictionaryUpdated = function (rowkey_column) {
+    if (rowkey_column.dictionary === "true") {
+      rowkey_column.length = 0;
     }
+
+  }
 });

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/ba9592c8/webapp/app/js/controllers/cubeDimensions.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeDimensions.js b/webapp/app/js/controllers/cubeDimensions.js
index f323d1f..77f8523 100644
--- a/webapp/app/js/controllers/cubeDimensions.js
+++ b/webapp/app/js/controllers/cubeDimensions.js
@@ -14,389 +14,388 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
-*/
+ */
 
 'use strict';
 
-KylinApp.controller('CubeDimensionsCtrl', function ($scope, $modal,MetaModel) {
+KylinApp.controller('CubeDimensionsCtrl', function ($scope, $modal, MetaModel) {
 
-    // Available columns list derived from cube data model.
-    $scope.availableColumns = {};
+  // Available columns list derived from cube data model.
+  $scope.availableColumns = {};
 
-    // Columns selected and disabled status bound to UI, group by table.
-    $scope.selectedColumns = {};
+  // Columns selected and disabled status bound to UI, group by table.
+  $scope.selectedColumns = {};
 
-    // Available tables cache: 1st is the fact table, next are lookup tables.
-    $scope.availableTables = [];
+  // Available tables cache: 1st is the fact table, next are lookup tables.
+  $scope.availableTables = [];
 
 
-    /**
-     * Helper func to get columns that dimensions based on, three cases:
-     * 1. normal dimension: column array.
-     * 2. hierarchy dimension: column array, the array index is the hierarchy level.
-     * 3. derived dimension: derived columns array.
-     * TODO new cube schema change
-     */
-    var dimCols = function (dim) {
-        var referredCols = [];
+  /**
+   * Helper func to get columns that dimensions based on, three cases:
+   * 1. normal dimension: column array.
+   * 2. hierarchy dimension: column array, the array index is the hierarchy level.
+   * 3. derived dimension: derived columns array.
+   * TODO new cube schema change
+   */
+  var dimCols = function (dim) {
+    var referredCols = [];
 
-        // Case 3.
-        if (dim.derived && dim.derived.length) {
-            referredCols = referredCols.concat(dim.derived);
-        }
-
-        // Case 2.
-        if (dim.hierarchy && dim.column.length) {
-            referredCols = referredCols.concat(dim.column);
-        }
-
-        // Case 1.
-        if (!dim.derived && !dim.hierarchy) {
-            referredCols.push(dim.column);
-        }
+    // Case 3.
+    if (dim.derived && dim.derived.length) {
+      referredCols = referredCols.concat(dim.derived);
+    }
 
-        return referredCols;
-    };
+    // Case 2.
+    if (dim.hierarchy && dim.column.length) {
+      referredCols = referredCols.concat(dim.column);
+    }
 
-    // Dump available columns plus column table name, whether is from lookup table.
-    $scope.initColumns = function () {
-        var factTable = $scope.metaModel.model.fact_table;
+    // Case 1.
+    if (!dim.derived && !dim.hierarchy) {
+      referredCols.push(dim.column);
+    }
 
-        // At first dump the columns of fact table.
-        var cols = $scope.getColumnsByTable(factTable);
+    return referredCols;
+  };
 
-        // Initialize selected available.
-        var factAvailable = {};
-        var factSelectAvailable = {};
+  // Dump available columns plus column table name, whether is from lookup table.
+  $scope.initColumns = function () {
+    var factTable = $scope.metaModel.model.fact_table;
 
-        for (var i = 0; i < cols.length; i++) {
-            cols[i].table = factTable;
-            cols[i].isLookup = false;
+    // At first dump the columns of fact table.
+    var cols = $scope.getColumnsByTable(factTable);
 
-            factAvailable[cols[i].name] = cols[i];
+    // Initialize selected available.
+    var factAvailable = {};
+    var factSelectAvailable = {};
 
-            // Default not selected and not disabled.
-            factSelectAvailable[cols[i].name] = {selected: false, disabled: false};
-        }
+    for (var i = 0; i < cols.length; i++) {
+      cols[i].table = factTable;
+      cols[i].isLookup = false;
 
-        $scope.availableColumns[factTable] = factAvailable;
-        $scope.selectedColumns[factTable] = factSelectAvailable;
-        $scope.availableTables.push(factTable);
+      factAvailable[cols[i].name] = cols[i];
 
-        // Then dump each lookup tables.
-        var lookups = $scope.metaModel.model.lookups;
+      // Default not selected and not disabled.
+      factSelectAvailable[cols[i].name] = {selected: false, disabled: false};
+    }
 
-        for (var j = 0; j < lookups.length; j++) {
-            var cols2 = $scope.getColumnsByTable(lookups[j].table);
+    $scope.availableColumns[factTable] = factAvailable;
+    $scope.selectedColumns[factTable] = factSelectAvailable;
+    $scope.availableTables.push(factTable);
 
-            // Initialize selected available.
-            var lookupAvailable = {};
-            var lookupSelectAvailable = {};
+    // Then dump each lookup tables.
+    var lookups = $scope.metaModel.model.lookups;
 
-            for (var k = 0; k < cols2.length; k++) {
-                cols2[k].table = lookups[j].table;
-                cols2[k].isLookup = true;
+    for (var j = 0; j < lookups.length; j++) {
+      var cols2 = $scope.getColumnsByTable(lookups[j].table);
 
-                lookupAvailable[cols2[k].name] = cols2[k];
+      // Initialize selected available.
+      var lookupAvailable = {};
+      var lookupSelectAvailable = {};
 
-                // Default not selected and not disabled.
-                lookupSelectAvailable[cols2[k].name] = {selected: false, disabled: false};
-            }
+      for (var k = 0; k < cols2.length; k++) {
+        cols2[k].table = lookups[j].table;
+        cols2[k].isLookup = true;
 
-            $scope.availableColumns[lookups[j].table] = lookupAvailable;
-            $scope.selectedColumns[lookups[j].table] = lookupSelectAvailable;
-            $scope.availableTables.push(lookups[j].table);
-        }
-    };
+        lookupAvailable[cols2[k].name] = cols2[k];
 
-    // Check column status: selected or disabled based on current cube dimensions.
-    $scope.initColumnStatus = function () {
-        angular.forEach($scope.cubeMetaFrame.dimensions, function (dim) {
-            var cols = dimCols(dim);
+        // Default not selected and not disabled.
+        lookupSelectAvailable[cols2[k].name] = {selected: false, disabled: false};
+      }
 
-            angular.forEach(cols, function (colName) {
-                $scope.selectedColumns[dim.table][colName] = {selected: true, disabled: true};
-            });
-        });
-    };
-
-    // Initialize data for columns widget in auto-gen when add/edit cube.
-    if ($scope.state.mode == 'edit') {
-        $scope.initColumns();
+      $scope.availableColumns[lookups[j].table] = lookupAvailable;
+      $scope.selectedColumns[lookups[j].table] = lookupSelectAvailable;
+      $scope.availableTables.push(lookups[j].table);
     }
+  };
+
+  // Check column status: selected or disabled based on current cube dimensions.
+  $scope.initColumnStatus = function () {
+    angular.forEach($scope.cubeMetaFrame.dimensions, function (dim) {
+      var cols = dimCols(dim);
+
+      angular.forEach(cols, function (colName) {
+        $scope.selectedColumns[dim.table][colName] = {selected: true, disabled: true};
+      });
+    });
+  };
+
+  // Initialize data for columns widget in auto-gen when add/edit cube.
+  if ($scope.state.mode == 'edit') {
+    $scope.initColumns();
+  }
+
+  // Initialize params for add/edit dimension.
+  $scope.dimState = {
+    editing: false,
+    editingIndex: -1,
+    filter: ''
+  };
+
+  // Init the dimension, dimension name default as the column key. TODO new cube schema change.
+  var Dimension = function (table, selectedCols, dimType) {
+    var origin = {name: '', table: table, hierarchy: false, derived: null, column: null};
+
+    switch (dimType) {
+      case 'normal':
+        // Default name as 1st column name.
+        if (table && selectedCols.length) {
+          origin.name = table + '.' + selectedCols[0];
+        }
 
-    // Initialize params for add/edit dimension.
-    $scope.dimState = {
-        editing: false,
-        editingIndex: -1,
-        filter: ''
-    };
-
-    // Init the dimension, dimension name default as the column key. TODO new cube schema change.
-    var Dimension = function (table, selectedCols, dimType) {
-        var origin = {name: '', table: table,hierarchy:false,derived:null,column:null};
-
-        switch (dimType) {
-            case 'normal':
-                // Default name as 1st column name.
-                if (table && selectedCols.length) {
-                    origin.name = table + '.' + selectedCols[0];
-                }
+        origin.column = selectedCols;
+        break;
 
-                origin.column = selectedCols;
-                break;
+      case 'derived':
+        if (table && selectedCols.length) {
+          origin.name = table + '_derived';
+        }
 
-            case 'derived':
-                if (table && selectedCols.length) {
-                    origin.name = table + '_derived';
-                }
+        origin.derived = selectedCols;
+        break;
 
-                origin.derived = selectedCols;
-                break;
+      case 'hierarchy':
+        if (table && selectedCols.length) {
+          origin.name = table + '_hierarchy';
+        }
 
-            case 'hierarchy':
-                if (table && selectedCols.length) {
-                    origin.name = table + '_hierarchy';
-                }
+        origin.hierarchy = true;
+        origin.column = selectedCols;
+        break;
+    }
 
-                origin.hierarchy = true;
-                origin.column = selectedCols;
-                break;
-        }
+    return origin;
+  };
 
-        return origin;
-    };
+  // Since old schema may be both derived and hierarchy. TODO new cube schema change.
+  $scope.getDimType = function (dim) {
+    var types = [];
 
-    // Since old schema may be both derived and hierarchy. TODO new cube schema change.
-    $scope.getDimType = function (dim) {
-        var types = [];
+    if (dim.derived && dim.derived.length) {
+      types.push('derived');
+    }
 
-        if (dim.derived && dim.derived.length) {
-            types.push('derived');
-        }
+    if (dim.hierarchy && dim.column.length) {
+      types.push('hierarchy');
+    }
 
-        if (dim.hierarchy && dim.column.length) {
-            types.push('hierarchy');
-        }
+    if (!types.length) {
+      types.push('normal');
+    }
 
-        if (!types.length) {
-            types.push('normal');
+    return types;
+  };
+
+  var dimList = $scope.cubeMetaFrame.dimensions;
+
+  // Open add/edit dimension modal.
+  $scope.openDimModal = function (dimType) {
+    var modalInstance = $modal.open({
+      templateUrl: 'addEditDimension.html',
+      controller: cubeDimModalCtrl,
+      backdrop: 'static',
+      scope: $scope,
+      resolve: {
+        dimType: function () {
+          // For old schema compatibility, convert into array here. TODO new cube schema change.
+          return angular.isArray(dimType) ? dimType : [dimType];
         }
-
-        return types;
+      }
+    });
+
+    modalInstance.result.then(function () {
+      if (!$scope.dimState.editing) {
+        $scope.doneAddDim();
+      } else {
+        $scope.doneEditDim();
+      }
+
+    }, function () {
+      $scope.cancelDim();
+    });
+  };
+
+  // Controller for cube dimension add/edit modal.
+  var cubeDimModalCtrl = function ($scope, $modalInstance, dimType) {
+    $scope.dimType = dimType;
+
+    $scope.ok = function () {
+      $modalInstance.close();
     };
 
-    var dimList = $scope.cubeMetaFrame.dimensions;
-
-    // Open add/edit dimension modal.
-    $scope.openDimModal = function (dimType) {
-        var modalInstance = $modal.open({
-            templateUrl: 'addEditDimension.html',
-            controller: cubeDimModalCtrl,
-            backdrop: 'static',
-            scope: $scope,
-            resolve: {
-                dimType: function () {
-                    // For old schema compatibility, convert into array here. TODO new cube schema change.
-                    return angular.isArray(dimType) ? dimType : [dimType];
-                }
-            }
-        });
-
-        modalInstance.result.then(function () {
-            if (!$scope.dimState.editing) {
-                $scope.doneAddDim();
-            } else {
-                $scope.doneEditDim();
-            }
-
-        }, function () {
-            $scope.cancelDim();
-        });
+    $scope.cancel = function () {
+      $modalInstance.dismiss('cancel');
     };
+  };
 
-    // Controller for cube dimension add/edit modal.
-    var cubeDimModalCtrl = function ($scope, $modalInstance, dimType) {
-        $scope.dimType = dimType;
+  $scope.addDim = function (dimType) {
+    $scope.newDimension = Dimension('', [], dimType);
 
-        $scope.ok = function () {
-            $modalInstance.close();
-        };
+    $scope.openDimModal(dimType);
+  };
 
-        $scope.cancel = function () {
-            $modalInstance.dismiss('cancel');
-        };
-    };
+  $scope.editDim = function (dim) {
+    $scope.dimState.editingIndex = dimList.indexOf(dim);
+    $scope.dimState.editing = true;
 
-    $scope.addDim = function (dimType) {
-        $scope.newDimension = Dimension('', [], dimType);
+    // Make a copy of model will be editing.
+    $scope.newDimension = angular.copy(dim);
 
-        $scope.openDimModal(dimType);
-    };
+    $scope.openDimModal($scope.getDimType(dim));
+  };
 
-    $scope.editDim = function (dim) {
-        $scope.dimState.editingIndex = dimList.indexOf(dim);
-        $scope.dimState.editing = true;
+  $scope.doneAddDim = function () {
+    // Push new dimension which bound user input data.
+    dimList.push(angular.copy($scope.newDimension));
 
-        // Make a copy of model will be editing.
-        $scope.newDimension = angular.copy(dim);
+    $scope.resetParams();
+  };
 
-        $scope.openDimModal($scope.getDimType(dim));
-    };
+  $scope.doneEditDim = function () {
+    // Copy edited model to destination model.
+    angular.copy($scope.newDimension, dimList[$scope.dimState.editingIndex]);
 
-    $scope.doneAddDim = function () {
-        // Push new dimension which bound user input data.
-        dimList.push(angular.copy($scope.newDimension));
+    $scope.resetParams();
+  };
 
-        $scope.resetParams();
-    };
+  $scope.cancelDim = function () {
+    $scope.resetParams();
+  };
 
-    $scope.doneEditDim = function () {
-        // Copy edited model to destination model.
-        angular.copy($scope.newDimension, dimList[$scope.dimState.editingIndex]);
+  $scope.removeDim = function (dim) {
+    dimList.splice(dimList.indexOf(dim), 1);
+  };
 
-        $scope.resetParams();
-    };
+  $scope.resetParams = function () {
+    $scope.dimState.editing = false;
+    $scope.dimState.editingIndex = -1;
 
-    $scope.cancelDim = function () {
-        $scope.resetParams();
-    };
+    $scope.newDimension = {};
+  };
 
-    $scope.removeDim = function (dim) {
-        dimList.splice(dimList.indexOf(dim), 1);
-    };
+  // Open auto-gen dimension modal.
+  $scope.openAutoGenModal = function (dimType) {
+    // Init columns status.
+    $scope.initColumnStatus();
 
-    $scope.resetParams = function () {
-        $scope.dimState.editing = false;
-        $scope.dimState.editingIndex = -1;
+    var modalInstance = $modal.open({
+      templateUrl: 'autoGenDimension.html',
+      controller: cubeAutoGenDimModalCtrl,
+      backdrop: 'static',
+      scope: $scope
+    });
 
-        $scope.newDimension = {};
-    };
+    modalInstance.result.then(function () {
+      $scope.autoGenDims();
+    }, function () {
+      $scope.resetGenDims();
+    });
+  };
 
-    // Open auto-gen dimension modal.
-    $scope.openAutoGenModal = function (dimType) {
-        // Init columns status.
-        $scope.initColumnStatus();
-
-        var modalInstance = $modal.open({
-            templateUrl: 'autoGenDimension.html',
-            controller: cubeAutoGenDimModalCtrl,
-            backdrop: 'static',
-            scope: $scope
-        });
-
-        modalInstance.result.then(function () {
-            $scope.autoGenDims();
-        }, function () {
-            $scope.resetGenDims();
-        });
+  // Controller for cube dimension auto-gen modal.
+  var cubeAutoGenDimModalCtrl = function ($scope, $modalInstance) {
+    $scope.ok = function () {
+      $modalInstance.close();
     };
 
-    // Controller for cube dimension auto-gen modal.
-    var cubeAutoGenDimModalCtrl = function ($scope, $modalInstance) {
-        $scope.ok = function () {
-            $modalInstance.close();
-        };
-
-        $scope.cancel = function () {
-            $modalInstance.dismiss('cancel');
-        };
+    $scope.cancel = function () {
+      $modalInstance.dismiss('cancel');
     };
+  };
 
-    // Helper func to get the selected status in auto gen.
-    $scope.getSelectedCols = function () {
-        var selectedCols = {};
+  // Helper func to get the selected status in auto gen.
+  $scope.getSelectedCols = function () {
+    var selectedCols = {};
 
-        angular.forEach($scope.selectedColumns, function (value, table) {
-            angular.forEach(value, function (status, colName) {
-                if (status.selected && !status.disabled) {
-                    if (!selectedCols[table]) {
-                        selectedCols[table] = [];
-                    }
+    angular.forEach($scope.selectedColumns, function (value, table) {
+      angular.forEach(value, function (status, colName) {
+        if (status.selected && !status.disabled) {
+          if (!selectedCols[table]) {
+            selectedCols[table] = [];
+          }
 
-                    selectedCols[table].push(colName);
-                }
-            });
-        });
-
-        return selectedCols;
-    };
-
-    // Auto generate dimensions.
-    $scope.autoGenDims = function () {
-        var selectedCols = $scope.getSelectedCols();
-
-        angular.forEach(selectedCols, function (cols, table) {
-            if ($scope.metaModel.model.fact_table == table) {
-                // Fact table: for each selected column, create one normal dimension.
-                for (var i = 0; i < cols.length; i++) {
-                    dimList.push(Dimension(table, [cols[i]], 'normal'));
-                }
-            } else {
-                // Per lookup table, create one derived dimension for all its selected columns;
-                if (cols.length) {
-                    dimList.push(Dimension(table, cols, 'derived'));
-                }
-            }
-        });
-    };
-
-    // Just reset the selected status of columns.
-    $scope.resetGenDims = function () {
-        var selectedCols = $scope.getSelectedCols();
+          selectedCols[table].push(colName);
+        }
+      });
+    });
 
-        angular.forEach(selectedCols, function (cols, table) {
-            for (var i = 0; i < cols.length; i++) {
-                $scope.selectedColumns[table][cols[i]].selected = false;
-            }
-        });
-    };
+    return selectedCols;
+  };
 
-    // Check whether there is column conflicts.
-    $scope.dimConflicts = [];
+  // Auto generate dimensions.
+  $scope.autoGenDims = function () {
+    var selectedCols = $scope.getSelectedCols();
 
-    $scope.$watch('cubeMetaFrame.dimensions', function (newVal, oldVal) {
-        if (!newVal || !newVal.length) {
-            return;
+    angular.forEach(selectedCols, function (cols, table) {
+      if ($scope.metaModel.model.fact_table == table) {
+        // Fact table: for each selected column, create one normal dimension.
+        for (var i = 0; i < cols.length; i++) {
+          dimList.push(Dimension(table, [cols[i]], 'normal'));
         }
+      } else {
+        // Per lookup table, create one derived dimension for all its selected columns;
+        if (cols.length) {
+          dimList.push(Dimension(table, cols, 'derived'));
+        }
+      }
+    });
+  };
+
+  // Just reset the selected status of columns.
+  $scope.resetGenDims = function () {
+    var selectedCols = $scope.getSelectedCols();
+
+    angular.forEach(selectedCols, function (cols, table) {
+      for (var i = 0; i < cols.length; i++) {
+        $scope.selectedColumns[table][cols[i]].selected = false;
+      }
+    });
+  };
+
+  // Check whether there is column conflicts.
+  $scope.dimConflicts = [];
+
+  $scope.$watch('cubeMetaFrame.dimensions', function (newVal, oldVal) {
+    if (!newVal || !newVal.length) {
+      return;
+    }
 
-        var referredCols = {};
-
-        angular.forEach(newVal, function (curDim) {
-            var table = curDim.table;
-            var cols = dimCols(curDim);
+    var referredCols = {};
 
-            for (var i = 0; i < cols.length; i++) {
-                var key = table + '.' + cols[i];
+    angular.forEach(newVal, function (curDim) {
+      var table = curDim.table;
+      var cols = dimCols(curDim);
 
-                if (!referredCols[key]) {
-                    referredCols[key] = [];
-                }
+      for (var i = 0; i < cols.length; i++) {
+        var key = table + '.' + cols[i];
 
-                referredCols[key].push({id: curDim.id, name: curDim.name});
-            }
-        });
+        if (!referredCols[key]) {
+          referredCols[key] = [];
+        }
 
-        var conflicts = [];
+        referredCols[key].push({id: curDim.id, name: curDim.name});
+      }
+    });
 
-        angular.forEach(referredCols, function (dims, key) {
-            if (dims.length > 1) {
-                // More than 1 dimensions has referred this column.
-                var colInfo = key.split('.');
-                conflicts.push({table: colInfo[0], column: colInfo[1], dims: dims});
-            }
-        });
+    var conflicts = [];
 
-        $scope.dimConflicts = conflicts;
-    }, true);
+    angular.forEach(referredCols, function (dims, key) {
+      if (dims.length > 1) {
+        // More than 1 dimensions has referred this column.
+        var colInfo = key.split('.');
+        conflicts.push({table: colInfo[0], column: colInfo[1], dims: dims});
+      }
+    });
 
+    $scope.dimConflicts = conflicts;
+  }, true);
 
 
-    if ($scope.state.mode == 'edit') {
-        $scope.$on('$destroy', function () {
-           // $scope.dimensionsAdapter();
-            // Emit dimensions edit event in order to re-generate row key.
-            $scope.$emit('DimensionsEdited');
-        });
-    }
+  if ($scope.state.mode == 'edit') {
+    $scope.$on('$destroy', function () {
+      // $scope.dimensionsAdapter();
+      // Emit dimensions edit event in order to re-generate row key.
+      $scope.$emit('DimensionsEdited');
+    });
+  }
 });


Mime
View raw message