fix UI zos compute #130
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_compute#130
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
RESERVATIONS TAB
We are creating a server called My Compute ZOS.
The way it works is that a user starts with a reservation, which represents a set of resources that can be combined. A reservation can have a secret attached to it and one or more SSH keys. Anything deployed within this reservation—whether a VM or a WebGateway—inherits those attributes. The secret protects the resources inside the reservation, while the SSH keys are relevant only for virtual machines.
Inside reservations we want the main pannel to displays the main statistics. allowing us to see which virtual machines exist. For each VM we should display its public IP address and provide a link that jumps to the console on the router (or a console tab for remote SSH access).
Below the main view, there should be a grid listing the contracts, with sections for virtual machines and lab gateways. When a user clicks on a virtual machine, a summary panel appears, showing basic information such as memory, CPU, and some statistics. Clicking again on that virtual machine opens a full‑page view with all details obtainable from the grid.
All information is cached in the database, so the UI always displays data from the database first. The database is kept in sync with the grid: we regularly run synchronisation tools (approximately hourly, or at random intervals as needed) that fetch the current status of each virtual machine and web gateway. This ensures that the status shown in the database matches the actual status on the grid.
CONTRACTS TAB
❯ we can have a tab of contracts, these are all contracts which are oned by the user of TFGrid, as defined by
his/her pub/private key = TFGRID_MNEMONIC
sync (in background) all known TFContracts, they to find to which reservation they belond and show, we can then
click on the reservation from the contract item
also multi select, we can delete
per contract we show if there is billing
Implementation Spec for Issue #130
Objective
Bring the "My Compute ZOS" admin UI in line with issue #130's two-tab design. (1) A Reservations tab whose main panel shows VM statistics with public IP and console/SSH links, a contracts grid grouped into VMs and lab gateways, a click-to-expand VM summary panel and a full-page VM detail view, all served from the DB cache and kept in sync with the grid by a periodic background sync. (2) A Contracts tab that lists all TFGrid contracts owned by the operator twin (TFGRID_MNEMONIC), syncs them into the DB in the background, maps each to its reservation (clickable), supports multi-select delete, and shows per-contract billing.
Current State
Reservation { sid, name, secret, ssh_keys }exists.VmandWebgatewayboth carry areservation_sid: Option<String>and on-chain meta structs. There is no Contract entity and no billing field.reservationstable + full CRUD. Helpersvm_list_for_reservation/webgateway_list_for_reservationexist. Nocontractstable. Theexplorer_nodestable +sync_explorer_nodesis the proven template for a DB-cached, gridproxy-fed, prune-stale sync.dispatch().tfgrid_twin_id()resolves the operator twin.cancel_rent_contract/gateway_driver::cancel_contract_on_tfgridcan cancel a contract by id.grid_driver::scan_orphan_contracts_since+ProxyContractquery gridproxy contracts. Nosync_contracts/list_contractsRPC;ProxyContractdoes not parse type/details/billing.computeservice_*for current methods incl. reservations andsync_explorer_nodes; no contract-sync method.index.htmltab bar has Dashboard / Explorer / Reservations (id tab-deployments) / API Docs / Settings. No Contracts tab button even thoughpanes/contracts.htmlandpanes/vms.htmlare included.panes/deployments.htmlis the Reservations pane (list + drill-in detail with VMs/Web Gateways/TFGrid Contracts cards). No VM public-IP/console column, no VM summary panel, no full-page VM view.panes/contracts.htmlexists but is unreachable, driven bylist_vms/list_webgateways+ direct browser fetch to gridproxy, with no reservation column/multi-select/billing._startTab('contracts')is never triggered (no tab). No multi-select, billing, VM console/IP link, or VM summary/full-page view.Requirements
Files to Modify/Create
crates/my_compute_zos_server/src/cloud/types.rs- AddContractstruct +ContractSyncResult+ trait methodssync_contracts,list_contracts,delete_contract, reservation/workload sync.crates/my_compute_zos_server/src/cloud/db.rs- Addcontractstable + accessors (contract_upsert/get/list/list_for_reservation/delete,contracts_delete_not_in,contracts_last_synced_at,row_to_contract).crates/my_compute_zos_server/src/cloud/grid_driver.rs- ExtendProxyContract(type/twin_id/details/billing via serde(default)); addfetch_twin_contractsand optionalfetch_contract_bills.crates/my_compute_zos_server/src/cloud/rpc.rs- Implementsync_contracts/list_contracts/delete_contract+ VM/WG reconcile +dispatch()arms.crates/my_compute_zos_sdk/src/generated/openrpc.openrpc.client.generated.rs+crates/my_compute_zos_server/src/cloud/openrpc.json- Add new method signatures.crates/my_compute_zos_admin/templates/index.html- Add Contracts tab button.crates/my_compute_zos_admin/templates/panes/contracts.html- Reservation column, multi-select + bulk-delete, billing column.crates/my_compute_zos_admin/templates/panes/deployments.html- VM public-IP + console/SSH columns; VM summary panel + full-page wiring.crates/my_compute_zos_admin/templates/panes/vms.html- Full-page VM detail view.crates/my_compute_zos_admin/static/js/panes.js- RewriteloadContractsPage/loadRentalsto readlist_contracts; add contracts background/stale sync; multi-select +bulkCancelContracts; VM summary + full-page handlers; IP/console link rendering.crates/my_compute_zos_admin/static/js/dashboard.js- VM console/SSH link helpers; trigger reservation VM/WG sync on entering Reservations tab.crates/my_compute_zos_server/tests/integration.rs- Tests for sync/list/delete contracts, mapping, and reconcile.Implementation Plan
Step 1: Define Contract entity + billing data model
Files:
types.rsContractstruct (contract_id, twin_id, kind, state, node_id, resource_sid, reservation_sid, billing fields, created_at, synced_at) +ContractSyncResult.sync_contracts,list_contracts,delete_contract, and a reservation/workload state sync.Dependencies: none
Step 2: Add contracts table + DB accessors
Files:
db.rsCREATE TABLE IF NOT EXISTS contractsinmigrate()(followexplorer_nodes).contracts_delete_not_in,contracts_last_synced_at,row_to_contract.Dependencies: Step 1
Step 3: Gridproxy contract + billing fetch
Files:
grid_driver.rsProxyContract(type/twin_id/details/billing via serde(default)); addfetch_twin_contracts; optionalfetch_contract_bills.Dependencies: none (parallel with 1-2)
Step 4: Implement sync_contracts/list_contracts/reconcile in RPC + dispatch
Files:
rpc.rssync_contracts: resolve operator twin, fetch contracts, map to reservation via stored vm/wg meta contract ids, upsert + prune.list_contracts,delete_contract, VM/WG reconcile sync; adddispatch()arms.Dependencies: Steps 1,2,3
Step 5: Expose new methods in SDK + openrpc.json
Files: generated client,
openrpc.jsoncomputeservice_*client fns following the existingsync_explorer_nodesblock.Dependencies: Step 4
Step 6: Add Contracts tab + multi-select + billing + reservation link (UI)
Files:
index.html,panes/contracts.html,panes.jsloadContractsPageto readlist_contracts; add_startTab('contracts')background sync + stale check; multi-select +bulkCancelContracts.Dependencies: Step 5
Step 7: Reservations VM IP/console links, summary panel, full-page view (UI)
Files:
panes/deployments.html,panes/vms.html,panes.js,dashboard.jsDependencies: Step 5 (parallel with Step 6)
Step 8: Tests
Files:
tests/integration.rsDependencies: Step 4 (backend), Step 5 (SDK)
Acceptance Criteria
Notes
development_no_osis; listed files already dirty from recent reservation commits. Reservations pane ispanes/deployments.html(id prefix deployments) - do not rename ids without updating switchTab/_startTab.sync_explorer_nodes+explorer_nodestable are the canonical pattern to copy for the contracts cache (paged fetch -> upsert -> delete_not_in prune -> last_synced_at + JS stale-check).Test Results
New contract tests (integration suite):
Breakdown:
Implementation Summary
Implemented the two-tab "My Compute ZOS" UI described in this issue: a Contracts tab backed by a new DB-cached contract store, and Reservations VM enhancements (public IP / console-SSH links, click-to-summary, full-page VM view).
Backend
types.rs- AddedContractandContractSyncResultstructs; declared trait methodssync_contracts,list_contracts,delete_contract,sync_workloadsonComputeServiceTrait.db.rs- Added thecontractstable tomigrate()plus accessorscontract_upsert,contract_get,contract_list,contract_list_for_reservation,contract_delete,contracts_delete_not_in,contracts_last_synced_at, and arow_to_contractmapper. Modeled on the existingexplorer_nodescache.grid_driver.rs- ExtendedProxyContract(type/twin_id/details, all serde(default)); addedfetch_twin_contracts(paginated, all non-deleted contracts for a twin) andfetch_contract_bills(sums billed amount).rpc.rs- Implemented the four trait methods.sync_contractsresolves the operator twin, fetches contracts, maps each to a reservation by matching on-chain contract ids stored on VMs (hypervisor_meta.vm/network_contract_id) and webgateways (meta.contract/name_contract_id), upserts and prunes.list_contractsreads from the DB cache.delete_contractcancels on-chain (idempotent on already-cancelled) then prunes.sync_workloadsreconciles VM/WG state from the grid. Added the matchingdispatch()arms.openrpc.json+ generated SDK - Added Contract / ContractSyncResult / ExplorerSyncResult schemas and the four method entries; theopenrpc_client!macro regenerates the typed SDK client.UI
index.html- Added the Contracts tab button to the top tab bar (the pane was already included but unreachable).panes/contracts.html- Restructured the contracts table to be driven bylist_contracts: select-all + per-row checkboxes, a bulk-delete toolbar with live count, a clickable Reservation column, and a Billing column.panes.js(Contracts) - RewroteloadContractsPageto read the DB cache; added cache-first load with backgroundsync_contractsand a_contractsAutoSyncIfStale(>1h) check mirroring the explorer pattern; multi-select state,bulkCancelContracts, andopenReservationFromContract.panes/deployments.html- Added Mycelium IP, Public IP, and Console/SSH columns to the reservation VM table.panes/vms.html- Added a full-page VM detail view (list view + detail view with a Back button).panes.js(Reservations) - Two-stage VM interaction: first click expands an inline summary (state, CPU, memory, IP, SSH), second click opens the full-page view (toggleVmSummary/openVmDetail/closeVmDetail). Entering the Reservations tab now triggerssync_workloadsin the background. Lightly grouped the detail Contracts card into VM and Web Gateway sections.dashboard.js- Added defensivevmPublicIp,vmConsoleUrl, andvmSshCommandhelpers.Tests
Added 6 integration tests in
tests/integration.rscovering the contract cache, reservation mapping/filter, prune, delete, and last-synced-at. Full suite: 60 passed, 0 failed (22 integration + 38 server lib unit). Workspace compiles cleanly.Notes / known gaps
Vm/HypervisorMetamodel today; the only routable address ismycelium_ip. The Public IP column and console/SSH links fall back to the mycelium IPv6, and Public IP renders a dash when no dedicated public IP is present. The helper picks up a real public-IP field automatically if one is added later.sync_contracts/delete_contractexercise the live grid proxy and on-chain cancel respectively, so the integration tests validate the DB cache / mapping / prune / filter data-flow offline rather than the network path.