mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 09:06:00 +00:00
removed fileformatbase
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import fileFormatBase from './fileFormatBase';
|
||||
import { FileFormatDefinition } from './types';
|
||||
|
||||
const csvFormat: FileFormatDefinition = {
|
||||
...fileFormatBase,
|
||||
storageType: 'csv',
|
||||
extension: 'csv',
|
||||
name: 'CSV',
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import axios from '../utility/axios';
|
||||
import fileFormatBase from './fileFormatBase';
|
||||
import { FileFormatDefinition } from './types';
|
||||
|
||||
const excelFormat: FileFormatDefinition = {
|
||||
...fileFormatBase,
|
||||
storageType: 'excel',
|
||||
extension: 'xlsx',
|
||||
name: 'MS Excel',
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
const fileFormatBase = {
|
||||
addFilesToSourceList: async (file, newSources, newValues) => {
|
||||
const sourceName = file.name;
|
||||
newSources.push(sourceName);
|
||||
newValues[`sourceFile_${sourceName}`] = {
|
||||
fileName: file.full,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default fileFormatBase;
|
||||
@@ -1,8 +1,6 @@
|
||||
import fileFormatBase from './fileFormatBase';
|
||||
import { FileFormatDefinition } from './types';
|
||||
|
||||
const jsonlFormat: FileFormatDefinition = {
|
||||
...fileFormatBase,
|
||||
storageType: 'jsonl',
|
||||
extension: 'jsonl',
|
||||
name: 'JSON lines',
|
||||
|
||||
@@ -5,7 +5,7 @@ export interface FileFormatDefinition {
|
||||
readerFunc?: string;
|
||||
writerFunc?: string;
|
||||
args?: any[];
|
||||
addFilesToSourceList: (
|
||||
addFilesToSourceList?: (
|
||||
file: {
|
||||
full: string;
|
||||
},
|
||||
|
||||
@@ -97,14 +97,22 @@ function getFileFilters(storageType) {
|
||||
return res;
|
||||
}
|
||||
|
||||
async function addFilesToSourceListDefault(file, newSources, newValues) {
|
||||
const sourceName = file.name;
|
||||
newSources.push(sourceName);
|
||||
newValues[`sourceFile_${sourceName}`] = {
|
||||
fileName: file.full,
|
||||
};
|
||||
}
|
||||
|
||||
async function addFilesToSourceList(files, values, setValues, preferedStorageType, setPreviewSource) {
|
||||
const newSources = [];
|
||||
const newValues = {};
|
||||
const storage = preferedStorageType || values.sourceStorageType;
|
||||
for (const file of getAsArray(files)) {
|
||||
const format = findFileFormat(storage);
|
||||
if (format && format.addFilesToSourceList) {
|
||||
await format.addFilesToSourceList(file, newSources, newValues);
|
||||
if (format) {
|
||||
await (format.addFilesToSourceList || addFilesToSourceListDefault)(file, newSources, newValues);
|
||||
}
|
||||
}
|
||||
newValues['sourceList'] = [...(values.sourceList || []).filter((x) => !newSources.includes(x)), ...newSources];
|
||||
|
||||
6
packages/web/src/utility/fileformats.js
Normal file
6
packages/web/src/utility/fileformats.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { usePlugins } from '../plugins/PluginsProvider';
|
||||
|
||||
export function useFileFormats() {
|
||||
const plugins = usePlugins();
|
||||
return [];
|
||||
}
|
||||
Reference in New Issue
Block a user