Files
waf-platform/EdgeAdmin/internal/web/actions/default/settings/client-systems/index.go
2026-02-04 20:27:13 +08:00

60 lines
1.4 KiB
Go

// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package clientsystems
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "", "")
}
func (this *IndexAction) RunGet(params struct {
Keyword string
}) {
this.Data["keyword"] = params.Keyword
countResp, err := this.RPC().FormalClientSystemRPC().CountFormalClientSystems(this.AdminContext(), &pb.CountFormalClientSystemsRequest{
Keyword: params.Keyword,
})
if err != nil {
this.ErrorPage(err)
return
}
var page = this.NewPage(countResp.Count)
this.Data["page"] = page.AsHTML()
systemsResp, err := this.RPC().FormalClientSystemRPC().ListFormalClientSystems(this.AdminContext(), &pb.ListFormalClientSystemsRequest{
Keyword: params.Keyword,
Offset: page.Offset,
Size: page.Size,
})
if err != nil {
this.ErrorPage(err)
return
}
var systemMaps = []maps.Map{}
for _, system := range systemsResp.FormalClientSystems {
var codes = system.Codes
if codes == nil {
codes = []string{}
}
systemMaps = append(systemMaps, maps.Map{
"id": system.Id,
"name": system.Name,
"codes": codes,
"dataId": system.DataId,
})
}
this.Data["systems"] = systemMaps
this.Show()
}