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

View File

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

View File

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