This commit is contained in:
Liang Ding 2015-11-24 16:44:34 +08:00
parent a732640bc1
commit 0ee3704a5b
7 changed files with 50 additions and 50 deletions

View File

@ -34,8 +34,8 @@ import (
// CrossCompilationHandler handles request of cross compilation. // CrossCompilationHandler handles request of cross compilation.
func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) { func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true} result := util.NewResult()
defer util.RetJSON(w, r, data) defer util.RetResult(w, r, result)
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { 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 { if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
@ -101,7 +101,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
@ -109,12 +109,12 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
stderr, err := cmd.StderrPipe() stderr, err := cmd.StderrPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
if !data["succ"].(bool) { if !result.Succ {
return return
} }
@ -141,7 +141,7 @@ func CrossCompilationHandler(w http.ResponseWriter, r *http.Request) {
if err := cmd.Start(); nil != err { if err := cmd.Start(); nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }

View File

@ -32,8 +32,8 @@ import (
// GoGetHandler handles request of go get. // GoGetHandler handles request of go get.
func GoGetHandler(w http.ResponseWriter, r *http.Request) { func GoGetHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true} result := util.NewResult()
defer util.RetJSON(w, r, data) defer util.RetResult(w, r, result)
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { if httpSession.IsNew {
@ -47,7 +47,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
var args map[string]interface{} var args map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&args); err != nil { if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
@ -65,7 +65,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
@ -73,12 +73,12 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
stderr, err := cmd.StderrPipe() stderr, err := cmd.StderrPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
if !data["succ"].(bool) { if !result.Succ {
return return
} }
@ -105,7 +105,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) {
if err := cmd.Start(); nil != err { if err := cmd.Start(); nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }

View File

@ -34,8 +34,8 @@ import (
// GoInstallHandler handles request of go install. // GoInstallHandler handles request of go install.
func GoInstallHandler(w http.ResponseWriter, r *http.Request) { func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true} result := util.NewResult()
defer util.RetJSON(w, r, data) defer util.RetResult(w, r, result)
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew { 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 { if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
@ -70,7 +70,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
@ -78,12 +78,12 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
stderr, err := cmd.StderrPipe() stderr, err := cmd.StderrPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
if !data["succ"].(bool) { if !result.Succ {
return return
} }
@ -110,7 +110,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) {
if err := cmd.Start(); nil != err { if err := cmd.Start(); nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }

View File

@ -41,20 +41,20 @@ type outputBuf struct {
// RunHandler handles request of executing a binary file. // RunHandler handles request of executing a binary file.
func RunHandler(w http.ResponseWriter, r *http.Request) { func RunHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true} result := util.NewResult()
defer util.RetJSON(w, r, data) defer util.RetResult(w, r, result)
var args map[string]interface{} var args map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&args); err != nil { if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
} }
sid := args["sid"].(string) sid := args["sid"].(string)
wSession := session.WideSessions.Get(sid) wSession := session.WideSessions.Get(sid)
if nil == wSession { if nil == wSession {
data["succ"] = false result.Succ = false
} }
filePath := args["executable"].(string) filePath := args["executable"].(string)
@ -70,13 +70,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
} }
stderr, err := cmd.StderrPipe() stderr, err := cmd.StderrPipe()
if nil != err { if nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
} }
outReader := bufio.NewReader(stdout) outReader := bufio.NewReader(stdout)
@ -84,14 +84,14 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
if err := cmd.Start(); nil != err { if err := cmd.Start(); nil != err {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
} }
wsChannel := session.OutputWS[sid] wsChannel := session.OutputWS[sid]
channelRet := map[string]interface{}{} channelRet := map[string]interface{}{}
if !data["succ"].(bool) { if !result.Succ {
if nil != wsChannel { if nil != wsChannel {
channelRet["cmd"] = "run-done" channelRet["cmd"] = "run-done"
channelRet["output"] = "" channelRet["output"] = ""
@ -235,13 +235,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
// StopHandler handles request of stoping a running process. // StopHandler handles request of stoping a running process.
func StopHandler(w http.ResponseWriter, r *http.Request) { func StopHandler(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{"succ": true} result := util.NewResult()
defer util.RetJSON(w, r, data) defer util.RetResult(w, r, result)
var args map[string]interface{} var args map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&args); err != nil { if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
logger.Error(err) logger.Error(err)
data["succ"] = false result.Succ = false
return return
} }
@ -251,7 +251,7 @@ func StopHandler(w http.ResponseWriter, r *http.Request) {
wSession := session.WideSessions.Get(sid) wSession := session.WideSessions.Get(sid)
if nil == wSession { if nil == wSession {
data["succ"] = false result.Succ = false
return return
} }

View File

@ -186,10 +186,10 @@ var menu = {
url: config.context + '/go/get', url: config.context + '/go/get',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function (data) { beforeSend: function () {
bottomGroup.resetOutput(); bottomGroup.resetOutput();
}, },
success: function (data) { success: function (result) {
} }
}); });
}, },
@ -213,10 +213,10 @@ var menu = {
url: config.context + '/go/install', url: config.context + '/go/install',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function (data) { beforeSend: function () {
bottomGroup.resetOutput(); bottomGroup.resetOutput();
}, },
success: function (data) { success: function (result) {
} }
}); });
}, },
@ -241,10 +241,10 @@ var menu = {
url: config.context + '/go/test', url: config.context + '/go/test',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function (data) { beforeSend: function () {
bottomGroup.resetOutput(); bottomGroup.resetOutput();
}, },
success: function (data) { success: function (result) {
} }
}); });
}, },
@ -269,10 +269,10 @@ var menu = {
url: config.context + '/go/vet', url: config.context + '/go/vet',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function (data) { beforeSend: function () {
bottomGroup.resetOutput(); bottomGroup.resetOutput();
}, },
success: function (data) { success: function (result) {
} }
}); });
}, },
@ -304,7 +304,7 @@ var menu = {
url: config.context + '/build', url: config.context + '/build',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function (result) { beforeSend: function () {
bottomGroup.resetOutput(); bottomGroup.resetOutput();
}, },
success: function (result) { success: function (result) {
@ -336,7 +336,7 @@ var menu = {
url: config.context + '/build', url: config.context + '/build',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function (result) { beforeSend: function () {
bottomGroup.resetOutput(); bottomGroup.resetOutput();
}, },
success: function (result) { success: function (result) {

View File

@ -182,9 +182,9 @@ var tree = {
url: config.context + '/cross', url: config.context + '/cross',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function (data) { success: function (result) {
if (!data.succ) { if (!result.succ) {
$("#dialogAlert").dialog("open", data.msg); $("#dialogAlert").dialog("open", result.msg);
return false; return false;
} }

View File

@ -617,7 +617,7 @@ var wide = {
url: config.context + '/build', url: config.context + '/build',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
beforeSend: function (result) { beforeSend: function () {
bottomGroup.resetOutput(); bottomGroup.resetOutput();
}, },
success: function (result) { success: function (result) {
@ -650,7 +650,7 @@ var wide = {
url: config.context + '/stop', url: config.context + '/stop',
data: JSON.stringify(request), data: JSON.stringify(request),
dataType: "json", dataType: "json",
success: function (data) { success: function (result) {
$("#buildRun").removeClass("ico-stop") $("#buildRun").removeClass("ico-stop")
.addClass("ico-buildrun").attr("title", config.label.build_n_run); .addClass("ico-buildrun").attr("title", config.label.build_n_run);
} }