Skip to content

Commit

Permalink
lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Jul 1, 2024
1 parent 1fdd74e commit 1872477
Show file tree
Hide file tree
Showing 24 changed files with 177 additions and 175 deletions.
2 changes: 1 addition & 1 deletion app/static/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
coveragePathIgnorePatterns: ["./tests/mocks.ts"],
transformIgnorePatterns: ["node_modules/(?!(d3-format))"],
moduleNameMapper: {
//"^color$": "<rootDir>/tests/color-shim.js",
// "^color$": "<rootDir>/tests/color-shim.js",
"raw-loader!.*/help/(.*)$": "<rootDir>/src/app/help/$1"
}
};
6 changes: 3 additions & 3 deletions app/static/src/app/components/code/CodeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
</div>
<error-info :error="error"></error-info>
<div class="mt-3">
<graph-configs-collapsible></graph-configs-collapsible>
<graph-configs-collapsible></graph-configs-collapsible>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent, computed, ref } from "vue";
import { defineComponent, computed } from "vue";
import { useStore } from "vuex";
import VueFeather from "vue-feather";
// eslint-disable-next-line import/no-webpack-loader-syntax
Expand All @@ -36,7 +36,7 @@ import GraphConfigsCollapsible from "../graphConfig/GraphConfigsCollapsible.vue"
export default defineComponent({
name: "CodeTab",
components: {
GraphConfigsCollapsible,
GraphConfigsCollapsible,
GenericHelp,
ErrorInfo,
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/components/graphConfig/GraphConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<span class="variable-name">{{ variable }}</span>
<span class="variable-delete">
<button @click="removeVariable(graphIndex, variable)" v-tooltip="'Remove variable'">×</button>
<button @click="removeVariable(graphIndex, variable)" v-tooltip="'Remove variable'">×</button>
</span>
</span>
</template>
Expand Down
67 changes: 32 additions & 35 deletions app/static/src/app/components/graphConfig/GraphConfigs.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>

<div id="graph-configs-instruction" class="ms-2">
Drag variables to 'Hidden variables' to remove them from your graph, or click 'Add Graph' to create a
new graph to move them to.
Drag variables to 'Hidden variables' to remove them from your graph, or click 'Add Graph' to create a new graph
to move them to.
</div>
<graph-config
v-for="(_, index) in graphConfigs"
Expand All @@ -12,44 +11,42 @@
@setDragging="setDraggingVariable"
></graph-config>
<button class="btn btn-primary mt-2 ms-2" id="add-graph-btn" @click="addGraph">
<vue-feather size="20" class="inline-icon" type="plus"></vue-feather>
Add Graph
<vue-feather size="20" class="inline-icon" type="plus"></vue-feather>
Add Graph
</button>
<hidden-variables
@setDragging="setDraggingVariable"
:dragging="draggingVariable"
></hidden-variables>

<hidden-variables @setDragging="setDraggingVariable" :dragging="draggingVariable"></hidden-variables>
</template>

<script lang="ts">
import {computed, defineComponent, ref} from "vue";
import {useStore} from "vuex";
import VueFeather from "vue-feather";;
import { computed, defineComponent, ref } from "vue";
import { useStore } from "vuex";
import VueFeather from "vue-feather";
import HiddenVariables from "./HiddenVariables.vue";
import GraphConfig from "./GraphConfig.vue";
import {GraphsAction} from "../../store/graphs/actions";
import { GraphsAction } from "../../store/graphs/actions";
export default defineComponent({
components: {
VueFeather,
GraphConfig,
HiddenVariables
},
setup() {
const store = useStore();
const draggingVariable = ref(false); // indicates whether a child component is dragging a variable
const setDraggingVariable = (value: boolean) => (draggingVariable.value = value);
const graphConfigs = computed(() => store.state.graphs.config);
const addGraph = () => {
store.dispatch(`graphs/${GraphsAction.NewGraph}`);
};
return {
draggingVariable,
setDraggingVariable,
graphConfigs,
addGraph
};
}
components: {
VueFeather,
GraphConfig,
HiddenVariables
},
setup() {
const store = useStore();
const draggingVariable = ref(false); // indicates whether a child component is dragging a variable
const setDraggingVariable = (value: boolean) => {
draggingVariable.value = value;
};
const graphConfigs = computed(() => store.state.graphs.config);
const addGraph = () => {
store.dispatch(`graphs/${GraphsAction.NewGraph}`);
};
return {
draggingVariable,
setDraggingVariable,
graphConfigs,
addGraph
};
}
});
</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<template>
<vertical-collapse v-if="showGraphs" title="Graphs" collapse-id="graphs">
<graph-configs></graph-configs>
</vertical-collapse>
<vertical-collapse v-if="showGraphs" title="Graphs" collapse-id="graphs">
<graph-configs></graph-configs>
</vertical-collapse>
</template>

<script lang="ts">
import GraphConfigs from "@/app/components/graphConfig/GraphConfigs.vue";
import VerticalCollapse from "@/app/components/VerticalCollapse.vue";
import {computed, defineComponent} from "vue";
import {useStore} from "vuex";
import { computed, defineComponent } from "vue";
import { useStore } from "vuex";
export default defineComponent({
name: "GraphConfigsCollapsible",
components: {
GraphConfigs,
VerticalCollapse
},
setup(){
const store = useStore();
const allVariables = computed<string[]>(() => store.state.model.odinModelResponse?.metadata?.variables || []);
const showGraphs = computed(() => allVariables.value.length && !store.state.model.compileRequired);
return {
showGraphs
};
}
name: "GraphConfigsCollapsible",
components: {
GraphConfigs,
VerticalCollapse
},
setup() {
const store = useStore();
const allVariables = computed<string[]>(() => store.state.model.odinModelResponse?.metadata?.variables || []);
const showGraphs = computed(() => allVariables.value.length && !store.state.model.compileRequired);
return {
showGraphs
};
}
});
</script>
</script>
8 changes: 3 additions & 5 deletions app/static/src/app/components/graphConfig/HiddenVariables.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
<script lang="ts">
import { computed, defineComponent } from "vue";
import { useStore } from "vuex";
import VueFeather from "vue-feather";
import { GraphsGetter } from "../../store/graphs/getters";
import SelectVariables from "../mixins/selectVariables";
import {fadeColor} from "./utils";
import { fadeColor } from "./utils";
export default defineComponent({
name: "HiddenVariables",
components: { VueFeather },
props: {
dragging: {
type: Boolean,
Expand All @@ -39,13 +37,13 @@ export default defineComponent({
},
setup(props, { emit }) {
const store = useStore();
const { startDrag, endDrag, onDrop } = SelectVariables(store, emit, true);
const { startDrag, endDrag, onDrop } = SelectVariables(store, emit, true);
const hiddenVariables = computed<string[]>(() => store.getters[`graphs/${GraphsGetter.hiddenVariables}`]);
const palette = computed(() => store.state.model.paletteModel!);
const getStyle = (variable: string) => {
const bgcolor = palette.value ? palette.value[variable] : "#eee";
return { "background-color": fadeColor(bgcolor)};
return { "background-color": fadeColor(bgcolor) };
};
return {
Expand Down
4 changes: 2 additions & 2 deletions app/static/src/app/components/graphConfig/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Color from "color";

export const fadeColor = (color: string) => {
export const fadeColor = (color: string): string => {
return Color(color).desaturate(0.6).fade(0.4).rgb().string();
};
};
44 changes: 22 additions & 22 deletions app/static/src/app/components/mixins/selectVariables.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import {AppState} from "../../store/appState/state";
import {Store} from "vuex";
import {GraphsAction} from "../../store/graphs/actions";
import {computed} from "vue";
import { Store } from "vuex";
import { computed } from "vue";
import { AppState } from "../../store/appState/state";
import { GraphsAction } from "../../store/graphs/actions";

export interface SelectVariablesMixin {
startDrag: (evt: DragEvent, variable: string) => void;
endDrag: () => void,
onDrop: (evt: DragEvent) => void,
removeVariable: (srcGraphIdx: number, variable: string) => void
endDrag: () => void;
onDrop: (evt: DragEvent) => void;
removeVariable: (srcGraphIdx: number, variable: string) => void;
}

export default (
store: Store<AppState>,
emit: (event: string, ...args: any[]) => void,
emit: (event: string, ...args: unknown[]) => void,
hiddenVariables: boolean,
graphIndex?: number): SelectVariablesMixin => {

graphIndex?: number
): SelectVariablesMixin => {
const thisSrcGraph = hiddenVariables ? "hidden" : graphIndex!.toString();

const startDrag = (evt: DragEvent, variable: string) => {
const { dataTransfer } = evt;
dataTransfer!!.dropEffect = "move";
dataTransfer!!.effectAllowed = "move";
dataTransfer!!.setData("variable", variable);
dataTransfer!!.setData("srcGraph", thisSrcGraph);
dataTransfer!.dropEffect = "move";
dataTransfer!.effectAllowed = "move";
dataTransfer!.setData("variable", variable);
dataTransfer!.setData("srcGraph", thisSrcGraph);

emit("setDragging", true);
};
Expand All @@ -32,9 +32,9 @@ export default (
emit("setDragging", false);
};

const updateSelectedVariables = (graphIndex: number, newVariables: string[]) => {
const updateSelectedVariables = (graphIdx: number, newVariables: string[]) => {
store.dispatch(`graphs/${GraphsAction.UpdateSelectedVariables}`, {
graphIndex,
graphIdx,
selectedVariables: newVariables
});
};
Expand All @@ -47,18 +47,18 @@ export default (
updateSelectedVariables(srcGraphIdx, srcVariables);
};

const selectedVariables = computed<string[]>(
() => hiddenVariables ? [] : store.state.graphs.config[graphIndex!].selectedVariables
const selectedVariables = computed<string[]>(() =>
hiddenVariables ? [] : store.state.graphs.config[graphIndex!].selectedVariables
);

const onDrop = (evt: DragEvent) => {
const { dataTransfer } = evt;
const variable = dataTransfer!!.getData("variable");
const srcGraph = dataTransfer!!.getData("srcGraph");
const variable = dataTransfer!.getData("variable");
const srcGraph = dataTransfer!.getData("srcGraph");
if (srcGraph !== thisSrcGraph) {
// remove from source graph
if (srcGraph !== "hidden") {
removeVariable(parseInt(srcGraph), variable);
removeVariable(parseInt(srcGraph, 10), variable);
}
// add to this graph if necessary
if (!hiddenVariables && !selectedVariables.value.includes(variable)) {
Expand All @@ -74,4 +74,4 @@ export default (
endDrag,
onDrop
};
}
};
6 changes: 2 additions & 4 deletions app/static/src/app/components/options/OptionsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<script lang="ts">
import { computed, defineComponent } from "vue";
import { useStore } from "vuex";
import GraphConfigsCollapsible from "@/app/components/graphConfig/GraphConfigsCollapsible.vue";
import VerticalCollapse from "../VerticalCollapse.vue";
import ParameterValues from "./ParameterValues.vue";
import RunOptions from "./RunOptions.vue";
Expand All @@ -47,14 +48,11 @@ import { AppType, VisualisationTab } from "../../store/appState/state";
import GraphSettings from "./GraphSettings.vue";
import ParameterSets from "./ParameterSets.vue";
import AdvancedSettings from "./AdvancedSettings.vue";
import GraphConfigs from "@/app/components/graphConfig/GraphConfigs.vue";
import GraphConfigsCollapsible from "@/app/components/graphConfig/GraphConfigsCollapsible.vue";
export default defineComponent({
name: "OptionsTab",
components: {
GraphConfigsCollapsible,
GraphConfigs,
GraphConfigsCollapsible,
ParameterSets,
LinkData,
OptimisationOptions,
Expand Down
8 changes: 4 additions & 4 deletions app/static/src/app/components/run/RunPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export default defineComponent({
name: "RunPlot",
props: {
fadePlot: Boolean,
graphIndex: {
type: Number,
default: 0
}
graphIndex: {
type: Number,
default: 0
}
},
components: {
WodinPlot
Expand Down
8 changes: 4 additions & 4 deletions app/static/src/app/components/run/RunStochasticPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default defineComponent({
name: "RunStochasticPlot",
props: {
fadePlot: Boolean,
graphIndex: {
type: Number,
default: 0
}
graphIndex: {
type: Number,
default: 0
}
},
components: {
WodinPlot
Expand Down
18 changes: 11 additions & 7 deletions app/static/src/app/components/run/RunTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
</div>
<action-required-message :message="updateMsg"></action-required-message>
<template v-for="(_, index) in graphConfigs" :key="index">
<run-stochastic-plot v-if="isStochastic" :fade-plot="!!updateMsg" :graph-index="index"></run-stochastic-plot>
<run-plot v-else :fade-plot="!!updateMsg" :model-fit="false" :graph-index="index">
<div v-if="sumOfSquares">
<span>Sum of squares: {{ sumOfSquares }}</span>
</div>
</run-plot>
<run-stochastic-plot
v-if="isStochastic"
:fade-plot="!!updateMsg"
:graph-index="index"
></run-stochastic-plot>
<run-plot v-else :fade-plot="!!updateMsg" :model-fit="false" :graph-index="index">
<div v-if="sumOfSquares">
<span>Sum of squares: {{ sumOfSquares }}</span>
</div>
</run-plot>
</template>
<error-info :error="error"></error-info>
<div>
Expand Down Expand Up @@ -136,7 +140,7 @@ export default defineComponent({
downloadUserFileName,
toggleShowDownloadOutput,
download,
graphConfigs
graphConfigs
};
}
});
Expand Down
Loading

0 comments on commit 1872477

Please sign in to comment.