change display, add StringParam (WIP)
This commit is contained in:
parent
dd1c072201
commit
98341d2d80
11 changed files with 352 additions and 125 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
server/services/logger/serverlog.log
|
server/services/logger/serverlog.log
|
||||||
.idea/
|
.idea/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
server/cofffeemachineConfig
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ export type RecipeDetail = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RecipeDetailMat = {
|
export type RecipeDetailMat = {
|
||||||
|
StringParam: string;
|
||||||
isUse: boolean;
|
isUse: boolean;
|
||||||
materialID: number;
|
materialID: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -75,7 +76,6 @@ export interface Recipe01 {
|
||||||
OnTOP: string;
|
OnTOP: string;
|
||||||
LastChange: Date;
|
LastChange: Date;
|
||||||
MenuStatus: string;
|
MenuStatus: string;
|
||||||
RemainingCups: string;
|
|
||||||
StringParam: string;
|
StringParam: string;
|
||||||
TextForWarningBeforePay: string[];
|
TextForWarningBeforePay: string[];
|
||||||
cashPrice: number;
|
cashPrice: number;
|
||||||
|
|
@ -142,6 +142,7 @@ export interface ToppingList {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MatRecipe {
|
export interface MatRecipe {
|
||||||
|
StringParam: string;
|
||||||
MixOrder: number;
|
MixOrder: number;
|
||||||
FeedParameter: number;
|
FeedParameter: number;
|
||||||
FeedPattern: number;
|
FeedPattern: number;
|
||||||
|
|
@ -164,6 +165,7 @@ export interface ToppingSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MaterialSetting {
|
export interface MaterialSetting {
|
||||||
|
StringParam: string,
|
||||||
AlarmIDWhenOffline: string;
|
AlarmIDWhenOffline: string;
|
||||||
BeanChannel: string;
|
BeanChannel: string;
|
||||||
CanisterType: string;
|
CanisterType: string;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,18 @@
|
||||||
<h5 class="mb-2 text-xl font-bold text-gray-900">
|
<h5 class="mb-2 text-xl font-bold text-gray-900">
|
||||||
{{ recipeDetailForm.getRawValue().otherName }}
|
{{ recipeDetailForm.getRawValue().otherName }}
|
||||||
</h5>
|
</h5>
|
||||||
|
|
||||||
|
<!-- productCode -->
|
||||||
|
<div>
|
||||||
|
<input
|
||||||
|
class="input text-lg text-gray-900 my-2"
|
||||||
|
type="text"
|
||||||
|
name="productCode"
|
||||||
|
[value]="productCode"
|
||||||
|
(keyup)="onProductCodeChange($event)"
|
||||||
|
[disabled]="!isEditable()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center mb-2">
|
<div class="flex items-center mb-2">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
|
|
@ -296,20 +308,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="sticky bottom-0 col-span-3 flex justify-end bg-white rounded-full drop-shadow-2xl p-3"
|
class="sticky bottom-0 col-span-3 flex justify-end bg-white rounded-full drop-shadow-2xl p-3"
|
||||||
>
|
>
|
||||||
<!-- <div> Commit Message </div> -->
|
<!-- <div> Commit Message </div> -->
|
||||||
<!-- <p class="text-2xl mr-8 text-gray-400 dark:text-gray-500">Commit Message</p> -->
|
<!-- <p class="text-2xl mr-8 text-gray-400 dark:text-gray-500">Commit Message</p> -->
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="commit-message"
|
name="commit-message"
|
||||||
id="commit-message"
|
id="commit-message"
|
||||||
placeholder="Commit Message"
|
placeholder="Commit Message"
|
||||||
class="input input-bordered mr-8 w-full max-w-xs"
|
class="input input-bordered mr-8 w-full max-w-xs"
|
||||||
[value]="productCode"
|
[value]="productCode"
|
||||||
(keyup)="onKeyUpCommitMsg($event)"
|
(keyup)="onKeyUpCommitMsg($event)"
|
||||||
[disabled]="!isEditable()"
|
[disabled]="!isEditable()"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
(click)="onPressConfirmClose()"
|
(click)="onPressConfirmClose()"
|
||||||
class="btn btn-error w-36 text-white mr-2"
|
class="btn btn-error w-36 text-white mr-2"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { CommonModule, DatePipe } from '@angular/common';
|
import { CommonModule, DatePipe } from '@angular/common';
|
||||||
import { Component, EventEmitter, OnInit } from '@angular/core';
|
import { Component, EventEmitter, OnInit } from '@angular/core';
|
||||||
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||||
import {Observable, first, map} from 'rxjs';
|
import {Observable, first, map} from 'rxjs';
|
||||||
import { RecipeService } from 'src/app/core/services/recipe.service';
|
import { RecipeService } from 'src/app/core/services/recipe.service';
|
||||||
|
|
@ -41,7 +41,8 @@ import { RecipeToppingsetComponent } from "./recipe-toppingset/recipe-toppingset
|
||||||
ConfirmModal,
|
ConfirmModal,
|
||||||
DatePipe,
|
DatePipe,
|
||||||
RecipeListComponent,
|
RecipeListComponent,
|
||||||
RecipeToppingsetComponent
|
RecipeToppingsetComponent,
|
||||||
|
FormsModule
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class RecipeDetailsComponent implements OnInit {
|
export class RecipeDetailsComponent implements OnInit {
|
||||||
|
|
@ -71,7 +72,8 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
private _userService: UserService
|
private _userService: UserService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
productCode!: string;
|
productCode!: any;
|
||||||
|
changedProductCode: string | undefined = undefined;
|
||||||
|
|
||||||
recipeDetailForm = this._formBuilder.group({
|
recipeDetailForm = this._formBuilder.group({
|
||||||
productCode: '',
|
productCode: '',
|
||||||
|
|
@ -111,7 +113,7 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
|
|
||||||
this._toppingService.getToppingsOfRecipe(this.department, this._recipeService.getCurrentFile(), this.productCode).subscribe((data) => {
|
this._toppingService.getToppingsOfRecipe(this.department, this._recipeService.getCurrentFile(), this.productCode).subscribe((data) => {
|
||||||
this.toppingSet = data;
|
this.toppingSet = data;
|
||||||
console.log('Toppings', data);
|
// console.log('Toppings', data);
|
||||||
})
|
})
|
||||||
|
|
||||||
// snap recipe detail form value
|
// snap recipe detail form value
|
||||||
|
|
@ -147,7 +149,7 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
let to_send = {
|
let to_send = {
|
||||||
edit_by: username,
|
edit_by: username,
|
||||||
commit_msg: this.commit_msg,
|
commit_msg: this.commit_msg,
|
||||||
productCode: this.productCode,
|
productCode: this.changedProductCode == undefined ? this.productCode : this.changedProductCode,
|
||||||
name: this.recipeDetailForm.getRawValue().name != this.recipeOriginalDetail.name ? this.recipeDetailForm.getRawValue().name : this.recipeOriginalDetail.name,
|
name: this.recipeDetailForm.getRawValue().name != this.recipeOriginalDetail.name ? this.recipeDetailForm.getRawValue().name : this.recipeOriginalDetail.name,
|
||||||
otherName: this.recipeDetailForm.getRawValue().otherName != this.recipeOriginalDetail.otherName ? this.recipeDetailForm.getRawValue().otherName : this.recipeOriginalDetail.otherName,
|
otherName: this.recipeDetailForm.getRawValue().otherName != this.recipeOriginalDetail.otherName ? this.recipeDetailForm.getRawValue().otherName : this.recipeOriginalDetail.otherName,
|
||||||
description: this.recipeDetailForm.getRawValue().description != this.recipeOriginalDetail.description ? this.recipeDetailForm.getRawValue().description : this.recipeOriginalDetail.description,
|
description: this.recipeDetailForm.getRawValue().description != this.recipeOriginalDetail.description ? this.recipeDetailForm.getRawValue().description : this.recipeOriginalDetail.description,
|
||||||
|
|
@ -225,7 +227,7 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
onToppingListChange(tpl: unknown[]) {
|
onToppingListChange(tpl: unknown[]) {
|
||||||
console.log('Topping List Form Changed', tpl);
|
// console.log('Topping List Form Changed', tpl);
|
||||||
this.tpl = tpl as never[];
|
this.tpl = tpl as never[];
|
||||||
this.isValueChanged ||= tpl != undefined;
|
this.isValueChanged ||= tpl != undefined;
|
||||||
|
|
||||||
|
|
@ -235,4 +237,10 @@ export class RecipeDetailsComponent implements OnInit {
|
||||||
return this._userService.getCurrentUser()!.permissions.includes(UserPermissions.EDITOR);
|
return this._userService.getCurrentUser()!.permissions.includes(UserPermissions.EDITOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onProductCodeChange(event: any) {
|
||||||
|
if(event.target.value != ""){
|
||||||
|
this.changedProductCode = event.target.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,7 @@
|
||||||
<th class="px-6 py-3">Is Use</th>
|
<th class="px-6 py-3">Is Use</th>
|
||||||
<th class="px-6 py-3">Material ID</th>
|
<th class="px-6 py-3">Material ID</th>
|
||||||
<th class="px-6 py-3">Material Name</th>
|
<th class="px-6 py-3">Material Name</th>
|
||||||
<th class="px-6 py-3">MixOrder</th>
|
<th class="px-6 py-3">Settings</th>
|
||||||
<th class="px-6 py-3">Stir Time</th>
|
|
||||||
<th class="px-6 py-3">Powder Gram</th>
|
|
||||||
<th class="px-6 py-3">Powder Time</th>
|
|
||||||
<th class="px-6 py-3">Syrup Gram</th>
|
|
||||||
<th class="px-6 py-3">Syrup Time</th>
|
|
||||||
<th class="px-6 py-3">Water Cold</th>
|
|
||||||
<th class="px-6 py-3">Water Yield</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody
|
<tbody
|
||||||
|
|
@ -30,33 +23,69 @@
|
||||||
(click)="openMaterialList(i)"
|
(click)="openMaterialList(i)"
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
<!-- powder -->
|
||||||
<input type="text" class="input" formControlName="name" />
|
<div *ngIf="getTypeForRecipeListAtIndex(i)['category'] == 'powder'">
|
||||||
</td>
|
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
<input type="text" class="input" formControlName="name" />
|
||||||
<input type="text" class="input" formControlName="mixOrder" />
|
</td>
|
||||||
</td>
|
<td class="m-2 px-4 py-4 font-medium text-gray-900 whitespace-nowrap">
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
<div class="flex items-center">
|
||||||
<input type="text" class="input" formControlName="powderGram" />
|
<p>Volume= </p>
|
||||||
</td>
|
<input type="text" class="input w-16" formControlName="powderGram" />
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
<p> gram</p>
|
||||||
<input type="text" class="input" formControlName="powderTime" />
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
</div>
|
||||||
<input type="text" class="input" formControlName="syrupGram" />
|
|
||||||
</td>
|
<!-- syrup -->
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
<div *ngIf="getTypeForRecipeListAtIndex(i)['category'] == 'syrup'">
|
||||||
<input type="text" class="input" formControlName="syrupTime" />
|
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
||||||
</td>
|
<input type="text" class="input" formControlName="name" />
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
</td>
|
||||||
<input type="text" class="input" formControlName="waterCold" />
|
<td class="m-2 px-4 py-4 font-medium text-gray-900 whitespace-nowrap">
|
||||||
</td>
|
<div class="flex items-center">
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
<p>Volume= </p>
|
||||||
<input type="text" class="input" formControlName="waterYield" />
|
<input type="text" class="input w-16" formControlName="syrupGram" />
|
||||||
</td>
|
<p> gram</p>
|
||||||
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
</div>
|
||||||
<input type="text" class="input" formControlName="stirTime" />
|
</td>
|
||||||
</td>
|
</div>
|
||||||
|
|
||||||
|
<!-- bean -->
|
||||||
|
<div *ngIf="getTypeForRecipeListAtIndex(i)['category'] == 'bean'">
|
||||||
|
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
||||||
|
<input type="text" class="input" formControlName="name" />
|
||||||
|
</td>
|
||||||
|
<td class="m-2 px-4 py-4 font-medium text-gray-900 whitespace-nowrap">
|
||||||
|
<div class="flex items-center">
|
||||||
|
|
||||||
|
<p>StringParam=</p>
|
||||||
|
<input type="text" class="input w-16" formControlName="StringParam" />
|
||||||
|
|
||||||
|
<p> </p>
|
||||||
|
|
||||||
|
<p>Volume= </p>
|
||||||
|
<input type="text" class="input w-16" formControlName="powderGram" />
|
||||||
|
<p> gram</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center" *ngIf="getTypeForRecipeListAtIndex(i)['id'] == 1002">
|
||||||
|
<p>Hot= </p>
|
||||||
|
<input type="text" class="input w-16" formControlName="waterYield" />
|
||||||
|
<p> ml </p>
|
||||||
|
<p>Grinder= </p><input type="text" class="input w-16" formControlName="stirTime" /><p> sec</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- others -->
|
||||||
|
<div *ngIf="(isNotExistbyCatagories(getTypeForRecipeListAtIndex(i)['id']) || isEquipment(getTypeForRecipeListAtIndex(i)['id']))">
|
||||||
|
<td class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap">
|
||||||
|
<input type="text" class="input" formControlName="name" />
|
||||||
|
</td>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
@ -75,18 +104,23 @@
|
||||||
<div class="flex flex-row m-2 modal">
|
<div class="flex flex-row m-2 modal">
|
||||||
<p class="font-bold text-lg m-2">Materials</p>
|
<p class="font-bold text-lg m-2">Materials</p>
|
||||||
</div>
|
</div>
|
||||||
<div
|
|
||||||
*ngFor="let material of fullMaterialList"
|
<div *ngFor="let cat of getCategoriesList()">
|
||||||
class="flex flex-row m-2 overflow-y-scroll"
|
<details class="dropdown">
|
||||||
>
|
<summary class="m-1 btn">{{ cat }}</summary>
|
||||||
<button
|
<ul class="mx-4 menu p-2 shadow bg-base-100 rounded-box w-auto">
|
||||||
class="btn bg-primary btn-md border-2 text-base text-gray-700"
|
<li
|
||||||
(click)="selectMaterial(currentSelectRecipeList!, material.materialId)"
|
class="my-1 mx-4"
|
||||||
>
|
*ngFor="let material of categoriedMaterial[cat]"
|
||||||
{{ material.materialId }}
|
>
|
||||||
</button>
|
<a
|
||||||
<h3 class="m-3">{{ material.name }}</h3>
|
class="btn"
|
||||||
<p class="m-3">{{ material.type }}</p>
|
(click)="selectMaterial(currentSelectRecipeList!, material.id)"
|
||||||
|
>{{ material.name }} ({{ material.id }})</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import { UserService } from 'src/app/core/services/user.service';
|
||||||
import { Action, ActionRecord } from 'src/app/shared/actionRecord/actionRecord';
|
import { Action, ActionRecord } from 'src/app/shared/actionRecord/actionRecord';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { NgSelectModule } from '@ng-select/ng-select';
|
import { NgSelectModule } from '@ng-select/ng-select';
|
||||||
|
import { getMaterialType, getCategories, isNonMaterial } from 'src/app/shared/helpers/mat_type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-recipe-list',
|
selector: 'app-recipe-list',
|
||||||
|
|
@ -35,13 +36,17 @@ export class RecipeListComponent implements OnInit {
|
||||||
|
|
||||||
materialList: MaterialCode[] = [];
|
materialList: MaterialCode[] = [];
|
||||||
|
|
||||||
fullMaterialList: { materialId: number; name: string; type: string; }[] | null = [];
|
fullMaterialList:
|
||||||
|
| { materialId: number; name: string; type: string }[]
|
||||||
|
| null = [];
|
||||||
showMaterialSelector: boolean = false;
|
showMaterialSelector: boolean = false;
|
||||||
|
|
||||||
currentSelectRecipeList: number | null = null;
|
currentSelectRecipeList: number | null = null;
|
||||||
|
|
||||||
isMatLoaded: boolean = false;
|
isMatLoaded: boolean = false;
|
||||||
|
|
||||||
|
categoriedMaterial: { [key: string]: { id: number; name: string }[] } = {};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _recipeService: RecipeService,
|
private _recipeService: RecipeService,
|
||||||
private _materialService: MaterialService,
|
private _materialService: MaterialService,
|
||||||
|
|
@ -67,17 +72,70 @@ export class RecipeListComponent implements OnInit {
|
||||||
result.forEach((recipeDetailMat: RecipeDetailMat) => {
|
result.forEach((recipeDetailMat: RecipeDetailMat) => {
|
||||||
this.recipeListData.push(
|
this.recipeListData.push(
|
||||||
this._formBuilder.group({
|
this._formBuilder.group({
|
||||||
isUse: [{ value: recipeDetailMat.isUse, disabled: !this.isEditable()}],
|
StringParam: [
|
||||||
materialPathId: [{value:recipeDetailMat.materialPathId, disabled: !this.isEditable()}],
|
{
|
||||||
|
value: recipeDetailMat.StringParam,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
isUse: [
|
||||||
|
{ value: recipeDetailMat.isUse, disabled: !this.isEditable() },
|
||||||
|
],
|
||||||
|
materialPathId: [
|
||||||
|
{
|
||||||
|
value: recipeDetailMat.materialPathId,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
name: [{ value: recipeDetailMat.name, disabled: true }],
|
name: [{ value: recipeDetailMat.name, disabled: true }],
|
||||||
mixOrder: [{ value:recipeDetailMat.mixOrder, disabled: !this.isEditable()}],
|
mixOrder: [
|
||||||
stirTime: [{value:recipeDetailMat.stirTime, disabled: !this.isEditable()}],
|
{
|
||||||
powderGram: [{value:recipeDetailMat.powderGram, disabled: !this.isEditable()}],
|
value: recipeDetailMat.mixOrder,
|
||||||
powderTime: [{value:recipeDetailMat.powderTime, disabled: !this.isEditable()}],
|
disabled: !this.isEditable(),
|
||||||
syrupGram: [{value:recipeDetailMat.syrupGram, disabled: !this.isEditable()}],
|
},
|
||||||
syrupTime: [{value: recipeDetailMat.syrupTime, disabled: !this.isEditable()}],
|
],
|
||||||
waterCold: [{value:recipeDetailMat.waterCold, disabled: !this.isEditable()}],
|
stirTime: [
|
||||||
waterYield: [{value:recipeDetailMat.waterYield, disabled: !this.isEditable()}],
|
{
|
||||||
|
value: recipeDetailMat.stirTime,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
powderGram: [
|
||||||
|
{
|
||||||
|
value: recipeDetailMat.powderGram,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
powderTime: [
|
||||||
|
{
|
||||||
|
value: recipeDetailMat.powderTime,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
syrupGram: [
|
||||||
|
{
|
||||||
|
value: recipeDetailMat.syrupGram,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
syrupTime: [
|
||||||
|
{
|
||||||
|
value: recipeDetailMat.syrupTime,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
waterCold: [
|
||||||
|
{
|
||||||
|
value: recipeDetailMat.waterCold,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
waterYield: [
|
||||||
|
{
|
||||||
|
value: recipeDetailMat.waterYield,
|
||||||
|
disabled: !this.isEditable(),
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -86,29 +144,27 @@ export class RecipeListComponent implements OnInit {
|
||||||
|
|
||||||
this.recipeListForm.valueChanges.subscribe((value) => {
|
this.recipeListForm.valueChanges.subscribe((value) => {
|
||||||
// console.log(value.recipeListData);
|
// console.log(value.recipeListData);
|
||||||
// console.log(this._recipeListOriginalArray);
|
// console.log("original recipe detail",this._recipeListOriginalArray);
|
||||||
if (
|
if (
|
||||||
!isEqual(
|
!isEqual(
|
||||||
sortBy(value, 'materialID'),
|
sortBy(value, 'materialID'),
|
||||||
sortBy(this._recipeListOriginalArray, 'materialID')
|
sortBy(this._recipeListOriginalArray, 'materialID')
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
let emitted_res: any[] = [];
|
||||||
let emitted_res: any[] = []
|
|
||||||
|
|
||||||
// force type change. temporary solution
|
// force type change. temporary solution
|
||||||
forEach(value.recipeListData!, (recipeDetailMat: any) => {
|
forEach(value.recipeListData!, (recipeDetailMat: any) => {
|
||||||
recipeDetailMat.materialPathId = parseInt(recipeDetailMat.materialPathId!)
|
recipeDetailMat.materialPathId = parseInt(
|
||||||
emitted_res.push(recipeDetailMat)
|
recipeDetailMat.materialPathId!
|
||||||
})
|
);
|
||||||
|
emitted_res.push(recipeDetailMat);
|
||||||
|
});
|
||||||
|
|
||||||
this.recipeListFormChange.emit(emitted_res as unknown[]);
|
this.recipeListFormChange.emit(emitted_res as unknown[]);
|
||||||
} else {
|
} else {
|
||||||
this.recipeListFormChange.emit([]);
|
this.recipeListFormChange.emit([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: make this
|
// TODO: make this
|
||||||
|
|
@ -118,28 +174,95 @@ export class RecipeListComponent implements OnInit {
|
||||||
|
|
||||||
this._materialService.getFullMaterialDetail().subscribe((materials) => {
|
this._materialService.getFullMaterialDetail().subscribe((materials) => {
|
||||||
this.fullMaterialList = materials;
|
this.fullMaterialList = materials;
|
||||||
})
|
this.categoriedMaterial = this.ListCategory();
|
||||||
|
console.log(this.categoriedMaterial);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get recipeListData(): FormArray {
|
get recipeListData(): FormArray {
|
||||||
return this.recipeListForm.get('recipeListData') as FormArray;
|
return this.recipeListForm.get('recipeListData') as FormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
isEditable(){
|
isEditable() {
|
||||||
return this._userService.getCurrentUser()!.permissions.includes(UserPermissions.EDITOR);
|
return this._userService
|
||||||
|
.getCurrentUser()!
|
||||||
|
.permissions.includes(UserPermissions.EDITOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
openMaterialList(i: any){
|
openMaterialList(i: any) {
|
||||||
console.log("open material list for ", i);
|
console.log('open material list for ', i);
|
||||||
this.showMaterialSelector = true;
|
this.showMaterialSelector = true;
|
||||||
this.currentSelectRecipeList = i;
|
this.currentSelectRecipeList = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectMaterial(i: number, material: number){
|
selectMaterial(i: number, material: number) {
|
||||||
|
// console.log("make material list by category", this.makeListCategory());
|
||||||
|
|
||||||
this.showMaterialSelector = false;
|
this.showMaterialSelector = false;
|
||||||
|
|
||||||
this.recipeListData.at(i).get('materialPathId')?.setValue(material);
|
this.recipeListData.at(i).get('materialPathId')?.setValue(material);
|
||||||
console.log("set mat ", material, "to slot", i);
|
console.log('set mat ', material, 'to slot', i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTypeForRecipeListAtIndex(i: any){
|
||||||
|
let target = this.recipeListData.at(i);
|
||||||
|
|
||||||
|
|
||||||
|
// search from full detail
|
||||||
|
for(const category of Object.keys(this.categoriedMaterial)){
|
||||||
|
let finder = this.categoriedMaterial[category].find(mat => mat.id == target.value.materialPathId);
|
||||||
|
|
||||||
|
if (finder != undefined) {
|
||||||
|
// console.log('found ', finder.name, ' in ', category);
|
||||||
|
return {
|
||||||
|
"category": category,
|
||||||
|
"name": finder.name,
|
||||||
|
"id": finder.id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log("did not find in full detail");
|
||||||
|
|
||||||
|
return {
|
||||||
|
"category": "others",
|
||||||
|
"name": target.value.name,
|
||||||
|
"id": target.value.materialPathId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Filter from full detail by type
|
||||||
|
ListCategory = () => {
|
||||||
|
let catMap: { [key: string]: any[] } = {
|
||||||
|
'others': []
|
||||||
|
};
|
||||||
|
|
||||||
|
// create category map
|
||||||
|
getCategories().forEach((category) => {
|
||||||
|
catMap[category] = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("generated category", catMap);
|
||||||
|
|
||||||
|
this.fullMaterialList!.forEach((mat) => {
|
||||||
|
let category = getMaterialType(mat.materialId);
|
||||||
|
|
||||||
|
if(Array.isArray(catMap[category])){
|
||||||
|
catMap[category].push({
|
||||||
|
id: mat.materialId,
|
||||||
|
name: mat.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return catMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
getCategoriesList = () => Object.keys(this.categoriedMaterial);
|
||||||
|
|
||||||
|
// exposed from mat_type.ts
|
||||||
|
isEquipment = (materialId: number) => isNonMaterial(materialId);
|
||||||
|
isNotExistbyCatagories = (materialId : number) => getMaterialType(materialId) == 'others';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ export class RecipeToppingsetComponent implements OnInit {
|
||||||
)
|
)
|
||||||
.subscribe((data) => {
|
.subscribe((data) => {
|
||||||
this.allToppings = data;
|
this.allToppings = data;
|
||||||
console.log('allToppings', data);
|
// console.log('allToppings', data);
|
||||||
|
|
||||||
data.ToppingGroup.forEach((group: ToppingGroup) => {
|
data.ToppingGroup.forEach((group: ToppingGroup) => {
|
||||||
if (this.allToppingsDefinitions != null) {
|
if (this.allToppingsDefinitions != null) {
|
||||||
|
|
@ -118,8 +118,8 @@ export class RecipeToppingsetComponent implements OnInit {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(this.allToppingsDefinitions);
|
// console.log(this.allToppingsDefinitions);
|
||||||
console.log('allToppingMembersByGroup', this.allToppingMembersByGroup);
|
// console.log('allToppingMembersByGroup', this.allToppingMembersByGroup);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.toppingForm.valueChanges.subscribe((value) => {
|
this.toppingForm.valueChanges.subscribe((value) => {
|
||||||
|
|
@ -157,7 +157,7 @@ export class RecipeToppingsetComponent implements OnInit {
|
||||||
// console.log('newToppingList', newToppingSetList);
|
// console.log('newToppingList', newToppingSetList);
|
||||||
this.toppingSetChange.emit(newToppingSetList as unknown[]);
|
this.toppingSetChange.emit(newToppingSetList as unknown[]);
|
||||||
} else {
|
} else {
|
||||||
console.log('newToppingListNoChange', value.toppingList);
|
// console.log('newToppingListNoChange', value.toppingList);
|
||||||
this.toppingSetChange.emit([]);
|
this.toppingSetChange.emit([]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
45
client/src/app/shared/helpers/mat_type.ts
Normal file
45
client/src/app/shared/helpers/mat_type.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
var rangeMaterialMapping: { [key: string]: (id: number) => boolean } = {
|
||||||
|
soda: (id: number) => id == 1031,
|
||||||
|
water: (id: number) => id == 1,
|
||||||
|
ice: (id: number) => id == 9100,
|
||||||
|
whipper: (id: number) => id == 8102,
|
||||||
|
bean: (id: number) => inRange(1001, 1009, id) || inRange(1100, 1199, id),
|
||||||
|
leaves: (id: number) => inRange(1600, 1799, id),
|
||||||
|
syrup: (id: number) =>
|
||||||
|
inRange(1032, 1039, id) ||
|
||||||
|
inRange(1020, 1030, id) ||
|
||||||
|
inRange(1200, 1299, id),
|
||||||
|
powder: (id: number) => inRange(1040, 1080, id) || inRange(1300, 1399, id),
|
||||||
|
cup: (id: number) => inRange(9500, 9549, id),
|
||||||
|
lid: (id: number) => inRange(9600, 9649, id),
|
||||||
|
straw: (id: number) => inRange(9700, 9749, id),
|
||||||
|
icecream: (id: number) => inRange(2100, 2200, id),
|
||||||
|
};
|
||||||
|
|
||||||
|
export function inRange(min: number, max: number, value: number) {
|
||||||
|
// console.log(min, max, value, value >= min && value <= max);
|
||||||
|
return value >= min && value <= max;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCategories() {
|
||||||
|
return Object.keys(rangeMaterialMapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMaterialType(materialId: number) {
|
||||||
|
for (const key of Object.keys(rangeMaterialMapping)) {
|
||||||
|
if (rangeMaterialMapping[key](materialId)) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'others';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isNonMaterial(materialId: number) {
|
||||||
|
// test cup, lid, straw
|
||||||
|
return (
|
||||||
|
rangeMaterialMapping['cup'](materialId) ||
|
||||||
|
rangeMaterialMapping['lid'](materialId) ||
|
||||||
|
rangeMaterialMapping['straw'](materialId) || rangeMaterialMapping['whipper'](materialId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
/Users/wanloprungsiyangkul/project/cofffeemachineConfig
|
|
||||||
1
server/cofffeemachineConfig
Submodule
1
server/cofffeemachineConfig
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6e0d512afc4667a2204ff773ad8a3851120cdadd
|
||||||
|
|
@ -28,31 +28,33 @@ type MaterialCode struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type MaterialSetting struct {
|
type MaterialSetting struct {
|
||||||
AlarmIDWhenOffline int `json:"AlarmIDWhenOffline"`
|
StringParam string `json:"StringParam"`
|
||||||
BeanChannel bool `json:"BeanChannel"`
|
AlarmIDWhenOffline int `json:"AlarmIDWhenOffline"`
|
||||||
CanisterType string `json:"CanisterType"`
|
BeanChannel bool `json:"BeanChannel"`
|
||||||
DrainTimer int `json:"DrainTimer"`
|
CanisterType string `json:"CanisterType"`
|
||||||
IsEquipment bool `json:"IsEquipment"`
|
DrainTimer int `json:"DrainTimer"`
|
||||||
LeavesChannel bool `json:"LeavesChannel"`
|
IceScreamBingsuChannel bool `json:"IceScreamBingsuChannel"`
|
||||||
LowToOffline int `json:"LowToOffline"`
|
IsEquipment bool `json:"IsEquipment"`
|
||||||
MaterialStatus int `json:"MaterialStatus"`
|
LeavesChannel bool `json:"LeavesChannel"`
|
||||||
PowderChannel bool `json:"PowderChannel"`
|
LowToOffline int `json:"LowToOffline"`
|
||||||
RefillUnitGram bool `json:"RefillUnitGram"`
|
MaterialStatus int `json:"MaterialStatus"`
|
||||||
RefillUnitMilliliters bool `json:"RefillUnitMilliliters"`
|
PowderChannel bool `json:"PowderChannel"`
|
||||||
RefillUnitPCS bool `json:"RefillUnitPCS"`
|
RefillUnitGram bool `json:"RefillUnitGram"`
|
||||||
ScheduleDrainType int `json:"ScheduleDrainType"`
|
RefillUnitMilliliters bool `json:"RefillUnitMilliliters"`
|
||||||
SodaChannel bool `json:"SodaChannel"`
|
RefillUnitPCS bool `json:"RefillUnitPCS"`
|
||||||
StockAdjust int `json:"StockAdjust"`
|
ScheduleDrainType int `json:"ScheduleDrainType"`
|
||||||
SyrupChannel bool `json:"SyrupChannel"`
|
SodaChannel bool `json:"SodaChannel"`
|
||||||
ID uint64 `json:"id"`
|
StockAdjust int `json:"StockAdjust"`
|
||||||
IDAlternate int `json:"idAlternate"`
|
SyrupChannel bool `json:"SyrupChannel"`
|
||||||
IsUse bool `json:"isUse"`
|
ID uint64 `json:"id"`
|
||||||
PayRettryMaxCount int `json:"pay_rettry_max_count"`
|
IDAlternate int `json:"idAlternate"`
|
||||||
FeedMode string `json:"feed_mode"`
|
IsUse bool `json:"isUse"`
|
||||||
MaterialParameter string `json:"MaterialParameter"`
|
PayRettryMaxCount int `json:"pay_rettry_max_count"`
|
||||||
MaterialName string `json:"materialName"`
|
FeedMode string `json:"feed_mode"`
|
||||||
MaterialOtherName string `json:"materialOtherName"`
|
MaterialParameter string `json:"MaterialParameter"`
|
||||||
RawMaterialUnit string `json:"RawMaterialUnit"`
|
MaterialName string `json:"materialName"`
|
||||||
|
MaterialOtherName string `json:"materialOtherName"`
|
||||||
|
RawMaterialUnit string `json:"RawMaterialUnit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Recipe01 struct {
|
type Recipe01 struct {
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ func (mr *MaterialRouter) GetFullMaterialDetail(w http.ResponseWriter, r *http.R
|
||||||
materialDetails = append(materialDetails, map[string]interface{}{
|
materialDetails = append(materialDetails, map[string]interface{}{
|
||||||
"materialId": matSetting.ID,
|
"materialId": matSetting.ID,
|
||||||
"name": mat_name,
|
"name": mat_name,
|
||||||
"type": "powder:" + strconv.FormatBool(matSetting.PowderChannel) + ",syrup:" + strconv.FormatBool(matSetting.SyrupChannel) + ",bean:" + strconv.FormatBool(matSetting.BeanChannel) + ",equipment:" + strconv.FormatBool(matSetting.IsEquipment),
|
"type": "powder:" + strconv.FormatBool(matSetting.PowderChannel) + ",syrup:" + strconv.FormatBool(matSetting.SyrupChannel) + ",bean:" + strconv.FormatBool(matSetting.BeanChannel) + ",equipment:" + strconv.FormatBool(matSetting.IsEquipment) + ",soda:" + strconv.FormatBool(matSetting.SodaChannel) + ",icecream:" + strconv.FormatBool(matSetting.IceScreamBingsuChannel),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue