auto expand directory after git clone

This commit is contained in:
Van 2015-03-08 12:43:04 +08:00
parent 0af3f70e53
commit 188307ee0a
2 changed files with 7 additions and 4 deletions

View File

@ -39,6 +39,7 @@ type Node struct {
Name string `json:"name"` Name string `json:"name"`
Path string `json:"path"` Path string `json:"path"`
IconSkin string `json:"iconSkin"` // Value should be end with a space IconSkin string `json:"iconSkin"` // Value should be end with a space
IsParent bool `json:"isParent"`
Type string `json:"type"` // "f": file, "d": directory Type string `json:"type"` // "f": file, "d": directory
Creatable bool `json:"creatable"` // whether can create file in this file node Creatable bool `json:"creatable"` // whether can create file in this file node
Removable bool `json:"removable"` // whether can remove this file node Removable bool `json:"removable"` // whether can remove this file node
@ -86,7 +87,7 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
userWorkspace := conf.GetUserWorkspace(username) userWorkspace := conf.GetUserWorkspace(username)
workspaces := filepath.SplitList(userWorkspace) workspaces := filepath.SplitList(userWorkspace)
root := Node{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", Children: []*Node{}} root := Node{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", IsParent: true, Children: []*Node{}}
if nil == apiNode { // lazy init if nil == apiNode { // lazy init
initAPINode() initAPINode()
@ -449,6 +450,7 @@ func walk(path string, node *Node, creatable, removable, isGOAPI bool) {
child.Type = "d" child.Type = "d"
child.Creatable = creatable child.Creatable = creatable
child.IconSkin = "ico-ztree-dir " child.IconSkin = "ico-ztree-dir "
child.IsParent = true
walk(fpath, &child, creatable, removable, isGOAPI) walk(fpath, &child, creatable, removable, isGOAPI)
} else { } else {

View File

@ -236,7 +236,8 @@ var wide = {
"iconSkin": "ico-ztree-dir ", "iconSkin": "ico-ztree-dir ",
"path": request.path, "path": request.path,
"removable": true, "removable": true,
"creatable": true "creatable": true,
"isParent": true
}]); }]);
} }
}); });
@ -476,7 +477,7 @@ var wide = {
break; break;
case 'git clone': case 'git clone':
bottomGroup.fillOutput($('.bottom-window-group .output > div').html() + data.output); bottomGroup.fillOutput($('.bottom-window-group .output > div').html() + data.output);
tree.fileTree.reAsyncChildNodes(wide.curNode, "refresh", true); tree.fileTree.reAsyncChildNodes(wide.curNode, "refresh", false);
break; break;
case 'build': case 'build':