mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-28 18:02:02 +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) {
|
"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{}{} // {{{
|
data := map[string]interface{}{} // {{{
|
||||||
for _, k := range m.Meta["option"] {
|
for _, k := range m.Meta["option"] {
|
||||||
if v, ok := m.Data[k]; ok {
|
if v, ok := m.Data[k]; ok {
|
||||||
|
@ -345,7 +345,15 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
},
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"module": "nfs", "detail": []interface{}{"pwd"},
|
"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{}{
|
"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")
|
m.Copy(msg, "result").Copy(msg, "append")
|
||||||
return
|
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) {
|
"/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")
|
m.Copy(check, "append")
|
||||||
return
|
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")
|
msg := m.Spawn().Cmd("right", "target", m.Option("module"), m.Append("username"), "show", "context")
|
||||||
m.Copy(msg, "append")
|
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) {
|
"/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") { // {{{
|
if login := m.Spawn().Cmd("/login"); login.Has("template") { // {{{
|
||||||
|
@ -38,17 +38,28 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "detail"}}
|
{{define "detail"}}
|
||||||
<fieldset><legend>{{append . "title"}}</legend>
|
{{$key := append . "title"|meta}}
|
||||||
<a onclick="return action('{{option .Meta "module"}}', '{{detail .Meta}}')" href="/">{{template "code" detail .Meta}}</a>
|
<fieldset><legend>{{append . "title"|meta}}</legend>
|
||||||
<pre><code class="{{append . "title"}}_result"></code></pre>
|
<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>
|
</fieldset>
|
||||||
<script>
|
<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) {
|
ctx.POST("", {module:module, details:details}, function(msg) {
|
||||||
var result = document.getElementsByClassName("{{append . "title"}}_result")[0];
|
var result = document.getElementsByClassName(results)[0];
|
||||||
result.innerHTML = msg.result || msg.message;
|
result.innerHTML = msg.result || msg.message || msg;
|
||||||
})
|
})
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -114,7 +114,7 @@
|
|||||||
|
|
||||||
{{define "upload"}}
|
{{define "upload"}}
|
||||||
<fieldset><legend>upload</legend>
|
<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">
|
<input type="file" name="file"><input type="submit">
|
||||||
</form>
|
</form>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@ -122,7 +122,7 @@
|
|||||||
|
|
||||||
{{define "create"}}
|
{{define "create"}}
|
||||||
<fieldset><legend>create</legend>
|
<fieldset><legend>create</legend>
|
||||||
<form method="POST" action="/create?dir={{option . "dir"}}">
|
<form method="POST" action="/create?dir={{option . "dir"|meta|unscaped}}">
|
||||||
<table>
|
<table>
|
||||||
<tr><td>filename:</td><td><input type="text" name="filename" required><input type="submit"></td></tr>
|
<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>
|
<tr><td>content:</td><td><textarea rows="5" cols="60" name="content"></textarea></td></tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user