Skip to content

Commit

Permalink
Add validation for missing info
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekSuchanek committed Feb 28, 2024
1 parent ce67477 commit ce82783
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/smp_importer/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,35 @@ importer
.then(() => {
jQuery('#file-input').on('input', function (e) {
const files = e.target.files
if (files.length === 0) {
alert('No file selected!')
return
}
console.log(files)
loadFile(files[0])
})

jQuery('#btn-github-load').on('click', function () {
const owner = jQuery('#github-owner-input').val()
const repo = jQuery('#github-repo-input').val()
const file = jQuery('#github-file-input').val()
if (owner === '' || repo === '') {
alert('Repository owner and name are required!');
return
}
let file = jQuery('#github-file-input').val()
if (file === '') {
file = 'metadata.json'
}
console.log(`${owner}/${repo}:/${file}`)
loadGitHubPublic(owner, repo, file)
})

jQuery('#btn-url-load').on('click', function () {
const url = jQuery('#url-input').val()
if (url === '') {
alert('URL is required!')
return
}
console.log(url)
loadUrl(url)
})
Expand Down Expand Up @@ -158,7 +173,7 @@ function loadGitHubPublic(owner, repo, file) {
},
error: function (result) {
console.log(result)
alert('failed')
alert('Failed to get file from GitHub!')
}
})
}
Expand Down

0 comments on commit ce82783

Please sign in to comment.