This project aims to develop a part of a smart home web interface with the following features:
- ✅ Connect to Database: Retrieve all user's devices.
- ✅ WebSocket Connection: Establish a WebSocket connection to a specific path and wait for messages.
- ✅ Device List Display: Show a list of user's devices with basic information (name, type, range).
- ✅ Interactive Dialog: Implement a draggable and resizable dialog box that opens when a device is clicked. The dialog retains its position after being closed.
- ✅ Dynamic Updates: Dynamically update the list with values from the WebSocket (and potentially the dialog).
Upon connecting to the site, the application downloads the devices and stores them in a global store. When a message is received from the WebSocket, Redux is used to:
- Update the existing device information.
- Add new devices to the array if they are not already present.
The dialog component, located higher in the component hierarchy, observes a special flag in the global store. This flag can be set to a specific device object or false
. If the flag is set to a device:
- The dialog opens and displays the device's properties.
- To maintain its position after closing, the dialog's visibility is toggled without re-rendering.
Make sure you have the following installed on your machine:
- Navigate to the
_server
directory:cd _server
- Install the server dependencies:
npm install
- Start the server:
npm run start
The server will run on localhost:1337
.
- Navigate to the
client
directory:cd ../client
- Install the client dependencies:
npm install
- Start the client:
npm run start
The client will run on localhost:3000
, and a browser should automatically open this address.
Once both the server and client are running:
- Access the Interface: Open your web browser and go to
http://localhost:3000
. - View Devices: The application will automatically fetch and display a list of your devices.
- Interact with Devices: Click on any device to open the interactive dialog. You can drag and resize this dialog. Its position and size will be retained even after you close and reopen it.
- Real-Time Updates: Any updates received via the WebSocket connection will dynamically update the device list and dialog.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is licensed under the MIT License.