diff --git a/app/Enums/RoomStatus.php b/app/Enums/RoomStatus.php index 3339443..00ef805 100644 --- a/app/Enums/RoomStatus.php +++ b/app/Enums/RoomStatus.php @@ -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'), }; } diff --git a/app/Http/Controllers/RoomControlController.php b/app/Http/Controllers/RoomControlController.php index 84bd146..a25ae43 100644 --- a/app/Http/Controllers/RoomControlController.php +++ b/app/Http/Controllers/RoomControlController.php @@ -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); diff --git a/app/Http/Requests/ReceiveSwitchRequest.php b/app/Http/Requests/ReceiveSwitchRequest.php index da002df..00f5fd4 100644 --- a/app/Http/Requests/ReceiveSwitchRequest.php +++ b/app/Http/Requests/ReceiveSwitchRequest.php @@ -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'], ]; diff --git a/app/Http/Requests/SendRoomSwitchCommandRequest.php b/app/Http/Requests/SendRoomSwitchCommandRequest.php index 07b8bcc..3dc8237 100644 --- a/app/Http/Requests/SendRoomSwitchCommandRequest.php +++ b/app/Http/Requests/SendRoomSwitchCommandRequest.php @@ -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'], ]; diff --git a/app/Livewire/Grids/Modals/RoomDetailModal.php b/app/Livewire/Grids/Modals/RoomDetailModal.php index c6fb3d6..8766ce3 100644 --- a/app/Livewire/Grids/Modals/RoomDetailModal.php +++ b/app/Livewire/Grids/Modals/RoomDetailModal.php @@ -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); } diff --git a/app/Services/ApiClient.php b/app/Services/ApiClient.php index 3bee70c..9f52345 100644 --- a/app/Services/ApiClient.php +++ b/app/Services/ApiClient.php @@ -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) { diff --git a/database/migrations/2025_05_06_055307_create_rooms_table.php b/database/migrations/2025_05_06_055307_create_rooms_table.php index 1ace277..c0b527a 100644 --- a/database/migrations/2025_05_06_055307_create_rooms_table.php +++ b/database/migrations/2025_05_06_055307_create_rooms_table.php @@ -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(); diff --git a/database/migrations/2025_05_06_055312_create_room_status_logs_table.php b/database/migrations/2025_05_06_055312_create_room_status_logs_table.php index 33c9743..59f2d25 100644 --- a/database/migrations/2025_05_06_055312_create_room_status_logs_table.php +++ b/database/migrations/2025_05_06_055312_create_room_status_logs_table.php @@ -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(); }); diff --git a/resources/lang/zh-tw/enums.php b/resources/lang/zh-tw/enums.php index 1d05487..2cd2211 100644 --- a/resources/lang/zh-tw/enums.php +++ b/resources/lang/zh-tw/enums.php @@ -27,5 +27,6 @@ return [ 'room.status.Active' => '已占用', 'room.status.Closed' => '可用', 'room.status.Fire' => '火災', - 'room.status.Error' => '維修', + 'room.status.Maintain' => '維護', + 'room.status.Error' => '異常', ]; \ No newline at end of file diff --git a/resources/lang/zh-tw/room.php b/resources/lang/zh-tw/room.php deleted file mode 100644 index 6e766fb..0000000 --- a/resources/lang/zh-tw/room.php +++ /dev/null @@ -1,7 +0,0 @@ - '正常', - 'error' => '維修', - -]; \ No newline at end of file diff --git a/resources/lang/zh-tw/rooms.php b/resources/lang/zh-tw/rooms.php index 154c4f2..310ca87 100644 --- a/resources/lang/zh-tw/rooms.php +++ b/resources/lang/zh-tw/rooms.php @@ -18,7 +18,7 @@ return [ 'ended_at' =>'結束於', 'created_at' =>'建立於', 'active' => '正常', - 'error' => '維修', + 'error' => '關機', 'select_type' =>'選擇型別', diff --git a/resources/views/components/room-card-svr.blade.php b/resources/views/components/room-card-svr.blade.php index 7e3bcb3..9fd91bf 100644 --- a/resources/views/components/room-card-svr.blade.php +++ b/resources/views/components/room-card-svr.blade.php @@ -8,6 +8,6 @@