fix skipping recipe list bug

This commit is contained in:
pakintada@gmail.com 2024-02-08 09:18:11 +07:00
parent ece4cef205
commit b3b55be388
6 changed files with 40 additions and 9 deletions

View file

@ -117,7 +117,7 @@ const routes: Routes = [
), ),
canActivate: [ canActivate: [
authGuard, authGuard,
permissionsGuard(UserPermissions.THAI_PERMISSION), permissionsGuard(UserPermissions.VIEWER, UserPermissions.EDITOR),
], ],
}, },
{ {
@ -128,7 +128,7 @@ const routes: Routes = [
).then((m) => m.RecipeDetailsComponent), ).then((m) => m.RecipeDetailsComponent),
canActivate: [ canActivate: [
authGuard, authGuard,
permissionsGuard(UserPermissions.THAI_PERMISSION), permissionsGuard(UserPermissions.VIEWER, UserPermissions.EDITOR),
], ],
}, },
{ {
@ -166,14 +166,14 @@ const routes: Routes = [
(m) => m.UnauthorizedComponent (m) => m.UnauthorizedComponent
), ),
}, },
{ // {
path: 'notfound', // path: 'notfound',
loadComponent: () => // loadComponent: () =>
import('./core/notfound.component').then((m) => m.NotfoundComponent), // import('./core/notfound.component').then((m) => m.NotfoundComponent),
}, // },
{ {
path: '**', path: '**',
redirectTo: 'notfound', redirectTo: 'departments',
}, },
]; ];

View file

@ -25,7 +25,7 @@
</svg> </svg>
</button> </button>
<a <a
routerLink="/{{ current_department }}/recipes" routerLink="/departments"
class="flex ml-14 max-sm:hidden" class="flex ml-14 max-sm:hidden"
> >
<img <img

View file

@ -28,6 +28,7 @@
> >
<td class="font-medium text-gray-900 whitespace-nowrap sticky left-0"> <td class="font-medium text-gray-900 whitespace-nowrap sticky left-0">
<input type="checkbox" class="toggle" formControlName="isUse" /> <input type="checkbox" class="toggle" formControlName="isUse" />
<p>{{i}}</p>
</td> </td>
<td class="font-medium text-gray-900 whitespace-nowrap sticky"> <td class="font-medium text-gray-900 whitespace-nowrap sticky">
<input <input

View file

@ -208,6 +208,7 @@ export class RecipesComponent implements OnInit, OnDestroy, AfterViewInit {
.subscribe({ .subscribe({
next: (files: any) => { next: (files: any) => {
console.log('Obtain saves: ', typeof files, files); console.log('Obtain saves: ', typeof files, files);
this.showSaveNoti = false;
if (files != undefined && typeof files === 'object') { if (files != undefined && typeof files === 'object') {
if (files.files != null) { if (files.files != null) {
console.log( console.log(

View file

@ -491,11 +491,20 @@ func (rr *RecipeRouter) updateRecipe(w http.ResponseWriter, r *http.Request) {
// partial // partial
// err = encoder.Encode(changes) // err = encoder.Encode(changes)
// put changes to redis
if err != nil { if err != nil {
rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipe", zap.Error(errors.WithMessage(err, "Error when write file"))) rr.taoLogger.Log.Error("RecipeRouter.UpdateRecipe", zap.Error(errors.WithMessage(err, "Error when write file")))
http.Error(w, "Internal Error", http.StatusInternalServerError) http.Error(w, "Internal Error", http.StatusInternalServerError)
return 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") w.Header().Add("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]interface{}{ json.NewEncoder(w).Encode(map[string]interface{}{

View file

@ -141,6 +141,26 @@ func (rs *recipeService) GetRecipeDetailMat(request *contracts.RecipeDetailReque
WaterYield: v.WaterYield, WaterYield: v.WaterYield,
}) })
break 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
} }
} }
} }