kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhongj...@apache.org
Subject [2/2] kylin git commit: KYLIN-1904-WEB-Global-Dictionary
Date Mon, 29 Aug 2016 03:45:56 GMT
KYLIN-1904-WEB-Global-Dictionary

Signed-off-by: Jason <jiatuer@163.com>


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

Branch: refs/heads/master
Commit: 1f4675fc81c8e8bcad847b4cb405b9f302e3b6d4
Parents: ab6b73b
Author: zx chen <346839943@qq.com>
Authored: Thu Aug 25 13:37:24 2016 +0800
Committer: Jason <jiatuer@163.com>
Committed: Mon Aug 29 11:31:44 2016 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubeAdvanceSetting.js | 114 +++++++++++++-
 webapp/app/js/controllers/cubeEdit.js           |  25 +++-
 webapp/app/js/model/cubeDescModel.js            |   9 ++
 .../cubeDesigner/advanced_settings.html         | 150 +++++++++++++++----
 4 files changed, 264 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/1f4675fc/webapp/app/js/controllers/cubeAdvanceSetting.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeAdvanceSetting.js b/webapp/app/js/controllers/cubeAdvanceSetting.js
index 09fb3d4..be90f65 100644
--- a/webapp/app/js/controllers/cubeAdvanceSetting.js
+++ b/webapp/app/js/controllers/cubeAdvanceSetting.js
@@ -18,14 +18,14 @@
 
 'use strict';
 
-KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfig,MetaModel,cubesManager,CubeDescModel)
{
+KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfig,MetaModel,cubesManager,CubeDescModel,SweetAlert)
{
     $scope.cubesManager = cubesManager;
 
 
   //rowkey
   $scope.convertedRowkeys = [];
   angular.forEach($scope.cubeMetaFrame.rowkey.rowkey_columns,function(item){
-    //var _isDictionary = item.encoding === "dict"?"true":"false";
+    //var _isDictionaries = item.encoding === "dict"?"true":"false";
     var _isFixedLength = item.encoding.substring(0,12) === "fixed_length"?"true":"false";//fixed_length:12
     var _isIntLength = item.encoding.substring(0,3) === "int"?"true":"false";//fixed_length:12
     var _encoding = item.encoding;
@@ -195,4 +195,114 @@ KylinApp.controller('CubeAdvanceSettingCtrl', function ($scope, $modal,cubeConfi
 
   }
 
+  $scope.isReuse=false;
+  $scope.addNew=false;
+  $scope.newDictionaries = {
+    "column":null,
+    "builder": null,
+    "reuse": null
+  }
+
+  $scope.initUpdateDictionariesStatus = function(){
+    $scope.updateDictionariesStatus = {
+      isEdit:false,
+      editIndex:-1
+    }
+  };
+  $scope.initUpdateDictionariesStatus();
+
+
+  $scope.addNewDictionaries = function (dictionaries, index) {
+    if(dictionaries&&index>=0){
+      $scope.updateDictionariesStatus.isEdit = true;
+      $scope.addNew=true;
+      $scope.updateDictionariesStatus.editIndex = index;
+      if(dictionaries.builder==null){
+        $scope.isReuse=true;
+      }
+      else{
+        $scope.isReuse=false;
+      }
+    }
+    else{
+      $scope.addNew=!$scope.addNew;
+    }
+    $scope.newDictionaries = (!!dictionaries)? jQuery.extend(true, {},dictionaries):CubeDescModel.createDictionaries();
+  };
+
+  $scope.saveNewDictionaries = function (){
+    if(!$scope.cubeMetaFrame.dictionaries){
+      $scope.cubeMetaFrame.dictionaries=[];
+    }
+
+    if($scope.updateDictionariesStatus.isEdit == true) {
+      if ($scope.cubeMetaFrame.dictionaries[$scope.updateDictionariesStatus.editIndex].column
!= $scope.newDictionaries.column) {
+        if(!$scope.checkColumn()){
+          return false;
+        }
+      }
+      else {
+        $scope.cubeMetaFrame.dictionaries[$scope.updateDictionariesStatus.editIndex] = $scope.newDictionaries;
+      }
+    }
+    else
+      {
+        if(!$scope.checkColumn()){
+        return false;
+        }
+        $scope.cubeMetaFrame.dictionaries.push($scope.newDictionaries);
+      }
+      $scope.newDictionaries = null;
+      $scope.initUpdateDictionariesStatus();
+      $scope.nextDictionariesInit();
+      $scope.addNew = !$scope.addNew;
+      $scope.isReuse = false;
+      return true;
+
+  };
+
+  $scope.nextDictionariesInit = function(){
+    $scope.nextDic = {
+      "coiumn":null,
+      "builder":null,
+      "reuse":null
+    }
+  }
+
+  $scope.checkColumn = function (){
+    var isColumnExit=false;
+        angular.forEach($scope.cubeMetaFrame.dictionaries,function(dictionaries){
+          if(!isColumnExit){
+            if(dictionaries.column==$scope.newDictionaries.column)
+              isColumnExit=true;
+          }
+        })
+    if(isColumnExit){
+      SweetAlert.swal('Oops...', "The column named [" + $scope.newDictionaries.column + "]
already exists", 'warning');
+      return false;
+    }
+    return true;
+  }
+
+  $scope.clearNewDictionaries = function (){
+    $scope.newDictionaries = null;
+    $scope.isReuse=false;
+    $scope.initUpdateDictionariesStatus();
+    $scope.nextDictionariesInit();
+    $scope.addNew=!$scope.addNew;
+  }
+
+  $scope.change = function (){
+    $scope.newDictionaries.builder=null;
+    $scope.newDictionaries.reuse=null;
+    $scope.isReuse=!$scope.isReuse;
+  }
+
+  $scope.removeDictionaries =  function(arr,element){
+    var index = arr.indexOf(element);
+    if (index > -1) {
+      arr.splice(index, 1);
+    }
+  };
+
 });

http://git-wip-us.apache.org/repos/asf/kylin/blob/1f4675fc/webapp/app/js/controllers/cubeEdit.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js
index 86c039a..b620d7f 100755
--- a/webapp/app/js/controllers/cubeEdit.js
+++ b/webapp/app/js/controllers/cubeEdit.js
@@ -116,16 +116,33 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams,
$locatio
   $scope.getFactColumns = function () {
     var me_columns = [];
     angular.forEach($scope.cubeMetaFrame.dimensions,function(dimension,index){
-      if($scope.metaModel.model.fact_table !== dimension.table){
-        return;
-      }
       if(dimension.column && dimension.derived == null){
         me_columns.push(dimension.column);
+
+      }
+      else{
+        angular.forEach(dimension.derived,function(derived){
+          me_columns.push(derived);
+        });
+
       }
 
     });
+    angular.forEach($scope.cubeMetaFrame.measure,function(measure){
+         if(measure.function.parameter.type==column){
+           me_columns.push(measure.function.parameter.value);
+         }
+    });
 
-    return me_columns;
+    var unique = []
+
+    angular.forEach(me_columns, function (column) {
+        if (unique.indexOf(column) === -1) {
+          unique.push(column);
+        }
+      });
+
+      return unique;
 
   };
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/1f4675fc/webapp/app/js/model/cubeDescModel.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/model/cubeDescModel.js b/webapp/app/js/model/cubeDescModel.js
index a6e02ac..57d7e6e 100644
--- a/webapp/app/js/model/cubeDescModel.js
+++ b/webapp/app/js/model/cubeDescModel.js
@@ -41,6 +41,7 @@ KylinApp.service('CubeDescModel', function () {
           }
         }
       ],
+      "dictionaries" :[],
       "rowkey": {
         "rowkey_columns": []
       },
@@ -79,6 +80,14 @@ KylinApp.service('CubeDescModel', function () {
 
     return measure;
   }
+  this.createDictionaries = function () {
+    var dictionaries = {
+      "column": null,
+      "builder": null,
+      "reuse":null
+    }
+    return dictionaries;
+  }
 
   this.createAggGroup = function () {
     var group = {

http://git-wip-us.apache.org/repos/asf/kylin/blob/1f4675fc/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 ab2b5dc..eac6944 100755
--- a/webapp/app/partials/cubeDesigner/advanced_settings.html
+++ b/webapp/app/partials/cubeDesigner/advanced_settings.html
@@ -16,11 +16,9 @@
 * limitations under the License.
 -->
 
-<div ng-controller="CubeAdvanceSettingCtrl">
-
+  <div ng-controller="CubeAdvanceSettingCtrl">
     <ng-form name="forms.cube_setting_form">
       <div>
-
         <div class="form-group">
           <h3 style="margin-left:42px;">Aggregation Groups </h3>
           <div style="margin-left:22px;">
@@ -30,7 +28,6 @@
               </div>
             </div>
           </div>
-
           <table style="margin-left:42px; width:92%"
                  ng-if="cubeMetaFrame.aggregation_groups.length > 0"
                  class="table table-hover list">
@@ -97,8 +94,6 @@
                     <td class="col-xs-1">
                     </td>
                   </tr>
-
-
                   <tr class="row">
                     <td class="col-xs-3">
                       Hierarchy Dimensions
@@ -121,7 +116,6 @@
                             </ui-select>
                             <p ng-if="state.mode=='view'">
                               {{hierarchyDims}}</p>
-
                           </td>
                           <td class="col-xs-2">
                             <button class="btn btn-sm btn-info"
@@ -130,7 +124,6 @@
                             </button>
                           </td>
                         </tr>
-
                         <tr class="row">
                           <td class="col-xs-12">
                             <button class="btn btn-sm btn-info"
@@ -139,11 +132,8 @@
                           </td>
                         </tr>
                       </table>
-
                     </td>
                   </tr>
-
-
                   <tr class="row">
                     <td class="col-xs-3">
                       Joint Dimensions
@@ -175,7 +165,6 @@
                             </button>
                           </td>
                         </tr>
-
                         <tr class="row">
                           <td class="col-xs-12">
                             <button class="btn btn-sm btn-info"
@@ -184,11 +173,9 @@
                           </td>
                         </tr>
                       </table>
-
                     </td>
                   </tr>
                 </table>
-
               </td>
               <td ng-if="state.mode=='edit'" class="col-xs-1">
                 <button class="btn btn-xs btn-info"
@@ -198,15 +185,10 @@
               </td>
             </tr>
           </table>
-
           <button class="btn btn-sm btn-info" style="margin-left:42px" ng-click="addNewAggregationGroup()"
                   ng-show="state.mode=='edit'">New Aggregation Group<i class="fa fa-plus"></i>
           </button>
-
-
         </div>
-
-
         <div class="form-group large-popover" style="overflow:auto">
           <h3 style="margin-left:42px">Rowkeys  <i kylinpopover placement="right"
title="Rowkey" template="rowkeyTip.html" class="fa fa-info-circle"></i></h3>
 
@@ -291,21 +273,132 @@
                   </tr>
                   </tbody>
                 </table>
-
-
               </div>
           </div>
-
           <button class="btn btn-sm btn-info" style="margin-left:42px"
                   ng-click="addNewRowkeyColumn()" ng-show="state.mode=='edit'">New Rowkey
Column<i class="fa fa-plus"></i>
           </button>
         </div>
+        <div class="form-group large-popover" style="overflow:auto">
+          <h3 style="margin-left:42px">Advanced Dictionaries  <i kylinpopover placement="right"
title="Advanced Dictionaries" template="AdvancedDictionariesTip.html" class="fa fa-info-circle"></i></h3>
+          <div style="margin-left:42px">
+            <div class="box-body">
+              <br/>
+              <table class="table table-striped table-hover">
+                <thead>
+                <tr>
+                  <th>Column</th>
+                  <th>Builder Class</th>
+                  <th>Reuse</th>
+                  <th ng-if="state.mode=='edit'">Actions</th>
+                </tr>
+                </thead>
+                <tbody>
+                  <tr ng-repeat="dictionaries in cubeMetaFrame.dictionaries | filter:
state.measureFilter track by $index">
+                    <td>
+                      <!--Column -->
+                      <span>{{dictionaries.column}}</span>
+                    </td>
+                    <td>
+                      <!--Builder-->
+                      <span>{{dictionaries.builder}}</span>
+                    </td>
+                    <td>
+                      <!--Reuse-->
+                      <span>{{dictionaries.reuse}}</span>
+                    </td>
+                    <td ng-if="state.mode=='edit'">
+                      <!--Edit Button -->
+                      <button class="btn btn-xs btn-info" ng-click="addNewDictionaries(dictionaries,
$index)" >
+                        <i class="fa fa-pencil"></i>
+                      </button>
+                      <!--Remove Button -->
+                      <button class="btn btn-xs  btn-danger" ng-click="removeDictionaries(cubeMetaFrame.dictionaries,
dictionaries)">
+                        <i class="fa fa-trash-o"></i>
+                      </button>
+                    </td>
+                  </tr>
+                </tbody>
+              </table>
+            </div>
+          </div>
+        </div>
+        <!--Add Dictionaries Button-->
+        <div class="form-group" style="margin-left:42px;">
+          <button class="btn btn-sm btn-info" ng-click="addNewDictionaries()" ng-show="state.mode=='edit'
&& !addNew">
+            <i class="fa fa-plus"></i> Dictionaries
+          </button>
+       </div>
+       <!--Edit Dictionsry-->
+       <ng-form name="edit_mes_form" style="margin-left:42px;">
+         <div class="box box-solid"  ng-if="addNew" style="margin-left:42px;">
+           <div class="box-header">
+             <h4 class="box-title text-info">Edit Dictionaries</h4>
+           </div>
+           <div class="box-body">
+             <div class="row">
+               <div class="col-xs-8">
+                 <!--Column-->
+                 <div class="form-group middle-popover">
+                   <div class="row">
+                     <label class="col-xs-12 col-sm-3 control-label no-padding-right font-color-default"><b>Column</b></label>
+                     <div class="col-xs-12 col-sm-6">
+                       <select class="form-control" chosen
+                               ng-model="newDictionaries.column"
+                               ng-change="measureReturnTypeUpdate();"
+                               ng-options="column as column for column in getFactColumns()"
required>
+                         <option value="">-- Select a Column --</option>
+                       </select>
+                     </div>
+                   </div>
+                 </div>
+                 <div class="form-group">
+                   <div class="row" style="margin-left:5px;">
+                     <label class="radio-inline ng-binding ng-scope">
+                       <input type="radio" name="reuse" ng-value=false ng-model="isReuse"
 ng-change="change()"/><b>Builder Class</b>
+                     </label>
+                     <label class="radio-inline ng-binding ng-scope">
+                       <input type="radio" name="reuse"  ng-value=true ng-model="isReuse"
ng-change="change()"/><b>Reuse</b>
+                     </label>
+                   </div>
+                 </div>
+                 <!--Builder-->
+                 <div class="form-group" ng-if="!isReuse" >
+                   <div class="row">
+                     <label class="col-xs-12 col-sm-3 control-label no-padding-right font-color-default"><b>Builder
Class</b></label>
+                     <div class="col-xs-12 col-sm-6">
+                       <input type="text" name="builder"  ng-model="newDictionaries.builder"
required  style="width:100% " />
+                     </div>
+                   </div>
+                 </div>
+                 <!--Reuse-->
+                 <div class="form-group middle-popover" ng-if="isReuse" >
+                   <div class="row">
+                     <label class="col-xs-12 col-sm-3 control-label no-padding-right font-color-default"><b>Reuse</b></label>
+                     <div class="col-xs-12 col-sm-6">
+                       <select class="form-control" chosen
+                               ng-model="newDictionaries.reuse"
+                               ng-change="measureReturnTypeUpdate();"
+                               ng-options="column as column for column in getFactColumns()"
required>
+                         <option value="">-- Select a Column --</option>
+                       </select>
+                     </div>
+                   </div>
+                 </div>
+               </div>
+             </div>
+           </div>
+           <div class="box-footer">
+             <button class="btn btn-sm btn-info" ng-disabled="edit_mes_form.$invalid"
+                     ng-click="saveNewDictionaries()" ng-show="state.mode=='edit'">OK</button>
+             <button class="btn btn-link" ng-click="clearNewDictionaries()">Cancel</button>
+           </div>
+         </div>
+       </ng-form>
+     </div>
+   </ng-form>
+ </div>
 
-      </div>
-
-    </ng-form>
-
-</div>
 <script type="text/ng-template" id="rowkeyTip.html">
   <div>
     <h4>Shard By this column?</h4>
@@ -316,7 +409,7 @@
     <h4>RowKey Encoding</h4>
     <ol>
       <li>
-        "dict" encoding will try to build a dictionary for the dimension
+        "dict" encoding will try to build a dictionaries for the dimension
       </li>
       <li>
         "fixed_length" encoding will encode the dimension vlaues by fixed length bytes with
padding
@@ -327,3 +420,4 @@
     </ol>
   </div>
 </script>
+<script type="text/ng-template" id="AdvancedDictionariesTip.html"


Mime
View raw message