From d5e50182ed84f3d28bd5ae4e26ea4f4056a8ba4c Mon Sep 17 00:00:00 2001 From: Gitea Date: Wed, 18 May 2022 10:13:14 +0800 Subject: [PATCH] fix issue --- templates/repo/datasets/index.tmpl | 474 +++++++------- web_src/js/components/images/Images.vue | 3 +- web_src/js/features/clipboard.js | 10 +- web_src/js/index.js | 1049 ++++++++++++++++--------------- web_src/less/openi.less | 4 + 5 files changed, 803 insertions(+), 737 deletions(-) diff --git a/templates/repo/datasets/index.tmpl b/templates/repo/datasets/index.tmpl index ba4842f57..f9f6a10fc 100755 --- a/templates/repo/datasets/index.tmpl +++ b/templates/repo/datasets/index.tmpl @@ -1,41 +1,47 @@ {{template "base/head" .}}
{{template "repo/header" .}} {{if .dataset}} - -{{template "base/footer" .}} +{{template "base/footer" .}} \ No newline at end of file diff --git a/web_src/js/components/images/Images.vue b/web_src/js/components/images/Images.vue index d524f6e15..e09aee26c 100644 --- a/web_src/js/components/images/Images.vue +++ b/web_src/js/components/images/Images.vue @@ -643,9 +643,8 @@ export default { message: '复制成功!', showProgress: 'bottom', showIcon:'check circle', - class: 'success', + class: 'info', position: 'top right', - compact:false, }) ; }, diff --git a/web_src/js/features/clipboard.js b/web_src/js/features/clipboard.js index 8965a798c..bbffbec47 100644 --- a/web_src/js/features/clipboard.js +++ b/web_src/js/features/clipboard.js @@ -2,7 +2,7 @@ export default async function initClipboard() { const els = document.querySelectorAll('.clipboard'); if (!els || !els.length) return; - const {default: ClipboardJS} = await import(/* webpackChunkName: "clipboard" */'clipboard'); + const { default: ClipboardJS } = await import(/* webpackChunkName: "clipboard" */'clipboard'); const clipboard = new ClipboardJS(els); clipboard.on('success', (e) => { @@ -13,14 +13,14 @@ export default async function initClipboard() { $(`#${e.trigger.getAttribute('id')}`).popup('show'); e.trigger.setAttribute('data-content', e.trigger.getAttribute('data-original')); $('body') - .toast({ + .toast({ message: '复制成功!', showProgress: 'bottom', - showIcon:'check circle', + showIcon: 'check circle', class: 'success', position: 'top right', - compact:false, - }) + compact: false, + }) }); clipboard.on('error', (e) => { diff --git a/web_src/js/index.js b/web_src/js/index.js index 88529bf8a..332950270 100755 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -13,7 +13,7 @@ import qs from 'qs'; import Cookies from 'js-cookie' import 'jquery.are-you-sure'; import './vendor/semanticdropdown.js'; -import {svg} from './utils.js'; +import { svg } from './utils.js'; import echarts from 'echarts' import initContextPopups from './features/contextpopup.js'; import initGitGraph from './features/gitgraph.js'; @@ -32,7 +32,7 @@ import { initNotificationsTable, initNotificationCount } from './features/notification.js'; -import {createCodeEditor} from './features/codeeditor.js'; +import { createCodeEditor } from './features/codeeditor.js'; import MinioUploader from './components/MinioUploader.vue'; import EditAboutInfo from './components/EditAboutInfo.vue'; // import Images from './components/Images.vue'; @@ -49,7 +49,7 @@ Vue.use(ElementUI); Vue.prototype.$axios = axios; Vue.prototype.$Cookies = Cookies; Vue.prototype.qs = qs; -const {AppSubUrl, StaticUrlPrefix, csrf} = window.config; +const { AppSubUrl, StaticUrlPrefix, csrf } = window.config; Object.defineProperty(Vue.prototype, '$echarts', { value: echarts @@ -230,7 +230,7 @@ function initLabelEdit() { }); } -function updateIssuesMeta(url, action, issueIds, elementId,isAdd) { +function updateIssuesMeta(url, action, issueIds, elementId, isAdd) { return new Promise((resolve) => { $.ajax({ type: 'POST', @@ -292,7 +292,7 @@ function initReactionSelector(parent) { parent.find(`${reactions}a.label`).popup({ position: 'bottom left', - metadata: {content: 'title', title: 'none'} + metadata: { content: 'title', title: 'none' } }); parent @@ -310,7 +310,7 @@ function initReactionSelector(parent) { $(this).data('action-url'); const url = `${actionURL}/${ $(this).hasClass('blue') ? 'unreact' : 'react' - }`; + }`; $.ajax({ type: 'POST', url, @@ -374,7 +374,7 @@ function retrieveImageFromClipboardAsBlob(pasteEvent, callback) { return; } - const {items} = pasteEvent.clipboardData; + const { items } = pasteEvent.clipboardData; if (typeof items === 'undefined') { return; } @@ -487,7 +487,7 @@ function initCommentForm() { const promises = []; Object.keys(labels).forEach((elementId) => { const label = labels[elementId]; - console.log("label:",label) + console.log("label:", label) const promise = updateIssuesMeta( label['update-url'], label.action, @@ -605,7 +605,7 @@ function initCommentForm() { $listMenu.data('issue-id'), '', '' - + ).then(reload); } @@ -640,15 +640,15 @@ function initCommentForm() { function selectItem(select_id, input_id) { let $menu; - if (select_id=='.select-branch'){ + if (select_id == '.select-branch') { $menu = $(`${select_id} .menu`).eq(1); - }else{ + } else { $menu = $(`${select_id} .menu`); } - + const $list = $(`.ui${select_id}.list`); const hasUpdateAction = $menu.data('action') === 'update'; - + $menu.find('.item:not(.no-select)').on('click', function () { $(this) .parent() @@ -661,8 +661,8 @@ function initCommentForm() { if (hasUpdateAction) { //let ref = '' //if (select_id=='.select-branch'){ - // ref = $(this).data('name'); - // } + // ref = $(this).data('name'); + // } updateIssuesMeta( $menu.data('update-url'), @@ -687,9 +687,9 @@ function initCommentForm() { .find('.selected') .html( `` + - `${htmlEncode($(this).text())}` + `${htmlEncode($(this).text())}` ); } $(`.ui${select_id}.list .no-select`).addClass('hide'); @@ -864,7 +864,7 @@ async function initRepository() { window.location.href = $choice.data('url'); } }, - message: {noResults: $dropdown.data('no-results')} + message: { noResults: $dropdown.data('no-results') } }); } @@ -1093,7 +1093,7 @@ async function initRepository() { const filenameDict = {}; dz = await createDropzone($dropzone[0], { url: $dropzone.data('upload-url'), - headers: {'X-Csrf-Token': csrf}, + headers: { 'X-Csrf-Token': csrf }, maxFiles: $dropzone.data('max-file'), maxFilesize: $dropzone.data('max-size'), acceptedFiles: @@ -1144,7 +1144,7 @@ async function initRepository() { $.each(data, function () { const imgSrc = `${$dropzone.data('upload-url')}/${ this.uuid - }`; + }`; dz.emit('addedfile', this); dz.emit('thumbnail', this, imgSrc); dz.emit('complete', this); @@ -1570,9 +1570,9 @@ function initPullRequestReview() { if (!ntr.hasClass('add-comment')) { ntr = $( `${ - isSplit ? - '' : - '' + isSplit ? + '' : + '' }` ); tr.after(ntr); @@ -2101,7 +2101,7 @@ function initWebhook() { $('#content_type') .parent() .parent() - [visible ? 'show' : 'hide'](); + [visible ? 'show' : 'hide'](); }; updateContentType(); $('#http_method').on('change', () => { @@ -2385,7 +2385,7 @@ function searchUsers() { }); }); - return {results: items}; + return { results: items }; } }, searchFields: ['login', 'full_name'], @@ -2401,7 +2401,7 @@ function searchTeams() { url: `${AppSubUrl}/api/v1/orgs/${$searchTeamBox.data( 'org' )}/teams/search?q={query}`, - headers: {'X-Csrf-Token': csrf}, + headers: { 'X-Csrf-Token': csrf }, onResponse(response) { const items = []; $.each(response.data, (_i, item) => { @@ -2411,7 +2411,7 @@ function searchTeams() { }); }); - return {results: items}; + return { results: items }; } }, searchFields: ['name', 'description'], @@ -2436,7 +2436,7 @@ function searchRepositories() { }); }); - return {results: items}; + return { results: items }; } }, searchFields: ['full_name'], @@ -2480,7 +2480,7 @@ function initCodeView() { }) .trigger('hashchange'); } - $('.fold-code').on('click', ({target}) => { + $('.fold-code').on('click', ({ target }) => { const box = target.closest('.file-content'); const folded = box.dataset.folded !== 'true'; target.classList.add(`fa-chevron-${folded ? 'right' : 'down'}`); @@ -2537,7 +2537,7 @@ function u2fSigned(resp) { $.ajax({ url: `${AppSubUrl}/user/u2f/sign`, type: 'POST', - headers: {'X-Csrf-Token': csrf}, + headers: { 'X-Csrf-Token': csrf }, data: JSON.stringify(resp), contentType: 'application/json; charset=utf-8' }) @@ -2556,7 +2556,7 @@ function u2fRegistered(resp) { $.ajax({ url: `${AppSubUrl}/user/settings/security/u2f/register`, type: 'POST', - headers: {'X-Csrf-Token': csrf}, + headers: { 'X-Csrf-Token': csrf }, data: JSON.stringify(resp), contentType: 'application/json; charset=utf-8', success() { @@ -2599,8 +2599,8 @@ function u2fError(errorType) { } function initU2FRegister() { - $('#register-device').modal({allowMultiple: false}); - $('#u2f-error').modal({allowMultiple: false}); + $('#register-device').modal({ allowMultiple: false }); + $('#u2f-error').modal({ allowMultiple: false }); $('#register-security-key').on('click', (e) => { e.preventDefault(); u2fApi @@ -2689,7 +2689,7 @@ function initTemplateSearch() { '#uid' ).val()}`, onResponse(response) { - const filteredResponse = {success: true, results: []}; + const filteredResponse = { success: true, results: [] }; filteredResponse.results.push({ name: '', value: '' @@ -2767,15 +2767,15 @@ $(document).ready(async () => { window.location = $(this).data('href'); }); // 在String原型对象上添加format方法 - String.prototype.format = function(){ + String.prototype.format = function () { let str = this; - if(arguments.length == 0){ - return str; - }else{ - Object.keys(arguments).forEach((item,index)=>{ - str = str.replace(/\?/,arguments[item]) - }) - return str + if (arguments.length == 0) { + return str; + } else { + Object.keys(arguments).forEach((item, index) => { + str = str.replace(/\?/, arguments[item]) + }) + return str } } @@ -2785,14 +2785,14 @@ $(document).ready(async () => { const filenameDict = {}; let maxFileTooltips let maxSizeTooltips - if($dropzone.data('max-file-tooltips')&&$dropzone.data('max-size-tooltips')){ - maxFileTooltips=$dropzone.data('max-file-tooltips').format($dropzone.data('max-file'),$dropzone.data('max-size')) - maxSizeTooltips=$dropzone.data('max-size-tooltips').format($dropzone.data('max-file')) + if ($dropzone.data('max-file-tooltips') && $dropzone.data('max-size-tooltips')) { + maxFileTooltips = $dropzone.data('max-file-tooltips').format($dropzone.data('max-file'), $dropzone.data('max-size')) + maxSizeTooltips = $dropzone.data('max-size-tooltips').format($dropzone.data('max-file')) } - + await createDropzone('#dropzone', { url: $dropzone.data('upload-url'), - headers: {'X-Csrf-Token': csrf}, + headers: { 'X-Csrf-Token': csrf }, maxFiles: $dropzone.data('max-file'), maxFilesize: $dropzone.data('max-size'), acceptedFiles: @@ -2821,25 +2821,25 @@ $(document).ready(async () => { }); } }); - this.on('addedfile',(file)=>{ - if(file.size/(1000*1000)>$dropzone.data('max-size')){ + this.on('addedfile', (file) => { + if (file.size / (1000 * 1000) > $dropzone.data('max-size')) { this.removeFile(file) - if(maxFileTooltips){ + if (maxFileTooltips) { $('.maxfilesize.ui.red.message').text(maxFileTooltips) - $('.maxfilesize.ui.red.message').css('display','block') + $('.maxfilesize.ui.red.message').css('display', 'block') } - }else{ - if(maxFileTooltips){ - $('.maxfilesize.ui.red.message').css('display','none') + } else { + if (maxFileTooltips) { + $('.maxfilesize.ui.red.message').css('display', 'none') } } - + }); - this.on('maxfilesexceeded',(file)=>{ + this.on('maxfilesexceeded', (file) => { this.removeFile(file) - if(maxSizeTooltips){ + if (maxSizeTooltips) { $('.maxfilesize.ui.red.message').text(maxSizeTooltips) - $('.maxfilesize.ui.red.message').css('display','block') + $('.maxfilesize.ui.red.message').css('display', 'block') } }) @@ -2905,8 +2905,8 @@ $(document).ready(async () => { }); $('.issue-action').on('click', function () { - let {action} = this.dataset; - let {elementId} = this.dataset; + let { action } = this.dataset; + let { elementId } = this.dataset; const issueIDs = $('.issue-checkbox') .children('input:checked') .map(function () { @@ -2914,8 +2914,8 @@ $(document).ready(async () => { }) .get() .join(); - console.log("this:",this) - const {url} = this.dataset; + console.log("this:", this) + const { url } = this.dataset; if (elementId === '0' && url.substr(-9) === '/assignee') { elementId = ''; action = 'clear'; @@ -3037,13 +3037,13 @@ $(document).ready(async () => { // Only modify if repo_name input is blank const repoValue = $cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3] $repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]); - $.get(`${window.config.AppSubUrl}/repo/check_name?q=${repoValue}&owner=${$owner}`,(data)=>{ + $.get(`${window.config.AppSubUrl}/repo/check_name?q=${repoValue}&owner=${$owner}`, (data) => { const repo_name = data.name $('#repo_name').val(repo_name) repo_name && $('#repo_name').parent().removeClass('error') - $('#repoAdress').css("display","flex") - $('#repoAdress span').text($urlAdd+'/'+$owner+'/'+$('#repo_name').val()+'.git') - $('#repo_name').attr("placeholder","") + $('#repoAdress').css("display", "flex") + $('#repoAdress span').text($urlAdd + '/' + $owner + '/' + $('#repo_name').val() + '.git') + $('#repo_name').attr("placeholder", "") }) } }); @@ -3324,23 +3324,23 @@ function initVueComponents() { return ( this.repos.length > 0 && this.repos.length < - this.counts[ - `${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}` - ] + this.counts[ + `${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}` + ] ); }, searchURL() { return `${ this.suburl - }/api/v1/repos/search?sort=updated&order=desc&uid=${this.uid}&q=${ + }/api/v1/repos/search?sort=updated&order=desc&uid=${this.uid}&q=${ this.searchQuery - }&page=${this.page}&limit=${this.searchLimit}&mode=${ + }&page=${this.page}&limit=${this.searchLimit}&mode=${ this.repoTypes[this.reposFilter].searchMode - }${this.reposFilter !== 'all' ? '&exclusive=1' : ''}${ + }${this.reposFilter !== 'all' ? '&exclusive=1' : ''}${ this.archivedFilter === 'archived' ? '&archived=true' : '' - }${this.archivedFilter === 'unarchived' ? '&archived=false' : ''}${ + }${this.archivedFilter === 'unarchived' ? '&archived=false' : ''}${ this.privateFilter === 'private' ? '&onlyPrivate=true' : '' - }${this.privateFilter === 'public' ? '&private=false' : ''}`; + }${this.privateFilter === 'public' ? '&private=false' : ''}`; }, repoTypeCount() { return this.counts[ @@ -3648,40 +3648,40 @@ function initVueApp() { } initVueComponents(); - + new Vue({ delimiters: ['${', '}'], el, data: { - page:parseInt(new URLSearchParams(window.location.search).get('page')), + page: parseInt(new URLSearchParams(window.location.search).get('page')), searchLimit: Number( (document.querySelector('meta[name=_search_limit]') || {}).content ), - page:1, + page: 1, suburl: AppSubUrl, uid: Number( (document.querySelector('meta[name=_context_uid]') || {}).content ), activityTopAuthors: window.ActivityTopAuthors || [], - localHref:'' + localHref: '' }, components: { ActivityTopAuthors }, - mounted(){ + mounted() { this.page = parseInt(new URLSearchParams(window.location.search).get('page')) this.localHref = location.href }, - methods:{ - handleCurrentChange:function (val) { + methods: { + handleCurrentChange: function (val) { const searchParams = new URLSearchParams(window.location.search) if (!window.location.search) { - window.location.href = this.localHref + '?page='+val + window.location.href = this.localHref + '?page=' + val } else if (searchParams.has('page')) { - window.location.href = this.localHref.replace(/page=[0-9]+/g,'page='+val) + window.location.href = this.localHref.replace(/page=[0-9]+/g, 'page=' + val) } else { - window.location.href=location.href+'&page='+val + window.location.href = location.href + '&page=' + val } this.page = val } @@ -3697,14 +3697,14 @@ function initVueUploader() { new Vue({ el: '#minioUploader', - components: {MinioUploader}, + components: { MinioUploader }, template: '' }); } function initVueEditAbout() { const el = document.getElementById('about-desc'); - + if (!el) { return; } @@ -3715,31 +3715,31 @@ function initVueEditAbout() { }); } -function initVueDataset() { - if($('#dataset_check').length){ - if(location.search.indexOf('recommend=true')!==-1){ +function initVueDataset() { + if ($('#dataset_check').length) { + if (location.search.indexOf('recommend=true') !== -1) { $('#dataset_check').checkbox('set checked') - }else{ + } else { $('#dataset_check').checkbox('set unchecked') } $('#dataset_check').checkbox({ - onChecked: function() { - if(location.search){ + onChecked: function () { + if (location.search) { const params = new URLSearchParams(location.search) - if(params.has('recommend')){ + if (params.has('recommend')) { params.delete('recommend') location.href = AppSubUrl + location.pathname + '?' + params.toString() + '&recommend=true' - }else{ + } else { location.href = `${window.config.AppSubUrl}/admin/datasets${location.search}&recommend=true` } - }else{ + } else { location.href = `${window.config.AppSubUrl}/admin/datasets?recommend=true` } }, - onUnchecked: function() { - if(location.search=='?recommend=true'){ + onUnchecked: function () { + if (location.search == '?recommend=true') { location.href = AppSubUrl + location.pathname - }else{ + } else { const params = new URLSearchParams(location.search) params.delete('recommend') location.href = AppSubUrl + location.pathname + '?' + params.toString() @@ -3747,87 +3747,87 @@ function initVueDataset() { }, }) } - $('.set_dataset').on('click', function(){ + $('.set_dataset').on('click', function () { const $this = $(this); let link = $this.data('url') $.ajax({ - url:link, - type:'PUT', - success:function(res){ + url: link, + type: 'PUT', + success: function (res) { console.log(res) - if(res.Code==0){ + if (res.Code == 0) { window.location.href = '/admin/datasets' - }else{ + } else { $('.ui.negative.message').text(res.Message).show().delay(1500).fadeOut(); } }, - error: function(xhr){ - // 隐藏 loading - // 只有请求不正常(状态码不为200)才会执行 + error: function (xhr) { + // 隐藏 loading + // 只有请求不正常(状态码不为200)才会执行 $('.ui.negative.message').html(xhr.responseText).show().delay(1500).fadeOut(); console.log(xhr) }, - complete:function(xhr){ + complete: function (xhr) { // $("#mask").css({"display":"none","z-index":"1"}) } }) - + }); const el = document.getElementById('dataset-base'); if (!el) { return; } - let link=$('#square-link').data('link') + let link = $('#square-link').data('link') let repolink = $('.dataset-repolink').data('repolink') let cloudbrainType = $('.dataset-repolink').data('cloudranin-type') - const clearBtn = document.getElementsByClassName("clear_dataset_value"); + 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 - } - }) + 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 = [] const zipStatus = [] - $('#dataset-range-value').find('.item').each(function(){ + $('#dataset-range-value').find('.item').each(function () { items.push($(this).data('private')) zipStatus.push($(this).data('decompress-state')) }) 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') - ruleForm.title = $this.data('edit-title') || '' - ruleForm.description = $this.data('edit-description') || '' - ruleForm.category = $this.data('edit-category') || '' - ruleForm.task = $this.data('edit-task') || '' - ruleForm.license = $this.data('edit-license') || '' - ruleForm.id = $this.data('edit-id')|| '' - ruleForm._csrf = csrf + if (document.getElementById('dataset-edit-value')) { + let $this = $('#dataset-edit-value') + ruleForm.title = $this.data('edit-title') || '' + ruleForm.description = $this.data('edit-description') || '' + ruleForm.category = $this.data('edit-category') || '' + ruleForm.task = $this.data('edit-task') || '' + ruleForm.license = $this.data('edit-license') || '' + ruleForm.id = $this.data('edit-id') || '' + ruleForm._csrf = csrf } const starItems = [] const starActives = [] - $('#datasets-square-range-value').find('.item').each(function(){ + $('#datasets-square-range-value').find('.item').each(function () { starItems.push($(this).data('num-stars')) starActives.push($(this).data('star-active')) }) const taskLists = [] const licenseLists = [] - $('#task-square-range-value').find('.item').each(function(){ + $('#task-square-range-value').find('.item').each(function () { taskLists.push($(this).data('task')) }) - $('#task-square-range-value').find('.item').each(function(){ + $('#task-square-range-value').find('.item').each(function () { licenseLists.push($(this).data('license')) }) let dataset_file_desc - if(document.getElementById('dataset-file-desc')){ + if (document.getElementById('dataset-file-desc')) { dataset_file_desc = document.getElementById('dataset-file-desc').value } new Vue({ @@ -3835,79 +3835,81 @@ function initVueDataset() { el, data: { suburl: AppSubUrl, - url:'', - checked:false, - clusterFlag:false, - type:0, - desc:'', - descfile:'', - datasetType:'', - privates:[], - zipStatus:[], - starItems:[], - starActives:[], - taskLists:[], - taskShow:[], - licenseLists:[], - licenseShow:[], + url: '', + checked: false, + clusterFlag: false, + type: 0, + desc: '', + descfile: '', + datasetType: '', + privates: [], + zipStatus: [], + starItems: [], + starActives: [], + taskLists: [], + taskShow: [], + licenseLists: [], + licenseShow: [], hasMoreBthHis: false, - showMoreHis:false, - star_active:false, - num_stars:0, - dialogVisible:false, + showMoreHis: false, + star_active: false, + num_stars: 0, + dialogVisible: false, activeName: 'first', - searchDataItem:'', - currentRepoDataset:[], - myDataset:[], - publicDataset:[], - myFavoriteDataset:[], - page:1, - totalnums:0, - repolink:'', - cloudbrainType:0, - dataset_uuid:'', - dataset_name:'', - loadingDataIndex:true, - timer:null, - ruleForm:{ - title:'', - description:'', - category:'', - task:'', - license:'', - _csrf:csrf, - + searchDataItem: '', + currentRepoDataset: [], + myDataset: [], + publicDataset: [], + myFavoriteDataset: [], + page: 1, + totalnums: 0, + repolink: '', + cloudbrainType: 0, + dataset_uuid: '', + dataset_name: '', + loadingDataIndex: true, + timer: null, + ruleForm: { + title: '', + description: '', + category: '', + task: '', + license: '', + _csrf: csrf, + }, - ruleForm1:{ - title:'', - description:'', - category:'', - task:'', - license:'', - _csrf:'', - id:'' + ruleForm1: { + title: '', + description: '', + category: '', + task: '', + license: '', + _csrf: '', + id: '' }, rules: { title: [ { required: true, message: '请输入数据集名称', trigger: 'blur' }, { min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' }, // {required:true,message:'test',pattern:'/^[a-zA-Z0-9-_]{1,100}[^-]$/',trigger:'blur'}, - { validator: (rule, value, callback) => { - if (/^[a-zA-Z0-9-_.]{0,100}$/.test(value) == false) { - callback(new Error("输入不符合数据集名称规则")); - } else { - callback(); - } - }, trigger: 'blur'} + { + validator: (rule, value, callback) => { + if (/^[a-zA-Z0-9-_.]{0,100}$/.test(value) == false) { + callback(new Error("输入不符合数据集名称规则")); + } else { + callback(); + } + }, trigger: 'blur' + } ], description: [ { required: true, message: '请输入数据集描述详情', trigger: 'blur' } ], category: [ - { required: true, message: '请选择分类', trigger: 'change' } + { required: true, message: '请选择分类', trigger: 'change' } ], task: [ - { required: true, message: '请选择研究方向/应用领域', trigger: 'change' } + { required: true, message: '请选择研究方向/应用领域', trigger: 'change' } ], // license: [ // { required: true, message: '请选择活动区域', trigger: 'change' } @@ -3917,7 +3919,7 @@ function initVueDataset() { components: { MinioUploader }, - mounted(){ + mounted() { // if(document.getElementById('postPath')){ // this.url = document.getElementById('postPath').value // } @@ -3925,24 +3927,24 @@ function initVueDataset() { // this.num_stars = num_stars // this.star_active = star_active // this.ruleForm1 = ruleForm - + // // this.getEditInit() // this.getTypeList() this.getTypeList() - - if(!!document.getElementById('dataset-repolink-init')){ - this.getCurrentRepoDataset(this.repolink,this.cloudbrainType) + + if (!!document.getElementById('dataset-repolink-init')) { + this.getCurrentRepoDataset(this.repolink, this.cloudbrainType) } - + const params = new URLSearchParams(location.search) - if (params.has('recommend') && params.get('recommend')=='true'){ + if (params.has('recommend') && params.get('recommend') == 'true') { this.checked = true - }else{ + } else { this.checked = false } }, - created(){ - if(document.getElementById('postPath')){ + created() { + if (document.getElementById('postPath')) { this.url = document.getElementById('postPath').value } this.privates = items @@ -3951,7 +3953,7 @@ function initVueDataset() { this.star_active = star_active this.ruleForm1 = ruleForm // this.getEditInit() - + this.starItems = starItems this.starActives = starActives this.taskLists = taskLists @@ -3960,131 +3962,148 @@ function initVueDataset() { this.repolink = repolink this.cloudbrainType = cloudbrainType }, - methods:{ + methods: { + copyUrl(url) { + const cInput = document.createElement('input') + cInput.value = url + document.body.appendChild(cInput) + cInput.select() + document.execCommand('Copy') + cInput.remove() + $('body') + .toast({ + message: '复制成功!', + showProgress: 'bottom', + showIcon: 'check circle', + class: 'info', + position: 'top right', + }) + ; + }, handleCurrentChange(val) { this.page = val - switch(this.activeName){ + switch (this.activeName) { case 'first': - this.getCurrentRepoDataset(this.repolink,this.cloudbrainType) - - break + this.getCurrentRepoDataset(this.repolink, this.cloudbrainType) + + break case 'second': - this.getMyDataset(this.repolink,this.cloudbrainType) - break + this.getMyDataset(this.repolink, this.cloudbrainType) + break case 'third': - this.getPublicDataset(this.repolink,this.cloudbrainType) - break + this.getPublicDataset(this.repolink, this.cloudbrainType) + break case 'fourth': - this.getStarDataset(this.repolink,this.cloudbrainType) - break - } + this.getStarDataset(this.repolink, this.cloudbrainType) + break + } }, - handleCheckedChange(val){ - if(val){ - if(location.search){ + handleCheckedChange(val) { + if (val) { + if (location.search) { const params = new URLSearchParams(location.search) - if(params.has('recommend')){ + if (params.has('recommend')) { params.delete('recommend') let search = params.toString() location.href = `${AppSubUrl}/explore/datasets?${search}&recommend=${val}` - }else{ + } else { location.href = `${AppSubUrl}/explore/datasets${location.search}&recommend=${val}` } - }else{ + } else { location.href = `${AppSubUrl}/explore/datasets?recommend=${val}` } - }else{ - if(location.search=='?recommend=true'){ + } else { + if (location.search == '?recommend=true') { location.href = AppSubUrl + location.pathname - }else{ + } else { const params = new URLSearchParams(location.search) params.delete('recommend') location.href = AppSubUrl + location.pathname + '?' + params.toString() } } }, - createDataset(formName){ + createDataset(formName) { let _this = this - this.$refs[formName].validate((valid)=>{ - if(valid){ + 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){ + _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('/create')[0]+'?type=-1' - }else{ + location.href = _this.url.split('/create')[0] + '?type=-1' + } else { console.log(res.data.Message) } document.getElementById("mask").style.display = "none" - }).catch(error=>{ - console.log(error) + }).catch(error => { + console.log(error) }) } - else{ + else { return false } }) }, - cancelDataset(getpage,attachment){ - if(getpage && !attachment){ - 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='/' + cancelDataset(getpage, attachment) { + if (getpage && !attachment) { + 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 = '/' } } - else{ + else { location.href = `${AppSubUrl}${attachment}/datasets` - + } - + }, - gotoUpload(repolink,datsetId){ + gotoUpload(repolink, datsetId) { // location.href = `${AppSubUrl}${repolink}/datasets/attachments/upload?datasetId=${datsetId}` - window.open(`${AppSubUrl}${repolink}/datasets/attachments/upload?datasetId=${datsetId}`,'_blank') + window.open(`${AppSubUrl}${repolink}/datasets/attachments/upload?datasetId=${datsetId}`, '_blank') }, - gotoDataset(datsetUrl){ + gotoDataset(datsetUrl) { location.href = datsetUrl }, - gotoAnnotate(repolink,uuid,type){ + gotoAnnotate(repolink, uuid, type) { location.href = `${AppSubUrl}${repolink}/datasets/label/${uuid}?type=${type}` }, - setcluster(val){ + setcluster(val) { this.clusterFlag = val }, - uploadGpu(){ - this.type=0 + uploadGpu() { + this.type = 0 }, - uploadNpu(){ - this.type=1 + 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)=>{ - this.$set(this.privates,index,privateFlag) - }).catch(error=>{ - console.log(error) + setPrivate(uuid, privateFlag, index) { + const params = { _csrf: csrf, file: uuid, is_private: privateFlag } + this.$axios.post('/attachments/private', this.qs.stringify(params)).then((res) => { + this.$set(this.privates, index, privateFlag) + }).catch(error => { + console.log(error) }) }, - delDataset(uuid){ + delDataset(uuid) { let _this = this - const params = {_csrf:csrf,file:uuid} + 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)=>{ - // $('#'+uuid).hide() - location.reload() - }).catch(error=>{ - console.log(error) - }) - } - }) - .modal('show'); + .modal({ + closable: false, + onApprove() { + _this.$axios.post('/attachments/delete', _this.qs.stringify(params)).then((res) => { + // $('#'+uuid).hide() + location.reload() + }).catch(error => { + console.log(error) + }) + } + }) + .modal('show'); }, // getEditInit(){ // if($('#dataset-edit-value')){ @@ -4097,368 +4116,368 @@ function initVueDataset() { // this.ruleForm.id = $this.data('edit-id')|| '' // } // }, - editDataset(formName,id){ + editDataset(formName, id) { let _this = this this.url = this.url.split(`/${id}`)[0] - this.$refs[formName].validate((valid)=>{ - if(valid){ + this.$refs[formName].validate((valid) => { + if (valid) { document.getElementById("mask").style.display = "block" - _this.$axios.post(_this.url,_this.qs.stringify(_this.ruleForm1)).then((res)=>{ - if(res.data.Code===0){ + _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' - }else{ + location.href = _this.url.split('/edit')[0] + '?type=-1' + } else { console.log(res.data.Message) } document.getElementById("mask").style.display = "none" - }).catch((err)=>{ + }).catch((err) => { console.log(err) }) } - else{ + else { return false } }) }, - editDatasetFile(id,backurl){ + editDatasetFile(id, backurl) { let url = '/attachments/edit' - const params={id:id,description:this.descfile,_csrf:csrf} + const params = { id: id, description: this.descfile, _csrf: csrf } // document.getElementById("mask").style.display = "block" - this.$axios.post(url,this.qs.stringify(params)).then((res)=>{ - if(res.data.Code===0){ + this.$axios.post(url, this.qs.stringify(params)).then((res) => { + if (res.data.Code === 0) { location.href = `${AppSubUrl}${backurl}/datasets` - }else{ + } else { console.log(res.data.Message) } - }).catch((err)=>{ + }).catch((err) => { console.log(err) }) }, - postStar(id,link){ - if(this.star_active){ - let url = link+'/'+ id + '/unstar' - this.$axios.put(url).then((res)=>{ - if(res.data.Code===0){ + postStar(id, link) { + if (this.star_active) { + let url = link + '/' + id + '/unstar' + this.$axios.put(url).then((res) => { + if (res.data.Code === 0) { this.star_active = false - this.num_stars = this.num_stars -1 + this.num_stars = this.num_stars - 1 } }) - }else{ - let url = link+'/'+ id + '/star' - this.$axios.put(url).then((res)=>{ - if(res.data.Code===0){ + } else { + let url = link + '/' + id + '/star' + this.$axios.put(url).then((res) => { + if (res.data.Code === 0) { this.star_active = true this.num_stars = this.num_stars + 1 } }) } }, - postSquareStar(id,link,index){ - if(this.starActives[index]){ - let url = link+'/'+ id + '/unstar' - this.$axios.put(url).then((res)=>{ - if(res.data.Code===0){ - this.$set(this.starActives,index,false) - this.$set(this.starItems,index,this.starItems[index]-1) + postSquareStar(id, link, index) { + if (this.starActives[index]) { + let url = link + '/' + id + '/unstar' + this.$axios.put(url).then((res) => { + if (res.data.Code === 0) { + this.$set(this.starActives, index, false) + this.$set(this.starItems, index, this.starItems[index] - 1) } }) - }else{ - let url = link+'/'+ id + '/star' - this.$axios.put(url).then((res)=>{ - if(res.data.Code===0){ - this.$set(this.starActives,index,true) - this.$set(this.starItems,index,this.starItems[index]+1) - + } else { + let url = link + '/' + id + '/star' + this.$axios.put(url).then((res) => { + if (res.data.Code === 0) { + this.$set(this.starActives, index, true) + this.$set(this.starItems, index, this.starItems[index] + 1) + } }) } }, - getTypeList(){ + getTypeList() { const params = new URLSearchParams(window.location.search) - if( window.location.search && params.has('type')){ - if(params.get('type')==0){ + if (window.location.search && params.has('type')) { + if (params.get('type') == 0) { this.datasetType = '0' - } - if(params.get('type')==1){ + } + if (params.get('type') == 1) { this.datasetType = '1' } - if(params.get('type')==-1){ + if (params.get('type') == -1) { this.datasetType = '-1' } - }else { + } else { this.datasetType = '-1' } }, - changeDatasetType(val){ + changeDatasetType(val) { const searchParams = new URLSearchParams(window.location.search) if (!window.location.search) { - window.location.href = window.location.href + '?type='+val + window.location.href = window.location.href + '?type=' + val } else if (searchParams.has('type')) { - window.location.href = window.location.href.replace(/type=([0-9]|-[0-9])/g,'type='+val) + window.location.href = window.location.href.replace(/type=([0-9]|-[0-9])/g, 'type=' + val) } else { - window.location.href=window.location.href+'&type='+val + window.location.href = window.location.href + '&type=' + val } - + }, - gotoDatasetEidt(repolink,id){ + gotoDatasetEidt(repolink, id) { location.href = `${repolink}/datasets/attachments/edit/${id}` }, - handleClick(repoLink, tabName,type) { - if(tabName=="first"){ - this.page=1 - this.searchDataItem='' - this.getCurrentRepoDataset(repoLink,type) - + handleClick(repoLink, tabName, type) { + if (tabName == "first") { + this.page = 1 + this.searchDataItem = '' + this.getCurrentRepoDataset(repoLink, type) + } - if(tabName=="second"){ - this.page=1 - this.searchDataItem='' - this.getMyDataset(repoLink,type) + if (tabName == "second") { + this.page = 1 + this.searchDataItem = '' + this.getMyDataset(repoLink, type) } - if(tabName=="third"){ - this.page=1 - this.searchDataItem='' - this.getPublicDataset(repoLink,type) + if (tabName == "third") { + this.page = 1 + this.searchDataItem = '' + this.getPublicDataset(repoLink, type) } - if(tabName=="fourth"){ - this.page=1 - this.searchDataItem='' - this.getStarDataset(repoLink,type) + if (tabName == "fourth") { + this.page = 1 + this.searchDataItem = '' + this.getStarDataset(repoLink, type) } }, - polling (checkStatuDataset,repoLink) { + polling(checkStatuDataset, repoLink) { this.timer = window.setInterval(() => { - setTimeout(() => { - this.getDatasetStatus(checkStatuDataset,repoLink) - },0) - },15000) + setTimeout(() => { + this.getDatasetStatus(checkStatuDataset, repoLink) + }, 0) + }, 15000) }, - getDatasetStatus(checkStatuDataset,repoLink){ - const getmap = checkStatuDataset.map((item)=>{ - let url = `${AppSubUrl}${repolink}/datasets/status/${item.UUID}` - return this.$axios.get(url) - }) - this.$axios.all(getmap) - .then((res)=>{ - let flag = res.some((item)=>{ + getDatasetStatus(checkStatuDataset, repoLink) { + const getmap = checkStatuDataset.map((item) => { + let url = `${AppSubUrl}${repolink}/datasets/status/${item.UUID}` + return this.$axios.get(url) + }) + this.$axios.all(getmap) + .then((res) => { + let flag = res.some((item) => { return item.data.AttachmentStatus == 1 }) flag && clearInterval(this.timer) flag && this.refreshStatusDataset() - + } ) }, - refreshStatusDataset(){ - switch(this.activeName){ + refreshStatusDataset() { + switch (this.activeName) { case 'first': - this.getCurrentRepoDataset(this.repolink,this.cloudbrainType) - break + this.getCurrentRepoDataset(this.repolink, this.cloudbrainType) + break case 'second': - this.getMyDataset(this.repolink,this.cloudbrainType) - break + this.getMyDataset(this.repolink, this.cloudbrainType) + break case 'third': - this.getPublicDataset(this.repolink,this.cloudbrainType) - break + this.getPublicDataset(this.repolink, this.cloudbrainType) + break case 'fourth': - this.getStarDataset(this.repolink,this.cloudbrainType) - break - } + this.getStarDataset(this.repolink, this.cloudbrainType) + break + } }, - getCurrentRepoDataset(repoLink,type){ + getCurrentRepoDataset(repoLink, type) { clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/current_repo' - this.$axios.get(url,{ - params:{ - type:type, - page:this.page, - q:this.searchDataItem + this.$axios.get(url, { + params: { + type: type, + page: this.page, + q: this.searchDataItem } - }).then((res)=>{ + }).then((res) => { this.currentRepoDataset = JSON.parse(res.data.data) - const checkStatuDataset = this.currentRepoDataset.filter(item=>item.DecompressState===2) - if(checkStatuDataset.length>0){ - this.polling(checkStatuDataset,repoLink) + const checkStatuDataset = this.currentRepoDataset.filter(item => item.DecompressState === 2) + if (checkStatuDataset.length > 0) { + this.polling(checkStatuDataset, repoLink) } this.totalnums = parseInt(res.data.count) this.loadingDataIndex = false }) }, - getMyDataset(repoLink,type){ + getMyDataset(repoLink, type) { clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/my_datasets' - this.$axios.get(url,{ - params:{ - type:type, - page:this.page, - q:this.searchDataItem + this.$axios.get(url, { + params: { + type: type, + page: this.page, + q: this.searchDataItem } - }).then((res)=>{ + }).then((res) => { this.myDataset = JSON.parse(res.data.data) - const checkStatuDataset = this.myDataset.filter(item=>item.DecompressState===2) - if(checkStatuDataset.length>0){ - this.polling(checkStatuDataset,repoLink) + const checkStatuDataset = this.myDataset.filter(item => item.DecompressState === 2) + if (checkStatuDataset.length > 0) { + this.polling(checkStatuDataset, repoLink) } this.totalnums = parseInt(res.data.count) this.loadingDataIndex = false }) }, - getPublicDataset(repoLink,type){ + getPublicDataset(repoLink, type) { clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/public_datasets' - this.$axios.get(url,{ - params:{ - type:type, - page:this.page, - q:this.searchDataItem + this.$axios.get(url, { + params: { + type: type, + page: this.page, + q: this.searchDataItem } - }).then((res)=>{ + }).then((res) => { this.publicDataset = JSON.parse(res.data.data) - const checkStatuDataset = this.publicDataset.filter(item=>item.DecompressState===2) - if(checkStatuDataset.length>0){ - this.polling(checkStatuDataset,repoLink) + const checkStatuDataset = this.publicDataset.filter(item => item.DecompressState === 2) + if (checkStatuDataset.length > 0) { + this.polling(checkStatuDataset, repoLink) } this.totalnums = parseInt(res.data.count) this.loadingDataIndex = false }) }, - getStarDataset(repoLink,type){ + getStarDataset(repoLink, type) { clearInterval(this.timer) this.loadingDataIndex = true let url = repoLink + '/datasets/my_favorite' - this.$axios.get(url,{ - params:{ - type:type, - page:this.page, - q:this.searchDataItem + this.$axios.get(url, { + params: { + type: type, + page: this.page, + q: this.searchDataItem } - }).then((res)=>{ + }).then((res) => { this.myFavoriteDataset = JSON.parse(res.data.data) - const checkStatuDataset = this.myFavoriteDataset.filter(item=>item.DecompressState===2) - if(checkStatuDataset.length>0){ - this.polling(checkStatuDataset,repoLink) + const checkStatuDataset = this.myFavoriteDataset.filter(item => item.DecompressState === 2) + if (checkStatuDataset.length > 0) { + this.polling(checkStatuDataset, repoLink) } - this.totalnums= parseInt(res.data.count) + this.totalnums = parseInt(res.data.count) this.loadingDataIndex = false }) }, - selectDataset(uuid,name){ + selectDataset(uuid, name) { this.dataset_uuid = uuid this.dataset_name = name this.dialogVisible = false }, - searchDataset(){ - switch(this.activeName){ + searchDataset() { + switch (this.activeName) { case 'first': this.page = 1 - this.getCurrentRepoDataset(this.repolink,this.cloudbrainType) - break + this.getCurrentRepoDataset(this.repolink, this.cloudbrainType) + break case 'second': this.page = 1 - this.getMyDataset(this.repolink,this.cloudbrainType) - break + this.getMyDataset(this.repolink, this.cloudbrainType) + break case 'third': this.page = 1 - this.getPublicDataset(this.repolink,this.cloudbrainType) - break + this.getPublicDataset(this.repolink, this.cloudbrainType) + break case 'fourth': this.page = 1 - this.getStarDataset(this.repolink,this.cloudbrainType) - break - } + this.getStarDataset(this.repolink, this.cloudbrainType) + break + } } }, - watch:{ - searchDataItem(){ - switch(this.activeName){ + watch: { + searchDataItem() { + switch (this.activeName) { case 'first': this.page = 1 - this.getCurrentRepoDataset(this.repolink,this.cloudbrainType) - break + this.getCurrentRepoDataset(this.repolink, this.cloudbrainType) + break case 'second': this.page = 1 - this.getMyDataset(this.repolink,this.cloudbrainType) - break + this.getMyDataset(this.repolink, this.cloudbrainType) + break case 'third': this.page = 1 - this.getPublicDataset(this.repolink,this.cloudbrainType) - break + this.getPublicDataset(this.repolink, this.cloudbrainType) + break case 'fourth': this.page = 1 - this.getStarDataset(this.repolink,this.cloudbrainType) - break - } + this.getStarDataset(this.repolink, this.cloudbrainType) + break + } } }, - }); + }); } - + function initVueEditTopic() { - const el = document.getElementById('topic_edit1'); - - if (!el) { - return; - } - - new Vue({ - el:'#topic_edit1', - render:h=>h(EditTopics) - }) + const el = document.getElementById('topic_edit1'); + + if (!el) { + return; + } + + new Vue({ + el: '#topic_edit1', + render: h => h(EditTopics) + }) } function initVueContributors() { const el = document.getElementById('Contributors'); - + if (!el) { return; } new Vue({ - el:'#Contributors', - render:h=>h(Contributors) + el: '#Contributors', + render: h => h(Contributors) }) } // function initVueImages() { // const el = document.getElementById('images'); - - + + // if (!el) { // return; // } // new Vue({ // el: '#images', - + // render: h => h(Images) // }); // } function initVueModel() { const el = document.getElementById('model_list'); - - + + if (!el) { return; } new Vue({ el: el, - + render: h => h(Model) }); } @@ -4470,7 +4489,7 @@ function initVueDataAnalysis() { new Vue({ el: '#data_analysis', - + render: h => h(DataAnalysis) }); } @@ -4480,7 +4499,7 @@ function initVueWxAutorize() { return; } new Vue({ - el:el, + el: el, render: h => h(WxAutorize) }); } @@ -4794,7 +4813,7 @@ function initIssueList() { apiSettings: { url: issueSearchUrl, onResponse(response) { - const filteredResponse = {success: true, results: []}; + const filteredResponse = { success: true, results: [] }; const currIssueId = $('#new-dependency-drop-list').data('issue-id'); // Parse the response from the api to work with our dropdown $.each(response, (_i, issue) => { @@ -4899,18 +4918,18 @@ $.get(`${window.config.StaticUrlPrefix}/img/svg/icons.svg`, (data) => { document.body.insertBefore(div, document.body.childNodes[0]); }); function initDropDown() { - $("#dropdown_PageHome").dropdown({ - on:'hover' ,//鼠标悬浮显示,默认值是click - }); - $("#dropdown_explore").dropdown({ - on:'hover' ,//鼠标悬浮显示,默认值是click - }); + $("#dropdown_PageHome").dropdown({ + on: 'hover',//鼠标悬浮显示,默认值是click + }); + $("#dropdown_explore").dropdown({ + on: 'hover',//鼠标悬浮显示,默认值是click + }); } //云脑提示 -$('.question.circle.icon.cloudbrain-question').hover(function(){ +$('.question.circle.icon.cloudbrain-question').hover(function () { $(this).popup('show') - $('.ui.popup.mini.top.center').css({"border-color":'rgba(50, 145, 248, 100)',"color":"rgba(3, 102, 214, 100)","border-radius":"5px","border-shadow":"none"}) + $('.ui.popup.mini.top.center').css({ "border-color": 'rgba(50, 145, 248, 100)', "color": "rgba(3, 102, 214, 100)", "border-radius": "5px", "border-shadow": "none" }) }); //云脑详情页面跳转回上一个页面 @@ -4918,80 +4937,80 @@ $('.question.circle.icon.cloudbrain-question').hover(function(){ //新建调试取消跳转 // $(".ui.button.cancel").attr("href",localStorage.getItem('all')) -function initcreateRepo(){ +function initcreateRepo() { let timeout; let keydown_flag = false const urlAdd = location.href.split('/')[0] + '//' + location.href.split('/')[2] let owner = $('#ownerDropdown div.text').attr("title") - $(document).ready(function(){ - $('#ownerDropdown').dropdown({ - onChange:function(value,text,$choice){ - owner = $choice[0].getAttribute("title") - $('#repoAdress').css("display","flex") - $('#repoAdress span').text(urlAdd+'/'+owner+'/'+$('#repo_name').val()+'.git') - } - }); - }) - $('#repo_name').keyup(function(){ + $(document).ready(function () { + $('#ownerDropdown').dropdown({ + onChange: function (value, text, $choice) { + owner = $choice[0].getAttribute("title") + $('#repoAdress').css("display", "flex") + $('#repoAdress span').text(urlAdd + '/' + owner + '/' + $('#repo_name').val() + '.git') + } + }); + }) + $('#repo_name').keyup(function () { keydown_flag = $('#repo_name').val() ? true : false - if(keydown_flag){ - $('#repoAdress').css("display","flex") - $('#repoAdress span').text(urlAdd+'/'+owner+'/'+$('#repo_name').val()+'.git') + if (keydown_flag) { + $('#repoAdress').css("display", "flex") + $('#repoAdress span').text(urlAdd + '/' + owner + '/' + $('#repo_name').val() + '.git') } - else{ - $('#repoAdress').css("display","none") - $('#repo_name').attr("placeholder","") + else { + $('#repoAdress').css("display", "none") + $('#repo_name').attr("placeholder", "") } }) $("#create_repo_form") - .form({ + .form({ on: 'blur', // inline:true, fields: { alias: { - identifier : 'alias', - rules: [ - { - type: 'regExp[/^[\u4E00-\u9FA5A-Za-z0-9_.-]{1,100}$/]', - } - ] - }, - repo_name:{ - identifier : 'repo_name', - rules: [ - { - type: 'regExp[/^[A-Za-z0-9_.-]{1,100}$/]', - - } - ] - }, + identifier: 'alias', + rules: [ + { + type: 'regExp[/^[\u4E00-\u9FA5A-Za-z0-9_.-]{1,100}$/]', + } + ] + }, + repo_name: { + identifier: 'repo_name', + rules: [ + { + type: 'regExp[/^[A-Za-z0-9_.-]{1,100}$/]', + + } + ] + }, }, - onFailure: function(e){ + onFailure: function (e) { return false; - } - }) + } + }) $('#alias').bind('input propertychange', function (event) { - clearTimeout(timeout) + clearTimeout(timeout) timeout = setTimeout(() => { //在此处写调用的方法,可以实现仅最后一次操作生效 - const aliasValue = $('#alias').val() - if(keydown_flag){ - $('#repo_name').attr("placeholder","") + const aliasValue = $('#alias').val() + if (keydown_flag) { + $('#repo_name').attr("placeholder", "") } - else if(aliasValue){ - $('#repo_name').attr("placeholder","正在获取路径...") - $.get(`${window.config.AppSubUrl}/repo/check_name?q=${aliasValue}&owner=${owner}`,(data)=>{ + else if (aliasValue) { + $('#repo_name').attr("placeholder", "正在获取路径...") + $.get(`${window.config.AppSubUrl}/repo/check_name?q=${aliasValue}&owner=${owner}`, (data) => { const repo_name = data.name $('#repo_name').val(repo_name) repo_name && $('#repo_name').parent().removeClass('error') - $('#repoAdress').css("display","flex") - $('#repoAdress span').text(urlAdd+'/'+owner+'/'+$('#repo_name').val()+'.git') - $('#repo_name').attr("placeholder","") + $('#repoAdress').css("display", "flex") + $('#repoAdress span').text(urlAdd + '/' + owner + '/' + $('#repo_name').val() + '.git') + $('#repo_name').attr("placeholder", "") }) - }else{ + } else { $('#repo_name').val('') - $('#repo_name').attr("placeholder","") - $('#repoAdress').css("display","none") + $('#repo_name').attr("placeholder", "") + $('#repoAdress').css("display", "none") } }, 500) }); diff --git a/web_src/less/openi.less b/web_src/less/openi.less index 2a7d86665..eed7ed94b 100644 --- a/web_src/less/openi.less +++ b/web_src/less/openi.less @@ -1025,4 +1025,8 @@ display: block; z-index: 9999; width:150; height: 80; +} + +.ui.toast-container .toast-box.compact, .ui.toast-container .toast-box>.compact { + width: 250px !important; } \ No newline at end of file