Skip to content

Commit

Permalink
Sync lamp info
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryBrain committed Aug 18, 2024
1 parent 10f1194 commit b3971f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client/src/views/LampPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,22 @@ onMounted(() => {
axiosInstance.get("/lamp/brightness")
.then(res => JSON.parse(res.data))
.then(data => brightness.value = data.brightness);
refreshAnimationAndCharacteristics();
});
function refreshAnimationAndCharacteristics() {
axiosInstance.get(`/lamp/animation`)
.then(res => {
return JSON.parse(res.data);
})
.then(data => {
console.log(data);
currentConfig.selectedAnimation = data.animation.name;
onNewAnimation();
})
}
function onSmartColorUpdate(smartColor: SmartColor, i: number) {
characteristics.array[i].value = smartColor;
onChange();
Expand Down
4 changes: 4 additions & 0 deletions server/lamp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export function initLamp() {
res.send("OK");
});

lamp.get("/animation", (req, res) => {
res.send({ animation: animationStore[currentAnimation] });
});

lamp.post("/animation", (req, res) => {
const animation: string = req.body.animation;

Expand Down

0 comments on commit b3971f1

Please sign in to comment.