From 8228a4f46cc4b5591c9bdf0a316da53f41cda5c1 Mon Sep 17 00:00:00 2001 From: Kenta420-Poom Date: Thu, 21 Sep 2023 15:57:35 +0700 Subject: [PATCH] update dashboard --- client/src/app/core/models/recipe.model.ts | 54 +++++++ .../dashboard/dashboard.component.html | 151 ++++++++++++++++-- .../features/dashboard/dashboard.component.ts | 28 +++- 3 files changed, 211 insertions(+), 22 deletions(-) create mode 100644 client/src/app/core/models/recipe.model.ts diff --git a/client/src/app/core/models/recipe.model.ts b/client/src/app/core/models/recipe.model.ts new file mode 100644 index 0000000..bed04bd --- /dev/null +++ b/client/src/app/core/models/recipe.model.ts @@ -0,0 +1,54 @@ +export interface Recipe { + Description: string; + ExtendID: number; + OnTOP: boolean; + LastChange: Date; + MenuStatus: number; + RemainingCups: string; + StringParam: string; + TextForWarningBeforePay: string[]; + cashPrice: number; + changerecipe: string; + disable: boolean; + disable_by_cup: boolean; + disable_by_ice: boolean; + EncoderCount: number; + id: number; + isUse: boolean; + isShow: boolean; + name: string; + nonCashPrice: number; + otherDescription: string; + otherName: string; + productCode: string; + recipes: MatRecipe[]; + SubMenu: Recipe[]; + ToppingSet: ToppingSet[]; + total_time: number; + total_weight: number; + uriData: string; + useGram: boolean; + weight_float: number; +} + +export interface MatRecipe { + MixOrder: number; + FeedParameter: number; + FeedPattern: number; + isUse: boolean; + materialPathId: number; + powderGram: number; + powderTime: number; + stirTime: number; + syrupGram: number; + syrupTime: number; + waterCold: number; + waterYield: number; +} + +export interface ToppingSet { + ListGroupID: number[]; + defaultIDSelect: number; + groupID: string; + isUse: boolean; +} diff --git a/client/src/app/features/dashboard/dashboard.component.html b/client/src/app/features/dashboard/dashboard.component.html index d931c01..3577e16 100644 --- a/client/src/app/features/dashboard/dashboard.component.html +++ b/client/src/app/features/dashboard/dashboard.component.html @@ -1,31 +1,66 @@ -
- +
+
- + - - - - - + - + - - - - + + +
Product nameColorCategoryPrice - Edit + +
+ {{ head }} + + +
+
+
+ Actions + + +
- Apple MacBook Pro 17" + {{ recipe.name }} SilverLaptop$2999 + {{ recipe.otherName }}{{ recipe.Description }}{{ recipe.LastChange }}
+ +
+
+ +
+
+
+ diff --git a/client/src/app/features/dashboard/dashboard.component.ts b/client/src/app/features/dashboard/dashboard.component.ts index 9f64909..3a75b69 100644 --- a/client/src/app/features/dashboard/dashboard.component.ts +++ b/client/src/app/features/dashboard/dashboard.component.ts @@ -2,19 +2,28 @@ import { Component, OnInit } from '@angular/core'; import { UserService } from 'src/app/core/services/user.service'; import { HttpClient } from '@angular/common/http'; import { User } from 'src/app/core/models/user.model'; -import { NgIf } from '@angular/common'; +import { NgFor, NgIf } from '@angular/common'; import { initFlowbite } from 'flowbite'; +import { environment } from 'src/environments/environment'; +import { delay } from 'rxjs'; +import { Recipe } from 'src/app/core/models/recipe.model'; @Component({ selector: 'app-dashboard', standalone: true, - imports: [NgIf], + imports: [NgIf, NgFor], templateUrl: './dashboard.component.html', }) export class DashboardComponent implements OnInit { userInfo: User | null = null; + recipes: Recipe[] | null = null; + tableHeads: string[] = ['Name', 'Other Name', 'Description', 'Last Updated']; + isLoaded: boolean = false; - constructor(private _userService: UserService) {} + constructor( + private _userService: UserService, + private _httpClient: HttpClient + ) {} ngOnInit(): void { initFlowbite(); @@ -22,10 +31,15 @@ export class DashboardComponent implements OnInit { this._userService.currentUser.subscribe((user) => { this.userInfo = user; }); - } - logout() { - console.log('logout'); - this._userService.logout(); + this._httpClient + .get<{ Recipe01: Recipe[] }>(environment.api + '/recipes', { + withCredentials: true, + }) + .subscribe(({ Recipe01 }) => { + this.recipes = Recipe01.slice(0, 10); + console.log(this.recipes); + this.isLoaded = true; + }); } }