diff --git a/packages/gridproxy_client/src/builders/farms.ts b/packages/gridproxy_client/src/builders/farms.ts index a39b328f63..35421d81c0 100644 --- a/packages/gridproxy_client/src/builders/farms.ts +++ b/packages/gridproxy_client/src/builders/farms.ts @@ -1,6 +1,6 @@ import { assertBoolean, assertId, assertIn, assertNatural, assertString } from "../utils"; import { AbstractBuilder, BuilderMapper, BuilderMethods, BuilderValidator } from "./abstract_builder"; - +import { SortBy, SortOrder } from "./nodes"; export enum CertificationType { Diy = "DIY", Certified = "Certified", @@ -23,6 +23,8 @@ export interface FarmsQuery { dedicated: boolean; stellarAddress: string; nodeHasIPv6: boolean; + sortBy: SortBy; + sortOrder: SortOrder; } const FARMS_MAPPER: BuilderMapper = { @@ -41,6 +43,8 @@ const FARMS_MAPPER: BuilderMapper = { totalIps: "total_ips", twinId: "twin_id", nodeHasIPv6: "node_has_ipv6", + sortBy: "sort_by", + sortOrder: "sort_order", }; const FARMS_VALIDATOR: BuilderValidator = { @@ -61,6 +65,8 @@ const FARMS_VALIDATOR: BuilderValidator = { dedicated: assertBoolean, stellarAddress: assertString, nodeHasIPv6: assertBoolean, + sortBy: assertString, + sortOrder: assertString, }; export class FarmsBuilder extends AbstractBuilder { diff --git a/packages/gridproxy_client/src/builders/nodes.ts b/packages/gridproxy_client/src/builders/nodes.ts index 5f62a617c2..07f2c2d43c 100644 --- a/packages/gridproxy_client/src/builders/nodes.ts +++ b/packages/gridproxy_client/src/builders/nodes.ts @@ -2,6 +2,10 @@ import { assertBoolean, assertId, assertIn, assertInt, assertNatural, assertPatt import { AbstractBuilder, BuilderMapper, BuilderMethods, BuilderValidator } from "./abstract_builder"; import { ID_PATTERN, UnifiedNodeStatus } from "./gateways"; +export enum SortOrder { + Desc = "desc", + Asc = "asc", +} export enum SortBy { NodeId = "node_id", FarmId = "farm_id", @@ -28,11 +32,6 @@ export enum SortBy { FreeCRU = "free_cru", } -export enum SortOrder { - Desc = "desc", - Asc = "asc", -} - export interface NodesQuery { page: number; size: number; diff --git a/packages/playground/src/dashboard/components/user_farms.vue b/packages/playground/src/dashboard/components/user_farms.vue index a7b2723fbc..e1ac3aa7dc 100644 --- a/packages/playground/src/dashboard/components/user_farms.vue +++ b/packages/playground/src/dashboard/components/user_farms.vue @@ -38,6 +38,13 @@ } } " + @update:sort-by=" + if ($event[0]) { + sortBy = $event[0].key == 'farmId' ? SortBy.FarmId : $event[0].key; + sortOrder = $event[0].order; + getUserFarms(); + } + " expand-on-click @update:options="getUserFarms" :hover="true" @@ -128,7 +135,7 @@