feat: 實作機台日誌核心功能與 IoT 高併發處理架構
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 36s

This commit is contained in:
2026-03-09 09:43:51 +08:00
parent 21e064ff91
commit c30c3a399d
53 changed files with 2300 additions and 2130 deletions

View File

@@ -1,74 +1,80 @@
@extends('layouts.admin')
@section('content')
@php
@endphp
<div class="container mx-auto px-6 py-8">
<div class="flex justify-between items-center">
<h3 class="text-gray-900 dark:text-gray-200 text-3xl font-medium">機台管理</h3>
<a href="{{ route('admin.machines.create') }}" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded">
新增機台
</a>
</div>
@section('header')
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('機台管理') }}
</h2>
@endsection
<div class="mt-8">
<div class="flex flex-col">
<div class="-my-2 py-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
<div class="align-middle inline-block min-w-full shadow overflow-hidden sm:rounded-lg border-b border-gray-200 dark:border-gray-700">
<table class="min-w-full">
<thead>
@section('content')
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg border border-gray-200">
<div class="p-6 text-gray-900">
<div class="flex justify-between items-center mb-6">
<h3 class="text-lg font-medium">機台列表</h3>
<div class="flex space-x-2">
<a href="{{ route('admin.machines.index') }}" class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-md text-sm transition">全部</a>
<a href="{{ route('admin.machines.index', ['status' => 'online']) }}" class="px-4 py-2 bg-green-100 text-green-700 hover:bg-green-200 rounded-md text-sm transition">線上</a>
<a href="{{ route('admin.machines.index', ['status' => 'error']) }}" class="px-4 py-2 bg-red-100 text-red-700 hover:bg-red-200 rounded-md text-sm transition">異常</a>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-left text-xs leading-4 font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wider">名稱</th>
<th class="px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-left text-xs leading-4 font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wider">位置</th>
<th class="px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-left text-xs leading-4 font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wider">狀態</th>
<th class="px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-left text-xs leading-4 font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wider">溫度</th>
<th class="px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-left text-xs leading-4 font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wider">最後心跳</th>
<th class="px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-left text-xs leading-4 font-medium text-gray-600 dark:text-gray-400 uppercase tracking-wider">操作</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">名稱</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">位置</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">狀態</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">溫度</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">最後心跳</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-gray-800">
@foreach($machines as $machine)
<tr>
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 dark:border-gray-700">
<div class="text-sm leading-5 font-medium text-gray-900 dark:text-gray-200">{{ $machine->name }}</div>
<tbody class="bg-white divide-y divide-gray-200">
@foreach ($machines as $machine)
<tr class="hover:bg-gray-50 transition">
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">{{ $machine->name }}</div>
<div class="text-xs text-gray-500">{{ $machine->firmware_version }}</div>
</td>
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 dark:border-gray-700">
<div class="text-sm leading-5 text-gray-600 dark:text-gray-400">{{ $machine->location ?? '-' }}</div>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $machine->location }}
</td>
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 dark:border-gray-700">
@if($machine->status === 'online')
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">連線中</span>
@elseif($machine->status === 'offline')
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">離線</span>
@else
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">異常</span>
@endif
<td class="px-6 py-4 whitespace-nowrap">
@php
$statusClasses = [
'online' => 'bg-green-100 text-green-800',
'offline' => 'bg-gray-100 text-gray-800',
'error' => 'bg-red-100 text-red-800',
];
$class = $statusClasses[$machine->status] ?? 'bg-blue-100 text-blue-800';
@endphp
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full {{ $class }}">
{{ strtoupper($machine->status) }}
</span>
</td>
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 dark:border-gray-700">
<div class="text-sm leading-5 text-gray-600 dark:text-gray-400">{{ $machine->temperature ? $machine->temperature . '°C' : '-' }}</div>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $machine->temperature ?? '--' }} °C
</td>
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 dark:border-gray-700">
<div class="text-sm leading-5 text-gray-600 dark:text-gray-400">{{ $machine->last_heartbeat_at ? $machine->last_heartbeat_at->diffForHumans() : '-' }}</div>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $machine->last_heartbeat_at ? $machine->last_heartbeat_at->diffForHumans() : '從未連線' }}
</td>
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 dark:border-gray-700 text-sm leading-5 font-medium">
<a href="{{ route('admin.machines.show', $machine) }}" class="text-indigo-400 hover:text-indigo-600 mr-3">查看</a>
<a href="{{ route('admin.machines.edit', $machine) }}" class="text-yellow-400 hover:text-yellow-600 mr-3">編輯</a>
<form action="{{ route('admin.machines.destroy', $machine) }}" method="POST" class="inline-block" onsubmit="return confirm('確定要刪除嗎?');">
@csrf
@method('DELETE')
<button type="submit" class="text-red-400 hover:text-red-600">刪除</button>
</form>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<a href="{{ route('admin.machines.show', $machine->id) }}" class="text-indigo-600 hover:text-indigo-900 bg-indigo-50 px-3 py-1 rounded-md transition border border-indigo-100">查看日誌</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="mt-6">
{{ $machines->links() }}
</div>
</div>
</div>
<div class="mt-4">
{{ $machines->links() }}
</div>
</div>
</div>
@endsection