| @@ -28,36 +28,36 @@ | |||
| <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"> | |||
| <el-form :model="ruleForm1" :rules="rules" ref="ruleForm" label-width="140px"> | |||
| {{.CsrfTokenHtml}} | |||
| <el-form-item label="数据集名称" prop="title"> | |||
| <el-input v-model="ruleForm.title"></el-input> | |||
| <el-input v-model="ruleForm1.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-input type="textarea" :rows="3" maxlength="255" v-model="ruleForm1.description"></el-input> | |||
| </el-form-item> | |||
| <el-form-item label="分类" prop="category"> | |||
| <el-select v-model="ruleForm.category" placeholder="请选择活动区域" style="width: 60%;"> | |||
| <el-select v-model="ruleForm1.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-select v-model="ruleForm1.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-select v-model="ruleForm1.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 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> | |||
| @@ -93,12 +93,13 @@ | |||
| } | |||
| .stars_active{ | |||
| fill: #FA8C16 !important; | |||
| stroke:#FA8C16 !important | |||
| } | |||
| </style> | |||
| <div class="repository"> | |||
| {{template "repo/header" .}} | |||
| {{if .dataset}} | |||
| <div id="dataset-range-value" data-num-stars="{{.dataset.NumStars}}" style="display: none;"> | |||
| <div id="dataset-range-value" data-num-stars="{{.dataset.NumStars}}" data-star-active="{{$.IsStaringDataset}}" style="display: none;"> | |||
| {{range .dataset.Attachments}} | |||
| <div class="item" data-private={{.IsPrivate}}></div> | |||
| {{end}} | |||
| @@ -111,17 +112,17 @@ | |||
| <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;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 style="line-height: 1;margin-right: 4px;margin-bottom: -2px;padding: 0 10px;" @click="postStar({{.dataset.ID}},'{{.Link}}',{{$.IsStaringDataset}})"> | |||
| <svg width="1.4em" height="1.4em" viewBox="0 0 32 32" class="heart-stroke" :class='{stars_active:star_active}'><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;"></span> | |||
| <span style="line-height: 1;">${num_stars}</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"> | |||
| {{if .dataset.Title}} | |||
| <span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=">{{.dataset.Title}}</span> | |||
| {{if .dataset.Task}} | |||
| <span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=">{{.dataset.Task}}</span> | |||
| {{end}} | |||
| {{if .dataset.Category}} | |||
| <span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=">{{.dataset.Category}}</span> | |||
| @@ -304,4 +305,5 @@ $('#dataset-range-value').find('.item').each(function(){ | |||
| items.push($(this).data('private')) | |||
| }) | |||
| console.log(items) | |||
| console.log({{$.IsStaringDataset}}) | |||
| </script> | |||
| @@ -311,6 +311,7 @@ export default { | |||
| }, | |||
| async newMultiUpload(file) { | |||
| console.log(this.uploadtype,this) | |||
| const res = await axios.get('/attachments/new_multipart', { | |||
| params: { | |||
| totalChunkCounts: file.totalChunkCounts, | |||
| @@ -335,6 +336,7 @@ export default { | |||
| fileReader = new FileReader(), | |||
| time = new Date().getTime(); | |||
| let currentChunk = 0; | |||
| let _this = this | |||
| function loadNext() { | |||
| const start = currentChunk * chunkSize; | |||
| @@ -358,7 +360,7 @@ export default { | |||
| uploadID: file.uploadID, | |||
| size: partSize, | |||
| chunkNumber: currentChunk + 1, | |||
| type: this.uploadtype, | |||
| type: _this.uploadtype, | |||
| _csrf: csrf | |||
| } | |||
| }); | |||
| @@ -373,13 +375,16 @@ export default { | |||
| } | |||
| async function uploadMinioNewMethod(url,e){ | |||
| console.log(_this.uploadtype,url,e) | |||
| var xhr = new XMLHttpRequest(); | |||
| xhr.open('PUT', url, false); | |||
| xhr.setRequestHeader('Content-Type', 'text/plain') | |||
| xhr.send(e.target.result); | |||
| var etagValue = xhr.getResponseHeader('etag'); | |||
| //console.log(etagValue); | |||
| etags[currentChunk] = etagValue; | |||
| xhr.send(e.target.result); | |||
| if(_this.uploadtype===0){ | |||
| var etagValue = xhr.getResponseHeader('etag'); | |||
| etags[currentChunk] = etagValue; | |||
| } | |||
| } | |||
| async function updateChunk(currentChunk) { | |||
| @@ -424,6 +429,7 @@ export default { | |||
| } | |||
| async function completeUpload() { | |||
| console.log(_this.uploadtype) | |||
| return await axios.post( | |||
| '/attachments/complete_multipart', | |||
| qs.stringify({ | |||
| @@ -432,9 +438,9 @@ export default { | |||
| file_name: file.name, | |||
| size: file.size, | |||
| dataset_id: file.datasetId, | |||
| type: this.uploadtype, | |||
| type: _this.uploadtype, | |||
| _csrf: csrf, | |||
| description:this.desc | |||
| description:_this.desc | |||
| }) | |||
| ); | |||
| } | |||
| @@ -3669,6 +3669,7 @@ function initVueDataset() { | |||
| items.push($(this).data('private')) | |||
| }) | |||
| let num_stars = $('#dataset-range-value').data('num-stars') | |||
| let star_active = $('#dataset-range-value').data('star-active') | |||
| const ruleForm = {} | |||
| if(document.getElementById('dataset-edit-value')){ | |||
| let $this = $('#dataset-edit-value') | |||
| @@ -3678,6 +3679,7 @@ function initVueDataset() { | |||
| ruleForm.task = $this.data('edit-task') || '' | |||
| ruleForm.license = $this.data('edit-license') || '' | |||
| ruleForm.id = $this.data('edit-id')|| '' | |||
| ruleForm._csrf = csrf | |||
| } | |||
| console.log(ruleForm) | |||
| // getEditInit(){ | |||
| @@ -3710,7 +3712,16 @@ function initVueDataset() { | |||
| task:'', | |||
| license:'', | |||
| _csrf:csrf, | |||
| id:'', | |||
| }, | |||
| ruleForm1:{ | |||
| title:'', | |||
| description:'', | |||
| category:'', | |||
| task:'', | |||
| license:'', | |||
| _csrf:'', | |||
| id:'' | |||
| }, | |||
| rules: { | |||
| title: [ | |||
| @@ -3749,7 +3760,9 @@ function initVueDataset() { | |||
| } | |||
| this.privates = items | |||
| this.num_stars = num_stars | |||
| this.ruleForm = ruleForm | |||
| this.star_active = star_active | |||
| this.ruleForm1 = ruleForm | |||
| // this.getEditInit() | |||
| }, | |||
| @@ -3840,7 +3853,7 @@ function initVueDataset() { | |||
| 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)=>{ | |||
| _this.$axios.post(_this.url,_this.qs.stringify(_this.ruleForm1)).then((res)=>{ | |||
| if(res.data.Code===0){ | |||
| document.getElementById("mask").style.display = "none" | |||
| location.href = _this.url.split('/edit')[0]+'?type=-1' | |||
| @@ -3858,8 +3871,27 @@ function initVueDataset() { | |||
| }) | |||
| }, | |||
| postStar(id,link){ | |||
| console.log(id,link) | |||
| postStar(id,link,IsStaringDataset){ | |||
| console.log(id,link,IsStaringDataset) | |||
| if(IsStaringDataset){ | |||
| let url = link+'/'+ id + '/unstar' | |||
| this.$axios.put(url).then((res)=>{ | |||
| console.log(res) | |||
| if(res.Code===0){ | |||
| this.num_stars = this.num_stars + 1 | |||
| } | |||
| }) | |||
| }else{ | |||
| let url = link+'/'+ id + '/star' | |||
| this.$axios.put(url).then((res)=>{ | |||
| console.log(res) | |||
| this.star_active = true | |||
| if(res.Code===0){ | |||
| this.num_stars = this.num_stars + 1 | |||
| } | |||
| }) | |||
| } | |||
| } | |||