scottlamb / moonfire-nvr

Moonfire NVR, a security camera network video recorder
Other
1.22k stars 137 forks source link

React-based UI rewrite #111

Closed scottlamb closed 3 years ago

scottlamb commented 3 years ago

The web UI has plenty of deficiencies: poor error handling, no scrub bar (#32), no live view (#59), no support for the "signals" schema (#28) or any kind of analytics, no configuration (#35), not very pretty, etc.

I don't think the current jQuery-based implementation is a good foundation to fix these problems. The cool kids haven't been writing jQuery in many years. I've tried out React and see why it's taken over—its well-defined component lifecycle and declarative style make it easier to build reliable UIs. There's even a fairly good story for testing.

My goals for a new UI are:

so I'm trying a new UI based on React, material-ui, TypeScript, and testing-libraries.com. (The tests run on Node now. I'll likely need tests on a real browser to test HTML5 Media Source Extensions functionality and such but I'll save that for later.) It uses create-react-app and tries to follow its recommendations.

I've already been playing with it for a couple weeks and will start committing to a new-ui branch shortly. The first commit won't do much (just the project structure and ability to log in and out, but no ability to view video). I think I'll add in a list-based UI to match the current UI's functionality next, as it'll be quicker than building a scrub bar thing. Once I match what the current UI does, I'll merge it to master.

jor3l commented 3 years ago

Do you need help with the UI? Lmk

scottlamb commented 3 years ago

@jor3l Short answer: yes, I'd love help with the UI!

Longer answer later; I'm taking care of my sick daughter + online kindergarten son right now.

scottlamb commented 3 years ago

@jor3l Sorry for the delay before my longer answer. My daughter's feeling better!

What did you have in mind for help? I'd gratefully accept about any type of help—from constructive criticism and ideas to PRs fixing small problems to even PRs for the bulk of the UI. The biggest constraint is that it has to be something that I (and ideally other people) can continue building on. That's what I'm aiming for with the choice of popular Javascript building blocks. (I'm open to exploring alternatives to some of those things, but the alternatives also have to be popular / well-documented things likely to stick around for a while.) Also, it's helpful to coordinate anything big with me ahead of time so we don't waste effort.

Are you able to run the new-ui branch's development server now? It works for me on my laptop, and (as of fbaf751 yesterday) on my workstation. There are some tests which (as of 2677184 yesterday) are also passing for me and on CI. Hopefully that all works for you too; please let me know if not. The UI still doesn't do very much; it just lets you log in and out.

I have the temporary list-based UI in progress in my client. I'll try to get something committed today to build from. It's likely to be not very pretty and somewhat broken but I figure that's better for collaboration than waiting to share until I've reached perfection (if I ever do).

jor3l commented 3 years ago

Hey! Glad to hear that she is better now!

So I'm setting up a smart home and got some IP cameras, I need-want a dashboard that also has object recognition and alerts. That said I'll give a try to your project and see how it works with my cameras, I think that having this with an API based approach is awesome, anyone can build a client for it. I'll check what you have for the UI and either improve it or get a standalone ui working with your server. Let me check this project out first and do some tests and I'll let you know how I'll help.

scottlamb commented 3 years ago

My list UI draft is on the new-ui branch. It's missing some things the original UI has, like trimming the recordings so they don't extend beyond the selected time range. But in quick (manual) testing, it seems to basically work.

scottlamb commented 3 years ago

I think it's about ready to replace the old UI. It actually has decent error handling, even some automated tests. I think it looks more polished. It should be much easier to extend; I'm looking forward to adding new functionality. And it feels pretty good in my manual testing.

A few quirks:

image

image

scottlamb commented 3 years ago

Oh, the date picker is missing some CSS to make it smaller on desktop. Looks like it broke with d273a99. I'll have to fix that. Fixed.

And the video sometimes flickers somehow on mobile—the element gets briefly larger then smaller again. Not sure why. Looks like this is unrelated to the new UI. It's an Android/Chrome bug that happens when I'm playing an <video controls src="..."> element with the controls visible (eg shortly after touching it) and I'm debugging that Chrome tab (with a USB cable + desktop computer via chrome://inspect). It sometimes shows the thing under the video, whether that's other parts of the webpage or (when in fullscreen mode) a completely different Android app. This happens even with a really basic HTML page.

scottlamb commented 3 years ago

Bit more dense. I just reverted d273a99, so I don't have the secondary color I want on the date picker. 😩

localhost_63606_ (2)

scottlamb commented 3 years ago

I think it's ready to switch over, except that I'd like to improve the time range problems mentioned above. I'm a little stuck on doing so properly; I asked on stackoverflow but got crickets. Help welcome...

scottlamb commented 3 years ago

I'm just going to accept imperfection for the moment on the timezone stuff. It's an improvement overall, including the new live view UI. Now merged to master and released as v0.6.3.