Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package libraries
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ip-library/iplibraryutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type CreateAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CreateAction) Init() {
|
||||
this.Nav("", "", "create")
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunGet(params struct {
|
||||
LibraryFileId int64
|
||||
}) {
|
||||
// 检查权限
|
||||
if !iplibraryutils.CanAccess() {
|
||||
return
|
||||
}
|
||||
this.Data["canAccess"] = true
|
||||
|
||||
// 初始化
|
||||
this.Data["updatingLibraryFile"] = nil
|
||||
|
||||
if params.LibraryFileId > 0 {
|
||||
libraryFileResp, err := this.RPC().IPLibraryFileRPC().FindIPLibraryFile(this.AdminContext(), &pb.FindIPLibraryFileRequest{IpLibraryFileId: params.LibraryFileId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var libraryFile = libraryFileResp.IpLibraryFile
|
||||
if libraryFile != nil {
|
||||
this.Data["updatingLibraryFile"] = maps.Map{
|
||||
"id": libraryFile.Id,
|
||||
"name": libraryFile.Name,
|
||||
"template": libraryFile.Template,
|
||||
"emptyValues": libraryFile.EmptyValues,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package libraries
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type DeleteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteAction) RunPost(params struct {
|
||||
LibraryFileId int64
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.IPLibraryFile_LogDeleteIPLibraryFile, params.LibraryFileId)
|
||||
|
||||
_, err := this.RPC().IPLibraryFileRPC().DeleteIPLibraryFile(this.AdminContext(), &pb.DeleteIPLibraryFileRequest{IpLibraryFileId: params.LibraryFileId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package libraries
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ip-library/iplibraryutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "library")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Data["canAccess"] = iplibraryutils.CanAccess()
|
||||
|
||||
librariesResp, err := this.RPC().IPLibraryFileRPC().FindAllFinishedIPLibraryFiles(this.AdminContext(), &pb.FindAllFinishedIPLibraryFilesRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var libraryMaps = []maps.Map{}
|
||||
for _, library := range librariesResp.IpLibraryFiles {
|
||||
if library.EmptyValues == nil {
|
||||
library.EmptyValues = []string{}
|
||||
}
|
||||
libraryMaps = append(libraryMaps, maps.Map{
|
||||
"id": library.Id,
|
||||
"name": library.Name,
|
||||
"template": library.Template,
|
||||
"emptyValues": library.EmptyValues,
|
||||
"generatedTime": timeutil.FormatTime("Y-m-d H:i:s", library.GeneratedAt),
|
||||
"generatedFileId": library.GeneratedFileId,
|
||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", library.CreatedAt),
|
||||
})
|
||||
}
|
||||
this.Data["libraries"] = libraryMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user