From bfdd694ad225236ace0a82a231cfe89c304b3c0a Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 8 Mar 2022 16:06:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=88=9B=E5=BB=BA=E5=A4=9A=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 096ab291c..e5b252ce6 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -101,11 +101,28 @@ type SearchDatasetOptions struct { } func CreateDataset(dataset *Dataset) (err error) { - if _, err = x.Insert(dataset); err != nil { + + sess := x.NewSession() + defer sess.Close() + + if err := sess.Begin(); err != nil { return err } - return nil + datasetByRepoId := &Dataset{RepoID: dataset.RepoID} + has, err := sess.Get(datasetByRepoId) + if err != nil { + return err + } + if has { + return fmt.Errorf("The dataset already exists.") + } + + if _, err = sess.Insert(dataset); err != nil { + return err + } + return sess.Commit() + } func SearchDataset(opts *SearchDatasetOptions) (DatasetList, int64, error) { From ce1ff8e795151611582108b8930bdcd8cfcaef9e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 8 Mar 2022 17:12:50 +0800 Subject: [PATCH 2/3] =?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/attachment.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 481d0900b..96cce5cd0 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -68,6 +68,12 @@ func renderAttachmentSettings(ctx *context.Context) { func UploadAttachmentUI(ctx *context.Context) { ctx.Data["datasetId"] = ctx.Query("datasetId") + dataset, _ := models.GetDatasetByID(ctx.QueryInt64("datasetId")) + if dataset == nil { + ctx.Error(404, "The dataset does not exits.") + } + r, _ := models.GetRepositoryByID(dataset.RepoID) + ctx.Data["Repo"] = r ctx.HTML(200, tplAttachmentUpload) } From 4d7323930eee1a670792902bbb160bbb1b64f507 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Tue, 8 Mar 2022 17:57:50 +0800 Subject: [PATCH 3/3] fix issue --- templates/repo/attachment/upload.tmpl | 98 +++++++++ templates/repo/datasets/create.tmpl | 65 ++++++ templates/repo/datasets/index.tmpl | 257 ++++++++++++------------ web_src/js/components/MinioUploader.vue | 122 +++++++---- web_src/js/components/ObsUploader.vue | 5 +- web_src/js/index.js | 96 +++++++++ web_src/less/openi.less | 4 + 7 files changed, 472 insertions(+), 175 deletions(-) create mode 100644 templates/repo/attachment/upload.tmpl create mode 100644 templates/repo/datasets/create.tmpl diff --git a/templates/repo/attachment/upload.tmpl b/templates/repo/attachment/upload.tmpl new file mode 100644 index 000000000..167a65aae --- /dev/null +++ b/templates/repo/attachment/upload.tmpl @@ -0,0 +1,98 @@ + +{{template "base/head" .}} +
+{{template "repo/header" .}} +
+ +
+

+ 上传数据集文件 +

+
+
+ + {{.CsrfTokenHtml}} + + CPU/GPU + NPU + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ +

说明:

+

只有zip格式的数据集才能发起云脑任务;
+ 云脑1提供CPU / GPU资源,云脑2提供Ascend NPU资源;调试使用的数据集也需要上传到对应的环境;

+ +
+
+
+{{template "base/footer" .}} + \ No newline at end of file diff --git a/templates/repo/datasets/create.tmpl b/templates/repo/datasets/create.tmpl new file mode 100644 index 000000000..ea935c345 --- /dev/null +++ b/templates/repo/datasets/create.tmpl @@ -0,0 +1,65 @@ + +
+
+
+
+
+
+
+
+
+{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+ +
+

+ {{.i18n.Tr "repo.modelarts.train_job.new_infer"}} +

+
+
+ + {{.CsrfTokenHtml}} + + + 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + + + + + + + + + + + + + + + + + + + + + + + + + 确定 + 取消 + + +
+
+
+
+
+{{template "base/footer" .}} diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 65ba2bb6e..9074e62c4 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -6,145 +6,142 @@ margin: -1px; background: #FFF !important; } +.wrapper { + display: flex; + overflow: hidden; + padding: 0 1rem; + } + .exp{ + display: none; + } + .exp:checked+.text{ + max-height: none; + } + .exp:checked+.text::after{ + visibility: hidden; + } + .exp:checked+.text .btn::before{ + visibility: hidden; + } + .exp:checked+.text .btn::after{ + content:'收起' + } + + .wrapper>.text { + font-family: SourceHanSansSC-regular; + font-size: 14px; + color: #101010; + overflow: hidden; + text-overflow: ellipsis; + text-align: justify; + position: relative; + line-height: 1.5; + max-height: 3em; + transition: .3s max-height; + } + .wrapper>.text::before { + content: ''; + height: calc(100% - 20px); + float: right; + } + .wrapper>.text::after { + content: ''; + width: 999vw; + height: 999vw; + position: absolute; + box-shadow: inset calc(100px - 999vw) calc(30px - 999vw) 0 0 #fff; + margin-left: -100px; + } + .btn{ + position: relative; + float: right; + clear: both; + margin-left: 20px; + font-size: 14px; + padding: 0 8px; + background: #3F51B5; + line-height: 20px; + border-radius: 4px; + color: #fff; + cursor: pointer; + /* margin-top: -30px; */ + } + .btn::after{ + content:'展开' + } + .btn::before{ + content: '...'; + position: absolute; + left: -5px; + color: #333; + transform: translateX(-100%) + } -
+
{{template "repo/header" .}} - -
- - -
- {{.CsrfTokenHtml}} - {{template "base/alert" .}} -
-
-
-

{{.dataset.Title}}

-
- {{if .Permission.CanWrite $.UnitTypeDatasets}} - - {{end}} -
-
-
- {{if .dataset.Description }} - {{.dataset.Description}} - {{else}} - {{.Repository.DescriptionHTML}} - {{end}} -
-
-
- -
- -
- -
- -
- -
- -
- {{.i18n.Tr "cancel"}} - -
-
- - - -
-
-
-
-
- {{if eq .Type 0}}{{.i18n.Tr "repo.cloudbrain1"}}{{else}}{{.i18n.Tr "repo.cloudbrain2"}}{{end}}-{{.i18n.Tr "datasets"}} -
-
-