diff --git a/models/dataset_star.go b/models/dataset_star.go index fac08caee..5dedb2ba4 100644 --- a/models/dataset_star.go +++ b/models/dataset_star.go @@ -51,9 +51,12 @@ func StarDataset(userID, datasetID int64, star bool) error { return sess.Commit() } -func IsDatasetStaring(userID, datasetID int64) bool { - - return isDatasetStaring(x, userID, datasetID) +func IsDatasetStaringByRepoId(userID, repoID int64) bool { + dataset, _ := GetDatasetByRepo(&Repository{ID: repoID}) + if dataset == nil { + return false + } + return isDatasetStaring(x, userID, dataset.ID) } func isDatasetStaring(e Engine, userID, datasetID int64) bool { diff --git a/modules/context/repo.go b/modules/context/repo.go index 64f02c921..7c425c8c0 100755 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -475,6 +475,8 @@ func RepoAssignment() macaron.Handler { if ctx.IsSigned { ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.ID, repo.ID) ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID) + + ctx.Data["IsStaringDataset"] = models.IsDatasetStaringByRepoId(ctx.User.ID, repo.ID) } if repo.IsFork { diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 9c3efb3a4..3f5209918 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -287,7 +287,7 @@ func DatasetAction(ctx *context.Context) { func CurrentRepoDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") repo := ctx.Repo.Repository var datasetIDs []int64 @@ -325,15 +325,16 @@ func CurrentRepoDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } -func MyDataset(ctx *context.Context) { +func MyDatasets(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") uploaderID := ctx.User.ID datasets, count, err := models.Attachments(&models.AttachmentsOptions{ @@ -363,15 +364,16 @@ func MyDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } func PublicDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ @@ -400,15 +402,16 @@ func PublicDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } func MyFavoriteDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") var datasetIDs []int64 @@ -448,7 +451,8 @@ func MyFavoriteDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 8c03824e3..a7b7c61d7 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -986,7 +986,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/edit/:id", reqRepoDatasetWriter, repo.EditDataset) m.Post("/edit", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) m.Get("/current_repo", reqRepoDatasetReader, repo.CurrentRepoDataset) - m.Get("/my_datasets", reqRepoDatasetReader, repo.MyDataset) + m.Get("/my_datasets", reqRepoDatasetReader, repo.MyDatasets) m.Get("/public_datasets", reqRepoDatasetReader, repo.PublicDataset) m.Get("/my_favorite", reqRepoDatasetReader, repo.MyFavoriteDataset)