Skip to content

Group all toggles in one component #4161

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

Open
wants to merge 23 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions packages/playground/src/components/caprover_worker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@
required
:ipv4="$props.modelValue.ipv4"
/>
<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch v-model="$props.modelValue.rentedByMe" color="primary" inset label="Rented By Me" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch v-model="$props.modelValue.dedicated" color="primary" inset label="Rentable" hide-details />
</input-tooltip>
<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch v-model="$props.modelValue.certified" color="primary" inset label="Certified" hide-details />
</input-tooltip>

<TfSelectionDetails
v-model="$props.modelValue.selectionDetails"
v-model:rented-by-me="$props.modelValue.rentedByMe"
v-model:dedicated="$props.modelValue.dedicated"
v-model:certified="$props.modelValue.certified"
:selected-machines="selectedMachines"
:nodes-lock="nodesLock"
:filters="{
Expand Down Expand Up @@ -70,7 +64,6 @@ import { computed, type PropType } from "vue";

import { useGrid } from "@/stores";
import type { SelectedMachine } from "@/types/nodeSelector";
import { manual } from "@/utils/manual";

import Networks from "../components/networks.vue";
import type { CaproverWorker } from "../types";
Expand Down Expand Up @@ -142,7 +135,7 @@ export default {
}, [] as SelectedMachine[]);
});

return { rootFilesystemSize, manual, selectedMachines, rentedBy };
return { rootFilesystemSize, selectedMachines, rentedBy };
},
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<template>
<div class="flex flex-col gap-4">
<input-tooltip
v-if="showGPU"
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just remove this v-if condition and remove showGPU prop since it will always be true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same, it's just check for only 2 solutions not the rest

Copy link
Contributor

Choose a reason for hiding this comment

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

please refer to replies above

inline
tooltip="
Selecting a Node with GPU.
When selecting a node with GPU resources, please make sure that you have a rented node. To rent a node and gain access to GPU capabilities, you can use our dashboard.
"
>
<v-switch
color="primary"
inset
label="GPU"
:model-value="hasGPUModel"
hide-details
@update:model-value="onUpdateHasGPU"
/>
</input-tooltip>

<v-switch
color="primary"
inset
label="Rented By Me"
:model-value="rentedByMeModel"
hide-details
@update:model-value="onUpdateRentedByMe"
/>

<input-tooltip
inline
tooltip="Click to know more about dedicated machines."
:href="manual?.dedicated_machines"
>
<v-switch
color="primary"
inset
label="Rentable"
:model-value="dedicatedModel"
hide-details
@update:model-value="onUpdateDedicated"
/>
</input-tooltip>

<input-tooltip
inline
tooltip="Renting capacity on certified nodes is charged 25% extra."
>
<v-switch
color="primary"
inset
label="Certified"
:model-value="certifiedModel"
hide-details
@update:model-value="onUpdateCertified"
/>
</input-tooltip>
</div>
</template>

<script setup lang="ts">
import { computed } from "vue";

import { manual } from "@/utils/manual";
import { solutionType } from "@/types";

import { useRoute } from "vue-router";

const props = defineProps({
rentedByMe: Boolean,
dedicated: Boolean,
certified: Boolean,
hasGPU: Boolean,
});
const emit = defineEmits(["update:rentedByMe", "update:dedicated", "update:certified", "update:hasGPU"]);

const route = useRoute();

const rentedByMeModel = computed({
get: () => !!props.rentedByMe,
set: val => emit("update:rentedByMe", val),
});

const dedicatedModel = computed({
get: () => !!props.dedicated,
set: val => emit("update:dedicated", val),
});

const certifiedModel = computed({
get: () => !!props.certified,
set: val => emit("update:certified", val),
});

const hasGPUModel = computed({
get: () => !!props.hasGPU,
set: val => emit("update:hasGPU", val),
});

const showGPU = computed(() => route.meta.title == solutionType.fullvm || route.meta.title == solutionType.openwebui);

function onUpdateRentedByMe(val: boolean | null) {
rentedByMeModel.value = !!val;
}

function onUpdateDedicated(val: boolean | null) {
dedicatedModel.value = !!val;
}

function onUpdateCertified(val: boolean | null) {
certifiedModel.value = !!val;
}

function onUpdateHasGPU(val: boolean | null) {
hasGPUModel.value = !!val;
}
Comment on lines +101 to +115
Copy link
Contributor

Choose a reason for hiding this comment

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

i think inline change the values in template would be better, Those founciton are not used anywhere else
example :

:model-value="(val)=> gpuModule = val"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did, but it caused type-check errors, let me try adding types there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0oM4R I tried it, but it caused the same error I mentioned, so I returned to the previous solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

  <v-switch
      color="primary"
      inset
      label="Rented By Me"
      :model-value="rentedByMeModel"
      hide-details
      @update:model-value="(val) => rentedByMeModel = !!val"
    />

this works fine with me without any errors

Copy link
Contributor

Choose a reason for hiding this comment

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

@samaradel please check this comment

</script>

<script lang="ts">
export default {
name: "RentalFilterSwitches",
};
</script>
17 changes: 4 additions & 13 deletions packages/playground/src/components/k8s_worker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,11 @@
:memory="$props.modelValue.memory"
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch v-model="$props.modelValue.rentedByMe" color="primary" inset label="Rented By Me" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch v-model="$props.modelValue.dedicated" color="primary" inset label="Rentable" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch v-model="$props.modelValue.certified" color="primary" inset label="Certified" hide-details />
</input-tooltip>

<TfSelectionDetails
v-model="$props.modelValue.selectionDetails"
v-model:rented-by-me="$props.modelValue.rentedByMe"
v-model:dedicated="$props.modelValue.dedicated"
v-model:certified="$props.modelValue.certified"
:selected-machines="selectedMachines"
:nodes-lock="nodesLock"
:filters-validators="{
Expand Down Expand Up @@ -124,7 +116,6 @@ import { computed, type PropType } from "vue";

import { useGrid } from "@/stores";
import type { SelectedMachine } from "@/types/nodeSelector";
import { manual } from "@/utils/manual";

import Networks from "../components/networks.vue";
import type { K8SWorker } from "../types";
Expand Down Expand Up @@ -193,7 +184,7 @@ export default {
}, [] as SelectedMachine[]);
});

return { calculateRootFileSystem, manual, selectedMachines, rentedBy };
return { calculateRootFileSystem, selectedMachines, rentedBy };
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,62 @@
<h3 class="bg-primary pa-2 text-h6 rounded">
Node Selection
</h3>
<p class="text-h6 mb-4 mt-2 ml-2">

<TfRentalFilterSwitches
:rented-by-me="rentedByMe"
:dedicated="dedicated"
:certified="certified"
:has-g-p-u="hasGPU"
class="my-2"
@update:rented-by-me="$emit('update:rentedByMe', $event)"
@update:dedicated="$emit('update:dedicated', $event)"
@update:certified="$emit('update:certified', $event)"
@update:has-g-p-u="$emit('update:hasGPU', $event)"
/>

<p class="text-h6 mb-4 ml-2">
Choose a way to select Node
</p>

<v-radio-group v-model="wayToSelect" color="primary" inline>
<v-radio-group
v-model="wayToSelect"
color="primary"
inline
>
<InputTooltip
align-center
tooltip="Automatically select your node by filtering with Region, country, or farm name"
>
<v-radio label="Automated" value="automated" />
<v-radio
label="Automated"
value="automated"
/>
</InputTooltip>
<InputTooltip align-center tooltip="Manually select your node by entering its id">
<v-radio label="Manual" value="manual" class="ml-5" />
<InputTooltip
align-center
tooltip="Manually select your node by entering its id"
>
<v-radio
label="Manual"
value="manual"
class="ml-5"
/>
</InputTooltip>
</v-radio-group>

<div ref="input">
<template v-if="wayToSelect === 'automated'">
<TfSelectLocation v-model="location" title="Choose a Location" :status="NodeStatus.Up" />
<TfSelectFarm v-model="farm" :valid-filters="validFilters" :filters="filters" :location="location" />
<TfSelectLocation
v-model="location"
title="Choose a Location"
:status="NodeStatus.Up"
/>
<TfSelectFarm
v-model="farm"
:valid-filters="validFilters"
:filters="filters"
:location="location"
/>
<TfAutoNodeSelector
v-model="node"
v-model:status="nodeStatus"
Expand Down Expand Up @@ -99,6 +135,7 @@ import type {
SelectionDetailsFiltersValidators,
} from "../../types/nodeSelector";
import { createSelectionDetailsFiltersValidator } from "../../utils/nodeSelector";
import TfRentalFilterSwitches from "../filters/TfRentalFilterSwitches.vue";
import TfAutoNodeSelector from "./TfAutoNodeSelector.vue";
import TfDomainName from "./TfDomainName.vue";
import TfManualNodeSelector from "./TfManualNodeSelector.vue";
Expand All @@ -108,7 +145,15 @@ import TfSelectLocation from "./TfSelectLocation.vue";

export default {
name: "TfSelectionDetails",
components: { TfSelectLocation, TfSelectFarm, TfAutoNodeSelector, TfManualNodeSelector, TfSelectGpu, TfDomainName },
components: {
TfRentalFilterSwitches,
TfSelectLocation,
TfSelectFarm,
TfAutoNodeSelector,
TfManualNodeSelector,
TfSelectGpu,
TfDomainName,
},
props: {
modelValue: Object as PropType<SelectionDetails>,
filters: {
Expand All @@ -132,10 +177,18 @@ export default {
default: () => [],
},
nodesLock: Object as PropType<AwaitLock>,
rentedByMe: Boolean,
dedicated: Boolean,
certified: Boolean,
hasGPU: Boolean,
},
emits: {
"update:model-value": (value: SelectionDetails) => true || value,
"update:status": (value: ValidatorStatus) => true || value,
"update:rentedByMe": (value: boolean) => value,
"update:dedicated": (value: boolean) => value,
"update:certified": (value: boolean) => value,
"update:hasGPU": (value: boolean) => value,
},
setup(props, ctx) {
const input = ref<HTMLElement>();
Expand Down
16 changes: 3 additions & 13 deletions packages/playground/src/weblets/tf_algorand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,11 @@
</input-tooltip>
</AlgorandCapacity>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch v-model="rentedByMe" color="primary" inset label="Rented By Me" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch v-model="dedicated" color="primary" inset label="Rentable" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch v-model="certified" color="primary" inset label="Certified" hide-details />
</input-tooltip>

<TfSelectionDetails
v-model="selectionDetails"
v-model:rented-by-me="rentedByMe"
v-model:dedicated="dedicated"
v-model:certified="certified"
:filters-validators="{
cpu: { min: type === 'relay' || type === 'indexer' ? 4 : 2 },
memory: { min: type === 'relay' || type === 'indexer' ? 8192 : 4096 },
Expand Down Expand Up @@ -124,8 +116,6 @@
<script lang="ts" setup>
import { computed, type Ref, ref, watch } from "vue";

import { manual } from "@/utils/manual";

import { useLayout } from "../components/weblet_layout.vue";
import { useGrid } from "../stores";
import { type Flist, ProjectName } from "../types";
Expand Down
16 changes: 3 additions & 13 deletions packages/playground/src/weblets/tf_casperlabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,11 @@
require-domain
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch v-model="rentedByMe" color="primary" inset label="Rented By Me" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch v-model="dedicated" color="primary" inset label="Rentable" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch v-model="certified" color="primary" inset label="Certified" hide-details />
</input-tooltip>

<TfSelectionDetails
v-model="selectionDetails"
v-model:rented-by-me="rentedByMe"
v-model:dedicated="dedicated"
v-model:certified="certified"
:filters="{
ipv4,
ipv6,
Expand Down Expand Up @@ -95,8 +87,6 @@
import { calculateRootFileSystem, FLISTS, type GridClient } from "@threefold/grid_client";
import { computed, type Ref, ref } from "vue";

import { manual } from "@/utils/manual";

import { useLayout } from "../components/weblet_layout.vue";
import { useGrid, useProfileManager } from "../stores";
import type { Flist, solutionFlavor as SolutionFlavor } from "../types";
Expand Down
Loading