update dashboard

This commit is contained in:
Kenta420-Poom 2023-09-21 15:57:35 +07:00
parent 325020fd37
commit 8228a4f46c
3 changed files with 211 additions and 22 deletions

View file

@ -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;
}

View file

@ -1,31 +1,66 @@
<main class="relative overflow-hidden shadow-md sm:rounded-lg">
<table class="w-full text-sm text-left text-gray-500">
<main class="relative overflow-auto max-h-[700px] shadow-md sm:rounded-lg">
<table
*ngIf="isLoaded; else loadingIndicator"
class="w-full table-auto text-sm text-left text-gray-500"
>
<caption
class="p-5 text-lg font-semibold text-left text-gray-900 bg-primary"
></caption>
<thead class="text-xs text-gray-700 uppercase bg-secondary">
<thead class="text-xs sticky top-0 text-gray-700 uppercase bg-secondary">
<tr>
<th scope="col" class="px-6 py-3">Product name</th>
<th scope="col" class="px-6 py-3">Color</th>
<th scope="col" class="px-6 py-3">Category</th>
<th scope="col" class="px-6 py-3 sm:hidden md:block">Price</th>
<th scope="col" class="px-6 py-3">
<span class="sr-only">Edit</span>
<th scope="col" class="px-6 py-3" *ngFor="let head of tableHeads">
<div class="flex items-center uppercase">
{{ head }}
<a href="#"
><svg
class="w-3 h-3 ml-1.5"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 24 24"
>
<path
d="M8.574 11.024h6.852a2.075 2.075 0 0 0 1.847-1.086 1.9 1.9 0 0 0-.11-1.986L13.736 2.9a2.122 2.122 0 0 0-3.472 0L6.837 7.952a1.9 1.9 0 0 0-.11 1.986 2.074 2.074 0 0 0 1.847 1.086Zm6.852 1.952H8.574a2.072 2.072 0 0 0-1.847 1.087 1.9 1.9 0 0 0 .11 1.985l3.426 5.05a2.123 2.123 0 0 0 3.472 0l3.427-5.05a1.9 1.9 0 0 0 .11-1.985 2.074 2.074 0 0 0-1.846-1.087Z"
/>
</svg>
</a>
</div>
</th>
<th scope="col" class="flex items-center py-3">
<div class="flex items-center text-center uppercase">
Actions
<a href="#"
><svg
class="w-3 h-3 ml-1.5"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 24 24"
>
<path
d="M8.574 11.024h6.852a2.075 2.075 0 0 0 1.847-1.086 1.9 1.9 0 0 0-.11-1.986L13.736 2.9a2.122 2.122 0 0 0-3.472 0L6.837 7.952a1.9 1.9 0 0 0-.11 1.986 2.074 2.074 0 0 0 1.847 1.086Zm6.852 1.952H8.574a2.072 2.072 0 0 0-1.847 1.087 1.9 1.9 0 0 0 .11 1.985l3.426 5.05a2.123 2.123 0 0 0 3.472 0l3.427-5.05a1.9 1.9 0 0 0 .11-1.985 2.074 2.074 0 0 0-1.846-1.087Z"
/>
</svg>
</a>
</div>
</th>
</tr>
</thead>
<tbody>
<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<tr
*ngFor="let recipe of recipes"
class="bg-white la border-b hover:bg-secondary"
>
<th
scope="row"
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white"
>
Apple MacBook Pro 17"
{{ recipe.name }}
</th>
<td class="px-6 py-4">Silver</td>
<td class="px-6 py-4">Laptop</td>
<td class="px-6 py-4 sm:hidden md:block">$2999</td>
<td class="px-6 py-4 text-right">
<td class="px-6 py-4">{{ recipe.otherName }}</td>
<td class="px-6 py-4">{{ recipe.Description }}</td>
<td class="px-6 py-4">{{ recipe.LastChange }}</td>
<td class="px-6 py-4">
<a
href="#"
class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
@ -35,4 +70,90 @@
</tr>
</tbody>
</table>
<ng-template #loadingIndicator>
<div
class="flex w-full items-center justify-center h-56 border border-gray-200 rounded-lg bg-gray-50"
>
<div role="status">
<svg
aria-hidden="true"
class="w-8 h-8 mr-2 text-gray-200 animate-spin fill-blue-600"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
</div>
</div>
</ng-template>
</main>
<nav
class="flex items-center justify-between pt-4"
aria-label="Table navigation"
>
<span class="text-sm font-normal text-gray-500 dark:text-gray-400"
>Showing
<span class="font-semibold text-gray-900 dark:text-white">1-10</span> of
<span class="font-semibold text-gray-900 dark:text-white">1000</span></span
>
<ul class="inline-flex -space-x-px text-sm h-8">
<li>
<a
href="#"
class="flex items-center justify-center px-3 h-8 ml-0 leading-tight text-gray-500 bg-white border border-gray-300 rounded-l-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
>Previous</a
>
</li>
<li>
<a
href="#"
class="flex items-center justify-center px-3 h-8 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
>1</a
>
</li>
<li>
<a
href="#"
class="flex items-center justify-center px-3 h-8 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
>2</a
>
</li>
<li>
<a
href="#"
aria-current="page"
class="flex items-center justify-center px-3 h-8 text-blue-600 border border-gray-300 bg-blue-50 hover:bg-blue-100 hover:text-blue-700 dark:border-gray-700 dark:bg-gray-700 dark:text-white"
>3</a
>
</li>
<li>
<a
href="#"
class="flex items-center justify-center px-3 h-8 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
>4</a
>
</li>
<li>
<a
href="#"
class="flex items-center justify-center px-3 h-8 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
>5</a
>
</li>
<li>
<a
href="#"
class="flex items-center justify-center px-3 h-8 leading-tight text-gray-500 bg-white border border-gray-300 rounded-r-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
>Next</a
>
</li>
</ul>
</nav>

View file

@ -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;
});
}
}