mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add nfs.draw
This commit is contained in:
parent
dc711c73c7
commit
13c9d07f71
@ -195,7 +195,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
"path": "usr/work",
|
||||
}, Help: "免密登录"},
|
||||
|
||||
|
||||
"timer": &ctx.Config{Name: "timer", Value: map[string]interface{}{}, Help: "定时器"},
|
||||
"timer_next": &ctx.Config{Name: "timer_next", Value: "", Help: "定时器"},
|
||||
"time_unit": &ctx.Config{Name: "time_unit", Value: "1000", Help: "时间倍数"},
|
||||
@ -669,6 +668,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
||||
m.Cmd("cli.version", "create")
|
||||
if len(arg) > 0 && arg[0] == "self" {
|
||||
if m.Cmdy("cli.system", "go", "install", m.Cmdx("nfs.path", m.Conf("compile", "bench"))); m.Result(0) == "" {
|
||||
m.Echo("version %v ", version.self)
|
||||
m.Cmdy("cli.quit", 1)
|
||||
}
|
||||
return
|
||||
@ -785,22 +785,22 @@ var version = struct {
|
||||
return
|
||||
}
|
||||
if len(arg) > 0 && arg[0] == "plugin" {
|
||||
m.Cmdy("web.get", "dev", fmt.Sprintf("publish/%s", arg[1]),
|
||||
"upgrade", "plugin", "save", path.Join("src/plugin", arg[1]))
|
||||
m.Cmdy("cli.plugin", "test.so")
|
||||
m.Cmdy("web.get", "dev", fmt.Sprintf("publish/%s", arg[1]),
|
||||
"upgrade", "plugin", "save", path.Join("src/plugin", arg[1]))
|
||||
m.Cmdy("cli.plugin", "test.so")
|
||||
return
|
||||
}
|
||||
if len(arg) > 1 && arg[0] == "script" {
|
||||
miss := ""
|
||||
if len(arg) > 2 {
|
||||
miss, arg = arg[1], arg[2:]
|
||||
} else {
|
||||
arg = arg[1:]
|
||||
}
|
||||
for _, v := range arg {
|
||||
m.Cmdy("web.get", "dev", fmt.Sprintf("publish/%s", v),
|
||||
"upgrade", "script", "missyou", miss, "save", path.Join("usr/script", v))
|
||||
}
|
||||
miss := ""
|
||||
if len(arg) > 2 {
|
||||
miss, arg = arg[1], arg[2:]
|
||||
} else {
|
||||
arg = arg[1:]
|
||||
}
|
||||
for _, v := range arg {
|
||||
m.Cmdy("web.get", "dev", fmt.Sprintf("publish/%s", v),
|
||||
"upgrade", "script", "missyou", miss, "save", path.Join("usr/script", v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,5 @@ var version = struct {
|
||||
host string
|
||||
self int
|
||||
}{
|
||||
"2019-07-04 21:17:32", "ZYB-20190522USI", 112,
|
||||
"2019-07-05 08:16:40", "com.mac", 41,
|
||||
}
|
||||
|
@ -69,28 +69,28 @@ func dir(m *ctx.Message, name string, level int, deep bool, dir_type string, tri
|
||||
} else {
|
||||
m.Add("append", "type", "file")
|
||||
}
|
||||
case "full":
|
||||
if f.IsDir() {
|
||||
m.Add("append", "full", path.Join(back, name, f.Name())+"/")
|
||||
} else {
|
||||
m.Add("append", "full", path.Join(back, name, f.Name()))
|
||||
}
|
||||
case "path":
|
||||
if f.IsDir() {
|
||||
m.Add("append", "path", path.Join(back, name, f.Name())[trip:]+"/")
|
||||
} else {
|
||||
m.Add("append", "path", path.Join(back, name, f.Name())[trip:])
|
||||
}
|
||||
case "tree":
|
||||
if level == 0 {
|
||||
m.Add("append", "tree", f.Name())
|
||||
} else {
|
||||
m.Add("append", "tree", strings.Repeat("| ", level-1)+"|-"+f.Name())
|
||||
}
|
||||
case "filename":
|
||||
if f.IsDir() {
|
||||
m.Add("append", "filename", f.Name()+"/")
|
||||
} else {
|
||||
case "full":
|
||||
if f.IsDir() {
|
||||
m.Add("append", "full", path.Join(back, name, f.Name())+"/")
|
||||
} else {
|
||||
m.Add("append", "full", path.Join(back, name, f.Name()))
|
||||
}
|
||||
case "path":
|
||||
if f.IsDir() {
|
||||
m.Add("append", "path", path.Join(back, name, f.Name())[trip:]+"/")
|
||||
} else {
|
||||
m.Add("append", "path", path.Join(back, name, f.Name())[trip:])
|
||||
}
|
||||
case "tree":
|
||||
if level == 0 {
|
||||
m.Add("append", "tree", f.Name())
|
||||
} else {
|
||||
m.Add("append", "tree", strings.Repeat("| ", level-1)+"|-"+f.Name())
|
||||
}
|
||||
case "filename":
|
||||
if f.IsDir() {
|
||||
m.Add("append", "filename", f.Name()+"/")
|
||||
} else {
|
||||
m.Add("append", "filename", f.Name())
|
||||
}
|
||||
case "size":
|
||||
@ -824,23 +824,23 @@ func (nfs *NFS) Send(meta string, arg ...interface{}) *NFS {
|
||||
|
||||
line := "\n"
|
||||
if meta != "" {
|
||||
if text, ok := arg[0].(string); ok && meta == "result" && len(text) > 1024 {
|
||||
text := arg[0].(string)
|
||||
for i := 0; i < len(text); i += 1024 {
|
||||
j := i + 1024
|
||||
if j >= len(text) {
|
||||
j = len(text)
|
||||
}
|
||||
line = fmt.Sprintf("%s: %s\n", url.QueryEscape(meta), url.QueryEscape(kit.Format(text[i:j])))
|
||||
n, e := fmt.Fprint(nfs.io, line)
|
||||
m.Assert(e)
|
||||
m.Capi("nwrite", n)
|
||||
m.Log("send", "%d [%s]", len(line), line)
|
||||
}
|
||||
return nfs
|
||||
} else {
|
||||
line = fmt.Sprintf("%s: %s\n", url.QueryEscape(meta), url.QueryEscape(kit.Format(arg[0])))
|
||||
}
|
||||
if text, ok := arg[0].(string); ok && meta == "result" && len(text) > 1024 {
|
||||
text := arg[0].(string)
|
||||
for i := 0; i < len(text); i += 1024 {
|
||||
j := i + 1024
|
||||
if j >= len(text) {
|
||||
j = len(text)
|
||||
}
|
||||
line = fmt.Sprintf("%s: %s\n", url.QueryEscape(meta), url.QueryEscape(kit.Format(text[i:j])))
|
||||
n, e := fmt.Fprint(nfs.io, line)
|
||||
m.Assert(e)
|
||||
m.Capi("nwrite", n)
|
||||
m.Log("send", "%d [%s]", len(line), line)
|
||||
}
|
||||
return nfs
|
||||
} else {
|
||||
line = fmt.Sprintf("%s: %s\n", url.QueryEscape(meta), url.QueryEscape(kit.Format(arg[0])))
|
||||
}
|
||||
}
|
||||
|
||||
n, e := fmt.Fprint(nfs.io, line)
|
||||
@ -998,7 +998,7 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool {
|
||||
msg, code, head, body := m, "0", "result", "append"
|
||||
bio := bufio.NewScanner(nfs.io)
|
||||
bio.Buffer(make([]byte, m.Confi("buf_size")), m.Confi("buf_size"))
|
||||
for ; bio.Scan(); {
|
||||
for bio.Scan() {
|
||||
|
||||
m.TryCatch(m, true, func(m *ctx.Message) {
|
||||
switch field, value := nfs.Recv(bio.Text()); field {
|
||||
@ -1349,10 +1349,10 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
|
||||
m.Confm("grep", "list", func(index int, value map[string]interface{}) {
|
||||
f, e := os.Open(kit.Format(value["file"]))
|
||||
if e != nil {
|
||||
m.Log("warn", "%v", e)
|
||||
return
|
||||
}
|
||||
if e != nil {
|
||||
m.Log("warn", "%v", e)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
// s, e := f.Stat()
|
||||
@ -1389,6 +1389,41 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
return
|
||||
}},
|
||||
|
||||
"draw": &ctx.Command{Name: "draw", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
for len(arg) > 0 {
|
||||
switch arg[0] {
|
||||
case "trend":
|
||||
m.Add("append", "type", arg[0])
|
||||
m.Add("append", "meta", kit.Formats(arg[1:]))
|
||||
arg = arg[:0]
|
||||
|
||||
case "begin":
|
||||
m.Add("append", "type", arg[0])
|
||||
m.Add("append", "meta", "{}")
|
||||
arg = arg[1:]
|
||||
|
||||
case "circle":
|
||||
m.Add("append", "type", arg[0])
|
||||
m.Add("append", "meta", kit.Format(map[string]string{
|
||||
"x": arg[1], "y": arg[2], "r": arg[3],
|
||||
}))
|
||||
arg = arg[4:]
|
||||
|
||||
case "stroke":
|
||||
m.Add("append", "type", arg[0])
|
||||
m.Add("append", "meta", kit.Format(map[string]string{
|
||||
"width": arg[1],
|
||||
"color": arg[2],
|
||||
}))
|
||||
arg = arg[3:]
|
||||
|
||||
default:
|
||||
arg = arg[1:]
|
||||
}
|
||||
}
|
||||
return
|
||||
}},
|
||||
|
||||
"hash": &ctx.Command{Name: "hash filename", Help: "查找文件路径", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||
dir, name := path.Split(arg[0])
|
||||
m.Append("dir", dir)
|
||||
|
@ -65,7 +65,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"type": "text", "name": "sub", "imports": "plugin_branch", "view": "long"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
"options": map[string]interface{}{"call_timeout": "180s"},
|
||||
"options": map[string]interface{}{"call_timeout": "180s"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "script", "componet_help": "脚本",
|
||||
"componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "",
|
||||
@ -151,7 +151,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"type": "button", "value": "升级"},
|
||||
},
|
||||
"display": map[string]interface{}{"hide_append": true, "show_result": true},
|
||||
"options": map[string]interface{}{"call_timeout": "180s"},
|
||||
"options": map[string]interface{}{"call_timeout": "180s"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "missyou", "componet_help": "任务",
|
||||
"componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "",
|
||||
@ -179,7 +179,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_args": []interface{}{"$$", "context", "aaa", "clip"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "you", "imports": "plugin_you", "action": "auto"},
|
||||
map[string]interface{}{"type": "text", "name": "txt", "view": "long"},
|
||||
map[string]interface{}{"type": "button", "value": "存储", "action": "auto"},
|
||||
map[string]interface{}{"type": "button", "value": "存储", "action": "auto"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "qrcode", "componet_help": "二维码",
|
||||
@ -199,6 +199,16 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"type": "button", "value": "计算"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "email", "componet_help": "电子邮件",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "email",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"label": "收件人", "type": "text", "name": "to", "value": "shylinux@163.com", "view": "long"},
|
||||
map[string]interface{}{"label": "主题", "type": "text", "name": "title", "view": "long"},
|
||||
map[string]interface{}{"type": "button", "value": "发送", "view": "clear"},
|
||||
map[string]interface{}{"type": "textarea", "name": "content", "view": "clear"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "location", "componet_help": "地理位置",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "location",
|
||||
@ -208,17 +218,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"type": "button", "value": "查看"},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "email", "componet_help": "电子邮件",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "email",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"label": "收件人", "type": "text", "name": "to", "value": "shylinux@163.com","view": "long"},
|
||||
map[string]interface{}{"label": "主题", "type": "text", "name": "title", "view": "long"},
|
||||
map[string]interface{}{"type": "button", "value": "发送", "view": "clear"},
|
||||
map[string]interface{}{"type": "textarea", "name": "content", "view": "clear"},
|
||||
},
|
||||
"display": map[string]interface{}{"map": true},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "baidu", "componet_help": "百度地图",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "location",
|
||||
@ -227,7 +226,16 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
map[string]interface{}{"type": "button", "value": "位置", "click": "Location"},
|
||||
map[string]interface{}{"type": "button", "value": "查看"},
|
||||
},
|
||||
"display": map[string]interface{}{"map": true},
|
||||
"display": map[string]interface{}{"deal": "map"},
|
||||
},
|
||||
map[string]interface{}{"componet_name": "draw", "componet_help": "绘图",
|
||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||
"componet_type": "public", "componet_ctx": "nfs", "componet_cmd": "draw",
|
||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "type"},
|
||||
map[string]interface{}{"type": "button", "value": "查看"},
|
||||
},
|
||||
"display": map[string]interface{}{"deal": "point"},
|
||||
},
|
||||
},
|
||||
"index": []interface{}{
|
||||
@ -255,7 +263,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{"$$", "context", "$$", "command"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": "plugin_pod"},
|
||||
map[string]interface{}{"type": "text", "name": "ctx", "value": "nfs", "imports": "plugin_ctx"},
|
||||
map[string]interface{}{"type": "text", "name": "ctx", "value": "nfs", "imports": "plugin_ctx"},
|
||||
map[string]interface{}{"type": "text", "name": "cmd", "value": "pwd"},
|
||||
map[string]interface{}{"type": "button", "value": "执行"},
|
||||
},
|
||||
@ -265,8 +273,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||
"componet_args": []interface{}{"$$", "context", "nfs", "dir", "$$", "time", "size", "line", "path"}, "inputs": []interface{}{
|
||||
map[string]interface{}{"type": "text", "name": "pod", "imports": []interface{}{"plugin_you", "plugin_pod"}},
|
||||
map[string]interface{}{"type": "text", "name": "dir", "value": "", "view": "long", "imports": "plugin_dir", "action": "auto"},
|
||||
map[string]interface{}{"type": "button", "value": "查看", "action": "auto"},
|
||||
map[string]interface{}{"type": "text", "name": "dir", "value": "", "view": "long", "imports": "plugin_dir", "action": "auto"},
|
||||
map[string]interface{}{"type": "button", "value": "查看", "action": "auto"},
|
||||
map[string]interface{}{"type": "button", "value": "回退", "click": "Back"},
|
||||
},
|
||||
"display": map[string]interface{}{"hide_result": true},
|
||||
@ -511,11 +519,11 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
||||
}
|
||||
|
||||
msg := m.Find(kit.Format(tool["componet_ctx"]))
|
||||
if option, ok := tool["options"].(map[string]interface{}); ok {
|
||||
for k, v := range option {
|
||||
msg.Option(k, v)
|
||||
}
|
||||
}
|
||||
if option, ok := tool["options"].(map[string]interface{}); ok {
|
||||
for k, v := range option {
|
||||
msg.Option(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
arg = arg[4:]
|
||||
args := []string{}
|
||||
|
@ -715,6 +715,7 @@ function Plugin(page, pane, field) {
|
||||
}, 1000)
|
||||
event.Plugin = plugin, field.Run(event, args, function(msg) {
|
||||
show = false, page.ontoast("")
|
||||
output.innerHTML = ""
|
||||
plugin.ondaemon[display.deal||"table"](msg)
|
||||
typeof cb == "function" && cb(msg)
|
||||
})
|
||||
@ -733,20 +734,36 @@ function Plugin(page, pane, field) {
|
||||
ondaemon: {
|
||||
void: function(msg) {},
|
||||
table: function(msg) {
|
||||
output.innerHTML = ""
|
||||
if (display.map) {
|
||||
kit.AppendChild(output, [{img: ["https://gss0.bdstatic.com/8bo_dTSlRMgBo1vgoIiO_jowehsv/tile/?qt=vtile&x=25310&y=9426&z=17&styles=pl&scaler=2&udt=20190622"]}])
|
||||
return
|
||||
}
|
||||
output.innerHTML = ""
|
||||
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value, name, line) {
|
||||
// if (line["latitude"]) {
|
||||
// page.openLocation(line.latitude, line.longitude, line.location)
|
||||
// }
|
||||
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
||||
});
|
||||
(display.show_result || !msg.append) && msg.result && kit.OrderCode(kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}]).first)
|
||||
},
|
||||
point: function(msg) {
|
||||
var id = "canvas"+page.ID()
|
||||
var canvas = kit.AppendChild(output, [{view: ["draw", "canvas"], data: {id: id, width: output.clientWidth-15}}]).last.getContext("2d")
|
||||
ctx.Table(msg, function(line) {
|
||||
var meta = JSON.parse(line.meta||"{}")
|
||||
switch (line.type) {
|
||||
case "begin":
|
||||
canvas.beginPath()
|
||||
break
|
||||
|
||||
case "circle":
|
||||
canvas.arc(parseInt(meta.x), parseInt(meta.y), parseInt(meta.r), 0, Math.PI*2, true)
|
||||
break
|
||||
|
||||
case "stroke":
|
||||
canvas.strokeStyle = meta.color
|
||||
canvas.lineWidth = parseInt(meta.width)
|
||||
canvas.stroke()
|
||||
break
|
||||
}
|
||||
})
|
||||
},
|
||||
map: function(msg) {
|
||||
kit.AppendChild(output, [{img: ["https://gss0.bdstatic.com/8bo_dTSlRMgBo1vgoIiO_jowehsv/tile/?qt=vtile&x=25310&y=9426&z=17&styles=pl&scaler=2&udt=20190622"]}])
|
||||
},
|
||||
},
|
||||
onexport: {
|
||||
"": function(value, name) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user