file format refactor

This commit is contained in:
Jan Prochazka
2020-11-19 08:36:56 +01:00
parent 64362cdf13
commit 6324fd1de4
7 changed files with 82 additions and 34 deletions

View File

@@ -1,6 +1,27 @@
export default {
import { DatabaseInfo } from 'dbgate-types';
import axios from '../utility/axios';
import fileFormatBase from './fileFormatBase';
import { FileFormatDefinition } from './types';
const excelFormat: FileFormatDefinition = {
...fileFormatBase,
storageType: 'excel',
extension: 'xlsx',
name: 'MS Excel files',
name: 'MS Excel',
readerFunc: 'excelSheetReader',
addFilesToSourceList: async (file, newSources, newValues) => {
const resp = await axios.get(`files/analyse-excel?filePath=${encodeURIComponent(file.full)}`);
const structure: DatabaseInfo = resp.data;
for (const table of structure.tables) {
const sourceName = table.pureName;
newSources.push(sourceName);
newValues[`sourceFile_${sourceName}`] = {
fileName: file.full,
sheetName: table.pureName,
};
}
},
};
export default excelFormat;