From f4b53c1cc764e4bda4d652e014992a7981a4d945 Mon Sep 17 00:00:00 2001 From: amiraabouhadid Date: Wed, 17 Jul 2024 12:08:35 +0300 Subject: [PATCH 1/2] add sorting by farm id and name --- .../gridproxy_client/src/builders/farms.ts | 8 +- .../gridproxy_client/src/builders/nodes.ts | 9 +- packages/playground/src/views/farms.vue | 18 +- yarn.lock | 350 +++++++++++++++++- 4 files changed, 371 insertions(+), 14 deletions(-) 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/views/farms.vue b/packages/playground/src/views/farms.vue index e9cdc22b5b..699d130ec0 100644 --- a/packages/playground/src/views/farms.vue +++ b/packages/playground/src/views/farms.vue @@ -105,7 +105,12 @@ page = $event; loadFarms(); " - :disable-sort="true" + @update:sort-by=" + sortBy = $event[0].key == 'farmId' ? SortBy.FarmId : $event[0].key; + sortOrder = $event[0].order; + loadFarms(); + " + @update:options="loadFarms()" @click:row="openSheet" >