Skip to content

Commit

Permalink
Merge pull request #2883 from threefoldtech/development_filter_up_sta…
Browse files Browse the repository at this point in the history
…ndby

Filter by up & standby nodes in Node Finder
  • Loading branch information
zaelgohary authored Jun 6, 2024
2 parents 10b2b62 + 8bfa4c3 commit 2747f34
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
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",
}

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

0 comments on commit 2747f34

Please sign in to comment.