From 212b3c217c1701c55d14aed20fe0a25b60628233 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 18 Apr 2022 09:24:21 +0800 Subject: [PATCH 01/16] =?UTF-8?q?fix-1913=20=E6=8F=90=E4=BA=A4=E9=95=9C?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/cloudbrain.go | 2 ++ models/cloudbrain_image.go | 4 ++-- modules/auth/cloudbrain.go | 10 +++++++++ modules/cloudbrain/resty.go | 41 +++++++++++++++++++++++++++++++++++- routers/admin/cloudbrains.go | 7 +++++++ routers/repo/cloudbrain.go | 49 ++++++++++++++++++++++++++++++++++++++++++++ routers/routes/routes.go | 2 ++ 7 files changed, 112 insertions(+), 3 deletions(-) diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 0465faf9a..44b177471 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -580,6 +580,8 @@ type CommitImageParams struct { Topics []string CloudBrainType int UID int64 + Place string + Type int } type CommitImageResult struct { diff --git a/models/cloudbrain_image.go b/models/cloudbrain_image.go index c88db0f67..eb21e0d87 100644 --- a/models/cloudbrain_image.go +++ b/models/cloudbrain_image.go @@ -567,12 +567,12 @@ func isImageStaring(e Engine, userID, imageID int64) bool { } func RecommendImage(imageId int64, recommond bool) error { - image := Image{Type: getRecommondType(recommond)} + image := Image{Type: GetRecommondType(recommond)} _, err := x.ID(imageId).Cols("type").Update(image) return err } -func getRecommondType(recommond bool) int { +func GetRecommondType(recommond bool) int { if recommond { return RECOMMOND_TYPE diff --git a/modules/auth/cloudbrain.go b/modules/auth/cloudbrain.go index 85f3a2127..e5be38084 100755 --- a/modules/auth/cloudbrain.go +++ b/modules/auth/cloudbrain.go @@ -33,6 +33,16 @@ type CommitImageCloudBrainForm struct { Topics string `form:"topics"` } +type CommitAdminImageCloudBrainForm struct { + Description string `form:"description" binding:"Required"` + Type int `form:"type" binding:"Required"` + Tag string `form:"tag" binding:"Required;MaxSize(100)" ` + IsPrivate bool `form:"isPrivate" binding:"Required"` + Topics string `form:"topics"` + Place string `form:"place" binding:"Required"` + IsRecommend bool `form:"isRecommend" binding:"Required"` +} + type EditImageCloudBrainForm struct { ID int64 `form:"id" binding:"Required"` Description string `form:"description" binding:"Required"` diff --git a/modules/cloudbrain/resty.go b/modules/cloudbrain/resty.go index f1f213bea..05f110856 100755 --- a/modules/cloudbrain/resty.go +++ b/modules/cloudbrain/resty.go @@ -312,12 +312,51 @@ sendjob: return nil }) if err == nil { - go updateImageStatus(image, isSetCreatedUnix, createTime) } return err } +func CommitAdminImage(jobID string, params models.CommitImageParams) error { + + exist, err := models.IsImageExist(params.ImageTag) + + if err != nil { + return fmt.Errorf("resty CommitImage: %v", err) + } + if exist { + return models.ErrorImageTagExist{ + Tag: params.ImageTag, + } + } + + image := models.Image{ + CloudbrainType: params.CloudBrainType, + UID: params.UID, + IsPrivate: params.IsPrivate, + Tag: params.ImageTag, + Description: params.ImageDescription, + Place: params.Place, + Status: models.IMAGE_STATUS_SUCCESS, + Type: params.Type, + } + + err = models.WithTx(func(ctx models.DBContext) error { + + if err := models.CreateLocalImage(&image); err != nil { + log.Error("Failed to insert image record.", err) + return fmt.Errorf("resty CommitImage: %v", err) + } + + if err := models.SaveImageTopics(image.ID, params.Topics...); err != nil { + log.Error("Failed to insert image record.", err) + return fmt.Errorf("resty CommitImage: %v", err) + } + return nil + }) + return err +} + func updateImageStatus(image models.Image, isSetCreatedUnix bool, createTime time.Time) { attemps := 5 commitSuccess := false diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index 91d866093..5ad1246ff 100755 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -21,6 +21,7 @@ import ( const ( tplCloudBrains base.TplName = "admin/cloudbrain/list" tplImages base.TplName = "admin/cloudbrain/images" + tplCommitImages base.TplName = "admin/cloudbrain/imagecommit" EXCEL_DATE_FORMAT = "20060102150405" CREATE_TIME_FORMAT = "2006/01/02 15:04:05" ) @@ -114,6 +115,12 @@ func Images(ctx *context.Context) { } +func CloudBrainCommitImageShow(ctx *context.Context) { + ctx.Data["PageIsAdminImages"] = true + ctx.HTML(200, tplImages) + +} + func DownloadCloudBrains(ctx *context.Context) { page := 1 diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 5daf96e78..c2eaf1468 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -702,6 +702,55 @@ func CloudBrainCommitImageCheck(ctx *context.Context, form auth.CommitImageCloud } +func CloudBrainAdminCommitImage(ctx *context.Context, form auth.CommitAdminImageCloudBrainForm) { + + if !NamePattern.MatchString(form.Tag) { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.title_format_err"))) + return + } + + if utf8.RuneCountInString(form.Description) > 255 { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.description_format_err", 255))) + return + } + + validTopics, errMessage := checkTopics(form.Topics) + if errMessage != "" { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr(errMessage))) + return + } + + err := cloudbrain.CommitAdminImage(ctx.Cloudbrain.JobID, models.CommitImageParams{ + CommitImageCloudBrainParams: models.CommitImageCloudBrainParams{ + Ip: ctx.Cloudbrain.ContainerIp, + TaskContainerId: ctx.Cloudbrain.ContainerID, + ImageDescription: form.Description, + ImageTag: form.Tag, + }, + IsPrivate: form.IsPrivate, + CloudBrainType: form.Type, + Topics: validTopics, + UID: ctx.User.ID, + Type: models.GetRecommondType(form.IsRecommend), + Place: form.Place, + }) + if err != nil { + log.Error("CommitImage(%s) failed:%v", ctx.Cloudbrain.JobName, err.Error(), ctx.Data["msgID"]) + if models.IsErrImageTagExist(err) { + ctx.JSON(200, models.BaseErrorMessage(ctx.Tr("repo.image_exist"))) + + } else if models.IsErrorImageCommitting(err) { + ctx.JSON(200, models.BaseErrorMessage(ctx.Tr("repo.image_committing"))) + } else { + ctx.JSON(200, models.BaseErrorMessage(ctx.Tr("repo.image_commit_fail"))) + } + + return + } + + ctx.JSON(200, models.BaseOKMessage) +} + func CloudBrainCommitImage(ctx *context.Context, form auth.CommitImageCloudBrainForm) { if !NamePattern.MatchString(form.Tag) { diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 9df429e8b..cf1a18b31 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -534,6 +534,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/images", func() { m.Get("", admin.Images) m.Get("/data", repo.GetAllImages) + m.Get("/commit_image", admin.CloudBrainCommitImageShow) + m.Post("/commit_image", bindIgnErr(auth.CommitAdminImageCloudBrainForm{}), repo.CloudBrainAdminCommitImage) }) m.Put("/image/:id/action/:action", image.Action) From 093ed5bfdc38e0c2451cc8ea8fbfe6f3eab98d2b Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Mon, 18 Apr 2022 11:03:47 +0800 Subject: [PATCH 02/16] =?UTF-8?q?fix-1898=201801=201761=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/attachment.go | 8 ++++++++ models/dataset.go | 16 ++++++++++++++-- routers/admin/dataset.go | 19 +++++++++++++++++++ routers/home.go | 1 + routers/repo/dataset.go | 3 +++ routers/routes/routes.go | 1 + routers/user/profile.go | 8 +++++--- 7 files changed, 51 insertions(+), 5 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index 7c95a73dd..778b9095f 100755 --- a/models/attachment.go +++ b/models/attachment.go @@ -64,6 +64,7 @@ type AttachmentInfo struct { Repo *Repository `xorm:"extends"` RelAvatarLink string `xorm:"extends"` UserName string `xorm:"extends"` + Recommend bool `xorm:"-"` } type AttachmentsOptions struct { @@ -78,6 +79,7 @@ type AttachmentsOptions struct { JustNeedZipFile bool NeedRepoInfo bool Keyword string + RecommendOnly bool } func (a *Attachment) AfterUpdate() { @@ -570,6 +572,11 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { builder.Eq{"attachment.is_private": opts.IsPrivate}, ) } + if opts.RecommendOnly { + cond = cond.And(builder.In("attachment.id", builder.Select("attachment.id"). + From("attachment"). + Join("INNER", "dataset", "attachment.dataset_id = dataset.id and dataset.recommend=true"))) + } if opts.JustNeedZipFile { var DecompressState []int32 @@ -618,6 +625,7 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) { if err != nil { return nil, 0, fmt.Errorf("GetDatasetByID failed error: %v", err) } + attachment.Recommend = dataset.Recommend repo, err := GetRepositoryByID(dataset.RepoID) if err == nil { attachment.Repo = repo diff --git a/models/dataset.go b/models/dataset.go index 95800100c..e841261c7 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -23,7 +23,8 @@ type Dataset struct { Category string Description string `xorm:"TEXT"` DownloadTimes int64 - NumStars int `xorm:"INDEX NOT NULL DEFAULT 0"` + NumStars int `xorm:"INDEX NOT NULL DEFAULT 0"` + Recommend bool `xorm:"INDEX NOT NULL DEFAULT false"` License string Task string ReleaseID int64 `xorm:"INDEX"` @@ -99,6 +100,7 @@ type SearchDatasetOptions struct { OwnerID int64 RepoID int64 IncludePublic bool + RecommendOnly bool Category string Task string License string @@ -132,6 +134,13 @@ func CreateDataset(dataset *Dataset) (err error) { } +func RecommendDataset(dataSetId int64, recommend bool) error { + + dataset := Dataset{Recommend: recommend} + _, err := x.ID(dataSetId).Cols("recommend").Update(dataset) + return err +} + func SearchDataset(opts *SearchDatasetOptions) (DatasetList, int64, error) { cond := SearchDatasetCondition(opts) return SearchDatasetByCondition(opts, cond) @@ -146,6 +155,9 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { if opts.RepoID > 0 { cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID}) } + if opts.RecommendOnly { + cond = cond.And(builder.Eq{"dataset.recommend": opts.RecommendOnly}) + } if opts.IncludePublic { cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic}) @@ -198,7 +210,7 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da defer sess.Close() datasets := make(DatasetList, 0, opts.PageSize) - selectColumnsSql := "distinct dataset.id,dataset.title, dataset.status, dataset.category, dataset.description, dataset.download_times, dataset.license, dataset.task, dataset.release_id, dataset.user_id, dataset.repo_id, dataset.created_unix,dataset.updated_unix,dataset.num_stars" + selectColumnsSql := "distinct dataset.id,dataset.title, dataset.status, dataset.category, dataset.description, dataset.download_times, dataset.license, dataset.task, dataset.release_id, dataset.user_id, dataset.repo_id, dataset.created_unix,dataset.updated_unix,dataset.num_stars,dataset.recommend" count, err := sess.Distinct("dataset.id").Join("INNER", "repository", "repository.id = dataset.repo_id"). Join("INNER", "attachment", "attachment.dataset_id=dataset.id"). diff --git a/routers/admin/dataset.go b/routers/admin/dataset.go index a4378cf67..c233c388c 100644 --- a/routers/admin/dataset.go +++ b/routers/admin/dataset.go @@ -1,6 +1,8 @@ package admin import ( + "net/http" + "strconv" "strings" "code.gitea.io/gitea/models" @@ -88,6 +90,23 @@ func Datasets(ctx *context.Context) { ctx.HTML(200, tplDatasets) } +func DatasetAction(ctx *context.Context) { + var err error + datasetId, _ := strconv.ParseInt(ctx.Params(":id"), 10, 64) + switch ctx.Params(":action") { + + case "recommend": + err = models.RecommendDataset(datasetId, true) + case "unrecommend": + err = models.RecommendDataset(datasetId, false) + } + if err != nil { + ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("repo.star_fail", ctx.Params(":action")))) + } else { + ctx.JSON(http.StatusOK, models.BaseOKMessage) + } +} + func DeleteDataset(ctx *context.Context) { dataset, err := models.GetDatasetByID(ctx.QueryInt64("id")) if err != nil { diff --git a/routers/home.go b/routers/home.go index 324bb1032..274e8af69 100755 --- a/routers/home.go +++ b/routers/home.go @@ -331,6 +331,7 @@ func ExploreDatasets(ctx *context.Context) { Task: task, License: license, OwnerID: ownerID, + RecommendOnly: ctx.QueryBool("recommend"), ListOptions: models.ListOptions{ Page: page, PageSize: 30, diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 1a3762be3..73036a2cc 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -358,6 +358,7 @@ func MyDatasets(ctx *context.Context) { NeedIsPrivate: false, JustNeedZipFile: true, NeedRepoInfo: true, + RecommendOnly: ctx.QueryBool("recommend"), }) if err != nil { ctx.ServerError("datasets", err) @@ -398,6 +399,7 @@ func PublicDataset(ctx *context.Context) { Type: cloudbrainType, JustNeedZipFile: true, NeedRepoInfo: true, + RecommendOnly: ctx.QueryBool("recommend"), }) if err != nil { ctx.ServerError("datasets", err) @@ -454,6 +456,7 @@ func MyFavoriteDataset(ctx *context.Context) { Type: cloudbrainType, JustNeedZipFile: true, NeedRepoInfo: true, + RecommendOnly: ctx.QueryBool("recommend"), }) if err != nil { ctx.ServerError("datasets", err) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index cf1a18b31..c281d832b 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -525,6 +525,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/datasets", func() { m.Get("", admin.Datasets) + m.Put(":id/action/:action", admin.DatasetAction) // m.Post("/delete", admin.DeleteDataset) }) m.Group("/cloudbrains", func() { diff --git a/routers/user/profile.go b/routers/user/profile.go index 41d8561d6..f82c03a75 100755 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -106,9 +106,9 @@ func Profile(ctx *context.Context) { for _, org := range orgs { _, repoCount, err := models.SearchRepository(&models.SearchRepoOptions{ - OwnerID: org.ID, - Private: ctx.IsSigned, - Actor: ctx.User, + OwnerID: org.ID, + Private: ctx.IsSigned, + Actor: ctx.User, }) if err != nil { ctx.ServerError("SearchRepository", err) @@ -175,6 +175,8 @@ func Profile(ctx *context.Context) { orderBy = models.SearchOrderByAlphabeticallyReverse case "alphabetically": orderBy = models.SearchOrderByAlphabetically + case "downloadtimes": + orderBy = models.SearchOrderByDownloadTimes case "moststars": orderBy = models.SearchOrderByStarsReverse case "feweststars": From c40653070154ef4b5539f4eda96ceadad49a0f01 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 19 Apr 2022 09:27:19 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/home.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/home.go b/routers/home.go index 274e8af69..5dec05ebe 100755 --- a/routers/home.go +++ b/routers/home.go @@ -358,6 +358,7 @@ func ExploreDatasets(ctx *context.Context) { ctx.Data["Category"] = category ctx.Data["Task"] = task ctx.Data["License"] = license + ctx.Data["Recommend"] = ctx.QueryBool("recommend") pager.SetDefaultParams(ctx) ctx.Data["Page"] = pager From dd83b488499fa83fe62616c9683ada4faafc3b78 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 19 Apr 2022 09:40:03 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/admin/dataset.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/admin/dataset.go b/routers/admin/dataset.go index c233c388c..ac56e52c7 100644 --- a/routers/admin/dataset.go +++ b/routers/admin/dataset.go @@ -72,6 +72,7 @@ func Datasets(ctx *context.Context) { PageSize: setting.UI.ExplorePagingNum, }, Keyword: keyword, + RecommendOnly: ctx.QueryBool("recommend"), SearchOrderBy: orderBy, }) if err != nil { @@ -82,7 +83,7 @@ func Datasets(ctx *context.Context) { ctx.Data["Keyword"] = keyword ctx.Data["Total"] = count ctx.Data["Datasets"] = datasets - + ctx.Data["Recommend"] = ctx.QueryBool("recommend") pager := context.NewPagination(int(count), setting.UI.ExplorePagingNum, page, 5) pager.SetDefaultParams(ctx) ctx.Data["Page"] = pager From d92589b6dcc2444a711e9bd7db547fa06d069f92 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 19 Apr 2022 09:54:40 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/admin/cloudbrains.go | 2 +- routers/admin/dataset.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/routers/admin/cloudbrains.go b/routers/admin/cloudbrains.go index 5ad1246ff..6687b990a 100755 --- a/routers/admin/cloudbrains.go +++ b/routers/admin/cloudbrains.go @@ -117,7 +117,7 @@ func Images(ctx *context.Context) { func CloudBrainCommitImageShow(ctx *context.Context) { ctx.Data["PageIsAdminImages"] = true - ctx.HTML(200, tplImages) + ctx.HTML(200, tplCommitImages) } diff --git a/routers/admin/dataset.go b/routers/admin/dataset.go index ac56e52c7..6b29b06ff 100644 --- a/routers/admin/dataset.go +++ b/routers/admin/dataset.go @@ -51,6 +51,8 @@ func Datasets(ctx *context.Context) { orderBy = models.SearchOrderBySizeReverse case "size": orderBy = models.SearchOrderBySize + case "downloadtimes": + orderBy = models.SearchOrderByDownloadTimes case "moststars": orderBy = models.SearchOrderByStarsReverse case "feweststars": From ac07d69580bffb916ebf8bdfacc344772890d8ba Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 19 Apr 2022 11:28:38 +0800 Subject: [PATCH 06/16] fix issue --- templates/admin/cloudbrain/imagecommit.tmpl | 129 ++++++++++++++++++++++++++++ web_src/js/features/images.js | 20 +++++ 2 files changed, 149 insertions(+) create mode 100644 templates/admin/cloudbrain/imagecommit.tmpl diff --git a/templates/admin/cloudbrain/imagecommit.tmpl b/templates/admin/cloudbrain/imagecommit.tmpl new file mode 100644 index 000000000..ef5afbbb7 --- /dev/null +++ b/templates/admin/cloudbrain/imagecommit.tmpl @@ -0,0 +1,129 @@ + +{{template "base/head" .}} +
+
+
+
+
+
+
+
+
+
+ {{template "repo/header" .}} +
+
+
+ + + +

+ {{.i18n.Tr "repo.submit_image"}} +

+ +
+
+ + {{.CsrfTokenHtml}} +
+ +
+ + CPU/GPU +
+ +
+
+ + + {{.i18n.Tr "repo.images.name_rule"}} +
+
+ + + +
+
+ + +
+
+   + +
+ {{.i18n.Tr "repo.image.label_tooltips"}} +
+ +
+
+ + +
+
+
+
+ + +
+
+ +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+ {{.i18n.Tr "repo.images.public_tooltips"}} +
+
+
+ + + {{.i18n.Tr "repo.cloudbrain.cancel"}} +
+
+
+
+
+
+ + +
+ +
+{{template "base/footer" .}} + \ No newline at end of file diff --git a/web_src/js/features/images.js b/web_src/js/features/images.js index 25da0aee2..dd27aaf6c 100644 --- a/web_src/js/features/images.js +++ b/web_src/js/features/images.js @@ -26,6 +26,15 @@ export default async function initImage(){ } ] }, + place:{ + identifier : 'place', + rules: [ + { + type: 'empty', + + } + ] + }, } }) } @@ -75,6 +84,7 @@ export default async function initImage(){ type:'POST', data:formData, success:function(res){ + console.log(res) if(res.Code===1){ $('.ui.info.message').text(res.Message).show().delay(1500).fadeOut(); }else if(res.Code==0){ @@ -105,6 +115,11 @@ export default async function initImage(){ $("textarea[name='description']").parent().addClass('error') return false } + if($("input[name='place']").length>0&&!$("input[name='place']").val()){ + console.log("1111111",$("input[name='place']")) + $("input[name='place']").parent().addClass('error') + return false + } const postData = { _csrf:$("input[name='_csrf']").val(), @@ -115,7 +130,12 @@ export default async function initImage(){ topics:$("input[name='topics']").val(), id:$("input[name='id']").val() } + if($("input[name='place']").val()&&$("input[name='isRecommend']:checked").val()){ + postData.isRecommend = $("input[name='isRecommend']:checked").val() + postData.place = $("input[name='place']").val() + } let formData = $params(postData) + console.log(formData) if($("input[name='edit']").val()=="edit"){ postImage(formData) } From 177e49d7f9a529a05e88b67654bf817757f94e38 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 19 Apr 2022 14:56:51 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/cloudbrain/resty.go | 2 +- routers/repo/cloudbrain.go | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/cloudbrain/resty.go b/modules/cloudbrain/resty.go index 05f110856..1565d3044 100755 --- a/modules/cloudbrain/resty.go +++ b/modules/cloudbrain/resty.go @@ -317,7 +317,7 @@ sendjob: return err } -func CommitAdminImage(jobID string, params models.CommitImageParams) error { +func CommitAdminImage(params models.CommitImageParams) error { exist, err := models.IsImageExist(params.ImageTag) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index c2eaf1468..76a825fa6 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -720,10 +720,8 @@ func CloudBrainAdminCommitImage(ctx *context.Context, form auth.CommitAdminImage return } - err := cloudbrain.CommitAdminImage(ctx.Cloudbrain.JobID, models.CommitImageParams{ + err := cloudbrain.CommitAdminImage(models.CommitImageParams{ CommitImageCloudBrainParams: models.CommitImageCloudBrainParams{ - Ip: ctx.Cloudbrain.ContainerIp, - TaskContainerId: ctx.Cloudbrain.ContainerID, ImageDescription: form.Description, ImageTag: form.Tag, }, From eaf8090feff19e7e8545031ad4d4d2985e44fd12 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 19 Apr 2022 15:31:34 +0800 Subject: [PATCH 08/16] fix issue --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/admin/dataset/list.tmpl | 45 ++++++++++++++++++++++++++++----------- templates/admin/repo/list.tmpl | 37 +++++++++++++++++++++++++++++++- templates/explore/datasets.tmpl | 3 ++- 5 files changed, 72 insertions(+), 15 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 14d4e19d1..58c6cc84a 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1389,6 +1389,7 @@ issues.filter_sort.feweststars = Fewest stars issues.filter_sort.mostforks = Most forks issues.filter_sort.fewestforks = Fewest forks issues.filter_sort.downloadtimes = Most downloaded +issues.filter_sort.moststars = Most star issues.action_open = Open issues.action_close = Close issues.action_label = Label diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index de9f79319..3e010893a 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1401,6 +1401,7 @@ issues.filter_sort.feweststars=点赞由少到多 issues.filter_sort.mostforks=派生由多到少 issues.filter_sort.fewestforks=派生由少到多 issues.filter_sort.downloadtimes=下载次数 +issues.filter_sort.moststars=收藏数量 issues.action_open=开启 issues.action_close=关闭 issues.action_label=标签 diff --git a/templates/admin/dataset/list.tmpl b/templates/admin/dataset/list.tmpl index 1044e4c28..4e73d10b5 100644 --- a/templates/admin/dataset/list.tmpl +++ b/templates/admin/dataset/list.tmpl @@ -27,7 +27,7 @@ {{.Title}} {{.CreatedUnix.FormatShort}} - + {{if .Recommend}}取消推荐{{else}}设为推荐{{end}} {{end}} @@ -37,16 +37,35 @@ {{template "base/paginate" .}} - - {{template "base/footer" .}} + \ No newline at end of file diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index 3dee62bfb..ddc4ea81a 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -44,7 +44,7 @@ {{.NumIssues}} {{SizeFmt .Size}} {{.CreatedUnix.FormatShort}} - + {{end}} @@ -68,3 +68,38 @@ {{template "base/delete_modal_actions" .}} {{template "base/footer" .}} + \ No newline at end of file diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index a48dbf478..20eafb26f 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -125,7 +125,8 @@ {{.i18n.Tr "repo.issues.filter_sort.oldest"}} {{.i18n.Tr "repo.issues.filter_sort.recentupdate"}} {{.i18n.Tr "repo.issues.filter_sort.leastupdate"}} - + {{.i18n.Tr "repo.issues.filter_sort.downloadtimes"}} + {{.i18n.Tr "repo.issues.issues.filter_sort.moststars"}} From 7cb3a03fffd1f56c170ffb5578efd86d1fcdd69d Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 19 Apr 2022 15:53:14 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/routes/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index c281d832b..a7238e602 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -525,7 +525,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Group("/datasets", func() { m.Get("", admin.Datasets) - m.Put(":id/action/:action", admin.DatasetAction) + m.Put("/:id/action/:action", admin.DatasetAction) // m.Post("/delete", admin.DeleteDataset) }) m.Group("/cloudbrains", func() { From bc02f0851b5facf1aa1954429998ef4fc52bd05a Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 19 Apr 2022 17:37:58 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/cloudbrain.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 76a825fa6..dcf999001 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -733,7 +733,7 @@ func CloudBrainAdminCommitImage(ctx *context.Context, form auth.CommitAdminImage Place: form.Place, }) if err != nil { - log.Error("CommitImage(%s) failed:%v", ctx.Cloudbrain.JobName, err.Error(), ctx.Data["msgID"]) + log.Error("CommitImagefailed") if models.IsErrImageTagExist(err) { ctx.JSON(200, models.BaseErrorMessage(ctx.Tr("repo.image_exist"))) From f9342252f1d0d046fa48600a38870e16215eb91b Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Wed, 20 Apr 2022 09:36:29 +0800 Subject: [PATCH 11/16] fix issue --- templates/admin/dataset/list.tmpl | 38 ++++------------------------ templates/admin/repo/list.tmpl | 37 +-------------------------- templates/custom/select_dataset.tmpl | 8 +++--- templates/custom/select_dataset_train.tmpl | 8 +++--- templates/explore/datasets.tmpl | 3 ++- web_src/js/components/images/adminImages.vue | 26 ++++++++++--------- web_src/js/features/images.js | 5 ++-- web_src/js/index.js | 26 +++++++++++++++++++ 8 files changed, 58 insertions(+), 93 deletions(-) diff --git a/templates/admin/dataset/list.tmpl b/templates/admin/dataset/list.tmpl index 4e73d10b5..afdfdf7f6 100644 --- a/templates/admin/dataset/list.tmpl +++ b/templates/admin/dataset/list.tmpl @@ -3,6 +3,9 @@ {{template "admin/navbar" .}}
{{template "base/alert" .}} +

{{.i18n.Tr "admin.datasets.dataset_manage_panel"}} ({{.i18n.Tr "admin.total" .Total}})

@@ -24,7 +27,7 @@ {{range .Datasets}} {{.ID}} - {{.Title}} + {{.Title}}{{if .Recommend}}{{end}} {{.CreatedUnix.FormatShort}} {{if .Recommend}}取消推荐{{else}}设为推荐{{end}} @@ -37,35 +40,4 @@ {{template "base/paginate" .}}
-{{template "base/footer" .}} - \ No newline at end of file +{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index ddc4ea81a..3dee62bfb 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -44,7 +44,7 @@ {{.NumIssues}} {{SizeFmt .Size}} {{.CreatedUnix.FormatShort}} - + {{end}} @@ -68,38 +68,3 @@ {{template "base/delete_modal_actions" .}} {{template "base/footer" .}} - \ No newline at end of file diff --git a/templates/custom/select_dataset.tmpl b/templates/custom/select_dataset.tmpl index cd4ce50da..befd186c5 100644 --- a/templates/custom/select_dataset.tmpl +++ b/templates/custom/select_dataset.tmpl @@ -23,7 +23,7 @@
-
${dataset.Repo.OwnerName}/${dataset.Repo.Alias} ${dataset.Name}
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
@@ -49,7 +49,7 @@
-
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
@@ -74,7 +74,7 @@
-
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
@@ -99,7 +99,7 @@
-
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
diff --git a/templates/custom/select_dataset_train.tmpl b/templates/custom/select_dataset_train.tmpl index 3da9be9aa..b8260f279 100644 --- a/templates/custom/select_dataset_train.tmpl +++ b/templates/custom/select_dataset_train.tmpl @@ -23,7 +23,7 @@
-
${dataset.Repo.OwnerName}/${dataset.Repo.Alias} ${dataset.Name}
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias} ${dataset.Name}
@@ -49,7 +49,7 @@
-
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
@@ -74,7 +74,7 @@
-
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}
+
${dataset.Repo.OwnerName}/${dataset.Repo.Alias}${dataset.Name}