Taobin-Recipe-Manager/client/src/app/features/recipes/recipes.component.html
2024-01-29 15:15:28 +07:00

403 lines
17 KiB
HTML

<main
class="relative overflow-auto max-h-[80%] h-[88vh] shadow-md sm:rounded-lg"
#table
>
<table class="table w-full">
<caption class="p-5 text-lg font-semibold text-left text-gray-900">
<div
class="divide-y divide-solid divide-gray-400"
*ngIf="recipesDashboard$ | async as recipesDashboard; else loading"
>
<div class="flex flex-row py-3 justify-between items-center">
<div class="flex flex-col">
<span
>Recipe Version {{ recipesDashboard.configNumber }} |
{{ recipesDashboard.filename }}</span
>
</div>
<div class="flex flex-col ml-5">
<button
class="btn bg-primary btn-md"
onclick="select_file_modal.showModal()"
>
<span class="text-base text-gray-700">เลือก Recipe ไฟล์</span>
</button>
<dialog id="select_file_modal" class="modal">
<div
class="modal-box overflow-visible flex flex-col justify-center items-center gap-5"
>
<h3 class="font-bold text-lg">Select Recipe File</h3>
<div class="flex flex-row gap-5">
<div class="dropdown dropdown-end">
<input
#countryInput
type="search"
tabindex="1"
placeholder="Select Country"
class="input input-bordered input-sm w-full"
[value]="selectedCountry"
(input)="setCountryFilter($event)"
(focus)="getRecipeCountries()"
/>
<div
class="dropdown-content z-[1000] min-w-[200px] max-h-[500px] overflow-y-auto"
>
<ul
tabindex="1"
class="menu p-2 shadow bg-base-100 rounded-box w-auto"
>
<li *ngFor="let country of recipeCountryFiltered">
<a (click)="countrySelected(country)">{{
country
}}</a>
</li>
</ul>
</div>
</div>
<div *ngIf="isCountrySelected" class="dropdown dropdown-end">
<input
#fileInput
type="search"
tabindex="1"
placeholder="เลือก Recipe File"
class="input input-bordered input-sm w-full max-w-xs"
(input)="setFileFilter($event)"
(focus)="getRecipeFiles()"
/>
<div
class="dropdown-content z-[1000] min-w-[200px] max-h-[500px] overflow-y-auto"
>
<ul
tabindex="1"
class="menu p-2 shadow bg-base-100 rounded-box w-auto"
>
<li *ngFor="let file of recipeFileCountries">
<a (click)="loadRecipe(file)">{{ file }}</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog>
<!-- <div class="dropdown dropdown-end">
<input
type="text"
tabindex="0"
placeholder="เลือก Recipe File"
class="input input-bordered input-sm w-full max-w-xs"
(input)="setRecipeVersion($event)"
(focus)="getRecipeVersions()"
/>
<div class="dropdown-content z-[1] max-h-[500px] overflow-y-auto">
<ul
tabindex="0"
class="menu p-2 shadow bg-base-100 rounded-box w-auto"
>
<li *ngFor="let recipeVersion of recipeVersions">
<a (click)="loadRecipe(recipeVersion)">{{
recipeVersion
}}</a>
</li>
</ul>
</div>
</div> -->
</div>
<!-- <button class="btn bg-primary btn-md border-2" *ngIf="savedTmpfiles.length > 0">
<span class="text-base text-gray-700" onclick="select_savefile_modal.showModal()">โหลดเซฟ</span>
</button> -->
<!-- todo: add modal -->
<!-- <dialog id="select_savefile_modal" class="modal">
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog> -->
<label
for="select_savefile_modal"
class="btn bg-primary btn-md border-2 text-base text-gray-700"
>โหลดเซฟ</label
>
<input
type="checkbox"
id="select_savefile_modal"
class="modal-toggle"
#checkBox="ngModel"
[(ngModel)]="saveTab"
/>
<label for="select_savefile_modal" class="modal">
<div class="modal-box max-w-[1000px] overflow-visible">
<p class="font-bold text-lg m-2">Saved Files</p>
<table class="table">
<tr class="bg-primary">
<th>Commit ID</th>
<th>Comment</th>
<th>Editor</th>
<th>Date</th>
<th>Based on</th>
</tr>
<tr
class="row hover:bg-secondary"
*ngFor="let file of savedTmpfiles"
>
<td>{{ file.Id }}</td>
<td>{{ file.Msg }}</td>
<td>{{ file.Editor }}</td>
<td>{{ file.Created_at }}</td>
<td>{{ file.Relation }}</td>
<button class="btn bg-blue-400" (click)="loadSavedFile(file)">Select</button>
</tr>
</table>
</div>
</label>
<!-- <button class="" *ngIf="savedTmpfiles.length > 0">
<span class="text-base text-gray-700" onloadstart="detect_save_noti.showModal()">;</span>
</button>
<dialog class="modal" id="detect_save_noti">
<div class="modal-box max-w-[400px] overflow-visible">
<p class="font-bold text-xl m-2"> พบการบันทึกไฟล์ก่อนหน้านี้ ต้องการแก้ไขต่อจากไฟล์บันทึกหรือไม่ </p>
</div>
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog> -->
<input
type="checkbox"
id="detect_save_noti"
class="modal-toggle"
#checkBox="ngModel"
[(ngModel)]="showSaveNoti"
/>
<label for="detect_save_noti" class="modal">
<div class="modal-box max-w-[580px] overflow-visible">
<p class="font-semibold text-lg m-2">
Found saved file(s). Want to continue editing saved file?
</p>
<p class="font-medium text-sm m-2">
พบการบันทึกไฟล์ก่อนหน้านี้ ต้องการแก้ไขต่อจากไฟล์บันทึกหรือไม่
</p>
<div class="flex float-right justify-between m-2">
<button
class="btn btn-secondary btn-square m-2"
(click)="showSaveNoti = false"
>
No
</button>
<button
class="btn btn-primary btn-square m-2"
(click)="openLoadSaves()"
>
Yes
</button>
</div>
</div>
</label>
<button class="btn bg-primary btn-md border-2" (click)="this.copyToTsv(this.copyList)">COPY</button>
<div class="flex flex-col ml-auto">
<span class=""
>Last Updated:
{{
recipesDashboard.lastUpdated
}}</span
>
</div>
</div>
<div class="flex flex-col">
<div class="relativ sm:rounded-lg">
<div
class="flex flex-col items-center justify-between p-4 space-y-3 md:flex-row md:space-y-0 md:space-x-4"
>
<div class="join">
<input
class="input input-bordered join-item w-[300px] bg-white"
placeholder="Product Code, Name or Other Name"
(input)="setSearch($event)"
(keydown.enter)="search($event)"
/>
<!-- <ng-select
[items]="materialList"
class="join-item text-base"
bindLabel="name"
bindValue="id"
[multiple]="true"
[closeOnSelect]="false"
[(ngModel)]="selectMaterialFilter"
>
<ng-template ng-option-tmp let-item="item">
<p class="text-xs">{{ item.name }}</p>
<small class="text-xs text-gray-500">{{ item.id }}</small>
</ng-template>
</ng-select> -->
<!-- test material setting -->
<ng-select
[items]="materialDetail"
class="join-item text-base"
bindLabel="name"
bindValue="materialId"
[searchable]="true"
[multiple]="true"
[searchFn]="filterMaterial"
[closeOnSelect]="false"
[(ngModel)]="selectMaterialFilter"
>
<ng-template ng-option-tmp let-item="item">
<p class="text-xs">{{ item.name }} ({{ item.materialId }})</p>
<small class="text-xs text-gray-500">{{ item.materialId }}</small>
</ng-template>
</ng-select>
<button class="btn join-item" (click)="search($event)">
Search
</button>
</div>
<div class="flex gap-2">
<button class="btn rounded-lg" (click)="openJsonTab()">
View JSON
</button>
<button class="btn rounded-lg">
<svg
class="w-6 h-6 text-gray-800 dark:text-white"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 18 20"
>
<path
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="1"
d="M15 6V2a.97.97 0 0 0-.933-1H5.828a2 2 0 0 0-1.414.586L1.586 4.414A2 2 0 0 0 1 5.828V18a.969.969 0 0 0 .933 1H14a1 1 0 0 0 1-1M6 1v4a1 1 0 0 1-1 1H1m6 6h9m-1.939-2.768L16.828 12l-2.767 2.768"
/>
</svg>
Export
</button>
<button class="btn rounded-lg">
Upgrade to {{ recipesDashboard.configNumber + 1 }}
</button>
</div>
</div>
</div>
</div>
</div>
</caption>
<thead class="text-xs sticky top-0 text-gray-700 uppercase bg-secondary">
<tr>
<th>
<label>
<input type="checkbox" class="checkbox" />
</label>
</th>
<th scope="col" class="px-6 py-3" *ngFor="let header of tableHeads">
<div class="flex items-center uppercase">
{{ header }}
<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="px-6 py-3"></th>
</tr>
</thead>
<tbody>
<tr
*ngFor="let recipe of recipeOverviewList"
class="bg-white la border-b hover:bg-secondary"
>
<th>
<label>
<input type="checkbox" class="checkbox" (click)="this.addToCopyList(recipe)"/>
</label>
</th>
<td
scope="row"
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap"
>
{{ recipe.productCode }}
</td>
<td
class="px-6 max-w-fit py-4 font-medium text-gray-900 whitespace-nowrap"
>
{{ recipe.name }}
</td>
<td class="px-6 py-4">{{ recipe.otherName }}</td>
<td class="px-6 py-4 flex-wrap max-w-xs">{{ recipe.description }}</td>
<td class="px-6 py-4 flex-wrap max-w-xs">{{ recipe.otherDescription }}</td>
<td class="px-6 py-4">
{{ recipe.lastUpdated | date : "dd-MMM-yyyy hh:mm:ss" }}
</td>
<td class="px-4 py-4 flex">
<!-- <recipe-modal productCode="{{ recipe.productCode }}"></recipe-modal> -->
<a
routerLink="/{{department}}/recipe/{{ recipe.productCode }}"
class="btn btn-ghost"
>
<svg
class="w-6 h-6 text-gray-800 dark:text-white"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 20 20"
>
<path
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="1"
d="M7.75 4H19M7.75 4a2.25 2.25 0 0 1-4.5 0m4.5 0a2.25 2.25 0 0 0-4.5 0M1 4h2.25m13.5 6H19m-2.25 0a2.25 2.25 0 0 1-4.5 0m4.5 0a2.25 2.25 0 0 0-4.5 0M1 10h11.25m-4.5 6H19M7.75 16a2.25 2.25 0 0 1-4.5 0m4.5 0a2.25 2.25 0 0 0-4.5 0M1 16h2.25"
/>
</svg>
</a>
</td>
</tr>
</tbody>
</table>
<ng-template #loading>
<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-amber-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>