|  | 
| 1 | 1 | import SidebarHeader from "@components/SidebarHeader"; | 
| 2 | 2 | import { | 
|  | 3 | +  BacklightSettings, | 
| 3 | 4 |   useLocalAuthModalStore, | 
| 4 | 5 |   useSettingsStore, | 
| 5 | 6 |   useUiStore, | 
| @@ -95,6 +96,7 @@ export default function SettingsSidebar() { | 
| 95 | 96 |   const hideCursor = useSettingsStore(state => state.isCursorHidden); | 
| 96 | 97 |   const setHideCursor = useSettingsStore(state => state.setCursorVisibility); | 
| 97 | 98 |   const setDeveloperMode = useSettingsStore(state => state.setDeveloperMode); | 
|  | 99 | +  const setBacklightSettings = useSettingsStore(state => state.setBacklightSettings); | 
| 98 | 100 | 
 | 
| 99 | 101 |   const [currentVersions, setCurrentVersions] = useState<{ | 
| 100 | 102 |     appVersion: string; | 
| @@ -228,6 +230,18 @@ export default function SettingsSidebar() { | 
| 228 | 230 |     [send, setDeveloperMode], | 
| 229 | 231 |   ); | 
| 230 | 232 | 
 | 
|  | 233 | +  const handleBacklightSettingChange = useCallback((settings: BacklightSettings) => { | 
|  | 234 | +    send("setBacklightSettings", { settings }, resp => { | 
|  | 235 | +      if ("error" in resp) { | 
|  | 236 | +        notifications.error( | 
|  | 237 | +          `Failed to set backlight settings: ${resp.error.data || "Unknown error"}`, | 
|  | 238 | +        ); | 
|  | 239 | +        return; | 
|  | 240 | +      } | 
|  | 241 | +      notifications.success("Backlight settings updated successfully"); | 
|  | 242 | +    }); | 
|  | 243 | +  }, [send]); | 
|  | 244 | + | 
| 231 | 245 |   const handleUpdateSSHKey = useCallback(() => { | 
| 232 | 246 |     send("setSSHKeyState", { sshKey }, resp => { | 
| 233 | 247 |       if ("error" in resp) { | 
| @@ -302,6 +316,17 @@ export default function SettingsSidebar() { | 
| 302 | 316 |       } | 
| 303 | 317 |     }); | 
| 304 | 318 | 
 | 
|  | 319 | +    send("getBacklightSettings", {}, resp => { | 
|  | 320 | +      if ("error" in resp) { | 
|  | 321 | +        notifications.error( | 
|  | 322 | +          `Failed to get backlight settings: ${resp.error.data || "Unknown error"}`, | 
|  | 323 | +        ); | 
|  | 324 | +        return; | 
|  | 325 | +      } | 
|  | 326 | +      const result = resp.result as BacklightSettings; | 
|  | 327 | +      setBacklightSettings(result); | 
|  | 328 | +    }) | 
|  | 329 | + | 
| 305 | 330 |     send("getDevModeState", {}, resp => { | 
| 306 | 331 |       if ("error" in resp) return; | 
| 307 | 332 |       const result = resp.result as { enabled: boolean }; | 
| @@ -797,6 +822,34 @@ export default function SettingsSidebar() { | 
| 797 | 822 |           /> | 
| 798 | 823 |         </SettingsItem> | 
| 799 | 824 |         <div className="h-[1px] w-full bg-slate-800/10 dark:bg-slate-300/20" /> | 
|  | 825 | +        <div className="pb-2 space-y-4"> | 
|  | 826 | +          <SectionHeader | 
|  | 827 | +            title="Hardware" | 
|  | 828 | +            description="Configure the JetKVM Hardware" | 
|  | 829 | +          /> | 
|  | 830 | +        </div> | 
|  | 831 | +        <SettingsItem title="Display Brightness" description="Set the brightness of the display"> | 
|  | 832 | +          {/* TODO: Allow the user to pick any value between 0 and 100 */} | 
|  | 833 | +          <SelectMenuBasic | 
|  | 834 | +            size="SM" | 
|  | 835 | +            label="" | 
|  | 836 | +            value={settings.backlightSettings.max_brightness.toString()} | 
|  | 837 | +            options={[ | 
|  | 838 | +              { value: "0", label: "Off" }, | 
|  | 839 | +              { value: "10", label: "Low" }, | 
|  | 840 | +              { value: "50", label: "Medium" }, | 
|  | 841 | +              { value: "100", label: "High" }, | 
|  | 842 | +            ]} | 
|  | 843 | +            onChange={e => { | 
|  | 844 | +              handleBacklightSettingChange({  | 
|  | 845 | +                max_brightness: parseInt(e.target.value), | 
|  | 846 | +                dim_after: settings.backlightSettings.dim_after, | 
|  | 847 | +                off_after: settings.backlightSettings.off_after, | 
|  | 848 | +              }); | 
|  | 849 | +            }} | 
|  | 850 | +          /> | 
|  | 851 | +        </SettingsItem> | 
|  | 852 | +        <div className="h-[1px] w-full bg-slate-800/10 dark:bg-slate-300/20" /> | 
| 800 | 853 |         <div className="pb-2 space-y-4"> | 
| 801 | 854 |           <SectionHeader | 
| 802 | 855 |             title="Advanced" | 
|  | 
0 commit comments