Skip to content

Commit

Permalink
Merge pull request goharbor#21 from DanielWangZhanggui/metadata
Browse files Browse the repository at this point in the history
后端分页代码
  • Loading branch information
zxydaisy authored Jul 20, 2016
2 parents 882cf7a + 75b862f commit 37e1870
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
16 changes: 7 additions & 9 deletions Deploy/harbor.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#The IP address or hostname to access admin UI and registry service.
#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname = reg.mydomain.com
hostname = registry.example.com

#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = http
ui_url_protocol = https

#Email account settings for sending out password resetting emails.
email_server = smtp.mydomain.com
Expand All @@ -24,7 +24,7 @@ harbor_admin_password = Harbor12345
auth_mode = db_auth

#The url for an ldap endpoint.
ldap_url = ldaps://ldap.mydomain.com
ldap_url = ldap://ldap.mydomain.com

#The basedn template to look up a user in LDAP and verify the user's password.
#For AD server, uses this template:
Expand All @@ -47,12 +47,10 @@ max_job_workers = 3
#Determine whether the job service should verify the ssl cert when it connects to a remote registry.
#Set this flag to off when the remote registry uses a self-signed or untrusted certificate.
verify_remote_cert = on

#Determine whether or not to generate certificate for the registry's token.
#If the value is on, the prepare script creates new root cert and private key
#for generating token to access the registry. If the value is off, a key/certificate must
#be supplied for token generation.
customize_crt = on
#Turn on or off the customize your certificate for registry's token.
#If the value is on, the prepare script will generate new root cert and private key
#for generating token to access the image in registry.
customize_crt = off

#Information of your organization for certificate
crt_country = CN
Expand Down
39 changes: 23 additions & 16 deletions api/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,23 @@ type labelReq struct {
LabelName string `json:"label_name"`
}

type repoReq struct {
ProjectID int64 `json:"project_id"`
PageNum int `json:"pageNum"`
Query string `json:q`
}

// Get ...
func (ra *RepositoryAPI) Get() {
projectID, err := ra.GetInt64("project_id")
if err != nil {
log.Errorf("Failed to get project id, error: %v", err)
ra.RenderError(http.StatusBadRequest, "Invalid project id")
return
}
var req repoReq
ra.DecodeJSONReq(&req)
projectID := req.ProjectID
pageNum := req.PageNum
//if err != nil {
// log.Errorf("Failed to get project id, error: %v", err)
// ra.RenderError(http.StatusBadRequest, "Invalid project id")
// return
//}
p, err := dao.GetProjectByID(projectID)
if err != nil {
log.Errorf("Error occurred in GetProjectById, error: %v", err)
Expand Down Expand Up @@ -94,30 +103,28 @@ func (ra *RepositoryAPI) Get() {
}

projectName := p.Name
q := ra.GetString("q")
q := req.Query
var resp []string
if len(q) > 0 {
for _, r := range repoList {
if strings.Contains(r, "/") && strings.Contains(r[strings.LastIndex(r, "/")+1:], q) && r[0:strings.LastIndex(r, "/")] == projectName {
resp = append(resp, r)
}
labelList,_ := dao.GetRepoLabels(r)
for _, label := range labelList{
if strings.Contains(label, q) {
resp = append(resp, label)
}
}
}
ra.Data["json"] = resp
repoLs, _ := dao.GetRepoNames(q)
for _, repol := range repoLs {
resp = append(resp, repol)
}
ra.Data["json"] = getSubPage(resp, pageNum)
} else if len(projectName) > 0 {
for _, r := range repoList {
if strings.Contains(r, "/") && r[0:strings.LastIndex(r, "/")] == projectName {
resp = append(resp, r)
}
}
ra.Data["json"] = resp
ra.Data["json"] = getSubPage(resp, pageNum)
} else {
ra.Data["json"] = repoList
ra.Data["json"] = getSubPage(repoList, pageNum)
}
ra.ServeJSON()
}
Expand Down

0 comments on commit 37e1870

Please sign in to comment.