From 361f4ee8e9ffc1610afbb6b630c8ad20fe8073e2 Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 25 Feb 2024 12:14:26 +0800 Subject: [PATCH] add some --- base/aaa/portal/apply.go | 13 +++++++------ base/aaa/user.go | 3 ++- base/log/debug.go | 12 +++++------- base/web/share.go | 2 +- base/web/token.go | 2 +- misc/ssh/relay/matrix.js | 1 + 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/base/aaa/portal/apply.go b/base/aaa/portal/apply.go index 688a7f1b..097ed349 100644 --- a/base/aaa/portal/apply.go +++ b/base/aaa/portal/apply.go @@ -13,12 +13,13 @@ import ( type apply struct { ice.Hash - email string `data:"admin"` - field string `data:"time,hash,status,email,usernick,username,userrole,icons,agent,system,ip,ua"` - apply string `name:"apply" help:"申请" role:"void"` - agree string `name:"agree userrole=tech,void" help:"同意" icon:"bi bi-check2-square"` - login string `name:"login" help:"登录" role:"void"` - list string `name:"list hash auto sso" help:"注册"` + email string `data:"admin"` + checkbox string `data:"true"` + field string `data:"time,hash,status,email,usernick,username,userrole,icons,agent,system,ip,ua"` + apply string `name:"apply" help:"申请" role:"void"` + agree string `name:"agree userrole=tech,void" help:"同意" icon:"bi bi-check2-square"` + login string `name:"login" help:"登录" role:"void"` + list string `name:"list hash auto sso" help:"注册"` } func (s apply) Sso(m *ice.Message, arg ...string) { diff --git a/base/aaa/user.go b/base/aaa/user.go index 19be5864..5c549f04 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -4,6 +4,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web/html" kit "shylinux.com/x/toolkits" ) @@ -54,7 +55,7 @@ func init() { mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone language", Hand: func(m *ice.Message, arg ...string) { _user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, LANGUAGE, EMAIL, BACKGROUND, AVATAR)...) }}, - }, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone,language"))}, + }, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone,language", html.CHECKBOX, ice.TRUE))}, }) } diff --git a/base/log/debug.go b/base/log/debug.go index 13aa1da3..f1095dd1 100644 --- a/base/log/debug.go +++ b/base/log/debug.go @@ -32,14 +32,14 @@ func init() { cli.OpenCmds(m, kit.Format("cd %s", kit.Path("")), "tail -f var/log/bench.log") }}, }, Hand: func(m *ice.Message, arg ...string) { - offset, limit, stats := kit.Int(kit.Select("0", arg, 1)), kit.Int(kit.Select("1000", arg, 2)), map[string]int{} + offset, limit := kit.Int(kit.Select("0", arg, 1)), kit.Int(kit.Select("100", arg, 2)) switch arg[0] { case BENCH, ERROR, DEBUG: m.Cmd(nfs.CAT, _debug_file(arg[0]), func(text string, index int) { if index < offset || index >= offset+limit || !strings.Contains(text, kit.Select("", arg, 3)) { return } - ls := strings.SplitN(strings.ReplaceAll(text, " ", " "), lex.SP, 8) + ls := strings.SplitN(strings.ReplaceAll(strings.ReplaceAll(text, " ", " "), " ", " "), lex.SP, 8) if _, e := time.Parse(kit.Split(ice.MOD_TIMES)[0], ls[0]); e != nil || len(ls) < 8 { m.Push(mdb.TIME, "").Push(ice.LOG_TRACEID, "").Push(mdb.ID, "") m.Push(nfs.PATH, "").Push(nfs.FILE, "").Push(nfs.LINE, "") @@ -67,24 +67,22 @@ func init() { } } m.Push(ctx.SHIP, ls[5]).Push(LEVEL, ls[6]).Push(nfs.CONTENT, ls[7]) - stats[ls[6]]++ }) case WATCH: m.Cmd(nfs.CAT, ice.VAR_LOG+arg[0]+".log", func(text string, index int) { - if len(arg) > 2 && !strings.Contains(text, arg[2]) || index < offset { + if index < offset || index >= offset+limit || !strings.Contains(text, kit.Select("", arg, 3)) { return } - ls := strings.SplitN(strings.ReplaceAll(text, " ", " "), lex.SP, 8) + ls := strings.SplitN(strings.ReplaceAll(strings.ReplaceAll(text, " ", " "), " ", " "), lex.SP, 8) m.Push(mdb.TIME, ls[0]+lex.SP+ls[1]).Push(ice.LOG_TRACEID, ls[3]).Push(mdb.ID, ls[4]) i := strings.LastIndex(ls[7], lex.SP) m.Push(nfs.PATH, ice.USR_ICEBERGS) m.Push(nfs.FILE, strings.TrimSpace(strings.Split(ls[7][i:], nfs.DF)[0])) m.Push(nfs.LINE, strings.TrimSpace(strings.Split(ls[7][i:], nfs.DF)[1])) m.Push(ctx.SHIP, ls[5]).Push(LEVEL, ls[6]).Push(nfs.CONTENT, ls[7][:i]) - stats[ls[6]]++ }) } - m.StatusTimeCountTotal(offset+m.Length(), stats) + m.StatusTimeCountStats(LEVEL) }}, }) } diff --git a/base/web/share.go b/base/web/share.go index 932a3a0e..665a1aa7 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -166,7 +166,7 @@ func ShareLocalFile(m *ice.Message, arg ...string) { return } } - if m.Option(ice.POD) == "" { + if m.Option(ice.POD) == "" || (strings.HasPrefix(p, ice.USR_ICONS) && nfs.Exists(m, p)) { m.RenderDownload(p) } else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD), p); nfs.Exists(m, pp) { m.RenderDownload(pp) diff --git a/base/web/token.go b/base/web/token.go index 58948717..1db7ed9a 100644 --- a/base/web/token.go +++ b/base/web/token.go @@ -16,7 +16,7 @@ const TOKEN = "token" func init() { Index.MergeCommands(ice.Commands{ - TOKEN: {Help: "令牌桶", Actions: mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.EXPIRE, mdb.MONTH)}, + TOKEN: {Help: "令牌桶", Actions: mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.EXPIRE, mdb.MONTH, html.CHECKBOX, ice.TRUE)}, }) } diff --git a/misc/ssh/relay/matrix.js b/misc/ssh/relay/matrix.js index 7087793b..dc5a5a3d 100644 --- a/misc/ssh/relay/matrix.js +++ b/misc/ssh/relay/matrix.js @@ -15,6 +15,7 @@ Volcanos(chat.ONIMPORT, { ] }]), can.onmotion.delay(can, function() { can.Status(mdb.COUNT, can.core.Item(list).length+"x"+can.core.Item(machine).length) }) }, void: function(can, space, machine, list) { + return return {view: html.ACTION, _init: function(target) { var worker = list[space]["localhost"], server = list["contexts"][machine] worker && can.onappend.input(can, {type: html.BUTTON, name: code.INSTALL, onclick: function(event) { can.Update(can.request(event, {space: space, machine: machine}, worker), [ctx.ACTION, code.INSTALL])