mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 11:17:08 +00:00
Add support for personalising QC graph settings.
Preferences are read from the store and passed to graph components via the `settings` prop. Component may changed their own settings by emitting the `update:settings` signal.
This commit is contained in:
@@ -92,9 +92,14 @@
|
|||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
|
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row v-for="(item, idx) in items" :key="idx">
|
<v-row v-for="(item, idx) in visibleItems" :key="idx">
|
||||||
<v-col>
|
<v-col>
|
||||||
<component :is="item.component" :data="attributesFor(item)"></component>
|
<component
|
||||||
|
:is="item.component"
|
||||||
|
:data="attributesFor(item)"
|
||||||
|
:settings="preferencesFor(item.component)"
|
||||||
|
@update:settings="configure">
|
||||||
|
</component>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
@@ -124,6 +129,7 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { mapActions, mapGetters } from 'vuex';
|
import { mapActions, mapGetters } from 'vuex';
|
||||||
|
import { preferencesλ } from '@/lib/utils.js';
|
||||||
import DougalGraphGunsPressure from '@/components/graph-guns-pressure.vue';
|
import DougalGraphGunsPressure from '@/components/graph-guns-pressure.vue';
|
||||||
import DougalGraphGunsTiming from '@/components/graph-guns-timing.vue';
|
import DougalGraphGunsTiming from '@/components/graph-guns-timing.vue';
|
||||||
import DougalGraphGunsDepth from '@/components/graph-guns-depth.vue';
|
import DougalGraphGunsDepth from '@/components/graph-guns-depth.vue';
|
||||||
@@ -142,32 +148,41 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
component: "DougalGraphGunsPressure",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: "DougalGraphGunsTiming",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: "DougalGraphGunsDepth",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: "DougalGraphGunsHeatmap",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
component: "GraphArraysIJScatter",
|
component: "GraphArraysIJScatter",
|
||||||
attributes: {
|
attributes: {
|
||||||
}
|
const items = [
|
||||||
|
{
|
||||||
|
component: "DougalGraphGunsPressure",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: "DougalGraphGunsTiming",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: "DougalGraphGunsDepth",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: "DougalGraphGunsHeatmap",
|
||||||
|
},
|
||||||
|
{
|
||||||
}
|
}
|
||||||
],
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
return {
|
||||||
|
items,
|
||||||
data: null,
|
data: null,
|
||||||
sequences: [],
|
sequences: [],
|
||||||
jumpToSequence: null,
|
jumpToSequence: null,
|
||||||
|
aspects: items.map(i => i.component)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
preferences () {
|
||||||
|
this.configure(preferencesλ(this.preferences)(this.$options.name, {aspects: this.aspects}))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
||||||
getRows() {
|
getRows() {
|
||||||
@@ -178,6 +193,10 @@ export default {
|
|||||||
return Array(this.cols).fill().map( (el, idx) => idx );
|
return Array(this.cols).fill().map( (el, idx) => idx );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
visibleItems () {
|
||||||
|
return this.items.filter( i => this.aspects.includes(i.component) );
|
||||||
|
},
|
||||||
|
|
||||||
firstSequence () {
|
firstSequence () {
|
||||||
return this.sequences[this.sequences.length-1]?.sequence;
|
return this.sequences[this.sequences.length-1]?.sequence;
|
||||||
},
|
},
|
||||||
@@ -206,11 +225,20 @@ export default {
|
|||||||
return this.sequences[0]?.sequence;
|
return this.sequences[0]?.sequence;
|
||||||
},
|
},
|
||||||
|
|
||||||
...mapGetters(['user', 'writeaccess', 'loading', 'serverEvent'])
|
...mapGetters(['user', 'preferences', 'writeaccess', 'loading', 'serverEvent'])
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
|
configure (data) {
|
||||||
|
if ("aspects" in data) {
|
||||||
|
this.aspects = [...data.aspects];
|
||||||
|
}
|
||||||
|
for (const key in data) {
|
||||||
|
this.saveUserPreference([`${this.$options.name}.${key}`, data[key]]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
attributesFor (item) {
|
attributesFor (item) {
|
||||||
return this.data
|
return this.data
|
||||||
? Object.assign({
|
? Object.assign({
|
||||||
@@ -220,11 +248,15 @@ export default {
|
|||||||
: null;
|
: null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
preferencesFor (key, defaults) {
|
||||||
|
return preferencesλ(this.preferences)(`${this.$options.name}.${key}`, defaults);
|
||||||
|
},
|
||||||
|
|
||||||
gotoSequence(seq) {
|
gotoSequence(seq) {
|
||||||
this.$route.params.sequence = seq;
|
this.$route.params.sequence = seq;
|
||||||
},
|
},
|
||||||
|
|
||||||
...mapActions(["api", "showSnack"])
|
...mapActions(["api", "showSnack", "saveUserPreference"])
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeRouteLeave (to, from, next) {
|
beforeRouteLeave (to, from, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user