mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 12:26:01 +00:00
removed MS excel support, moved to plugin
This commit is contained in:
@@ -5,6 +5,10 @@ import { useInstalledPlugins } from '../utility/metadataLoaders';
|
||||
|
||||
const PluginsContext = React.createContext(null);
|
||||
|
||||
const dbgateEnv = {
|
||||
axios,
|
||||
};
|
||||
|
||||
export default function PluginsProvider({ children }) {
|
||||
const installedPlugins = useInstalledPlugins();
|
||||
const [plugins, setPlugins] = React.useState({});
|
||||
@@ -22,7 +26,9 @@ export default function PluginsProvider({ children }) {
|
||||
});
|
||||
const module = eval(resp.data);
|
||||
console.log('Loaded plugin', module);
|
||||
newPlugins[installed.name] = module.__esModule ? module.default : module;
|
||||
const moduleContent = module.__esModule ? module.default : module;
|
||||
if (moduleContent.initialize) moduleContent.initialize(dbgateEnv);
|
||||
newPlugins[installed.name] = moduleContent;
|
||||
}
|
||||
}
|
||||
setPlugins((x) =>
|
||||
|
||||
@@ -1,53 +1,3 @@
|
||||
import { usePlugins } from '../plugins/PluginsProvider';
|
||||
import axios from './axios';
|
||||
import { FormSchemaSelect } from './forms';
|
||||
|
||||
const excelFormat = {
|
||||
storageType: 'excel',
|
||||
extension: 'xlsx',
|
||||
name: 'MS Excel',
|
||||
readerFunc: 'excelSheetReader',
|
||||
writerFunc: 'excelSheetWriter',
|
||||
|
||||
addFilesToSourceList: async (file, newSources, newValues) => {
|
||||
const resp = await axios.get(`files/analyse-excel?filePath=${encodeURIComponent(file.full)}`);
|
||||
const sheetNames = resp.data;
|
||||
for (const sheetName of sheetNames) {
|
||||
newSources.push(sheetName);
|
||||
newValues[`sourceFile_${sheetName}`] = {
|
||||
fileName: file.full,
|
||||
sheetName,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
args: [
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'singleFile',
|
||||
label: 'Create single file',
|
||||
direction: 'target',
|
||||
},
|
||||
],
|
||||
|
||||
getDefaultOutputName: (sourceName, values) => {
|
||||
if (values.target_excel_singleFile) {
|
||||
return sourceName;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
getOutputParams: (sourceName, values) => {
|
||||
if (values.target_excel_singleFile) {
|
||||
return {
|
||||
sheetName: values[`targetName_${sourceName}`] || sourceName,
|
||||
fileName: 'data.xlsx',
|
||||
};
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
|
||||
const jsonlFormat = {
|
||||
storageType: 'jsonl',
|
||||
extension: 'jsonl',
|
||||
@@ -58,7 +8,7 @@ const jsonlFormat = {
|
||||
|
||||
/** @returns {import('dbgate-types').FileFormatDefinition[]} */
|
||||
export function buildFileFormats(plugins) {
|
||||
const res = [excelFormat, jsonlFormat];
|
||||
const res = [ jsonlFormat];
|
||||
for (const { content } of plugins) {
|
||||
const { fileFormats } = content;
|
||||
if (fileFormats) res.push(...fileFormats);
|
||||
|
||||
Reference in New Issue
Block a user