🍵 Fix #158
This commit is contained in:
parent
2bf2272ac1
commit
f892a7138d
|
@ -66,7 +66,7 @@ func initAPINode() {
|
|||
// GetFiles handles request of constructing user workspace file tree.
|
||||
//
|
||||
// The Go API source code package also as a child node,
|
||||
// so that users can easily view the Go API source code in filre tree.
|
||||
// so that users can easily view the Go API source code in file tree.
|
||||
func GetFiles(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
|
@ -103,6 +103,25 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
|
|||
data["root"] = root
|
||||
}
|
||||
|
||||
// RefreshDirectory handles request of refresh a directory of file tree.
|
||||
func RefreshDirectory(w http.ResponseWriter, r *http.Request) {
|
||||
r.ParseForm()
|
||||
path := r.FormValue("path")
|
||||
|
||||
node := FileNode{Name: "root", Path: path, IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}}
|
||||
|
||||
walk(path, &node, true, true)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
data, err := json.Marshal(node.FileNodes)
|
||||
if err != nil {
|
||||
glog.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write(data)
|
||||
}
|
||||
|
||||
// GetFile handles request of opening file by editor.
|
||||
func GetFile(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
|
|
|
@ -134,5 +134,6 @@
|
|||
"locale": "Locale",
|
||||
"apply": "Apply",
|
||||
"clearOutput": "Clear Output",
|
||||
"export": "Export"
|
||||
"export": "Export",
|
||||
"refresh": "Refresh"
|
||||
}
|
|
@ -134,5 +134,6 @@
|
|||
"locale": "ロケール",
|
||||
"apply": "適用する",
|
||||
"clearOutput": "空の出力",
|
||||
"export": "輸出"
|
||||
"export": "輸出",
|
||||
"refresh": "リフレッシュ"
|
||||
}
|
||||
|
|
|
@ -134,5 +134,6 @@
|
|||
"locale": "语言环境",
|
||||
"apply": "应用",
|
||||
"clearOutput": "清空输出",
|
||||
"export": "导出"
|
||||
"export": "导出",
|
||||
"refresh": "刷新"
|
||||
}
|
|
@ -134,5 +134,6 @@
|
|||
"locale": "語言環境",
|
||||
"apply": "應用",
|
||||
"clearOutput": "清空輸出",
|
||||
"export": "導出"
|
||||
"export": "導出",
|
||||
"refresh": "刷新"
|
||||
}
|
1
main.go
1
main.go
|
@ -273,6 +273,7 @@ func main() {
|
|||
|
||||
// file tree
|
||||
http.HandleFunc("/files", handlerWrapper(file.GetFiles))
|
||||
http.HandleFunc("/file/refresh", handlerWrapper(file.RefreshDirectory))
|
||||
http.HandleFunc("/file", handlerWrapper(file.GetFile))
|
||||
http.HandleFunc("/file/save", handlerWrapper(file.SaveFile))
|
||||
http.HandleFunc("/file/new", handlerWrapper(file.NewFile))
|
||||
|
|
|
@ -179,6 +179,18 @@ var tree = {
|
|||
$("#dirRMenu").hide();
|
||||
$("#fileRMenu").hide();
|
||||
},
|
||||
refresh: function (it) {
|
||||
if (it) {
|
||||
if ($(it).hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tree.fileTree.reAsyncChildNodes(wide.curNode, "refresh");
|
||||
|
||||
$("#dirRMenu").hide();
|
||||
$("#fileRMenu").hide();
|
||||
},
|
||||
init: function () {
|
||||
$("#file").click(function () {
|
||||
$(this).focus();
|
||||
|
@ -205,6 +217,11 @@ var tree = {
|
|||
showTitle: true,
|
||||
selectedMulti: false
|
||||
},
|
||||
async: {
|
||||
enable: true,
|
||||
url: "/file/refresh",
|
||||
autoParam: ["path"]
|
||||
},
|
||||
callback: {
|
||||
onDblClick: function (event, treeId, treeNode) {
|
||||
if (treeNode) {
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
<li class="remove" onclick="tree.removeIt(this);">{{.i18n.delete}}</li>
|
||||
<li class="rename" onclick="tree.rename(this);">{{.i18n.rename}}</li>
|
||||
<li class="hr"></li>
|
||||
<li class="refresh" onclick="tree.refresh(this);">{{.i18n.refresh}}</li>
|
||||
<li class="export" onclick="tree.export(this);">{{.i18n.export}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue