continuous updates for UI

This commit is contained in:
kunw 2016-04-27 18:29:55 +08:00
parent 2ab653c642
commit 44a8e5d578
20 changed files with 172 additions and 79 deletions

View File

@ -13,6 +13,10 @@
vm.isOpen = false;
vm.closeRetrievePane = closeRetrievePane;
$scope.$on('selectedProjectId', function(e, val) {
$scope.$broadcast('currentProjectId',val);
});
ListProjectService({'isPublic' : 0, 'projectName' : ''})
.then(getProjectComplete)
.catch(getProjectFailed);

View File

@ -6,9 +6,9 @@
.module('harbor.details')
.directive('retrieveProjects', retrieveProjects);
RetrieveProjectsController.$inject = ['$scope', 'nameFilter', '$routeParams'];
RetrieveProjectsController.$inject = ['$scope', 'nameFilter'];
function RetrieveProjectsController($scope, nameFilter, $routeParams) {
function RetrieveProjectsController($scope, nameFilter) {
var vm = this;
vm.selectItem = selectItem;
@ -16,16 +16,16 @@
$scope.$watch('vm.selectedProject', function(current, origin) {
if(current) {
var projectId = current.ProjectId || $routeParams.project_id;
var projectId = current.ProjectId;
vm.selectedId = projectId;
}
});
function selectItem(item) {
vm.selectedId = item.ProjectId;
vm.selectedProject = item;
vm.isOpen = false;
$scope.$emit('selectedProjectId', vm.selectedId);
}
}

View File

@ -6,9 +6,9 @@
.module('harbor.details')
.directive('switchPaneProjects', switchPaneProjects);
SwitchPaneProjectsController.$inject = ['$scope', '$routeParams'];
SwitchPaneProjectsController.$inject = ['$scope'];
function SwitchPaneProjectsController($scope, $routeParams) {
function SwitchPaneProjectsController($scope) {
var vm = this;
$scope.$on('isOpen', function(e, val){

View File

@ -32,7 +32,7 @@
<div class="col-xs-2 col-md-2">
<form>
<div class="form-group" style="margin-top: 40%;">
<button type="button" class="btn btn-primary" ng-click="vm.search()">Search</button>
<button type="button" class="btn btn-primary" ng-click="vm.search({op: vm.op})">Search</button>
</div>
</form>
</div>

View File

@ -12,7 +12,6 @@
var vm = this;
vm.checkOperation = checkOperation;
vm.search = search;
vm.opAll = true;
vm.opCreate = true;
@ -51,15 +50,6 @@
if(vm.opOthers) {
vm.op.push(vm.others);
}
}
function search() {
if(vm.opAll) {
vm.op = [];
vm.op.push('all');
}
console.log(vm.op.join(","));
}
}
@ -68,7 +58,10 @@
'restrict': 'E',
'templateUrl': '/static/ng/resources/js/components/log/advanced-search.directive.html',
'scope': {
'isOpen': '='
'isOpen': '=',
'op': '=',
'others': '=',
'search': '&'
},
'controller': AdvancedSearchController,
'controllerAs': 'vm',

View File

@ -2,9 +2,9 @@
<div class="col-xs-12 col-md-12 each-tab-pane">
<div class="form-inline">
<div class="input-group">
<input type="text" class="form-control" placeholder="" size="30">
<input type="text" class="form-control" placeholder="" ng-model="vm.username" size="30">
<span class="input-group-btn">
<button class="btn btn-primary" type="button"><span class="glyphicon glyphicon-search"></span></button>
<button class="btn btn-primary" type="button" ng-click="vm.search({username: vm.username})"><span class="glyphicon glyphicon-search"></span></button>
</span>
<span class="input-group-btn">
<button class="btn btn-link" type="button" ng-click="vm.advancedSearch()">Advanced Search</button>
@ -12,21 +12,15 @@
</div>
</div>
<div class="pane">
<advanced-search ng-show="vm.isOpen" is-open="vm.isOpen"></advanced-search>
<advanced-search ng-show="vm.isOpen" is-open="vm.isOpen" op="vm.op" others="vm.others" search='vm.aSearch({op: vm.op, others: vm.others})'></advanced-search>
<div class="sub-pane">
<table class="table table-pane">
<thead>
<th>Username</th><th>Repository Name</th><th>Operation</th><th>Timestamp</th>
</thead>
<tbody>
<tr>
<td>Haox</td><td>myrepo/Ubuntu</td><td>Create</td><td>2016-03-22 12:35:00</td>
</tr>
<tr>
<td>Haox</td><td>myrepo/MySQL</td><td>Push</td><td>2016-03-22 12:35:00</td>
</tr>
<tr>
<td>Daniel</td><td>myproject/Golang</td><td>Create</td><td>2016-03-12 12:35:00</td>
<tr ng-repeat="log in vm.logs">
<td>//log.Username//</td><td>//log.RepoName//</td><td>//log.Operation//</td><td>//log.OpTime//</td>
</tr>
</tbody>
</table>

View File

@ -6,13 +6,57 @@
.module('harbor.log')
.directive('listLog', listLog);
ListLogController.$inject = ['ListLogService'];
ListLogController.$inject = ['ListLogService', '$routeParams'];
function ListLogController(ListLogService) {
function ListLogController(ListLogService, $routeParams) {
var vm = this;
vm.isOpen = false;
vm.projectId = $routeParams.project_id;
vm.beginTimestamp = 0;
vm.endTimestamp = 0;
vm.keywords = "";
vm.username = "";
vm.op = [];
vm.others = "";
vm.search = search;
vm.aSearch= aSearch;
vm.advancedSearch = advancedSearch;
var queryParams = {
'beginTimestamp' : vm.beginTimestamp,
'endTimestamp' : vm.endTimestamp,
'keywords' : vm.keywords,
'projectId': vm.projectId,
'username' : vm.username
};
retrieve(queryParams);
function search(e) {
queryParams.username = e.username;
retrieve(queryParams);
}
function aSearch(e) {
if(e.op == 'all') {
queryParams.keywords = '';
}else {
queryParams.keywords = e.op.join('/') ;
}
if(e.others != "") {
queryParams.keywords += '/' + e.others;
}
queryParams.username = vm.username;
retrieve(queryParams);
}
function advancedSearch() {
if(vm.isOpen){
vm.isOpen = false;
@ -20,6 +64,20 @@
vm.isOpen = true;
}
}
function retrieve(queryParams) {
ListLogService(queryParams)
.then(listLogComplete)
.catch(listLogFailed);
}
function listLogComplete(response) {
vm.logs = response.data;
}
function listLogFailed(e){
console.log('listLogFailed:' + e);
}
}
function listLog() {

View File

@ -10,19 +10,32 @@
function AddProjectMemberController(roles, AddProjectMemberService) {
var vm = this;
vm.username = "";
vm.roles = roles();
vm.optRole = 1;
vm.save = save;
vm.cancel = cancel;
function save() {
console.log(vm.optRole);
AddProjectMemberService(2, vm.optRole, vm.username)
.success(addProjectMemberComplete)
.error(addProjectMemberFailed);
vm.isOpen = false;
}
function cancel() {
vm.isOpen = false;
}
function addProjectMemberComplete(data, status, header) {
console.log('addProjectMemberComplete: status:' + status + ', data:' + data);
}
function addProjectMemberFailed(data, status, headers) {
console.log('addProjectMemberFailed: status:' + status + ', data:' + data);
}
}
function addProjectMember() {

View File

@ -4,7 +4,7 @@
<div class="input-group">
<input type="text" class="form-control" placeholder="" ng-model="vm.username" size="30">
<span class="input-group-btn">
<button class="btn btn-primary" type="button" ng-click="vm.search({username: vm.username})"><span class="glyphicon glyphicon-search"></span></button>
<button class="btn btn-primary" type="button" ng-click="vm.search({projectId: vm.projectId, username: vm.username})"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
<button class="btn btn-success" type="button" ng-click="vm.addProjectMember()"><span class="glyphicon glyphicon-plus"></span>Add Member</button>

View File

@ -6,23 +6,25 @@
.module('harbor.project.member')
.directive('listProjectMember', listProjectMember);
ListProjectMemberController.$inject = ['ListProjectMemberService', '$routeParams'];
ListProjectMemberController.$inject = ['$scope', 'ListProjectMemberService', '$routeParams'];
function ListProjectMemberController(ListProjectMemberService, $routeParams) {
function ListProjectMemberController($scope, ListProjectMemberService, $routeParams) {
var vm = this;
vm.projectId = $routeParams.project_id;
vm.isOpen = false;
vm.username = "";
vm.search = search;
vm.addProjectMember = addProjectMember;
vm.projectId = $routeParams.project_id || 2;
retrieve(vm.projectId , vm.username);
retrieve(vm.username);
function search(e) {
retrieve(e.username);
console.log('project_id:' + e.projectId);
retrieve(e.projectId, e.username);
}
function addProjectMember() {
@ -33,8 +35,8 @@
}
}
function retrieve(username) {
ListProjectMemberService(vm.projectId, {'username': username})
function retrieve(projectId, username) {
ListProjectMemberService(projectId, {'username': username})
.then(getProjectMemberComplete)
.catch(getProjectMemberFailed);
}

View File

@ -5,17 +5,20 @@
.module('harbor.repository')
.directive('listRepository', listRepository);
ListRepositoryController.$inject = ['ListRepositoryService', 'ListTagService', 'nameFilter', '$routeParams'];
ListRepositoryController.$inject = ['$scope', 'ListRepositoryService', 'ListTagService', 'nameFilter', '$routeParams'];
function ListRepositoryController(ListRepositoryService, ListTagService, nameFilter, $routeParams) {
function ListRepositoryController($scope, ListRepositoryService, ListTagService, nameFilter, $routeParams) {
var vm = this;
vm.projectId = $routeParams.project_id;
vm.filterInput = "";
vm.expand = expand;
ListRepositoryService({'projectId': $routeParams.project_id, 'q': ''})
ListRepositoryService({'projectId': vm.projectId, 'q': ''})
.then(getRepositoryComplete)
.catch(getRepositoryFailed);
function getRepositoryComplete(response) {
vm.repositories = response.data;
}
@ -24,8 +27,6 @@
}
vm.expand = expand;
function expand(e) {
vm.tags = [];
ListTagService(e.repoName)
@ -47,9 +48,6 @@
restrict: 'E',
templateUrl: '/static/ng/resources/js/components/repository/list-repository.directive.html',
replace: true,
scope: {
'info': '='
},
controller: ListRepositoryController,
controllerAs: 'vm',
bindToController: true

View File

@ -1,5 +1,5 @@
<ul class="switch-pane-tabs" role="tablist">
<li><a tag="repositories" ng-click="vm.clickTab()" href="/ng/repository#/repositories">Repositories</a><span class="gutter">|</span></li>
<li><a tag="users" ng-click="vm.clickTab()" href="/ng/repository#/users">Users</a><span class="gutter">|</span></li>
<li><a tag="logs" ng-click="vm.clickTab()" href="/ng/repository#/logs">Logs</a></li>
<li><a tag="repositories" ng-click="vm.clickTab()" href="/ng/repository#/repositories?project_id=//vm.selectedProject.ProjectId//">Repositories</a><span class="gutter">|</span></li>
<li><a tag="users" ng-click="vm.clickTab()" href="/ng/repository#/users?project_id=//vm.selectedProject.ProjectId//">Users</a><span class="gutter">|</span></li>
<li><a tag="logs" ng-click="vm.clickTab()" href="/ng/repository#/logs?project_id=//vm.selectedProject.ProjectId//">Logs</a></li>
</ul>

View File

@ -30,7 +30,8 @@
templateUrl: '/static/ng/resources/js/layout/navigation/navigation-details.directive.html',
link: link,
scope: {
'isOpen': "="
'isOpen': '=',
'selectedProject': '='
},
replace: true,
controller: NavigationDetailsController,

View File

@ -6,8 +6,14 @@
.module('harbor.layout.project.member')
.controller('ProjectMemberController', ProjectMemberController);
function ProjectMemberController() {
ProjectMemberController.$inject = ['$scope'];
function ProjectMemberController($scope) {
var vm = this;
$scope.$on('currentProjectId', function(e, val) {
console.log('received currentProjecjtId: ' + val + ' in ProjectMemberController');
vm.projectId = val;
});
}
})();

View File

@ -1 +1 @@
<list-repository info="vm.info"></list-repository>
<list-repository></list-repository>

View File

@ -6,8 +6,16 @@
.module('harbor.layout.repository')
.controller('RepositoryController', RepositoryController);
function RepositoryController() {
RepositoryController.$inject = ['$scope'];
function RepositoryController($scope) {
var vm = this;
$scope.$on('currentProjectId', function(e, val) {
console.log('received currentProjecjtId: ' + val + ' in RepositoryController');
vm.projectId = val;
});
}
})();

View File

@ -13,7 +13,20 @@
return LogResult;
function LogResult(queryParams) {
$log.info(queryParams);
var projectId = queryParams.projectId;
var username = queryParams.username;
var beginTimestamp = queryParams.beginTimestamp;
var endTimestamp = queryParams.endTimestamp;
var keywords = queryParams.keywords;
return $http
.post('/api/projects/' + projectId + '/logs/filter', {
'beginTimestamp' : beginTimestamp,
'endTimestamp' : endTimestamp,
'keywords' : keywords,
'project_id': projectId,
'username' : username
});
}
}
})();

View File

@ -12,8 +12,12 @@
return AddProjectMember;
function AddProjectMember(projectMember) {
function AddProjectMember(projectId, roles, username) {
return $http
.post('/api/projects/' + projectId + '/members/', {
'roles': [ Number(roles) ],
'user_name': username
});
}
}

View File

@ -7,7 +7,7 @@
<div class="switch-pane">
<switch-pane-projects is-open="vm.open" selected-project="vm.selectedProject"></switch-pane-projects>
<span>
<navigation-details is-open="vm.open"></navigation-details>
<navigation-details is-open="vm.open" selected-project="vm.selectedProject"></navigation-details>
</span>
</div>
<retrieve-projects is-open="vm.open" projects="vm.projects" selected-project="vm.selectedProject"></retrieve-projects>
@ -18,5 +18,4 @@
</div>
</div>
</div>
</div>
</div>