mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 04:10:26 +08:00
增加刷新、预热缓存任务管理
This commit is contained in:
72
internal/web/actions/default/servers/components/cache/batch/tasks.go
vendored
Normal file
72
internal/web/actions/default/servers/components/cache/batch/tasks.go
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
)
|
||||
|
||||
type TasksAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *TasksAction) Init() {
|
||||
this.Nav("", "", "task")
|
||||
}
|
||||
|
||||
func (this *TasksAction) RunGet(params struct{}) {
|
||||
// 初始化菜单数据
|
||||
err := InitMenu(this.Parent())
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
}
|
||||
|
||||
// 任务数量
|
||||
countResp, err := this.RPC().HTTPCacheTaskRPC().CountHTTPCacheTasks(this.AdminContext(), &pb.CountHTTPCacheTasksRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var count = countResp.Count
|
||||
var page = this.NewPage(count)
|
||||
this.Data["page"] = page.AsHTML()
|
||||
|
||||
// 任务列表
|
||||
var taskMaps = []maps.Map{}
|
||||
tasksResp, err := this.RPC().HTTPCacheTaskRPC().ListHTTPCacheTasks(this.AdminContext(), &pb.ListHTTPCacheTasksRequest{
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
for _, task := range tasksResp.HttpCacheTasks {
|
||||
var userMap = maps.Map{"id": 0, "username": "", "fullname": ""}
|
||||
if task.User != nil {
|
||||
userMap = maps.Map{
|
||||
"id": task.User.Id,
|
||||
"username": task.User.Username,
|
||||
"fullname": task.User.Fullname,
|
||||
}
|
||||
}
|
||||
|
||||
taskMaps = append(taskMaps, maps.Map{
|
||||
"id": task.Id,
|
||||
"type": task.Type,
|
||||
"keyType": task.KeyType,
|
||||
"isDone": task.IsDone,
|
||||
"isOk": task.IsOk,
|
||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", task.CreatedAt),
|
||||
"description": task.Description,
|
||||
"user": userMap,
|
||||
})
|
||||
}
|
||||
|
||||
this.Data["tasks"] = taskMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user