mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 01:04:06 +08:00
tce mod nfs.json
This commit is contained in:
parent
fa8bf1607a
commit
2a7c0dfe65
@ -1099,6 +1099,31 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
||||
} // }}}
|
||||
}},
|
||||
"json": &ctx.Command{Name: "json [key value]...", Help: "生成格式化内容, key: 参数名, value: 参数值", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
if len(arg) == 1 {
|
||||
data := map[string]interface{}{}
|
||||
e := json.Unmarshal([]byte(arg[0]), &data)
|
||||
m.Assert(e)
|
||||
|
||||
buf, e := json.MarshalIndent(data, "", " ")
|
||||
m.Assert(e)
|
||||
m.Echo("'")
|
||||
m.Echo(string(buf))
|
||||
m.Echo("'")
|
||||
return
|
||||
}
|
||||
|
||||
if len(arg) > 1 && arg[0] == "file" {
|
||||
data := map[string]interface{}{}
|
||||
f, e := os.Open(arg[1])
|
||||
m.Assert(e)
|
||||
d := json.NewDecoder(f)
|
||||
d.Decode(&data)
|
||||
|
||||
buf, e := json.MarshalIndent(data, "", " ")
|
||||
m.Assert(e)
|
||||
m.Echo(string(buf))
|
||||
return
|
||||
}
|
||||
data := map[string]interface{}{} // {{{
|
||||
for _, k := range m.Meta["option"] {
|
||||
if v, ok := m.Data[k]; ok {
|
||||
|
@ -345,7 +345,15 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"module": "nfs", "detail": []interface{}{"pwd"},
|
||||
"template": "detail", "title": "detail",
|
||||
"template": "detail", "title": "pwd",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"module": "cli", "detail": []interface{}{"time"},
|
||||
"template": "detail", "title": "time",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"module": "nfs", "detail": []interface{}{"json"},
|
||||
"template": "detail", "title": "json",
|
||||
},
|
||||
},
|
||||
"xujianing": []interface{}{
|
||||
@ -664,7 +672,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
}
|
||||
}
|
||||
|
||||
msg := m.Find(m.Option("module")).Cmd(m.Option("details"))
|
||||
msg := m.Find(m.Option("module")).Cmd(m.Optionv("details"))
|
||||
m.Copy(msg, "result").Copy(msg, "append")
|
||||
return
|
||||
}
|
||||
@ -954,7 +962,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
// }}}
|
||||
}},
|
||||
"/share": &ctx.Command{Name: "/share arg...", Help: "资源共享", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
if check := m.Spawn().Cmd("/check", "target", m.Option("module"), m.Optionv("share")); !check.Results(0) {
|
||||
if check := m.Spawn().Cmd("/check", "target", m.Option("module"), m.Optionv("share")); !check.Results(0) { // {{{
|
||||
m.Copy(check, "append")
|
||||
return
|
||||
}
|
||||
@ -969,6 +977,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
||||
|
||||
msg := m.Spawn().Cmd("right", "target", m.Option("module"), m.Append("username"), "show", "context")
|
||||
m.Copy(msg, "append")
|
||||
// }}}
|
||||
}},
|
||||
"/check": &ctx.Command{Name: "/check arg...", Help: "权限检查, cache|config|command: 接口类型, name: 接口名称, args: 其它参数", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
|
||||
if login := m.Spawn().Cmd("/login"); login.Has("template") { // {{{
|
||||
|
@ -38,17 +38,28 @@
|
||||
{{end}}
|
||||
|
||||
{{define "detail"}}
|
||||
<fieldset><legend>{{append . "title"}}</legend>
|
||||
<a onclick="return action('{{option .Meta "module"}}', '{{detail .Meta}}')" href="/">{{template "code" detail .Meta}}</a>
|
||||
<pre><code class="{{append . "title"}}_result"></code></pre>
|
||||
{{$key := append . "title"|meta}}
|
||||
<fieldset><legend>{{append . "title"|meta}}</legend>
|
||||
<input type="text" class="{{$key}}_input" value="" onkeyup="return input(event, '{{option .Meta "module"}}', '{{detail .Meta}}', '{{$key}}_input', '{{$key}}_result')"></input>
|
||||
<a onclick="return action(event, '{{option .Meta "module"}}', '{{detail .Meta}}', '{{$key}}_input', '{{$key}}_result')" href="/">{{template "code" detail .Meta}}</a>
|
||||
<pre><code class="{{$key}}_result"></code></pre>
|
||||
</fieldset>
|
||||
<script>
|
||||
function action(module, details, cb) {
|
||||
function input(event, module, details, input, results) {
|
||||
if (event.code == "Enter") {
|
||||
action(event, module, details, input, results);
|
||||
}
|
||||
}
|
||||
function action(event, module, details, input, results) {
|
||||
var input = document.getElementsByClassName(input)[0];
|
||||
if (input.value != "") {
|
||||
details = [details, input.value];
|
||||
}
|
||||
ctx.POST("", {module:module, details:details}, function(msg) {
|
||||
var result = document.getElementsByClassName("{{append . "title"}}_result")[0];
|
||||
result.innerHTML = msg.result || msg.message;
|
||||
var result = document.getElementsByClassName(results)[0];
|
||||
result.innerHTML = msg.result || msg.message || msg;
|
||||
})
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
{{end}}
|
||||
|
@ -114,7 +114,7 @@
|
||||
|
||||
{{define "upload"}}
|
||||
<fieldset><legend>upload</legend>
|
||||
<form method="POST" action="/create?dir={{option . "dir"}}" enctype="multipart/form-data">
|
||||
<form method="POST" action="/create?dir={{option . "dir"|meta|unscaped}}" enctype="multipart/form-data">
|
||||
<input type="file" name="file"><input type="submit">
|
||||
</form>
|
||||
</fieldset>
|
||||
@ -122,7 +122,7 @@
|
||||
|
||||
{{define "create"}}
|
||||
<fieldset><legend>create</legend>
|
||||
<form method="POST" action="/create?dir={{option . "dir"}}">
|
||||
<form method="POST" action="/create?dir={{option . "dir"|meta|unscaped}}">
|
||||
<table>
|
||||
<tr><td>filename:</td><td><input type="text" name="filename" required><input type="submit"></td></tr>
|
||||
<tr><td>content:</td><td><textarea rows="5" cols="60" name="content"></textarea></td></tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user