mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-18 22:57:38 +01:00
Merge pull request #4444 from ywk253100/180320_project
Return role and repository count info in GET project API
This commit is contained in:
commit
da41a1c1d4
@ -199,6 +199,8 @@ func (p *ProjectAPI) Get() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.populateProperties(p.project)
|
||||||
|
|
||||||
p.Data["json"] = p.project
|
p.Data["json"] = p.project
|
||||||
p.ServeJSON()
|
p.ServeJSON()
|
||||||
}
|
}
|
||||||
@ -372,6 +374,15 @@ func (p *ProjectAPI) List() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, project := range result.Projects {
|
for _, project := range result.Projects {
|
||||||
|
p.populateProperties(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.SetPaginationHeader(result.Total, page, size)
|
||||||
|
p.Data["json"] = result.Projects
|
||||||
|
p.ServeJSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ProjectAPI) populateProperties(project *models.Project) {
|
||||||
if p.SecurityCtx.IsAuthenticated() {
|
if p.SecurityCtx.IsAuthenticated() {
|
||||||
roles := p.SecurityCtx.GetProjectRoles(project.ProjectID)
|
roles := p.SecurityCtx.GetProjectRoles(project.ProjectID)
|
||||||
if len(roles) != 0 {
|
if len(roles) != 0 {
|
||||||
@ -391,11 +402,6 @@ func (p *ProjectAPI) List() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
project.RepoCount = len(repos)
|
project.RepoCount = len(repos)
|
||||||
}
|
|
||||||
|
|
||||||
p.SetPaginationHeader(result.Total, page, size)
|
|
||||||
p.Data["json"] = result.Projects
|
|
||||||
p.ServeJSON()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put ...
|
// Put ...
|
||||||
|
Loading…
Reference in New Issue
Block a user