Skip to content

Commit

Permalink
Fix types dependency in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
amberstarlight committed Jun 8, 2024
1 parent a9e6238 commit cc44149
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 1,687 deletions.
1 change: 1 addition & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified .yarn/install-state.gz
Binary file not shown.
21 changes: 21 additions & 0 deletions packages/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# starlight/api

REST API for Starlight. Connects to `zigbee2mqtt` and `mosquitto` or other MQTT
endpoint.

## Environment Variables

### `PORT`

The port the API runs on. Defaults to 8080.


### `MQTT_ENDPOINT_HOSTNAME`

The endpoint for the MQTT server. Defaults to `localhost`, using `mqtt`
protocol.


### `MQTT_ENDPOINT_PORT`

The port the MQTT endpoint uses. Defaults to 1883.
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"private": true,
"devDependencies": {
"@starlight/types": "workspace:^",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.17",
"@types/node": "^20.10.5",
Expand All @@ -12,7 +13,6 @@
"typescript": "^5.0.2"
},
"dependencies": {
"@starlight/types": "workspace:^",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# types
# starlight/types

Types and interface exports for Starlight. Based on the Zigbee2MQTT project.
Binary file added packages/ui/.yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions packages/ui/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
9 changes: 9 additions & 0 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# starlight/ui

Vite + React UI for Starlight. Connects to Starlight API.

## Environment Variables

### `VITE_API_URL`

API URL (including port) to connect to.
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"wouter": "^3.1.2"
},
"devDependencies": {
"@starlight/types": "workspace:^",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Groups from "./pages/Groups/Groups";

import Button from "./components/Button/Button";
import DeviceSettings from "./components/DeviceSettings/DeviceSettings";
import { type Device, type Group } from "../../types/zigbee_types";
import { type Device, type Group } from "starlight/types";
import GroupSettings from "./components/GroupSettings/GroupSettings";

const Wrapper = styled.div`
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/src/components/DeviceCard/DeviceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import { deviceDescription } from "../../utils/deviceUtilities";
import styled from "styled-components";
import { StyledText, StyledHeader } from "../../utils/theme";

import { type Device } from "../../../../types/zigbee_types";
import { type Device } from "@starlight/types";

const emojiLookup = {
light: "💡",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/DeviceList/DeviceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { Link } from "wouter";
import DeviceCard from "../DeviceCard/DeviceCard";
import { type Device } from "../../../../types/zigbee_types";
import { type Device } from "@starlight/types";

function DeviceList(props: { devices: Device[]; onClick: Function }) {
return (
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/src/components/GroupCard/GroupCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import styled from "styled-components";
import { StyledText, StyledHeader } from "../../utils/theme";

import { type Group } from "../../../../types/zigbee_types";
import { type Group } from "@starlight/types";

const Card = styled.div`
margin: 2em 0em;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/GroupList/GroupList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { Link } from "wouter";
import GroupCard from "../GroupCard/GroupCard";
import { type Group } from "../../../../types/zigbee_types";
import { type Group } from "@starlight/types";

function GroupList(props: { groups: Group[]; onClick?: Function }) {
return (
Expand Down
15 changes: 12 additions & 3 deletions packages/ui/src/components/GroupSettings/GroupSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useState, useEffect } from "react";

import LoadingSpinner from "../LoadingSpinner/LoadingSpinner";
import EditableText from "../EditableText/EditableText";
import { deviceSettingsGenerator } from "../DeviceSettings/generator";

const backend = import.meta.env.VITE_API_URL ?? "";

Expand All @@ -17,7 +18,10 @@ function GroupSettings(props) {
useEffect(() => {
fetch(`${backend}/api/groups/${props.group.id}/state`)
.then((res) => res.json())
.then((data) => setGroupSettingsState(data.data));
.then((data) => {
setGroupSettingsState(data.data);
console.log(data.data);
});
}, []);

if (!groupSettingsState) return <LoadingSpinner />;
Expand All @@ -40,8 +44,13 @@ function GroupSettings(props) {
// }}
/>
</div>

<div>"todo"</div>
<div>
{deviceSettingsGenerator(
props.group,
groupSettingsState,
setGroupSettingsState,
)}
</div>
</>
);
}
Expand Down
Loading

0 comments on commit cc44149

Please sign in to comment.