add changes diffing modal & silence some logs
This commit is contained in:
parent
148488e2c4
commit
da353cec84
22 changed files with 1770 additions and 120 deletions
|
|
@ -5,7 +5,6 @@ import (
|
|||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"recipe-manager/config"
|
||||
|
|
@ -63,7 +62,7 @@ func (ar *AuthRouter) Route(r chi.Router) {
|
|||
var kind string
|
||||
state := r.URL.Query().Get("state")
|
||||
|
||||
fmt.Println("url query", r.URL.Query())
|
||||
//fmt.Println("url query", r.URL.Query())
|
||||
|
||||
if state == "" {
|
||||
http.Error(w, "State not found", http.StatusBadRequest)
|
||||
|
|
@ -76,7 +75,7 @@ func (ar *AuthRouter) Route(r chi.Router) {
|
|||
return
|
||||
}
|
||||
|
||||
fmt.Println("val", val)
|
||||
//fmt.Println("val", val)
|
||||
|
||||
redirectTo = val["redirect_to"]
|
||||
kind = val["kind"]
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
return
|
||||
}
|
||||
})
|
||||
|
||||
r.Post("/sort/{country}/{filename}", rr.sortRecipe)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -594,7 +596,7 @@ func (rr *RecipeRouter) getSavedRecipes(w http.ResponseWriter, r *http.Request)
|
|||
}
|
||||
|
||||
commits, err := data.GetCommitLogOfFilename(countryID, file_version)
|
||||
// fmt.Println("commits", commits)
|
||||
// //fmt.Println("commits", commits)
|
||||
rr.taoLogger.Log.Debug("RecipeRouter.getSavedRecipes", zap.Any("commits", commits))
|
||||
|
||||
if err != nil || len(commits) == 0 {
|
||||
|
|
@ -836,3 +838,37 @@ func lockThenTimeout(mutex *sync.Mutex, timeout time.Duration) bool {
|
|||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ Sorting ------------------
|
||||
func (rr *RecipeRouter) sortRecipe(w http.ResponseWriter, r *http.Request) {
|
||||
country := chi.URLParam(r, "country")
|
||||
filename := chi.URLParam(r, "filename")
|
||||
|
||||
// get sort type from body
|
||||
var sortConfig map[string]interface{}
|
||||
err := json.NewDecoder(r.Body).Decode(&sortConfig)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
sortKey := sortConfig["sortKey"].(string)
|
||||
|
||||
// sort recipe
|
||||
err, emptiedComparators := rr.data.SortRecipe(country, filename, sortKey)
|
||||
|
||||
if err != nil {
|
||||
|
||||
rr.taoLogger.Log.Error("RecipeRouter.sortRecipe", zap.Error(err), zap.Any("emptiedComparators", emptiedComparators))
|
||||
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"status": "OK",
|
||||
"key": sortKey,
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func NewToppingRouter(data *data.Data, taoLogger *logger.TaoLogger) *ToppingRout
|
|||
func (tr *ToppingRouter) Route(r chi.Router) {
|
||||
|
||||
// check incoming request
|
||||
// fmt.Println("topping router", r.Routes())
|
||||
// //fmt.Println("topping router", r.Routes())
|
||||
|
||||
r.Route("/toppover", func(r chi.Router) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue