led.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. {% extends "base.html" %} {% block title %}LED Control - {{ app_name or 'Dune Weaver' }}{% endblock %}
  2. {% block additional_styles %}
  3. /* Dark mode styles for LED page */
  4. .dark .bg-white {
  5. background-color: #262626;
  6. }
  7. .dark .bg-gray-100 {
  8. background-color: #1f1f1f;
  9. }
  10. .dark .border-slate-200 {
  11. border-color: #404040;
  12. }
  13. .dark .border-slate-300 {
  14. border-color: #404040;
  15. }
  16. .dark .text-gray-500 {
  17. color: #9ca3af;
  18. }
  19. .dark .text-gray-700 {
  20. color: #d1d5db;
  21. }
  22. .dark .text-slate-500 {
  23. color: #a1a1aa;
  24. }
  25. .dark .text-slate-600 {
  26. color: #d4d4d8;
  27. }
  28. .dark .text-slate-700 {
  29. color: #e4e4e7;
  30. }
  31. .dark .text-slate-800 {
  32. color: #e5e5e5;
  33. }
  34. .dark .text-slate-900 {
  35. color: #f4f4f5;
  36. }
  37. /* Form elements */
  38. .dark input[type="range"] {
  39. background-color: #404040;
  40. }
  41. .dark select,
  42. .dark .form-select {
  43. background-color: #1f1f1f;
  44. border-color: #404040;
  45. color: #e5e5e5;
  46. }
  47. .dark select option {
  48. background-color: #262626;
  49. color: #e5e5e5;
  50. }
  51. /* Status messages - keep backgrounds but adjust borders */
  52. .dark .bg-green-50 {
  53. background-color: #14532d;
  54. }
  55. .dark .border-green-200 {
  56. border-color: #166534;
  57. }
  58. .dark .text-green-700 {
  59. color: #86efac;
  60. }
  61. .dark .bg-red-50 {
  62. background-color: #450a0a;
  63. }
  64. .dark .border-red-200 {
  65. border-color: #991b1b;
  66. }
  67. .dark .text-red-700 {
  68. color: #fca5a5;
  69. }
  70. .dark .bg-amber-50 {
  71. background-color: #451a03;
  72. }
  73. .dark .border-amber-200 {
  74. border-color: #92400e;
  75. }
  76. .dark .text-amber-700 {
  77. color: #fcd34d;
  78. }
  79. /* Iframe border */
  80. .dark iframe {
  81. border-color: #404040;
  82. }
  83. {% endblock %}
  84. {% block content %}
  85. <div class="layout-content-container flex flex-col w-full max-w-4xl gap-0 pt-2 pb-[75px]">
  86. <!-- Not Configured State -->
  87. <section id="led-not-configured" class="bg-white rounded-xl shadow-sm overflow-hidden pt-4 sm:pt-0 h-full hidden">
  88. <div class="flex flex-col items-center px-0 py-0 h-full">
  89. <div class="w-full h-full max-w-5xl flex flex-col overflow-hidden">
  90. <div class="w-full p-8 text-center">
  91. <div class="flex flex-col items-center gap-4">
  92. <span class="material-icons text-6xl text-gray-500">lightbulb</span>
  93. <h2 class="text-2xl font-semibold text-gray-700">LED Controller Not Configured</h2>
  94. <p class="text-gray-500 max-w-md">Please configure your LED controller (WLED or DW LEDs) in the Settings page.</p>
  95. <a href="/settings" class="mt-4 flex items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-3 text-sm font-semibold text-white shadow-md hover:bg-blue-700 transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-offset-2">
  96. <span class="material-icons">settings</span>
  97. Go to Settings
  98. </a>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </section>
  104. <!-- WLED iframe -->
  105. <section id="wled-container" class="bg-white rounded-xl shadow-sm overflow-hidden pt-4 sm:pt-0 h-full hidden">
  106. <div class="flex flex-col items-center px-0 py-0 h-full">
  107. <div class="w-full h-full max-w-5xl flex flex-col overflow-hidden">
  108. <iframe id="wled-frame"
  109. src=""
  110. class="h-full w-full rounded-lg border border-slate-200"
  111. frameborder="0"
  112. allowfullscreen
  113. ></iframe>
  114. </div>
  115. </div>
  116. </section>
  117. <!-- DW LEDs Controls -->
  118. <section id="dw-leds-container" class="bg-white rounded-xl shadow-sm overflow-hidden hidden">
  119. <div class="px-6 py-5 space-y-6">
  120. <h2 class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em]">
  121. DW LEDs Control
  122. </h2>
  123. <!-- Connection Status -->
  124. <div id="dw-leds-status" class="p-4 rounded-lg bg-gray-100 border border-slate-200">
  125. <div class="flex items-center gap-2">
  126. <span class="material-icons text-gray-500">info</span>
  127. <span class="text-sm text-gray-700">Checking connection...</span>
  128. </div>
  129. </div>
  130. <!-- Power and Brightness Grid -->
  131. <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
  132. <!-- Power Control -->
  133. <div class="flex flex-col gap-3">
  134. <h3 class="text-slate-800 text-base font-semibold">Power</h3>
  135. <button id="dw-leds-power-toggle" class="flex items-center justify-center gap-2 rounded-lg bg-green-600 px-4 py-3 text-sm font-semibold text-white shadow-md hover:bg-green-700 transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-green-400 focus:ring-offset-2">
  136. <span class="material-icons">power_settings_new</span>
  137. <span id="dw-leds-power-text">Turn ON</span>
  138. </button>
  139. </div>
  140. <!-- Brightness Control -->
  141. <div class="flex flex-col gap-3">
  142. <div class="flex items-center justify-between">
  143. <h3 class="text-slate-800 text-base font-semibold">Brightness</h3>
  144. <span id="dw-leds-brightness-value" class="text-sm font-medium text-slate-600">35%</span>
  145. </div>
  146. <input type="range" id="dw-leds-brightness" min="0" max="100" value="35" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
  147. </div>
  148. </div>
  149. <!-- Effects and Palettes -->
  150. <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
  151. <div class="flex flex-col gap-3">
  152. <h3 class="text-slate-800 text-base font-semibold">Effect</h3>
  153. <select id="dw-leds-effect-select" class="form-select w-full rounded-lg border border-slate-300 bg-white px-4 py-3 text-slate-900 focus:outline-0 focus:ring-2 focus:ring-blue-500">
  154. <option value="">Loading effects...</option>
  155. </select>
  156. </div>
  157. <div class="flex flex-col gap-3">
  158. <h3 class="text-slate-800 text-base font-semibold">Palette</h3>
  159. <select id="dw-leds-palette-select" class="form-select w-full rounded-lg border border-slate-300 bg-white px-4 py-3 text-slate-900 focus:outline-0 focus:ring-2 focus:ring-blue-500">
  160. <option value="">Loading palettes...</option>
  161. </select>
  162. </div>
  163. </div>
  164. <!-- Speed and Intensity -->
  165. <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
  166. <!-- Speed Control -->
  167. <div class="flex flex-col gap-3">
  168. <div class="flex items-center justify-between">
  169. <h3 class="text-slate-800 text-base font-semibold">Speed</h3>
  170. <span id="dw-leds-speed-value" class="text-sm font-medium text-slate-600">128</span>
  171. </div>
  172. <input type="range" id="dw-leds-speed" min="0" max="255" value="128" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
  173. </div>
  174. <!-- Intensity Control -->
  175. <div class="flex flex-col gap-3">
  176. <div class="flex items-center justify-between">
  177. <h3 class="text-slate-800 text-base font-semibold">Intensity</h3>
  178. <span id="dw-leds-intensity-value" class="text-sm font-medium text-slate-600">128</span>
  179. </div>
  180. <input type="range" id="dw-leds-intensity" min="0" max="255" value="128" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
  181. </div>
  182. </div>
  183. <!-- Effect Color Slots -->
  184. <div class="flex items-center gap-4">
  185. <h3 class="text-slate-800 text-base font-semibold">Effect Colors:</h3>
  186. <div class="flex items-center gap-2">
  187. <label class="text-xs font-medium text-slate-600">Slot 1</label>
  188. <input type="color" id="dw-leds-color1" value="#ff0000" class="w-14 h-14 rounded-lg border-2 border-slate-300 cursor-pointer effect-color-picker">
  189. </div>
  190. <div class="flex items-center gap-2">
  191. <label class="text-xs font-medium text-slate-600">Slot 2</label>
  192. <input type="color" id="dw-leds-color2" value="#000000" class="w-14 h-14 rounded-lg border-2 border-slate-300 cursor-pointer effect-color-picker">
  193. </div>
  194. <div class="flex items-center gap-2">
  195. <label class="text-xs font-medium text-slate-600">Slot 3</label>
  196. <input type="color" id="dw-leds-color3" value="#0000ff" class="w-14 h-14 rounded-lg border-2 border-slate-300 cursor-pointer effect-color-picker">
  197. </div>
  198. </div>
  199. <!-- Effect Settings -->
  200. <div class="flex flex-col gap-6 pt-4 border-t border-slate-200">
  201. <div>
  202. <h3 class="text-slate-800 text-base font-semibold">Automation Settings</h3>
  203. <p class="text-xs text-slate-500 mt-1">Configure LED effects to automatically activate when idle or playing patterns</p>
  204. </div>
  205. <!-- Playing Effect Configuration -->
  206. <div class="bg-slate-50 rounded-lg p-4 border border-slate-200">
  207. <div class="flex items-center justify-between mb-3">
  208. <h4 class="text-slate-700 text-sm font-semibold flex items-center gap-2">
  209. <span class="material-icons text-green-600 text-lg">play_circle</span>
  210. Playing Effect
  211. </h4>
  212. <div class="flex gap-2">
  213. <button id="dw-leds-save-current-playing" class="flex items-center gap-1.5 rounded-lg bg-green-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm hover:bg-green-700 transition-colors focus:outline-none focus:ring-2 focus:ring-green-400">
  214. <span class="material-icons text-sm">save</span>
  215. Save Current
  216. </button>
  217. <button id="dw-leds-clear-playing" class="flex items-center gap-1.5 rounded-lg bg-gray-500 px-3 py-1.5 text-xs font-semibold text-white shadow-sm hover:bg-gray-600 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-400">
  218. <span class="material-icons text-sm">clear</span>
  219. Clear
  220. </button>
  221. </div>
  222. </div>
  223. <div id="playing-current-settings" class="text-xs text-slate-600 p-2 bg-white rounded border border-slate-200">
  224. <span class="font-medium">Current:</span> <span id="playing-settings-display">Not configured</span>
  225. </div>
  226. </div>
  227. <!-- Idle Configuration (Effect + Timeout) -->
  228. <div class="bg-slate-50 rounded-lg p-4 border border-slate-200">
  229. <div class="flex items-center justify-between mb-4">
  230. <h4 class="text-slate-700 text-sm font-semibold flex items-center gap-2">
  231. <span class="material-icons text-blue-600 text-lg">bedtime</span>
  232. Idle Configuration
  233. </h4>
  234. </div>
  235. <!-- Idle Effect -->
  236. <div class="mb-4 pb-4 border-b border-slate-200">
  237. <div class="flex items-center justify-between mb-3">
  238. <label class="text-xs font-medium text-slate-600">Idle Effect</label>
  239. <div class="flex gap-2">
  240. <button id="dw-leds-save-current-idle" class="flex items-center gap-1.5 rounded-lg bg-green-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm hover:bg-green-700 transition-colors focus:outline-none focus:ring-2 focus:ring-green-400">
  241. <span class="material-icons text-sm">save</span>
  242. Save Current
  243. </button>
  244. <button id="dw-leds-clear-idle" class="flex items-center gap-1.5 rounded-lg bg-gray-500 px-3 py-1.5 text-xs font-semibold text-white shadow-sm hover:bg-gray-600 transition-colors focus:outline-none focus:ring-2 focus:ring-gray-400">
  245. <span class="material-icons text-sm">clear</span>
  246. Clear
  247. </button>
  248. </div>
  249. </div>
  250. <div id="idle-current-settings" class="text-xs text-slate-600 p-2 bg-white rounded border border-slate-200">
  251. <span class="font-medium">Current:</span> <span id="idle-settings-display">Not configured</span>
  252. </div>
  253. </div>
  254. <!-- Idle Timeout -->
  255. <div>
  256. <div class="flex items-center justify-between mb-3">
  257. <label class="text-xs font-medium text-slate-600 flex items-center gap-2">
  258. <span class="material-icons text-blue-600 text-base">schedule</span>
  259. Auto Turn Off
  260. </label>
  261. <label class="relative inline-flex items-center cursor-pointer" title="Enable automatic LED turn off after idle period">
  262. <input type="checkbox" id="dw-leds-idle-timeout-enabled" class="sr-only peer">
  263. <div class="w-11 h-6 bg-slate-300 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-slate-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
  264. </label>
  265. </div>
  266. <!-- Help text when disabled -->
  267. <div id="idle-timeout-disabled-help" class="hidden mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg">
  268. <div class="flex items-start gap-2">
  269. <span class="material-icons text-blue-600 text-sm">info</span>
  270. <p class="text-xs text-blue-700">
  271. <span class="font-semibold">Enable the toggle above</span> to automatically turn off LEDs after a period of inactivity.
  272. </p>
  273. </div>
  274. </div>
  275. <div id="idle-timeout-settings" class="space-y-3 transition-opacity duration-200">
  276. <div>
  277. <label class="block text-xs text-slate-500 mb-2">Turn off LEDs after</label>
  278. <div class="flex items-center gap-3">
  279. <input type="number" id="dw-leds-idle-timeout-minutes" min="1" max="1440" value="30"
  280. class="flex-1 rounded-lg border-slate-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 text-sm">
  281. <span class="text-sm text-slate-600 whitespace-nowrap">minutes idle</span>
  282. </div>
  283. </div>
  284. <div id="idle-timeout-remaining" class="text-xs text-slate-600 p-2 bg-white rounded border border-slate-200 hidden">
  285. <span class="font-medium">Time remaining:</span> <span id="idle-timeout-remaining-display">--</span>
  286. </div>
  287. <button id="dw-leds-save-idle-timeout" class="w-full flex items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700 transition-colors focus:outline-none focus:ring-2 focus:ring-blue-400">
  288. <span class="material-icons text-base">save</span>
  289. Save Timeout Settings
  290. </button>
  291. </div>
  292. </div>
  293. </div>
  294. <div class="bg-blue-50 border border-blue-200 rounded-lg p-3">
  295. <div class="flex items-start gap-2">
  296. <span class="material-icons text-blue-600 text-base">info</span>
  297. <div class="text-xs text-blue-700">
  298. <p class="font-medium text-blue-800">How to use:</p>
  299. <ul class="mt-1 space-y-1 list-disc list-inside">
  300. <li>Adjust LED settings above (effect, palette, speed, intensity, colors)</li>
  301. <li>Click "Save Current" to capture current settings for automation</li>
  302. <li>Click "Clear" to turn off automation for that state</li>
  303. <li>Settings are applied automatically when table changes state</li>
  304. </ul>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. </div>
  310. </section>
  311. </div>
  312. <script src="/static/js/led-control.js"></script>
  313. {% endblock %}