mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
opt some
This commit is contained in:
parent
436c230b5f
commit
bbccdd96f5
@ -967,7 +967,7 @@ func main() {
|
|||||||
case "plugin":
|
case "plugin":
|
||||||
arg = arg[1:]
|
arg = arg[1:]
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
m.Cmdy("nfs.dir", m.Conf("publish", "path"), "dir_deep", "dir_reg", ".*\\.so", "time", "size", "hash", "path")
|
m.Cmdy("nfs.dir", m.Conf("publish", "path"), "dir_deep", "dir_reg", ".*\\.so", "time", "size", "hashs", "path")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
fallthrough
|
fallthrough
|
||||||
@ -1094,6 +1094,7 @@ func main() {
|
|||||||
msg.Confm("_index", func(index int, value map[string]interface{}) {
|
msg.Confm("_index", func(index int, value map[string]interface{}) {
|
||||||
value["componet_ctx"] = "cli." + arg[0]
|
value["componet_ctx"] = "cli." + arg[0]
|
||||||
m.Conf("ssh.componet", []interface{}{arg[0], index}, value)
|
m.Conf("ssh.componet", []interface{}{arg[0], index}, value)
|
||||||
|
m.Add("append", "componet", arg[0])
|
||||||
m.Add("append", "index", index)
|
m.Add("append", "index", index)
|
||||||
m.Add("append", "name", value["componet_name"])
|
m.Add("append", "name", value["componet_name"])
|
||||||
m.Add("append", "help", value["componet_help"])
|
m.Add("append", "help", value["componet_help"])
|
||||||
@ -1101,6 +1102,8 @@ func main() {
|
|||||||
m.Table()
|
m.Table()
|
||||||
}
|
}
|
||||||
return e
|
return e
|
||||||
|
} else {
|
||||||
|
m.Log("info", "open %v", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
restart := false
|
restart := false
|
||||||
@ -1192,49 +1195,6 @@ func main() {
|
|||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"plugin": &ctx.Command{Name: "plugin [action] file", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
|
||||||
suffix, action, target := "go", "build", path.Join(m.Conf("runtime", "boot.ctx_home"), "src/examples/app/bench.go")
|
|
||||||
if len(arg) == 0 {
|
|
||||||
arg = append(arg, target)
|
|
||||||
}
|
|
||||||
if cs := strings.Split(arg[0], "."); len(cs) > 1 {
|
|
||||||
suffix = cs[len(cs)-1]
|
|
||||||
} else if cs := strings.Split(arg[1], "."); len(cs) > 1 {
|
|
||||||
suffix, action, arg = cs[len(cs)-1], arg[0], arg[1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
if target = m.Cmdx("nfs.path", arg[0]); target == "" {
|
|
||||||
target = m.Cmdx("nfs.path", path.Join("src/plugin/", arg[0]))
|
|
||||||
}
|
|
||||||
|
|
||||||
for suffix != "" && action != "" {
|
|
||||||
m.Log("info", "%v %v %v", suffix, action, target)
|
|
||||||
cook := m.Confv("plugin", suffix)
|
|
||||||
next := strings.Replace(target, "."+suffix, "."+kit.Chains(cook, "next.0"), -1)
|
|
||||||
|
|
||||||
args := []string{}
|
|
||||||
if suffix == "so" {
|
|
||||||
if p, e := plugin.Open(target); m.Assert(e) {
|
|
||||||
s, e := p.Lookup("Index")
|
|
||||||
m.Assert(e)
|
|
||||||
w := *(s.(**ctx.Context))
|
|
||||||
w.Name = kit.Select(w.Name, arg, 1)
|
|
||||||
c.Register(w, nil)
|
|
||||||
m.Spawn(w).Cmd("_init", arg[1:])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if suffix == "go" {
|
|
||||||
args = append(args, "-o", next)
|
|
||||||
}
|
|
||||||
m.Assert(m.Cmd("cli.system", kit.Chain(cook, action), args, target))
|
|
||||||
}
|
|
||||||
|
|
||||||
suffix = kit.Chains(cook, "next.0")
|
|
||||||
action = kit.Chains(cook, "next.1")
|
|
||||||
target = next
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}},
|
|
||||||
"version": &ctx.Command{Name: "version", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"version": &ctx.Command{Name: "version", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
types := reflect.TypeOf(version)
|
types := reflect.TypeOf(version)
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-07-16 19:44:54", "ZYB-20190522USI", 171,
|
"2019-07-17 01:14:15", "com.mac", 191,
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,9 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
|
|||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
case "cmd":
|
case "cmd":
|
||||||
if arg[0] == "command" {
|
if len(arg) == 0 {
|
||||||
|
arg = append(arg, "command")
|
||||||
|
} else if arg[0] == "command" && len(arg) > 1 {
|
||||||
arg = arg[1:]
|
arg = arg[1:]
|
||||||
}
|
}
|
||||||
if msg.Cmd(arg); !msg.Hand {
|
if msg.Cmd(arg); !msg.Hand {
|
||||||
|
@ -120,10 +120,11 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
},
|
},
|
||||||
"context": []interface{}{
|
"context": []interface{}{
|
||||||
map[string]interface{}{"componet_name": "runtime", "componet_help": "系统",
|
map[string]interface{}{"componet_name": "runtime", "componet_help": "系统",
|
||||||
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
|
"componet_tmpl": "componet", "componet_view": "componet", "componet_init": "",
|
||||||
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "runtime",
|
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "runtime",
|
||||||
"componet_args": []interface{}{"system"}, "inputs": []interface{}{
|
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||||
map[string]interface{}{"type": "button", "value": "运行"},
|
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{"system", "host", "boot", "node", "user", "work"}},
|
||||||
|
map[string]interface{}{"type": "button", "value": "运行", "action": "auto"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
map[string]interface{}{"componet_name": "project", "componet_help": "项目",
|
map[string]interface{}{"componet_name": "project", "componet_help": "项目",
|
||||||
@ -132,7 +133,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||||
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{"plugin", "stat", "init"}},
|
map[string]interface{}{"type": "select", "name": "cmd", "values": []interface{}{"plugin", "stat", "init"}},
|
||||||
map[string]interface{}{"type": "text", "name": "who"},
|
map[string]interface{}{"type": "text", "name": "who"},
|
||||||
map[string]interface{}{"type": "button", "value": "执行"},
|
map[string]interface{}{"type": "button", "value": "执行", "action": "auto"},
|
||||||
},
|
},
|
||||||
"exports": []interface{}{"see", "filename", "see"},
|
"exports": []interface{}{"see", "filename", "see"},
|
||||||
},
|
},
|
||||||
@ -284,7 +285,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
|
||||||
"componet_args": []interface{}{"$$", "context", "nfs", "dir", "$$", "time", "size", "line", "path"}, "inputs": []interface{}{
|
"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": "pod", "imports": []interface{}{"plugin_you", "plugin_pod"}},
|
||||||
map[string]interface{}{"type": "text", "name": "dir", "value": "usr/script", "view": "long", "imports": "plugin_dir", "action": "auto"},
|
map[string]interface{}{"type": "text", "name": "dir", "value": "usr/script", "imports": "plugin_dir", "action": "auto", "history": "true", "view": "long"},
|
||||||
map[string]interface{}{"type": "button", "value": "查看", "action": "auto"},
|
map[string]interface{}{"type": "button", "value": "查看", "action": "auto"},
|
||||||
map[string]interface{}{"type": "button", "value": "回退", "click": "Back"},
|
map[string]interface{}{"type": "button", "value": "回退", "click": "Back"},
|
||||||
},
|
},
|
||||||
|
@ -343,14 +343,17 @@ page = Page({
|
|||||||
"表格": function(event, value) {
|
"表格": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.display("table")
|
page.plugin && page.plugin.Plugin.display("table")
|
||||||
},
|
},
|
||||||
"图表": function(event, value) {
|
"编辑": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.display("trend")
|
page.plugin && page.plugin.Plugin.display("editor")
|
||||||
|
},
|
||||||
|
"绘图": function(event, value) {
|
||||||
|
page.plugin && page.plugin.Plugin.display("canvas")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"], "",
|
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"], "",
|
||||||
"刷新", "清空", "并行", "串行", "",
|
"刷新", "清空", "并行", "串行", "",
|
||||||
"添加", "删除", "加参", "减参", "",
|
"添加", "删除", "加参", "减参", "",
|
||||||
["display", "表格", "图表"],
|
["display", "表格", "绘图"],
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -513,6 +513,9 @@ function Pane(page, field) {
|
|||||||
} else {
|
} else {
|
||||||
first && index == 0 && ui.first.click()
|
first && index == 0 && ui.first.click()
|
||||||
}
|
}
|
||||||
|
if (index == msg[msg.append[0]].length-1) {
|
||||||
|
pane.Field.scrollTo(0, 0)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Share: function(objs) {
|
Share: function(objs) {
|
||||||
@ -629,7 +632,7 @@ function Plugin(page, pane, field) {
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
item.type != "textarea" && event.key == "Enter" && plugin.Check(action)
|
item.type != "textarea" && event.key == "Enter" && (item.history == "true"? plugin.Goto(event.target.value): plugin.Check(action))
|
||||||
}
|
}
|
||||||
|
|
||||||
var input = {type: "input", name: name, data: item}
|
var input = {type: "input", name: name, data: item}
|
||||||
@ -674,13 +677,13 @@ function Plugin(page, pane, field) {
|
|||||||
var ui = kit.AppendChild(option, [{view: [item.view||""], list: [{type: "label", inner: item.label||""}, input]}])
|
var ui = kit.AppendChild(option, [{view: [item.view||""], list: [{type: "label", inner: item.label||""}, input]}])
|
||||||
var action = ui[name] || {}
|
var action = ui[name] || {}
|
||||||
|
|
||||||
action.History = [""], action.Goto = function(value, cb) {
|
item.history == "true" && (action.History = [""], plugin.Goto = function(value) {
|
||||||
action.History.push(action.value = value)
|
action.History.push(action.value = value)
|
||||||
plugin.Check(action, cb)
|
plugin.Runs(window.event)
|
||||||
return value
|
return value
|
||||||
}, action.Back = function() {
|
}, plugin.Back = function() {
|
||||||
action.History.pop(), action.History.length > 0 && action.Goto(action.History.pop())
|
action.History.pop(), action.History.length > 0 && plugin.Goto(action.History.pop())
|
||||||
};
|
});
|
||||||
|
|
||||||
(typeof item.imports == "object"? item.imports: typeof item.imports == "string"? [item.imports]: []).forEach(function(imports) {
|
(typeof item.imports == "object"? item.imports: typeof item.imports == "string"? [item.imports]: []).forEach(function(imports) {
|
||||||
page.Sync(imports).change(function(value) {
|
page.Sync(imports).change(function(value) {
|
||||||
@ -768,9 +771,6 @@ function Plugin(page, pane, field) {
|
|||||||
canvas: function(msg, cb) {
|
canvas: function(msg, cb) {
|
||||||
typeof cb == "function" && !cb(msg) || (output.innerHTML = "", Canvas(plugin, option, output, output.clientWidth-40, 400, 10, msg))
|
typeof cb == "function" && !cb(msg) || (output.innerHTML = "", Canvas(plugin, option, output, output.clientWidth-40, 400, 10, msg))
|
||||||
},
|
},
|
||||||
trend: function(msg, cb) {
|
|
||||||
typeof cb == "function" && !cb(msg) || (output.innerHTML = "", Canvas(plugin, output, output.clientWidth-40, 400, 10, msg))
|
|
||||||
},
|
|
||||||
point: function(msg) {
|
point: function(msg) {
|
||||||
var id = "canvas"+page.ID()
|
var id = "canvas"+page.ID()
|
||||||
var canvas = kit.AppendChild(output, [{view: ["draw", "canvas"], data: {id: id, width: output.clientWidth-15}}]).last.getContext("2d")
|
var canvas = kit.AppendChild(output, [{view: ["draw", "canvas"], data: {id: id, width: output.clientWidth-15}}]).last.getContext("2d")
|
||||||
@ -823,9 +823,9 @@ function Plugin(page, pane, field) {
|
|||||||
if (name != "path") {
|
if (name != "path") {
|
||||||
value = line.path
|
value = line.path
|
||||||
}
|
}
|
||||||
|
plugin.Goto(value)
|
||||||
|
return value
|
||||||
if (value.endsWith("/")) {
|
if (value.endsWith("/")) {
|
||||||
option.dir.Goto(value)
|
|
||||||
return value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
option.dir.value = value
|
option.dir.value = value
|
||||||
@ -881,7 +881,7 @@ function Editor(plugin, option, output, width, height, space, msg) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
kit.AppendChild(output, [{view: ["edit", "table"], list: msg.result.map(function(value, index) {
|
kit.AppendChild(output, [{view: ["edit", "table"], list: (msg.result||[]).map(function(value, index) {
|
||||||
return {view: ["line", "tr"], list: [{view: ["num", "td", index+1]}, {view: ["txt", "td"], list: [{value: value, style: {width: width+"px"}, input: [value, function(event) {
|
return {view: ["line", "tr"], list: [{view: ["num", "td", index+1]}, {view: ["txt", "td"], list: [{value: value, style: {width: width+"px"}, input: [value, function(event) {
|
||||||
if (event.key == "Enter") {
|
if (event.key == "Enter") {
|
||||||
field.Run(event, args.concat(["dir_sed", "set", index, event.target.value]))
|
field.Run(event, args.concat(["dir_sed", "set", index, event.target.value]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user