diff --git a/base/aaa/role.go b/base/aaa/role.go index fffd28f7..c88a7b50 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -158,7 +158,8 @@ func Right(m *ice.Message, key ...ice.Any) bool { } else if len(key) > 0 && key[0] == ice.ETC_PATH { return true } + m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey())+" "+logs.FileLine(-2)) return !ice.Info.Important || m.Option(ice.MSG_USERROLE) == ROOT || !m.WarnNotRight(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK, - kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-2)) + kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE)) } func IsTechOrRoot(m *ice.Message) bool { return kit.IsIn(m.Option(ice.MSG_USERROLE), TECH, ROOT) } diff --git a/base/web/dream.go b/base/web/dream.go index eb8edfc9..fca2880d 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -83,6 +83,7 @@ func _dream_list_more(m *ice.Message, simple bool) *ice.Message { m.Cmds(SPACE).Table(func(value ice.Maps) { value[mdb.ICONS] = nfs.USR_ICONS_VOLCANOS value[nfs.REPOS] = "https://" + value[nfs.MODULE] + value[aaa.ACCESS] = kit.Select("", value[aaa.USERROLE], value[aaa.USERROLE] != aaa.VOID) value[mdb.STATUS] = cli.START switch value[mdb.TYPE] { case SERVER: @@ -99,7 +100,6 @@ func _dream_list_more(m *ice.Message, simple bool) *ice.Message { value[mdb.ICONS] = kit.Select(value[mdb.ICONS], spide[mdb.ICONS]) } value[mdb.TEXT] = kit.JoinLine(value[nfs.MODULE], value[mdb.TEXT]) - value[aaa.ACCESS] = value[aaa.USERROLE] if simple { defer m.PushButton("") } else { @@ -488,7 +488,7 @@ func DreamTablesAction(arg ...string) ice.Actions { } } func DreamAction() ice.Actions { - return gdb.EventsAction(DREAM_INPUTS, DREAM_CREATE, DREAM_TRASH, DREAM_OPEN, DREAM_CLOSE, SERVE_START) + return gdb.EventsAction(DREAM_INPUTS, DREAM_CREATE, DREAM_TRASH, DREAM_OPEN, DREAM_CLOSE, SPACE_LOGIN, SERVE_START) } func DreamWhiteHandle(m *ice.Message, arg ...string) { aaa.White(m, kit.Keys(DREAM, ctx.ACTION, m.ShortKey())) diff --git a/base/web/render.go b/base/web/render.go index a4138008..e4502ed6 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -29,6 +29,16 @@ const ( STYLE = "style" ) +func renderMsg(m *ice.Message) { + m.FormatsMeta(m.W, + ice.MSG_USERIP, ice.MSG_USERUA, ice.MSG_METHOD, ice.MSG_REFERER, ice.MSG_DAEMON, + ice.MSG_LANGUAGE, ice.MSG_THEME, ice.MSG_BG, ice.MSG_FG, + ice.MSG_RIVER, ice.MSG_STORM, ice.MSG_INDEX, ice.MSG_FIELDS, + ice.MSG_SOURCE, ice.MSG_TARGET, + "task.id", "work.id", "space.timeout", + ice.MSG_USERWEB0, ice.MSG_USERPOD0, + ) +} func Render(m *ice.Message, cmd string, args ...ice.Any) bool { if cmd == ice.RENDER_VOID { return true @@ -46,7 +56,10 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool { case COOKIE: // value [name [path [expire]]] RenderCookie(m, arg[0], arg[1:]...) case STATUS, ice.RENDER_STATUS: // [code [text]] - RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), kit.Select(m.Result(), strings.Join(kit.Slice(arg, 1), " "))) + // RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), m.FormatsMeta(nil)) + m.W.WriteHeader(kit.Int(kit.Select("200", arg, 0))) + renderMsg(m) + // RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), kit.Select(m.Result(), strings.Join(kit.Slice(arg, 1), " "))) case ice.RENDER_REDIRECT: // url [arg...] http.Redirect(m.W, m.R, m.MergeLink(arg[0], arg[1:]), http.StatusTemporaryRedirect) case ice.RENDER_DOWNLOAD: // file [type [name]] @@ -75,14 +88,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool { default: kit.If(cmd != "" && cmd != ice.RENDER_RAW, func() { m.Echo(kit.Format(cmd, args...)) }) RenderType(m.W, nfs.JSON, "") - m.FormatsMeta(m.W, - ice.MSG_USERIP, ice.MSG_USERUA, ice.MSG_METHOD, ice.MSG_REFERER, ice.MSG_DAEMON, - ice.MSG_LANGUAGE, ice.MSG_THEME, ice.MSG_BG, ice.MSG_FG, - ice.MSG_RIVER, ice.MSG_STORM, ice.MSG_INDEX, ice.MSG_FIELDS, - ice.MSG_SOURCE, ice.MSG_TARGET, - "task.id", "work.id", "space.timeout", - ice.MSG_USERWEB0, ice.MSG_USERPOD0, - ) + renderMsg(m) } m.Render(ice.RENDER_VOID) return true @@ -196,3 +202,11 @@ const ( PLUGIN_XTERM = "/plugin/local/code/xterm.js" ) + +func MessageInsertJSON(m *ice.Message, zone, name, text string, arg ...string) { + MessageInsert(m, zone, kit.Simple(mdb.TYPE, html.TEXT, mdb.NAME, kit.Select(m.CommandKey(), name), + mdb.TEXT, text, ctx.DISPLAY, html.PLUGIN_STORY_JSON, arg)...) +} +func MessageInsert(m *ice.Message, zone string, arg ...string) { + m.Cmd(MESSAGE, mdb.INSERT, zone, tcp.DIRECT, tcp.RECV, arg) +} diff --git a/base/web/space.go b/base/web/space.go index f7efa587..17acbc89 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -123,6 +123,7 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) { } msg := m.Spawn(b) if safe { // 下行权限 + kit.If(msg.Option(ice.MSG_USERROLE) == aaa.VOID, func() { msg.Option(ice.MSG_USERROLE, "") }) msg.OptionDefault(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME))) } else { // 上行权限 kit.If(msg.Option(ice.MSG_USERROLE), func() { msg.Option(ice.MSG_USERROLE, aaa.VOID) }) diff --git a/core/chat/grant.go b/core/chat/grant.go index 19abc95b..47ef2213 100644 --- a/core/chat/grant.go +++ b/core/chat/grant.go @@ -43,13 +43,22 @@ func init() { aaa.SessCreate(m, m.Option(ice.MSG_USERNAME)) } m.Cmd(web.SPACE, m.Option(web.SPACE), ice.MSG_SESSID, m.Option(ice.MSG_SESSID)) - m.ProcessLocation(m.MergeLink(msg.Append(mdb.TEXT))) - kit.If(m.IsWeixinUA(), func() { m.Echo(ice.SUCCESS) }) + if m.IsWeixinUA() { + m.Echo(ice.SUCCESS) + } else if web.UserWeb(m).Path == "/c/web.chat.grant" { + m.ProcessLocation(m.MergeLink(msg.Append(mdb.TEXT))) + } else { + m.Echo(ice.SUCCESS) + m.ProcessInner() + } gdb.Event(m, web.SPACE_GRANT, m.OptionSimple(web.SPACE)) } }}, }, gdb.EventsAction(web.SPACE_LOGIN)), Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(web.SPACE, m.Option(web.SPACE, arg[0])) + if msg.Length() == 0 { + return + } m.Options(tcp.HOSTNAME, ice.Info.Hostname, nfs.PATH, msg.Append(mdb.TEXT)) if !m.WarnNotValid(m.Option(nfs.PATH) == "", arg[0]) { if m.EchoInfoButton(nfs.Template(m, "auth.html"), aaa.CONFIRM); m.IsWeixinUA() { diff --git a/core/chat/message.css b/core/chat/message.css index fdd29f28..0ebfba11 100644 --- a/core/chat/message.css +++ b/core/chat/message.css @@ -31,8 +31,9 @@ fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list> fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.send div.container { display:flex; flex-direction:column; align-items:flex-end; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.text div.content { white-space:pre; padding:var(--input-padding) var(--button-padding); } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content div.item.text.path>input { width:var(--input-width); } -fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content fieldset.story.xterm>form.option>div.item.hash input { width:var(--input-width); } -fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content fieldset.story.iframe>form.option>div.item.hash input { width:var(--input-width); } +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content fieldset.story.xterm>form.option>div.item.hash input { width:var(--form-width); } +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content fieldset.story.web.chat.grant>form.option>div.item.space input { width:var(--form-width); } +fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content fieldset.story.iframe>form.option>div.item.hash input { width:var(--form-width); } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content fieldset.story.user>form.option>div.item.username input { width:var(--form-width); } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content fieldset.story>div.action>div.item.chat.icons { display:none; } fieldset.web.chat.message>div.output>div.layout>div.layout>div.content>div.list>div.item.plug>div.container>div.content { box-shadow:var(--box-shadow); } diff --git a/core/chat/message.go b/core/chat/message.go index dfc31743..b8feb8bc 100644 --- a/core/chat/message.go +++ b/core/chat/message.go @@ -24,7 +24,7 @@ func init() { MessageCreate(m, aaa.APPLY, html.ICONS_MAIL) MessageCreate(m, web.DREAM, html.ICONS_DREAM) MessageCreate(m, cli.SYSTEM, html.ICONS_SETTINGS) - MessageInsert(m, cli.SYSTEM, mdb.TYPE, html.TEXT, mdb.NAME, cli.BOOTINFO, mdb.TEXT, m.Cmdx(cli.RUNTIME), ctx.DISPLAY, html.PLUGIN_STORY_JSON) + web.MessageInsertJSON(m, cli.SYSTEM, cli.BOOTINFO, m.Cmdx(cli.RUNTIME)) }}, mdb.CREATE: {Name: "create type*=tech,void title icons target zone", Hand: func(m *ice.Message, arg ...string) { if strings.HasPrefix(m.Option(web.TARGET), "from.") { @@ -40,6 +40,8 @@ func init() { mdb.HashSelectUpdate(m, arg[0], func(value ice.Map) { kit.Value(value, mdb.TIME, m.Time()) }) web.StreamPushRefreshConfirm(m, m.Trans("refresh for new message ", "刷新列表,查看最新消息 ")) }}, + cli.CLEAR: {Hand: func(m *ice.Message, arg ...string) { + }}, tcp.SEND: {Hand: func(m *ice.Message, arg ...string) { m.Cmd("", mdb.INSERT, arg, tcp.DIRECT, tcp.SEND) kit.If(mdb.HashSelectField(m, arg[0], web.TARGET), func(p string) { m.Cmd(web.SPACE, p, MESSAGE, tcp.RECV, arg[1:]) }) @@ -54,6 +56,9 @@ func init() { MessageInsert(m, web.DREAM, mdb.TYPE, html.PLUG, ctx.INDEX, IFRAME, ctx.ARGS, web.S(m.Option(mdb.NAME))) } }}, + web.SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) { + MessageInsert(m, aaa.APPLY, mdb.TYPE, html.PLUG, mdb.NAME, m.ActionKey(), ctx.INDEX, web.CHAT_GRANT, ctx.ARGS, m.Option(mdb.NAME)) + }}, aaa.USER_CREATE: {Hand: func(m *ice.Message, arg ...string) { if ice.Info.Important { MessageInsert(m, aaa.APPLY, mdb.TYPE, html.PLUG, mdb.NAME, m.ActionKey(), ctx.INDEX, aaa.USER, ctx.ARGS, m.Option(aaa.USERNAME)) @@ -80,11 +85,14 @@ func init() { return } m.PushRecord(value, mdb.Config(m, mdb.FIELD)) - if value[web.TARGET] == "" { - m.PushButton(mdb.REMOVE) - } else { - m.PushButton(web.OPEN, mdb.REMOVE) + list := []ice.Any{} + if value[web.TARGET] != "" { + list = append(list, web.OPEN) } + if aaa.IsTechOrRoot(m) { + list = append(list, cli.CLEAR, mdb.REMOVE) + } + m.PushButton(list...) }) m.Sort(mdb.TIME, ice.STR_R) } else { diff --git a/core/chat/message.js b/core/chat/message.js index 63ef8f57..43d4853c 100644 --- a/core/chat/message.js +++ b/core/chat/message.js @@ -127,7 +127,8 @@ Volcanos(chat.ONFIGURE, { return {view: wiki.CONTENT, list: [{text: value.text||"[未知消息]"}], _init: function(target) { if (value.display) { var msg = can.request(); msg.Echo(value.text), can.onmotion.clear(can, target) var height = can.onexport.plugHeight(can, value), width = can.onexport.plugWidth(can, value) - can.onappend.plugin(can, {title: value.name, index: "can._plugin", height: height, display: value.display, msg: msg}, function(sub) { + can.onappend.plugin(can, {title: value.name, index: "can._filter", height: height, display: value.display, msg: msg}, function(sub) { + sub.onimport.size(sub, height, width) delete(sub._legend.onclick) }, target) } @@ -142,7 +143,9 @@ Volcanos(chat.ONFIGURE, { value._commands = {direct: value.direct, target: can.db.zone.target} value.title = value.name can.onappend.plugin(can, value, function(sub) { - sub.onexport.output = function() { sub.onimport.size(sub, height, width) + sub.onimport.size(sub, height, width) + sub.onexport.output = function() { + sub.onimport.size(sub, height, width) can.page.style(can, target, html.HEIGHT, sub._target.offsetHeight+2, html.WIDTH, sub._target.offsetWidth) } }, target) diff --git a/core/chat/river.go b/core/chat/river.go index 57c0be57..7cda512b 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -13,6 +13,7 @@ func _river_right(m *ice.Message, hash string) (ok bool) { if m.Option(ice.MSG_USERROLE) == aaa.ROOT { return true } + ok = true m.Cmd(mdb.SELECT, RIVER, "", mdb.HASH, hash).Table(func(value ice.Maps) { ok = kit.IsIn(m.Option(ice.MSG_USERROLE), value[mdb.TYPE], aaa.TECH, aaa.ROOT) }) diff --git a/core/code/compile.go b/core/code/compile.go index d0ac396c..4070b357 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -122,6 +122,7 @@ func init() { } else { m.Logs(nfs.SAVE, nfs.TARGET, file, nfs.SOURCE, main) m.Cmdy(nfs.DIR, file, "time,path,size,hash,link") + web.MessageInsertJSON(m, cli.SYSTEM, "", m.Spawn().Copy(m).FormatMeta()) kit.If(!m.IsCliUA() && strings.Contains(file, ice.ICE), func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.APP) }) web.Count(m, "", file) } diff --git a/core/team/plan.go b/core/team/plan.go index 8481dfcb..c094eb18 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -6,6 +6,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web/html" @@ -65,6 +66,13 @@ func init() { ), Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }}, mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }}, + mdb.INSERT: {Name: "insert space zone* type*=once,step,week name* text begin_time@date end_time@date", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(TASK, mdb.INSERT, arg) + web.StreamPushRefreshConfirm(m, m.Trans("refresh for new message ", "刷新列表,查看最新消息 ")) + }}, + aaa.USER_CREATE: {Hand: func(m *ice.Message, arg ...string) { + PlanInsert(m, aaa.APPLY, "", m.Option(aaa.USERNAME), aaa.USER, m.Option(aaa.USERNAME)) + }}, ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { if m.RenameOption(TASK_POD, ice.POD); ctx.PodCmd(m, m.ShortKey(), ctx.RUN, arg) { return @@ -74,7 +82,7 @@ func init() { m.Cmdy(arg) } }}, - }, web.DreamTablesAction(), ctx.ConfAction(mdb.TOOLS, "todo,epic"), TASK), Hand: func(m *ice.Message, arg ...string) { + }, web.DreamTablesAction(), gdb.EventsAction(aaa.USER_CREATE, aaa.USER_REMOVE), ctx.ConfAction(mdb.TOOLS, "todo,epic"), TASK), Hand: func(m *ice.Message, arg ...string) { begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...) _plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME)) web.PushPodCmd(m, "", arg...) @@ -83,3 +91,9 @@ func init() { }}, }) } +func PlanInsert(m *ice.Message, zone, name, text, index, args string, arg ...string) { + m.Cmd(PLAN, mdb.INSERT, web.SPACE, "", mdb.ZONE, zone, mdb.TYPE, "one", + mdb.NAME, kit.Select(m.ActionKey(), name), mdb.TEXT, text, BEGIN_TIME, m.Time(), + "extra.index", index, "extra.args", args, arg, + ) +} diff --git a/logs.go b/logs.go index 4b8b62cf..40bb8914 100644 --- a/logs.go +++ b/logs.go @@ -120,6 +120,7 @@ func (m *Message) Warn(err Any, arg ...Any) bool { } str, meta := m.join(arg...) if m.log(LOG_WARN, str, meta...); len(arg) > 0 { + m.Option(MSG_TITLE, kit.JoinWord(kit.Keys(m.Option(MSG_USERPOD), m.CommandKey(), m.ActionKey()), logs.FileLines(-2))) m.error(arg...) kit.If(map[string]int{ ErrNotLogin: http.StatusUnauthorized,