Merge branch 'master' into new-schema

This commit is contained in:
Scott Lamb 2020-05-08 16:33:49 -07:00
commit c7c0d5a6c1
5 changed files with 58 additions and 40 deletions

2
Cargo.lock generated
View File

@ -1340,7 +1340,7 @@ dependencies = [
[[package]] [[package]]
name = "mylog" name = "mylog"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/scottlamb/mylog#00d39a9ca0c1f399c453360de3f1e7f61db0d50d" source = "git+https://github.com/scottlamb/mylog#bebeacb74efc127f9c16e57e38886c8e6ba8a95c"
dependencies = [ dependencies = [
"chrono", "chrono",
"log", "log",

View File

@ -31,6 +31,7 @@
#![cfg_attr(all(feature="nightly", test), feature(test))] #![cfg_attr(all(feature="nightly", test), feature(test))]
use log::{error, info}; use log::{error, info};
use std::str::FromStr;
use structopt::StructOpt; use structopt::StructOpt;
#[cfg(feature = "analytics")] #[cfg(feature = "analytics")]
@ -124,20 +125,12 @@ impl Args {
} }
} }
fn parse_fmt<S: AsRef<str>>(fmt: S) -> Option<mylog::Format> {
match fmt.as_ref() {
"google" => Some(mylog::Format::Google),
"google-systemd" => Some(mylog::Format::GoogleSystemd),
_ => None,
}
}
fn main() { fn main() {
let args = Args::from_args(); let args = Args::from_args();
let mut h = mylog::Builder::new() let mut h = mylog::Builder::new()
.set_format(::std::env::var("MOONFIRE_FORMAT") .set_format(::std::env::var("MOONFIRE_FORMAT")
.ok() .map_err(|_| ())
.and_then(parse_fmt) .and_then(|s| mylog::Format::from_str(&s))
.unwrap_or(mylog::Format::Google)) .unwrap_or(mylog::Format::Google))
.set_spec(&::std::env::var("MOONFIRE_LOG").unwrap_or("info".to_owned())) .set_spec(&::std::env::var("MOONFIRE_LOG").unwrap_or("info".to_owned()))
.build(); .build();

View File

@ -227,7 +227,7 @@ function updateSession(session) {
return; return;
} }
sessionBar.append($('<span id="session-username" />').text(session.username)); sessionBar.append($('<span id="session-username" />').text(session.username));
const logout = $('<a>logout</a>'); const logout = $('<a id="logout">logout</a>');
logout.click(() => { logout.click(() => {
api api
.logout(session.csrf) .logout(session.csrf)
@ -384,6 +384,11 @@ export default class NVRApplication {
* Start the application. * Start the application.
*/ */
start() { start() {
let nav = $('#nav');
$('#toggle-nav').click(() => {
nav.toggle('slide');
});
loginDialog = $('#login').dialog({ loginDialog = $('#login').dialog({
autoOpen: false, autoOpen: false,
modal: true, modal: true,

View File

@ -1,12 +1,30 @@
@media only screen and (max-width: 720px) {
#nav {
float: none;
display: none;
}
}
body { body {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
} }
#top {
width: 100%;
padding-bottom: 2ex;
}
#toggle-nav {
font-size: 1.25em;
cursor: pointer;
}
#nav { #nav {
float: left; float: left;
} }
#session { #session {
float: right; float: right;
} }
#logout {
cursor: pointer;
}
#datetime .ui-datepicker { #datetime .ui-datepicker {
width: 100%; width: 100%;

View File

@ -5,7 +5,9 @@
<title>Moonfire NVR</title> <title>Moonfire NVR</title>
</head> </head>
<body> <body>
<div id="session"> <div id="top">
<a id="toggle-nav">&#x2630;</a>
<span id="session"></div>
</div> </div>
<div id="nav"> <div id="nav">
<form action="#"> <form action="#">