excel import fix

This commit is contained in:
Jan Prochazka 2023-02-17 13:57:30 +01:00
parent c7aaf06506
commit 36c792f44e
3 changed files with 4 additions and 15 deletions

View File

@ -22,7 +22,7 @@
for (const file of getAsArray(files)) {
const format = findFileFormat(extensions, storage);
if (format) {
await (format.addFileToSourceList || addFileToSourceListDefault)(file, newSources, newValues);
await (format.addFileToSourceList || addFileToSourceListDefault)(file, newSources, newValues, apiCall);
}
}
newValues['sourceList'] = [...(values.sourceList || []).filter(x => !newSources.includes(x)), ...newSources];
@ -58,6 +58,7 @@
import { showModal } from '../modals/modalTools';
import { findFileFormat } from '../plugins/fileformats';
import { extensions } from '../stores';
import { apiCall } from '../utility/api';
import getAsArray from '../utility/getAsArray';
import { useConnectionInfo, useDatabaseInfo } from '../utility/metadataLoaders';
import { setUploadListener } from '../utility/uploadFiles';

View File

@ -1,8 +1,4 @@
<script lang="ts" context="module">
const dbgateEnv = {
apiCall,
};
async function loadPlugins(pluginsDict, installedPlugins) {
window['DBGATE_TOOLS'] = dbgateTools;
@ -20,7 +16,6 @@
const module = eval(`${resp}; plugin`);
console.log('Loaded plugin', module);
const moduleContent = module.__esModule ? module.default : module;
if (moduleContent.initialize) moduleContent.initialize(dbgateEnv);
newPlugins[installed.name] = moduleContent;
}
}

View File

@ -1,9 +1,3 @@
let dbgateEnv;
function initialize(dbgateEnv) {
dbgateEnv = dbgateEnv;
}
const fileFormat = {
packageName: 'dbgate-plugin-excel',
// file format identifier
@ -17,8 +11,8 @@ const fileFormat = {
// function name from backend, which contains writer factory, postfixed by package name
writerFunc: 'writer@dbgate-plugin-excel',
addFileToSourceList: async ({ fileName }, newSources, newValues) => {
const resp = await dbgateEnv.apiCall('plugins/command', {
addFileToSourceList: async ({ fileName }, newSources, newValues, apiCall) => {
const resp = await apiCall('plugins/command', {
command: 'analyse',
packageName: 'dbgate-plugin-excel',
args: {
@ -85,5 +79,4 @@ export default {
}),
},
],
initialize,
};