@extends('layouts.admin') @section('content')
@if(auth()->user()->isSystemAdmin())
@endif {{-- 桌面版表格 --}} {{-- 行動版/平版 Card 列表 --}}
@forelse($companies as $company) @php $settings = $company->settings ?? []; $isEnabled = (bool)($settings['discord_notify_enabled'] ?? false); $webhook = $settings['discord_webhook_url'] ?? ''; $types = $settings['discord_notify_types'] ?? []; @endphp

{{ $company->name }}

{{ $company->code }}

{{ __('Webhook URL') }}

@if($webhook)

{{ $webhook }}

@else

{{ __('Not Configured') }}

@endif

{{ __('Configured Alert Types') }}

@if(empty($types)) @endif @foreach($types as $type) @php $label = match($type) { 'submachine' => __('Device Exception'), 'status' => __('Connectivity Logs'), 'temperature' => __('Temperature Alert'), default => $type }; @endphp {{ $label }} @endforeach
@empty @endforelse
{{-- 分頁 --}}
{{ $companies->appends(array_merge(request()->query(), ['tab' => 'company']))->links('vendor.pagination.luxury', [ 'ajax_navigate_event' => 'ajax:navigate:discord', 'per_page_param' => 'company_per_page', ]) }}
@if(auth()->user()->isSystemAdmin())
@foreach($allCompanies as $c) @endforeach
@endif
{{-- 桌面版表格 --}} {{-- 行動版/平版 Card 列表 --}}
@forelse($machines as $machine) @php $mSettings = $machine->settings ?? []; $mWebhook = $mSettings['discord_webhook_url'] ?? null; $cSettings = $machine->company->settings ?? []; $cWebhook = $cSettings['discord_webhook_url'] ?? null; $cNotifyTypes = $cSettings['discord_notify_types'] ?? []; $mNotifyTypes = array_key_exists('discord_notify_types', $mSettings) && is_array($mSettings['discord_notify_types']) ? $mSettings['discord_notify_types'] : null; $effectiveNotifyTypes = $mNotifyTypes ?? $cNotifyTypes; $isTypeInherited = $mNotifyTypes === null; $hasTemperatureNotify = in_array('temperature', $effectiveNotifyTypes, true); $mTempAlert = $mSettings['temp_alert_enabled'] ?? 'inherit'; // 繼承鏈 $mUpper = $mSettings['temp_upper_limit'] ?? null; $mLower = $mSettings['temp_lower_limit'] ?? null; $modelSettings = $machine->machineModel->settings ?? []; $modelUpper = $modelSettings['temp_upper_limit'] ?? null; $modelLower = $modelSettings['temp_lower_limit'] ?? null; $sysUpper = 40.0; $sysLower = 0.0; $finalUpper = $sysUpper; $finalLower = $sysLower; $tempSource = __('System Default'); if ($mTempAlert === 'enabled' && $hasTemperatureNotify && ($mUpper !== null || $mLower !== null)) { $finalUpper = $mUpper !== null ? $mUpper : $sysUpper; $finalLower = $mLower !== null ? $mLower : $sysLower; $tempSource = __('Custom'); } elseif ($hasTemperatureNotify && ($modelUpper !== null || $modelLower !== null)) { $finalUpper = $modelUpper !== null ? $modelUpper : $sysUpper; $finalLower = $modelLower !== null ? $modelLower : $sysLower; $tempSource = __('Model Default'); } @endphp

{{ $machine->name }}

{{ $machine->serial_no }}

{{-- Temperature status is implied by configured alert types; show only range below. --}}

{{ __('Model') }}

{{ $machine->machineModel->name ?? __('No Model') }}

@if(auth()->user()->isSystemAdmin())

{{ __('Company') }}

{{ $machine->company->name ?? __('No Company') }}

@endif

{{ __('Webhook URL') }}

@if($mWebhook)

{{ $mWebhook }}

{{ __('Machine Specific') }} @elseif($cWebhook)

{{ $cWebhook }}

{{ __('Inherit Company') }} @else

{{ __('Not Configured') }}

@endif

{{ __('Configured Alert Types') }}

@if($isTypeInherited) {{ __('Inherit Company') }} @endif
@foreach($effectiveNotifyTypes as $type) @php $label = match($type) { 'submachine' => __('Device Exception'), 'status' => __('Connectivity Logs'), 'temperature' => __('Temperature Alert'), default => $type }; @endphp {{ $label }} @endforeach @if(empty($effectiveNotifyTypes))

{{ __('Not Configured') }}

@endif
@if($mTempAlert !== 'disabled' && $hasTemperatureNotify)

{{ __('Temp Alert Range') }}

{{ number_format($finalLower, 0) }}°C ~ {{ number_format($finalUpper, 0) }}°C ({{ $tempSource }})
@endif
@empty @endforelse
{{-- 分頁 --}}
{{ $machines->appends(array_merge(request()->query(), ['tab' => 'machine']))->links('vendor.pagination.luxury', [ 'ajax_navigate_event' => 'ajax:navigate:discord', 'per_page_param' => 'machine_per_page', ]) }}
@endsection @section('scripts') @endsection