From c6f56a7226fb0be5299f016cac4e162bbf93f83e Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 10 Mar 2022 16:23:47 +0800 Subject: [PATCH] fix issue --- templates/repo/datasets/create.tmpl | 4 +- templates/repo/datasets/edit.tmpl | 72 ++++++++++++ templates/repo/datasets/index.tmpl | 164 +++++++++++++++++++++++++++- web_src/js/index.js | 101 ++++++++++++++++- 4 files changed, 330 insertions(+), 11 deletions(-) create mode 100644 templates/repo/datasets/edit.tmpl diff --git a/templates/repo/datasets/create.tmpl b/templates/repo/datasets/create.tmpl index ea935c345..e7a2a4f8e 100644 --- a/templates/repo/datasets/create.tmpl +++ b/templates/repo/datasets/create.tmpl @@ -54,12 +54,12 @@ 确定 - 取消 + 取消 - + {{template "base/footer" .}} diff --git a/templates/repo/datasets/edit.tmpl b/templates/repo/datasets/edit.tmpl new file mode 100644 index 000000000..d44e8765c --- /dev/null +++ b/templates/repo/datasets/edit.tmpl @@ -0,0 +1,72 @@ + +
+
+
+
+
+
+
+
+
+{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+ +
+

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

+ + +
+
+ + {{.CsrfTokenHtml}} + + + 请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。 + + + + + + + + + + + + + + + + + + + + + + + + + 确定 + 取消 + + +
+
+
+
+
+{{template "base/footer" .}} + \ No newline at end of file diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index 289e6525a..73f153c04 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -6,6 +6,14 @@ margin: -1px; background: #FFF !important; } + +.dataset_title{ + font-size: 14px; + max-width: 80%; + display: inline-block !important; + margin-left: 6px !important; + padding-right: 0 !important; +} .wrapper { display: flex; overflow: hidden; @@ -76,10 +84,26 @@ color: #333; transform: translateX(-100%) } + + .el-button--text{color:#0366d6 ;} + .heart-stroke{ + stroke: #666; + stroke-width: 2; + fill: #fff + } + .stars_active{ + fill: #FA8C16 !important; + }
{{template "repo/header" .}} {{if .dataset}} + +
@@ -87,11 +111,12 @@

{{.dataset.Title}}

-
+
-
- {{.dataset.NumStars}} - 修改 + +
+ + 修改
@@ -130,10 +155,122 @@ 上传
+
+
+
+
+ +
+ 文件名称 +
+
+ 大小 +
+
+ 存储位置 +
+
+ 状态 +
+
+ 创建者 +
+
+ 上传时间 +
+
+ 操作 +
+
+
+ {{range $k, $v :=.dataset.Attachments}} +
+
+ + + +
+ {{.Size | FileSize}} +
+
+ {{.Type}} +
+
+ {{.IsPrivate}} +
+
+ 创建者 +
+
+ {{.CreatedUnix | TimeSinceUnix1}} +
+ +
+
+ {{end}} + +
+ +
+
- +
+
+ + +
+
{{else}}
@@ -146,8 +283,25 @@
{{end}} + + {{template "base/footer" .}} \ No newline at end of file diff --git a/web_src/js/index.js b/web_src/js/index.js index 0663cb3f2..fdcc617c2 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -43,7 +43,7 @@ import Contributors from './components/Contributors.vue' import Model from './components/Model.vue'; import WxAutorize from './components/WxAutorize.vue' import initCloudrain from './features/cloudrbanin.js' - +// import $ from 'jquery.js' Vue.use(ElementUI); Vue.prototype.$axios = axios; @@ -3664,6 +3664,11 @@ function initVueDataset() { if (!el) { return; } + const items = [] + $('#dataset-range-value').find('.item').each(function(){ + items.push($(this).data('private')) + }) + let num_stars = $('#dataset-range-value').data('num-stars') new Vue({ delimiters: ['${', '}'], el, @@ -3673,13 +3678,17 @@ function initVueDataset() { type:0, desc:'', datasetType:'全部', + privates:[], + star_active:false, + num_stars:0, ruleForm:{ title:'', description:'', category:'', task:'', license:'', - _csrf:csrf + _csrf:csrf, + id:'', }, rules: { title: [ @@ -3716,6 +3725,10 @@ function initVueDataset() { if(document.getElementById('postPath')){ this.url = document.getElementById('postPath').value } + this.privates = items + this.num_stars = num_stars + this.getEditInit() + }, methods:{ createDataset(formName){ @@ -3730,6 +3743,9 @@ function initVueDataset() { }else{ console.log(res.data.Message) } + document.getElementById("mask").style.display = "none" + }).catch(error=>{ + console.log(error) }) } else{ @@ -3737,8 +3753,15 @@ function initVueDataset() { } }) }, - cancelDataset(){ - location.href = this.url.split('/create')[0]+'?type=-1' + cancelDataset(getpage){ + if(getpage==='create'){ + location.href = this.url.split('/create')[0]+'?type=-1' + }else if(getpage==='edit'){ + location.href = this.url.split('/edit')[0]+'?type=-1' + }else{ + location.href='/' + } + }, gotoUpload(datsetId){ location.href = `${AppSubUrl}/attachments/upload?datasetId=${datsetId}` @@ -3748,8 +3771,78 @@ function initVueDataset() { }, uploadNpu(){ this.type=1 + }, + setPrivate(uuid,privateFlag,index){ + const params = {_csrf:csrf,file:uuid,is_private:privateFlag} + this.$axios.post('/attachments/private',this.qs.stringify(params)).then((res)=>{ + console.log(res) + this.$set(this.privates,index,privateFlag) + }).catch(error=>{ + console.log(error) + }) + }, + delDataset(uuid){ + let _this = this + const params = {_csrf:csrf,file:uuid} + $('#data-dataset-delete-modal') + .modal({ + closable: false, + onApprove() { + _this.$axios.post('/attachments/delete',_this.qs.stringify(params)).then((res)=>{ + console.log(res) + $('#'+uuid).hide() + }).catch(error=>{ + console.log(error) + }) + } + }) + .modal('show'); + }, + getEditInit(){ + console.log(this.ruleForm) + if($('#dataset-edit-value')){ + console.log("==========") + let $this = $('#dataset-edit-value') + this.ruleForm.title = $this.data('edit-title') || '' + this.ruleForm.description = $this.data('edit-description') || '' + this.ruleForm.category = $this.data('edit-category') || '' + this.ruleForm.task = $this.data('edit-task') || '' + this.ruleForm.license = $this.data('edit-license') || '' + this.ruleForm.id = $this.data('edit-id') || '' + } + console.log(this.ruleForm) + }, + editDataset(formName,id){ + let _this = this + console.log(this.url) + this.url = this.url.split(`/${id}`)[0] + console.log(this.url) + this.$refs[formName].validate((valid)=>{ + if(valid){ + document.getElementById("mask").style.display = "block" + _this.$axios.post(_this.url,_this.qs.stringify(_this.ruleForm)).then((res)=>{ + if(res.data.Code===0){ + document.getElementById("mask").style.display = "none" + location.href = _this.url.split('/edit')[0]+'?type=-1' + }else{ + console.log(res.data.Message) + } + document.getElementById("mask").style.display = "none" + }).catch((err)=>{ + console.log(err) + }) + } + else{ + return false + } + }) + + }, + postStar(id,link){ + console.log(id,link) } + } });