update for retrieving repos and tags.

This commit is contained in:
kunw 2016-06-29 12:23:03 +08:00
parent 48c9cbd3c3
commit 149e07f51c
3 changed files with 17 additions and 14 deletions

View File

@ -14,7 +14,7 @@
<div class="sub-pane"> <div class="sub-pane">
<div ng-if="vm.repositories.length > 0" class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <div ng-if="vm.repositories.length > 0" class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<modal-dialog action="vm.deleteImage()" content-type="text/html" modal-title="//vm.modalTitle//" modal-message="//vm.modalMessage//"></modal-dialog> <modal-dialog action="vm.deleteImage()" content-type="text/html" modal-title="//vm.modalTitle//" modal-message="//vm.modalMessage//"></modal-dialog>
<div class="panel panel-default" ng-repeat="repo in vm.repositories"> <div class="panel panel-default" ng-repeat="repo in vm.repositories" ng-show="vm.tagCount[repo] > 0">
<div class="panel-heading" role="tab" id="heading//$index + 1//"> <div class="panel-heading" role="tab" id="heading//$index + 1//">
<h4 class="panel-title"> <h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="" href="?project_id=//vm.projectId//#collapse//$index + 1//" aria-expanded="true" aria-controls="collapse//$index+1//"> <a role="button" data-toggle="collapse" data-parent="" href="?project_id=//vm.projectId//#collapse//$index + 1//" aria-expanded="true" aria-controls="collapse//$index+1//">

View File

@ -33,12 +33,6 @@
vm.projectId = getParameterByName('project_id', $location.absUrl()); vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.retrieve(); vm.retrieve();
$scope.$on('$locationChangeStart', function() {
console.log('triggered locationChangeStart....');
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.retrieve();
});
$scope.$on('$locationChangeSuccess', function() { $scope.$on('$locationChangeSuccess', function() {
vm.projectId = getParameterByName('project_id', $location.absUrl()); vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.retrieve(); vm.retrieve();
@ -82,6 +76,7 @@
function getRepositoryComplete(data, status) { function getRepositoryComplete(data, status) {
vm.repositories = data || []; vm.repositories = data || [];
$scope.$broadcast('refreshTags', true);
} }
function getRepositoryFailed(response) { function getRepositoryFailed(response) {

View File

@ -12,18 +12,29 @@
var vm = this; var vm = this;
vm.tags = []; vm.tags = [];
vm.retrieve = retrieve;
$scope.$watch('vm.repoName', function(current, origin) { $scope.$watch('vm.repoName', function(current, origin) {
if(current) { if(current) {
console.log('vm.repoName in tags:' + current); console.log('vm.repoName in tags:' + current);
ListTagService(current) vm.retrieve();
.then(getTagComplete) }
.catch(getTagFailed); });
$scope.$on('refreshTags', function(e, val) {
if(val) {
vm.retrieve();
} }
}); });
vm.deleteByTag = deleteByTag; vm.deleteByTag = deleteByTag;
function retrieve() {
ListTagService(vm.repoName)
.then(getTagComplete)
.catch(getTagFailed);
}
function getTagComplete(response) { function getTagComplete(response) {
vm.tags = response.data; vm.tags = response.data;
vm.tagCount[vm.repoName] = vm.tags.length; vm.tagCount[vm.repoName] = vm.tags.length;
@ -45,7 +56,6 @@
}else { }else {
message = $filter('tr')('alert_delete_tag', [e.tag]); message = $filter('tr')('alert_delete_tag', [e.tag]);
} }
$scope.$emit('modalMessage', message); $scope.$emit('modalMessage', message);
} }
@ -71,8 +81,6 @@
function link(scope, element, attrs, ctrl) { function link(scope, element, attrs, ctrl) {
} }
} }
})(); })();