Skip to content
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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

iamsherlocked1891
Copy link
Collaborator

Client-side

Additions & Modifications:

  1. Enhanced DropdownCard Component:

    • The DropdownCard component was refactored to allow dynamic control over its state (collapsed or expanded) based on a passed parameter.
    • By default, the component remains open.
  2. Refinements in the Training Information Section:

    • Graphs within the Training Information section were encapsulated within the newly refactored DropdownCard component. This provides users the option to expand or collapse the graphical data, improving the clarity and organization of training details.
  3. Removed Training Logs from Training Information:

    • The Training Logs information was removed from the Training Information section, streamlining the display and focusing user attention on more important information.

@JulienVig JulienVig removed the request for review from tharvik November 5, 2024 13:43
Copy link
Collaborator

@tharvik tharvik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the work! a few comments on how to improve it, please also fix the tests/lint found by the CI

Comment on lines +34 to +39
const props = defineProps({
initiallyOpen: {
type: String,
default: "true", //open by default
},
});
Copy link
Collaborator

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.

Suggested change
const props = defineProps({
initiallyOpen: {
type: String,
default: "true", //open by default
},
});
const props = withDefaults(
defineProps<{
initiallyOpen?: boolean;
}>(),
{ initiallyOpen: true },
);

Comment on lines +43 to +45
onMounted(() => {
opened.value = JSON.parse(props.initiallyOpen);
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onMounted is quite special, it doesn't get triggered when data change for example. better to watch for prop to change instead, so that if someone change the prop from the outside, it will behave as expected.

Suggested change
onMounted(() => {
opened.value = JSON.parse(props.initiallyOpen);
});
watch(props, ({ initiallyOpen }) => {
opened.value = initiallyOpen;
});

@@ -186,6 +166,9 @@ 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');
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.
also, the "or" op is quite unsafe (as many values can be falsy), better to use a nullish coaslescing which only check for null and undefined.

Suggested change
const currentOpen = ref(localStorage.getItem('initiallyOpen') || 'false');
const currentOpen = ref(localStorage.getItem("initiallyOpen") === "true" ? true : false);

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());

@@ -51,8 +51,9 @@
</IconCardSmall>
</div>

<!-- Training and validation loss charts -->
<div
<DropdownCard :initiallyOpen="currentOpen" @click="toggleAdvancedInfo">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider renaming currentOpen to initiallyOpen, then you can use the short version of the attribute, which is a bit nicer

Suggested change
<DropdownCard :initiallyOpen="currentOpen" @click="toggleAdvancedInfo">
<DropdownCard :initiallyOpen @click="toggleAdvancedInfo">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants