-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9df2c3
commit 2f0ec80
Showing
18 changed files
with
289 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/static/src/app/components/graphConfig/GraphConfigsCollapsible.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<template> | ||
<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"; | ||
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 | ||
}; | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as Color from "color"; | ||
|
||
export const fadeColor = (color: string) => { | ||
return Color(color).desaturate(0.6).fade(0.4).rgb().string(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const Color = require("color/index.js"); | ||
const color2 = Color.default; | ||
//module.exports = color2; | ||
console.log("Color from shim") | ||
console.log(typeof Color) | ||
module.exports = Color; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/static/tests/unit/components/graphConfig/graphConfigsCollapsible.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {ModelState} from "../../../../src/app/store/model/state"; | ||
import Vuex from "vuex"; | ||
import {BasicState} from "../../../../src/app/store/basic/state"; | ||
import {mockBasicState, mockCodeState, mockModelState} from "../../../mocks"; | ||
import {shallowMount} from "@vue/test-utils"; | ||
import GraphConfigsCollapsible from "../../../../src/app/components/graphConfig/GraphConfigsCollapsible.vue"; | ||
import VerticalCollapse from "../../../../src/app/components/VerticalCollapse.vue"; | ||
|
||
describe("GraphConfigsCollapsible", () => { | ||
const defaultModelState = { | ||
compileRequired: false, | ||
odinModelResponse: { | ||
metadata: { | ||
variables: ["S", "I", "R"] | ||
}, | ||
valid: true | ||
} as any | ||
}; | ||
|
||
const getWrapper = (modelState: Partial<ModelState> = {}) => { | ||
const store = new Vuex.Store<BasicState>({ | ||
state: mockBasicState({ | ||
configured: true | ||
}), | ||
modules: { | ||
model: { | ||
namespaced: true, | ||
state: mockModelState({...defaultModelState, ...modelState}) | ||
} | ||
} | ||
}); | ||
|
||
return shallowMount(GraphConfigsCollapsible, { | ||
global: { | ||
plugins: [store] | ||
} | ||
}); | ||
}; | ||
|
||
it("renders collapsible when graph configs should be shown", () => { | ||
const wrapper = getWrapper(); | ||
expect(wrapper.findComponent(VerticalCollapse).props("title")).toBe("Graphs"); | ||
}); | ||
|
||
it("does not render collapsible when no variables in model", () => { | ||
const wrapper = getWrapper({ | ||
odinModelResponse: { | ||
metadata: { | ||
variables: [] | ||
}, | ||
valid: true | ||
} as any | ||
}); | ||
expect(wrapper.findComponent(VerticalCollapse).exists()).toBe(false); | ||
}); | ||
|
||
it("does not render collapsible when compile required", () => { | ||
const wrapper = getWrapper({ | ||
compileRequired: true | ||
}); | ||
expect(wrapper.findComponent(VerticalCollapse).exists()).toBe(false); | ||
}); | ||
|
||
}); |
Oops, something went wrong.