45 lines
935 B
Go
45 lines
935 B
Go
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
//go:build plus
|
|
|
|
package scripts
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
"github.com/iwind/TeaGo/maps"
|
|
)
|
|
|
|
type ScriptAction struct {
|
|
actionutils.ParentAction
|
|
}
|
|
|
|
func (this *ScriptAction) Init() {
|
|
this.Nav("", "", "")
|
|
}
|
|
|
|
func (this *ScriptAction) RunGet(params struct {
|
|
ScriptId int64
|
|
}) {
|
|
scriptResp, err := this.RPC().ScriptRPC().FindEnabledScript(this.AdminContext(), &pb.FindEnabledScriptRequest{ScriptId: params.ScriptId})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
|
|
var script = scriptResp.Script
|
|
if script == nil {
|
|
this.NotFound("script", params.ScriptId)
|
|
return
|
|
}
|
|
|
|
this.Data["script"] = maps.Map{
|
|
"id": script.Id,
|
|
"name": script.Name,
|
|
"filename": script.Filename,
|
|
"code": script.Code,
|
|
"isOn": script.IsOn,
|
|
}
|
|
|
|
this.Show()
|
|
}
|