Skip to content

Commit

Permalink
ADD: service dropdown to the control page
Browse files Browse the repository at this point in the history
  • Loading branch information
mabasian committed Sep 19, 2024
1 parent b0c8244 commit 4d0d999
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 22 deletions.
35 changes: 26 additions & 9 deletions launcher/public/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,10 @@ video {
top: 1px;
}

.top-\[25\%\]{
top: 25%;
}

.top-\[33\%\]{
top: 33%;
}
Expand Down Expand Up @@ -1039,6 +1043,10 @@ video {
grid-column: span 10 / span 10;
}

.col-span-12{
grid-column: span 12 / span 12;
}

.col-span-2{
grid-column: span 2 / span 2;
}
Expand Down Expand Up @@ -1067,10 +1075,6 @@ video {
grid-column: 1 / -1;
}

.col-span-12{
grid-column: span 12 / span 12;
}

.col-start-1{
grid-column-start: 1;
}
Expand Down Expand Up @@ -2266,6 +2270,10 @@ video {
width: 75%;
}

.w-\[10\%\]{
width: 10%;
}

.w-\[100px\]{
width: 100px;
}
Expand Down Expand Up @@ -2322,6 +2330,10 @@ video {
width: 200px;
}

.w-\[24\%\]{
width: 24%;
}

.w-\[27px\]{
width: 27px;
}
Expand Down Expand Up @@ -4125,6 +4137,11 @@ video {
background-color: rgb(54 83 20 / var(--tw-bg-opacity));
}

.bg-orange-300{
--tw-bg-opacity: 1;
background-color: rgb(253 186 116 / var(--tw-bg-opacity));
}

.bg-orange-500{
--tw-bg-opacity: 1;
background-color: rgb(249 115 22 / var(--tw-bg-opacity));
Expand All @@ -4140,6 +4157,11 @@ video {
background-color: rgb(252 165 165 / var(--tw-bg-opacity));
}

.bg-red-400{
--tw-bg-opacity: 1;
background-color: rgb(248 113 113 / var(--tw-bg-opacity));
}

.bg-red-500{
--tw-bg-opacity: 1;
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
Expand Down Expand Up @@ -4224,11 +4246,6 @@ video {
background-color: rgb(63 63 70 / var(--tw-bg-opacity));
}

.bg-red-400{
--tw-bg-opacity: 1;
background-color: rgb(248 113 113 / var(--tw-bg-opacity));
}

.bg-opacity-80{
--tw-bg-opacity: 0.8;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<template>
<div
class="select-service-widget-parent flex flex-col w-full h-full justify-center items-center"
>
<div class="h-1/2 w-full justify-center items-center flex p-1">
<div
class="selector-services w-full h-full flex rounded-md border border-gray-500"
@click="deopdownHandler"
>
<div
class="selected-service-name flex justify-center items-center w-[90%] h-full text-gray-200 text-2xs font-semibold uppercase"
>
{{
controlStore.pickeedService === "exeCons"
? "EXECUTION & CONSENSUS CLIENTS"
: "VALIDATOR CLIENT"
}}
</div>
<div
class="arrow-box flex justify-center items-center w-[10%] h-full text-gray-200 text-lg font-semibold uppercase"
>
<svg
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
class="h-3 w-3 text-white self-center col-span-1 transform transition-transform duration-200 ease-in-out"
:class="[isOpen ? 'rotate-180' : 'rotate-0']"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 9l-7 7-7-7"
/>
</svg>
</div>
</div>

<Transition
enter-active-class="transform transition duration-500 ease-custom"
enter-class="-translate-y-1/2 scale-y-0 opacity-0"
enter-to-class="translate-y-0 scale-y-100 opacity-100"
leave-active-class="transform transition duration-300 ease-custom"
leave-class="translate-y-0 scale-y-100 opacity-100"
leave-to-class="-translate-y-1/2 scale-y-0 opacity-0"
>
<div
v-if="isOpen"
class="absolute top-[25%] z-20 min-h-20 mt-1 origin-top-right shadow-md bg-gray-200 transition-all duration-100 divide-y divide-gray-600 shadow-black rounded-md p-1 w-[24%]"
>
<div
class="p-2 bg-gray-200 capitalize transition-colors duration-300 transform text-gray-600 hover:bg-blue-300 hover:text-gray-700 cursor-pointer text-2xs font-bold"
@click="servicePicker('exeCons')"
>
<span
class="col-start-1 col-span-full self-center text-left text-xs font-semibold overflow-hidden truncate font-sans uppercase"
>EXECUTION & CONSENSUS CLIENTS</span
>
</div>
<div
class="p-2 bg-gray-200 capitalize transition-colors duration-300 transform text-gray-600 hover:bg-blue-300 hover:text-gray-700 cursor-pointer font-bold overflow-hidden truncate grid grid-cols-6 gap-x-1"
@click="servicePicker('vld')"
>
<span
class="col-start-1 col-span-full self-center text-xs font-bold overflow-hidden truncate font-sans uppercase"
>VALIDATOR CLIENT</span
>
</div>
</div>
</Transition>
</div>
<div class="h-1/2 w-full justify-center items-center bg-orange-300 flex"></div>
</div>
</template>

<script setup>
import { ref } from "vue";
import { useControlStore } from "@/store/theControl";
const controlStore = useControlStore();
const isOpen = ref(false);
const deopdownHandler = () => {
isOpen.value = !isOpen.value;
};
const servicePicker = (arg) => {
arg === "vld"
? (controlStore.pickeedService = "vld")
: (controlStore.pickeedService = "exeCons");
isOpen.value = !isOpen.value;
};
</script>

<style scoped>
.ease-custom {
transition-timing-function: cubic-bezier(0.61, -0.53, 0.43, 1.43);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,52 @@
>
<WidgetCard
class="services-select-widget col-start-1 col-span-6 row-start-1 row-span-3"
></WidgetCard>
><SelectServiceWidget
/></WidgetCard>
<WidgetCard
class="amsterdam-widget col-start-1 col-span-6 row-start-4 row-span-3"
></WidgetCard>
<WidgetCard
v-if="controlStore.pickeedService === 'exeCons'"
class="endpoint-widget col-start-1 col-span-6 row-start-7 row-span-3"
></WidgetCard>
<WidgetCard
v-if="controlStore.pickeedService === 'exeCons'"
class="p2pNetwork-widget col-start-1 col-span-6 row-start-10 row-span-3"
></WidgetCard>
<WidgetCard
v-if="controlStore.pickeedService === 'exeCons'"
class="p2p-widget col-start-1 col-span-6 row-start-13 row-span-3"
></WidgetCard>
<WidgetCard
class="connected-validator-widget col-start-7 col-span-12 row-start-1 row-span-3"
></WidgetCard>
<WidgetCard
v-if="controlStore.pickeedService === 'exeCons'"
class="sync-status-widget col-start-7 col-span-12 row-start-4 row-span-3"
></WidgetCard>
<WidgetCard
v-if="controlStore.pickeedService === 'exeCons'"
class="epoch-slot-widget col-start-7 col-span-12 row-start-7 row-span-3"
></WidgetCard>
<WidgetCard
v-if="controlStore.pickeedService === 'exeCons'"
class="subscribed-subnet-widget col-start-7 col-span-12 row-start-10 row-span-3"
></WidgetCard>
<WidgetCard
v-if="controlStore.pickeedService === 'exeCons'"
class="peer-over-time-widget col-start-7 col-span-12 row-start-13 row-span-3"
></WidgetCard>
</div>
</template>

<script setup>
import WidgetCard from "../components/cards/WidgetCard.vue";
import SelectServiceWidget from "../components/widgets/SelectServiceWidget.vue";
import { useControlStore } from "@/store/theControl";
const controlStore = useControlStore();
</script>

<style scoped></style>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="w-full relative col-start-1 col-span-full grid grid-cols-6 gap-x-1" :class="newHeight">
<div
class="w-full relative col-start-1 col-span-full grid grid-cols-6 gap-x-1"
:class="newHeight"
>
<label
v-if="setupStore.isRenameSetupActive && route.path === '/edit'"
for="rename"
Expand All @@ -19,7 +22,9 @@
<div
v-else
class="col-start-1 relative p-1 grid rounded-[4px] border border-gray-600"
:class="route.path === '/edit' ? 'col-end-6 grid-cols-9' : 'col-span-full grid-cols-12'"
:class="
route.path === '/edit' ? 'col-end-6 grid-cols-9' : 'col-span-full grid-cols-12'
"
@click="toggleDropdown"
>
<span
Expand All @@ -44,9 +49,17 @@
viewBox="0 0 24 24"
stroke="currentColor"
class="h-3 w-3 text-white self-center col-span-1 transform transition-transform duration-200 ease-in-out"
:class="[isOpen ? 'rotate-180' : 'rotate-0', route.path === '/edit' ? 'col-start-9' : 'col-start-12']"
:class="[
isOpen ? 'rotate-180' : 'rotate-0',
route.path === '/edit' ? 'col-start-9' : 'col-start-12',
]"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 9l-7 7-7-7"
/>
</svg>
</div>

Expand Down Expand Up @@ -75,7 +88,8 @@
src="/img/icon/stereum-icons/stereum-logo.png"
alt="Node Server View"
/>
<span class="col-start-2 col-span-full self-center text-left text-sm font-semibold overflow-hidden truncate font-sans"
<span
class="col-start-2 col-span-full self-center text-left text-sm font-semibold overflow-hidden truncate font-sans"
>Server View</span
>
</div>
Expand All @@ -93,16 +107,21 @@
class="col-start-1 col-span-1 w-5 h-5 rounded-full border border-gray-300 self-center justify-self-start"
:class="setupStore.getBGColor(setup.color)"
></span>
<span class="col-start-2 col-span-full self-center text-sm font-bold overflow-hidden truncate font-sans">{{
setup.setupName
}}</span>
<span
class="col-start-2 col-span-full self-center text-sm font-bold overflow-hidden truncate font-sans"
>{{ setup.setupName }}</span
>
</div>
</div>
</Transition>

<!-- Rename setup button -->
<!-- Rename Button -->
<RenameSetup v-if="route.path === '/edit'" @confirm-rename="confirmRename" @rename-setup="selectRename" />
<RenameSetup
v-if="route.path === '/edit'"
@confirm-rename="confirmRename"
@rename-setup="selectRename"
/>
</div>
</template>
<script setup>
Expand Down Expand Up @@ -135,14 +154,18 @@ const serviceStore = useServices();
const isOpen = ref(false);
const setupsList = computed(() => {
const validators = serviceStore.installedServices.filter((s) => s.category === "validator").map((v) => v.service);
const validators = serviceStore.installedServices
.filter((s) => s.category === "validator")
.map((v) => v.service);
let output = setupStore.allSetups.filter((s) => s.setupName !== "commonServices");
output = output.map((setup) => {
if (!setup.services || setup.services.length === 0) {
setup.noValidator = true;
} else {
const hasValidator = setup.services.some((service) => validators.includes(service.service));
const hasValidator = setup.services.some((service) =>
validators.includes(service.service)
);
if (!hasValidator) {
setup.noValidator = true;
}
Expand Down Expand Up @@ -197,7 +220,6 @@ const noValidatorHandler = (setup) => {
const toggleDropdown = () => {
if (route.path === "/control") {
isOpen.value = !isOpen.value;
console.log("Control");
} else if (setupsList.value.length > 0 && route.path !== "/control") {
isOpen.value = !isOpen.value;
}
Expand Down
1 change: 1 addition & 0 deletions launcher/src/store/theControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const useControlStore = defineStore("theControl", {
state: () => {
return {
setupServices: 0,
pickeedService: "exeCons",
currentConsensusIcon: "",
currentExecutionIcon: "",
synchronizationError: false,
Expand Down

0 comments on commit 4d0d999

Please sign in to comment.