From 02e8fe6635f0f6f80f03a1fd44728c10cfe510eb Mon Sep 17 00:00:00 2001 From: jiazhong Date: Wed, 29 Oct 2014 14:12:37 +0800 Subject: [PATCH 01/26] add project2home branch --- server/src/main/resources/kylinSecurity.xml | 1 + webapp/app/js/controllers/cubes.js | 22 ++++++++++-------- webapp/app/js/controllers/job.js | 10 ++++++-- webapp/app/js/controllers/page.js | 19 ++++++++++++++- webapp/app/js/controllers/projectMeta.js | 27 +++++----------------- webapp/app/partials/cubes/cubes.html | 10 +------- webapp/app/partials/header.html | 11 ++++++++- webapp/app/partials/jobs/jobs.html | 8 ------- webapp/app/partials/login.html | 10 ++++++++ .../app/partials/projects/project_table_tree.html | 10 -------- 10 files changed, 67 insertions(+), 61 deletions(-) diff --git a/server/src/main/resources/kylinSecurity.xml b/server/src/main/resources/kylinSecurity.xml index ee3f3e2..9ad18bd 100644 --- a/server/src/main/resources/kylinSecurity.xml +++ b/server/src/main/resources/kylinSecurity.xml @@ -20,6 +20,7 @@ + diff --git a/webapp/app/js/controllers/cubes.js b/webapp/app/js/controllers/cubes.js index ece6f01..bc6d038 100644 --- a/webapp/app/js/controllers/cubes.js +++ b/webapp/app/js/controllers/cubes.js @@ -4,10 +4,10 @@ KylinApp .controller('CubesCtrl', function ($scope, $q, $routeParams, $location, $modal, MessageService, CubeDescService, CubeService, JobService, UserService, ProjectService) { $scope.listParams={ cubeName: $routeParams.cubeName, - projectName: null + projectName: $scope.project.selectedProject }; $scope.cubes = []; - $scope.projects = []; +// $scope.projects = []; $scope.loading = false; $scope.action = {}; @@ -24,11 +24,11 @@ KylinApp $scope.state = { filterAttr: 'create_time', filterReverse: true, reverseColumn: 'create_time', dimensionFilter: '', measureFilter: ''}; - ProjectService.list({}, function (projects) { - angular.forEach(projects, function(project, index){ - $scope.projects.push(project.name); - }); - }); +// ProjectService.list({}, function (projects) { +// angular.forEach(projects, function(project, index){ +// $scope.projects.push(project.name); +// }); +// }); $scope.list = function (offset, limit) { offset = (!!offset) ? offset : 0; @@ -39,8 +39,8 @@ KylinApp if ($scope.listParams.cubeName) { queryParam.cubeName = $scope.listParams.cubeName; } - if ($scope.listParams.projectName){ - queryParam.projectName = $scope.listParams.projectName; + if ($scope.project.selectedProject){ + queryParam.projectName = $scope.project.selectedProject; } $scope.loading = true; @@ -65,6 +65,10 @@ KylinApp return defer.promise; } + $scope.$watch('project.selectedProject', function (newValue, oldValue) { + $scope.cubes=[]; + $scope.list(); + }); $scope.reload = function () { // trigger reload action in pagination directive $scope.action.reload = !$scope.action.reload; diff --git a/webapp/app/js/controllers/job.js b/webapp/app/js/controllers/job.js index 7a0df27..ab522a7 100644 --- a/webapp/app/js/controllers/job.js +++ b/webapp/app/js/controllers/job.js @@ -22,7 +22,8 @@ KylinApp {attr: 'duration', name: 'Duration'} ]; $scope.status = [$scope.allStatus[0], $scope.allStatus[1], $scope.allStatus[2], $scope.allStatus[3], $scope.allStatus[4], $scope.allStatus[5]]; - $scope.state = {loading: false, refreshing: false, filterAttr: 'last_modified', filterReverse: true, reverseColumn: 'last_modified', projectName:null}; + // projectName from page ctrl + $scope.state = {loading: false, refreshing: false, filterAttr: 'last_modified', filterReverse: true, reverseColumn: 'last_modified', projectName:$scope.project.selectedProject}; ProjectService.list({}, function (projects) { angular.forEach(projects, function(project, index){ @@ -77,8 +78,13 @@ KylinApp $scope.reload = function () { // trigger reload action in pagination directive $scope.action.reload = !$scope.action.reload; - } + }; + $scope.$watch('project.selectedProject', function (newValue, oldValue) { + $scope.jobs={}; + $scope.state.projectName = $scope.project.selectedProject; + $scope.list(); + }); $scope.resume = function (job) { if (confirm("Are you sure to resume the job?")) { JobService.resume({jobId: job.uuid}, {}, function (job) { diff --git a/webapp/app/js/controllers/page.js b/webapp/app/js/controllers/page.js index 960ea28..e2187f6 100644 --- a/webapp/app/js/controllers/page.js +++ b/webapp/app/js/controllers/page.js @@ -1,6 +1,6 @@ 'use strict'; -KylinApp.controller('PageCtrl', function ($scope, $q, AccessService, $location, $rootScope, $routeParams, $http, UserService) { +KylinApp.controller('PageCtrl', function ($scope, $q, AccessService, $location, $rootScope, $routeParams, $http, UserService,ProjectService) { $scope.header = {show: true}; $scope.footer = { @@ -116,6 +116,23 @@ KylinApp.controller('PageCtrl', function ($scope, $q, AccessService, $location, return size; } + + + $scope.project = { + projects:[], + selectedProject: null + }; + ProjectService.list({}, function (projects) { + angular.forEach(projects, function(project, index){ + $scope.project.projects.push(project.name); + }); + }); + +// $scope.$watch('curProject', function (newValue, oldValue) { +// if (newValue) { +// $scope.curProject = newValue; +// } +// }); }); var projCtrl = function ($scope, $modalInstance, ProjectService, MessageService, projects, project) { diff --git a/webapp/app/js/controllers/projectMeta.js b/webapp/app/js/controllers/projectMeta.js index 37081ff..45d5d75 100644 --- a/webapp/app/js/controllers/projectMeta.js +++ b/webapp/app/js/controllers/projectMeta.js @@ -2,7 +2,6 @@ KylinApp .controller('ProjectMetaCtrl', function ($scope, $q, ProjectService, QueryService) { - $scope.projects = []; $scope.selectedSrcDb = []; $scope.treeOptions = { nodeChildren: "columns", @@ -16,30 +15,13 @@ KylinApp label: "a6", labelSelected: "a8" } - } - - ProjectService.list({}, function (projects) { - angular.forEach(projects, function (project, index) { - $scope.projects.push(project.name); - }); - - if ($scope.projects.length > 0) - { - $scope.state.selectedProject=$scope.projects[0]; - $scope.projectMetaLoad(); - } - }); + }; $scope.projectMetaLoad = function () { - if (!$scope.state.selectedProject) - { - return; - } var defer = $q.defer(); $scope.selectedSrcDb = []; - $scope.loading = true; - QueryService.getTables({project: $scope.state.selectedProject}, {}, function (tables) { + QueryService.getTables({project: $scope.project.selectedProject}, {}, function (tables) { var tableMap = []; angular.forEach(tables, function (table) { if (!tableMap[table.table_SCHEM]) { @@ -63,7 +45,6 @@ KylinApp $scope.loading = false; defer.resolve(); }); - return defer.promise; } @@ -75,5 +56,9 @@ KylinApp return typeName.trim().toLowerCase(); } + + $scope.$watch('project.selectedProject', function (newValue, oldValue) { + $scope.projectMetaLoad(); + }); }); diff --git a/webapp/app/partials/cubes/cubes.html b/webapp/app/partials/cubes/cubes.html index a0a7e31..2086c13 100644 --- a/webapp/app/partials/cubes/cubes.html +++ b/webapp/app/partials/cubes/cubes.html @@ -1,14 +1,6 @@ - +