add fetch all merge logs
This commit is contained in:
parent
baa66609ee
commit
325020fd37
6 changed files with 205 additions and 70 deletions
|
|
@ -12,6 +12,7 @@ import (
|
|||
"path/filepath"
|
||||
"recipe-manager/config"
|
||||
"recipe-manager/data"
|
||||
"recipe-manager/models"
|
||||
"recipe-manager/routers"
|
||||
"recipe-manager/services/oauth"
|
||||
"strings"
|
||||
|
|
@ -159,8 +160,7 @@ func (s *Server) createHandler() {
|
|||
dev_path := repo_path + dev_version + ".json"
|
||||
|
||||
// Get who's requesting
|
||||
user := r.Context().Value("user").(map[string]interface{})
|
||||
log.Println("User: ", user["email"].(string))
|
||||
user := r.Context().Value("user").(*models.User)
|
||||
|
||||
// lookup for python exec
|
||||
py_exec, err := exec.LookPath("python")
|
||||
|
|
@ -178,7 +178,7 @@ func (s *Server) createHandler() {
|
|||
}
|
||||
defer merge_api.Close()
|
||||
log.Println("Locate python api", merge_api.Name())
|
||||
cmd := exec.Command(py_exec, merge_api.Name(), "merge", master_path, dev_path, output_path, changelog_path, "", user["email"].(string))
|
||||
cmd := exec.Command(py_exec, merge_api.Name(), "merge", master_path, dev_path, output_path, changelog_path, "", user.Name)
|
||||
|
||||
log.Println("Run merge command", cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
|
|
@ -214,8 +214,10 @@ func (s *Server) createHandler() {
|
|||
}
|
||||
}
|
||||
|
||||
log.Println("Log file ext: ", file_ext)
|
||||
changelog_path := "cofffeemachineConfig/changelog/testlog" + file_ext
|
||||
log_name := postRequest["filename"].(string)
|
||||
|
||||
// log.Println("Log file ext: ", file_ext)
|
||||
changelog_path := "cofffeemachineConfig/changelog/" + log_name + file_ext
|
||||
logFile, err := os.Open(changelog_path)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
@ -247,6 +249,25 @@ func (s *Server) createHandler() {
|
|||
}
|
||||
|
||||
})
|
||||
|
||||
r.Get("/mergelogList", func(w http.ResponseWriter, r *http.Request) {
|
||||
ch_dir, err := os.ReadDir("cofffeemachineConfig/changelog")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
displayable := make([]string, 0)
|
||||
|
||||
for _, file := range ch_dir {
|
||||
if strings.Contains(file.Name(), ".html") {
|
||||
|
||||
displayable = append(displayable, file.Name()[:len(file.Name())-len(filepath.Ext(file.Name()))])
|
||||
}
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(map[string][]string{"dirs": displayable})
|
||||
})
|
||||
|
||||
// Recipe Router
|
||||
rr := routers.NewRecipeRouter(database)
|
||||
rr.Route(r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue