mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:57:08 +00:00
Refactor Smartsource header reading configuration.
- Use a fixed width name parser rather than regular expressions - Move the Smartsource header files configuration to a different part of the configuration object.
This commit is contained in:
@@ -0,0 +1,135 @@
|
|||||||
|
<template>
|
||||||
|
<dougal-project-settings-file-matching-parameters
|
||||||
|
title="Smartsource header data"
|
||||||
|
subtitle="Smartsource header data files location and parameters."
|
||||||
|
v-bind.sync="bind"
|
||||||
|
:is-valid="isValid"
|
||||||
|
:save="save"
|
||||||
|
>
|
||||||
|
</dougal-project-settings-file-matching-parameters>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.sample {
|
||||||
|
font-family: mono;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { deepCompare, deepMerge } from '@/lib/utils';
|
||||||
|
import setIfDifferent from '@/lib/watcher-mixin';
|
||||||
|
import DougalProjectSettingsFileMatchingParameters from '@/components/project-settings/file-matching-parameters';
|
||||||
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "DougalProjectSettingsSmartsourceHeader",
|
||||||
|
|
||||||
|
components: {
|
||||||
|
DougalProjectSettingsFileMatchingParameters
|
||||||
|
},
|
||||||
|
|
||||||
|
props: [ "value", "title", "subtitle" ],
|
||||||
|
|
||||||
|
mixins: [
|
||||||
|
setIfDifferent({
|
||||||
|
globs: "globs_",
|
||||||
|
paths: "paths_",
|
||||||
|
pattern: "pattern_",
|
||||||
|
lineNameInfo: "lineNameInfo_"
|
||||||
|
})
|
||||||
|
],
|
||||||
|
|
||||||
|
props: {
|
||||||
|
title: String,
|
||||||
|
subtitle: String,
|
||||||
|
rootPath: String,
|
||||||
|
paths: Array,
|
||||||
|
globs: Array,
|
||||||
|
lineNameInfo: Object,
|
||||||
|
pattern: Object
|
||||||
|
},
|
||||||
|
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
tab: null,
|
||||||
|
paths_: [],
|
||||||
|
globs_: [],
|
||||||
|
pattern_: {},
|
||||||
|
lineNameInfo_: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
|
||||||
|
bind () {
|
||||||
|
return {
|
||||||
|
globs: this.globs_,
|
||||||
|
paths: this.paths_,
|
||||||
|
//pattern: this.pattern_,
|
||||||
|
lineNameInfo: this.lineNameInfo_
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
isValid () {
|
||||||
|
return true;
|
||||||
|
return !!(this.paths.length && this.globs.length && (
|
||||||
|
this.pattern?.regex &&
|
||||||
|
["direction", "line", "sequence"].every( i => this.pattern?.captures?.includes(i) )) || (
|
||||||
|
this.lineNameInfo &&
|
||||||
|
this.lineNameInfo?.fields &&
|
||||||
|
[ "line", "sequence", "incr" ].every( i =>
|
||||||
|
["offset", "length"].every( j => j in this.lineNameInfo.fields[i] ))));
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
reset () {
|
||||||
|
|
||||||
|
this.paths_ = [...this.paths];
|
||||||
|
|
||||||
|
this.globs_ = [...this.globs];
|
||||||
|
|
||||||
|
this.lineNameInfo_ = deepMerge({
|
||||||
|
example: "",
|
||||||
|
fields: {
|
||||||
|
sequence: {
|
||||||
|
length: 3,
|
||||||
|
type: "int"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}, structuredClone(this.lineNameInfo ?? {}));
|
||||||
|
|
||||||
|
this.pattern_ = structuredClone(this.pattern ?? {});
|
||||||
|
},
|
||||||
|
|
||||||
|
save () {
|
||||||
|
this.$emit("merge", [ ["raw", "source", "smsrc", "header"], {
|
||||||
|
paths: this.paths_,
|
||||||
|
globs: this.globs_,
|
||||||
|
pattern: this.pattern_,
|
||||||
|
lineNameInfo: this.lineNameInfo_
|
||||||
|
}]);
|
||||||
|
this.$nextTick(this.reset);
|
||||||
|
},
|
||||||
|
|
||||||
|
back () {
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
|
||||||
|
...mapActions(["api"])
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted () {
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
<template>
|
|
||||||
<dougal-project-settings-file-matching-parameters
|
|
||||||
:value="value" title="Smartsource" subtitle="Smartsource data files location and parameters."
|
|
||||||
>
|
|
||||||
</dougal-project-settings-file-matching-parameters>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.sample {
|
|
||||||
font-family: mono;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import DougalProjectSettingsFileMatchingParameters from '@/components/project-settings/file-matching-parameters';
|
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "DougalProjectSettingsSmartsource",
|
|
||||||
|
|
||||||
components: {
|
|
||||||
DougalProjectSettingsFileMatchingParameters
|
|
||||||
},
|
|
||||||
|
|
||||||
props: [ "value", "title", "subtitle" ],
|
|
||||||
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
tab: null,
|
|
||||||
globs: [],
|
|
||||||
paths: [],
|
|
||||||
pattern: {
|
|
||||||
flags: "i",
|
|
||||||
regex: null,
|
|
||||||
captures: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
|
|
||||||
isValid () {
|
|
||||||
return false;
|
|
||||||
// return this.preplots && this.preplots.every( item => item.format != null );
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
value (newValue) {
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
|
|
||||||
reset () {
|
|
||||||
if (!this.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.globs = this.value.globs;
|
|
||||||
this.paths = this.value.paths;
|
|
||||||
this.pattern = this.value.pattern;
|
|
||||||
},
|
|
||||||
|
|
||||||
save () {
|
|
||||||
this.$emit('input', this.data);
|
|
||||||
},
|
|
||||||
|
|
||||||
back () {
|
|
||||||
this.$emit('close');
|
|
||||||
},
|
|
||||||
|
|
||||||
...mapActions(["api"])
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted () {
|
|
||||||
this.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -154,7 +154,7 @@ import DougalProjectSettingsRawP111 from '@/components/project-settings/input-ra
|
|||||||
import DougalProjectSettingsFinalP111 from '@/components/project-settings/input-final-p111';
|
import DougalProjectSettingsFinalP111 from '@/components/project-settings/input-final-p111';
|
||||||
import DougalProjectSettingsRawNTBP from '@/components/project-settings/input-raw-ntbp';
|
import DougalProjectSettingsRawNTBP from '@/components/project-settings/input-raw-ntbp';
|
||||||
import DougalProjectSettingsFinalPending from '@/components/project-settings/input-final-pending';
|
import DougalProjectSettingsFinalPending from '@/components/project-settings/input-final-pending';
|
||||||
import DougalProjectSettingsSmartsource from '@/components/project-settings/input-smartsource';
|
import DougalProjectSettingsSmartsourceHeader from '@/components/project-settings/input-smartsource-header';
|
||||||
import DougalProjectSettingsPlanner from '@/components/project-settings/planner';
|
import DougalProjectSettingsPlanner from '@/components/project-settings/planner';
|
||||||
import DougalProjectSettingsOnlineLineNameFormat from '@/components/project-settings/online-line-name-format';
|
import DougalProjectSettingsOnlineLineNameFormat from '@/components/project-settings/online-line-name-format';
|
||||||
import DougalProjectSettingsASAQC from '@/components/project-settings/asaqc';
|
import DougalProjectSettingsASAQC from '@/components/project-settings/asaqc';
|
||||||
@@ -171,7 +171,7 @@ const components = {
|
|||||||
preplots: DougalProjectSettingsPreplots,
|
preplots: DougalProjectSettingsPreplots,
|
||||||
//raw_data: DougalProjectSettingsNotImplemented,
|
//raw_data: DougalProjectSettingsNotImplemented,
|
||||||
raw_data_p111: DougalProjectSettingsRawP111,
|
raw_data_p111: DougalProjectSettingsRawP111,
|
||||||
raw_data_smartsource: DougalProjectSettingsSmartsource,
|
raw_data_smsrc_header: DougalProjectSettingsSmartsourceHeader,
|
||||||
raw_data_ntbp: DougalProjectSettingsRawNTBP,
|
raw_data_ntbp: DougalProjectSettingsRawNTBP,
|
||||||
//final_data: DougalProjectSettingsNotImplemented,
|
//final_data: DougalProjectSettingsNotImplemented,
|
||||||
final_data_p111: DougalProjectSettingsFinalP111,
|
final_data_p111: DougalProjectSettingsFinalP111,
|
||||||
@@ -265,15 +265,19 @@ export default {
|
|||||||
{
|
{
|
||||||
id: "raw_data_smsrc",
|
id: "raw_data_smsrc",
|
||||||
name: "Smartsource",
|
name: "Smartsource",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
id: "raw_data_smsrc_header",
|
||||||
|
name: "Headers",
|
||||||
values: (obj) => ({
|
values: (obj) => ({
|
||||||
rootPath: obj.rootPath,
|
rootPath: obj.rootPath,
|
||||||
globs: [...obj.raw.smsrc.globs],
|
globs: obj?.raw?.source?.smsrc?.header?.globs,
|
||||||
paths: [...obj.raw.smsrc.paths],
|
paths: obj?.raw?.source?.smsrc?.header?.paths,
|
||||||
pattern: structuredClone(obj.raw.smsrc.pattern)
|
pattern: obj?.raw?.source?.smsrc?.header?.pattern,
|
||||||
}),
|
lineNameInfo: obj?.raw?.source?.smsrc?.header?.lineNameInfo
|
||||||
save: async (data, cfg) => {
|
})
|
||||||
await this.patch({raw: {smsrc: {...data}}});
|
},
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "raw_data_ntbp",
|
id: "raw_data_ntbp",
|
||||||
|
|||||||
Reference in New Issue
Block a user