led.html 16 KB

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