1
0

led.html 16 KB

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