dataset load importer settings& ui
@@ -14,6 +14,10 @@ const initState = {
wordlist: {}
}
+let audioFiles = []
+let additionalTextFiles = []
+let transcriptionFiles = []
+
const dataset = (state = initState, action) => {
switch (action.type) {
@@ -26,41 +30,38 @@ const dataset = (state = initState, action) => {
let dataset_state = action.response.data.data.state;
let name = dataset_state.name;
-
let importer_name = null;
let settings = null;
let ui = null;
-
if (dataset_state.importer !== null) {
- name = dataset_state.importer.name;
+ importer_name = dataset_state.importer.name;
settings = dataset_state.importer.settings;
ui = dataset_state.importer.ui;
}
-
- console.log("DATASET_NEW_SUCCESS name", name);
return { ...initState,
name,
importer_name,
settings,
- ui}
+ ui
+ }
}
case actionTypes.DATASET_LOAD_SUCCESS: {
// loading existing data set might have files and settings
let dataset_state = action.response.data.data.state;
+ console.log("dataset load state", dataset_state)
let {
name,
files,
- settings,
- ui
+ importer
} = dataset_state;
// action.data is an array of filenames. parse this, split into separate lists
- var audioFiles = files.filter(file => getFileExtension(file) === 'wav').sort();
- var additionalTextFiles = files.filter(file => getFileExtension(file) === 'txt').sort();
- var transcriptionFiles = files.filter(file => {
+ audioFiles = files.filter(file => getFileExtension(file) === 'wav').sort();
+ additionalTextFiles = files.filter(file => getFileExtension(file) === 'txt').sort();
+ transcriptionFiles = files.filter(file => {
return (getFileExtension(file) !== 'wav' && getFileExtension(file) !== 'txt')
}).sort();
- // remove duplicates (should do this on the server though!)
+ // remove duplicates
audioFiles = [...(new Set(audioFiles))];
transcriptionFiles = [...(new Set(transcriptionFiles))];
return {
@@ -70,10 +71,11 @@ const dataset = (state = initState, action) => {
audioFiles,
transcriptionFiles,
additionalTextFiles,
- settings,
- ui,
- wordlist: "",
- };
+ importer_name: importer.name,
+ settings: importer.settings,
+ ui: importer.ui,
+ wordlist: {},
+ }
}
case actionTypes.DATASET_LIST_SUCCESS:
@@ -90,9 +92,9 @@ const dataset = (state = initState, action) => {
var { data, status } = action.response.data
if (status === 200) {
// action.data is an array of filenames. parse this, split into separate lists
- var audioFiles = data.files.filter(file => getFileExtension(file) === 'wav').sort()
- var transcriptionFiles = data.files.filter(file => getFileExtension(file) === 'eaf').sort()
- var additionalTextFiles = data.files.filter(file => getFileExtension(file) === 'txt').sort()
+ audioFiles = data.files.filter(file => getFileExtension(file) === 'wav').sort()
+ transcriptionFiles = data.files.filter(file => getFileExtension(file) === 'eaf').sort()
+ additionalTextFiles = data.files.filter(file => getFileExtension(file) === 'txt').sort()
// remove duplicates
audioFiles = [...(new Set(audioFiles))];
return {
