Browse Source

fix issue

tags/v1.22.3.2^2
Gitea 4 years ago
parent
commit
5a36c1576f
8 changed files with 144 additions and 56 deletions
  1. +25
    -7
      templates/explore/dataset_left.tmpl
  2. +50
    -11
      templates/explore/datasets.tmpl
  3. +5
    -4
      templates/repo/attachment/edit.tmpl
  4. +1
    -1
      templates/repo/datasets/create.tmpl
  5. +11
    -8
      templates/repo/datasets/edit.tmpl
  6. +18
    -12
      templates/repo/datasets/index.tmpl
  7. +4
    -6
      web_src/js/components/MinioUploader.vue
  8. +30
    -7
      web_src/js/index.js

+ 25
- 7
templates/explore/dataset_left.tmpl View File

@@ -9,6 +9,7 @@
<div class="item" data-task='{{$.i18n.Tr (printf "dataset.task.%s" $task)}}'></div>
{{end}}
</div>
<div id="square-link" style="display: none;" data-link="{{$.Link}}"></div>
<div id="licenses-square-range-value" style="display: none;">
{{range $license := licenses}}
<div class="item" data-license="{{$license}}"></div>
@@ -16,36 +17,53 @@
</div>
<div class="mg-b-2">
<div class="flex mg-b-1">
<h3 class="font-medium">{{.i18n.Tr "dataset.category"}}</h3>
<h3 class="font-medium">
{{.i18n.Tr "dataset.category"}}
{{if $.Category}}
<span class="mg-l-1 underline text-gray-400 text-sm clear_dataset_value" data-clear-value="category"style="cursor: pointer;" >Clear</span>
{{end}}
</h3>
</div>
<div class="flex flex-wrap">
{{range $category := categories}}
<a class="tag tag-red"><span>{{$.i18n.Tr (printf "dataset.category.%s" $category)}}</span></a>
{{$Cate := $.i18n.Tr (printf "dataset.category.%s" $category)}}
<a class="tag {{if or (eq $Cate $.Category) (not $.Category)}} tag-red {{else}} inactive{{end}}" href="{{$.Link}}?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{$Cate}}&task={{$.Task}}&license={{$.License}}"><span>{{$Cate}}</span></a>
{{end}}
</div>
</div>
<div class="mg-b-2">
<div class="flex mg-b-1">
<h3 class="font-medium">{{.i18n.Tr "dataset.task"}}</h3>
<h3 class="font-medium">
{{.i18n.Tr "dataset.task"}}
{{if $.Task}}
<span class="mg-l-1 underline text-gray-400 text-sm clear_dataset_value" data-clear-value="task" style="cursor: pointer;" >Clear</span>
{{end}}
</h3>
</div>
<div class="flex flex-wrap history-content">
{{range $task := tasks}}
<a class="tag tag-purple"><span>{{$.i18n.Tr (printf "dataset.task.%s" $task)}}</span></a>
{{$Task := $.i18n.Tr (printf "dataset.task.%s" $task)}}
<a class="tag {{if or (eq $Task $.Task) (not $.Task)}} tag-purple {{else}} inactive{{end}}" href="{{$.Link}}?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{$.Category}}&task={{$Task}}&license={{$.License}}"><span>{{$Task}}</span></a>
{{end}}
</div>
</div>
<div class="mg-b-2">
<div class="flex mg-b-1">
<h3 class="font-medium">{{.i18n.Tr "dataset.license"}}</h3>
<h3 class="font-medium">
{{.i18n.Tr "dataset.license"}}
{{if $.License}}
<span class="mg-l-1 underline text-gray-400 text-sm clear_dataset_value" data-clear-value="license" style="cursor: pointer;" >Clear</span>
{{end}}
</h3>
</div>
<div class="flex flex-wrap">
{{range $license := licenses}}
<a class="tag tag-red"><span>{{$license}}</span></a>
<a class="tag {{if or (eq $license $.License) (not $.License)}} tag-red {{else}} inactive {{end}}" href="{{$.Link}}?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{$.Category}}&task={{$.Task}}&license={{$license}}"><span>{{$license}}</span></a>
{{end}}
</div>
</div>

</div>
</div>
</div>
</div>

+ 50
- 11
templates/explore/datasets.tmpl View File

@@ -6,7 +6,20 @@
.mg-b-2{
margin-bottom: 2rem;
}

.mg-l-1{
margin-left: 1rem;
}
.text-gray-400 {
--tw-text-opacity: 1;
color: rgba(156,163,175,var(--tw-text-opacity));
}
.text-sm {
font-size: .875rem;
line-height: 1.25rem;
}
.underline {
text-decoration: underline;
}
.flex{
display: flex;
}
@@ -48,6 +61,10 @@
--tw-text-opacity: 1;
color: rgba(30,64,175,var(--tw-text-opacity));
}
.tag.inactive {
filter: grayscale(100%);
opacity: .5;
}
.tag {
align-items: center;
display: inline-flex;
@@ -77,7 +94,7 @@
</style>
<div class="explore repositories">
{{template "explore/dataset_search" .}}
<div id="dataset-base">
<div>
<div class="ui container">
<div class="ui grid">
@@ -93,7 +110,7 @@
<div class="ui right dropdown type jump item">
<span class="text">
{{.i18n.Tr "repo.issues.filter_sort"}}
<i class="dropdown icon"></i>
<i class="dropdown icon"></i>
</span>
<div class="menu">
<a class="{{if eq .SortType "newest"}}active{{end}} item" href="{{$.Link}}?sort=newest&q={{$.Keyword}}&tab={{$.TabName}}">{{.i18n.Tr "repo.issues.filter_sort.latest"}}</a>
@@ -113,30 +130,39 @@
</div>
{{end}}

<div class="ui row" style="clear: both;">
<div class="ui row" style="clear: both;" id="dataset-base">
<div class="ui two cards">
{{range $k, $v :=.Datasets}}
<div class="ui card" @click="gotoDataset('{{.Repo.Link}}/datasets')" style="cursor: pointer;">
<div class="content">
<div class="repo_dataset_header" style="display: flex;align-items: center;justify-content: space-between;">
<a href="{{.Repo.Link}}/datasets" style="font-size: 12px;color: #3291F8;height: 24px;">{{.Repo.OwnerName}} / {{.Repo.Alias}}</a>
{{if $.IsSigned}}
<span style="display: flex;align-items: center;justify-content: flex-end;cursor: pointer;" @click.stop="postSquareStar({{.ID}},'{{.Repo.Link}}/datasets',{{$k}})">
<div style="line-height: 1;margin-right: 4px;margin-bottom: -2px;">
<svg width="1.4em" height="1.4em" viewBox="0 0 32 32" class="heart-stroke" :class='{stars_active:starActives[{{$k}}]}'><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;color: #101010;">${starItems[{{$k}}]}</span>
</span>
{{else}}
<span style="display: flex;align-items: center;justify-content: flex-end;cursor: pointer;">
<div style="line-height: 1;margin-right: 4px;margin-bottom: -2px;">
<svg width="1.4em" height="1.4em" viewBox="0 0 32 32" class="heart-stroke" :class='{stars_active:starActives[{{$k}}]}'><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;color: #101010;">${starItems[{{$k}}]}</span>
</span>
{{end}}
</div>
<div style="font-size: 16px;color:#0366D6;font-family: SourceHanSansSC-medium;height: 27px;">{{.Title}}</div>
<div style="font-size: 12px;margin-top: 5px;height: 24px;">
{{if .Task}}
<span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Task}}&topic=">{{.Task}}</span>
<a class="ui repo-topic label topic" href="{{$.Link}}?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{$.Category}}&task={{.Task}}&license={{$.License}}">{{.Task}}</a>
{{end}}
{{if .Category}}
<span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Category}}&topic=">{{.Category}}</span>
<a class="ui repo-topic label topic" href="{{$.Link}}?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{.Category}}&task={{$.Task}}&license={{$.License}}">{{.Category}}</a>
{{end}}
{{if .License}}
<span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.License}}&topic=">{{.License}}</span>
<a class="ui repo-topic label topic" href="{{$.Link}}?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{$.Category}}&task={{$.Task}}&license={{.License}}">{{.License}}</a>
{{end}}
</div>
@@ -147,7 +173,7 @@
</div>
<div class="extra content">
<div style="display: flex;align-items: center;">
<a href="{{.Repo.OwnerName}}" title="{{.Repo.OwnerName}}">
<a href="{{AppSubUrl}}/{{.Repo.OwnerName}}" title="{{.Repo.OwnerName}}">
<img class="ui avatar image" style="width: 22px;height:22px;" src="/user/avatar/{{.Repo.OwnerName}}/-1">
</a>
<span style="color: #999999;font-size: 14px;;">创建于:{{TimeSinceUnix1 .CreatedUnix}}</span>
@@ -155,10 +181,24 @@
</div>
</div>
{{end}}
{{.Page.Paginater.Total}}

</div>
</div>

<div id="app" style="margin-top: 2rem;">
<div class="center">
<el-pagination
background
@current-change="handleCurrentChange"
:current-page="page"
:page-sizes="[30]"
:page-size="30"
layout="total, sizes, prev, pager, next, jumper"
:total="{{.Page.Paginater.Total}}">
</el-pagination>
</div>
</div>
</div>
</div>
</div>
@@ -166,6 +206,5 @@
</div>
{{template "base/footer" .}}
<script>

console.log({{.Datasets}});
console.log({{.Datasets}})
</script>

+ 5
- 4
templates/repo/attachment/edit.tmpl View File

@@ -21,7 +21,7 @@
<el-form label-width="140px">
{{.CsrfTokenHtml}}
<el-form-item label="存储位置:" prop="title">
<span style="display: flex;color: #3291F8;"><i class="ri-archive-drawer-line" style="margin-right: 10px;"></i>NPU</span>
<span style="display: flex;color: #3291F8;"><i class="ri-archive-drawer-line" style="margin-right: 10px;"></i>{{.Attachment.Type | AttachmentResourceType}}</span>
<!-- <span>请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。</span> -->
</el-form-item>
<el-form-item label="数据集文件:" prop="description">
@@ -31,8 +31,8 @@
<el-input type="textarea" :rows="3" maxlength="255" v-model="descfile"></el-input>
</el-form-item>
<el-form-item>
<el-button style="background-color: #21ba45;" type="success" @click="editDatasetFile({{.Attachment.ID}})">确定</el-button>
<el-button type="info" @click="cancelDataset('',)">取消</el-button>
<el-button style="background-color: #21ba45;" type="success" @click="editDatasetFile({{.Attachment.ID}},'{{.Repo.OwnerName}}/{{.Repo.Name}}')">确定</el-button>
<el-button type="info" @click="cancelDataset('','{{.Repo.OwnerName}}/{{.Repo.Name}}')">取消</el-button>
</el-form-item>
</el-form>
@@ -45,5 +45,6 @@
{{template "base/footer" .}}
<script>
console.log({{.Attachment}})

console.log({{.Repo}})
console.log({{$.Link}})
</script>

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

@@ -32,7 +32,7 @@
<!-- <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="1024" 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%;">


+ 11
- 8
templates/repo/datasets/edit.tmpl View File

@@ -20,7 +20,7 @@
<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}}">
@@ -36,24 +36,27 @@
<!-- <span>请输入字母、数字、_和-,最长64个字符,且不能以中划线(-)结尾。</span> -->
</el-form-item>
<el-form-item label="数据集描述" prop="description">
<el-input type="textarea" :rows="3" maxlength="255" v-model="ruleForm1.description"></el-input>
<el-input type="textarea" :rows="3" maxlength="1024" v-model="ruleForm1.description"></el-input>
</el-form-item>
<el-form-item label="分类" prop="category">
<el-select v-model="ruleForm1.category" placeholder="请选择活动区域" style="width: 60%;">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
{{range $category := categories}}
<el-option label='{{$.i18n.Tr (printf "dataset.category.%s" $category)}}' value='{{$.i18n.Tr (printf "dataset.category.%s" $category)}}'></el-option>
{{end}}
</el-select>
</el-form-item>
<el-form-item label="研究方向/应用领域" prop="task">
<el-select v-model="ruleForm1.task" placeholder="请选择活动区域" style="width: 60%;">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
{{range $task := tasks}}
<el-option label='{{$.i18n.Tr (printf "dataset.task.%s" $task)}}' value='{{$.i18n.Tr (printf "dataset.task.%s" $task)}}'></el-option>
{{end}}
</el-select>
</el-form-item>
<el-form-item label="授权许可" prop="license">
<el-select v-model="ruleForm1.license" placeholder="请选择活动区域" style="width: 60%;">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
{{range $license := licenses}}
<el-option label='{{$license}}' value='{{$license}}'></el-option>
{{end}}
</el-select>
</el-form-item>
<el-form-item>


+ 18
- 12
templates/repo/datasets/index.tmpl View File

@@ -46,6 +46,8 @@
line-height: 1.5;
max-height: 3em;
transition: .3s max-height;
word-wrap: break-word;
word-break: break-all;
}
.wrapper>.text::before {
content: '';
@@ -128,13 +130,13 @@
</div>
<div class="column thirteen wide">
{{if .dataset.Task}}
<span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=">{{.dataset.Task}}</span>
<a class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/datasets?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{$.Category}}&task={{.dataset.Task}}&license={{$.License}}">{{.dataset.Task}}</a>
{{end}}
{{if .dataset.Category}}
<span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=">{{.dataset.Category}}</span>
<a class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/datasets?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{.dataset.Category}}&task={{$.Task}}&license={{$.License}}">{{.dataset.Category}}</a>
{{end}}
{{if .dataset.License}}
<span class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=">{{.dataset.License}}</span>
<a class="ui repo-topic label topic" href="{{AppSubUrl}}/explore/datasets?sort={{$.SortType}}&q={{$.Keyword}}&tab={{$.TabName}}&category={{$.Category}}&task={{$.Task}}&license={{.dataset.License}}">{{.dataset.License}}</a>
{{end}}
</div>
</div>
@@ -143,10 +145,7 @@
<input id="exp1" class="exp" type="checkbox">
<div class="text">
<label class="btn" for="exp1"></label>
浮动元素是如何定位的
正如我们前面提到的那样,当一个元素浮动之后,它会被移出正常的文档流,然后向左或者向右平移,一直平移直到碰到了所处的容器的边框,或者碰到另外一个浮动的元素。
浮动元素是如何定位的
正如我们前面提到的那样,当一个元素浮动之后,它会被移出正常的文档流,然后向左或者向右平移,一直平移直到碰到了所处的容器的边框,或者碰到另外一个浮动的元素。
{{.dataset.Description}}
</div>
</div>
</div>
@@ -245,14 +244,19 @@
</el-popover>
</el-button> -->
<div class="ui compact buttons">
<a class="ui basic{{if $.CanRead}} disabled {{else}} blue{{end}} button" href="{{.DownloadURL}}">下载</a>
{{if $.CanRead}}
<a class="ui basic blue button" href="{{.DownloadURL}}">下载</a>
{{else}}
<a class="ui basic disabled button">下载</a>
{{end}}
{{if eq .DecompressState 1}}
<a class="ui basic blue button" href="datasets/dirs/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.directory"}}'>预览</a>
{{end}}

<a class="ui basic {{if $.CanRead}} disabled {{else}} blue{{end}}button" href="datasets/label/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.create_label_task"}}'>标注</a>
{{if $.CanRead}}
<a class="ui basic blue button" href="datasets/label/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.create_label_task"}}'>标注</a>
{{else}}
<a class="ui basic disabled button">标注</a>
{{end}}
<a class="ui basic blue button">
<el-dropdown size="medium">
<span class="el-dropdown-link">
@@ -333,4 +337,6 @@ $('#dataset-range-value').find('.item').each(function(){
console.log(items)
console.log({{$.IsStaringDataset}})
console.log({{.Attachments}})
console.log({{$.CanRead}})
console.log({{$.CanWrite}})
</script>

+ 4
- 6
web_src/js/components/MinioUploader.vue View File

@@ -9,7 +9,7 @@
<strong class="success text red">{{ status }}</strong>
</p>
<el-button style="background-color: #21ba45;" type="success" :disabled="btnFlag" @click="onFileAdded">上传</el-button>
<el-button type="info" @click="cancelDataset('',backurl)">取消</el-button>
<el-button type="info" @click="cancelDataset">取消</el-button>
<!-- <p>说明:<br>
- 只有zip格式的数据集才能发起云脑任务;<br>
- 云脑1提供 <span class="text blue">CPU / GPU</span> 资源,云脑2提供 <span class="text blue">Ascend NPU</span> 资源;调试使用的数据集也需要上传到对应的环境。</p> -->
@@ -37,10 +37,6 @@ export default {
desc:{
type:String,
default:''
},
backurl:{
type:String,
default:''
}
},
data() {
@@ -60,7 +56,6 @@ export default {
},

async mounted() {
console.log(this.backurl)
this.dropzoneParams = $('div#minioUploader-params');
this.file_status_text = this.dropzoneParams.data('file-status');
this.status = this.dropzoneParams.data('file-init-status');
@@ -131,6 +126,9 @@ export default {
this.dropzoneUploader = dropzoneUploader;
},
methods: {
cancelDataset(){
location.href = this.repoPath
},
resetStatus() {
this.progress = 0;
this.status = '';


+ 30
- 7
web_src/js/index.js View File

@@ -3664,6 +3664,19 @@ function initVueDataset() {
if (!el) {
return;
}
let link=$('#square-link').data('link')
const clearBtn = document.getElementsByClassName("clear_dataset_value");
const params = new URLSearchParams(location.search)
for (let i = 0; i < clearBtn.length; i++) {
clearBtn[i].addEventListener('click',function(e){
let searchType=e.target.getAttribute("data-clear-value")
if(params.has(searchType)){
params.delete(searchType)
let clearSearch = params.toString()
location.href = link + '?' + clearSearch
}
})
}
const items = []
$('#dataset-range-value').find('.item').each(function(){
items.push($(this).data('private'))
@@ -3814,6 +3827,7 @@ function initVueDataset() {
this.taskLists = taskLists
this.licenseLists = licenseLists
this.descfile = dataset_file_desc
console.log(this.starItems,this.starActives)
},
methods:{
createDataset(formName){
@@ -3850,6 +3864,8 @@ function initVueDataset() {
}
else{
console.log(attachment)
location.href = '/'+attachment + '/datasets'
}
},
@@ -3929,13 +3945,20 @@ function initVueDataset() {
})

},
editDatasetFile(id){
console.log(id)
editDatasetFile(id,backurl){
console.log(id,backurl)
let url = '/attachments/edit'
const params={id:id,description:this.descfile}
const params={id:id,description:this.descfile,_csrf:csrf}
console.log(this.qs.stringify(params))
// document.getElementById("mask").style.display = "block"
this.$axios.post(url,this.qs.stringify(params)).then((res)=>{
console.log(res)
if(res.data.Code===0){
location.href = '/'+backurl + '/datasets'
}else{
console.log(res.data.Message)
}
}).catch((err)=>{
console.log(err)
})
},
postStar(id,link){
@@ -3962,14 +3985,14 @@ function initVueDataset() {
},
postSquareStar(id,link,index){
console.log(id,link,index)
if(this.starItems[index]){
console.log(this.starItems,this.starActives)
if(this.starActives[index]){
let url = link+'/'+ id + '/unstar'
this.$axios.put(url).then((res)=>{
console.log(res)
if(res.data.Code===0){
this.$set(this.starActives,index,false)
this.$set(this.starItems,index,this.starItems[index]-1)
this.$set(this.starItems,index,this.starItems[index]-1)
}
})
}else{


Loading…
Cancel
Save