-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toggle graphs in the training board olena #825
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -24,14 +24,26 @@ | |||||||||||||
</template> | ||||||||||||||
|
||||||||||||||
<script setup lang="ts"> | ||||||||||||||
import { ref } from "vue"; | ||||||||||||||
import { ref, onMounted } from "vue"; | ||||||||||||||
|
||||||||||||||
import UpArrow from "@/assets/svg/UpArrow.vue"; | ||||||||||||||
import DownArrow from "@/assets/svg/DownArrow.vue"; | ||||||||||||||
|
||||||||||||||
import IconCardHeader from "./IconCardHeader.vue"; | ||||||||||||||
|
||||||||||||||
const props = defineProps({ | ||||||||||||||
initiallyOpen: { | ||||||||||||||
type: String, | ||||||||||||||
default: "true", //open by default | ||||||||||||||
}, | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
const opened = ref(true); | ||||||||||||||
|
||||||||||||||
onMounted(() => { | ||||||||||||||
opened.value = JSON.parse(props.initiallyOpen); | ||||||||||||||
}); | ||||||||||||||
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
function toggle() { | ||||||||||||||
opened.value = !opened.value; | ||||||||||||||
} | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -51,8 +51,9 @@ | |||||
</IconCardSmall> | ||||||
</div> | ||||||
|
||||||
<!-- Training and validation loss charts --> | ||||||
<div | ||||||
<DropdownCard :initiallyOpen="currentOpen" @click="toggleAdvancedInfo"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider renaming
Suggested change
|
||||||
<template #title> Advanced information </template> | ||||||
<div | ||||||
class="flex flex-col md:grid gap-4 md:gap-8" | ||||||
:class="hasValidationData ? 'md:grid-cols-2' : ''" | ||||||
> | ||||||
|
@@ -146,35 +147,14 @@ | |||||
/> | ||||||
</IconCard> | ||||||
</div> | ||||||
|
||||||
<IconCard> | ||||||
<template #title> Training Logs </template> | ||||||
<template #icon> <Contact /> </template> | ||||||
|
||||||
<!-- Scrollable training logs --> | ||||||
<div id="mapHeader" class="max-h-80 overflow-y-auto"> | ||||||
<ul class="grid grid-cols-1"> | ||||||
<li | ||||||
v-for="(message, index) in props.messages" | ||||||
:key="index" | ||||||
class="border-slate-400" | ||||||
> | ||||||
<span | ||||||
style="white-space: pre-line" | ||||||
class="text-sm text-slate-500 dark:text-slate-400" | ||||||
> | ||||||
{{ message }} | ||||||
</span> | ||||||
</li> | ||||||
</ul> | ||||||
</div> | ||||||
</IconCard> | ||||||
</DropdownCard> | ||||||
<!-- Training and validation loss charts --> | ||||||
</div> | ||||||
</template> | ||||||
|
||||||
<script setup lang="ts"> | ||||||
import { List } from "immutable"; | ||||||
import { computed } from "vue"; | ||||||
import { computed, ref } from "vue"; | ||||||
import ApexChart from "vue3-apexcharts"; | ||||||
|
||||||
import type { BatchLogs, EpochLogs, RoundLogs } from "@epfml/discojs"; | ||||||
|
@@ -185,7 +165,10 @@ | |||||
import ModelExchangeIcon from "@/assets/svg/ModelExchangeIcon.vue"; | ||||||
import ModelUpdateIcon from "@/assets/svg/ModelUpdateIcon.vue"; | ||||||
import PeopleIcon from "@/assets/svg/PeopleIcon.vue"; | ||||||
import Contact from "@/assets/svg/Contact.vue"; | ||||||
import DropdownCard from "../containers/DropdownCard.vue"; | ||||||
|
||||||
const currentOpen = ref(localStorage.getItem('initiallyOpen') || 'false'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now that it is a boolean, parsing as to be updated, as close as the loading point you can. it helps with debugging because you know where the value is created. an easy parser is shown below.
Suggested change
one can even make it safer by checking for the full valid range, which would be the nicest (as it fails on unexpected values, which is always nice for finding logical bugs) function loadCurrentOpen(): boolean {
const raw = localStorage.getItem("initiallyOpen");
switch (raw) {
case "true":
return true;
case "false":
case null:
return false;
default:
throw new Error(`unexpected loadCurrent stored value: ${raw}`);
}
}
const currentOpen = ref(loadCurrentOpen()); |
||||||
|
||||||
const props = defineProps<{ | ||||||
rounds: List<RoundLogs>; | ||||||
|
@@ -359,4 +342,11 @@ | |||||
function percent(n: number): string { | ||||||
return (n * 100).toFixed(2); | ||||||
} | ||||||
// Function to toggle the advanced information | ||||||
const toggleAdvancedInfo = () => { | ||||||
const newOpen = currentOpen.value === 'false' ? 'true' : 'false'; | ||||||
localStorage.setItem('initiallyOpen', newOpen); | ||||||
currentOpen.value = newOpen; | ||||||
}; | ||||||
|
||||||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find it clearer to use type-only props declarations. also, you can have a preciser type (only two value are possible here, true or false) and avoid
JSON.parse
at all.