diff options
Diffstat (limited to 'server/src/routes/ui/admin')
-rw-r--r-- | server/src/routes/ui/admin/log.rs | 4 | ||||
-rw-r--r-- | server/src/routes/ui/admin/mod.rs | 75 |
2 files changed, 37 insertions, 42 deletions
diff --git a/server/src/routes/ui/admin/log.rs b/server/src/routes/ui/admin/log.rs index 884ad7a..b123ada 100644 --- a/server/src/routes/ui/admin/log.rs +++ b/server/src/routes/ui/admin/log.rs @@ -136,9 +136,7 @@ impl log::Log for Log { fn vt100_to_html(s: &str) -> String { let mut out = HtmlOut::default(); let mut st = vte::Parser::new(); - for b in s.bytes() { - st.advance(&mut out, b); - } + st.advance(&mut out, s.as_bytes()); out.s } diff --git a/server/src/routes/ui/admin/mod.rs b/server/src/routes/ui/admin/mod.rs index 25f1f42..6e19373 100644 --- a/server/src/routes/ui/admin/mod.rs +++ b/server/src/routes/ui/admin/mod.rs @@ -26,12 +26,10 @@ use jellybase::{ database::{ redb::{ReadableTable, ReadableTableMetadata}, tantivy::query::Bm25StatisticsProvider, - TableExt, T_INVITE, T_NODE, T_NODE_EXTENDED, T_USER_NODE, + TableExt, T_INVITE, T_NODE, T_USER_NODE, }, - federation::Federation, CONF, }; -use jellyimport::{import, is_importing, IMPORT_ERRORS}; use markup::DynRender; use rand::Rng; use rocket::{form::Form, get, post, FromForm, State}; @@ -66,7 +64,7 @@ pub async fn admin_dashboard<'a>( }; let flash = flash.map(|f| f.map_err(|e| format!("{e:?}"))); - let last_import_err = IMPORT_ERRORS.read().await.to_owned(); + // let last_import_err = IMPORT_ERRORS.read().await.to_owned(); let database = database.to_owned(); Ok(LayoutPage { @@ -74,28 +72,28 @@ pub async fn admin_dashboard<'a>( content: markup::new! { h1 { "Admin Panel" } @FlashDisplay { flash: flash.clone() } - @if !last_import_err.is_empty() { - section.message.error { - p.error {"The last import resulted in at least one error:"} - ol { @for e in &last_import_err { - li.error { pre.error { @e } } - }} - } - } + // @if !last_import_err.is_empty() { + // section.message.error { + // p.error {"The last import resulted in at least one error:"} + // ol { @for e in &last_import_err { + // li.error { pre.error { @e } } + // }} + // } + // } ul { li{a[href=uri!(r_admin_log(true))] { "Server Log (Warnings only)" }} li{a[href=uri!(r_admin_log(false))] { "Server Log (Full) " }} } h2 { "Library" } - @if is_importing() { - section.message { p.warn { "An import is currently running." } } - } + // @if is_importing() { + // section.message { p.warn { "An import is currently running." } } + // } @if is_transcoding() { section.message { p.warn { "Currently transcoding posters." } } } - form[method="POST", action=uri!(r_admin_import())] { - input[type="submit", disabled=is_importing(), value="(Re-)Import Library"]; - } + // form[method="POST", action=uri!(r_admin_import())] { + // input[type="submit", disabled=is_importing(), value="(Re-)Import Library"]; + // } form[method="POST", action=uri!(r_admin_transcode_posters())] { input[type="submit", disabled=is_transcoding(), value="Transcode all posters with low resolution"]; } @@ -133,7 +131,7 @@ pub async fn r_admin_invite( _session: AdminSession, database: &State<DataAcid>, ) -> MyResult<DynLayoutPage<'static>> { - let i = format!("{}", rand::thread_rng().gen::<u128>()); + let i = format!("{}", rand::rng().random::<u128>()); T_INVITE.insert(database, &*i, ())?; admin_dashboard(database, Some(Ok(format!("Invite: {}", i)))).await @@ -158,24 +156,24 @@ pub async fn r_admin_remove_invite( admin_dashboard(database, Some(Ok("Invite invalidated".into()))).await } -#[post("/admin/import")] -pub async fn r_admin_import( - session: AdminSession, - database: &State<DataAcid>, - federation: &State<Federation>, -) -> MyResult<DynLayoutPage<'static>> { - drop(session); - let t = Instant::now(); - let r = import(database, federation).await; - admin_dashboard( - database, - Some( - r.map_err(|e| e.into()) - .map(|_| format!("Import successful; took {:?}", t.elapsed())), - ), - ) - .await -} +// #[post("/admin/import")] +// pub async fn r_admin_import( +// session: AdminSession, +// database: &State<DataAcid>, +// federation: &State<Federation>, +// ) -> MyResult<DynLayoutPage<'static>> { +// drop(session); +// let t = Instant::now(); +// let r = import(database, federation).await; +// admin_dashboard( +// database, +// Some( +// r.map_err(|e| e.into()) +// .map(|_| format!("Import successful; took {:?}", t.elapsed())), +// ), +// ) +// .await +// } #[post("/admin/delete_cache")] pub async fn r_admin_delete_cache( @@ -218,7 +216,7 @@ pub async fn r_admin_transcode_posters( let nodes = txn.open_table(T_NODE)?; for node in nodes.iter()? { let (_, node) = node?; - if let Some(poster) = &node.value().0.public.poster { + if let Some(poster) = &node.value().0.poster { let asset = AssetInner::deser(&poster.0)?; if asset.is_federated() { continue; @@ -246,7 +244,6 @@ fn db_stats(db: &DataAcid) -> anyhow::Result<DynRender> { let txn = db.inner.begin_read()?; let stats = [ ("node", txn.open_table(T_NODE)?.stats()?), - ("node-ext", txn.open_table(T_NODE_EXTENDED)?.stats()?), ("user", txn.open_table(T_USER_NODE)?.stats()?), ("user-node", txn.open_table(T_USER_NODE)?.stats()?), ("invite", txn.open_table(T_INVITE)?.stats()?), |