mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt toast
This commit is contained in:
parent
e98b9848fe
commit
d62af7bc90
@ -68,9 +68,10 @@ func init() {
|
||||
m.OptionDefault(FG, BLACK, BG, WHITE)
|
||||
_qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0))
|
||||
} else {
|
||||
m.OptionDefault(SIZE, kit.Select("360", "280", m.IsMobileUA()))
|
||||
// m.OptionDefault(SIZE, kit.Select("360", "280", m.IsMobileUA()))
|
||||
m.Option(FG, kit.Select(m.Option(ice.MSG_FG), arg, 1))
|
||||
m.Option(BG, kit.Select(m.Option(ice.MSG_BG), arg, 2))
|
||||
m.Option(SIZE, kit.Select(m.OptionDefault(SIZE, "360"), arg, 3))
|
||||
switch m.Option(ice.MSG_THEME) {
|
||||
case LIGHT, WHITE:
|
||||
m.OptionDefault(FG, BLACK, BG, WHITE)
|
||||
|
@ -103,7 +103,7 @@ func _runtime_hostinfo(m *ice.Message) {
|
||||
}
|
||||
}
|
||||
func _runtime_diskinfo(m *ice.Message) {
|
||||
m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", lex.SP, lex.NL).Table(func(index int, value ice.Maps, head []string) {
|
||||
m.Spawn().Split(kit.Replace(m.Cmdx(SYSTEM, "df", "-h"), "Mounted on", "Mountedon"), "", lex.SP, lex.NL).Table(func(value ice.Maps, index int, head []string) {
|
||||
kit.If(strings.HasPrefix(value["Filesystem"], "/dev"), func() { m.Push("", value, head) })
|
||||
})
|
||||
m.RenameAppend("%iused", "piused", "Use%", "Usep")
|
||||
|
@ -88,12 +88,12 @@ func init() {
|
||||
m.StatusTimeCount(stat)
|
||||
}},
|
||||
aaa.LOCATION: {Hand: func(m *ice.Message, arg ...string) {
|
||||
GoToast(mdb.HashSelects(m).Sort(mdb.COUNT, ice.INT_R), "", func(toast func(string, int, int)) []string {
|
||||
m.Table(func(index int, value ice.Maps) {
|
||||
GoToast(mdb.HashSelects(m).Sort(mdb.COUNT, ice.INT_R), func(toast func(string, int, int)) []string {
|
||||
m.Table(func(value ice.Maps, index, total int) {
|
||||
if value[aaa.LOCATION] == "" {
|
||||
location := kit.Format(kit.Value(SpideGet(m, "http://opendata.baidu.com/api.php?co=&resource_id=6006&oe=utf8", "query", value[mdb.NAME]), "data.0.location"))
|
||||
mdb.HashModify(m, mdb.HASH, value[mdb.HASH], aaa.LOCATION, location)
|
||||
toast(kit.Select(value[mdb.NAME], location), index, m.Length())
|
||||
toast(kit.Select(value[mdb.NAME], location), index, total)
|
||||
m.Sleep300ms()
|
||||
}
|
||||
})
|
||||
|
@ -158,14 +158,10 @@ func _dream_binary(m *ice.Message, p string) {
|
||||
if bin := path.Join(m.Option(cli.CMD_DIR), ice.BIN_ICE_BIN); nfs.Exists(m, bin) {
|
||||
return
|
||||
} else if kit.IsUrl(p) || strings.HasPrefix(p, S()) {
|
||||
GoToast(m, DOWNLOAD, func(toast func(string, int, int)) (list []string) {
|
||||
GoToast(m, func(toast func(string, int, int)) []string {
|
||||
begin := time.Now()
|
||||
SpideSave(m, bin, kit.MergeURL(p, cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH), func(count, total, value int) {
|
||||
if strings.HasPrefix(p, S()) {
|
||||
toast(m.Option(mdb.NAME), count, total)
|
||||
} else {
|
||||
toast(m.Option(mdb.NAME)+"\n"+kit.FormatShow(cli.COST, kit.FmtDuration(time.Now().Sub(begin))), count, total)
|
||||
}
|
||||
toast(m.Option(mdb.NAME)+lex.NL+kit.FormatShow(cli.COST, kit.FmtDuration(time.Now().Sub(begin))), count, total)
|
||||
})
|
||||
return nil
|
||||
})
|
||||
@ -310,8 +306,8 @@ func init() {
|
||||
})
|
||||
}},
|
||||
cli.BUILD: {Name: "build name", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
compile := cli.SystemFind(m, "go") != ""
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
m.Cmd("", FOR_FLOW, m.Option(mdb.NAME), kit.JoinWord(cli.SH, ice.ETC_MISS_SH), func(p string) bool {
|
||||
if compile && nfs.Exists(m, path.Join(p, ice.SRC_MAIN_GO)) {
|
||||
return false
|
||||
@ -342,27 +338,23 @@ func init() {
|
||||
m.ProcessHold()
|
||||
}},
|
||||
FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||
list := []string{}
|
||||
DreamEach(m.Spawn(ice.Maps{ice.MSG_DAEMON: ""}), m.Option(mdb.NAME), "", func(name string) { list = append(list, name) })
|
||||
msg := m.Spawn()
|
||||
DreamEach(m.Spawn(ice.Maps{ice.MSG_DAEMON: ""}), m.Option(mdb.NAME), "", func(name string) { msg.Push(SPACE, name) })
|
||||
m.Options(ctx.DISPLAY, PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
|
||||
PushNoticeGrow(m.Options(ice.MSG_COUNT, "0"), strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
|
||||
return len(buf), nil
|
||||
}, func() error { return nil }))
|
||||
GoToast(m, "", func(toast func(string, int, int)) []string {
|
||||
kit.For(list, func(index int, name string) {
|
||||
toast(name, index, len(list))
|
||||
p := path.Join(ice.USR_LOCAL_WORK, name)
|
||||
switch cb := m.OptionCB("").(type) {
|
||||
case func(string) bool:
|
||||
if cb(p) {
|
||||
return
|
||||
}
|
||||
GoToastTable(msg, SPACE, func(value ice.Maps) {
|
||||
p := path.Join(ice.USR_LOCAL_WORK, value[SPACE])
|
||||
switch cb := m.OptionCB("").(type) {
|
||||
case func(string) bool:
|
||||
if cb(p) {
|
||||
return
|
||||
}
|
||||
PushNoticeGrow(m, strings.ReplaceAll(kit.Format("[%s]%s$ %s\n", time.Now().Format(ice.MOD_TIME_ONLY), name, m.Option(ice.CMD)), lex.NL, "\r\n"))
|
||||
m.Cmd(cli.SYSTEM, kit.Split(m.Option(ice.CMD)), kit.Dict(cli.CMD_DIR, p)).Sleep300ms()
|
||||
PushNoticeGrow(m, "\r\n\r\n\r\n")
|
||||
})
|
||||
return nil
|
||||
}
|
||||
PushNoticeGrow(m, strings.ReplaceAll(kit.Format("[%s]%s$ %s\r\n", time.Now().Format(ice.MOD_TIME_ONLY), value[SPACE], m.Option(ice.CMD)), lex.NL, "\r\n"))
|
||||
m.Cmd(cli.SYSTEM, kit.Split(m.Option(ice.CMD)), kit.Dict(cli.CMD_DIR, p)).Sleep300ms()
|
||||
PushNoticeGrow(m, "\r\n\r\n\r\n")
|
||||
})
|
||||
}},
|
||||
ctx.CMDS: {Name: "cmds name cmds*", Help: "命令", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -495,8 +487,8 @@ func DreamEach(m *ice.Message, name string, status string, cb func(string)) *ice
|
||||
if len(list) == 0 {
|
||||
return m
|
||||
}
|
||||
GoToast(m, "", func(toast func(string, int, int)) []string {
|
||||
kit.For(list, func(index int, name string) { toast(name, index, len(list)); cb(name) })
|
||||
GoToast(m, func(toast func(string, int, int)) []string {
|
||||
kit.For(list, func(name string, index, total int) { toast(name, index, total); cb(name) })
|
||||
return nil
|
||||
})
|
||||
return m
|
||||
@ -514,10 +506,10 @@ func DreamListSpide(m *ice.Message, list []string, types string, cb func(dev, or
|
||||
kit.If(value[mdb.TYPE] == types, func() { list = append(list, value[mdb.NAME]) })
|
||||
})
|
||||
has := map[string]bool{}
|
||||
GoToast(m, "", func(toast func(name string, count, total int)) []string {
|
||||
kit.For(list, func(index int, dev string) {
|
||||
toast(dev, index, len(list))
|
||||
if origin := m.Cmdv(SPIDE, dev, CLIENT_ORIGIN); !has[origin] {
|
||||
GoToast(m, func(toast func(name string, count, total int)) []string {
|
||||
kit.For(list, func(dev string, index, total int) {
|
||||
toast(dev, index, total)
|
||||
if origin := SpideOrigin(m, dev); !has[origin] {
|
||||
has[origin] = true
|
||||
cb(dev, origin)
|
||||
}
|
||||
|
@ -10,14 +10,15 @@ fieldset.web.matrix>div.output>table.content div.item div.title>span { cursor:po
|
||||
fieldset.web.matrix>div.output>table.content div.item div.status i { font-size:var(--status-font-size); padding:0; }
|
||||
fieldset.web.matrix>div.output>table.content div.item div.action { margin-top:var(--input-margin); overflow:hidden; }
|
||||
fieldset.web.matrix>div.output>table.content div.item div.action input.icons { display:none; }
|
||||
fieldset.web.matrix>div.output>table.content div.item:hover { background-color:unset; color:unset; }
|
||||
fieldset.web.matrix>div.output>table.content div.item div.title:hover { background-color:unset; }
|
||||
fieldset.web.matrix>div.output>table.content div.item div.title span:hover { background-color:var(--hover-bg-color); }
|
||||
fieldset.web.matrix>div.output>table.content div.item div.status div.item:hover { background-color:var(--hover-bg-color); }
|
||||
fieldset.web.matrix>div.output>table.content div.item.stop div.title>span { color:var(--disable-fg-color); }
|
||||
fieldset.web.matrix>div.output>table.content div.item:hover { background-color:unset; color:unset; }
|
||||
fieldset.web.matrix>div.output>table.content div.item.notice { background-color:var(--notice-bg-color); color:var(--notice-fg-color); }
|
||||
fieldset.web.matrix>div.output>table.content div.item.danger { background-color:var(--danger-bg-color); color:var(--danger-fg-color); }
|
||||
fieldset.web.matrix>div.output>table.content div.item.danger div.status div.item { color:var(--danger-fg-color); }
|
||||
fieldset.web.matrix>div.output>table.content div.item.notice div.status div.item { color:var(--notice-fg-color); }
|
||||
fieldset.web.matrix>div.output>table.content div.item.stop div.title>span { color:var(--disable-fg-color); }
|
||||
fieldset.web.matrix>div.output>table.content tr:not(:hover) div.action { visibility:hidden; }
|
||||
body:not(.mobile) fieldset.web.matrix>div.output>table.content thead { z-index:2; }
|
||||
body:not(.mobile) fieldset.web.matrix>div.output>table.content th:first-child { position:sticky; left:2px; z-index:2; }
|
||||
|
@ -59,14 +59,16 @@ func _matrix_action(m *ice.Message, action string, arg ...string) {
|
||||
func _matrix_dream(m *ice.Message, action string, arg ...string) {
|
||||
m.Cmd(Space(m, m.Option(DOMAIN)), DREAM, kit.Select(m.ActionKey(), action), m.OptionSimple(mdb.NAME), arg)
|
||||
}
|
||||
func _matrix_cmd(m *ice.Message, cmd string, arg ...string) *ice.Message {
|
||||
return m.Cmdy(Space(m, kit.Keys(m.Option(DOMAIN), m.Option(mdb.NAME))), kit.Select(m.ActionKey(), cmd), arg)
|
||||
}
|
||||
|
||||
const MATRIX = "matrix"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
MATRIX: {Name: "matrix refresh", Help: "矩阵", Meta: kit.Dict(
|
||||
ice.CTX_ICONS, kit.Dict(STATUS, "bi bi-git"),
|
||||
ice.CTX_TRANS, kit.Dict(STATUS, "源码"),
|
||||
ice.CTX_ICONS, kit.Dict(STATUS, "bi bi-git"), ice.CTX_TRANS, kit.Dict(STATUS, "源码"),
|
||||
), Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(DREAM, mdb.INPUTS, arg) }},
|
||||
mdb.CREATE: {Name: "create name*=hi icons repos binary template", Hand: func(m *ice.Message, arg ...string) { m.Cmd(DREAM, mdb.CREATE, arg) }},
|
||||
@ -74,15 +76,16 @@ func init() {
|
||||
cli.START: {Hand: func(m *ice.Message, arg ...string) { _matrix_dream(m, "") }},
|
||||
cli.STOP: {Hand: func(m *ice.Message, arg ...string) { _matrix_dream(m, "") }},
|
||||
COMPILE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(Space(m, kit.Keys(m.Option(DOMAIN), m.Option(mdb.NAME))), COMPILE, cli.AMD64, cli.LINUX, ice.SRC_MAIN_GO).ProcessHold()
|
||||
_matrix_cmd(m, "", cli.AMD64, cli.LINUX, ice.SRC_MAIN_GO).ProcessHold()
|
||||
}},
|
||||
UPGRADE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(Space(m, kit.Keys(m.Option(DOMAIN), m.Option(mdb.NAME))), UPGRADE).Sleep3s()
|
||||
_matrix_cmd(m, "").ProcessRefresh().Sleep3s()
|
||||
}},
|
||||
INSTALL: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.OptionDefault(nfs.BINARY, UserHost(m)+S(m.Option(mdb.NAME)))
|
||||
if kit.IsIn(m.Cmdv(Space(m, m.Option(DOMAIN)), SPIDE, ice.DEV_IP, CLIENT_HOSTNAME), m.Cmd(tcp.HOST).Appendv(aaa.IP)...) {
|
||||
m.Option(nfs.BINARY, S(m.Option(mdb.NAME)))
|
||||
} else {
|
||||
m.OptionDefault(nfs.BINARY, UserHost(m)+S(m.Option(mdb.NAME)))
|
||||
}
|
||||
_matrix_dream(m, mdb.CREATE, kit.Simple(m.OptionSimple(mdb.ICONS, nfs.REPOS, nfs.BINARY))...)
|
||||
_matrix_dream(m, cli.START)
|
||||
@ -92,21 +95,20 @@ func init() {
|
||||
_matrix_action(m, arg[1], arg[2:]...)
|
||||
return
|
||||
}
|
||||
GoToast(m, "", func(toast func(name string, count, total int)) []string {
|
||||
fields := kit.Split(mdb.Config(m, mdb.FIELD))
|
||||
GoToast(m, func(toast func(name string, count, total int)) []string {
|
||||
field := kit.Split(mdb.Config(m, mdb.FIELD))
|
||||
m.Options("space.timeout", cli.TIME_300ms, "dream.simple", ice.TRUE)
|
||||
kit.For(_matrix_list(m, "", fields...), func(domain string, index int, total int) {
|
||||
kit.For(_matrix_list(m, "", field...), func(domain string, index int, total int) {
|
||||
toast(domain, index, total)
|
||||
_matrix_list(m, domain, fields...)
|
||||
_matrix_list(m, domain, field...)
|
||||
})
|
||||
stat := map[string]int{}
|
||||
m.Table(func(value ice.Maps) { stat[value[mdb.TYPE]]++; stat[value[mdb.STATUS]]++ }).StatusTimeCount(stat)
|
||||
m.RewriteAppend(func(value, key string, index int) string {
|
||||
if key == mdb.ICONS && strings.HasPrefix(value, nfs.REQUIRE) && m.Appendv(DOMAIN)[index] != "" {
|
||||
value = kit.MergeURL(strings.Split(value, "?")[0], ice.POD, kit.Keys(m.Appendv(DOMAIN)[index], m.Appendv(mdb.NAME)[index]))
|
||||
}
|
||||
return value
|
||||
}).Sort("type,status,name,domain", []string{SERVER, WORKER, ""}, []string{cli.START, cli.STOP, ""}, "str_r", "str_r")
|
||||
m.StatusTimeCountStats(mdb.TYPE, mdb.STATUS)
|
||||
return nil
|
||||
}).Action(html.FILTER, mdb.CREATE).Display("")
|
||||
}},
|
||||
|
@ -48,24 +48,17 @@ func ParseLink(m *ice.Message, url string) ice.Maps {
|
||||
return list
|
||||
}
|
||||
func PushPodCmd(m *ice.Message, cmd string, arg ...string) *ice.Message {
|
||||
list := []string{}
|
||||
msg := m.Spawn()
|
||||
m.Cmds(SPACE, func(value ice.Maps) {
|
||||
kit.If(kit.IsIn(value[mdb.TYPE], WORKER), func() { list = append(list, value[mdb.NAME]) })
|
||||
kit.If(kit.IsIn(value[mdb.TYPE], WORKER), func() { msg.Push(SPACE, value[mdb.NAME]) })
|
||||
})
|
||||
if len(list) == 0 {
|
||||
return m
|
||||
}
|
||||
kit.If(m.Length() > 0 && len(m.Appendv(SPACE)) == 0, func() { m.Table(func(value ice.Maps) { m.Push(SPACE, "") }) })
|
||||
GoToast(m, "", func(toast func(string, int, int)) []string {
|
||||
kit.For(list, func(index int, space string) {
|
||||
toast(space, index, len(list))
|
||||
m.Cmd(SPACE, space, kit.Dict(ice.MSG_USERPOD, space), kit.Select(m.PrefixKey(), cmd), arg).Table(func(index int, val ice.Maps, head []string) {
|
||||
kit.If(!kit.IsIn(SPACE, head...), func() { head = append(head, SPACE) })
|
||||
val[SPACE] = kit.Keys(space, val[SPACE])
|
||||
m.Push("", val, head)
|
||||
})
|
||||
GoToastTable(msg, SPACE, func(value ice.Maps) {
|
||||
m.Cmd(SPACE, value[SPACE], kit.Dict(ice.MSG_USERPOD, value[SPACE]), kit.Select(m.PrefixKey(), cmd), arg).Table(func(val ice.Maps, index int, head []string) {
|
||||
kit.If(!kit.IsIn(SPACE, head...), func() { head = append(head, SPACE) })
|
||||
val[SPACE] = kit.Keys(value[SPACE], val[SPACE])
|
||||
m.Push("", val, head)
|
||||
})
|
||||
return nil
|
||||
})
|
||||
return m
|
||||
}
|
||||
@ -138,13 +131,21 @@ func ToastProcess(m *ice.Message, arg ...ice.Any) func(...ice.Any) {
|
||||
Toast(m, toastContent(m, ice.PROCESS, arg...), "", "-1", "", h)
|
||||
return func(arg ...ice.Any) { Toast(m, toastContent(m, ice.SUCCESS, arg...), "", cli.TIME_3s, "", h) }
|
||||
}
|
||||
func GoToast(m *ice.Message, title string, cb func(toast func(name string, count, total int)) []string) *ice.Message {
|
||||
h := kit.HashsUniq()
|
||||
icon, _total := Icons[ice.PROCESS], 0
|
||||
func GoToastTable(m *ice.Message, key string, cb func(value ice.Maps)) *ice.Message {
|
||||
if m.Length() == 0 {
|
||||
return m
|
||||
}
|
||||
return GoToast(m, func(toast func(string, int, int)) []string {
|
||||
m.Table(func(value ice.Maps, index, total int) { toast(value[key], index, total); cb(value) })
|
||||
return nil
|
||||
})
|
||||
}
|
||||
func GoToast(m *ice.Message, cb func(toast func(name string, count, total int)) []string) *ice.Message {
|
||||
icon, _total, h := Icons[ice.PROCESS], 1, kit.HashsUniq()
|
||||
toast := func(name string, count, total int) {
|
||||
kit.If(total == 0, func() { total = 1 })
|
||||
Toast(m, kit.Format("%s %s %s", icon, kit.JoinWord(kit.Select(ice.LIST, m.ActionKey()), name), strings.ReplaceAll(kit.FmtSize(count, total), "B", "")),
|
||||
kit.Select(title, m.Option(ice.MSG_TITLE)), m.OptionDefault(ice.TOAST_DURATION, "-1"), count*100/total, h)
|
||||
m.Option(ice.MSG_TITLE), m.OptionDefault(ice.TOAST_DURATION, "-1"), count*100/total, h)
|
||||
_total = total
|
||||
}
|
||||
if list := cb(toast); len(list) > 0 {
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
func _route_push(m *ice.Message, space string, msg *ice.Message) *ice.Message {
|
||||
return msg.Table(func(index int, value ice.Maps, head []string) {
|
||||
return msg.Table(func(value ice.Maps, index int, head []string) {
|
||||
value[SPACE], head = space, append(head, SPACE)
|
||||
m.Push("", value, head)
|
||||
})
|
||||
@ -44,7 +44,7 @@ func _route_match(m *ice.Message, space string, cb func(ice.Maps, int, []ice.Map
|
||||
}
|
||||
}
|
||||
func _route_toast(m *ice.Message, space string, args ...string) {
|
||||
GoToast(m, "", func(toast func(string, int, int)) (list []string) {
|
||||
GoToast(m, func(toast func(string, int, int)) (list []string) {
|
||||
count, total := 0, 1
|
||||
_route_match(m, space, func(value ice.Maps, i int, _list []ice.Maps) {
|
||||
count, total = i, len(_list)
|
||||
@ -84,9 +84,8 @@ func init() {
|
||||
_route_toast(m, m.Option(SPACE), append([]string{m.Option(ctx.INDEX)}, kit.Split(m.Option(ctx.ARGS))...)...)
|
||||
}},
|
||||
cli.BUILD: {Name: "build space", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey()))
|
||||
_route_toast(m, m.Option(SPACE), cli.RUNTIME, UPGRADE)
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
func() { defer ToastProcess(m)(); m.Sleep3s() }()
|
||||
m.SetAppend().Cmdy("", "travel")
|
||||
}},
|
||||
"travel": {Help: "遍历", Icon: "bi bi-card-list", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -100,21 +99,18 @@ func init() {
|
||||
m.Push(key, ice.Info.Make.Module)
|
||||
case nfs.VERSION:
|
||||
m.Push(key, ice.Info.Make.Versions())
|
||||
case "commitTime":
|
||||
case cli.COMMIT_TIME:
|
||||
m.Push(key, ice.Info.Make.When)
|
||||
case "compileTime":
|
||||
case cli.COMPILE_TIME:
|
||||
m.Push(key, ice.Info.Make.Time)
|
||||
case "bootTime":
|
||||
case cli.BOOT_TIME:
|
||||
m.Push(key, m.Cmdx(cli.RUNTIME, "boot.time"))
|
||||
case "md5":
|
||||
m.Push(key, ice.Info.Hash)
|
||||
case nfs.SIZE:
|
||||
if m.Option(ice.MSG_USERPOD) == "" {
|
||||
defer ToastProcess(m)()
|
||||
}
|
||||
var stats runtime.MemStats
|
||||
runtime.ReadMemStats(&stats)
|
||||
m.Push(key, kit.Format("%s/%s/%s", kit.FmtSize(int64(stats.Sys)), ice.Info.Size, m.Cmdx(nfs.DIR, nfs.SIZE)))
|
||||
m.Push(key, kit.Format("%s/%s/%s", ice.Info.Size, kit.FmtSize(int64(stats.Sys)), m.Cmdx(nfs.DIR, nfs.SIZE)))
|
||||
case nfs.PATH:
|
||||
m.Push(key, kit.Path(""))
|
||||
case tcp.HOSTNAME:
|
||||
|
@ -311,7 +311,7 @@ func init() {
|
||||
}
|
||||
defer m.StatusTimeCount(kit.Dict(ice.MAIN, mdb.Config(m, ice.MAIN)))
|
||||
kit.If(len(arg) > 0 && arg[0] != "", func() { m.OptionFields(ice.MSG_DETAIL) })
|
||||
mdb.HashSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, field []string) {
|
||||
mdb.HashSelect(m.Spawn(), arg...).Table(func(value ice.Maps) {
|
||||
if m.Push("", value, kit.Split(mdb.Config(m, mdb.FIELD))); len(arg) > 0 && arg[0] != "" {
|
||||
m.Push(mdb.STATUS, value[mdb.STATUS]).Push(aaa.UA, value[aaa.UA])
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ func init() {
|
||||
m.PushAction(mdb.REMOVE).Action(html.FILTER, mdb.CREATE)
|
||||
}
|
||||
} else {
|
||||
defer ToastProcess(m, ice.LIST, arg[0])(ice.LIST, arg[0])
|
||||
if arg[0] == ice.OPS && ice.Info.NodeType == SERVER {
|
||||
m.Cmdy(DREAM)
|
||||
return
|
||||
}
|
||||
defer ToastProcess(m, m.Trans("querying, please wait", "查询中,请稍候"))(m.Trans("query succsess", "查询成功"))
|
||||
origin := SpideOrigin(m, arg[0])
|
||||
kit.If(kit.IsIn(arg[0], ice.OPS, ice.DEV), func() { origin = tcp.PublishLocalhost(m, origin) })
|
||||
list := m.Spawn(ice.Maps{ice.MSG_FIELDS: ""}).CmdMap(DREAM, mdb.NAME)
|
||||
|
@ -57,7 +57,7 @@ func PodCmdAction(arg ...string) ice.Actions {
|
||||
msg := disableApp(mdb.HashSelect(m.Spawn(), arg...).Sort(mdb.NAME))
|
||||
web.PushPodCmd(msg, m.PrefixKey(), arg...)
|
||||
has := map[string]bool{}
|
||||
msg.Table(func(index int, value ice.Maps, head []string) {
|
||||
msg.Table(func(value ice.Maps, index int, head []string) {
|
||||
kit.If(!has[value[ctx.INDEX]], func() { has[value[ctx.INDEX]] = true; m.Push("", value, head) })
|
||||
})
|
||||
}},
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/task"
|
||||
"shylinux.com/x/toolkits/util/bench"
|
||||
)
|
||||
|
||||
@ -47,16 +46,14 @@ func _bench_http(m *ice.Message, target string, arg ...string) {
|
||||
}
|
||||
}
|
||||
})
|
||||
var ndata int64
|
||||
total, count := nreqs*nconn, 0
|
||||
var lock task.Lock
|
||||
web.GoToast(m, m.Option(mdb.NAME), func(toast func(name string, count, total int)) []string {
|
||||
var ndata, count int64
|
||||
total := int(nreqs * nconn)
|
||||
web.GoToast(m, func(toast func(name string, count, total int)) []string {
|
||||
if s, e := bench.HTTP(m.FormatTaskMeta(), nconn, nreqs, list, func(req *http.Request, res *http.Response) {
|
||||
toast(m.Option(mdb.NAME), int(count), total)
|
||||
n, _ := io.Copy(ioutil.Discard, res.Body)
|
||||
atomic.AddInt64(&ndata, n)
|
||||
defer lock.Lock()()
|
||||
toast(m.Option(mdb.NAME), count, int(total))
|
||||
count++
|
||||
atomic.AddInt64(&count, 1)
|
||||
}); m.Assert(e) {
|
||||
m.Echo("nconn: %d total: %d ndata: %s\n", nconn, total, kit.FmtSize(ndata)).Echo(s.Show()).ProcessInner()
|
||||
}
|
||||
|
@ -38,22 +38,21 @@ func _install_download(m *ice.Message, arg ...string) {
|
||||
return
|
||||
}
|
||||
mdb.HashCreate(m.Cmd(nfs.SAVE, file, ""), mdb.NAME, name, nfs.PATH, file, web.LINK, link)
|
||||
web.GoToast(m, name, func(toast func(string, int, int)) (list []string) {
|
||||
web.GoToast(m, func(toast func(string, int, int)) []string {
|
||||
begin := time.Now()
|
||||
_toast := func(count, total, value int) {
|
||||
cost := time.Now().Sub(begin)
|
||||
toast(kit.FormatShow(nfs.FROM, begin.Format("15:04:05"), cli.COST, kit.FmtDuration(cost), cli.REST, kit.FmtDuration(cost*time.Duration(101)/time.Duration(value+1)-cost)), count, total)
|
||||
toast(kit.FormatShow(cli.COST, kit.FmtDuration(time.Now().Sub(begin))), count, total)
|
||||
mdb.HashSelectUpdate(m, name, func(value ice.Map) { value[mdb.COUNT], value[mdb.TOTAL], value[mdb.VALUE] = count, total, value })
|
||||
}
|
||||
defer nfs.TarExport(m, file)
|
||||
if mdb.Config(m, nfs.REPOS) != "" {
|
||||
web.SpideSave(m, file, mdb.Config(m, nfs.REPOS)+path.Base(link), _toast)
|
||||
if s, e := nfs.StatFile(m, file); e == nil && s.Size() > 0 {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
}
|
||||
web.SpideSave(m, file, link, _toast)
|
||||
return
|
||||
return nil
|
||||
})
|
||||
if s, e := nfs.StatFile(m, file); e == nil && s.Size() > 0 {
|
||||
web.ToastSuccess(m)
|
||||
|
@ -46,10 +46,9 @@ func init() {
|
||||
uri = kit.MergeURL(uri, ice.POD, p)
|
||||
})
|
||||
dir := path.Join(kit.Format(value[nfs.PATH]), kit.Format(value[nfs.FILE]))
|
||||
web.GoToast(m, web.DOWNLOAD, func(toast func(name string, count, total int)) []string {
|
||||
switch web.SpideSave(m, dir, uri, func(count, total, value int) {
|
||||
toast(dir, count, total)
|
||||
}); value[mdb.TYPE] {
|
||||
web.GoToast(m, func(toast func(name string, count, total int)) []string {
|
||||
web.SpideSave(m, dir, uri, func(count, total, value int) { toast(dir, count, total) })
|
||||
switch value[mdb.TYPE] {
|
||||
case nfs.TAR:
|
||||
m.Cmd(cli.SYSTEM, nfs.TAR, "xf", dir, "-C", path.Dir(dir))
|
||||
// m.Cmd(nfs.TAR, mdb.EXPORT, dir, "-C", path.Dir(dir))
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
func _table_run(m *ice.Message, arg ...string) {
|
||||
list := [][]string{}
|
||||
m.Cmd(arg).Table(func(index int, value ice.Maps, head []string) {
|
||||
m.Cmd(arg).Table(func(value ice.Maps, index int, head []string) {
|
||||
ls := []string{}
|
||||
kit.If(index == 0, func() { m.Options(HEAD, head) })
|
||||
kit.For(head, func(h string) { ls = append(ls, value[h]) })
|
||||
|
17
meta.go
17
meta.go
@ -176,7 +176,7 @@ func (m *Message) Length() (max int) {
|
||||
return max
|
||||
}
|
||||
func (m *Message) TablesLimit(count int, cb func(value Maps)) *Message {
|
||||
return m.Table(func(index int, value Maps) { kit.If(index < count, func() { cb(value) }) })
|
||||
return m.Table(func(value Maps, index int) { kit.If(index < count, func() { cb(value) }) })
|
||||
}
|
||||
func (m *Message) Stats(arg ...string) (res []string) {
|
||||
stats := map[string]float64{}
|
||||
@ -184,6 +184,11 @@ func (m *Message) Stats(arg ...string) (res []string) {
|
||||
kit.For(arg, func(k string) { res = append(res, k, kit.Format("%0.2f", stats[k])) })
|
||||
return
|
||||
}
|
||||
func (m *Message) TableStats(field ...string) map[string]int {
|
||||
stat := map[string]int{}
|
||||
m.Table(func(value Maps) { kit.For(field, func(k string) { stat[value[k]]++ }) })
|
||||
return stat
|
||||
}
|
||||
func (m *Message) TableAmount(cb func(Maps) float64) float64 {
|
||||
var amount float64
|
||||
m.Table(func(value Maps) { amount += cb(value) })
|
||||
@ -196,14 +201,12 @@ func (m *Message) Table(cb Any) *Message {
|
||||
}
|
||||
cbs := func(index int, value Maps, head []string) {
|
||||
switch cb := cb.(type) {
|
||||
case func(index int, value Maps, head []string):
|
||||
cb(index, value, head)
|
||||
case func(index int, value Maps):
|
||||
cb(index, value)
|
||||
case func(value Maps, index int):
|
||||
cb(value, index)
|
||||
case func(value Maps, index int, head []string):
|
||||
cb(value, index, head)
|
||||
case func(value Maps, index, total int):
|
||||
cb(value, index, n)
|
||||
case func(value Maps, index int):
|
||||
cb(value, index)
|
||||
case func(value Maps):
|
||||
cb(value)
|
||||
default:
|
||||
|
2
misc.go
2
misc.go
@ -108,7 +108,7 @@ func (m *Message) RenameAppend(arg ...string) *Message {
|
||||
return m
|
||||
}
|
||||
func (m *Message) RewriteAppend(cb func(value, key string, index int) string) *Message {
|
||||
m.Table(func(index int, value Maps, head []string) {
|
||||
m.Table(func(value Maps, index int, head []string) {
|
||||
for _, key := range head {
|
||||
v := cb(value[key], key, index)
|
||||
if m.FieldsIsDetail() {
|
||||
|
@ -103,7 +103,7 @@ func Complete(m *ice.Message, detail bool, arg ...string) (res []string) {
|
||||
kit.If(detail, func() { echo("func") })
|
||||
m.Cmdy(arg).Search(arg[0], func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||
field := kit.Format(kit.Value(cmd.List, kit.Keys(len(arg)-1, mdb.NAME)))
|
||||
m.Table(func(index int, value ice.Maps, head []string) {
|
||||
m.Table(func(value ice.Maps, index int, head []string) {
|
||||
echo(value[field])
|
||||
if detail {
|
||||
echo(kit.Join(kit.Simple(head, func(key string) string { return key + ": " + value[key] }), lex.SP))
|
||||
|
@ -19,7 +19,7 @@ type field struct {
|
||||
|
||||
func (s field) Inputs(m *ice.Message, arg ...string) { s.daemon.Inputs(m, arg...) }
|
||||
func (s field) Command(m *ice.Message, arg ...string) {
|
||||
s.Zone.List(m.Spawn(), kit.Simple(m.Option(web.DOMAIN), arg)...).Table(func(index int, value ice.Maps, head []string) {
|
||||
s.Zone.List(m.Spawn(), kit.Simple(m.Option(web.DOMAIN), arg)...).Table(func(value ice.Maps, index int, head []string) {
|
||||
if len(arg) == 0 {
|
||||
m.Options(ice.MSG_OPTS, head, kit.Simple(value))
|
||||
s.send(m, "1", m.Option(TID), m.CommandKey(), value[mdb.ID], value[ctx.ARGS])
|
||||
|
@ -109,16 +109,10 @@ func _repos_open(m *ice.Message, p string) *git.Repository {
|
||||
return mdb.HashSelectTarget(m, p, nil).(*git.Repository)
|
||||
}
|
||||
func _repos_each(m *ice.Message, title string, cb func(*git.Repository, ice.Maps) error) {
|
||||
msg := m.Cmd("")
|
||||
web.GoToast(m, title, func(toast func(string, int, int)) (list []string) {
|
||||
msg.Table(func(index int, value ice.Maps) {
|
||||
toast(value[REPOS], index, msg.Length())
|
||||
if err := cb(_repos_open(m, value[REPOS]), value); err != nil && err != git.NoErrAlreadyUpToDate {
|
||||
web.ToastFailure(m, value[REPOS], err.Error())
|
||||
list = append(list, value[REPOS])
|
||||
}
|
||||
})
|
||||
return
|
||||
web.GoToastTable(m.Cmd(""), REPOS, func(value ice.Maps) {
|
||||
if err := cb(_repos_open(m, value[REPOS]), value); err != nil && err != git.NoErrAlreadyUpToDate {
|
||||
web.ToastFailure(m, value[REPOS], err.Error())
|
||||
}
|
||||
})
|
||||
}
|
||||
func _repos_each_origin(m *ice.Message, title string, cb func(*git.Repository, string, *http.BasicAuth, ice.Maps) error) {
|
||||
|
@ -32,7 +32,7 @@ func (s spring) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
s.Hash.List(m, arg...).PushAction(s.Start, s.Build)
|
||||
} else {
|
||||
m.Cmd(cli.DAEMON).Table(func(index int, value ice.Maps, head []string) {
|
||||
m.Cmd(cli.DAEMON).Table(func(value ice.Maps, index int, head []string) {
|
||||
if strings.Contains(value[ice.CMD], "target/"+arg[0]+"-0.0.1-SNAPSHOT.jar") {
|
||||
m.PushRecord(value, head...)
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
val := []string{}
|
||||
m.Table(func(index int, value ice.Maps, head []string) {
|
||||
m.Table(func(value ice.Maps, index int, head []string) {
|
||||
kit.For(head, func(k string) { val = append(val, kit.Format("%s:\t%s", k, value[k])) })
|
||||
val = append(val, lex.NL)
|
||||
})
|
||||
|
@ -173,21 +173,13 @@ func init() {
|
||||
SESSION: {Help: "会话", Hand: func(m *ice.Message, arg ...string) { _ssh_hold(m, _ssh_target(m, m.Option(mdb.NAME))) }},
|
||||
DIRECT: {Name: "direct cmd=pwd", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(mdb.NAME) == "" {
|
||||
msg := m.Cmds("")
|
||||
web.GoToast(m, m.Option(ice.CMD), func(toast func(string, int, int)) []string {
|
||||
count, total := 0, msg.Length()
|
||||
toast("", count, total)
|
||||
msg.Table(func(value ice.Maps) {
|
||||
toast(value[mdb.NAME], count, total)
|
||||
msg := m.Cmds("", m.ActionKey(), value)
|
||||
kit.If(len(msg.Resultv()) == 0, func() { msg.TableEcho() })
|
||||
m.Push(mdb.TIME, msg.Time())
|
||||
m.Push(mdb.NAME, value[mdb.NAME])
|
||||
m.Push(cli.COST, m.FormatCost())
|
||||
m.Push(RES, msg.Result())
|
||||
count++
|
||||
})
|
||||
return nil
|
||||
web.GoToastTable(m.Cmds(""), mdb.NAME, func(value ice.Maps) {
|
||||
msg := m.Cmds("", m.ActionKey(), value)
|
||||
kit.If(len(msg.Resultv()) == 0, func() { msg.TableEcho() })
|
||||
m.Push(mdb.TIME, msg.Time())
|
||||
m.Push(mdb.NAME, value[mdb.NAME])
|
||||
m.Push(cli.COST, m.FormatCost())
|
||||
m.Push(RES, msg.Result())
|
||||
}).ProcessInner()
|
||||
} else if s, e := _ssh_target(m, m.Option(mdb.NAME)).NewSession(); !m.WarnNotValid(e) {
|
||||
defer s.Close()
|
||||
|
@ -137,12 +137,11 @@ func (s relay) Stats(m *ice.Message) {
|
||||
},
|
||||
}
|
||||
machine := m.Option(MACHINE)
|
||||
web.GoToast(m.Message, "", func(toast func(string, int, int)) []string {
|
||||
m.GoToast(func(toast func(string, int, int)) {
|
||||
kit.For(cmds, func(key, value string, index int) {
|
||||
toast(key, index/2, len(cmds)/2)
|
||||
s.foreachModify(m, machine, key, value, trans[key])
|
||||
})
|
||||
return nil
|
||||
}).ProcessInner()
|
||||
s.foreach(m.Spawn(ice.Maps{MACHINE: machine}), func(msg *ice.Message, cmd []string) {
|
||||
ssh.CombinedOutput(msg.Message, s.admins(msg, cli.RUNTIME), func(res string) {
|
||||
|
@ -43,7 +43,7 @@ func (s trans) Send(m *ice.Message, arg ...string) {
|
||||
s.open(m, func(fs *ssh.FileSystem) {
|
||||
nfs.Create(m.Message, path.Join(m.Option(nfs.PATH), m.OptionDefault(nfs.FILE, path.Base(m.Option(nfs.FROM)))), func(w io.Writer, p string) {
|
||||
m.Logs(tcp.SEND, nfs.TO, p, m.OptionSimple(tcp.HOST, nfs.FROM), nfs.SIZE, kit.FmtSize(info.Size()))
|
||||
web.GoToast(m.Message, "", func(toast func(name string, count, total int)) []string {
|
||||
m.GoToast(func(toast func(name string, count, total int)) {
|
||||
last := 0
|
||||
nfs.CopyStream(m.Message, w, r, 81920, int(info.Size()), func(count, total int) {
|
||||
if size := count / 1024 / 1024; size != last {
|
||||
@ -51,7 +51,6 @@ func (s trans) Send(m *ice.Message, arg ...string) {
|
||||
last = size
|
||||
}
|
||||
})
|
||||
return nil
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -98,6 +98,9 @@ func (m *Message) StatusTime(arg ...Any) *Message {
|
||||
func (m *Message) StatusTimeCount(arg ...Any) *Message {
|
||||
return m.StatusTime(append([]Any{kit.MDB_COUNT, kit.Split(m.FormatSize())[0]}, arg...))
|
||||
}
|
||||
func (m *Message) StatusTimeCountStats(field ...string) *Message {
|
||||
return m.StatusTimeCount(m.TableStats(field...))
|
||||
}
|
||||
func (m *Message) StatusTimeCountTotal(arg ...Any) *Message {
|
||||
return m.StatusTimeCount(append([]Any{kit.MDB_TOTAL}, arg...))
|
||||
}
|
||||
@ -116,8 +119,8 @@ func (m *Message) ProcessReplace(url string, arg ...Any) {
|
||||
}
|
||||
func (m *Message) ProcessHistory(arg ...Any) { m.Process(PROCESS_HISTORY, arg...) }
|
||||
func (m *Message) ProcessConfirm(arg ...Any) { m.Process(PROCESS_CONFIRM, arg...) }
|
||||
func (m *Message) ProcessRefresh(arg ...string) {
|
||||
m.Process(PROCESS_REFRESH).Option(PROCESS_ARG, int(kit.Duration(kit.Select("30ms", arg, 0))/time.Millisecond))
|
||||
func (m *Message) ProcessRefresh(arg ...string) *Message {
|
||||
return m.Process(PROCESS_REFRESH).Options(PROCESS_ARG, int(kit.Duration(kit.Select("30ms", arg, 0))/time.Millisecond))
|
||||
}
|
||||
func (m *Message) ProcessRewrite(arg ...Any) { m.Process(PROCESS_REWRITE, arg...) }
|
||||
func (m *Message) ProcessDisplay(arg ...Any) { m.Process(PROCESS_DISPLAY).Option(MSG_DISPLAY, arg...) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user