This commit is contained in:
Timothy Jaeryang Baek 2025-09-26 22:57:38 -05:00
parent 45e1c72613
commit d7c54d92b5

View file

@ -152,7 +152,16 @@
console.log('importHandler', json); console.log('importHandler', json);
try { try {
const data = JSON.parse(json); let data = JSON.parse(json);
// validate data
if (Array.isArray(data)) {
if (data.length === 0) {
toast.error($i18n.t('Please select a valid JSON file'));
return;
}
data = data[0];
}
if (data.type) type = data.type; if (data.type) type = data.type;
if (data.url) url = data.url; if (data.url) url = data.url;
@ -184,23 +193,25 @@
const exportHandler = async () => { const exportHandler = async () => {
// export current connection as json file // export current connection as json file
const json = JSON.stringify({ const json = JSON.stringify([
type, {
url, type,
url,
spec_type, spec_type,
spec, spec,
path, path,
auth_type, auth_type,
key, key,
info: { info: {
id: id, id: id,
name: name, name: name,
description: description description: description
}
} }
}); ]);
const blob = new Blob([json], { const blob = new Blob([json], {
type: 'application/json' type: 'application/json'