This commit is contained in:
IT 老营长 @云轩领航-创始人 2025-02-23 08:03:35 +08:00
parent b9a4ee596e
commit af29281507
5 changed files with 38 additions and 28 deletions

View File

@ -13,6 +13,6 @@ import (
func main() { print(ice.Run()) } func main() { print(ice.Run()) }
func init() { func init() {
ice.Info.NodeMain = "web.team.production.portal" ice.Info.NodeMain = "web.team.operation.portal"
ice.Info.CodeMain = "src/operation/portal.go" ice.Info.CodeMain = "src/operation/portal.go"
} }

View File

@ -12,14 +12,16 @@ import (
) )
type container struct { type container struct {
ice.Space
Table Table
order string `data:"1"` order string `data:"1"`
fields string `data:"name,module,version"` fields string `data:"space,name"`
create string `name:"create uid* domain module version" role:"leader"` foreach string `name:"foreach" help:"遍历" icon:"bi bi-card-list"`
remove string `name:"remove" role:"leader"` create string `name:"create uid* domain module version" role:"leader"`
apply string `name:"apply" role:"void"` remove string `name:"remove" role:"leader"`
rename string `name:"rename name" role:"void"` apply string `name:"apply" role:"void"`
open string `name:"open" role:"void"` rename string `name:"rename name" role:"void"`
open string `name:"open" role:"void"`
} }
func (s container) Inputs(m *ice.Message, arg ...string) { func (s container) Inputs(m *ice.Message, arg ...string) {
@ -30,6 +32,13 @@ func (s container) Inputs(m *ice.Message, arg ...string) {
s.Table.Inputs(m, arg...) s.Table.Inputs(m, arg...)
} }
} }
func (s container) Foreach(m *ice.Message, arg ...string) {
m.Cmdy(web.SPACE, "20250211-service", "web.chat.dev.service.gateway", m.ActionKey()).Table(func(value ice.Maps) {
if s.Select(m.Spawn(), web.SPACE, value[web.SPACE]).Length() == 0 {
s.Insert(m, web.SPACE, value[web.SPACE])
}
})
}
func (s container) Create(m *ice.Message, arg ...string) { func (s container) Create(m *ice.Message, arg ...string) {
s.Table.Insert(m, kit.Simple(arg, m.OptionSimple(model.CLOUD_UID))...) s.Table.Insert(m, kit.Simple(arg, m.OptionSimple(model.CLOUD_UID))...)
} }
@ -39,31 +48,34 @@ func (s container) Rename(m *ice.Message, arg ...string) {
func (s container) List(m *ice.Message, arg ...string) { func (s container) List(m *ice.Message, arg ...string) {
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, model.CLOUD_UID, arg[0], model.USER_UID, m.Option(model.USER_UID)).PushAction(s.Open, s.Rename) s.Select(m, model.CLOUD_UID, arg[0], model.USER_UID, m.Option(model.USER_UID)).PushAction(s.Open, s.Rename)
kit.If(m.Length() == 0, func() { m.EchoInfoButton("请申请云容器", s.Apply) }) kit.If(m.Length() == 0, func() { m.EchoInfoButton("请申请云主机", s.Apply) })
kit.If(s.IsLeader(m), func() { m.Action(s.Create, s.Apply) }, func() { if m.IsTech() {
if m.Length() > 0 { m.Action(s.Foreach, s.Create, s.Apply)
m.Action() } else if s.IsLeader(m) {
} m.Action(s.Create, s.Apply)
}) } else if m.Length() > 0 {
m.Action()
}
} else { } else {
s.SelectDetail(m, model.UID, arg[1], model.CLOUD_UID, arg[0], model.USER_UID, m.Option(model.USER_UID)).PushAction(s.Open, s.Rename) s.SelectDetail(m, model.UID, arg[1], model.CLOUD_UID, arg[0], model.USER_UID, m.Option(model.USER_UID)).PushAction(s.Open, s.Rename)
m.EchoIFrame(web.S(arg[1])) m.EchoIFrame(web.S(m.Append(web.SPACE)))
} }
m.Display("").DisplayCSS("") m.Display("").DisplayCSS("")
} }
func (s container) Apply(m *ice.Message, arg ...string) { func (s container) Apply(m *ice.Message, arg ...string) {
s.Transaction(m, func() { s.Transaction(m, func() {
msg := m.Spawn() msg := m.Spawn()
msg = s.Limit(msg, 1).SelectForUpdate(msg, "(user_uid IS NULL OR user_uid = '') AND cloud_uid = ?", m.Option(model.CLOUD_UID)) msg = s.Limit(msg, 1).SelectForUpdate(msg, "(user_uid IS NULL OR user_uid = '') AND (cloud_uid = ? OR cloud_uid IS NULL OR cloud_uid = '')", m.Option(model.CLOUD_UID))
if m.Warn(msg.Length() == 0, "容器不够用啦!") { if msg.Length() == 0 {
m.Echo("主机不够用啦!请等待管理员添加。")
return return
} }
s.Update(m, m.OptionSimple(model.USER_UID), msg.AppendSimple(model.UID)...) s.Update(m, m.OptionSimple(model.CLOUD_UID, model.USER_UID), msg.AppendSimple(model.UID)...)
m.Cmd(web.SPACE, msg.Append(model.UID), aaa.USER, mdb.CREATE, aaa.TECH, m.Option(model.USER_UID), kit.Dict(ice.MSG_USERROLE, aaa.TECH)) m.Cmd(web.SPACE, msg.Append(web.SPACE), aaa.USER, mdb.CREATE, aaa.TECH, m.Option(model.USER_UID), kit.Dict(ice.MSG_USERROLE, aaa.TECH))
}) })
} }
func (s container) Open(m *ice.Message, arg ...string) { func (s container) Open(m *ice.Message, arg ...string) {
m.ProcessOpen(m.Options(ice.MSG_USERPOD, "").MergePod(m.Option(model.UID))) m.ProcessOpen(m.Options(ice.MSG_USERPOD, "").MergePod(m.Option(web.SPACE)))
} }
func init() { ice.TeamCtxCmd(container{}) } func init() { ice.TeamCtxCmd(container{}) }

View File

@ -2,8 +2,8 @@ Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.name||"container", can.onimport.titleAction(can, value)]}, {view: html.TITLE, list: [value.name||"container", can.onimport.titleAction(can, value)]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]}, {view: html.STATUS, list: [value.uid && value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]},
{view: html.STATUS, list: [value.module, value.version]}, {view: html.STATUS, list: [value.space]},
] }) ] })
}, },
}) })

View File

@ -32,10 +32,8 @@ type Container struct {
db.ModelWithUID db.ModelWithUID
CloudUID string `gorm:"type:char(32);index"` CloudUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:varchar(32);index"` Space string `gorm:"type:char(128);uniqueIndex"`
Module string `gorm:"type:varchar(255);index"` Name string `gorm:"type:char(64)"`
Version string `gorm:"type:varchar(32);index"`
Domain string `gorm:"type:char(255);index"`
} }
func init() { db.CmdModels("", &UserCloud{}, &Cloud{}, &Release{}, &Container{}) } func init() { db.CmdModels("", &UserCloud{}, &Cloud{}, &Release{}, &Container{}) }

View File

@ -1,6 +1,6 @@
{ {
"portal": "系统运维", "portal": "系统运维",
"container": "容器", "container": "云主机",
"release": "发布", "release": "发布",
"icons": { "icons": {
"container": "https://img.icons8.com/officel/80/activity-grid.png", "container": "https://img.icons8.com/officel/80/activity-grid.png",