1
0

wled.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. {% extends "base.html" %} {% block title %}WLED - Kinetic Sand Table{% endblock %}
  2. {% block additional_styles %}
  3. /* Dark mode styles for WLED page */
  4. .dark .bg-white {
  5. background-color: #262626;
  6. }
  7. .dark .border-slate-200 {
  8. border-color: #404040;
  9. }
  10. .dark .text-gray-500 {
  11. color: #9ca3af;
  12. }
  13. .dark .text-gray-700 {
  14. color: #d1d5db;
  15. }
  16. {% endblock %}
  17. {% block content %}
  18. <div class="layout-content-container flex flex-col w-full max-w-4xl gap-0 pt-2 pb-[75px]">
  19. <section class="bg-white rounded-xl shadow-sm overflow-hidden pt-4 sm:pt-0 h-full">
  20. <div class="flex flex-col items-center px-0 py-0 h-full">
  21. <div class="w-full h-full max-w-5xl flex flex-col overflow-hidden">
  22. <div id="wled-status" class="w-full p-8 text-center">
  23. <div class="flex flex-col items-center gap-4">
  24. <span class="material-icons text-6xl text-gray-500">lightbulb</span>
  25. <h2 class="text-2xl font-semibold text-gray-700">WLED Not Configured</h2>
  26. <p class="text-gray-500 max-w-md">Please set up your WLED IP address in the Settings page to control your LED lights.</p>
  27. <a href="/settings" class="mt-4 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
  28. Go to Settings
  29. </a>
  30. </div>
  31. </div>
  32. <iframe id="wled-frame"
  33. src=""
  34. class="h-full w-full rounded-lg border border-slate-200 hidden"
  35. frameborder="0"
  36. allowfullscreen
  37. ></iframe>
  38. </div>
  39. </div>
  40. </section>
  41. </div>
  42. <script>
  43. async function loadWledIframe() {
  44. let wledIp = localStorage.getItem('wled_ip');
  45. const status = document.getElementById('wled-status');
  46. const frame = document.getElementById('wled-frame');
  47. if (!wledIp) {
  48. // Try to fetch from server if not in localStorage
  49. try {
  50. const resp = await fetch('/get_wled_ip');
  51. if (resp.ok) {
  52. const data = await resp.json();
  53. wledIp = data.wled_ip;
  54. localStorage.setItem('wled_ip', wledIp);
  55. }
  56. } catch (e) {}
  57. }
  58. if (wledIp && frame) {
  59. frame.src = `http://${wledIp}`;
  60. frame.classList.remove('hidden');
  61. status.classList.add('hidden');
  62. } else {
  63. if (frame) {
  64. frame.src = '';
  65. frame.classList.add('hidden');
  66. }
  67. if (status) {
  68. status.classList.remove('hidden');
  69. }
  70. }
  71. }
  72. document.addEventListener('DOMContentLoaded', loadWledIframe);
  73. </script>
  74. {% endblock %}