This commit is contained in:
4cuck committed 2025-12-24 03:42:26 +01:00
1 parent ba10512f29
commit 709f1e5aa2
24 files changed
+112 -147

No files matched your search

+2 -8
View File
@@ -1,7 +1,4 @@
use std::{
collections::HashMap,
sync::Arc,
};
use std::{collections::HashMap, sync::Arc};
use crate::{Result, ServerError};
use axum::{
@@ -9,10 +6,7 @@ use axum::{
response::{Html, IntoResponse},
};
use chrono::{TimeZone, Utc};
use entities::{
host,
log,
};
use entities::{host, log};
use sea_orm::EntityTrait;
use sea_orm::{DatabaseConnection, QueryOrder, QuerySelect};
use serde::Serialize;
+5 -35
View File
@@ -1,7 +1,6 @@
use std::collections::HashSet;
use std::sync::Arc;
use axum::extract::Path;
use axum::extract::State;
use axum::response::Html;
use axum::response::IntoResponse;
@@ -24,7 +23,6 @@ use sea_orm::ColumnTrait;
use sea_orm::DatabaseConnection;
use sea_orm::EntityTrait;
use sea_orm::QueryFilter;
use sea_orm::QueryOrder;
use serde::Deserialize;
use serde::Serialize;
use sha2::{Digest, Sha256};
@@ -42,21 +40,21 @@ use crate::ADMIN_OVERVIEW_URL;
use crate::LOGIN_URL;
mod errors;
mod settings;
mod locks;
mod logs;
mod settings;
mod stats;
pub use errors::errors_view;
pub use settings::post_settings;
pub use settings::settings_view;
pub use locks::locks_view;
pub use locks::post_locks;
pub use logs::log_view;
pub use stats::stats_view;
pub use settings::post_settings;
pub use settings::settings_view;
pub use stats::health_csv_api;
pub use stats::stats_csv_api;
pub use stats::overview_csv_api;
pub use stats::stats_csv_api;
pub use stats::stats_view;
/// Stored session login information
#[derive(Serialize, Deserialize, Default)]
@@ -368,34 +366,6 @@ pub async fn history_json(
.into_response())
}
pub async fn history_view(
State(ref app_state): State<AppState>,
State(ref template): State<Arc<tera::Tera>>,
State(ref db): State<DatabaseConnection>,
Path(host): Path<i32>,
session: Session,
) -> Result<axum::response::Response> {
tracing::info!(?session);
let (host, _login) = get_specific_login_host(host, &session, db).await?;
let mut context = tera::Context::new();
let res = {
let guard = app_state
.cache
.read()
.map_err(|_| ServerError::MutexFailure)?;
let time = guard.last_update.format("%Y.%m.%d %H:%M").to_string();
context.insert("last_updated", &time);
context.insert("HOST_DOMAIN", &host.domain);
let res = Html(template.render("errors_admin.html.j2", &context)?).into_response();
drop(guard);
res
};
Ok(res)
}
/// Get all [host::Model] for current [Session], optionally return all hosts for admins
async fn get_all_login_hosts(
session: &Session,
+1 -4
View File
@@ -1,7 +1,4 @@
use std::{
sync::Arc,
time::{SystemTime, UNIX_EPOCH},
};
use std::sync::Arc;
use crate::{Result, ServerError};
use axum::{
+5 -16
View File
@@ -1,27 +1,16 @@
use std::{collections::HashMap, fmt::Write, sync::Arc};
use std::{fmt::Write as _, sync::Arc};
use axum::{
extract::{Path, State},
http::HeaderValue,
response::{Html, IntoResponse, Redirect},
Form,
response::{Html, IntoResponse},
};
use chrono::{TimeZone, Utc};
use entities::{
health_check::{self, ResponseTimeStat},
host_overrides::{
self,
keys::{HostOverrides, LOCKED_FALSE, LOCKED_TRUE},
},
instance_stats,
};
use sea_orm::{sea_query::OnConflict, ActiveValue, DatabaseConnection, EntityTrait};
use entities::{health_check::ResponseTimeStat, instance_stats};
use sea_orm::DatabaseConnection;
use tower_sessions::Session;
use crate::{
admin::{get_all_login_hosts, get_session_login},
Result, ServerError,
};
use crate::{admin::get_all_login_hosts, Result, ServerError};
use super::get_specific_login_host;
-5
View File
@@ -2,13 +2,8 @@
use crate::{Result, ServerError};
use axum::response::IntoResponse;
use axum::{extract::State, Json};
use chrono::{TimeZone, Utc};
use entities::state::AppState;
use entities::{health_check, instance_stats};
use hyper::http::HeaderValue;
use sea_orm::DatabaseConnection;
use serde::Serialize;
use std::fmt::Write;
use std::sync::Arc;
pub async fn instances(
-23
View File
@@ -78,26 +78,3 @@ pub async fn about(
);
Ok(res)
}
pub async fn rip(
State(ref app_state): State<AppState>,
State(ref template): State<Arc<tera::Tera>>,
State(ref scanner_config): State<ScannerConfig>,
) -> Result<axum::response::Response> {
let mut context = tera::Context::new();
{
let guard = app_state
.cache
.read()
.map_err(|_| ServerError::MutexFailure)?;
let time = guard.last_update.format("%Y.%m.%d %H:%M").to_string();
context.insert("last_updated", &time);
}
let mut res = Html(template.render("rip.html.j2", &context)?).into_response();
res.headers_mut().insert(
"cache-control",
HeaderValue::from_static("public, max-age=900"),
);
Ok(res)
}
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-only
document.addEventListener("DOMContentLoaded", function() {
const startDateInput = document.getElementById('startDate');
const endDateInput = document.getElementById('endDate');
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-only
document.addEventListener("DOMContentLoaded", function (event) {
const startDateInput = document.getElementById('startDate');
const endDateInput = document.getElementById('endDate');
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-only
document.addEventListener("DOMContentLoaded", function (event) {
var loadGraphBtn = document.getElementById("loadGraphBtn");
if (loadGraphBtn) {
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-only
let chart = undefined;
document.addEventListener("DOMContentLoaded", function() {
const startDateInput = document.getElementById('startDate');
+1
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-only
async function sha256(message) {
const msgBuffer = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
+4 -2
View File
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: AGPL-3.0-only
document.addEventListener("DOMContentLoaded", function (event) {
var host_id = document.getElementById("body").getAttribute("data-hid");
var loadGraphBtn = document.getElementById("loadGraphBtn");
@@ -19,7 +20,7 @@ async function loadHealthGraph(host_id) {
try {
let g = new Dygraph(
graphDiv,
"/admin/api/graphs/health/"+host_id,
"/admin/api/graphs/health/" + host_id,
{
title: 'Historic Instance Healthiness',
showRangeSelector: true,
@@ -34,6 +35,7 @@ async function loadHealthGraph(host_id) {
ylabel: 'Nitter Instances',
}
);
// fixme: find valid annotation dates, regardless of the host
g.ready(function () {
g.setAnnotations([
{
@@ -66,7 +68,7 @@ async function loadStatsGraph(host_id) {
try {
let g = new Dygraph(
graphDiv,
"/admin/api/graphs/stats/"+host_id,
"/admin/api/graphs/stats/" + host_id,
{
title: 'Historic Average Instance Statistics',
showRangeSelector: true,
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Get the table and checkboxes
const dataTable = document.getElementById('status-tbl');
const toggleColumnCheckboxes = document.querySelectorAll('.toggle-column');
+1
View File
@@ -1,3 +1,4 @@
{#- SPDX-License-Identifier: AGPL-3.0-only #}
<style>
.dygraph-annotation {
height: auto !important;