diff --git a/packages/grid_client/src/modules/farms.ts b/packages/grid_client/src/modules/farms.ts index 5aeb3cf743..b2e57ff221 100644 --- a/packages/grid_client/src/modules/farms.ts +++ b/packages/grid_client/src/modules/farms.ts @@ -2,7 +2,14 @@ import { TFClient } from "../clients/tf-grid/client"; import { GridClientConfig } from "../config"; import { expose } from "../helpers/expose"; import { validateInput } from "../helpers/validator"; -import { FarmIdModel } from "./models"; +import { + AddFarmIPModel, + AddStellarAddressToFarmModel, + CreateFarmModel, + FarmIdModel, + RemoveFarmIPModel, +} from "./models"; +import { checkBalance } from "./utils"; class Farms { client: TFClient; @@ -11,6 +18,34 @@ class Farms { this.client = config.tfclient; } + @expose + @validateInput + @checkBalance + async create(options: CreateFarmModel) { + return (await this.client.farms.create(options)).apply(); + } + + @expose + @validateInput + @checkBalance + async addFarmIp(options: AddFarmIPModel) { + return (await this.client.farms.addFarmIp(options)).apply(); + } + + @expose + @validateInput + @checkBalance + async removeFarmIp(options: RemoveFarmIPModel) { + return (await this.client.farms.removeFarmIp(options)).apply(); + } + + @expose + @validateInput + @checkBalance + async addStellarAddress(options: AddStellarAddressToFarmModel) { + return (await this.client.farms.addStellarAddress(options)).apply(); + } + @expose @validateInput async getFarmByID(options: FarmIdModel) { diff --git a/packages/grid_client/src/modules/models.ts b/packages/grid_client/src/modules/models.ts index 6ff2a6a8b3..910514af54 100644 --- a/packages/grid_client/src/modules/models.ts +++ b/packages/grid_client/src/modules/models.ts @@ -658,6 +658,51 @@ class FarmIdModel { @Expose() @IsInt() @IsNotEmpty() @Min(1) id: number; } +class FarmPublicIPsModel { + @Expose() @IsNotEmpty() @IsIP() ip: string; + @Expose() @IsNotEmpty() @IsString() gw: string; +} + +class AddFarmIPModel { + @Expose() @IsInt() @IsNotEmpty() @Min(1) farmId: number; + @Expose() @IsNotEmpty() @IsString() ip: string; + @Expose() @IsNotEmpty() @IsIP() gw: string; +} + +class IPConfig { + @Expose() @IsNotEmpty() @IsString() ip: string; + @Expose() @IsNotEmpty() @IsIP() gw: string; +} +class PublicConfigModel { + @Expose() @IsNotEmpty() @Type(() => IPConfig) @ValidateNested() ip4: IPConfig; + @Expose() @IsOptional() ip6: IPConfig | null; + @Expose() @IsOptional() @IsString() domain: string | null; +} +class AddPublicConfig { + @Expose() @IsInt() @IsNotEmpty() @Min(1) farmId: number; + @Expose() @IsInt() @IsNotEmpty() @Min(1) nodeId: number; + @Expose() @IsOptional() @Type(() => PublicConfigModel) @ValidateNested() publicConfig?: PublicConfigModel | null; +} + +class RemoveFarmIPModel { + @Expose() @IsInt() @IsNotEmpty() @Min(1) farmId: number; + @Expose() @IsNotEmpty() @IsString() ip: string; +} + +class AddStellarAddressToFarmModel { + @Expose() @IsInt() @IsNotEmpty() @Min(1) farmId: number; + @Expose() @IsString() @IsNotEmpty() stellarAddress: string; +} + +class CreateFarmModel { + @Expose() @IsString() @IsNotEmpty() @MaxLength(NameLength) name: string; + @Expose() + @IsOptional() + @Type(() => FarmPublicIPsModel) + @ValidateNested({ each: true }) + publicIps?: FarmPublicIPsModel[]; +} + class pingFarmModel { @Expose() @IsInt() @IsNotEmpty() @Min(1) farmId: number; } @@ -682,7 +727,7 @@ class NetworkGetModel { class SetDedicatedNodeExtraFeesModel { @Expose() @IsInt() @IsNotEmpty() @Min(1) nodeId: number; - @Expose() @IsInt() @IsNotEmpty() @Min(1) extraFee: number; + @Expose() @IsNumber() @IsNotEmpty() @Min(0) extraFee: number; } class GetDedicatedNodePriceModel { @@ -812,6 +857,7 @@ export { ZOSNodeModel, NodePowerModel, FarmIdModel, + CreateFarmModel, pingFarmModel, CreateServiceContractModel, ServiceContractApproveModel, @@ -828,5 +874,9 @@ export { GetDedicatedNodePriceModel, SwapToStellarModel, ListenToMintCompletedModel, + AddFarmIPModel, + RemoveFarmIPModel, + AddStellarAddressToFarmModel, + AddPublicConfig, GetActiveContractsModel, }; diff --git a/packages/grid_client/src/modules/nodes.ts b/packages/grid_client/src/modules/nodes.ts index af4631d976..3ee892c8c6 100644 --- a/packages/grid_client/src/modules/nodes.ts +++ b/packages/grid_client/src/modules/nodes.ts @@ -4,6 +4,7 @@ import { events, validateInput } from "../helpers"; import { expose } from "../helpers/expose"; import { capacity } from "./capacity"; import { + AddPublicConfig, FilterOptions, NodeGetModel, NodePowerModel, @@ -82,6 +83,13 @@ class Nodes { return (await this.client.nodes.setPower(options)).apply(); } + @expose + @validateInput + @checkBalance + async addNodePublicConfig(options: AddPublicConfig) { + return (await this.client.nodes.addNodePublicConfig(options)).apply(); + } + @expose async all() { return await this.capacity.getAllNodes(); diff --git a/packages/playground/package.json b/packages/playground/package.json index 2041414ee9..9c1d9c6444 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -31,6 +31,7 @@ "vue-router": "^4.1.6", "vuetify": "^3.1.15", "web-ssh-keygen": "^0.1.2", + "get-ip-range": "^4.0.1", "chart.js": "^4.4.0", "vue-chartjs": "^5.2.0", "moment": "^2.29.4" diff --git a/packages/playground/src/App.vue b/packages/playground/src/App.vue index f080b6cd85..812de826a3 100644 --- a/packages/playground/src/App.vue +++ b/packages/playground/src/App.vue @@ -155,7 +155,7 @@
- +
@@ -179,6 +179,7 @@ import { useProfileManager } from "./stores/profile_manager"; const $route = useRoute(); const $router = useRouter(); const profileManager = useProfileManager(); +const gridStore = useGrid(); const network = process.env.NETWORK || (window as any).env.NETWORK; const openProfile = ref(true); @@ -186,6 +187,7 @@ const hasActiveProfile = computed(() => !!profileManager.profile); const theme = useTheme(); const navbarConfig = ref(); +const hasGrid = computed(() => !!gridStore.grid); watch( () => $route.meta, meta => { @@ -373,6 +375,7 @@ import FundsCard from "./components/funds_card.vue"; import ProfileManagerController from "./components/profile_manager_controller.vue"; import TftSwapPrice from "./components/swap_price.vue"; import TFNotification from "./components/tf_notification.vue"; +import { useGrid } from "./stores"; import ProfileManager from "./weblets/profile_manager.vue"; interface AppRoute { @@ -404,125 +407,3 @@ export default { }, }; - - diff --git a/packages/playground/src/components/dashboard/portal/NodeMintingDetails.vue b/packages/playground/src/components/dashboard/portal/NodeMintingDetails.vue new file mode 100644 index 0000000000..7db8921b0f --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/NodeMintingDetails.vue @@ -0,0 +1,143 @@ + + + diff --git a/packages/playground/src/components/dashboard/portal/add_ip.vue b/packages/playground/src/components/dashboard/portal/add_ip.vue new file mode 100644 index 0000000000..5a4b806fdf --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/add_ip.vue @@ -0,0 +1,299 @@ + + + + + diff --git a/packages/playground/src/components/dashboard/portal/create_farm.vue b/packages/playground/src/components/dashboard/portal/create_farm.vue new file mode 100644 index 0000000000..57586b2ea6 --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/create_farm.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/packages/playground/src/components/dashboard/portal/public_config.vue b/packages/playground/src/components/dashboard/portal/public_config.vue new file mode 100644 index 0000000000..6fbf28bc84 --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/public_config.vue @@ -0,0 +1,271 @@ + + + + + diff --git a/packages/playground/src/components/dashboard/portal/public_ips_table.vue b/packages/playground/src/components/dashboard/portal/public_ips_table.vue new file mode 100644 index 0000000000..4c8452e270 --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/public_ips_table.vue @@ -0,0 +1,162 @@ + + + diff --git a/packages/playground/src/components/dashboard/portal/set_extra_fee.vue b/packages/playground/src/components/dashboard/portal/set_extra_fee.vue new file mode 100644 index 0000000000..f0e166786d --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/set_extra_fee.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/packages/playground/src/components/dashboard/portal/user_farms.vue b/packages/playground/src/components/dashboard/portal/user_farms.vue new file mode 100644 index 0000000000..218e21a839 --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/user_farms.vue @@ -0,0 +1,345 @@ + + + + diff --git a/packages/playground/src/components/dashboard/portal/user_nodes.vue b/packages/playground/src/components/dashboard/portal/user_nodes.vue new file mode 100644 index 0000000000..16c384dc27 --- /dev/null +++ b/packages/playground/src/components/dashboard/portal/user_nodes.vue @@ -0,0 +1,331 @@ + + + + + diff --git a/packages/playground/src/explorer/components/node_details.vue b/packages/playground/src/explorer/components/node_details.vue index 5c8e59171f..3b96bd5ea2 100644 --- a/packages/playground/src/explorer/components/node_details.vue +++ b/packages/playground/src/explorer/components/node_details.vue @@ -170,7 +170,7 @@ export default { }; -