diff --git a/src/main.go b/src/main.go index 0722396..99f1dba 100644 --- a/src/main.go +++ b/src/main.go @@ -13,6 +13,6 @@ import ( func main() { print(ice.Run()) } func init() { - ice.Info.NodeMain = "web.team.production.portal" + ice.Info.NodeMain = "web.team.operation.portal" ice.Info.CodeMain = "src/operation/portal.go" -} \ No newline at end of file +} diff --git a/src/operation/container.go b/src/operation/container.go index 3748057..8c2646d 100644 --- a/src/operation/container.go +++ b/src/operation/container.go @@ -12,14 +12,16 @@ import ( ) type container struct { + ice.Space Table - order string `data:"1"` - fields string `data:"name,module,version"` - create string `name:"create uid* domain module version" role:"leader"` - remove string `name:"remove" role:"leader"` - apply string `name:"apply" role:"void"` - rename string `name:"rename name" role:"void"` - open string `name:"open" role:"void"` + order string `data:"1"` + fields string `data:"space,name"` + foreach string `name:"foreach" help:"遍历" icon:"bi bi-card-list"` + create string `name:"create uid* domain module version" role:"leader"` + remove string `name:"remove" role:"leader"` + apply string `name:"apply" role:"void"` + rename string `name:"rename name" role:"void"` + open string `name:"open" role:"void"` } 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...) } } +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) { 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) { 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) - 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.Length() > 0 { - m.Action() - } - }) + kit.If(m.Length() == 0, func() { m.EchoInfoButton("请申请云主机", s.Apply) }) + if m.IsTech() { + m.Action(s.Foreach, s.Create, s.Apply) + } else if s.IsLeader(m) { + m.Action(s.Create, s.Apply) + } else if m.Length() > 0 { + m.Action() + } } 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) - m.EchoIFrame(web.S(arg[1])) + m.EchoIFrame(web.S(m.Append(web.SPACE))) } m.Display("").DisplayCSS("") } func (s container) Apply(m *ice.Message, arg ...string) { s.Transaction(m, func() { 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)) - if m.Warn(msg.Length() == 0, "容器不够用啦!") { + 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 msg.Length() == 0 { + m.Echo("主机不够用啦!请等待管理员添加。") return } - s.Update(m, m.OptionSimple(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)) + s.Update(m, m.OptionSimple(model.CLOUD_UID, model.USER_UID), msg.AppendSimple(model.UID)...) + 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) { - 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{}) } diff --git a/src/operation/container.js b/src/operation/container.js index 0e4caa8..eb02002 100644 --- a/src/operation/container.js +++ b/src/operation/container.js @@ -2,8 +2,8 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onimport.myView(can, msg, function(value) { return [ {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.module, value.version]}, + {view: html.STATUS, list: [value.uid && value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]}, + {view: html.STATUS, list: [value.space]}, ] }) }, }) \ No newline at end of file diff --git a/src/operation/model/model.go b/src/operation/model/model.go index d8cdb01..0cfbeb2 100644 --- a/src/operation/model/model.go +++ b/src/operation/model/model.go @@ -32,10 +32,8 @@ type Container struct { db.ModelWithUID CloudUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"` - Name string `gorm:"type:varchar(32);index"` - Module string `gorm:"type:varchar(255);index"` - Version string `gorm:"type:varchar(32);index"` - Domain string `gorm:"type:char(255);index"` + Space string `gorm:"type:char(128);uniqueIndex"` + Name string `gorm:"type:char(64)"` } func init() { db.CmdModels("", &UserCloud{}, &Cloud{}, &Release{}, &Container{}) } diff --git a/src/operation/portal.json b/src/operation/portal.json index 84000f6..bfa77c4 100644 --- a/src/operation/portal.json +++ b/src/operation/portal.json @@ -1,6 +1,6 @@ { "portal": "系统运维", - "container": "容器", + "container": "云主机", "release": "发布", "icons": { "container": "https://img.icons8.com/officel/80/activity-grid.png",