Juice/templates/index.html

224 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>Juice</title>
<link rel="stylesheet" type="text/css" href="/static/juice.css">
<script>
const init_state = {{ init_state|tojson|safe }};
const ws_uri = "{{ url('ws') }}";
</script>
<script type="text/javascript" src="/static/juice.js"></script>
<script>window.onload = load;</script>
<meta name="viewport" content="width=device-width, initial-scale=0.8">
<meta name="description" content="An IOT hub.">
<meta name="theme-color" content="lightblue">
<link rel="manifest" href="/static/juice-manifest.webmanifest">
<link rel="icon" href="/static/orange-juice.svg">
<link rel="icon" href="/static/orange-juice-144p.png">
</head>
<body>
<header>
<div id="logo-line">
<object id="logo" aria-label="Juice: An IOT hub" data="/static/orange-juice.svg"></object>
<h1>Juice</h1>
<h3>An IOT hub</h3>
</div>
<nav>
<span class="font-awesome" title="Home"><a href="./">&#xe806;</a></span>
<span class="font-awesome" title="Add new device" onclick="document.querySelector('#new_device_dialog').showModal();">&#xe802;</span>
</nav>
</header>
<main>
<div id="devices">
{% for device in network %}
{% if device.type == 'RelayDevice' %}
{% include 'RelayDevice.html' %}
{% elif device.type == 'LightStrip' %}
{% include 'LightStrip.html' %}
{% elif device.type == 'LixieClock' %}
{% include 'LixieClock.html' %}
{% endif %}
{% endfor %}
</div>
</main>
<template id="RelayDevice_template">
<div class="device RelayDevice" id="">
<div class="id editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span><span class="delete font-awesome" onclick="delete_device(this.parentElement.parentElement)">&#xe804;</span><span class="lock font-awesome" onclick="lock_device(this.parentElement.parentElement)">&#xe803;</span></div>
<div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="location editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="ip_address editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="sub_devices">
</div>
</div>
</template>
<template id="RelayOutlet_template">
<div class="sub_device RelayOutlet">
<div class="id"></div>
<object class="outlet_image" alt="Outlet Image" data="/static/outlet.svg"></object>
<div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div>
</template>
<template id="LightStrip_template">
<div class="device LightStrip" id="">
<div class="id editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span><span class="delete font-awesome" onclick="delete_device(this.parentElement.parentElement)">&#xe804;</span><span class="lock font-awesome" onclick="lock_device(this.parentElement.parentElement)">&#xe803;</span></div>
<div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="location editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="mqtt_root editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="light_controls">
<div class="state">
<span>State</span><br>
<select class="state_select" onchange="state_select(this)">
<option selected value="solid">Solid</option>
<option value="rainbow">Rainbow</option>
<option value="america">America</option>
</select>
<div class="state_solid" style="display: block">
<input type="radio" id="state_solid_all_" name="state_solid_" value="all" onchange="state_solid_amount(this)" checked>
<label for="state_solid_all_">All</label><br>
<input type="radio" id="state_solid_single_" name="state_solid_" value="single" onchange="state_solid_amount(this)">
<label for="state_solid_single_">Single</label><br>
<label for="state_solid_all_color_">All:</label>
<input type="color" id="state_solid_all_color_" value="#000000" onchange="neopixel_state(this.closest('.device'))">
</div>
<div class="state_rainbow" style="display: none">
<table>
<tr>
<td>Red</td>
<td>
<input type="number" id="state_rainbow_red_freq_" min="0" max="1" step="0.1" value="0.5" onchange="neopixel_state(this.closest('.device'))">
<label for="state_rainbow_red_freq_">f</label>
</td>
<td>
<input type="number" id="state_rainbow_red_phase_" min="0" max="10" step="1" value="0" onchange="neopixel_state(this.closest('.device'))">
<label for="state_rainbow_red_phase_">Φ</label>
</td>
</tr>
<tr>
<td>Green</td>
<td>
<input type="number" id="state_rainbow_green_freq_" min="0" max="1" step="0.1" value="0.5" onchange="neopixel_state(this.closest('.device'))">
<label for="state_rainbow_green_freq_">f</label>
</td>
<td>
<input type="number" id="state_rainbow_green_phase_" min="0" max="10" step="1" value="2" onchange="neopixel_state(this.closest('.device'))">
<label for="state_rainbow_green_phase_">Φ</label>
</td>
</tr>
<tr>
<td>Blue</td>
<td>
<input type="number" id="state_rainbow_blue_freq_" min="0" max="1" step="0.1" value="0.5" onchange="neopixel_state(this.closest('.device'))">
<label for="state_rainbow_blue_freq_">f</label>
</td>
<td>
<input type="number" id="state_rainbow_blue_phase_" min="0" max="10" step="1" value="4" onchange="neopixel_state(this.closest('.device'))">
<label for="state_rainbow_blue_phase_">Φ</label>
</td>
</tr>
<tr>
<td><label for="state_rainbow_center_">Center</label></td>
<td><input type="number" id="state_rainbow_center_" min="0" max="255" step="1" value="28" onchange="neopixel_state(this.closest('.device'))"></td>
</tr>
<tr>
<td><label for="state_rainbow_width_">Width</label></td>
<td><input type="number" id="state_rainbow_width_" min="0" max="128" step="1" value="28" onchange="neopixel_state(this.closest('.device'))"></td>
</tr>
</table>
</div>
<div class="state_america" style="display: none">
<table>
<tr>
<td><label for="state_america_stripe_">Stripe Length</label></td>
<td><input type="number" id="state_america_stripe_" min="1" max="256" step="1" value="8" onchange="neopixel_state(this.closest('.device'))"></td>
</tr>
<tr>
<td><label for="state_america_magnitude_">Magnitude</label></td>
<td><input type="number" id="state_america_magnitude_" min="0" max="255" step="1" value="127" onchange="neopixel_state(this.closest('.device'))"></td>
</tr>
</table>
</div>
</div>
<div class="animation">
<span>Animation</span><br>
<select class="animation_select" onchange="animation_select(this)">
<option selected value="static">Static</option>
<option value="rotate_left">Rotate Left</option>
<option value="rotate_right">Rotate Right</option>
</select>
<div class="animation_static" style="display: block">
</div>
<div class="animation_rotate" style="display: none">
<label for="animation_rotate_count_">Rotate Count</label>
<input type="number" id="animation_rotate_count_" min="1" max="255" step="1" value="1" onchange="neopixel_animation(this.closest('.device'))">
</div>
Delay
<input type="number" id="animation_delay_" min="1" max="255" step="1" value="200" onchange="neopixel_animation(this)">
<label for="animation_delay_">ms</label>
</div>
</div>
<div class="sub_devices">
</div>
</div>
</template>
<template id="NeoPixel_template">
<div class="sub_device NeoPixel">
<label class="NeoPixel_color" style="background-color: #000000">
<input class="NeoPixel_color_input" type="color" value="#000000" onchange="neopixel_state(this.closest('.sub_device'))" disabled>
</label>
</div>
</template>
<template id="LixieClock_template">
<div class="device LixieClock" id="">
<div class="id editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span><span class="delete font-awesome" onclick="delete_device(this.parentElement.parentElement)">&#xe804;</span><span class="lock font-awesome" onclick="lock_device(this.parentElement.parentElement)">&#xe803;</span></div>
<div class="description editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="location editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="mqtt_root editable"><span class="field_value"></span><span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="lixie_controls">
<input type="radio" id="display_mode_time_" class="time" name="display_mode_" value="time" onchange="lixie_display_mode(this)" checked>
<label for="display_mode_time_">Time</label><br>
<div class='lixie_time_offset' style="display: block">
<label for="lixie_time_offset_">Time Zone Offset:</label>
<input type="number" id="lixie_time_offset_" class="time_offset" min="-12" max="12" value="-5" onchange="lixie_clock(this)">
</div>
<input type="radio" id="display_mode_number_" class="number" name="display_mode_" value="number" onchange="lixie_display_mode(this)">
<label for="display_mode_number_">Number</label><br>
<div class="lixie_number" style="display: none">
<label for="lixie_number_">Number:</label>
<input type="number" id="lixie_number_" class="number" min="0" max="9999" value="1111" onchange="lixie_clock(this)">
</div>
<label for="display_color_">Color:</label>
<input type="color" id="display_color_" class="color" value="#000000" onchange="lixie_clock(this)">
</div>
<div class="sub_devices">
</div>
</div>
</template>
<template id="LixieDisplay_template">
<div class="sub_device LixieDisplay">
LixieDisplay
</div>
</template>
<dialog id="new_device_dialog" onclose="new_device(this)">
<form id="new_device_form" method="dialog">
<div id="new_device_settings">
<div>
<input type="radio" name="new_device_type" id="new_device_relay" value="relay_device" checked>
<label for="new_device_relay">Relay Device</label><br>
<input type="radio" name="new_device_type" id="new_device_light_strip" value="light_strip">
<label for="new_device_light_strip">Light Strip</label><br>
<input type="radio" name="new_device_type" id="new_device_lixie_clock" value="lixie_clock">
<label for="new_device_lixie_clock">Lixie Clock</label>
</div>
<div>
<label for="new_device_id">New Device ID</label>
<input type"text" id="new_device_id" required><br>
<label for="new_device_num_sub_devices">Num. Sub-Devices:</label>
<input type="number" id="new_device_num_sub_devices" min="0" max="999" default="2"><br>
</div>
</div>
<input type="submit">
</form>
</dialog>
</body>
</html>