add a basic Javascript UI

The Javascript is pretty amateurish I'm sure but at least it's something to
iterate from. It's already much more pleasant for browsing through videos in
several ways:

* more responsive to load only a day at a time rather than 90+ days
* much easier to see the same time segment on several cameras
* more pleasant to have the videos load as a popup rather than a link
  that blows away your position in an enormous list
* exposes the fancier .mp4 generation options: splitting at lengths
  other than the default, trimming to an arbitrary start and end time,
  including a subtitle track with timestamps.

There's a slight regression in functionality: I didn't match the former
top-level page which showed how much camera used of its disk allocation and
the total duration of video. This is exposed in the JSON API, so it shouldn't
be too hard to add back.
This commit is contained in:
Scott Lamb
2017-10-21 21:54:27 -07:00
parent 6eda26a9cc
commit 315f3594c2
19 changed files with 4411 additions and 354 deletions

View File

@@ -53,6 +53,8 @@ Options:
--sample-file-dir=DIR Set the directory holding video data.
This is typically on a hard drive.
[default: /var/lib/moonfire-nvr/sample]
--ui-dir=DIR Set the directory with the user interface files (.html, .js, etc).
[default: /usr/local/lib/moonfire-nvr/ui]
--http-addr=ADDR Set the bind address for the unencrypted HTTP server.
[default: 0.0.0.0:8080]
--read-only Forces read-only mode / disables recording.
@@ -63,6 +65,7 @@ struct Args {
flag_db_dir: String,
flag_sample_file_dir: String,
flag_http_addr: String,
flag_ui_dir: String,
flag_read_only: bool,
}
@@ -83,6 +86,8 @@ pub fn run() -> Result<(), Error> {
let dir = dir::SampleFileDir::new(&args.flag_sample_file_dir, db.clone()).unwrap();
info!("Database is loaded.");
let s = web::Service::new(db.clone(), dir.clone(), Some(&args.flag_ui_dir))?;
// Start a streamer for each camera.
let shutdown_streamers = Arc::new(AtomicBool::new(false));
let mut streamers = Vec::new();
@@ -113,7 +118,7 @@ pub fn run() -> Result<(), Error> {
// Start the web interface.
let addr = args.flag_http_addr.parse().unwrap();
let server = ::hyper::server::Http::new()
.bind(&addr, move || Ok(web::Service::new(db.clone(), dir.clone())))
.bind(&addr, move || Ok(s.clone()))
.unwrap();
let shutdown = setup_shutdown_future(&server.handle());