-
Notifications
You must be signed in to change notification settings - Fork 4
/
listPopup.go
67 lines (58 loc) · 1.5 KB
/
listPopup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package tasks
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
timeutil "github.com/iwind/TeaGo/utils/time"
)
type ListPopupAction struct {
actionutils.ParentAction
}
func (this *ListPopupAction) Init() {
this.Nav("", "", "")
}
func (this *ListPopupAction) RunGet(params struct{}) {
this.retrieveTasks()
this.Show()
}
func (this *ListPopupAction) RunPost(params struct {
Must *actions.Must
}) {
this.retrieveTasks()
this.Success()
}
func (this *ListPopupAction) retrieveTasks() {
resp, err := this.RPC().NodeTaskRPC().FindNodeClusterTasks(this.AdminContext(), &pb.FindNodeClusterTasksRequest{})
if err != nil {
this.ErrorPage(err)
return
}
countTasks := 0
clusterMaps := []maps.Map{}
for _, cluster := range resp.ClusterTasks {
taskMaps := []maps.Map{}
for _, task := range cluster.NodeTasks {
countTasks++
taskMaps = append(taskMaps, maps.Map{
"id": task.Id,
"type": task.Type,
"node": maps.Map{
"id": task.Node.Id,
"name": task.Node.Name,
},
"isOk": task.IsOk,
"error": task.Error,
"isDone": task.IsDone,
"updatedTime": timeutil.FormatTime("Y-m-d H:i:s", task.UpdatedAt),
})
}
clusterMaps = append(clusterMaps, maps.Map{
"id": cluster.ClusterId,
"name": cluster.ClusterName,
"tasks": taskMaps,
})
}
this.Data["clusters"] = clusterMaps
this.Data["countTasks"] = countTasks
}