From 600b353849b2b37504f93a938105e73931c9375e Mon Sep 17 00:00:00 2001 From: palytoxin Date: Wed, 19 Aug 2020 21:26:14 +0800 Subject: [PATCH 01/10] improved ui --- options/locale/locale_en-US.ini | 7 ++++++- options/locale/locale_zh-CN.ini | 9 +++++++-- templates/repo/cloudbrain/index.tmpl | 2 +- templates/repo/cloudbrain/new.tmpl | 6 +++--- templates/repo/header.tmpl | 2 +- templates/repo/settings/options.tmpl | 2 +- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 221de16b8..c2fafc324 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -752,6 +752,10 @@ unit_disabled = The site administrator has disabled this repository section. language_other = Other datasets = Datasets datasets.desc = Enable Dataset +cloudbrain=cloudbrain +cloudbrain.new=New cloudbrain +cloudbrain.desc=cloudbrain +cloudbrain.cancel=Cancel template.items = Template Items template.git_content = Git Content (Default Branch) @@ -1420,7 +1424,8 @@ settings.use_external_wiki = Use External Wiki settings.external_wiki_url = External Wiki URL settings.external_wiki_url_error = The external wiki URL is not a valid URL. settings.external_wiki_url_desc = Visitors are redirected to the external wiki URL when clicking the wiki tab. -settings.dataset_desc= Enable Repository Dataset +settings.dataset_desc = Enable Repository Dataset +settings.cloudbrain_desc = Enable Cloudbarin settings.issues_desc = Enable Repository Issue Tracker settings.use_internal_issue_tracker = Use Built-In Issue Tracker settings.use_external_issue_tracker = Use External Issue Tracker diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 95087525a..6529c3699 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -751,8 +751,12 @@ pick_reaction=选择你的表情 reactions_more=再加载 %d unit_disabled=站点管理员已禁用此项目单元。 language_other=其它 -datasets = 数据集 -datasets.desc = 数据集功能 +datasets=数据集 +datasets.desc=数据集功能 +cloudbrain=云脑 +cloudbrain.new=新建任务 +cloudbrain.desc=云脑功能 +cloudbrain.cancel=取消 template.items=模板选项 template.git_content=Git数据(默认分支) @@ -1423,6 +1427,7 @@ settings.external_wiki_url=外部 Wiki 链接 settings.external_wiki_url_error=外部百科链接无效 settings.external_wiki_url_desc=当点击工单标签时,访问者将被重定向到外部工单系统的URL。 settings.dataset_desc=启用数据集 +settings.cloudbrain_desc = 启用云脑 settings.issues_desc=启用工单系统 settings.use_internal_issue_tracker=使用内置的轻量级工单管理系统 settings.use_external_issue_tracker=使用外部的工单管理系统 diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl index 175b6aea9..caefa45f4 100644 --- a/templates/repo/cloudbrain/index.tmpl +++ b/templates/repo/cloudbrain/index.tmpl @@ -4,7 +4,7 @@
-

{{.i18n.Tr "cloudbrain"}}

+

{{.i18n.Tr "repo.cloudbrain"}}

diff --git a/templates/repo/cloudbrain/new.tmpl b/templates/repo/cloudbrain/new.tmpl index 8b0afe8a7..03ab78829 100644 --- a/templates/repo/cloudbrain/new.tmpl +++ b/templates/repo/cloudbrain/new.tmpl @@ -1,13 +1,13 @@ {{template "base/head" .}}
-{{template "repo/header" .}} + {{template "repo/header" .}}
{{template "base/alert" .}}
{{.CsrfTokenHtml}}

- New Cloudbrain task + {{.i18n.Tr "repo.cloudbrain.new"}}


@@ -27,7 +27,7 @@
Cancel
diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 7baf67809..3d9f00c4e 100755 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -141,7 +141,7 @@ {{if .Permission.CanRead $.UnitTypeCloudBrain}} - {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "cloudbrains"}} + {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "repo.cloudbrain"}} {{end}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index e63d369f5..6aea5214e 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -143,7 +143,7 @@ {{$isDatasetEnabled := .Repository.UnitEnabled $.UnitTypeDatasets }}
- +
From f1ff3ad39e2bf37437ab3d72baa4c052ec91fc8e Mon Sep 17 00:00:00 2001 From: colorfulberry Date: Thu, 20 Aug 2020 09:16:00 +0800 Subject: [PATCH 02/10] feat; improve the dataset list pages and i18n for the directory --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/repo/datasets/dataset_list.tmpl | 6 +- web_src/less/_repository.less | 99 +++++++++++------------ 4 files changed, 50 insertions(+), 57 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index c2fafc324..a47da02d6 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -647,6 +647,7 @@ private = private public = public back = back copy_url=copy download url +directory=check directory of the datasets visibility = visibility visibility_description = Only the owner or the organization members if they have rights, will be able to see it. visibility_helper = Make Dataset Private diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 6529c3699..4b3444b70 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -648,6 +648,7 @@ public=公有 dir=目录 back=返回 copy_url=复制下载链接 +directory=查看数据集目录结构 visibility=可见性 visibility_description=只有组织所有人或拥有权利的组织成员才能看到。 visibility_helper=将数据集设为私有 diff --git a/templates/repo/datasets/dataset_list.tmpl b/templates/repo/datasets/dataset_list.tmpl index f1257062d..5910a9537 100755 --- a/templates/repo/datasets/dataset_list.tmpl +++ b/templates/repo/datasets/dataset_list.tmpl @@ -2,7 +2,7 @@ {{range .Attachments}}
-
+
{{svg "octicon-cloud-download" 16}} {{.Name}} @@ -18,8 +18,8 @@ {{svg "octicon-file" 16}}
-
- {{$.i18n.Tr "dataset.dir"}} + {{if $.Permission.CanWrite $.UnitTypeDatasets}} diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less index 47b020d4e..10c234bb9 100644 --- a/web_src/less/_repository.less +++ b/web_src/less/_repository.less @@ -1,6 +1,5 @@ .repository { - - padding-top: 15px; + // padding-top: 15px; .repo-header { .ui.compact.menu { @@ -154,7 +153,7 @@ &.labels { .label-filter .menu .info { display: inline-block; - padding: .5rem .25rem; + padding: 0.5rem 0.25rem; border-bottom: 1px solid #cccccc; font-size: 12px; width: 100%; @@ -171,7 +170,7 @@ } .text { - margin-left: .9em; + margin-left: 0.9em; } .menu { @@ -227,7 +226,7 @@ padding: 0 5px; &:first-child { - border-radius: .28571429rem 0 0 .28571429rem; + border-radius: 0.28571429rem 0 0 0.28571429rem; } } @@ -259,7 +258,6 @@ } .repo-path { - .section, .divider { display: inline; @@ -377,11 +375,11 @@ } .small.icon { - font-size: .75em; + font-size: 0.75em; } .tiny.icon { - font-size: .5em; + font-size: 0.5em; } .file-actions { @@ -464,7 +462,7 @@ input { vertical-align: middle; - box-shadow: rgba(0, 0, 0, .0745098) 0 1px 2px inset; + box-shadow: rgba(0, 0, 0, 0.0745098) 0 1px 2px inset; width: inherit; padding: 7px 8px; margin-right: 5px; @@ -504,8 +502,8 @@ display: inline-block; padding: 3px 6px; font: 12px @monospaced-fonts, monospace; - color: rgba(0, 0, 0, .65); - background-color: rgba(209, 227, 237, .45); + color: rgba(0, 0, 0, 0.65); + background-color: rgba(209, 227, 237, 0.45); border-radius: 3px; } @@ -582,7 +580,6 @@ overflow-x: auto; } } - } } @@ -596,7 +593,7 @@ margin-bottom: 5px; .ui.input { - font-size: .5em; + font-size: 0.5em; vertical-align: top; width: 50%; min-width: 600px; @@ -660,7 +657,6 @@ } .review-item { - .avatar, .type-icon { float: none; @@ -675,7 +671,7 @@ } .text { - margin: .3em 0 .5em .5em; + margin: 0.3em 0 0.5em 0.5em; } .type-icon { @@ -684,7 +680,7 @@ } .divider { - margin: .5rem 0; + margin: 0.5rem 0; } .review-content { @@ -696,7 +692,7 @@ .comment-list { &:not(.prevent-before-timeline):before { display: block; - content: ""; + content: ''; position: absolute; margin-top: 12px; margin-bottom: 14px; @@ -714,9 +710,10 @@ margin-left: 40px; padding-left: 16px; - &:before { //ciara + &:before { + //ciara display: block; - content: ""; + content: ''; position: absolute; margin-top: 12px; margin-bottom: 14px; @@ -810,13 +807,12 @@ } .comment { - .tag { color: #767676; margin-top: 3px; padding: 2px 5px; font-size: 12px; - border: 1px solid rgba(0, 0, 0, .1); + border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 3px; &.review { margin-left: 5px; @@ -888,10 +884,10 @@ } .actions a { - color: rgba(0, 0, 0, .4); + color: rgba(0, 0, 0, 0.4); &:hover { - color: rgba(0, 0, 0, .8); + color: rgba(0, 0, 0, 0.8); } } } @@ -998,7 +994,8 @@ padding-left: 15px; & > .svg:not(.issue-symbol) { - text-shadow: -2px 0 #fff, 0 2px #fff, 2px 0 #fff, 0 -2px #fff; + text-shadow: -2px 0 #fff, 0 2px #fff, 2px 0 #fff, + 0 -2px #fff; } & > .svg.issue-symbol { @@ -1037,7 +1034,7 @@ } .detail { - font-size: .9rem; + font-size: 0.9rem; margin-top: 5px; margin-left: 35px; @@ -1134,9 +1131,8 @@ } .orglabel { - opacity: .7; + opacity: 0.7; } - } .milestone.list { @@ -1315,7 +1311,7 @@ } &.ui.basic.striped.table tbody tr:nth-child(2n) { - background-color: rgba(0, 0, 0, .02) !important; + background-color: rgba(0, 0, 0, 0.02) !important; } } @@ -1434,7 +1430,7 @@ > div:after { clear: both; - content: ""; + content: ''; display: block; } @@ -1590,14 +1586,12 @@ } .code-diff-split { - table, tbody { width: 100%; } tbody tr { - // light gray for empty lines before / after commit &.add-code td:nth-child(1), &.add-code td:nth-child(2), @@ -1650,7 +1644,6 @@ } .diff-stats { - clear: both; margin-bottom: 5px; max-height: 400px; @@ -1697,7 +1690,7 @@ } .clone.button:first-child { - border-radius: .28571429rem 0 0 .28571429rem; + border-radius: 0.28571429rem 0 0 0.28571429rem; } .ui.action.small.input { @@ -1825,7 +1818,6 @@ } .field { - button, input { @media only screen and (max-width: 438px) { @@ -2158,7 +2150,7 @@ } &.active { - background: rgba(0, 0, 0, .05); + background: rgba(0, 0, 0, 0.05); } } } @@ -2172,12 +2164,12 @@ min-width: 15em; > .header { - margin: .75rem 0 .5rem; + margin: 0.75rem 0 0.5rem; } > .item { float: left; - padding: .5rem .5rem !important; + padding: 0.5rem 0.5rem !important; font-size: 1.5em; width: 45px; left: 13px; @@ -2206,7 +2198,7 @@ &.disabled { cursor: default; - opacity: .5; + opacity: 0.5; } } @@ -2221,7 +2213,7 @@ .select-reaction { float: left; - padding: .6em; + padding: 0.6em; line-height: 21px; &:not(.active) a { @@ -2462,11 +2454,11 @@ border-radius: 4px; .dz-button { - color: rgba(0, 0, 0, .6); + color: rgba(0, 0, 0, 0.6); } &:hover .dz-button { - color: rgba(0, 0, 0, .8); + color: rgba(0, 0, 0, 0.8); } .dz-error-message { @@ -2481,7 +2473,7 @@ > .header, .segment { - box-shadow: 0 1px 2px 0 rgba(34, 36, 38, .15); + box-shadow: 0 1px 2px 0 rgba(34, 36, 38, 0.15); } } @@ -2503,7 +2495,7 @@ > .svg + .content { display: table-cell; - padding: 0 0 0 .5em; + padding: 0 0 0 0.5em; vertical-align: top; } @@ -2590,13 +2582,12 @@ } #avatar-arrow { - &:before, &:after { right: 100%; top: 20px; border: solid transparent; - content: " "; + content: ' '; height: 0; width: 0; position: absolute; @@ -2642,7 +2633,7 @@ display: table-cell; &.tiny { - height: .5em; + height: 0.5em; } } } @@ -2799,18 +2790,18 @@ tbody.commit-list { } .repo-buttons .disabled-repo-button .label { - opacity: .5; + opacity: 0.5; } .repo-buttons .disabled-repo-button a.button { - opacity: .5; + opacity: 0.5; cursor: not-allowed; } .repo-buttons .disabled-repo-button a.button:hover { background: none !important; - color: rgba(0, 0, 0, .6) !important; - box-shadow: 0 0 0 1px rgba(34, 36, 38, .15) inset !important; + color: rgba(0, 0, 0, 0.6) !important; + box-shadow: 0 0 0 1px rgba(34, 36, 38, 0.15) inset !important; } .repo-buttons .ui.labeled.button > .label { @@ -2857,12 +2848,12 @@ td.blob-excerpt { margin-top: 1em; } -.diff-file-box[data-folded="true"] .diff-file-body { +.diff-file-box[data-folded='true'] .diff-file-body { display: none; } -.diff-file-box[data-folded="true"] .diff-file-header { - border-radius: .28571429rem !important; +.diff-file-box[data-folded='true'] .diff-file-header { + border-radius: 0.28571429rem !important; } /* prevent page shaking on language bar click */ @@ -2872,7 +2863,7 @@ td.blob-excerpt { } .ui.form .right .ui.button { - margin-left: .25em; + margin-left: 0.25em; margin-right: 0; } From 4ccc44f61215e8c1343a0982aa8a5a2028231c7d Mon Sep 17 00:00:00 2001 From: palytoxin Date: Thu, 20 Aug 2020 09:27:56 +0800 Subject: [PATCH 03/10] routes --- routers/routes/routes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 959159649..0ef12c581 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -880,8 +880,8 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("", reqRepoDatasetReader, repo.DatasetIndex) m.Post("", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) - m.Group("/dirs/:uuid", func() { - m.Get("", reqRepoDatasetReader, repo.DirIndex) + m.Group("/dirs", func() { + m.Get("/:uuid", reqRepoDatasetReader, repo.DirIndex) }) }, context.RepoRef()) From 51560a849b940c660d900e2b55e1ef1de665f9ff Mon Sep 17 00:00:00 2001 From: colorfulberry Date: Thu, 20 Aug 2020 10:15:41 +0800 Subject: [PATCH 04/10] feat: fixing --- templates/repo/datasets/dirs/index.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/datasets/dirs/index.tmpl b/templates/repo/datasets/dirs/index.tmpl index 424e29bb2..e89067a23 100755 --- a/templates/repo/datasets/dirs/index.tmpl +++ b/templates/repo/datasets/dirs/index.tmpl @@ -1,6 +1,6 @@ {{template "base/head" .}} -
+ {{template "repo/header" .}}
@@ -22,7 +22,7 @@
- {{template "repo/datasets/dirs/dir_list" .}} + {{/* {{template "repo/datasets/dirs/dir_list" .}} */}}
From 578538fc7d9fa5c378ba4d562813b28ec1a13a55 Mon Sep 17 00:00:00 2001 From: colorfulberry Date: Thu, 20 Aug 2020 11:02:27 +0800 Subject: [PATCH 05/10] feat: replace the icons --- templates/repo/header.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 3d9f00c4e..9c137d53a 100755 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -99,7 +99,7 @@ {{if .Permission.CanRead $.UnitTypeDatasets}} - {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}} + {{svg "octicon-inbox" 16}} {{.i18n.Tr "datasets"}} {{end}} @@ -141,7 +141,7 @@ {{if .Permission.CanRead $.UnitTypeCloudBrain}} - {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "repo.cloudbrain"}} + {{svg "octicon-server" 16}} {{.i18n.Tr "repo.cloudbrain"}} {{end}} From 0a47e13feb692b82f8867e2551c16860353613af Mon Sep 17 00:00:00 2001 From: colorfulberry Date: Thu, 20 Aug 2020 11:14:54 +0800 Subject: [PATCH 06/10] user inbox replace --- templates/explore/navbar.tmpl | 4 ++-- templates/repo/view_list.tmpl | 2 +- templates/user/profile.tmpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/explore/navbar.tmpl b/templates/explore/navbar.tmpl index dbfb7381b..200363c66 100644 --- a/templates/explore/navbar.tmpl +++ b/templates/explore/navbar.tmpl @@ -4,7 +4,7 @@ {{svg "octicon-repo" 16}} {{.i18n.Tr "explore.repos"}} - {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}} + {{svg "octicon-inbox" 16}} {{.i18n.Tr "datasets"}} {{/* {{svg "octicon-person" 16}} {{.i18n.Tr "explore.users"}} @@ -28,7 +28,7 @@ {{svg "octicon-repo" 16}} {{.i18n.Tr "explore.repos"}} - {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "datasets"}} + {{svg "octicon-inbox" 16}} {{.i18n.Tr "datasets"}} {{/* {{svg "octicon-person" 16}} {{.i18n.Tr "explore.users"}} diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index 2add12577..3640ff133 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -63,7 +63,7 @@ {{if $entry.IsSubModule}} - {{svg "octicon-file-submodule" 16}} + {{svg "octicon-inbox" 16}} {{$refURL := $commit.RefURL AppUrl $.Repository.FullName}} {{if $refURL}} {{$entry.Name}} @ {{ShortSha $commit.RefID}} diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 97764a9ad..58f6cc471 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -87,7 +87,7 @@ {{svg "octicon-repo" 16}} {{.i18n.Tr "user.repositories"}} - {{svg "octicon-file-submodule" 16}} {{.i18n.Tr "user.datasets"}} + {{svg "octicon-inbox" 16}} {{.i18n.Tr "user.datasets"}} {{svg "octicon-rss" 16}} {{.i18n.Tr "user.activity"}} From a7802547c169d5e6cbef4f25815bdcf7a31bdd13 Mon Sep 17 00:00:00 2001 From: palytoxin Date: Thu, 20 Aug 2020 11:48:18 +0800 Subject: [PATCH 07/10] improve --- modules/templates/helper.go | 3 +++ routers/repo/dir.go | 15 ++++++++------- templates/repo/datasets/dirs/dir_list.tmpl | 6 +++--- templates/repo/datasets/dirs/index.tmpl | 18 +++++++----------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index d5d7bcdab..762471ca5 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -307,6 +307,9 @@ func NewFuncMap() []template.FuncMap { "tasks": tasks, "categories": categories, "licenses": licenses, + "DatasetPathJoin": func(arr []string, index int, seq string) string { + return strings.Join(arr[0:index+1], seq) + }, }} } diff --git a/routers/repo/dir.go b/routers/repo/dir.go index e8aecbcd6..f99b3ad95 100755 --- a/routers/repo/dir.go +++ b/routers/repo/dir.go @@ -29,6 +29,7 @@ type FileInfo struct { func DirIndex(ctx *context.Context) { uuid := ctx.Params("uuid") parentDir := ctx.Query("parentDir") + dirArray := strings.Split(parentDir, "/") if parentDir == "" { attachment, err := models.GetAttachmentByUUID(uuid) @@ -41,15 +42,13 @@ func DirIndex(ctx *context.Context) { log.Error("The file is not zip file, can not query the dir") ctx.ServerError("The file is not zip file, can not query the dir", errors.New("The file is not zip file, can not query the dir")) return - } else { - if attachment.DecompressState != models.DecompressStateDone { - log.Error("The file has not been decompressed completely now") - ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now")) - return - } + } else if attachment.DecompressState != models.DecompressStateDone { + log.Error("The file has not been decompressed completely now") + ctx.ServerError("The file has not been decompressed completely now", errors.New("The file has not been decompressed completely now")) + return } - ctx.Data["Title"] = attachment.Name + // ctx.Data["OriginName"] = attachment.Name } files, err := ioutil.ReadDir(setting.Attachment.Minio.RealPath + setting.Attachment.Minio.Bucket + "/" + setting.Attachment.Minio.BasePath + @@ -87,7 +86,9 @@ func DirIndex(ctx *context.Context) { i++ } + ctx.Data["Path"] = dirArray ctx.Data["Dirs"] = fileInfos + ctx.Data["PageIsDataset"] = true ctx.HTML(200, tplDirIndex) } diff --git a/templates/repo/datasets/dirs/dir_list.tmpl b/templates/repo/datasets/dirs/dir_list.tmpl index 93e4b09cc..15f15920d 100755 --- a/templates/repo/datasets/dirs/dir_list.tmpl +++ b/templates/repo/datasets/dirs/dir_list.tmpl @@ -2,15 +2,15 @@ {{range .Dirs}}
-
+
{{.Size | FileSize}}
-
+
{{.ModTime}}
diff --git a/templates/repo/datasets/dirs/index.tmpl b/templates/repo/datasets/dirs/index.tmpl index e89067a23..a6caf79db 100755 --- a/templates/repo/datasets/dirs/index.tmpl +++ b/templates/repo/datasets/dirs/index.tmpl @@ -5,24 +5,20 @@
-

{{.Title}}

+

+ {{ range $index, $item := .Path }} + {{ $item }}/ + {{ end }} +

-
-
-
-
-
-

{{.i18n.Tr "dataset.dir"}}

-
-
-
+
- {{/* {{template "repo/datasets/dirs/dir_list" .}} */}} + {{template "repo/datasets/dirs/dir_list" .}}
From 522b42571bec3e0372966b5d9ee8d6e4775a80cb Mon Sep 17 00:00:00 2001 From: palytoxin Date: Thu, 20 Aug 2020 15:08:43 +0800 Subject: [PATCH 08/10] dataset dir list height improvment --- templates/repo/datasets/dirs/dir_list.tmpl | 41 +++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/templates/repo/datasets/dirs/dir_list.tmpl b/templates/repo/datasets/dirs/dir_list.tmpl index 15f15920d..98232e17e 100755 --- a/templates/repo/datasets/dirs/dir_list.tmpl +++ b/templates/repo/datasets/dirs/dir_list.tmpl @@ -1,20 +1,27 @@ {{if .Dirs}} - {{range .Dirs}} -
-
- -
- {{.Size | FileSize}} -
-
- {{.ModTime}} -
+ + + {{range .Dirs}} + + + + + + {{end}} + +
+ + + + {{if .IsDir}} {{svg "octicon-file-directory" 16}}{{else}}{{svg "octicon-file" 16}}{{end}} {{.FileName}} + + + + + {{.Size | FileSize}} + + + {{.ModTime}} +
-
-
- {{end}} {{end}} From 4585d0578900b88c8c0bd5ea876c9a855244fd06 Mon Sep 17 00:00:00 2001 From: palytoxin Date: Thu, 20 Aug 2020 15:51:05 +0800 Subject: [PATCH 09/10] error --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/repo/datasets/index.tmpl | 1 + web_src/js/components/MinioUploader.vue | 84 +++++++++++++++---------- web_src/less/_dataset.less | 4 ++ 5 files changed, 58 insertions(+), 33 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a47da02d6..45f91ec8e 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2440,6 +2440,7 @@ md5_computing = MD5 computing loading_file = Loading uploading = Uploading upload_complete = Uploading complete +falied = Upload Failed enable_minio_support = Enable minio support to use the dataset service [notification] diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 4b3444b70..bc5cab924 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2442,6 +2442,7 @@ md5_computing=计算MD5 loading_file=加载文件 uploading=正在上传 upload_complete=上传完成 +failed=上传失败 enable_minio_support=启用minio支持以使用数据集服务 [notification] diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index d0ab20430..09642b222 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -92,6 +92,7 @@ data-loading-file='{{.i18n.Tr "dropzone.loading_file"}}' data-upload-complete='{{.i18n.Tr "dropzone.upload_complete"}}' data-uploading='{{.i18n.Tr "dropzone.uploading"}}' + data-failed='{{.i18n.Tr "dropzone.failed"}}' >
{{if eq .StoreType "minio"}} diff --git a/web_src/js/components/MinioUploader.vue b/web_src/js/components/MinioUploader.vue index abcc036b9..a1b85c6b3 100755 --- a/web_src/js/components/MinioUploader.vue +++ b/web_src/js/components/MinioUploader.vue @@ -37,6 +37,10 @@ export default { }, async mounted() { + this.dropzoneParams = $('div#minioUploader-params'); + this.file_status_text = this.dropzoneParams.data('file-status'); + this.status = this.dropzoneParams.data('file-init-status'); + let previewTemplate = ''; previewTemplate += '
\n '; previewTemplate += '
\n '; @@ -61,9 +65,6 @@ export default { previewTemplate += '
\n'; previewTemplate += '
'; - this.dropzoneParams = $('div#minioUploader-params'); - this.file_status_text = this.dropzoneParams.data('file-status'); - this.status = this.dropzoneParams.data('file-init-status'); const $dropzone = $('div#dataset'); console.log('createDropzone'); const dropzoneUploader = await createDropzone($dropzone[0], { @@ -111,6 +112,12 @@ export default { this.dropzoneUploader.emit('success', file); this.dropzoneUploader.emit('complete', file); }, + emitDropzoneFailed(file) { + this.status = this.dropzoneParams.data('falied'); + file.status = 'error'; + this.dropzoneUploader.emit('error', file); + // this.dropzoneUploader.emit('complete', file); + }, onFileAdded(file) { file.datasetId = document .getElementById('datasetId') @@ -188,33 +195,38 @@ export default { async computeMD5Success(md5edFile) { const file = await this.getSuccessChunks(md5edFile); - if (file.uploadID == '' || file.uuid == '') { + try { + if (file.uploadID == '' || file.uuid == '') { // 未上传过 - await this.newMultiUpload(file); - if (file.uploadID != '' && file.uuid != '') { - file.chunks = ''; - this.multipartUpload(file); - } else { + await this.newMultiUpload(file); + if (file.uploadID != '' && file.uuid != '') { + file.chunks = ''; + this.multipartUpload(file); + } else { // 失败如何处理 + return; + } return; } - return; - } - if (file.uploaded == '1') { + if (file.uploaded == '1') { // 已上传成功 // 秒传 - if (file.attachID == '0') { + if (file.attachID == '0') { // 删除数据集记录,未删除文件 - await addAttachment(file); - } - console.log('文件已上传完成'); - this.progress = 100; - this.status = this.dropzoneParams.data('upload-complete'); - this.finishUpload(file); - } else { + await addAttachment(file); + } + console.log('文件已上传完成'); + this.progress = 100; + this.status = this.dropzoneParams.data('upload-complete'); + this.finishUpload(file); + } else { // 断点续传 - this.multipartUpload(file); + this.multipartUpload(file); + } + } catch (error) { + this.emitDropzoneFailed(file); + console.log(error); } async function addAttachment(file) { @@ -247,6 +259,7 @@ export default { file.attachID = response.data.attachID; return file; } catch (error) { + this.emitDropzoneFailed(file); console.log('getSuccessChunks catch: ', error); return null; } @@ -323,24 +336,29 @@ export default { ); } async function uploadChunk(e) { - if (!checkSuccessChunks()) { - const start = currentChunk * chunkSize; - const partSize = + try { + if (!checkSuccessChunks()) { + const start = currentChunk * chunkSize; + const partSize = start + chunkSize >= file.size ? file.size - start : chunkSize; - // 获取分片上传url - await getUploadChunkUrl(currentChunk, partSize); - if (urls[currentChunk] != '') { + // 获取分片上传url + await getUploadChunkUrl(currentChunk, partSize); + if (urls[currentChunk] != '') { // 上传到minio - await uploadMinio(urls[currentChunk], e); - if (etags[currentChunk] != '') { + await uploadMinio(urls[currentChunk], e); + if (etags[currentChunk] != '') { // 更新数据库:分片上传结果 - await updateChunk(currentChunk); + await updateChunk(currentChunk); + } else { + console.log("上传到minio uploadChunk etags[currentChunk] == ''");// TODO + } } else { - console.log("上传到minio uploadChunk etags[currentChunk] == ''");// TODO + console.log("uploadChunk urls[currentChunk] != ''");// TODO } - } else { - console.log("uploadChunk urls[currentChunk] != ''");// TODO } + } catch (error) { + this.emitDropzoneFailed(file); + console.log(error); } } diff --git a/web_src/less/_dataset.less b/web_src/less/_dataset.less index f3fc87b69..091492ff9 100644 --- a/web_src/less/_dataset.less +++ b/web_src/less/_dataset.less @@ -52,6 +52,10 @@ } .dz-preview .dz-error-message { top: 30px; + background: none; + } + .dz-preview .dz-error-message ::after{ + border: none; } } .upload-info { From dc7db7cfa7d7d1838e96303f73d087fb33b4b112 Mon Sep 17 00:00:00 2001 From: colorfulberry Date: Thu, 20 Aug 2020 16:07:43 +0800 Subject: [PATCH 10/10] feat: improve the pages --- web_src/less/_dataset.less | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web_src/less/_dataset.less b/web_src/less/_dataset.less index 091492ff9..3cd889212 100644 --- a/web_src/less/_dataset.less +++ b/web_src/less/_dataset.less @@ -51,11 +51,10 @@ } } .dz-preview .dz-error-message { - top: 30px; background: none; } - .dz-preview .dz-error-message ::after{ - border: none; + .dz-preview .dz-error-message::after { + border: none !important; } } .upload-info {