add notifications for device updates #18

This commit is contained in:
Maxi Quoß
2022-05-24 23:17:47 +02:00
parent e02ecbc639
commit d08b8b3722
2 changed files with 17 additions and 1 deletions

View File

@@ -84,7 +84,17 @@ class WSConsumer(AsyncWebsocketConsumer):
}
)
elif received["type"] == "update_device":
await self.update_device(received["data"])
try:
await self.update_device(received["data"])
await self.send(text_data=json.dumps({
"type": "operationStatus",
"message": "Success"
}))
except Exception as e:
await self.send(text_data=json.dumps({
"type": "operationStatus",
"message": "Error"
}))
elif received["type"] == "update_port":
await self.update_port(received["data"])
elif received["type"] == "update_settings":

View File

@@ -70,6 +70,12 @@
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
} else if (currentMessage.type == "operationStatus") {
if (currentMessage.message == "Success") {
showToast(currentMessage.message, "Device was saved and will be visible on next ping", "success")
} else if (currentMessage.message == "Error") {
showToast(currentMessage.message, "Error while saving the device. Please check the logs.", "danger")
}
}
})
})