dwyl / smart-home-security-system

Smart Home Security System
GNU General Public License v2.0
4 stars 2 forks source link

Hub GUI #9

Closed th0mas closed 4 years ago

th0mas commented 4 years ago

Currently there's not a "good" way of interfacing with the Hub Server - I'm currently using Insomnia, a REST api development tool.

We should probably build a GUI on top of or next to this API at some point.

Our options are:

nelsonic commented 4 years ago

@th0mas thanks for opening this issue to capture the requirement, discussion and decision of what to do next. 👍 We tend to avoid React wherever possible in favour of Elm which is a lot easier to maintain. We will eventually integrate this into our Flutter App but for now, our preference is a Phoenix SSR just in terms of simplicity and ease of maintenance. Having it as a SSR will mean we can easily load it in a WebView in Flutter without having to rewrite it in Dart. The initial page load on SSR pages is considerably faster. And as noted in https://github.com/dwyl/phoenix-todo-list-tutorial the UX is comparable to a SPA for subsequent pages/routes.

Perhaps the best question in terms of advancing with this is: What want to include in the GUI? Please see: #12

As for using Insomnia https://insomnia.rest | https://github.com/Kong/insomnia We used Mashape (now "Kong") back in the day, but have not used insomnia; it looks good. 👍 Are you paying for the "Plus" version? Or do you get what you need from the "free" App?

image

Where did you find out/learn about it?

th0mas commented 4 years ago

Been working on a LiveView/SSR GUI all morning and have some thoughts:

I'm sure some of these problems (my own experience) will be solved with time, but I'm mindful of not taking too much time on this. I'm happy to press ahead with SSR if needed.

The REST API is fully documented now, is it worth just working on a Flutter application?

th0mas commented 4 years ago

Currently using the Free Insomnia version, and pretty sure I heard about it on HN. Its useful for testing out REST APIs and developing them.

My workspace currently looks like this:

image

nelsonic commented 4 years ago

@th0mas yeah, I get the feeling that LiveView Apps are meant to be a lightweight alternative (in terms of code/boilerplate) to MVC. Many people appear to like them for their single file/page approach. But totally get it if you prefer to have a separation of concerns between the API and UI. 👍 We could have a simple lightweight Pub/Sub (Phoenix) socket to display desired content on the Welcome Display. This doesn't have to be more than 10 of lines of JS:

import socket from "./socket"
let channel = socket.channel('room:display', {});
channel.on('update', function (payload) {
    fetch(payload.url).then(function (response) {
      return response.text(); // get HTML content of response
    }).then(function (html) {
      document.body.innerHTML = html; // replace contents of page
    })    
});
channel.join(); // join the channel.

e.g. the client would receive a notification of an update over WebSocket Channel and then just do a full page refresh of the new content.

th0mas commented 4 years ago

On the Welcome display I was going to use Scenic, unless you would prefer a browser based version?

I'm currently building a basic Admin interface for the hub

nelsonic commented 4 years ago

@th0mas yep. that makes sense. the Admin interface does't need to be fancy at all. MVC is perfect. Scenic for the Welcome Display makes sense as previously discussed. Sorry for the confusion. 👍

th0mas commented 4 years ago

GUI Implemented for both Hub and edge nodes