Move logs view from dev_panel page to a logs page
This commit is contained in:
parent
1bb0f05fc0
commit
b0f0633338
7 changed files with 110 additions and 42 deletions
|
|
@ -68,18 +68,10 @@ pub async fn home_page(
|
|||
|
||||
///// DEV_PANEL /////
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct LogFile {
|
||||
#[serde(default)]
|
||||
pub log_file: String,
|
||||
}
|
||||
|
||||
#[debug_handler(state = AppState)]
|
||||
pub async fn dev_panel(
|
||||
State(connection): State<db::Connection>,
|
||||
State(log): State<Log>,
|
||||
Extension(context): Extension<Context>,
|
||||
log_file: Query<LogFile>,
|
||||
) -> Result<Response> {
|
||||
if context.user.is_some() && context.user.as_ref().unwrap().is_admin {
|
||||
Ok(Html(
|
||||
|
|
@ -92,8 +84,60 @@ pub async fn dev_panel(
|
|||
)
|
||||
.await?,
|
||||
context,
|
||||
}
|
||||
.render()?,
|
||||
)
|
||||
.into_response())
|
||||
} else {
|
||||
Ok((
|
||||
StatusCode::UNAUTHORIZED,
|
||||
Html(
|
||||
MessageTemplate::new_with_user(
|
||||
consts::NOT_AUTHORIZED_MESSAGE,
|
||||
context.tr,
|
||||
context.user,
|
||||
)
|
||||
.render()?,
|
||||
),
|
||||
)
|
||||
.into_response())
|
||||
}
|
||||
}
|
||||
|
||||
///// DEV_PANEL /////
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct LogFile {
|
||||
#[serde(default)]
|
||||
pub log_file: String,
|
||||
}
|
||||
|
||||
#[debug_handler(state = AppState)]
|
||||
pub async fn logs(
|
||||
State(connection): State<db::Connection>,
|
||||
State(log): State<Log>,
|
||||
Extension(context): Extension<Context>,
|
||||
log_file: Query<LogFile>,
|
||||
) -> Result<Response> {
|
||||
if context.user.is_some() && context.user.as_ref().unwrap().is_admin {
|
||||
Ok(Html(
|
||||
LogsTemplate {
|
||||
recipes: Recipes::new(
|
||||
connection,
|
||||
&context.user,
|
||||
context.tr.current_lang_code(),
|
||||
None,
|
||||
)
|
||||
.await?,
|
||||
context,
|
||||
current_log_file: match (
|
||||
log_file.log_file.is_empty(),
|
||||
log.file_names().unwrap_or_default(),
|
||||
) {
|
||||
(true, file_names) if !file_names.is_empty() => file_names[0].clone(),
|
||||
_ => log_file.log_file.clone(),
|
||||
},
|
||||
log,
|
||||
current_log_file: log_file.log_file.clone(),
|
||||
}
|
||||
.render()?,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue