diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index bd04fca8..433282db 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -5,6 +5,7 @@ import ( "strings" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/web/html" kit "shylinux.com/x/toolkits" ) @@ -217,7 +218,31 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands // LIST, func() { _list_prunes(m, arg[0], arg[1], arg[3:]...) }, ) }}, - EXPORT: {Name: "export key sub type file", Hand: func(m *ice.Message, arg ...string) { + EXPORT: {Name: "export index auto", Help: "导出数据", Actions: ice.MergeActions(ice.Actions{ + IMPORT: {Hand: func(m *ice.Message, arg ...string) { + HashSelect(m).Table(func(value ice.Maps) { + if value[STATUS] != DISABLE { + m.Cmd(IMPORT, value["index"], "", value["type"]) + } + }) + }}, + EXPORT: {Hand: func(m *ice.Message, arg ...string) { + HashSelect(m).Table(func(value ice.Maps) { + if value[STATUS] != DISABLE { + m.Cmd(EXPORT, value["index"], "", value["type"]) + } + }) + }}, + ENABLE: {Hand: func(m *ice.Message, arg ...string) { HashModify(m, STATUS, ENABLE) }}, + DISABLE: {Hand: func(m *ice.Message, arg ...string) { HashModify(m, STATUS, DISABLE) }}, + }, ExportHashAction(SHORT, "index", FIELD, "time,index,type,status")), Hand: func(m *ice.Message, arg ...string) { + if len(arg) < 2 { + HashSelect(m, arg...).RewriteAppend(func(value, key string, index int) string { + kit.If(key == STATUS, func() { value = kit.Select(ENABLE, value) }) + return value + }).PushAction().Action(html.FILTER) + return + } m.OptionDefault(CACHE_LIMIT, "-1") file := _mdb_export_file(m, arg...) kit.Switch(arg[2], diff --git a/conf.go b/conf.go index 0c4c7a6b..aede53d7 100644 --- a/conf.go +++ b/conf.go @@ -356,6 +356,8 @@ const ( // mdb INPUTS = "inputs" CREATE = "create" SELECT = "select" + IMPORT = "import" + EXPORT = "export" KEY = "key" VALUE = "value" diff --git a/init.go b/init.go index b6b34158..56a01384 100644 --- a/init.go +++ b/init.go @@ -60,6 +60,7 @@ var Index = &Context{Name: ICE, Help: "冰山模块", Commands: Commands{ INIT: {Hand: func(m *Message, arg ...string) { m.Cmd(kit.Keys(MDB, CTX_INIT)) m.Cmd(CTX_INIT) + m.Cmd(EXPORT, IMPORT) m.Cmd(SOURCE, ETC_INIT_SHY) loadImportant(m) m.Cmd(CTX_OPEN) @@ -71,6 +72,7 @@ var Index = &Context{Name: ICE, Help: "冰山模块", Commands: Commands{ m.GoSleep300ms(func() { m.root.Option(EXIT, kit.Select("0", arg, 0)) m.Cmd(SOURCE, ETC_EXIT_SHY) + m.Cmd(EXPORT, EXPORT) m.Cmd(CTX_EXIT) removeImportant(m) }) diff --git a/misc/ssh/relay/relay.go b/misc/ssh/relay/relay.go index d7ac02bb..88192e4a 100644 --- a/misc/ssh/relay/relay.go +++ b/misc/ssh/relay/relay.go @@ -60,6 +60,7 @@ type relay struct { ice.Hash ice.Code checkbox string `data:"true"` + export string `data:"true"` short string `data:"machine"` field string `data:"time,icons,machine,username,host,port,portal,dream,module,version,commitTime,compileTime,bootTime,go,git,package,shell,kernel,arch,vcpu,ncpu,mhz,mem,disk,network,listen,socket,proc,vendor"` create string `name:"create host* port=22 username machine icons"`