<!DOCTYPE html>
<html lang="en">
{{ template "head" . }}
<body>

<div class="container-fluid">
    {{ $root := . }}
    {{ $devs := .Devices }}
    {{ $temperatures := .Temperatures }}
    {{ $device := .Device }}
    {{ $fanModes := .Device.FanModes }}
    {{ $fanMode := .Device.DeviceProfile.FanMode }}
    {{ $devices := $device.Devices }}
    <input type="hidden" id="deviceId" name="deviceId" value="{{ $device.Serial }}">

    <div class="row">
        <!-- Sidebar -->
        {{ template "sidebar" . }}

        <!-- Main -->
        <main class="main-content p-4">
            <!-- Temperature bar -->
            {{ if .Dashboard.TemperatureBar }}
            {{ template "temperature-bar" . }}
            {{ end }}

            <!-- PSU -->
            <div class="row g-4 mb-4 align-items-start">
                <div class="col-md-2">
                    <div class="card system-card text-center">
                        <div class="card-header">
                            {{ $device.Product }}
                        </div>
                        <div class="card-body">
                            <div class="settings-list">
                                {{ range $device := $devices }}
                                {{ if $device.MainPSU }}
                                {{ continue }}
                                {{ end }}

                                <!-- Speed -->
                                {{ if $device.HasSpeed }}
                                <div class="settings-row">
                                    <span class="settings-label text-ellipsis">{{ $root.Lang "txtSpeed" }}</span>
                                    <span class="meta-value" id="speed-{{ .DeviceId }}">{{ $device.Rpm }} RPM</span>
                                </div>
                                <div class="settings-row">
                                    <span class="settings-label text-ellipsis">{{ $root.Lang "txtProfile" }}</span>
                                    <label>
                                        <select class="form-select system-select compact auto-width fanProfile" name="{{ $device.DeviceId }}">
                                            {{ range $key, $value := $fanModes }}
                                            <option value="{{ $key }}" {{ if eq $fanMode $key }} selected {{ end }}>{{ $value }}</option>
                                            {{ end }}
                                        </select>
                                    </label>
                                </div>
                                {{ end }}

                                <!-- Temperatures -->
                                {{ if $device.HasTemps }}
                                <div class="settings-row">
                                    <span class="settings-label text-ellipsis">{{ $device.Name }}</span>
                                    <span class="meta-value" id="temperature-{{ .DeviceId }}">{{ $device.TemperatureString }}</span>
                                </div>
                                {{ end }}

                                <!-- Power Out -->
                                {{ if eq $device.Name "Power Out" }}
                                <div class="settings-row">
                                    <span class="settings-label text-ellipsis">{{ $device.Name }}</span>
                                    <span class="meta-value" id="watts-{{ .DeviceId }}">{{ $device.Watts }} W</span>
                                </div>
                                {{ end }}

                                {{ end }}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-10">
                    <div class="row g-4 mb-4 align-items-start">
                        {{ range $device := $devices }}
                        {{ if $device.HasSpeed }}
                        {{ continue }}
                        {{ else if $device.HasTemps }}
                        {{ continue }}
                        {{ else if eq $device.Name "Power Out" }}
                        {{ continue }}
                        {{ else if $device.MainPSU }}
                        {{ continue }}
                        {{ end }}
                        <div class="col-md-2">
                            <div class="card system-card">
                                <div class="card-header header-split">
                                    <span class="header-left">
                                        {{ $device.Name }}
                                    </span>
                                    <span class="header-right">
                                        <span class="labelValue">{{ $device.Label }}</span>
                                    </span>
                                </div>

                                <div class="card-body">
                                    <div class="settings-list">
                                        <!-- Watts -->
                                        {{ if $device.HasWatts }}
                                        <div class="settings-row">
                                            <span class="settings-label text-ellipsis">{{ $root.Lang "txtWatts" }}</span>
                                            <span class="meta-value" id="watts-{{ .DeviceId }}">{{ $device.Watts }} W</span>
                                        </div>
                                        {{ end }}

                                        <!-- Amps -->
                                        {{ if $device.HasAmps }}
                                        <div class="settings-row">
                                            <span class="settings-label text-ellipsis">{{ $root.Lang "txtAmps" }}</span>
                                            <span class="meta-value" id="amps-{{ .DeviceId }}">{{ $device.Amps }} A</span>
                                        </div>
                                        {{ end }}

                                        <!-- Volts -->
                                        {{ if $device.HasVolts }}
                                        <div class="settings-row">
                                            <span class="settings-label text-ellipsis">{{ $root.Lang "txtVolts" }}</span>
                                            <span class="meta-value" id="volts-{{ .DeviceId }}">{{ $device.Volts }} V</span>
                                        </div>
                                        {{ end }}

                                    </div>
                                </div>
                            </div>
                        </div>
                        {{ end }}
                    </div>
                </div>
            </div>
        </main>
    </div>
</div>
<script src="/static/js/psu.js"></script>
<script src="/static/js/sidebar.js"></script>
{{ if .Dashboard.TemperatureBar }}
<script src="/static/js/temperature-bar.js"></script>
{{ end }}
</body>
</html>