From aab4e181053faee819d3a707550c96624aa2acc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 15 Jul 2024 15:20:26 +0200 Subject: [PATCH] fix cluster tasks UI (#91) --- web/api/webrpc/tasks.go | 13 +++++++++---- web/static/cluster-tasks.mjs | 15 +++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/web/api/webrpc/tasks.go b/web/api/webrpc/tasks.go index 5474f7bd3..4aa5bd98f 100644 --- a/web/api/webrpc/tasks.go +++ b/web/api/webrpc/tasks.go @@ -2,6 +2,7 @@ package webrpc import ( "context" + "time" "github.com/samber/lo" @@ -9,17 +10,20 @@ import ( ) type TaskSummary struct { - MinerID string + ID int64 Name string - SincePosted string + MinerID string + SincePosted time.Time `db:"since_posted"` Owner, OwnerID *string - ID int64 + + // db ignored + SincePostedStr string `db:"-"` } func (a *WebRPC) ClusterTaskSummary(ctx context.Context) ([]TaskSummary, error) { var ts []TaskSummary err := a.deps.DB.Select(ctx, &ts, `SELECT - t.id as id, t.name as name, t.update_time as SincePosted, t.owner_id as owner_id, hm.host_and_port as owner + t.id as id, t.name as name, t.update_time as since_posted, t.owner_id as owner_id, hm.host_and_port as owner FROM harmony_task t LEFT JOIN curio.harmony_machines hm ON hm.id = t.owner_id ORDER BY t.update_time ASC, t.owner_id`) if err != nil { @@ -37,6 +41,7 @@ func (a *WebRPC) ClusterTaskSummary(ctx context.Context) ([]TaskSummary, error) } } } + return ts, nil } diff --git a/web/static/cluster-tasks.mjs b/web/static/cluster-tasks.mjs index 0f6fa1a72..c358b9aec 100644 --- a/web/static/cluster-tasks.mjs +++ b/web/static/cluster-tasks.mjs @@ -13,8 +13,7 @@ class ClusterTasks extends LitElement { } async loadData() { - this.data = await RPCCall('ClusterTasks'); - ///hapi/simpleinfo/tasks + this.data = await RPCCall('ClusterTaskSummary'); setTimeout(() => this.loadData(), 1000); super.requestUpdate(); } @@ -36,11 +35,11 @@ class ClusterTasks extends LitElement { ${this.data.map(entry => html` - ${this.MinerID? this.MinerID: ''} - ${this.Name} - ${this.ID} - ${this.SincePosted} - ${!this.OwnerID ? html`{{.Owner}}{{end}}`:''} + ${entry.MinerID? entry.MinerID: ''} + ${entry.Name} + ${entry.ID} + ${entry.SincePosted} + ${entry.OwnerID ? html`${entry.Owner}`:''} `)} @@ -49,4 +48,4 @@ class ClusterTasks extends LitElement { } } -customElements.define('storage-gc-stats', StorageGCStats); +customElements.define('cluster-tasks', ClusterTasks);