{% extends 'base.html' %}
{% block content %}
    <div class="container">
        <h1>센서 값 대시보드</h1>

        <div class="sensor">
            <p>초음파 센서:</p>
            <div class="value">{{ ultrasonic_value | round(2) }} cm</div>
        </div>

        <div class="sensor">
            <p>온도 센서:</p>
            <div class="value">{{ temperature_value | round(2) }} °C</div>
        </div>

        <div class="sensor">
            <p>습도 센서:</p>
            <div class="value">{{ humidity_value | round(2) }} %</div>
        </div>

        <a href="{{ url_for('monitor.sensor') }}">
            <button>값 갱신</button>
        </a>
		<hr>
        <div class="sensor-value">
            <p>현재 거리:</p>
            <div class="value">{{ ultrasonic_value | round(2) }} cm</div>
        </div>
        <div class="sensor-value">
        <h2>최근 5개의 측정값</h2>
		<table class="table table-hover">
			<thead>
                <tr>
                    <th>ID</th>
                    <th>거리 (cm)</th>
                    <th>타임스탬프</th>
                </tr>
            </thead>
            <tbody>
                {% for row in data %}
                <tr>
                    <td>{{ row[0] }}</td>
                    <td>{{ row[1] }}</td>
                    <td>{{ row[2] }}</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>		
		</div>
        <div class="login-btn-container mt-5">
            {% if not user_is_authenticated %}
                <a href="{{url_for('auth.login')}}" class="btn btn-success btn-lg">로그인</a>
            {% else %}
                <a href="{{url_for('auth.logout')}}" class="btn btn-danger btn-lg">로그아웃</a>
            {% endif %}
        </div>		
    </div>
{% endblock %}
