Browse Source

fix issue

tags/v1.22.3.2^2
zhoupzh 4 years ago
parent
commit
c6f56a7226
4 changed files with 330 additions and 11 deletions
  1. +2
    -2
      templates/repo/datasets/create.tmpl
  2. +72
    -0
      templates/repo/datasets/edit.tmpl
  3. +159
    -5
      templates/repo/datasets/index.tmpl
  4. +97
    -4
      web_src/js/index.js

+ 2
- 2
templates/repo/datasets/create.tmpl View File

@@ -54,12 +54,12 @@
</el-form-item>
<el-form-item>
<el-button style="background-color: #21ba45;" type="success" @click="createDataset('ruleForm')">确定</el-button>
<el-button type="info" @click="cancelDataset">取消</el-button>
<el-button type="info" @click="cancelDataset('create')">取消</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</div>
</div onbeforeunload="return false">
</div>
{{template "base/footer" .}}

+ 72
- 0
templates/repo/datasets/edit.tmpl View File

@@ -0,0 +1,72 @@
<style>
#dataset-base>.field>label{
width:120px !important;
text-align:right !important;
}
</style>
<div id="mask">
<div id="loadingPage">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
</div>
{{template "base/head" .}}
<div class="repository">
{{template "repo/header" .}}
<div class="ui container">
<input type="hidden" id="postPath" value="{{.Link}}">
<div style="width: 80%;margin: auto;">
<h4 class="ui top attached header">
{{.i18n.Tr "repo.modelarts.train_job.new_infer"}}
</h4>
<div id="dataset-edit-value" style="display: none;" data-edit-id="{{.Dataset.ID}}" data-edit-title="{{.Dataset.Title}}" data-edit-description="{{.Dataset.Description}}"
data-edit-category="{{.Dataset.Category}}" data-edit-task="{{.Dataset.Task}}" data-edit-license="{{.Dataset.License}}">
</div>

<div class="ui attached segment" style="padding: 2em 3em;">
<div class="ui form" id="dataset-base">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="140px">
{{.CsrfTokenHtml}}
<el-form-item label="数据集名称" prop="title">
<el-input v-model="ruleForm.title"></el-input>
<span style="font-size: 12px;color: #888;line-height: 1;margin-top: 0.5em;display: inline-block;">请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。</span>
<!-- <span>请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。</span> -->
</el-form-item>
<el-form-item label="数据集描述" prop="description">
<el-input type="textarea" :rows="3" maxlength="255" v-model="ruleForm.description"></el-input>
</el-form-item>
<el-form-item label="分类" prop="category">
<el-select v-model="ruleForm.category" placeholder="请选择活动区域" style="width: 60%;">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
<el-form-item label="研究方向/应用领域" prop="task">
<el-select v-model="ruleForm.task" placeholder="请选择活动区域" style="width: 60%;">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
<el-form-item label="授权许可" prop="license">
<el-select v-model="ruleForm.license" placeholder="请选择活动区域" style="width: 60%;">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button style="background-color: #21ba45;" type="success" @click="editDataset('ruleForm','{{.Dataset.ID}}')">确定</el-button>
<el-button type="info" @click="cancelDataset('edit')">取消</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</div>
</div>
{{template "base/footer" .}}
<script>
console.log({{.Dataset}})
</script>

+ 159
- 5
templates/repo/datasets/index.tmpl View File

@@ -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;
}
</style>
<div class="repository">
{{template "repo/header" .}}
{{if .dataset}}
<div id="dataset-range-value" data-num-stars="{{.dataset.NumStars}}" style="display: none;">
{{range .dataset.Attachments}}
<div class="item" data-private={{.IsPrivate}}></div>
{{end}}
</div>
<div id="dataset-base">
<div class="ui container">
<div class="ui mobile reversed stackable grid">
@@ -87,11 +111,12 @@
<div class="column thirteen wide"><h2>{{.dataset.Title}}</h2></div>
<div class="column three wide right aligned">
<span style="display: flex;align-items: center;justify-content: flex-end;height: 36px;">
<div style="line-height: 1;margin-right: 4px;margin-bottom: -2px;fill: #FA8C16;">
<div style="line-height: 1;margin-right: 4px;margin-bottom: -2px;padding: 0 10px;" @click="postStar({{.dataset.ID}},'{{.Link}}')">
<svg width="1.4em" height="1.4em" viewBox="0 0 32 32" class="heart-stroke"><path d="M4.4 6.54c-1.761 1.643-2.6 3.793-2.36 6.056.24 2.263 1.507 4.521 3.663 6.534a29110.9 29110.9 0 0010.296 9.633l10.297-9.633c2.157-2.013 3.424-4.273 3.664-6.536.24-2.264-.599-4.412-2.36-6.056-1.73-1.613-3.84-2.29-6.097-1.955-1.689.25-3.454 1.078-5.105 2.394l-.4.319-.398-.319c-1.649-1.316-3.414-2.143-5.105-2.394a7.612 7.612 0 00-1.113-.081c-1.838 0-3.541.694-4.983 2.038z"></path></svg>
</div>
<span style="line-height: 1;">{{.dataset.NumStars}}</span>
<a style="margin-left:30px;" href="" class="ui primary basic mini button">修改</a>
</div>
<span style="line-height: 1;"></span>
<a style="margin-left:30px;" href="{{.RepoLink}}/datasets/edit/{{.dataset.ID}}" class="ui primary basic mini button">修改</a>
</span>
</div>
<div class="column thirteen wide">
@@ -130,10 +155,122 @@
<el-button icon="el-icon-upload" type="primary" size="small" @click="gotoUpload({{.dataset.ID}})">上传</el-button>
</div>
</div>
<div class="row">
<div class="ui sixteen wide column dataset">
<div class="ui grid stackable" style="background: #f0f0f0;;">
<div class="row">
<!-- 数据集名称 -->
<div class="four wide column">
<span style="margin:0 6px">文件名称</span>
</div>
<div class="one wide column text center">
大小
</div>
<div class="two wide column text center">
存储位置
</div>
<div class="one wide column text center">
状态
</div>
<div class="one wide column text center">
创建者
</div>
<div class="three wide column text center">
上传时间
</div>
<div class="four wide column text center">
操作
</div>
</div>
</div>
{{range $k, $v :=.dataset.Attachments}}
<div class="ui grid stackable item" id="{{.FileChunk.UUID}}">
<div class="row">
<!-- 数据集名称 -->

<div class="four wide column" style="display: flex;align-items: center;">
<a class="dataset_title title" href="javascript:void(0)" title="{{.Name}}">
{{.Name}}
</a>
<i class="ri-lock-2-line" style="color: #fa8c16;" v-if="privates[{{$k}}]"></i>
</div>
<div class="one wide column text center">
{{.Size | FileSize}}
</div>
<div class="two wide column text center">
{{.Type}}
</div>
<div class="one wide column text center">
{{.IsPrivate}}
</div>
<div class="one wide column text center">
创建者
</div>
<div class="three wide column text center">
{{.CreatedUnix | TimeSinceUnix1}}
</div>
<div class="four wide column text center">
<!-- <el-button type="text">下载</el-button>
<el-button type="text">预览</el-button>
<el-button type="text">标注</el-button>
<el-button type="text">
<el-popover
placement="right"
width="400"
trigger="click">
<span>asdasd</span>
<el-button slot="reference" type="text"><i class="ri-more-line"></i></el-button>
</el-popover>
</el-button> -->
<div class="ui compact buttons">
<a class="ui basic blue button">下载</a>
<a class="ui basic blue button">预览</a>
<a class="ui basic blue button">标注</a>
<a class="ui basic blue button">
<el-dropdown size="medium">
<span class="el-dropdown-link">
更多<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item class="clipboard" data-clipboard-text="{{.DownloadURL}}" data-clipboard-action="copy">复制下载链接</el-dropdown-item>
<el-dropdown-item class="clipboard" data-clipboard-text="{{.FileChunk.Md5}}" data-clipboard-action="copy">复制文件MD5</el-dropdown-item>
<el-dropdown-item style="color: #13c28d;" @click.native="setPrivate('{{.FileChunk.UUID}}',false,{{$k}})" v-if="privates[{{$k}}]">设为公有</el-dropdown-item>
<el-dropdown-item style="color: #fa8c16;" @click.native="setPrivate('{{.FileChunk.UUID}}',true,{{$k}})" v-else="privates[{{$k}}]">设为私有</el-dropdown-item>
<el-dropdown-item>修改描述</el-dropdown-item>
<el-dropdown-item style="color: red;" @click.native="delDataset('{{.FileChunk.UUID}}')">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</a>

</div>
</div>
</div>
</div>
{{end}}
</div>

</div>
</div>
</div>
</div>
<div id="app" style="margin-top: 2rem;">
<div class="center">
<el-pagination
background
@current-change="handleCurrentChange"
:current-page="page"
:page-sizes="[10]"
:page-size="10"
layout="total, sizes, prev, pager, next, jumper"
:total="{{.Page.Paginater.Total}}">
</el-pagination>
</div>
</div>
{{else}}
<div class="ui placeholder segment bgtask-none">
<div class="ui icon header bgtask-header-pic"></div>
@@ -146,8 +283,25 @@
</div>
{{end}}
</div>

<div class="ui small basic delete modal" id="data-dataset-delete-modal">
<div class="ui icon header">
<i class="trash icon"></i>
{{.i18n.Tr "dataset.attachment.delete"}}
</div>
<div class="content">
<p>{{.i18n.Tr "dataset.attachment.delete_desc" | Str2html}}</p>
</div>
{{template "base/delete_modal_actions" .}}
</div>
{{template "base/footer" .}}
<script>
console.log({{.dataset}})
console.log({{.RepoLink}})

const items = []
$('#dataset-range-value').find('.item').each(function(){
items.push($(this).data('private'))
})
console.log(items)
</script>

+ 97
- 4
web_src/js/index.js View File

@@ -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)
}


}
});



Loading…
Cancel
Save