From b3b55be388afcc6daf91ecd021a9396d9e274a62 Mon Sep 17 00:00:00 2001 From: "pakintada@gmail.com" Date: Thu, 8 Feb 2024 09:18:11 +0700 Subject: [PATCH] fix skipping recipe list bug --- client/src/app/app-routing.module.ts | 16 +++++++-------- .../src/app/core/layout/layout.component.html | 2 +- .../recipe-list/recipe-list.component.html | 1 + .../app/features/recipes/recipes.component.ts | 1 + server/routers/recipe.go | 9 +++++++++ server/services/recipe/recipe.go | 20 +++++++++++++++++++ 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index cfd77d5..3289799 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -117,7 +117,7 @@ const routes: Routes = [ ), canActivate: [ authGuard, - permissionsGuard(UserPermissions.THAI_PERMISSION), + permissionsGuard(UserPermissions.VIEWER, UserPermissions.EDITOR), ], }, { @@ -128,7 +128,7 @@ const routes: Routes = [ ).then((m) => m.RecipeDetailsComponent), canActivate: [ authGuard, - permissionsGuard(UserPermissions.THAI_PERMISSION), + permissionsGuard(UserPermissions.VIEWER, UserPermissions.EDITOR), ], }, { @@ -166,14 +166,14 @@ const routes: Routes = [ (m) => m.UnauthorizedComponent ), }, - { - path: 'notfound', - loadComponent: () => - import('./core/notfound.component').then((m) => m.NotfoundComponent), - }, + // { + // path: 'notfound', + // loadComponent: () => + // import('./core/notfound.component').then((m) => m.NotfoundComponent), + // }, { path: '**', - redirectTo: 'notfound', + redirectTo: 'departments', }, ]; diff --git a/client/src/app/core/layout/layout.component.html b/client/src/app/core/layout/layout.component.html index ba0c638..010993c 100644 --- a/client/src/app/core/layout/layout.component.html +++ b/client/src/app/core/layout/layout.component.html @@ -25,7 +25,7 @@ +

{{i}}

{ console.log('Obtain saves: ', typeof files, files); + this.showSaveNoti = false; if (files != undefined && typeof files === 'object') { if (files.files != null) { console.log( diff --git a/server/routers/recipe.go b/server/routers/recipe.go index 567c61b..5681898 100644 --- a/server/routers/recipe.go +++ b/server/routers/recipe.go @@ -491,11 +491,20 @@ func (rr *RecipeRouter) updateRecipe(w http.ResponseWriter, r *http.Request) { // partial // err = encoder.Encode(changes) + // put changes to redis + if err != nil { rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipe", zap.Error(errors.WithMessage(err, "Error when write file"))) http.Error(w, "Internal Error", http.StatusInternalServerError) return } + err = rr.cache_db.SetToKey(commit_hash+"_"+filename, changes) + + if err != nil { + rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipeCache", zap.Error(errors.WithMessage(err, "Error when write file"))) + http.Error(w, "Internal Error", http.StatusInternalServerError) + return + } w.Header().Add("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]interface{}{ diff --git a/server/services/recipe/recipe.go b/server/services/recipe/recipe.go index 089b96c..f5d7904 100644 --- a/server/services/recipe/recipe.go +++ b/server/services/recipe/recipe.go @@ -141,6 +141,26 @@ func (rs *recipeService) GetRecipeDetailMat(request *contracts.RecipeDetailReque WaterYield: v.WaterYield, }) break + } else if v.MaterialPathId == 0 { + // this is empty material slot + result.Result = append(result.Result, contracts.RecipeDetailMat{ + StringParam: "", + IsUse: false, + MaterialID: 0, + Name: "", + MixOrder: 0, + FeedParameter: 0, + FeedPattern: 0, + MaterialPathId: 0, + PowderGram: 0, + PowderTime: 0, + StirTime: 0, + SyrupGram: 0, + SyrupTime: 0, + WaterCold: 0, + WaterYield: 0, + }) + break } } }