From a4893bc2fb35abdb577bbea3aa85c0079ece5d5f Mon Sep 17 00:00:00 2001 From: kunw Date: Tue, 3 May 2016 18:29:58 +0800 Subject: [PATCH] updates on project and details page of UI --- static/ng/resources/css/footer.css | 1 + static/ng/resources/css/repository.css | 7 ++ .../details/retrieve-projects.directive.html | 2 +- .../details/retrieve-projects.directive.js | 40 ++++++++- .../log/advanced-search.directive.html | 4 +- .../project/list-project.directive.html | 14 ---- .../project/list-project.directive.js | 84 ------------------- .../repository/list-repository.directive.html | 2 +- .../repository/list-repository.directive.js | 19 ++--- .../js/layout/details/details.config.js | 4 +- .../js/layout/details/details.controller.js | 23 +---- .../navigation-details.directive.js | 11 +-- .../js/layout/project/project.controller.js | 65 +++++++++++--- .../repository/services.list-repository.js | 11 +-- views/ng/project.htm | 19 ++++- views/ng/repository.htm | 2 +- views/ng/sections/headerInclude.htm | 1 - 17 files changed, 137 insertions(+), 172 deletions(-) delete mode 100644 static/ng/resources/js/components/project/list-project.directive.html delete mode 100644 static/ng/resources/js/components/project/list-project.directive.js diff --git a/static/ng/resources/css/footer.css b/static/ng/resources/css/footer.css index 135b2d61e..00533e0a6 100644 --- a/static/ng/resources/css/footer.css +++ b/static/ng/resources/css/footer.css @@ -8,6 +8,7 @@ clear: both; background-color: #A8A8A8; height: 35px; + z-index: 2; } .footer p { margin-top: 8px; diff --git a/static/ng/resources/css/repository.css b/static/ng/resources/css/repository.css index b6e3b4e88..5ac952216 100644 --- a/static/ng/resources/css/repository.css +++ b/static/ng/resources/css/repository.css @@ -96,3 +96,10 @@ line-height: 2.5em; margin: 0 0.5em 0 0; } + +.input-group .form-control { + z-index: 1; +} +.well { + padding: 12px; +} \ No newline at end of file diff --git a/static/ng/resources/js/components/details/retrieve-projects.directive.html b/static/ng/resources/js/components/details/retrieve-projects.directive.html index 9c31d0cfe..7efbd2799 100644 --- a/static/ng/resources/js/components/details/retrieve-projects.directive.html +++ b/static/ng/resources/js/components/details/retrieve-projects.directive.html @@ -7,7 +7,7 @@ - +
@@ -35,7 +35,7 @@
- +
diff --git a/static/ng/resources/js/components/project/list-project.directive.html b/static/ng/resources/js/components/project/list-project.directive.html deleted file mode 100644 index 98703eaad..000000000 --- a/static/ng/resources/js/components/project/list-project.directive.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -
Project NameRepositoriesRoleCreation TimePublicity
//p.Name//N/AN/A//p.CreationTime | dateL : 'YYYY-MM-DD HH:mm:ss'//
\ No newline at end of file diff --git a/static/ng/resources/js/components/project/list-project.directive.js b/static/ng/resources/js/components/project/list-project.directive.js deleted file mode 100644 index ab411cef9..000000000 --- a/static/ng/resources/js/components/project/list-project.directive.js +++ /dev/null @@ -1,84 +0,0 @@ -(function() { - - 'use strict'; - - angular - .module('harbor.project') - .directive('listProject', listProject); - - ListProjectController.$inject = ['ListProjectService', 'CurrentUserService', '$scope']; - - function ListProjectController(ListProjectService, CurrentUserService, $scope) { - var vm = this; - - vm.retrieve = retrieve; - vm.reload = reload; - - vm.getCurrentUser = getCurrentUser; - vm.resultCount = 0; - vm.publicity = 0; - - function reload() { - $.when(vm.getCurrentUser()) - .done(function(e) { - vm.retrieve(); - }); - } - - vm.reload(); - - $scope.$on('needToReload', function(e, val) { - if(val) { - vm.reload(); - } - }); - - function retrieve() { - ListProjectService(vm.projectName, vm.publicity) - .success(listProjectSuccess) - .error(listProjectFailed); - } - - function listProjectSuccess(data, status) { - vm.projects = data; - if(data) { - vm.resultCount = vm.projects.length; - } - } - function listProjectFailed(e) { - console.log('Failed in listProject:' + e); - } - - function getCurrentUser() { - CurrentUserService() - .success(getCurrentUserSuccess) - .error(getCurrentUserFailed); - } - - function getCurrentUserSuccess(data, status) { - vm.currentUser = data; - } - - function getCurrentUserFailed(e) { - console.log('Failed in getCurrentUser:' + e); - } - - } - - function listProject() { - var directive = { - 'restrict': 'E', - 'templateUrl': '/static/ng/resources/js/components/project/list-project.directive.html', - 'scope': { - 'projectName': '=', - 'publicity': '=', - 'resultCount': '=' - }, - 'controller': ListProjectController, - 'controllerAs': 'vm', - 'bindToController': true - }; - return directive; - } - -})(); \ No newline at end of file diff --git a/static/ng/resources/js/components/repository/list-repository.directive.html b/static/ng/resources/js/components/repository/list-repository.directive.html index 7a76f2fc7..73b38d3f4 100644 --- a/static/ng/resources/js/components/repository/list-repository.directive.html +++ b/static/ng/resources/js/components/repository/list-repository.directive.html @@ -4,7 +4,7 @@
- +
diff --git a/static/ng/resources/js/components/repository/list-repository.directive.js b/static/ng/resources/js/components/repository/list-repository.directive.js index b1d7ed2fb..cd5b559f1 100644 --- a/static/ng/resources/js/components/repository/list-repository.directive.js +++ b/static/ng/resources/js/components/repository/list-repository.directive.js @@ -5,33 +5,30 @@ .module('harbor.repository') .directive('listRepository', listRepository); - ListRepositoryController.$inject = ['$scope', '$q', 'ListRepositoryService', 'ListTagService', 'nameFilter', '$routeParams']; + ListRepositoryController.$inject = ['$scope', 'ListRepositoryService', 'ListTagService', 'nameFilter', '$routeParams']; - function ListRepositoryController($scope, $q, ListRepositoryService, ListTagService, nameFilter, $routeParams) { + function ListRepositoryController($scope, ListRepositoryService, ListTagService, nameFilter, $routeParams) { var vm = this; vm.filterInput = ""; - vm.expand = expand; - vm.retrieve = retrieve; - + vm.expand = expand; vm.projectId = $routeParams.project_id; - vm.retrieve(vm.projectId, vm.filterInput); - - function retrieve(projectId, filterInput) { - ListRepositoryService({'projectId': projectId, 'q': filterInput}) + vm.retrieve(); + + function retrieve(){ + ListRepositoryService(vm.projectId, vm.filterInput) .success(getRepositoryComplete) .error(getRepositoryFailed); } function getRepositoryComplete(data, status) { - console.log(data); vm.repositories = data; } function getRepositoryFailed(repsonse) { - + console.log('failed to list repositories:' + response); } function expand(e) { diff --git a/static/ng/resources/js/layout/details/details.config.js b/static/ng/resources/js/layout/details/details.config.js index 481586f4e..d5aeee5ee 100644 --- a/static/ng/resources/js/layout/details/details.config.js +++ b/static/ng/resources/js/layout/details/details.config.js @@ -32,7 +32,7 @@ return filter; function filter(input, filterInput, key) { - input = input || ''; + input = input || []; var filteredResults = []; if (filterInput != '') { @@ -41,7 +41,7 @@ if((key == "" && item.indexOf(filterInput) >= 0) || (key != "" && item[key].indexOf(filterInput) >= 0)) { filteredResults.push(item); continue; - } + } } input = filteredResults; } diff --git a/static/ng/resources/js/layout/details/details.controller.js b/static/ng/resources/js/layout/details/details.controller.js index 7b6b2b864..7a21921bf 100644 --- a/static/ng/resources/js/layout/details/details.controller.js +++ b/static/ng/resources/js/layout/details/details.controller.js @@ -6,30 +6,13 @@ .module('harbor.details') .controller('DetailsController', DetailsController); - DetailsController.$inject = ['ListProjectService', '$scope', '$location']; + DetailsController.$inject = ['ListProjectService', '$scope', '$location', '$routeParams']; - function DetailsController(ListProjectService, $scope, $location) { + function DetailsController(ListProjectService, $scope, $location, $routeParams) { var vm = this; vm.isOpen = false; vm.closeRetrievePane = closeRetrievePane; - vm.projectName = ''; - vm.isPublic = 0; - - - ListProjectService(vm.projectName, vm.isPublic) - .then(getProjectComplete) - .catch(getProjectFailed); - - function getProjectComplete(response) { - vm.projects = response.data; - vm.selectedProject = vm.projects[0]; - $location.url('repositories').search('project_id', vm.selectedProject.ProjectId); - } - - function getProjectFailed(response) { - - } - + function closeRetrievePane() { $scope.$broadcast('isOpen', false); } diff --git a/static/ng/resources/js/layout/navigation/navigation-details.directive.js b/static/ng/resources/js/layout/navigation/navigation-details.directive.js index 0a29a9c5a..1ec650a0a 100644 --- a/static/ng/resources/js/layout/navigation/navigation-details.directive.js +++ b/static/ng/resources/js/layout/navigation/navigation-details.directive.js @@ -47,14 +47,9 @@ function link(scope, element, attrs, ctrl) { - var visited = ctrl.url; - - if(visited == "/") { - element.find('a:first').addClass('active'); - }else{ - element.find('a[href$="' + visited + '"]').addClass('active'); - } - + var visited = ctrl.url.substring(1, ctrl.url.indexOf('?') - 1); + + element.find('a[tag^="' + visited + '"]').addClass('active'); element.on('click', click); function click(event) { diff --git a/static/ng/resources/js/layout/project/project.controller.js b/static/ng/resources/js/layout/project/project.controller.js index 9cb044522..aa54ae3e1 100644 --- a/static/ng/resources/js/layout/project/project.controller.js +++ b/static/ng/resources/js/layout/project/project.controller.js @@ -6,21 +6,60 @@ .module('harbor.layout.project') .controller('ProjectController', ProjectController); - ProjectController.$inject = ['$scope']; + ProjectController.$inject = ['$scope', 'ListProjectService', 'CurrentUserService']; - function ProjectController($scope) { + function ProjectController($scope, ListProjectService, CurrentUserService) { var vm = this; - vm.showAddProject = showAddProject; - vm.isOpen = false; - vm.searchProject = searchProject; - vm.inputProjectName = ""; - vm.inputPublicity = 0; + vm.isOpen = false; + vm.projectName = ''; + vm.publicity = 0; + + vm.retrieve = retrieve; + vm.getCurrentUser = getCurrentUser; + vm.showAddProject = showAddProject; + vm.searchProject = searchProject; vm.showAddButton = showAddButton; vm.togglePublicity = togglePublicity; + vm.retrieve(); + + function retrieve() { + $.when( + CurrentUserService() + .success(getCurrentUserSuccess) + .error(getCurrentUserFailed)) + .then(function(){ + ListProjectService(vm.projectName, vm.publicity) + .success(listProjectSuccess) + .error(listProjectFailed); + }); + } + + function listProjectSuccess(data, status) { + vm.projects = data; + } + + function listProjectFailed(e) { + console.log('Failed to list Project:' + e); + } + + function getCurrentUser() { + CurrentUserService() + .success(getCurrentUserSuccess) + .error(getCurrentUserFailed); + } + + function getCurrentUserSuccess(data, status) { + vm.currentUser = data; + } + + function getCurrentUserFailed(e) { + console.log('Failed in getCurrentUser:' + e); + } + $scope.$on('addedSuccess', function(e, val) { - $scope.$broadcast('needToReload', true); + vm.retrieve(); }); function showAddProject() { @@ -32,11 +71,11 @@ } function searchProject() { - $scope.$broadcast('needToReload', true); + vm.retrieve(); } function showAddButton() { - if(vm.inputPublicity == 0) { + if(vm.publicity == 0) { return true; }else{ return false; @@ -44,9 +83,9 @@ } function togglePublicity(e) { - vm.inputPublicity = e.publicity; - $scope.$broadcast('needToReload', true); - console.log('vm.inputPublicity:' + vm.inputPublicity); + vm.publicity = e.publicity; + vm.retrieve(); + console.log('vm.publicity:' + vm.publicity); } } diff --git a/static/ng/resources/js/services/repository/services.list-repository.js b/static/ng/resources/js/services/repository/services.list-repository.js index fbd92726e..10cb815d4 100644 --- a/static/ng/resources/js/services/repository/services.list-repository.js +++ b/static/ng/resources/js/services/repository/services.list-repository.js @@ -9,14 +9,11 @@ function ListRepositoryService($http, $log) { - return RepositoryResult; + return ListRepository; - function RepositoryResult(queryParams) { - $log.info(queryParams); - - var projectId = queryParams.projectId; - var q = queryParams.q; - + function ListRepository(projectId, q) { + $log.info('list repositories:' + projectId + ', q:' + q); + return $http .get('/api/repositories', { 'params':{ diff --git a/views/ng/project.htm b/views/ng/project.htm index 4453e521b..df12e8439 100644 --- a/views/ng/project.htm +++ b/views/ng/project.htm @@ -7,7 +7,7 @@
- + @@ -18,9 +18,22 @@
- + + + + + + + + + + + + + +
Project NameRepositoriesRoleCreation TimePublicity
//p.Name//N/AN/A//p.CreationTime | dateL : 'YYYY-MM-DD HH:mm:ss'//
-
//vm.resultCount// items
+
//vm.projects ? vm.projects.length : 0// items
diff --git a/views/ng/repository.htm b/views/ng/repository.htm index ac233ad48..3d40ceb86 100644 --- a/views/ng/repository.htm +++ b/views/ng/repository.htm @@ -10,7 +10,7 @@
- +
diff --git a/views/ng/sections/headerInclude.htm b/views/ng/sections/headerInclude.htm index 52ae34197..2351d353b 100644 --- a/views/ng/sections/headerInclude.htm +++ b/views/ng/sections/headerInclude.htm @@ -101,7 +101,6 @@ -