diff --git a/modules/cloudbrain/resty.go b/modules/cloudbrain/resty.go
index a58e31e20..bee9967ec 100755
--- a/modules/cloudbrain/resty.go
+++ b/modules/cloudbrain/resty.go
@@ -150,6 +150,38 @@ sendjob:
return &getImagesResult, nil
}
+func GetPublicImages() (*models.GetImagesResult, error) {
+ checkSetting()
+ client := getRestyClient()
+ var getImagesResult models.GetImagesResult
+
+ retry := 0
+
+sendjob:
+ res, err := client.R().
+ SetHeader("Content-Type", "application/json").
+ SetAuthToken(TOKEN).
+ SetBody(map[string]interface{}{"pageIndex": 1, "pageSize": 50}).
+ SetResult(&getImagesResult).
+ Get(HOST + "/rest-server/api/v1/image/public/list/")
+
+ if err != nil {
+ return nil, fmt.Errorf("resty GetPublicImages: %v", err)
+ }
+
+ if getImagesResult.Code == "S401" && retry < 1 {
+ retry++
+ _ = loginCloudbrain()
+ goto sendjob
+ }
+
+ if getImagesResult.Code != Success {
+ return &getImagesResult, fmt.Errorf("getImgesResult err: %s", res.String())
+ }
+
+ return &getImagesResult, nil
+}
+
func CommitImage(jobID string, params models.CommitImageParams) error {
checkSetting()
client := getRestyClient()
diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go
index 3f60284a0..d0e662505 100755
--- a/routers/repo/cloudbrain.go
+++ b/routers/repo/cloudbrain.go
@@ -101,6 +101,23 @@ func CloudBrainNew(ctx *context.Context) {
ctx.Data["images"] = result.Payload.ImageInfo
+ resultPublic, err := cloudbrain.GetPublicImages()
+ if err != nil {
+ ctx.Data["error"] = err.Error()
+ log.Error("cloudbrain.GetPublicImages failed:", err.Error())
+ }
+
+ for i, payload := range resultPublic.Payload.ImageInfo {
+ log.Info(resultPublic.Payload.ImageInfo[i].Place)
+ if strings.HasPrefix(resultPublic.Payload.ImageInfo[i].Place, "192.168") {
+ resultPublic.Payload.ImageInfo[i].PlaceView = payload.Place[strings.Index(payload.Place, "/"):len(payload.Place)]
+ } else {
+ resultPublic.Payload.ImageInfo[i].PlaceView = payload.Place
+ }
+ }
+
+ ctx.Data["public_images"] = resultPublic.Payload.ImageInfo
+
attachs, err := models.GetAllUserAttachments(ctx.User.ID)
if err != nil {
ctx.ServerError("GetAllUserAttachments failed:", err)
diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl
index 409ae01bb..b21264772 100755
--- a/templates/repo/cloudbrain/new.tmpl
+++ b/templates/repo/cloudbrain/new.tmpl
@@ -126,6 +126,9 @@
{{range .images}}
{{end}}
+ {{range .public_images}}
+
+ {{end}}