Skip to content

Commit

Permalink
KYLIN-4312 Front end for supporting specified cube when querying by API
Browse files Browse the repository at this point in the history
  • Loading branch information
nichunen authored and hit-lacus committed Feb 3, 2020
1 parent 3a2adde commit 0b2b94e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
28 changes: 26 additions & 2 deletions webapp/app/js/controllers/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

KylinApp
.controller('QueryCtrl', function ($scope, storage, $base64, $q, $location, $anchorScroll, $routeParams, QueryService, $modal, MessageService, $domUtilityService, $timeout, TableService, SweetAlert, VdmUtil) {
.controller('QueryCtrl', function ($scope, storage, $base64, $q, $location, $anchorScroll, $routeParams, QueryService, CubeService, $modal, MessageService, $domUtilityService, $timeout, TableService, SweetAlert, VdmUtil) {
$scope.mainPanel = 'query';
if ($routeParams.queryPanel) {
$scope.mainPanel = $routeParams.queryPanel;
Expand Down Expand Up @@ -57,6 +57,8 @@ KylinApp
};

$scope.locationChangeConfirmed = false;
$scope.selectDirective = null;
$scope.cubeItems = [];

var Query = {
createNew: function (sql, project) {
Expand Down Expand Up @@ -250,7 +252,11 @@ KylinApp

$scope.query = function (query) {
scrollToButton();
QueryService.query({}, {sql: query.sql, offset: 0, limit: $scope.rowsPerPage, acceptPartial: query.acceptPartial, project: query.project}, function (result) {
var backdoorToggles = null;
if ($scope.selectDirective.selected != null && $scope.selectDirective.selected !== "-- All cubes in current project --") {
backdoorToggles = {"DEBUG_TOGGLE_HIT_CUBE": $scope.selectDirective.selected};
}
QueryService.query({}, {sql: query.sql, offset: 0, limit: $scope.rowsPerPage, acceptPartial: query.acceptPartial, project: query.project, backdoorToggles: backdoorToggles}, function (result) {
scrollToButton();
$scope.parseQueryResult(query, result, (!result || result.isException) ? 'failed' : 'success');
$scope.curQuery.result.hasMore = (query.result.results && query.result.results.length == $scope.rowsPerPage);
Expand Down Expand Up @@ -397,6 +403,10 @@ KylinApp
});
}

$scope.getSelected = function (selected) {
$scope.selectDirective = selected;
}

var saveQueryController = function ($scope, $modalInstance, curQuery, QueryService) {
$scope.curQuery = curQuery;

Expand All @@ -415,6 +425,20 @@ KylinApp
$scope.$watch('projectModel.selectedProject', function (newValue, oldValue) {
$scope.listCachedQueries();
$scope.listSavedQueries();
$scope.cubeItems = [];
$scope.cubeItems.push("-- All cubes in current project --")
if ($scope.selectDirective != null) {
$scope.selectDirective.clearSelected();
}
CubeService.list({projectName:newValue}, function (_cubes) {
if (_cubes !== 0) {
angular.forEach(_cubes,function(cube){
if (cube.status==="READY"){
$scope.cubeItems.push(cube.name);
}
})
}
})
});

$scope.$on('$locationChangeStart', function (event, next, current) {
Expand Down
4 changes: 4 additions & 0 deletions webapp/app/js/directives/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ uis.controller('uiSelectCtrl',
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '' || (ctrl.multiple && ctrl.selected.length === 0);
};

ctrl.clearSelected = function() {
ctrl.selected = undefined;
}

function _findIndex(collection, predicate, thisArg){
if (collection.findIndex){
return collection.findIndex(predicate, thisArg);
Expand Down
12 changes: 12 additions & 0 deletions webapp/app/partials/query/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
<div class="pull-left">
<h4>
Project: <span class="label label-info">{{projectModel.getSelectedProject()}}</span>
&nbsp&nbsp Cube:
<ui-select style="display: inline-flex; width: 250px" ng-model="mandatary_cube" ng-init="getSelected($select)">
<ui-select-match placeholder="Filter ..." style="overflow: auto;width: 250px">{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="cube in cubeItems | filter:$select.search" style="word-break:break-all;">
<span ng-bind-html="cube | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
<i class="fa fa-info-circle" title="Specify cube to query" kylinpopover template="specifyCubeTip.html" placement="right"></i>
</h4>
</div>
<div class="pull-right">
Expand Down Expand Up @@ -229,3 +237,7 @@ <h3 class="kylin_title">
</div>

<div ng-include="'partials/projects/project_create.html'"></div>

<script type="text/ng-template" id="specifyCubeTip.html">
<p style="font-size: 8px;">Specify the cube to query, other cubes in current project won't be queried.</p>
</script>

0 comments on commit 0b2b94e

Please sign in to comment.