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

Filter by up & standby nodes in Node Finder #2883

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions packages/gridproxy_client/src/builders/gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export enum NodeStatus {
Standby = "standby",
}

export enum UnifiedNodeStatus {
Up = "up",
Down = "down",
Standby = "standby",
UpStandby = "up,standby",
zaelgohary marked this conversation as resolved.
Show resolved Hide resolved
}

export interface GatewaysQuery {
page: number;
size: number;
Expand Down
11 changes: 8 additions & 3 deletions packages/gridproxy_client/src/builders/nodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assertBoolean, assertId, assertIn, assertInt, assertNatural, assertPattern, assertString } from "../utils";
import { AbstractBuilder, BuilderMapper, BuilderMethods, BuilderValidator } from "./abstract_builder";
import { ID_PATTERN, NodeStatus } from "./gateways";
import { ID_PATTERN, UnifiedNodeStatus } from "./gateways";

export enum SortBy {
NodeId = "node_id",
Expand Down Expand Up @@ -47,7 +47,7 @@ export interface NodesQuery {
totalSru: number;
totalHru: number;
freeIps: number;
status: NodeStatus;
status: UnifiedNodeStatus;
city: string;
country: string;
region: string;
Expand Down Expand Up @@ -129,7 +129,12 @@ const NODES_VALIDATOR: BuilderValidator<NodesQuery> = {
freeGpu: assertNatural,
freeIps: assertNatural,
status(value) {
assertIn(value, [NodeStatus.Up, NodeStatus.Down, NodeStatus.Standby]);
assertIn(value, [
UnifiedNodeStatus.Up,
UnifiedNodeStatus.Down,
UnifiedNodeStatus.Standby,
UnifiedNodeStatus.UpStandby,
]);
},
city: assertString,
country: assertString,
Expand Down
13 changes: 7 additions & 6 deletions packages/playground/src/views/nodes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
:model-value="filters.status || undefined"
@update:model-value="filters.status = $event || ''"
:items="[
{ title: 'Up', value: NodeStatus.Up },
{ title: 'Down', value: NodeStatus.Down },
{ title: 'Standby', value: NodeStatus.Standby },
{ title: 'Up', value: UnifiedNodeStatus.Up },
{ title: 'Standby', value: UnifiedNodeStatus.Standby },
{ title: 'Up & Standby', value: UnifiedNodeStatus.UpStandby },
{ title: 'Down', value: UnifiedNodeStatus.Down },
]"
label="Select Nodes Status"
item-title="title"
Expand Down Expand Up @@ -443,7 +444,7 @@
</template>

<script lang="ts">
import { type GridNode, NodeStatus, SortBy, SortOrder } from "@threefold/gridproxy_client";
import { type GridNode, SortBy, SortOrder, UnifiedNodeStatus } from "@threefold/gridproxy_client";
import { sortBy } from "lodash";
import { computed, onMounted, ref } from "vue";
import { useRoute } from "vue-router";
Expand Down Expand Up @@ -538,7 +539,7 @@ export default {
farmName: filters.value.farmName || undefined,
country: filters.value.country,
region: filters.value.region,
status: (filters.value.status as NodeStatus) || undefined,
status: (filters.value.status as UnifiedNodeStatus) || undefined,
freeHru: convertToBytes(filters.value.freeHDD),
freeMru: convertToBytes(filters.value.freeRAM),
freeSru: convertToBytes(filters.value.freeSSD),
Expand Down Expand Up @@ -605,7 +606,7 @@ export default {
requestNodes,
isDialogOpened,
filters,
NodeStatus,
UnifiedNodeStatus,
size,
page,
loadNodes,
Expand Down
Loading