[FEAT] 遠端指令中心 AJAX 化與介面標準化
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 2m10s
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 2m10s
1. 將遠端指令中心 (Remote Command Center) 兩大分頁 (操作紀錄、新增指令) 改為 AJAX 異步載入,提升切換速度。 2. 建立抽離的 Blade Partials 結構 (partials/tab-history-index.blade.php, tab-machines-index.blade.php) 以利維護。 3. 實作全域 Loading Bar 與 Luxury Spinner 視覺回饋,確保 AJAX 過程中有明確狀態。 4. 修正庫存管理與指令中心在機台圖片不存在時的 `Undefined array key 0` 錯誤。 5. 標準化操作紀錄搜尋行為:文字搜尋改為 Enter 觸發,日期範圍改為手動按下搜尋按鈕觸發,並新增「重設」功能。 6. 設定 Flatpickr 日期時間選擇器預設時間為 `00:00`。 7. 修正 `stock.blade.php` 中的 PHP 語法錯誤 (括號未閉合)。 8. 同步更新多語系翻譯檔案 (zh_TW, en, ja)。
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
// 預設為 history,篩選條件存在時也維持 history
|
||||
history: @js($history),
|
||||
loading: false,
|
||||
tabLoading: null,
|
||||
submitting: false,
|
||||
|
||||
// App Config & Meta
|
||||
@@ -67,17 +68,153 @@
|
||||
note: '',
|
||||
|
||||
async init() {
|
||||
if (initialMachineId) {
|
||||
const machine = this.machines.find(m => m.id == initialMachineId);
|
||||
if (machine) {
|
||||
await this.selectMachine(machine);
|
||||
}
|
||||
}
|
||||
|
||||
// Watch for machine data changes to rebuild slot select
|
||||
this.$watch('selectedMachine.slots', () => {
|
||||
this.$nextTick(() => this.updateSlotSelect());
|
||||
});
|
||||
|
||||
// 首次載入時綁定分頁連結
|
||||
this.$nextTick(() => {
|
||||
this.bindPaginationLinks(this.$refs.historyContent, 'history');
|
||||
this.bindPaginationLinks(this.$refs.listContent, 'list');
|
||||
});
|
||||
|
||||
// 同步頂部進度條
|
||||
this.$watch('tabLoading', (val) => {
|
||||
const bar = document.getElementById('top-loading-bar');
|
||||
if (bar) {
|
||||
if (val) bar.classList.add('loading');
|
||||
else bar.classList.remove('loading');
|
||||
}
|
||||
});
|
||||
|
||||
if (initialMachineId) {
|
||||
const machine = this.machines.data.find(m => m.id == initialMachineId);
|
||||
if (machine) {
|
||||
await this.selectMachine(machine);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 攔截分頁連結與下拉切換 (與庫存模組一致的強健版本)
|
||||
bindPaginationLinks(container, tab) {
|
||||
if (!container) return;
|
||||
|
||||
// 處理連結
|
||||
container.querySelectorAll('a[href]').forEach(a => {
|
||||
const href = a.getAttribute('href');
|
||||
if (!href || href.startsWith('#') || href.startsWith('javascript:')) return;
|
||||
|
||||
try {
|
||||
const url = new URL(href, window.location.origin);
|
||||
const pageKey = (tab === 'list') ? 'machine_page' : 'history_page';
|
||||
|
||||
// 確保只有分頁連結被攔截
|
||||
if (!url.searchParams.has(pageKey) || a.closest('td.px-6')) return;
|
||||
|
||||
a.addEventListener('click', (e) => {
|
||||
if (a.title) return; // 略過有 title 的連結 (可能是其他功能)
|
||||
e.preventDefault();
|
||||
const page = url.searchParams.get(pageKey) || 1;
|
||||
const perPage = url.searchParams.get('per_page') || '';
|
||||
let extra = `&${pageKey}=${page}`;
|
||||
if (perPage) extra += `&per_page=${perPage}`;
|
||||
|
||||
const newUrl = new URL(this.appConfig.indexUrl);
|
||||
newUrl.searchParams.set('tab', tab);
|
||||
newUrl.searchParams.set('_ajax', '1');
|
||||
extra.split('&').filter(Boolean).forEach(p => {
|
||||
const [k, v] = p.split('=');
|
||||
newUrl.searchParams.set(k, v);
|
||||
});
|
||||
|
||||
this.fetchTabData(tab, newUrl.toString());
|
||||
});
|
||||
} catch (err) { }
|
||||
});
|
||||
|
||||
// 處理下拉切換 (每頁筆數或跳頁)
|
||||
container.querySelectorAll('select[onchange]').forEach(sel => {
|
||||
const origOnchange = sel.getAttribute('onchange');
|
||||
sel.removeAttribute('onchange');
|
||||
sel.addEventListener('change', () => {
|
||||
const val = sel.value;
|
||||
const pageKey = (tab === 'list') ? 'machine_page' : 'history_page';
|
||||
try {
|
||||
if (val.startsWith('http') || val.startsWith('/')) {
|
||||
const url = new URL(val, window.location.origin);
|
||||
const page = url.searchParams.get(pageKey) || 1;
|
||||
const perPage = url.searchParams.get('per_page') || '';
|
||||
let extra = `&${pageKey}=${page}`;
|
||||
if (perPage) extra += `&per_page=${perPage}`;
|
||||
|
||||
const newUrl = new URL(this.appConfig.indexUrl);
|
||||
newUrl.searchParams.set('tab', tab);
|
||||
newUrl.searchParams.set('_ajax', '1');
|
||||
extra.split('&').filter(Boolean).forEach(p => {
|
||||
const [k, v] = p.split('=');
|
||||
newUrl.searchParams.set(k, v);
|
||||
});
|
||||
this.fetchTabData(tab, newUrl.toString());
|
||||
} else if (origOnchange && origOnchange.includes('per_page')) {
|
||||
const newUrl = new URL(this.appConfig.indexUrl);
|
||||
newUrl.searchParams.set('tab', tab);
|
||||
newUrl.searchParams.set('_ajax', '1');
|
||||
newUrl.searchParams.set('per_page', val);
|
||||
this.fetchTabData(tab, newUrl.toString());
|
||||
}
|
||||
} catch (err) { }
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async searchInTab(tab, clear = false) {
|
||||
const form = event?.target?.closest('form');
|
||||
const url = new URL(this.appConfig.indexUrl);
|
||||
url.searchParams.set('tab', tab);
|
||||
url.searchParams.set('_ajax', '1');
|
||||
|
||||
if (!clear && form) {
|
||||
const formData = new FormData(form);
|
||||
for (let [key, value] of formData.entries()) {
|
||||
if (value) url.searchParams.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
await this.fetchTabData(tab, url.toString());
|
||||
},
|
||||
|
||||
async fetchTabData(tab, url) {
|
||||
this.tabLoading = tab;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
const ref = (tab === 'history') ? this.$refs.historyContent : this.$refs.listContent;
|
||||
if (ref) {
|
||||
ref.innerHTML = data.html;
|
||||
|
||||
this.$nextTick(() => {
|
||||
Alpine.initTree(ref);
|
||||
this.bindPaginationLinks(ref, tab);
|
||||
if (window.HSStaticMethods && window.HSStaticMethods.autoInit) {
|
||||
setTimeout(() => window.HSStaticMethods.autoInit(), 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Update browser URL
|
||||
const browserUrl = new URL(url);
|
||||
browserUrl.searchParams.delete('_ajax');
|
||||
window.history.pushState({}, '', browserUrl.toString());
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Fetch error:', e);
|
||||
} finally {
|
||||
this.tabLoading = null;
|
||||
}
|
||||
},
|
||||
|
||||
updateSlotSelect() {
|
||||
@@ -400,244 +537,9 @@
|
||||
<!-- History View: Operation Records -->
|
||||
<div x-show="viewMode === 'history'" x-cloak>
|
||||
<div class="space-y-6 animate-luxury-in">
|
||||
<div class="luxury-card rounded-3xl p-8 overflow-hidden">
|
||||
<!-- Filters Area -->
|
||||
<div class="mb-8">
|
||||
<form method="GET" action="{{ route('admin.remote.index') }}"
|
||||
class="flex flex-wrap items-center gap-4">
|
||||
<!-- Search Box -->
|
||||
<div class="relative group flex-[1.5] min-w-[200px]">
|
||||
<span class="absolute inset-y-0 left-0 flex items-center pl-4 pointer-events-none z-10">
|
||||
<svg class="h-4 w-4 text-slate-400 group-focus-within:text-cyan-500 transition-colors"
|
||||
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="11" cy="11" r="8"></circle>
|
||||
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
||||
</svg>
|
||||
</span>
|
||||
<input type="text" name="search" value="{{ request('search') }}"
|
||||
placeholder="{{ __('Search machines...') }}"
|
||||
class="luxury-input py-2.5 pl-12 pr-6 block w-full">
|
||||
</div>
|
||||
|
||||
<!-- Date Range -->
|
||||
<div class="relative group flex-[2] min-w-[340px]" x-data="{
|
||||
fp: null,
|
||||
startDate: '{{ request('start_date') }}',
|
||||
endDate: '{{ request('end_date') }}'
|
||||
}" x-init="fp = flatpickr($refs.dateRange, {
|
||||
mode: 'range',
|
||||
dateFormat: 'Y-m-d H:i', enableTime: true, time_24hr: true,
|
||||
locale: 'zh_tw',
|
||||
defaultDate: startDate && endDate ? [startDate, endDate] : (startDate ? [startDate] : []),
|
||||
onChange: function(selectedDates, dateStr, instance) {
|
||||
if (selectedDates.length === 2) {
|
||||
$refs.startDate.value = instance.formatDate(selectedDates[0], 'Y-m-d H:i');
|
||||
$refs.endDate.value = instance.formatDate(selectedDates[1], 'Y-m-d H:i');
|
||||
} else if (selectedDates.length === 0) {
|
||||
$refs.startDate.value = '';
|
||||
$refs.endDate.value = '';
|
||||
}
|
||||
}
|
||||
})">
|
||||
<span
|
||||
class="absolute inset-y-0 left-0 flex items-center pl-4 pointer-events-none z-10 text-slate-400 group-focus-within:text-cyan-500 transition-colors">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||
</svg>
|
||||
</span>
|
||||
<input type="hidden" name="start_date" x-ref="startDate"
|
||||
value="{{ request('start_date') }}">
|
||||
<input type="hidden" name="end_date" x-ref="endDate" value="{{ request('end_date') }}">
|
||||
<input type="text" x-ref="dateRange"
|
||||
value="{{ request('start_date') && request('end_date') ? request('start_date') . ' 至 ' . request('end_date') : (request('start_date') ?: '') }}"
|
||||
placeholder="{{ __('Select Date Range') }}"
|
||||
class="luxury-input py-2.5 pl-12 pr-6 block w-full cursor-pointer">
|
||||
</div>
|
||||
|
||||
<!-- Command Type -->
|
||||
<div class="flex-1 min-w-[160px]">
|
||||
<x-searchable-select name="command_type" :options="[
|
||||
'reboot' => __('Machine Reboot'),
|
||||
'reboot_card' => __('Card Reader Reboot'),
|
||||
'checkout' => __('Remote Settlement'),
|
||||
'lock' => __('Lock Page Lock'),
|
||||
'unlock' => __('Lock Page Unlock'),
|
||||
'change' => __('Remote Change'),
|
||||
'dispense' => __('Remote Dispense'),
|
||||
]" :selected="request('command_type')" :placeholder="__('All Command Types')"
|
||||
:hasSearch="false"
|
||||
onchange="this.form.submit()" />
|
||||
</div>
|
||||
|
||||
<!-- Status -->
|
||||
<div class="flex-1 min-w-[160px]">
|
||||
<x-searchable-select name="status" :options="[
|
||||
'pending' => __('Pending'),
|
||||
'sent' => __('Sent'),
|
||||
'success' => __('Success'),
|
||||
'failed' => __('Failed'),
|
||||
'superseded' => __('Superseded'),
|
||||
]" :selected="request('status')" :placeholder="__('All Status')" :hasSearch="false" onchange="this.form.submit()" />
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="flex items-center gap-2">
|
||||
<button type="submit"
|
||||
class="p-2.5 rounded-xl bg-cyan-600 text-white hover:bg-cyan-500 shadow-lg shadow-cyan-500/20 transition-all active:scale-95">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
||||
</svg>
|
||||
</button>
|
||||
<a href="{{ route('admin.remote.index') }}"
|
||||
class="p-2.5 rounded-xl bg-slate-100 dark:bg-slate-800 text-slate-500 dark:text-slate-400 hover:bg-slate-200 dark:hover:bg-slate-700 transition-all active:scale-95">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left border-separate border-spacing-y-0 text-sm">
|
||||
<thead>
|
||||
<tr class="bg-slate-50/50 dark:bg-slate-900/10">
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800">
|
||||
{{ __('Machine Information') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800 text-center whitespace-nowrap">
|
||||
{{ __('Creation Time') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800 text-center whitespace-nowrap">
|
||||
{{ __('Picked up Time') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800">
|
||||
{{ __('Command Type') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800">
|
||||
{{ __('Operator') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800 text-center">
|
||||
{{ __('Status') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50 dark:divide-slate-800/80">
|
||||
@foreach ($history as $item)
|
||||
<tr
|
||||
class="group hover:bg-slate-50/80 dark:hover:bg-slate-800/40 transition-all duration-300">
|
||||
<td class="px-6 py-6 cursor-pointer" @click="selectMachine(@js($item->machine))">
|
||||
<div class="flex items-center gap-4">
|
||||
<div
|
||||
class="w-12 h-12 rounded-2xl bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-400 border border-slate-200 dark:border-slate-700 group-hover:bg-cyan-500 group-hover:text-white transition-all duration-300 shadow-sm overflow-hidden">
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor"
|
||||
viewBox="0 0 24 24" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-5.25v9" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<div
|
||||
class="text-[17px] font-black text-slate-800 dark:text-slate-100 group-hover:text-cyan-600 dark:group-hover:text-cyan-400 transition-colors tracking-tight">
|
||||
{{ $item->machine->name }}</div>
|
||||
<div
|
||||
class="text-[11px] font-mono font-bold text-slate-400 dark:text-slate-500 uppercase tracking-widest mt-0.5">
|
||||
{{ $item->machine->serial_no }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="px-6 py-6 font-mono text-xs font-black text-slate-400 tracking-widest whitespace-nowrap text-center">
|
||||
<div class="flex flex-col">
|
||||
<span>{{ $item->created_at->format('Y/m/d') }}</span>
|
||||
<span class="text-[15px] font-bold text-slate-500 dark:text-slate-400">{{ $item->created_at->format('H:i:s')
|
||||
}}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="px-6 py-6 font-mono text-xs font-black text-slate-400 tracking-widest whitespace-nowrap text-center">
|
||||
@if($item->executed_at)
|
||||
<div class="flex flex-col text-cyan-600/80 dark:text-cyan-400/60">
|
||||
<span>{{ $item->executed_at->format('Y/m/d') }}</span>
|
||||
<span class="text-[15px] font-bold">{{ $item->executed_at->format('H:i:s')
|
||||
}}</span>
|
||||
</div>
|
||||
@else
|
||||
<span class="text-slate-300 dark:text-slate-700">-</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-6 py-6">
|
||||
<div class="flex flex-col min-w-[200px]">
|
||||
<span
|
||||
class="text-sm font-black text-slate-700 dark:text-slate-300 tracking-tight"
|
||||
x-text="getCommandName(@js($item->command_type))"></span>
|
||||
<div class="flex flex-col gap-0.5 mt-1">
|
||||
<span x-show="getPayloadDetails(@js($item))"
|
||||
class="text-[11px] font-bold text-cyan-600 dark:text-cyan-400/80 bg-cyan-500/5 px-2 py-0.5 rounded-md border border-cyan-500/10 w-fit"
|
||||
x-text="getPayloadDetails(@js($item))"></span>
|
||||
@if($item->note)
|
||||
<span class="text-[10px] text-slate-400 italic pl-1"
|
||||
x-text="translateNote(@js($item->note))"></span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-6 whitespace-nowrap">
|
||||
<div class="flex items-center gap-2">
|
||||
<div
|
||||
class="w-6 h-6 rounded-full bg-cyan-500/10 flex items-center justify-center text-[10px] font-black text-cyan-600 dark:text-cyan-400 border border-cyan-500/20">
|
||||
{{ mb_substr($item->user ? $item->user->name : __('System'), 0, 1) }}
|
||||
</div>
|
||||
<span class="text-sm font-bold text-slate-600 dark:text-slate-300">{{
|
||||
$item->user ? $item->user->name : __('System') }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-6 text-center">
|
||||
<div class="flex flex-col items-center gap-1.5">
|
||||
<div class="inline-flex items-center px-4 py-1.5 rounded-full border text-[10px] font-black uppercase tracking-widest shadow-sm"
|
||||
:class="getCommandBadgeClass(@js($item->status))">
|
||||
<div class="w-1.5 h-1.5 rounded-full mr-2" :class="{
|
||||
'bg-amber-500 animate-pulse': @js($item->status) === 'pending',
|
||||
'bg-cyan-500': @js($item->status) === 'sent',
|
||||
'bg-emerald-500': @js($item->status) === 'success',
|
||||
'bg-rose-500': @js($item->status) === 'failed',
|
||||
'bg-slate-400': @js($item->status) === 'superseded'
|
||||
}"></div>
|
||||
<span x-text="getCommandStatus(@js($item->status))"></span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@if($history->isEmpty())
|
||||
<tr>
|
||||
<td colspan="6" class="px-6 py-20 text-center">
|
||||
<div class="flex flex-col items-center gap-3">
|
||||
<div
|
||||
class="w-16 h-16 rounded-full bg-slate-50 dark:bg-slate-900/50 flex items-center justify-center text-slate-200 dark:text-slate-800">
|
||||
<svg class="w-8 h-8" fill="none" stroke="currentColor"
|
||||
viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4" />
|
||||
</svg>
|
||||
</div>
|
||||
<p class="text-slate-400 font-bold tracking-widest uppercase text-xs">{{
|
||||
__('No records found') }}</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination Area -->
|
||||
<div class="mt-8">
|
||||
{{ $history->appends(request()->query())->links('vendor.pagination.luxury') }}
|
||||
<div class="luxury-card rounded-3xl p-8 overflow-hidden relative">
|
||||
<div x-ref="historyContent">
|
||||
@include('admin.remote.partials.tab-history-index')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -647,138 +549,9 @@
|
||||
<!-- Master View: Machine List -->
|
||||
<div x-show="viewMode === 'list'" x-cloak>
|
||||
<div class="space-y-6 animate-luxury-in">
|
||||
<div class="luxury-card rounded-3xl p-8 overflow-hidden">
|
||||
<!-- Filters Area -->
|
||||
<div class="flex items-center justify-between mb-8">
|
||||
<div class="relative group">
|
||||
<span class="absolute inset-y-0 left-0 flex items-center pl-4 pointer-events-none z-10">
|
||||
<svg class="h-4 w-4 text-slate-400 group-focus-within:text-cyan-500 transition-colors"
|
||||
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="11" cy="11" r="8"></circle>
|
||||
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
||||
</svg>
|
||||
</span>
|
||||
<input type="text" x-model="searchQuery" placeholder="{{ __('Search...') }}"
|
||||
class="luxury-input py-2.5 pl-12 pr-6 block w-72">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto pb-4">
|
||||
<table class="w-full text-left border-separate border-spacing-y-0 text-sm whitespace-nowrap">
|
||||
<thead>
|
||||
<tr class="bg-slate-50/50 dark:bg-slate-900/10">
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800">
|
||||
{{ __('Machine Information') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800 text-center">
|
||||
{{ __('Status') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800 text-center">
|
||||
{{ __('Last Communication') }}</th>
|
||||
<th
|
||||
class="px-6 py-4 text-xs font-bold text-slate-500 dark:text-slate-400 uppercase tracking-[0.15em] border-b border-slate-100 dark:border-slate-800 text-right">
|
||||
{{ __('Actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50 dark:divide-slate-800/80">
|
||||
<template x-for="machine in machines.filter(m =>
|
||||
m.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
m.serial_no.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
)" :key="machine.id">
|
||||
<tr
|
||||
class="group hover:bg-slate-50/80 dark:hover:bg-slate-800/40 transition-all duration-300">
|
||||
<td class="px-6 py-6 cursor-pointer" @click="selectMachine(machine)">
|
||||
<div class="flex items-center gap-4">
|
||||
<div
|
||||
class="w-12 h-12 rounded-2xl bg-slate-100 dark:bg-slate-800 flex items-center justify-center text-slate-400 border border-slate-200 dark:border-slate-700 group-hover:bg-cyan-500 group-hover:text-white transition-all duration-300 overflow-hidden shadow-sm shrink-0">
|
||||
<template x-if="machine.image_urls && machine.image_urls[0]">
|
||||
<img :src="machine.image_urls[0]"
|
||||
class="w-full h-full object-cover">
|
||||
</template>
|
||||
<template x-if="!machine.image_urls || !machine.image_urls[0]">
|
||||
<svg class="w-6 h-6 shrink-0" fill="none" stroke="currentColor"
|
||||
viewBox="0 0 24 24" stroke-width="1.5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-5.25v9" />
|
||||
</svg>
|
||||
</template>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-[17px] font-black text-slate-800 dark:text-slate-100 group-hover:text-cyan-600 dark:group-hover:text-cyan-400 transition-colors tracking-tight"
|
||||
x-text="machine.name"></div>
|
||||
<div class="text-[11px] font-mono font-bold text-slate-400 dark:text-slate-500 uppercase tracking-widest mt-0.5"
|
||||
x-text="machine.serial_no"></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-6 text-center">
|
||||
<div class="flex items-center justify-center">
|
||||
<template x-if="machine.status === 'online' || !machine.status">
|
||||
<div
|
||||
class="flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-emerald-500/10 border border-emerald-500/20">
|
||||
<div class="relative flex h-2 w-2">
|
||||
<span
|
||||
class="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
|
||||
<span
|
||||
class="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
|
||||
</div>
|
||||
<span
|
||||
class="text-[10px] font-black text-emerald-600 dark:text-emerald-400 tracking-[0.1em] uppercase">{{
|
||||
__('Online') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="machine.status === 'offline'">
|
||||
<div
|
||||
class="flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-slate-500/10 border border-slate-500/20">
|
||||
<div class="h-2 w-2 rounded-full bg-slate-400"></div>
|
||||
<span
|
||||
class="text-[10px] font-black text-slate-500 dark:text-slate-400 tracking-[0.1em] uppercase">{{
|
||||
__('Offline') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template
|
||||
x-if="machine.status && machine.status !== 'online' && machine.status !== 'offline'">
|
||||
<div
|
||||
class="flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-full bg-rose-500/10 border border-rose-500/20">
|
||||
<div class="relative flex h-2 w-2">
|
||||
<span
|
||||
class="animate-ping absolute inline-flex h-full w-full rounded-full bg-rose-400 opacity-75"></span>
|
||||
<span
|
||||
class="relative inline-flex rounded-full h-2 w-2 bg-rose-500"></span>
|
||||
</div>
|
||||
<span
|
||||
class="text-[10px] font-black text-rose-600 dark:text-rose-400 tracking-[0.1em] uppercase">{{
|
||||
__('Abnormal') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-6 text-center">
|
||||
<div class="flex flex-col items-center">
|
||||
<span class="text-sm font-black text-slate-700 dark:text-slate-200"
|
||||
x-text="formatTime(machine.last_heartbeat_at)"></span>
|
||||
<span
|
||||
class="text-[10px] font-bold text-slate-400 dark:text-slate-500 uppercase tracking-widest mt-0.5"
|
||||
x-text="machine.last_heartbeat_at ? machine.last_heartbeat_at.split('T')[0] : '--'"></span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-6 text-right">
|
||||
<button @click="selectMachine(machine)"
|
||||
class="p-2.5 rounded-lg bg-slate-50 dark:bg-slate-800 text-slate-400 hover:text-cyan-500 hover:bg-cyan-500/5 transition-all border border-transparent hover:border-cyan-500/20"
|
||||
title="{{ __('Manage') }}">
|
||||
<svg class="size-4" fill="none" stroke="currentColor"
|
||||
viewBox="0 0 24 24" stroke-width="2.5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
|
||||
</svg>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="luxury-card rounded-3xl p-8 overflow-hidden relative">
|
||||
<div x-ref="listContent">
|
||||
@include('admin.remote.partials.tab-machines-index')
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user