mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt plan
This commit is contained in:
parent
56ce985dad
commit
47a1dc4cdd
@ -52,7 +52,7 @@ func _mdb_modify(m *ice.Message, val ice.Map, field string, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _mdb_select(m *ice.Message, cb Any, key string, value Map, fields []string, val Map) {
|
func _mdb_select(m *ice.Message, cb Any, key string, value Map, fields []string, val Map) {
|
||||||
switch value = kit.GetMeta(value); cb := cb.(type) {
|
switch value, val = kit.GetMeta(value), kit.GetMeta(val); cb := cb.(type) {
|
||||||
case func([]string, Map):
|
case func([]string, Map):
|
||||||
cb(fields, value)
|
cb(fields, value)
|
||||||
case func(string, []string, Map, Map):
|
case func(string, []string, Map, Map):
|
||||||
@ -177,7 +177,7 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
|
|||||||
case ice.CMD:
|
case ice.CMD:
|
||||||
m.Cmdy("context", kit.Select(m.Option(ice.CTX), m.Option(kit.Keys(EXTRA, ice.CTX))), "command")
|
m.Cmdy("context", kit.Select(m.Option(ice.CTX), m.Option(kit.Keys(EXTRA, ice.CTX))), "command")
|
||||||
case "index":
|
case "index":
|
||||||
m.OptionFields(arg[0])
|
m.OptionFields(arg[3])
|
||||||
m.Cmdy("command", SEARCH, "command", kit.Select("", arg, 1))
|
m.Cmdy("command", SEARCH, "command", kit.Select("", arg, 1))
|
||||||
default:
|
default:
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
@ -249,12 +249,10 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
|
|||||||
}
|
}
|
||||||
switch file := _file_name(m, arg...); arg[2] {
|
switch file := _file_name(m, arg...); arg[2] {
|
||||||
case ZONE:
|
case ZONE:
|
||||||
m.OptionFields(ZoneShort(m), m.Config(FIELD))
|
|
||||||
_zone_export(m, arg[0], arg[1], file)
|
_zone_export(m, arg[0], arg[1], file)
|
||||||
case HASH:
|
case HASH:
|
||||||
_hash_export(m, arg[0], arg[1], file)
|
_hash_export(m, arg[0], arg[1], file)
|
||||||
case LIST:
|
case LIST:
|
||||||
m.OptionFields(m.Config(FIELD))
|
|
||||||
_list_export(m, arg[0], arg[1], file)
|
_list_export(m, arg[0], arg[1], file)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -63,7 +63,6 @@ func _zone_export(m *ice.Message, prefix, chain, file string) {
|
|||||||
|
|
||||||
w := csv.NewWriter(f)
|
w := csv.NewWriter(f)
|
||||||
defer w.Flush()
|
defer w.Flush()
|
||||||
|
|
||||||
fields := _zone_fields(m)
|
fields := _zone_fields(m)
|
||||||
if kit.IndexOf(fields, EXTRA) == -1 {
|
if kit.IndexOf(fields, EXTRA) == -1 {
|
||||||
fields = append(fields, EXTRA)
|
fields = append(fields, EXTRA)
|
||||||
@ -197,6 +196,13 @@ func ZoneInsert(m *ice.Message, arg ...Any) {
|
|||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
args = m.OptionSimple(ZoneShort(m), m.Config(FIELD))
|
args = m.OptionSimple(ZoneShort(m), m.Config(FIELD))
|
||||||
}
|
}
|
||||||
|
for i := len(args) - 2; i >= 0; i -= 2 {
|
||||||
|
if args[i+1] == "" {
|
||||||
|
args = args[:i]
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
m.Cmdy(INSERT, m.PrefixKey(), "", ZONE, args[1], ZoneArgs(m, args[2:]))
|
m.Cmdy(INSERT, m.PrefixKey(), "", ZONE, args[1], ZoneArgs(m, args[2:]))
|
||||||
}
|
}
|
||||||
func ZoneModify(m *ice.Message, arg ...Any) {
|
func ZoneModify(m *ice.Message, arg ...Any) {
|
||||||
@ -217,6 +223,11 @@ func ZoneSelect(m *ice.Message, arg ...string) *ice.Message {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
func ZoneExport(m *ice.Message, arg ...Any) {
|
func ZoneExport(m *ice.Message, arg ...Any) {
|
||||||
|
m.Debug("what %v", m.OptionFields())
|
||||||
|
if m.OptionFields() == "" {
|
||||||
|
m.OptionFields(m.Config(SHORT), m.Config(FIELD))
|
||||||
|
}
|
||||||
|
m.Debug("what %v", m.OptionFields())
|
||||||
m.Cmdy(EXPORT, m.PrefixKey(), "", ZONE, arg)
|
m.Cmdy(EXPORT, m.PrefixKey(), "", ZONE, arg)
|
||||||
}
|
}
|
||||||
func ZoneImport(m *ice.Message, arg ...Any) {
|
func ZoneImport(m *ice.Message, arg ...Any) {
|
||||||
|
@ -10,18 +10,15 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _plan_scope(m *ice.Message, tz int, arg ...string) (time.Time, time.Time) {
|
func _plan_scope(m *ice.Message, tz int, arg ...string) (begin_time, end_time time.Time) {
|
||||||
begin_time := time.Now()
|
if begin_time = time.Now(); len(arg) > 1 {
|
||||||
if len(arg) > 1 {
|
|
||||||
begin_time, _ = time.ParseInLocation(ice.MOD_TIME, arg[1], time.Local)
|
begin_time, _ = time.ParseInLocation(ice.MOD_TIME, arg[1], time.Local)
|
||||||
}
|
}
|
||||||
|
|
||||||
begin_time = begin_time.Add(time.Duration(tz) * time.Hour)
|
begin_time = begin_time.Add(time.Duration(tz) * time.Hour)
|
||||||
begin_time = begin_time.Add(-time.Duration(begin_time.UnixNano()) % (24 * time.Hour))
|
begin_time = begin_time.Add(-time.Duration(begin_time.UnixNano()) % (24 * time.Hour))
|
||||||
begin_time = begin_time.Add(-time.Duration(tz) * time.Hour)
|
begin_time = begin_time.Add(-time.Duration(tz) * time.Hour)
|
||||||
|
|
||||||
end_time := begin_time
|
switch end_time = begin_time; kit.Select(WEEK, arg, 0) {
|
||||||
switch kit.Select(WEEK, arg, 0) {
|
|
||||||
case DAY:
|
case DAY:
|
||||||
end_time = begin_time.AddDate(0, 0, 1)
|
end_time = begin_time.AddDate(0, 0, 1)
|
||||||
case WEEK:
|
case WEEK:
|
||||||
@ -38,21 +35,18 @@ func _plan_scope(m *ice.Message, tz int, arg ...string) (time.Time, time.Time) {
|
|||||||
begin_time = begin_time.AddDate(-30, 0, 0)
|
begin_time = begin_time.AddDate(-30, 0, 0)
|
||||||
end_time = begin_time.AddDate(60, 0, 0)
|
end_time = begin_time.AddDate(60, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return begin_time, end_time
|
return begin_time, end_time
|
||||||
}
|
}
|
||||||
func _plan_list(m *ice.Message, begin_time, end_time time.Time) *ice.Message {
|
func _plan_list(m *ice.Message, begin_time, end_time time.Time) *ice.Message {
|
||||||
m.Option(mdb.CACHE_LIMIT, "100")
|
m.Option(mdb.CACHE_LIMIT, "100")
|
||||||
m.Fields(0, "begin_time,close_time,zone,id,level,status,score,type,name,text,pod,extra")
|
m.OptionFields("begin_time,close_time,zone,id,level,status,score,type,name,text,pod,extra")
|
||||||
m.OptionCB(mdb.SELECT, func(key string, fields []string, value, val ice.Map) {
|
m.Cmd(mdb.SELECT, m.Prefix(TASK), "", mdb.ZONE, mdb.FOREACH, func(key string, fields []string, value, val ice.Map) {
|
||||||
begin, _ := time.ParseInLocation(ice.MOD_TIME, kit.Format(value[BEGIN_TIME]), time.Local)
|
begin, _ := time.ParseInLocation(ice.MOD_TIME, kit.Format(value[BEGIN_TIME]), time.Local)
|
||||||
if begin_time.After(begin) || begin.After(end_time) {
|
if begin_time.After(begin) || begin.After(end_time) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Push(key, value, fields, val)
|
m.Push(key, value, fields, val).PushButton(_task_action(m, value[STATUS], mdb.PLUGIN))
|
||||||
m.PushButton(_task_action(m, value[STATUS], mdb.PLUGIN))
|
|
||||||
})
|
})
|
||||||
m.Cmd(mdb.SELECT, m.Prefix(TASK), "", mdb.ZONE, mdb.FOREACH)
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,33 +62,34 @@ const PLAN = "plan"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Meta: kit.Dict(
|
PLAN: {Name: "plan scale=week,day,week,month,year,long begin_time@date list", Help: "计划", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.Display("/plugin/local/team/plan.js"),
|
|
||||||
), Actions: ice.MergeActions(ice.Actions{
|
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(TODO, mdb.INPUTS, arg)
|
m.Cmdy(TODO, mdb.INPUTS, arg)
|
||||||
}},
|
}},
|
||||||
mdb.PLUGIN: {Name: "plugin extra.ctx extra.cmd extra.arg", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
mdb.PLUGIN: {Name: "plugin extra.index extra.args", Help: "插件", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_task_modify(m, arg[0], arg[1], arg[2:]...)
|
m.Cmdy(TASK, mdb.MODIFY, arg)
|
||||||
}},
|
|
||||||
mdb.SEARCH: {Name: "search", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if arg[0] == mdb.FOREACH && arg[1] == "" {
|
|
||||||
m.PushSearch(mdb.TYPE, "plan", mdb.NAME, "", mdb.TEXT, web.MergePodCmd(m, "", ""))
|
|
||||||
}
|
|
||||||
}},
|
}},
|
||||||
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(ice.POD, m.Option("task.pod"))
|
m.Option(ice.POD, m.Option("task.pod"))
|
||||||
if m.Option("task.pod", ""); ctx.PodCmd(m, m.PrefixKey(), ice.RUN, arg) {
|
if m.Option("task.pod", ""); ctx.PodCmd(m, m.PrefixKey(), ice.RUN, arg) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
msg := m.Cmd(TASK, arg[0], arg[1], ice.OptionFields(ice.CTX, ice.CMD))
|
m.Cmdy(m.CmdAppend(TASK, arg[0], arg[1], ctx.INDEX), arg[2:])
|
||||||
m.Cmdy(kit.Simple(kit.Keys(msg.Append(ice.CTX), msg.Append(ice.CMD)), arg[2:]))
|
|
||||||
}},
|
}},
|
||||||
}, TASK), Hand: func(m *ice.Message, arg ...string) {
|
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
arg = kit.Slice(arg, 0, 2)
|
m.Cmdy(TASK, mdb.INSERT, arg)
|
||||||
begin_time, end_time := _plan_scope(m, 8, arg...)
|
}},
|
||||||
|
mdb.EXPORT: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.EXPORT) }},
|
||||||
|
mdb.IMPORT: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.IMPORT) }},
|
||||||
|
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if len(arg) > 0 && arg[0] == ctx.ACTION {
|
||||||
|
m.Cmdy(TASK, arg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
begin_time, end_time := _plan_scope(m, 8, kit.Slice(arg, 0, 2)...)
|
||||||
_plan_list(m, begin_time, end_time)
|
_plan_list(m, begin_time, end_time)
|
||||||
web.PushPodCmd(m, m.CommandKey(), arg...)
|
web.PushPodCmd(m, m.CommandKey(), arg...)
|
||||||
|
ctx.DisplayLocal(m, "")
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package team
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
@ -10,10 +9,12 @@ import (
|
|||||||
func _task_action(m *ice.Message, status ice.Any, action ...string) string {
|
func _task_action(m *ice.Message, status ice.Any, action ...string) string {
|
||||||
switch status {
|
switch status {
|
||||||
case PREPARE:
|
case PREPARE:
|
||||||
action = append(action, BEGIN)
|
action = append(action, BEGIN, CANCEL)
|
||||||
case PROCESS:
|
case PROCESS:
|
||||||
action = append(action, END)
|
action = append(action, END, CANCEL)
|
||||||
case CANCEL, FINISH:
|
case CANCEL:
|
||||||
|
action = append(action, BEGIN)
|
||||||
|
case FINISH:
|
||||||
}
|
}
|
||||||
return kit.Join(action)
|
return kit.Join(action)
|
||||||
}
|
}
|
||||||
@ -26,7 +27,7 @@ func _task_modify(m *ice.Message, field, value string, arg ...string) {
|
|||||||
arg = append(arg, CLOSE_TIME, m.Time())
|
arg = append(arg, CLOSE_TIME, m.Time())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Cmdy(mdb.MODIFY, m.Prefix(TASK), "", mdb.ZONE, m.Option(mdb.ZONE), m.Option(mdb.ID), field, value, arg)
|
mdb.ZoneModify(m, field, value, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
const ( // type
|
const ( // type
|
||||||
@ -52,45 +53,20 @@ const (
|
|||||||
BEGIN = "begin"
|
BEGIN = "begin"
|
||||||
END = "end"
|
END = "end"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TASK = "task"
|
const TASK = "task"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TASK: {Name: "task zone id auto insert export import", Help: "任务", Actions: ice.MergeActions(ice.Actions{
|
TASK: {Name: "task zone id auto insert export import", Help: "任务", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.HASH, m.OptionSimple(mdb.ZONE))
|
mdb.ZoneInsert(m, arg[:2], BEGIN_TIME, m.Time(), STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg[2:])
|
||||||
m.Cmdy(mdb.INSERT, m.Prefix(TASK), "", mdb.ZONE, m.Option(mdb.ZONE),
|
|
||||||
BEGIN_TIME, m.Time(), CLOSE_TIME, m.Time("30m"),
|
|
||||||
STATUS, PREPARE, LEVEL, 3, SCORE, 3, arg)
|
|
||||||
m.ProcessRefresh30ms()
|
|
||||||
}},
|
}},
|
||||||
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, arg[0], arg[1], arg[2:]...) }},
|
||||||
_task_modify(m, arg[0], arg[1])
|
CANCEL: {Name: "cancal", Help: "取消", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, CANCEL) }},
|
||||||
m.ProcessRefresh30ms()
|
BEGIN: {Name: "begin", Help: "开始", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, PROCESS) }},
|
||||||
}},
|
END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }},
|
||||||
mdb.DELETE: {Name: "delete", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "begin_time,close_time,id,status,level,score,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
_task_modify(m, STATUS, CANCEL)
|
if mdb.ZoneSelect(m, arg...); len(arg) > 0 && arg[0] != "" {
|
||||||
}},
|
|
||||||
mdb.EXPORT: {Name: "export", Help: "导出", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.OptionFields(mdb.ZONE, "time,id,type,name,text,level,status,score,begin_time,close_time")
|
|
||||||
m.Cmdy(mdb.EXPORT, m.Prefix(TASK), "", mdb.ZONE)
|
|
||||||
m.ProcessRefresh30ms()
|
|
||||||
}},
|
|
||||||
mdb.IMPORT: {Name: "import", Help: "导入", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.OptionFields(mdb.ZONE)
|
|
||||||
m.Cmdy(mdb.IMPORT, m.Prefix(TASK), "", mdb.ZONE)
|
|
||||||
m.ProcessRefresh30ms()
|
|
||||||
}},
|
|
||||||
|
|
||||||
BEGIN: {Name: "begin", Help: "开始", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_task_modify(m, STATUS, PROCESS)
|
|
||||||
}},
|
|
||||||
END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_task_modify(m, STATUS, FINISH)
|
|
||||||
}},
|
|
||||||
}, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "begin_time,id,status,level,score,type,name,text"), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if mdb.ZoneSelect(m, arg...); len(arg) > 0 {
|
|
||||||
status := map[string]int{}
|
status := map[string]int{}
|
||||||
m.Tables(func(value ice.Maps) {
|
m.Tables(func(value ice.Maps) {
|
||||||
m.PushButton(_task_action(m, value[STATUS]))
|
m.PushButton(_task_action(m, value[STATUS]))
|
||||||
|
@ -2,9 +2,10 @@ package team
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/web"
|
"shylinux.com/x/icebergs/base/web"
|
||||||
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
const TODO = "todo"
|
const TODO = "todo"
|
||||||
@ -13,18 +14,18 @@ func init() {
|
|||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TODO: {Name: "todo hash list create export import", Help: "待办", Actions: ice.MergeActions(ice.Actions{
|
TODO: {Name: "todo hash list create export import", Help: "待办", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(mdb.INPUTS, m.PrefixKey(), "", mdb.HASH, arg)
|
mdb.HashInputs(m, arg)
|
||||||
m.Cmdy(TASK, mdb.INPUTS, arg)
|
// m.Cmdy(TASK, mdb.INPUTS, arg)
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create zone name text", Help: "创建"},
|
mdb.CREATE: {Name: "create zone name text", Help: "创建"},
|
||||||
cli.START: {Name: "start type=once,step,week", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
cli.START: {Name: "start type=once,step,week", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(TASK, mdb.INSERT, m.OptionSimple("zone,type,name,text"), BEGIN_TIME, m.Time())
|
m.Cmd(TASK, mdb.INSERT, m.OptionSimple("zone,type,name,text"), BEGIN_TIME, m.Time())
|
||||||
m.Cmd(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(mdb.HASH))
|
mdb.HashRemove(m, m.OptionSimple(mdb.HASH))
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,name,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Display("/plugin/table.js", "style", "card")
|
|
||||||
mdb.HashSelect(m, arg...).PushAction(cli.START, mdb.REMOVE)
|
mdb.HashSelect(m, arg...).PushAction(cli.START, mdb.REMOVE)
|
||||||
web.PushPodCmd(m, m.CommandKey(), arg...)
|
web.PushPodCmd(m, m.CommandKey(), arg...)
|
||||||
|
ctx.DisplayTableCard(m)
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package webview
|
package webview
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
"shylinux.com/x/webview"
|
"shylinux.com/x/webview"
|
||||||
)
|
)
|
||||||
@ -16,6 +18,9 @@ type WebView struct {
|
|||||||
func (w WebView) Menu() bool {
|
func (w WebView) Menu() bool {
|
||||||
list := []string{}
|
list := []string{}
|
||||||
ice.Pulse.Cmd(nfs.CAT, w.Source, func(ls []string, line string) {
|
ice.Pulse.Cmd(nfs.CAT, w.Source, func(ls []string, line string) {
|
||||||
|
if strings.HasPrefix(line, "# ") {
|
||||||
|
return
|
||||||
|
}
|
||||||
if len(ls) > 1 {
|
if len(ls) > 1 {
|
||||||
list = append(list, kit.Format(`<button onclick=%s()>%s</button>`, ls[0], ls[0]))
|
list = append(list, kit.Format(`<button onclick=%s()>%s</button>`, ls[0], ls[0]))
|
||||||
w.WebView.Bind(ls[0], func() { w.navigate(ls[1]) })
|
w.WebView.Bind(ls[0], func() { w.navigate(ls[1]) })
|
||||||
@ -55,7 +60,7 @@ func (w WebView) OpenCmd(cmd string) {
|
|||||||
ice.Pulse.Cmd(nfs.SAVE, kit.HomePath(".bash_temp"), cmd)
|
ice.Pulse.Cmd(nfs.SAVE, kit.HomePath(".bash_temp"), cmd)
|
||||||
ice.Pulse.Cmd(cli.SYSTEM, "open", "-a", "Terminal")
|
ice.Pulse.Cmd(cli.SYSTEM, "open", "-a", "Terminal")
|
||||||
}
|
}
|
||||||
func (w WebView) Terminate() { w.WebView.Terminate() }
|
func (w WebView) Terminate() { w.WebView.Terminate() }
|
||||||
func (w WebView) Close() {
|
func (w WebView) Close() {
|
||||||
if !w.Menu() {
|
if !w.Menu() {
|
||||||
w.WebView.Terminate()
|
w.WebView.Terminate()
|
||||||
@ -71,7 +76,7 @@ func Run(cb func(*WebView) ice.Any) {
|
|||||||
defer w.Destroy()
|
defer w.Destroy()
|
||||||
defer w.Run()
|
defer w.Run()
|
||||||
|
|
||||||
view := &WebView{Source: "src/webview.txt", WebView: w}
|
view := &WebView{Source: "etc/webview.txt", WebView: w}
|
||||||
kit.Reflect(cb(view), func(name string, value ice.Any) { w.Bind(name, value) })
|
kit.Reflect(cb(view), func(name string, value ice.Any) { w.Bind(name, value) })
|
||||||
|
|
||||||
if !view.Menu() {
|
if !view.Menu() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user