KYLIN-2010 UI filter encoding options for different column type

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

Branch: refs/heads/KYLIN-2033
Commit: 45cc681326bbd701fd8740c6425354f362f1d87e
Parents: c1fc723
Author: Jason <jiat...@163.com>
Authored: Wed Sep 21 14:20:48 2016 +0800
Committer: Jason <jiat...@163.com>
Committed: Wed Sep 21 14:20:48 2016 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubeEdit.js           | 41 +++++++++++++++++++-
 webapp/app/js/model/cubeConfig.js               |  6 ++-
 webapp/app/js/model/tableModel.js               |  2 +
 .../cubeDesigner/advanced_settings.html         |  3 +-
 4 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/45cc6813/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js 
b/webapp/app/js/controllers/cubeEdit.js
index e2d0ab5..e9bd93e 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -40,11 +40,50 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, 
$routeParams, $locatio
     supportedEncoding:[]
   }
   CubeService.getValidEncodings({}, function (encodings) {
-    $scope.store.supportedEncoding = encodings;
+    for(var i =0;i<encodings.length;i++){
+      var value = encodings[i];
+      var name = value;
+      if(value=="int"){
+        name = "int (deprecated)";
+      }
+      $scope.store.supportedEncoding.push({
+        "name":name,
+        "value":value
+      });
+    }
   },function(e){
     $scope.store.supportedEncoding = $scope.cubeConfig.encodings;
   })
 
+  $scope.getEncodings =function (name){
+    var type = TableModel.columnNameTypeMap[name];
+    var encodings = $scope.store.supportedEncoding;
+    if(!type){
+      return encodings;
+    }
+    var filterEncodings = [];
+    for(var i = 0;i<encodings.length;i++){
+      var encodingValue = encodings[i].value;
+      if(encodingValue == "fixed_length_hex" ){
+        if(type.indexOf("varchar")!==-1){
+          filterEncodings.push(encodings[i]);
+        }
+      }else if(encodingValue == "date"){
+        if(type=="date"){
+          filterEncodings.push(encodings[i]);
+        }
+      }else if(encodingValue == "time"){
+        if(type=="time"||type=="datetime"||type=="timestamp"){
+          filterEncodings.push(encodings[i]);
+        }
+      }else{
+        filterEncodings.push(encodings[i]);
+      }
+    }
+
+    return filterEncodings;
+  }
+
   $scope.getColumnsByTable = function (tableName) {
     var temp = [];
     angular.forEach(TableModel.selectProjectTables, function (table) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/45cc6813/webapp/app/js/model/cubeConfig.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/model/cubeConfig.js 
b/webapp/app/js/model/cubeConfig.js
index 2876f40..a77ab4f 100644
--- a/webapp/app/js/model/cubeConfig.js
+++ b/webapp/app/js/model/cubeConfig.js
@@ -66,7 +66,11 @@ KylinApp.constant('cubeConfig', {
     topN:{name: 'Top 100', value: "topn(100)"}
   },
     dictionaries: ["true", "false"],
-    encodings:["dict","fixed_length","int"],
+    encodings:[
+      {name:"dict",value:"value"},
+      {name:"fixed_length",value:"fixed_length"},
+      {name:"int (deprecated)",value:"int"}
+    ],
     intEncodingOptions: [1,2,3,4,5,6,7,8],
 //    cubes config
   theaditems: [

http://git-wip-us.apache.org/repos/asf/kylin/blob/45cc6813/webapp/app/js/model/tableModel.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/model/tableModel.js 
b/webapp/app/js/model/tableModel.js
index 788fbae..87c9b9d 100755
--- a/webapp/app/js/model/tableModel.js
+++ b/webapp/app/js/model/tableModel.js
@@ -25,6 +25,7 @@ KylinApp.service('TableModel', 
function(ProjectModel,$q,TableService,$log) {
     var loading = false;
    //for tables in cubeDesigner
     this.selectProjectTables = [];
+    this.columnNameTypeMap = {};
 
     this.initTables = function(){
         this.selectProjectTables = [];
@@ -81,6 +82,7 @@ KylinApp.service('TableModel', 
function(ProjectModel,$q,TableService,$log) {
                         column.cardinality = null;
                     }
                     column.id = parseInt(column.id);
+                  _this.columnNameTypeMap[column.name] = column.datatype;
                 });
                 tableMap[table.database].push(table);
             });

http://git-wip-us.apache.org/repos/asf/kylin/blob/45cc6813/webapp/app/partials/cubeDesigner/advanced_settings.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubeDesigner/advanced_settings.html 
b/webapp/app/partials/cubeDesigner/advanced_settings.html
index 29d55a6..b11fc8e 100755
--- a/webapp/app/partials/cubeDesigner/advanced_settings.html
+++ b/webapp/app/partials/cubeDesigner/advanced_settings.html
@@ -229,11 +229,12 @@
 
                       <span 
ng-if="state.mode=='view'">{{rowkey_column.column}}</span>
                     </td>
+
                     <td>
                       <select ng-if="state.mode=='edit'" style="width:180px;"
                               chosen ng-model="rowkey_column.encoding"
                               
ng-change="refreshRowKey(convertedRowkeys,$index,rowkey_column);"
-                              ng-options="dt as dt for dt in 
store.supportedEncoding">
+                              ng-options="dt.value as dt.name for dt in 
getEncodings(rowkey_column.column)">
                         <option value=""></option>
                       </select>
                       <span 
ng-if="state.mode=='view'">{{rowkey_column.encoding}}</span>

Reply via email to