From 74fe35720148914b79364ac5ecc93c838114ce12 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Sun, 24 Apr 2022 11:15:45 +0800 Subject: [PATCH] fix issue --- options/locale/locale_en-US.ini | 1 + options/locale/locale_zh-CN.ini | 1 + templates/admin/dataset/list.tmpl | 10 +++- templates/admin/dataset/search.tmpl | 27 ++++++----- templates/explore/datasets.tmpl | 15 +++--- web_src/js/index.js | 74 ++++++++++++++++++++++++----- 6 files changed, 96 insertions(+), 32 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f53bea7b1..8b78d369a 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2512,6 +2512,7 @@ datasets.name=name datasets.private=Private datasets.recommend=Set recommend datasets.unrecommend=Set unrecommend +datasets.only_recommend = Only show platform recommendations cloudbrain.all_task_types=All Task Types cloudbrain.all_computing_resources=All Computing Resources diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index c82347d5e..ee57fd613 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -2522,6 +2522,7 @@ datasets.name=名称 datasets.private=私有 datasets.recommend=设为推荐 datasets.unrecommend=取消推荐 +datasets.only_recommend = 仅显示平台推荐 cloudbrain.all_task_types=全部任务类型 cloudbrain.all_computing_resources=全部计算资源 diff --git a/templates/admin/dataset/list.tmpl b/templates/admin/dataset/list.tmpl index ca1ca27af..9e4e72b68 100644 --- a/templates/admin/dataset/list.tmpl +++ b/templates/admin/dataset/list.tmpl @@ -4,7 +4,6 @@
{{template "base/alert" .}}

{{.i18n.Tr "admin.datasets.dataset_manage_panel"}} ({{.i18n.Tr "admin.total" .Total}}) @@ -12,6 +11,15 @@
{{template "admin/dataset/search" .}}
+
+
+
+ + +
+
+
+
diff --git a/templates/admin/dataset/search.tmpl b/templates/admin/dataset/search.tmpl index 5d01d836c..749065401 100644 --- a/templates/admin/dataset/search.tmpl +++ b/templates/admin/dataset/search.tmpl @@ -6,18 +6,18 @@ @@ -27,3 +27,6 @@ + \ No newline at end of file diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index 94a843d74..7b2577900 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -121,12 +121,12 @@ @@ -140,6 +140,7 @@ {{end}}
+ 仅显示平台推荐
{{range $k, $v :=.Datasets}}
@@ -162,7 +163,7 @@ {{end}}
-
{{.Title}}{{if .Recommend}}{{end}}
+
{{.Title}}{{if .Recommend}}{{end}}
{{if or (.Category) (.Task) (.License)}}
{{if .Category}} diff --git a/web_src/js/index.js b/web_src/js/index.js index c558e7624..ecd637ad0 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -3700,6 +3700,37 @@ function initVueEditAbout() { } function initVueDataset() { + if($('#dataset_check').length){ + if(location.search.indexOf('recommend=true')!==-1){ + $('#dataset_check').checkbox('set checked') + }else{ + $('#dataset_check').checkbox('set unchecked') + } + $('#dataset_check').checkbox({ + onChecked: function() { + if(location.search){ + const params = new URLSearchParams(location.search) + if(params.has('recommend')){ + params.delete('recommend') + location.href = AppSubUrl + location.pathname + '?' + params.toString() + '&recommend=true' + }else{ + location.href = `${window.config.AppSubUrl}/admin/datasets${location.search}&recommend=true` + } + }else{ + location.href = `${window.config.AppSubUrl}/admin/datasets?recommend=true` + } + }, + onUnchecked: function() { + if(location.search=='?recommend=true'){ + location.href = AppSubUrl + location.pathname + }else{ + const params = new URLSearchParams(location.search) + params.delete('recommend') + location.href = AppSubUrl + location.pathname + '?' + params.toString() + } + }, + }) + } $('.set_dataset').on('click', function(){ const $this = $(this); let link = $this.data('url') @@ -3783,24 +3814,13 @@ function initVueDataset() { if(document.getElementById('dataset-file-desc')){ dataset_file_desc = document.getElementById('dataset-file-desc').value } - - // getEditInit(){ - // if($('#dataset-edit-value')){ - // $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')|| '' - // } - // }, new Vue({ delimiters: ['${', '}'], el, data: { suburl: AppSubUrl, url:'', + checked:false, type:0, desc:'', descfile:'', @@ -3897,6 +3917,12 @@ function initVueDataset() { this.getCurrentRepoDataset(this.repolink,this.cloudbrainType) } + const params = new URLSearchParams(location.search) + if (params.has('recommend') && params.get('recommend')=='true'){ + this.checked = true + }else{ + this.checked = false + } }, created(){ if(document.getElementById('postPath')){ @@ -3937,6 +3963,30 @@ function initVueDataset() { } }, + handleCheckedChange(val){ + if(val){ + if(location.search){ + const params = new URLSearchParams(location.search) + if(params.has('recommend')){ + params.delete('recommend') + let search = params.toString() + location.href = `${AppSubUrl}/explore/datasets?${search}&recommend=${val}` + }else{ + location.href = `${AppSubUrl}/explore/datasets${location.search}&recommend=${val}` + } + }else{ + location.href = `${AppSubUrl}/explore/datasets?recommend=${val}` + } + }else{ + if(location.search=='?recommend=true'){ + location.href = AppSubUrl + location.pathname + }else{ + const params = new URLSearchParams(location.search) + params.delete('recommend') + location.href = AppSubUrl + location.pathname + '?' + params.toString() + } + } + }, createDataset(formName){ let _this = this this.$refs[formName].validate((valid)=>{