mirror of
https://shylinux.com/x/operation
synced 2025-04-25 01:08:04 +08:00
add some
This commit is contained in:
parent
733d50beb1
commit
a2a0cb8960
@ -1,8 +1,26 @@
|
|||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
import "shylinux.com/x/ice"
|
import (
|
||||||
|
"shylinux.com/x/ice"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
|
||||||
type client struct{ Table }
|
"shylinux.com/x/operation/src/dashboard/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type client struct {
|
||||||
|
Table
|
||||||
|
config string `name:"config host* port* username* password* database*" role:"leader"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s client) List(m *ice.Message, arg ...string) {
|
||||||
|
if len(arg) == 1 {
|
||||||
|
s.Fields(m, model.HOST, model.PORT, model.USERNAME, model.DATABASE)
|
||||||
|
s.SelectDetail(m, model.UID, arg[0]).PushAction(s.Config).Action(s.Config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (s client) Config(m *ice.Message, arg ...string) {
|
||||||
|
s.Update(m, kit.Dict(arg), model.UID, m.Option(model.CLIENT_UID))
|
||||||
|
}
|
||||||
|
|
||||||
func init() { ice.TeamCtxCmd(client{}) }
|
func init() { ice.TeamCtxCmd(client{}) }
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@ package dashboard
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
|
|
||||||
"shylinux.com/x/operation/src/dashboard/model"
|
"shylinux.com/x/operation/src/dashboard/model"
|
||||||
@ -19,6 +21,14 @@ func (s Table) Inputs(m *ice.Message, arg ...string) {
|
|||||||
s.InputsListRole(m, UserClientRoleList, arg...)
|
s.InputsListRole(m, UserClientRoleList, arg...)
|
||||||
case model.CLIENT_TYPE:
|
case model.CLIENT_TYPE:
|
||||||
s.InputsList(m, ClientTypeList, arg...)
|
s.InputsList(m, ClientTypeList, arg...)
|
||||||
|
case web.SPACE:
|
||||||
|
s.Hash.Inputs(m, arg...)
|
||||||
|
case ctx.INDEX:
|
||||||
|
s.Hash.Inputs(m, arg...)
|
||||||
|
case model.TABLES:
|
||||||
|
s.Hash.Inputs(m, ctx.INDEX)
|
||||||
|
case model.FIELDS:
|
||||||
|
m.Push(arg[0], "count(*)")
|
||||||
default:
|
default:
|
||||||
s.Table.Inputs(m, arg...)
|
s.Table.Inputs(m, arg...)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ const (
|
|||||||
ROLE = "role"
|
ROLE = "role"
|
||||||
TITLE = "title"
|
TITLE = "title"
|
||||||
CONTENT = "content"
|
CONTENT = "content"
|
||||||
|
CREATED_AT = "created_at"
|
||||||
USER_UID = "user_uid"
|
USER_UID = "user_uid"
|
||||||
USER_CLIENT_ROLE = "user_client_role"
|
USER_CLIENT_ROLE = "user_client_role"
|
||||||
CLIENT_UID = "client_uid"
|
CLIENT_UID = "client_uid"
|
||||||
@ -17,6 +18,15 @@ const (
|
|||||||
SUMMARY_UID = "summary_uid"
|
SUMMARY_UID = "summary_uid"
|
||||||
COMPANY_UID = "company_uid"
|
COMPANY_UID = "company_uid"
|
||||||
CITY_UID = "city_uid"
|
CITY_UID = "city_uid"
|
||||||
|
HOST = "host"
|
||||||
|
PORT = "port"
|
||||||
|
USERNAME = "username"
|
||||||
|
PASSWORD = "password"
|
||||||
|
DATABASE = "database"
|
||||||
|
TABLES = "tables"
|
||||||
|
FIELDS = "fields"
|
||||||
|
VALUE = "value"
|
||||||
|
SCORE = "score"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserClient struct {
|
type UserClient struct {
|
||||||
@ -26,10 +36,21 @@ type UserClient struct {
|
|||||||
type Client struct {
|
type Client struct {
|
||||||
db.ModelPlace
|
db.ModelPlace
|
||||||
CompanyUID string `gorm:"type:char(32);index"`
|
CompanyUID string `gorm:"type:char(32);index"`
|
||||||
|
Host string `gorm:"type:varchar(32)"`
|
||||||
|
Port string `gorm:"type:varchar(8)"`
|
||||||
|
Username string `gorm:"type:varchar(32)"`
|
||||||
|
Password string `gorm:"type:varchar(32)"`
|
||||||
|
Database string `gorm:"type:varchar(32)"`
|
||||||
}
|
}
|
||||||
type Summary struct {
|
type Summary struct {
|
||||||
db.ModelContent
|
db.ModelContent
|
||||||
ClientUID string `gorm:"type:char(32);index"`
|
ClientUID string `gorm:"type:char(32);index"`
|
||||||
|
Space string `gorm:"type:varchar(32)"`
|
||||||
|
Index string `gorm:"type:varchar(32)"`
|
||||||
|
Value float32 `gorm:"default:0"`
|
||||||
|
Score float32 `gorm:"default:0"`
|
||||||
|
Tables string `gorm:"type:varchar(32)"`
|
||||||
|
Fields string `gorm:"type:varchar(32)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { db.CmdModels("", &UserClient{}, &Client{}, &Summary{}) }
|
func init() { db.CmdModels("", &UserClient{}, &Client{}, &Summary{}) }
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
{
|
{
|
||||||
"portal": "数据分析",
|
"portal": "数据分析",
|
||||||
|
"client": "连接配置",
|
||||||
"summary": "数据汇总",
|
"summary": "数据汇总",
|
||||||
|
"config": "配置",
|
||||||
"icons": {
|
"icons": {
|
||||||
|
"client": "https://img.icons8.com/officel/80/activity-grid.png",
|
||||||
"summary": "https://img.icons8.com/officel/80/activity-grid.png"
|
"summary": "https://img.icons8.com/officel/80/activity-grid.png"
|
||||||
},
|
},
|
||||||
"input": {
|
"input": {
|
||||||
"My Client": "我的数据",
|
"My Client": "我的数据",
|
||||||
"user_client_role": "用户角色",
|
"user_client_role": "用户角色",
|
||||||
"client_name": "数据名称",
|
"client_name": "数据名称",
|
||||||
"client_type": "数据类型"
|
"client_type": "数据类型",
|
||||||
|
"database": "数据库"
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"user_client_role": {
|
"user_client_role": {
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gorm.io/driver/mysql"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/logger"
|
||||||
|
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
|
|
||||||
"shylinux.com/x/operation/src/dashboard/model"
|
"shylinux.com/x/operation/src/dashboard/model"
|
||||||
@ -11,15 +18,50 @@ type summary struct {
|
|||||||
Table
|
Table
|
||||||
client client
|
client client
|
||||||
userClient userClient
|
userClient userClient
|
||||||
create string `name:"create title* content*" role:"leader"`
|
create string `name:"create title* space index* score" role:"leader"`
|
||||||
|
modify string `name:"modify title* space index* score" role:"leader"`
|
||||||
|
remove string `name:"remove" role:"leader"`
|
||||||
|
scan string `name:"scan" role:"leader"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s summary) Create(m *ice.Message, arg ...string) {
|
func (s summary) Create(m *ice.Message, arg ...string) {
|
||||||
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.CLIENT_UID))...)
|
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.USER_UID, model.CLIENT_UID))...)
|
||||||
s.RecordEventWithName(m, "")
|
s.RecordEventWithName(m, "")
|
||||||
}
|
}
|
||||||
func (s summary) List(m *ice.Message, arg ...string) {
|
func (s summary) Remove(m *ice.Message, arg ...string) {
|
||||||
s.TablesWithRole(m, arg, s.userClient, s.client, s, model.TITLE, model.CONTENT).Display("")
|
s.Table.Delete(m, m.OptionSimple(model.CLIENT_UID, model.UID)...)
|
||||||
|
}
|
||||||
|
func (s summary) Modify(m *ice.Message, arg ...string) {
|
||||||
|
s.Table.Update(m, kit.Dict(arg), m.OptionSimple(model.CLIENT_UID, model.UID)...)
|
||||||
|
}
|
||||||
|
func (s summary) Scan(m *ice.Message, arg ...string) {
|
||||||
|
if false {
|
||||||
|
s.List(m, arg...).Table(func(value ice.Maps) {
|
||||||
|
msg := m.Cmd(web.SPACE, value[web.SPACE], value[ctx.INDEX], s.Select, kit.Dict(mdb.FIELDS, kit.Select("count(*)", value[model.FIELDS])))
|
||||||
|
s.Update(m, kit.Dict(model.VALUE, msg.Append(msg.Append(ice.MSG_APPEND))), model.UID, value[model.UID])
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.Open(m, func(db *gorm.DB) {
|
||||||
|
s.List(m, arg...).Table(func(value ice.Maps) {
|
||||||
|
db = db.Table(s.TableName(kit.Join(kit.Slice(kit.Split(value[ctx.INDEX], "."), -2), ".")))
|
||||||
|
msg := s.Rows(m.Spawn(), db.Select(kit.Select("count(*)", value[model.FIELDS])))
|
||||||
|
s.Update(m, kit.Dict(model.VALUE, msg.Append(msg.Append(ice.MSG_APPEND))), model.UID, value[model.UID])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
func (s summary) List(m *ice.Message, arg ...string) *ice.Message {
|
||||||
|
s.Orders(m, model.SCORE, s.Desc(model.CREATED_AT))
|
||||||
|
s.Select(m, model.CLIENT_UID, arg[0]).Action(s.Create, s.Scan).PushAction(s.Modify, s.Remove).Display("").DisplayCSS("")
|
||||||
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.TeamCtxCmd(summary{}) }
|
func init() { ice.TeamCtxCmd(summary{}) }
|
||||||
|
|
||||||
|
func (s summary) Open(m *ice.Message, cb func(*gorm.DB)) {
|
||||||
|
msg := m.Cmd(s.client, s.Select, model.UID, m.Option(model.CLIENT_UID))
|
||||||
|
dsn := kit.Format("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True", msg.Append(model.USERNAME), msg.Append(model.PASSWORD), msg.Append(model.HOST), msg.Append(model.PORT), msg.Append(model.DATABASE))
|
||||||
|
if db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{Logger: logger.Default.LogMode(logger.Info)}); !m.Warn(err) {
|
||||||
|
cb(db)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
Volcanos(chat.ONIMPORT, {
|
Volcanos(chat.ONIMPORT, {
|
||||||
_init: function(can, msg) { can.onimport.shareTitle(can, msg)
|
_init: function(can, msg) {
|
||||||
can.onimport.itemcards(can, msg, function(value) { return [
|
can.page.Append(can, can._output, msg.Table(function(value) {
|
||||||
{view: html.TITLE, list: [value.title]},
|
return {view: html.ITEM, list: [{view: ["value", "", value.value]}, {view: ["title", "", value.title]}], oncontextmenu: function(event) {
|
||||||
{view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at), value.user_name]},
|
can.user.carteItem(event, can, value)
|
||||||
{view: html.OUTPUT, list: [value.content]},
|
}}
|
||||||
] })
|
}))
|
||||||
},
|
},
|
||||||
})
|
})
|
Loading…
x
Reference in New Issue
Block a user