This commit is contained in:
parent
a732640bc1
commit
0ee3704a5b
|
@ -34,8 +34,8 @@ import (
|
|||
|
||||
// CrossCompilationHandler handles request of cross compilation.
|
||||
func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
result := util.NewResult()
|
||||
defer util.RetResult(w, r, result)
|
||||
|
||||
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
||||
if httpSession.IsNew {
|
||||
|
@ -50,7 +50,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
stdout, err := cmd.StdoutPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -109,12 +109,12 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
stderr, err := cmd.StderrPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if !data["succ"].(bool) {
|
||||
if !result.Succ {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := cmd.Start(); nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ import (
|
|||
|
||||
// GoGetHandler handles request of go get.
|
||||
func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
result := util.NewResult()
|
||||
defer util.RetResult(w, r, result)
|
||||
|
||||
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
||||
if httpSession.IsNew {
|
||||
|
@ -47,7 +47,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var args map[string]interface{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
stdout, err := cmd.StdoutPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -73,12 +73,12 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
stderr, err := cmd.StderrPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if !data["succ"].(bool) {
|
||||
if !result.Succ {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := cmd.Start(); nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ import (
|
|||
|
||||
// GoInstallHandler handles request of go install.
|
||||
func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
result := util.NewResult()
|
||||
defer util.RetResult(w, r, result)
|
||||
|
||||
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
||||
if httpSession.IsNew {
|
||||
|
@ -50,7 +50,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
stdout, err := cmd.StdoutPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -78,12 +78,12 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
stderr, err := cmd.StderrPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if !data["succ"].(bool) {
|
||||
if !result.Succ {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := cmd.Start(); nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -41,20 +41,20 @@ type outputBuf struct {
|
|||
|
||||
// RunHandler handles request of executing a binary file.
|
||||
func RunHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
result := util.NewResult()
|
||||
defer util.RetResult(w, r, result)
|
||||
|
||||
var args map[string]interface{}
|
||||
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
}
|
||||
|
||||
sid := args["sid"].(string)
|
||||
wSession := session.WideSessions.Get(sid)
|
||||
if nil == wSession {
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
}
|
||||
|
||||
filePath := args["executable"].(string)
|
||||
|
@ -70,13 +70,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
stdout, err := cmd.StdoutPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
}
|
||||
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
}
|
||||
|
||||
outReader := bufio.NewReader(stdout)
|
||||
|
@ -84,14 +84,14 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := cmd.Start(); nil != err {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
}
|
||||
|
||||
wsChannel := session.OutputWS[sid]
|
||||
|
||||
channelRet := map[string]interface{}{}
|
||||
|
||||
if !data["succ"].(bool) {
|
||||
if !result.Succ {
|
||||
if nil != wsChannel {
|
||||
channelRet["cmd"] = "run-done"
|
||||
channelRet["output"] = ""
|
||||
|
@ -235,13 +235,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// StopHandler handles request of stoping a running process.
|
||||
func StopHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := map[string]interface{}{"succ": true}
|
||||
defer util.RetJSON(w, r, data)
|
||||
result := util.NewResult()
|
||||
defer util.RetResult(w, r, result)
|
||||
|
||||
var args map[string]interface{}
|
||||
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
|
||||
logger.Error(err)
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ func StopHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
wSession := session.WideSessions.Get(sid)
|
||||
if nil == wSession {
|
||||
data["succ"] = false
|
||||
result.Succ = false
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -186,10 +186,10 @@ var menu = {
|
|||
url: config.context + '/go/get',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (data) {
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
},
|
||||
success: function (data) {
|
||||
success: function (result) {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -213,10 +213,10 @@ var menu = {
|
|||
url: config.context + '/go/install',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (data) {
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
},
|
||||
success: function (data) {
|
||||
success: function (result) {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -241,10 +241,10 @@ var menu = {
|
|||
url: config.context + '/go/test',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (data) {
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
},
|
||||
success: function (data) {
|
||||
success: function (result) {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -269,10 +269,10 @@ var menu = {
|
|||
url: config.context + '/go/vet',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (data) {
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
},
|
||||
success: function (data) {
|
||||
success: function (result) {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -304,7 +304,7 @@ var menu = {
|
|||
url: config.context + '/build',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (result) {
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
},
|
||||
success: function (result) {
|
||||
|
@ -336,7 +336,7 @@ var menu = {
|
|||
url: config.context + '/build',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (result) {
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
},
|
||||
success: function (result) {
|
||||
|
|
|
@ -182,9 +182,9 @@ var tree = {
|
|||
url: config.context + '/cross',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.succ) {
|
||||
$("#dialogAlert").dialog("open", data.msg);
|
||||
success: function (result) {
|
||||
if (!result.succ) {
|
||||
$("#dialogAlert").dialog("open", result.msg);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -617,7 +617,7 @@ var wide = {
|
|||
url: config.context + '/build',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
beforeSend: function (result) {
|
||||
beforeSend: function () {
|
||||
bottomGroup.resetOutput();
|
||||
},
|
||||
success: function (result) {
|
||||
|
@ -650,7 +650,7 @@ var wide = {
|
|||
url: config.context + '/stop',
|
||||
data: JSON.stringify(request),
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
success: function (result) {
|
||||
$("#buildRun").removeClass("ico-stop")
|
||||
.addClass("ico-buildrun").attr("title", config.label.build_n_run);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue