led.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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 input[type="color"] {
  42. background-color: #262626;
  43. border-color: #404040;
  44. }
  45. .dark select,
  46. .dark .form-select {
  47. background-color: #1f1f1f;
  48. border-color: #404040;
  49. color: #e5e5e5;
  50. }
  51. .dark select option {
  52. background-color: #262626;
  53. color: #e5e5e5;
  54. }
  55. /* Quick color buttons - ensure they remain visible */
  56. .dark .quick-color {
  57. border-color: #525252;
  58. }
  59. /* Status messages - keep backgrounds but adjust borders */
  60. .dark .bg-green-50 {
  61. background-color: #14532d;
  62. }
  63. .dark .border-green-200 {
  64. border-color: #166534;
  65. }
  66. .dark .text-green-700 {
  67. color: #86efac;
  68. }
  69. .dark .bg-red-50 {
  70. background-color: #450a0a;
  71. }
  72. .dark .border-red-200 {
  73. border-color: #991b1b;
  74. }
  75. .dark .text-red-700 {
  76. color: #fca5a5;
  77. }
  78. .dark .bg-amber-50 {
  79. background-color: #451a03;
  80. }
  81. .dark .border-amber-200 {
  82. border-color: #92400e;
  83. }
  84. .dark .text-amber-700 {
  85. color: #fcd34d;
  86. }
  87. /* Iframe border */
  88. .dark iframe {
  89. border-color: #404040;
  90. }
  91. {% endblock %}
  92. {% block content %}
  93. <div class="layout-content-container flex flex-col w-full max-w-4xl gap-0 pt-2 pb-[75px]">
  94. <!-- Not Configured State -->
  95. <section id="led-not-configured" class="bg-white rounded-xl shadow-sm overflow-hidden pt-4 sm:pt-0 h-full hidden">
  96. <div class="flex flex-col items-center px-0 py-0 h-full">
  97. <div class="w-full h-full max-w-5xl flex flex-col overflow-hidden">
  98. <div class="w-full p-8 text-center">
  99. <div class="flex flex-col items-center gap-4">
  100. <span class="material-icons text-6xl text-gray-500">lightbulb</span>
  101. <h2 class="text-2xl font-semibold text-gray-700">LED Controller Not Configured</h2>
  102. <p class="text-gray-500 max-w-md">Please configure your LED controller (WLED or DW LEDs) in the Settings page.</p>
  103. <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">
  104. <span class="material-icons">settings</span>
  105. Go to Settings
  106. </a>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </section>
  112. <!-- WLED iframe -->
  113. <section id="wled-container" class="bg-white rounded-xl shadow-sm overflow-hidden pt-4 sm:pt-0 h-full hidden">
  114. <div class="flex flex-col items-center px-0 py-0 h-full">
  115. <div class="w-full h-full max-w-5xl flex flex-col overflow-hidden">
  116. <iframe id="wled-frame"
  117. src=""
  118. class="h-full w-full rounded-lg border border-slate-200"
  119. frameborder="0"
  120. allowfullscreen
  121. ></iframe>
  122. </div>
  123. </div>
  124. </section>
  125. <!-- DW LEDs Controls -->
  126. <section id="dw-leds-container" class="bg-white rounded-xl shadow-sm overflow-hidden hidden">
  127. <div class="px-6 py-5 space-y-6">
  128. <h2 class="text-slate-800 text-xl sm:text-2xl font-semibold leading-tight tracking-[-0.01em]">
  129. DW LEDs Control
  130. </h2>
  131. <!-- Connection Status -->
  132. <div id="dw-leds-status" class="p-4 rounded-lg bg-gray-100 border border-slate-200">
  133. <div class="flex items-center gap-2">
  134. <span class="material-icons text-gray-500">info</span>
  135. <span class="text-sm text-gray-700">Checking connection...</span>
  136. </div>
  137. </div>
  138. <!-- Power and Brightness Grid -->
  139. <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
  140. <!-- Power Control -->
  141. <div class="flex flex-col gap-3">
  142. <h3 class="text-slate-800 text-base font-semibold">Power</h3>
  143. <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">
  144. <span class="material-icons">power_settings_new</span>
  145. <span id="dw-leds-power-text">Turn ON</span>
  146. </button>
  147. </div>
  148. <!-- Brightness Control -->
  149. <div class="flex flex-col gap-3">
  150. <div class="flex items-center justify-between">
  151. <h3 class="text-slate-800 text-base font-semibold">Brightness</h3>
  152. <span id="dw-leds-brightness-value" class="text-sm font-medium text-slate-600">35%</span>
  153. </div>
  154. <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">
  155. </div>
  156. </div>
  157. <!-- Color Control -->
  158. <div class="flex flex-col gap-3">
  159. <h3 class="text-slate-800 text-base font-semibold">Color Picker</h3>
  160. <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
  161. <div class="flex items-center gap-3">
  162. <input type="color" id="dw-leds-color" value="#ff0000" class="w-20 h-20 rounded-lg border-2 border-slate-300 cursor-pointer">
  163. <div class="flex flex-col gap-1">
  164. <span id="dw-leds-color-hex" class="text-sm font-mono font-semibold text-slate-700">#FF0000</span>
  165. <button id="dw-leds-set-color" class="flex items-center justify-center gap-2 rounded-lg bg-blue-600 px-3 py-2 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">
  166. <span class="material-icons text-base">palette</span>
  167. <span>Apply</span>
  168. </button>
  169. </div>
  170. </div>
  171. <!-- Quick Colors -->
  172. <div class="flex flex-col gap-2">
  173. <span class="text-sm font-medium text-slate-600">Quick Colors</span>
  174. <div class="grid grid-cols-4 gap-2">
  175. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#ff0000" style="background-color: #ff0000;" title="Red"></button>
  176. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#00ff00" style="background-color: #00ff00;" title="Green"></button>
  177. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#0000ff" style="background-color: #0000ff;" title="Blue"></button>
  178. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#ffff00" style="background-color: #ffff00;" title="Yellow"></button>
  179. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#ff00ff" style="background-color: #ff00ff;" title="Magenta"></button>
  180. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#00ffff" style="background-color: #00ffff;" title="Cyan"></button>
  181. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#ff8000" style="background-color: #ff8000;" title="Orange"></button>
  182. <button class="dw-leds-quick-color h-10 rounded-lg border-2 border-slate-300 hover:scale-105 transition-transform" data-color="#ffffff" style="background-color: #ffffff;" title="White"></button>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. <!-- Effects and Palettes -->
  188. <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
  189. <div class="flex flex-col gap-3">
  190. <h3 class="text-slate-800 text-base font-semibold">Effect</h3>
  191. <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">
  192. <option value="">Loading effects...</option>
  193. </select>
  194. </div>
  195. <div class="flex flex-col gap-3">
  196. <h3 class="text-slate-800 text-base font-semibold">Palette</h3>
  197. <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">
  198. <option value="">Loading palettes...</option>
  199. </select>
  200. </div>
  201. </div>
  202. <!-- Speed and Intensity -->
  203. <div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
  204. <!-- Speed Control -->
  205. <div class="flex flex-col gap-3">
  206. <div class="flex items-center justify-between">
  207. <h3 class="text-slate-800 text-base font-semibold">Speed</h3>
  208. <span id="dw-leds-speed-value" class="text-sm font-medium text-slate-600">128</span>
  209. </div>
  210. <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">
  211. </div>
  212. <!-- Intensity Control -->
  213. <div class="flex flex-col gap-3">
  214. <div class="flex items-center justify-between">
  215. <h3 class="text-slate-800 text-base font-semibold">Intensity</h3>
  216. <span id="dw-leds-intensity-value" class="text-sm font-medium text-slate-600">128</span>
  217. </div>
  218. <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">
  219. </div>
  220. </div>
  221. <!-- Effect Color Slots -->
  222. <div class="flex items-center gap-4">
  223. <h3 class="text-slate-800 text-base font-semibold">Effect Colors:</h3>
  224. <div class="flex items-center gap-2">
  225. <label class="text-xs font-medium text-slate-600">Slot 1</label>
  226. <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">
  227. </div>
  228. <div class="flex items-center gap-2">
  229. <label class="text-xs font-medium text-slate-600">Slot 2</label>
  230. <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">
  231. </div>
  232. <div class="flex items-center gap-2">
  233. <label class="text-xs font-medium text-slate-600">Slot 3</label>
  234. <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">
  235. </div>
  236. </div>
  237. <!-- Effect Settings -->
  238. <div class="flex flex-col gap-6 pt-4 border-t border-slate-200">
  239. <div>
  240. <h3 class="text-slate-800 text-base font-semibold">Automation Settings</h3>
  241. <p class="text-xs text-slate-500 mt-1">Configure LED effects to automatically activate when idle or playing patterns</p>
  242. </div>
  243. <!-- Playing Effect Configuration -->
  244. <div class="bg-slate-50 rounded-lg p-4 border border-slate-200">
  245. <div class="flex items-center justify-between mb-3">
  246. <h4 class="text-slate-700 text-sm font-semibold flex items-center gap-2">
  247. <span class="material-icons text-green-600 text-lg">play_circle</span>
  248. Playing Effect
  249. </h4>
  250. <div class="flex gap-2">
  251. <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">
  252. <span class="material-icons text-sm">save</span>
  253. Save Current
  254. </button>
  255. <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">
  256. <span class="material-icons text-sm">clear</span>
  257. Clear
  258. </button>
  259. </div>
  260. </div>
  261. <div id="playing-current-settings" class="text-xs text-slate-600 p-2 bg-white rounded border border-slate-200">
  262. <span class="font-medium">Current:</span> <span id="playing-settings-display">Not configured</span>
  263. </div>
  264. </div>
  265. <!-- Idle Configuration (Effect + Timeout) -->
  266. <div class="bg-slate-50 rounded-lg p-4 border border-slate-200">
  267. <div class="flex items-center justify-between mb-4">
  268. <h4 class="text-slate-700 text-sm font-semibold flex items-center gap-2">
  269. <span class="material-icons text-blue-600 text-lg">bedtime</span>
  270. Idle Configuration
  271. </h4>
  272. </div>
  273. <!-- Idle Effect -->
  274. <div class="mb-4 pb-4 border-b border-slate-200">
  275. <div class="flex items-center justify-between mb-3">
  276. <label class="text-xs font-medium text-slate-600">Idle Effect</label>
  277. <div class="flex gap-2">
  278. <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">
  279. <span class="material-icons text-sm">save</span>
  280. Save Current
  281. </button>
  282. <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">
  283. <span class="material-icons text-sm">clear</span>
  284. Clear
  285. </button>
  286. </div>
  287. </div>
  288. <div id="idle-current-settings" class="text-xs text-slate-600 p-2 bg-white rounded border border-slate-200">
  289. <span class="font-medium">Current:</span> <span id="idle-settings-display">Not configured</span>
  290. </div>
  291. </div>
  292. <!-- Idle Timeout -->
  293. <div>
  294. <div class="flex items-center justify-between mb-3">
  295. <label class="text-xs font-medium text-slate-600 flex items-center gap-2">
  296. <span class="material-icons text-blue-600 text-base">schedule</span>
  297. Auto Turn Off
  298. </label>
  299. <label class="relative inline-flex items-center cursor-pointer">
  300. <input type="checkbox" id="dw-leds-idle-timeout-enabled" class="sr-only peer">
  301. <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>
  302. </label>
  303. </div>
  304. <div id="idle-timeout-settings" class="space-y-3">
  305. <div>
  306. <label class="block text-xs text-slate-500 mb-2">Turn off LEDs after</label>
  307. <div class="flex items-center gap-3">
  308. <input type="number" id="dw-leds-idle-timeout-minutes" min="1" max="1440" value="30"
  309. class="flex-1 rounded-lg border-slate-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 text-sm">
  310. <span class="text-sm text-slate-600 whitespace-nowrap">minutes idle</span>
  311. </div>
  312. </div>
  313. <div id="idle-timeout-remaining" class="text-xs text-slate-600 p-2 bg-white rounded border border-slate-200 hidden">
  314. <span class="font-medium">Time remaining:</span> <span id="idle-timeout-remaining-display">--</span>
  315. </div>
  316. <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">
  317. <span class="material-icons text-base">save</span>
  318. Save Timeout Settings
  319. </button>
  320. </div>
  321. </div>
  322. </div>
  323. <div class="bg-blue-50 border border-blue-200 rounded-lg p-3">
  324. <div class="flex items-start gap-2">
  325. <span class="material-icons text-blue-600 text-base">info</span>
  326. <div class="text-xs text-blue-700">
  327. <p class="font-medium text-blue-800">How to use:</p>
  328. <ul class="mt-1 space-y-1 list-disc list-inside">
  329. <li>Adjust LED settings above (effect, palette, speed, intensity, colors)</li>
  330. <li>Click "Save Current" to capture current settings for automation</li>
  331. <li>Click "Clear" to turn off automation for that state</li>
  332. <li>Settings are applied automatically when table changes state</li>
  333. </ul>
  334. </div>
  335. </div>
  336. </div>
  337. </div>
  338. </div>
  339. </section>
  340. </div>
  341. <script src="/static/js/led-control.js"></script>
  342. {% endblock %}