From 498bcf1c24cb0d3028275fa890b9041615a210dd Mon Sep 17 00:00:00 2001 From: Kenta420 Date: Fri, 6 Oct 2023 15:33:10 +0700 Subject: [PATCH] Add material code and settings --- client/src/app/core/models/recipe.model.ts | 13 +-- .../src/app/core/services/material.service.ts | 41 ++++++++++ .../recipe-details.component.html | 81 +++++++++++-------- .../recipe-details.component.ts | 50 ++++++++++-- .../app/features/recipes/recipes.component.ts | 7 +- server/data/data.go | 46 +++++++++++ server/models/recipe.go | 19 ++--- server/routers/material.go | 76 +++++++++++++++++ server/server.go | 6 +- 9 files changed, 279 insertions(+), 60 deletions(-) create mode 100644 client/src/app/core/services/material.service.ts create mode 100644 server/routers/material.go diff --git a/client/src/app/core/models/recipe.model.ts b/client/src/app/core/models/recipe.model.ts index cbfe306..5fba4f8 100644 --- a/client/src/app/core/models/recipe.model.ts +++ b/client/src/app/core/models/recipe.model.ts @@ -3,7 +3,8 @@ export interface Recipe { MachineSetting: MachineSetting; Recipe01: Recipe01[]; Topping: Topping; - MaterailCode: MaterailCode[]; + MaterialCode: MaterialCode[]; + MaterialSetting: MaterialSetting[]; } export interface MachineSetting { @@ -14,10 +15,10 @@ export interface MachineSetting { temperatureMin: string; } -export interface MaterailCode { +export interface MaterialCode { PackageDescription: string; RefillValuePerStep: string; - materialID: string; + materialID: number; materialCode: string; } @@ -25,7 +26,7 @@ export interface Recipe01 { Description: string; ExtendID: string; OnTOP: string; - LastChange: string; + LastChange: Date; MenuStatus: string; RemainingCups: string; StringParam: string; @@ -97,8 +98,8 @@ export interface MatRecipe { MixOrder: string; FeedParameter: string; FeedPattern: string; - isUse: string; - materialPathId: string; + isUse: boolean; + materialPathId: number; powderGram: string; powderTime: string; stirTime: string; diff --git a/client/src/app/core/services/material.service.ts b/client/src/app/core/services/material.service.ts new file mode 100644 index 0000000..4128cd9 --- /dev/null +++ b/client/src/app/core/services/material.service.ts @@ -0,0 +1,41 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { MaterialCode, MaterialSetting } from '../models/recipe.model'; +import { environment } from 'src/environments/environment'; +import { Observable } from 'rxjs'; + +@Injectable({ providedIn: 'root' }) +export class MaterialService { + constructor(private _httpClient: HttpClient) {} + + getMaterialCodes( + matIds?: number[], + version?: string + ): Observable { + return this._httpClient.get( + `${environment.api}/materials/code`, + { + params: { + version: version || '', + mat_ids: matIds?.join(',') || '', + }, + withCredentials: true, + } + ); + } + + getMaterialSettingById( + id: number, + version?: string + ): Observable { + return this._httpClient.get( + `${environment.api}/materials/setting/${id}`, + { + params: { + version: version || '', + }, + withCredentials: true, + } + ); + } +} diff --git a/client/src/app/features/recipes/recipe-details/recipe-details.component.html b/client/src/app/features/recipes/recipe-details/recipe-details.component.html index 3f5b5c9..4f3ebba 100644 --- a/client/src/app/features/recipes/recipe-details/recipe-details.component.html +++ b/client/src/app/features/recipes/recipe-details/recipe-details.component.html @@ -4,20 +4,23 @@ class="block col-span-1 p-6 bg-white border border-gray-200 rounded-lg shadow" >
-
- {{ originalRecipeDetail?.name }} | - {{ originalRecipeDetail?.productCode }} -
+
+
+ {{ originalRecipeDetail.name }} +
+
|
+
+ {{ originalRecipeDetail.productCode }} +
+
-
-

สูตร

-

- {{ originalRecipeDetail?.name }} -

-
-

ประเภท

-

เครื่องดื่ม

+

Last Modify

+

+ {{ + originalRecipeDetail.lastModified | date : "dd/MM/yyyy HH:mm:ss" + }} +

@@ -103,26 +106,38 @@
-
-

- -

+
+ + + + + + + + + + + + + + + +
EnableMaterial IDMaterial Name
+ + + {{ mat.id }} + + {{ mat.name }} +