Browse Source

add real data to repo/dataset

tags/v1.21.12.1
yan 5 years ago
parent
commit
a09919ee40
5 changed files with 36 additions and 57 deletions
  1. +7
    -3
      models/dataset.go
  2. +1
    -1
      routers/dataset/dataset.go
  3. +11
    -7
      routers/repo/dataset.go
  4. +3
    -32
      templates/repo/datasets/dataset_list.tmpl
  5. +14
    -14
      templates/repo/datasets/index.tmpl

+ 7
- 3
models/dataset.go View File

@@ -106,6 +106,10 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond {
cond = cond.And(builder.Like{"title", opts.Keyword})
}

if opts.RepoID > 0 {
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
}

if opts.IncludePublic {
cond = cond.And(builder.Eq{"status": DatasetStatusPublic})
if opts.OwnerID > 0 {
@@ -167,11 +171,11 @@ func (s datasetMetaSearch) Less(i, j int) bool {
return s.ID[i] < s.ID[j]
}

func GeDatasetAttachments(rels ...*Dataset) (err error) {
return geDatasetAttachments(x, rels...)
func GetDatasetAttachments(rels ...*Dataset) (err error) {
return getDatasetAttachments(x, rels...)
}

func geDatasetAttachments(e Engine, rels ...*Dataset) (err error) {
func getDatasetAttachments(e Engine, rels ...*Dataset) (err error) {
if len(rels) == 0 {
return
}


+ 1
- 1
routers/dataset/dataset.go View File

@@ -156,7 +156,7 @@ func Show(ctx *context.Context) {
return
}

err = models.GeDatasetAttachments(dataset)
err = models.GetDatasetAttachments(dataset)
if err != nil {
ctx.ServerError("GetDatasetAttachments", err)
return


+ 11
- 7
routers/repo/dataset.go View File

@@ -16,7 +16,7 @@ const (
func DatasetIndex(ctx *context.Context) {
var orderBy models.SearchOrderBy
repo := ctx.Repo.Repository
user := ctx.User
// user := ctx.User
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
@@ -44,7 +44,7 @@ func DatasetIndex(ctx *context.Context) {
ctx.Data["PageIsDataset"] = true
ctx.Data["Title"] = ctx.Tr("dataset.show_dataset")
ctx.Data["Link"] = ctx.Repo.RepoLink + "/datasets"
models.SearchDataset(&models.SearchDatasetOptions{
datasets, _, err := models.SearchDataset(&models.SearchDatasetOptions{
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.ExplorePagingNum,
@@ -52,22 +52,26 @@ func DatasetIndex(ctx *context.Context) {
SearchOrderBy: orderBy,
RepoID: repo.ID,
})
dataset, err := models.GetDatasetByID(5)
if err != nil {
ctx.NotFound("GetDataset", err)
ctx.NotFound("SearchDataset", err)
return
}

err = models.GeDatasetAttachments(dataset)
var dataset *models.Dataset
if len(datasets) > 0 { //TODO check list is single item
dataset = datasets[len(datasets)-1]
}
err = models.GetDatasetAttachments(dataset)
if err != nil {
ctx.ServerError("GetDatasetAttachments", err)
return
}

isOwner := (ctx.User != nil && dataset.UserID == user.ID)
// TODO permission
// isOwner := (ctx.User != nil && dataset.UserID == user.ID)

ctx.Data["dataset"] = dataset
ctx.Data["IsOwner"] = isOwner
ctx.Data["IsOwner"] = true

ctx.HTML(200, tplIndex)
}


+ 3
- 32
templates/repo/datasets/dataset_list.tmpl View File

@@ -11,11 +11,11 @@
{{.Size | FileSize}}
</div>
<div class="two wide column">
<span class="ui text center" data-tooltip="{{$.i18n.Tr "dataset.download_count"}}" data-position="bottom right">{{svg "octicon-flame" 16}} {{(.DownloadCount | PrettyNumber)}}</span>
<span class="ui text center" data-tooltip='{{$.i18n.Tr "dataset.download_count"}}' data-position="bottom right">{{svg "octicon-flame" 16}} {{(.DownloadCount | PrettyNumber)}}</span>
</div>

<div class="one wide column">
<span class="ui text center" data-tooltip="{{$.i18n.Tr "dataset.copy_url"}}" data-position="bottom right">{{svg "octicon-file" 16}}</span>
<span class="ui text center" data-tooltip='{{$.i18n.Tr "dataset.copy_url"}}' data-position="bottom right">{{svg "octicon-file" 16}}</span>
</div>

<div class="three wide column">
@@ -25,6 +25,7 @@
<a class="ui positive button active mini">public</a>
</div>
</div>

<div class="two wide column right aligned">
<a class="delete-button ui red button mini" href="">删除</a>
</div>
@@ -32,34 +33,4 @@
</div>
{{end}}
{{end}}
<div class="ui grid item">
<div class="row">
<div class="six wide column">
<a class="title">
<span class="fitted">{{svg "octicon-cloud-download" 16}}</span> 深度学习数据集视频1.1.0
</a>
</div>
<div class="two wide column">
12GB
</div>

<div class="two wide column">
<span class="ui text center" data-tooltip="{{$.i18n.Tr "dataset.download_count"}}" data-position="bottom right">{{svg "octicon-flame" 16}} 100</span>
</div>

<div class="one wide column">
<span class="ui text center" data-tooltip="{{$.i18n.Tr "dataset.copy_url"}}" data-position="bottom right">{{svg "octicon-flame" 16}}</span>
</div>

<div class="three wide column">
<div class="ui buttons mini">
<a class="ui button mini">private</a>
<div class="or"></div>
<a class="ui positive button active mini">public</a>
</div>
</div>
<div class="two wide column right aligned">
<a class="delete-button ui red button mini" href="">删除</a>
</div>
</div>
</div>

+ 14
- 14
templates/repo/datasets/index.tmpl View File

@@ -39,24 +39,24 @@
<div class="ui twelve wide column">
<div class="ui sixteen wide column">
<div class="ui two column stackable grid">
<div class="column">
<h2>{{.i18n.Tr "datasets"}}</h2>
</div>
<div class="column right aligned">
<div class="ui right dropdown type jump item">
<span class="text">
{{.i18n.Tr "repo.issues.filter_sort"}}<i class="dropdown icon"></i>
</span>
<div class="menu">
<a class="item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
<a class="item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.oldest"}}</a>
<a class="item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.recentupdate"}}</a>
<a class="item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.leastupdate"}}</a>
<div class="column">
<h2>{{.i18n.Tr "datasets"}}</h2>
</div>
<div class="column right aligned">
<div class="ui right dropdown type jump item">
<span class="text">
{{.i18n.Tr "repo.issues.filter_sort"}}<i class="dropdown icon"></i>
</span>
<div class="menu">
<a class="item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
<a class="item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.oldest"}}</a>
<a class="item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.recentupdate"}}</a>
<a class="item" href="{{$.Link}}?sort=oldest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.leastupdate"}}</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="dataset list">
{{template "repo/datasets/dataset_list" .}}
</div>


Loading…
Cancel
Save