調整包廂Status 功能介面改維護
This commit is contained in:
parent
2769e82a37
commit
b17d008735
@ -8,7 +8,7 @@ use App\Enums\Traits\HasLabels;
|
||||
* @OA\Schema(
|
||||
* schema="RoomStatus",
|
||||
* type="string",
|
||||
* enum={"active", "closed", "fire", "error"},
|
||||
* enum={"active", "closed", "fire", "maintain", "error"},
|
||||
* example="error"
|
||||
* )
|
||||
*/
|
||||
@ -18,6 +18,7 @@ enum RoomStatus: string {
|
||||
case Active = 'active';
|
||||
case Closed = 'closed';
|
||||
case Fire ='fire';
|
||||
case Maintain ='maintain';
|
||||
case Error = 'error';
|
||||
|
||||
// 返回對應的顯示文字
|
||||
@ -27,6 +28,7 @@ enum RoomStatus: string {
|
||||
self::Active => __('enums.room.status.Active'),
|
||||
self::Closed => __('enums.room.status.Closed'),
|
||||
self::Fire => __('enums.room.status.Fire'),
|
||||
self::Maintain => __('enums.room.status.Maintain'),
|
||||
self::Error => __('enums.room.status.Error'),
|
||||
};
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class RoomControlController extends Controller
|
||||
'started_at' => $validated['started_at'] ?? null,
|
||||
'ended_at' => $validated['ended_at'] ?? null,
|
||||
];
|
||||
$token = \App\Models\User::find(2)->api_plain_token;
|
||||
$token = auth()->user()?->api_plain_token;
|
||||
$api = new \App\Services\ApiClient($branch->external_ip,$token);
|
||||
$response = $api->post('/api/room/sendSwitch', $payload);
|
||||
|
||||
|
@ -16,7 +16,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
* @OA\Property(property="internal_ip", type="string", nullable=true, example="192.168.1.100"),
|
||||
* @OA\Property(property="port", type="integer", nullable=true, example=3389),
|
||||
* @OA\Property(property="is_online", type="integer", enum={0, 1}, example=1),
|
||||
* @OA\Property(property="status", type="string", enum={"active", "closed", "fire", "error"}, example="active"),
|
||||
* @OA\Property(property="status", type="string", enum={"active", "closed", "fire","maintain", "error"}, example="active"),
|
||||
* @OA\Property(property="started_at", type="string", format="date-time", nullable=true, example="2025-05-19 09:31:00"),
|
||||
* @OA\Property(property="ended_at", type="string", format="date-time", nullable=true, example="2025-05-19 12:00:00")
|
||||
* )
|
||||
@ -39,7 +39,7 @@ class ReceiveSwitchRequest extends ApiRequest
|
||||
'internal_ip' => ['nullable','string'],
|
||||
'port' => ['nullable','integer'],
|
||||
'is_online' => ['required','integer'],
|
||||
'status' => ['required','in:active,closed,fire,error'],
|
||||
'status' => ['required','in:active,closed,fire,maintain,error'],
|
||||
'started_at' => ['nullable','date'],
|
||||
'ended_at' => ['nullable','date'],
|
||||
];
|
||||
|
@ -10,7 +10,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
* required={"branch_name", "room_name", "command"},
|
||||
* @OA\Property(property="branch_name", type="string", example="測試"),
|
||||
* @OA\Property(property="room_name", type="string", example="pc102"),
|
||||
* @OA\Property(property="command", type="string", enum={"active", "closed", "fire", "error"}, example="active"),
|
||||
* @OA\Property(property="command", type="string", enum={"active", "closed", "fire",maintain, "error"}, example="active"),
|
||||
* @OA\Property(property="started_at", type="string", nullable=true, example="2025-05-19 09:31:00"),
|
||||
* @OA\Property(property="ended_at", type="string", nullable=true, example="2025-05-19 09:31:00")
|
||||
* )
|
||||
@ -27,7 +27,7 @@ class SendRoomSwitchCommandRequest extends ApiRequest
|
||||
return [
|
||||
'branch_name' => ['required','string','exists:branches,name'],
|
||||
'room_name' => ['required','string'],
|
||||
'command' => ['required','in:active,closed,fire,error'],
|
||||
'command' => ['required','in:active,closed,fire,maintain,error'],
|
||||
'started_at'=> ['nullable','date_format:Y-m-d H:i:s'],
|
||||
'ended_at' => ['nullable','date_format:Y-m-d H:i:s'],
|
||||
];
|
||||
|
@ -37,7 +37,7 @@ class RoomDetailModal extends Component
|
||||
}
|
||||
public function startNotify()
|
||||
{
|
||||
$data = $this->buildNotifyData('active', now(), null);
|
||||
$data = $this->buildNotifyData('maintain', null, null);
|
||||
$this->send($data);
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,15 @@ class ApiClient
|
||||
|
||||
protected function withDefaultHeaders(): PendingRequest
|
||||
{
|
||||
$request = Http::connectTimeout($this->connectTimeout)
|
||||
->timeout($this->timeout)
|
||||
->withHeaders([
|
||||
'Accept' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . $this->token,
|
||||
]);
|
||||
$request = Http::withOptions([
|
||||
'verify' => false, // ✅ 關閉憑證驗證
|
||||
])
|
||||
->connectTimeout($this->connectTimeout)
|
||||
->timeout($this->timeout)
|
||||
->withHeaders([
|
||||
'Accept' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . $this->token,
|
||||
]);
|
||||
|
||||
if ($this->retryTimes > 0) {
|
||||
$request = $request->retry($this->retryTimes, $this->retryDelay, function ($exception, $request) {
|
||||
|
@ -20,7 +20,7 @@ return new class extends Migration
|
||||
$table->string('internal_ip')->nullable()->comment('內部 IP');
|
||||
$table->unsignedSmallInteger('port')->nullable()->comment('通訊 Port');
|
||||
$table->tinyInteger('is_online')->default(0)->comment('連線狀態');
|
||||
$table->enum('status', ['active', 'closed','fire', 'error'])->default('error')->comment('狀態'); // :啟用中 / 已結束
|
||||
$table->enum('status', ['active', 'closed','fire', 'error', 'maintain'])->default('error')->comment('狀態'); // :啟用中 / 已結束
|
||||
$table->dateTime('started_at')->nullable()->comment('開始時間'); //
|
||||
$table->dateTime('ended_at')->nullable()->comment('結束時間'); //
|
||||
$table->timestamps();
|
||||
|
@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('room_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('user_id')->nullable()->constrained()->onDelete('set null'); // 操作者,可為 null(系統)
|
||||
$table->enum('status', ['active', 'closed','fire', 'error', 'maintenance']);
|
||||
$table->enum('status', ['active', 'closed','fire', 'error', 'maintain']);
|
||||
$table->text('message')->nullable(); // 可填異常原因或操作說明
|
||||
$table->timestamps();
|
||||
});
|
||||
|
@ -27,5 +27,6 @@ return [
|
||||
'room.status.Active' => '已占用',
|
||||
'room.status.Closed' => '可用',
|
||||
'room.status.Fire' => '火災',
|
||||
'room.status.Error' => '維修',
|
||||
'room.status.Maintain' => '維護',
|
||||
'room.status.Error' => '異常',
|
||||
];
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'active' => '正常',
|
||||
'error' => '維修',
|
||||
|
||||
];
|
@ -18,7 +18,7 @@ return [
|
||||
'ended_at' =>'結束於',
|
||||
'created_at' =>'建立於',
|
||||
'active' => '正常',
|
||||
'error' => '維修',
|
||||
'error' => '關機',
|
||||
|
||||
'select_type' =>'選擇型別',
|
||||
|
||||
|
@ -8,6 +8,6 @@
|
||||
|
||||
</div>
|
||||
<div class="text-sm text-{{ $room->is_online ? 'green-600': 'red-600' }} text-center">
|
||||
{{ $room->is_online ? __('room.active') : __('room.error') }}
|
||||
{{ $room->is_online ? __('rooms.active') : __('rooms.error') }}
|
||||
</div>
|
||||
</div>
|
@ -3,7 +3,7 @@
|
||||
$statusColors = [
|
||||
RoomStatus::Active->value => 'green-600',
|
||||
RoomStatus::Closed->value => 'gray-600',
|
||||
RoomStatus::Error->value => 'red-600',
|
||||
RoomStatus::Maintain->value => 'red-600',
|
||||
];
|
||||
@endphp
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
</div>
|
||||
@if(!$room->is_online)
|
||||
<div class="text-sm text-red-600 text-center">
|
||||
{{ __('room.error') }}
|
||||
{{ __('rooms.error') }}
|
||||
</div>
|
||||
@else
|
||||
<div class="text-sm text-{{ $statusColors[$room->status->value] ?? 'gray-500' }} text-center">
|
||||
|
@ -59,6 +59,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-wireui:notifications/>
|
||||
<livewire:grids.modals.room-detail-modal />
|
||||
</x-wireui:card>
|
Loading…
x
Reference in New Issue
Block a user