mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-29 02:09:22 +08:00
add feature
This commit is contained in:
parent
e2d819dc8f
commit
b4541ab2f3
@ -3,18 +3,55 @@ package team
|
|||||||
import (
|
import (
|
||||||
"contexts/ctx"
|
"contexts/ctx"
|
||||||
"contexts/web"
|
"contexts/web"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Index = &ctx.Context{Name: "team", Help: "团队中心",
|
var Index = &ctx.Context{Name: "team", Help: "团队中心",
|
||||||
Caches: map[string]*ctx.Cache{},
|
Caches: map[string]*ctx.Cache{},
|
||||||
Configs: map[string]*ctx.Config{},
|
Configs: map[string]*ctx.Config{},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"task": {Name: "task table title content", Help: "任务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"task": {Name: "task table index level status begin_time close_time target detail", Help: "任务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
if len(arg) == 1 {
|
switch arg[0] {
|
||||||
m.Cmdy("ssh.data", "show", arg[0], "fields", "id", "title", "content")
|
case "progress":
|
||||||
return
|
if len(arg) > 2 {
|
||||||
|
switch arg[2] {
|
||||||
|
case "prepare", "action", "cancel", "finish":
|
||||||
|
m.Cmd("ssh.data", "update", m.Option("table"), arg[1], "status", arg[2])
|
||||||
|
arg = []string{arg[0], m.Option("table")}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Meta["append"] = []string{"prepare", "action", "cancel", "finish"}
|
||||||
|
m.Cmd("ssh.data", "show", arg[1:]).Table(func(index int, value map[string]string) {
|
||||||
|
m.Push(value["status"],
|
||||||
|
fmt.Sprintf("<span data-id='%s' title='%s'>%s</span>", value["id"], value["detail"], value["target"]))
|
||||||
|
})
|
||||||
|
m.Table()
|
||||||
|
|
||||||
|
default:
|
||||||
|
if len(arg) > 1 && arg[1] == "modify" {
|
||||||
|
m.Cmdy("ssh.data", "update", m.Option("table"), m.Option("index"), arg[2], arg[3])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(arg) < 8 {
|
||||||
|
if len(arg) > 2 {
|
||||||
|
arg = arg[:2]
|
||||||
|
}
|
||||||
|
if len(arg) > 1 && arg[1] == "" {
|
||||||
|
arg = arg[:1]
|
||||||
|
}
|
||||||
|
if len(arg) > 0 && arg[0] == "" {
|
||||||
|
arg = arg[:0]
|
||||||
|
}
|
||||||
|
m.Cmdy("ssh.data", "show", arg, "fields", "id", "status", "level", "target", "begin_time", "close_time")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Cmdy("ssh.data", "insert", arg[0],
|
||||||
|
"level", arg[2], "status", arg[3],
|
||||||
|
"begin_time", arg[4], "close_time", arg[5],
|
||||||
|
"target", arg[6], "detail", arg[7], arg[8:],
|
||||||
|
)
|
||||||
}
|
}
|
||||||
m.Cmdy("ssh.data", "insert", arg[0], "title", arg[1], "content", arg[2], arg[3:])
|
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
@ -58,8 +58,15 @@ ctx = context = (function(kit) {var ctx = {__proto__: kit,
|
|||||||
Result: function() {return msg.result? msg.result.join(""): ""},
|
Result: function() {return msg.result? msg.result.join(""): ""},
|
||||||
Results: function() {return kit.Color(msg.Result().replace(/</g, "<").replace(/>/g, ">"))},
|
Results: function() {return kit.Color(msg.Result().replace(/</g, "<").replace(/>/g, ">"))},
|
||||||
Table: function(cb) {if (!msg.append || !msg.append.length || !msg[msg.append[0]]) {return}
|
Table: function(cb) {if (!msg.append || !msg.append.length || !msg[msg.append[0]]) {return}
|
||||||
return kit.List(msg[msg.append[0]], function(value, index, array) {var one = {}
|
var max = "", len = 0
|
||||||
msg.append.forEach(function(key) {one[key] = msg[key][index]})
|
kit.List(msg.append, function(key, index) {
|
||||||
|
if (msg[key].length > len) {
|
||||||
|
max = key, len = msg[key].length
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return kit.List(msg[max], function(value, index, array) {var one = {}
|
||||||
|
msg.append.forEach(function(key) {one[key] = msg[key][index]||""})
|
||||||
return kit._call(cb, [one, index, array])
|
return kit._call(cb, [one, index, array])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -1059,9 +1059,9 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
kit.classList.add(item, "args")
|
kit.classList.add(item, "args")
|
||||||
break
|
break
|
||||||
case "textarea":
|
case "textarea":
|
||||||
var half = parseInt(item.half||"1")||1
|
var half = parseFloat(item.half||"1")||1
|
||||||
kit.AppendChild(option, "br")
|
kit.AppendChild(option, "br")
|
||||||
input.type = "textarea", item.style = "height:"+(item.height||"50px")+";width:"+((pane.target.clientWidth-35)/half)+"px"
|
input.type = "textarea", item.style = "height:"+(item.height||"50px")+";width:"+parseInt(((pane.target.clientWidth-35)/half))+"px"
|
||||||
// no break
|
// no break
|
||||||
case "text":
|
case "text":
|
||||||
item.value = value || item.value || ""
|
item.value = value || item.value || ""
|
||||||
@ -1483,6 +1483,10 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
var text = td.innerText.trim()
|
var text = td.innerText.trim()
|
||||||
if (typeof meta[item] == "function") {meta[item](event, text); return}
|
if (typeof meta[item] == "function") {meta[item](event, text); return}
|
||||||
|
|
||||||
|
var msg = plugin.Event(event)
|
||||||
|
kit.Selector(option, ".args", function(item) {
|
||||||
|
msg.Option(item.name, item.value)
|
||||||
|
})
|
||||||
item == "修改"? (text = kit.AppendChilds(td, [{type: "input", value: text, style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
|
item == "修改"? (text = kit.AppendChilds(td, [{type: "input", value: text, style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
|
||||||
if (event.key == "Enter") {
|
if (event.key == "Enter") {
|
||||||
var id = ""
|
var id = ""
|
||||||
@ -1504,7 +1508,7 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
}, true)
|
}, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}}}]).input, text.focus(), text.setSelectionRange(0, -1)): output[meta[item]]? output[meta[item]](event): plugin.Run(event, [(line[exports[1]]||"").trim(), meta[item]||item], function(msg) {
|
}}}]).input, text.focus(), text.setSelectionRange(0, -1)): output[meta[item]]? output[meta[item]](event): plugin.Run(event, [td.dataset.id||(line[exports[1]]||"").trim(), meta[item]||item], function(msg) {
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -363,6 +363,10 @@ kit = toolkit = (function() {var kit = {__proto__: document,
|
|||||||
kit.Selector(table, "tr", function(item, i) {item == target.parentElement && (index = i)})
|
kit.Selector(table, "tr", function(item, i) {item == target.parentElement && (index = i)})
|
||||||
var name = target.parentElement.parentElement.querySelector("tr").childNodes[i].innerText
|
var name = target.parentElement.parentElement.querySelector("tr").childNodes[i].innerText
|
||||||
name.startsWith(field) && kit._call(event.type=="contextmenu"? cbs: cb, [event, item.innerText, name, item.parentNode.Meta, index])
|
name.startsWith(field) && kit._call(event.type=="contextmenu"? cbs: cb, [event, item.innerText, name, item.parentNode.Meta, index])
|
||||||
|
} else if (target.parentNode.tagName == "TD"){
|
||||||
|
kit.Selector(table, "tr", function(item, i) {item == target.parentElement.parentElement && (index = i)})
|
||||||
|
var name = target.parentElement.parentElement.parentElement.querySelector("tr").childNodes[i].innerText
|
||||||
|
name.startsWith(field) && kit._call(event.type=="contextmenu"? cbs: cb, [event, item.innerText, name, item.parentNode.Meta, index])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
kit.CopyText()
|
kit.CopyText()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user