code cleanup
This commit is contained in:
parent
a9a3d3f1d7
commit
ccdc1cdfbc
50 changed files with 147 additions and 211 deletions
|
|
@ -7,7 +7,7 @@ use sslo_lib::error::SsloError;
|
|||
use sslo_lib::parameters::{DEFAULT_LOBBY_URL, LEAGUE_LOGO_MAX_DIMENSION};
|
||||
use sslo_lib::pathbuf::PathBufSslo;
|
||||
use crate::db2;
|
||||
use crate::db2::{DatabaseManager, DatabaseManagerData};
|
||||
use crate::db2::DatabaseManagerData;
|
||||
use super::config::Config;
|
||||
|
||||
pub type AppState = SsloAppState<LeagueAppState>;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use std::path::Path;
|
||||
use std::sync::{Arc, Weak};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use sslo_lib::error::SsloError;
|
||||
use crate::db2::configuration::{ConfigurationDbData, ConfigurationDbInterface};
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ use sqlx::SqlitePool;
|
|||
use tokio::sync::RwLock;
|
||||
use sslo_lib::error::SsloError;
|
||||
use crate::db2::configuration::presets::{PresetTable, PresetTableData};
|
||||
use crate::db2::{DatabaseManager, DatabaseManagerData};
|
||||
use crate::db2::DatabaseManagerData;
|
||||
|
||||
pub mod presets;
|
||||
|
||||
pub struct ConfigurationDbData {
|
||||
pool: SqlitePool,
|
||||
|
||||
_pool: SqlitePool,
|
||||
tbl_presets: Arc<RwLock<PresetTableData>>,
|
||||
db_mgr: Weak<RwLock<DatabaseManagerData>>,
|
||||
}
|
||||
|
|
@ -28,7 +29,7 @@ impl ConfigurationDbData {
|
|||
|
||||
// create data object
|
||||
Ok(Arc::new_cyclic(|me| RwLock::new(Self {
|
||||
pool: pool.clone(),
|
||||
_pool: pool.clone(),
|
||||
tbl_presets: PresetTableData::new(pool.clone(), me.clone()),
|
||||
db_mgr: Weak::new(),
|
||||
})))
|
||||
|
|
|
|||
|
|
@ -2,16 +2,13 @@ use std::collections::HashMap;
|
|||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::sync::{Arc, Weak};
|
||||
use serde::de::IntoDeserializer;
|
||||
use serde::Serialize;
|
||||
use sqlx::{Row, SqlitePool};
|
||||
use tokio::sync::{RwLock, RwLockReadGuard};
|
||||
use utoipa::gen::serde_json;
|
||||
use tokio::sync::RwLock;
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::db::{IndexedDataRow, OrderBy, WhereFieldsEqual};
|
||||
use sslo_lib::ndpc2::collection::NdpcCollection;
|
||||
use crate::db2::configuration::ConfigurationDbData;
|
||||
use crate::db2::{DatabaseManager, DatabaseManagerData};
|
||||
use crate::db2::DatabaseManager;
|
||||
use crate::ndpc::coll_preset::CollPreset;
|
||||
|
||||
#[derive(sqlx::FromRow, Clone)]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ pub mod brands;
|
|||
pub mod cars;
|
||||
pub mod liveries;
|
||||
pub mod classes;
|
||||
pub mod presets;
|
||||
|
||||
pub struct ContentDbData {
|
||||
pool: SqlitePool,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ impl BrandItem {
|
|||
}
|
||||
|
||||
/// Returns true, when the item is not actively inuse (is obsolete)
|
||||
pub async fn deprecated(&self) -> bool { self.0.read().await.row.deprecated }
|
||||
pub async fn _deprecated(&self) -> bool { self.0.read().await.row.deprecated }
|
||||
|
||||
pub async fn cars(&self) -> Vec<CarItem> {
|
||||
let db_content: ContentDbInterface;
|
||||
|
|
@ -60,7 +60,7 @@ impl BrandItem {
|
|||
}
|
||||
|
||||
/// Returns a string, that can be used in log messages
|
||||
pub async fn display(&self) -> String {
|
||||
pub async fn _display(&self) -> String {
|
||||
self.0.read().await.row.display()
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ impl BrandItem {
|
|||
.await.inspect_err(|e| log::error!("Upserting {} failed: {}", item_data.row.display(), e))
|
||||
}
|
||||
|
||||
pub async fn set_name(&self, name: &str) -> Result<(), SsloError> {
|
||||
pub async fn _set_name(&self, name: &str) -> Result<(), SsloError> {
|
||||
let mut item_data = self.0.write().await;
|
||||
let pool = item_data.pool.clone();
|
||||
item_data.row.name = name.trim().to_string();
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ impl CarItem {
|
|||
}
|
||||
|
||||
/// Returns true, when the item is not actively inuse (is obsolete)
|
||||
pub async fn deprecated(&self) -> bool { self.0.read().await.row.deprecated }
|
||||
pub async fn _deprecated(&self) -> bool { self.0.read().await.row.deprecated }
|
||||
|
||||
/// Returns a string, that can be used in log messages
|
||||
pub async fn display(&self) -> String {
|
||||
|
|
@ -137,7 +137,7 @@ impl CarItem {
|
|||
.inspect_err(|e| log::error!("Upserting {} failed: {}", item_data.row.display(), e))
|
||||
}
|
||||
|
||||
pub async fn set_source(&self, source: Option<&str>) -> Result<(), SsloError> {
|
||||
pub async fn _set_source(&self, source: Option<&str>) -> Result<(), SsloError> {
|
||||
let mut item_data = self.0.write().await;
|
||||
let pool = item_data.pool.clone();
|
||||
item_data.row.source = match source {
|
||||
|
|
@ -149,7 +149,7 @@ impl CarItem {
|
|||
}
|
||||
|
||||
/// supported sim
|
||||
pub async fn sim(&self) -> SupportedSim {
|
||||
pub async fn _sim(&self) -> SupportedSim {
|
||||
SupportedSim::from_sqlite(self.0.read().await.row.sim)
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ impl CarItem {
|
|||
pub async fn sim_data(&self) -> String { self.0.read().await.row.sim_data.clone() }
|
||||
|
||||
/// source (in case it is a mod)
|
||||
pub async fn source(&self) -> Option<String> { self.0.read().await.row.source.clone() }
|
||||
pub async fn _source(&self) -> Option<String> { self.0.read().await.row.source.clone() }
|
||||
|
||||
pub async fn url_html(&self) -> String {
|
||||
let row = &self.0.read().await.row;
|
||||
|
|
|
|||
|
|
@ -57,16 +57,16 @@ impl CountryItem {
|
|||
}
|
||||
|
||||
/// the country code
|
||||
pub async fn code(&self) -> String {
|
||||
pub async fn _code(&self) -> String {
|
||||
self.0.read().await.row.code.clone()
|
||||
}
|
||||
|
||||
pub async fn deprecated(&self) -> bool {
|
||||
pub async fn _deprecated(&self) -> bool {
|
||||
self.0.read().await.row.deprecated
|
||||
}
|
||||
|
||||
/// Returns a string, that can be used in log messages
|
||||
pub async fn display(&self) -> String {
|
||||
pub async fn _display(&self) -> String {
|
||||
self.0.read().await.row.display()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl LiveryItem {
|
|||
}
|
||||
|
||||
/// Returns true, when the item is not actively inuse (is obsolete)
|
||||
pub async fn deprecated(&self) -> bool { self.0.read().await.row.deprecated }
|
||||
pub async fn _deprecated(&self) -> bool { self.0.read().await.row.deprecated }
|
||||
|
||||
/// Returns a string, that can be used in log messages
|
||||
pub async fn display(&self) -> String {
|
||||
|
|
@ -109,7 +109,7 @@ impl LiveryItem {
|
|||
pub async fn id(&self) -> i64 { self.0.read().await.row.rowid }
|
||||
|
||||
/// name of the car
|
||||
pub async fn number(&self) -> String { self.0.read().await.row.number.clone() }
|
||||
pub async fn _number(&self) -> String { self.0.read().await.row.number.clone() }
|
||||
|
||||
/// description of the car
|
||||
pub async fn name(&self) -> String { self.0.read().await.row.name.clone() }
|
||||
|
|
@ -138,7 +138,7 @@ impl LiveryItem {
|
|||
.inspect_err(|e| log::error!("Upserting {} failed: {}", item_data.row.display(), e))
|
||||
}
|
||||
|
||||
pub async fn set_source(&self, source: Option<&str>) -> Result<(), SsloError> {
|
||||
pub async fn _set_source(&self, source: Option<&str>) -> Result<(), SsloError> {
|
||||
let mut item_data = self.0.write().await;
|
||||
let pool = item_data.pool.clone();
|
||||
item_data.row.source = match source {
|
||||
|
|
@ -150,10 +150,10 @@ impl LiveryItem {
|
|||
}
|
||||
|
||||
/// data for sim
|
||||
pub async fn sim_data(&self) -> String { self.0.read().await.row.sim_data.clone() }
|
||||
pub async fn _sim_data(&self) -> String { self.0.read().await.row.sim_data.clone() }
|
||||
|
||||
/// source (in case it is a mod)
|
||||
pub async fn source(&self) -> Option<String> { self.0.read().await.row.source.clone() }
|
||||
pub async fn _source(&self) -> Option<String> { self.0.read().await.row.source.clone() }
|
||||
|
||||
/// relative Url to html page
|
||||
pub async fn url_html(&self) -> String {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use crate::db2::content::countries::CountryItem;
|
|||
use crate::db2::content::tracks::TrackItem;
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub struct GeoCoordinates {
|
||||
pub latitude: f64,
|
||||
pub longitude: f64,
|
||||
|
|
@ -52,7 +53,7 @@ impl LocationItem {
|
|||
Self(item_data)
|
||||
}
|
||||
|
||||
pub async fn deprecated(&self) -> bool {
|
||||
pub async fn _deprecated(&self) -> bool {
|
||||
self.0.read().await.row.deprecated
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +114,7 @@ impl LocationItem {
|
|||
pub async fn name(&self) -> String { self.0.read().await.row.name.clone() }
|
||||
|
||||
/// Geological coordinates
|
||||
pub async fn coordinates(&self) -> GeoCoordinates {
|
||||
pub async fn _coordinates(&self) -> GeoCoordinates {
|
||||
let row = &self.0.read().await.row;
|
||||
GeoCoordinates{
|
||||
latitude: row.latitude,
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
use sslo_lib::db::OrderBy;
|
||||
use sslo_lib::db::WhereFieldsEqual;
|
||||
use sqlx::SqlitePool;
|
||||
use sslo_lib::db::IndexedDataRow;
|
||||
use sslo_lib::error::SsloError;
|
||||
|
||||
#[derive(sqlx::FromRow, Clone)]
|
||||
#[derive(IndexedDataRow)]
|
||||
#[tablename("brands")]
|
||||
struct DbDataRow {
|
||||
rowid: i64,
|
||||
ancestor: Option<i64>,
|
||||
deprecated: bool,
|
||||
name: String,
|
||||
json: Option<String>,
|
||||
}
|
||||
|
|
@ -125,8 +125,8 @@ impl CookieLoginItem {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn last_useragent(&self) -> Option<String> { self.0.read().await.row.last_useragent.clone() }
|
||||
pub async fn last_usage(&self) -> Option<DateTime<Utc>> { self.0.read().await.row.last_usage.clone() }
|
||||
pub async fn _last_useragent(&self) -> Option<String> { self.0.read().await.row.last_useragent.clone() }
|
||||
pub async fn _last_usage(&self) -> Option<DateTime<Utc>> { self.0.read().await.row.last_usage.clone() }
|
||||
|
||||
/// returns a http header to unset cookie
|
||||
async fn delete(self) -> String {
|
||||
|
|
@ -278,7 +278,7 @@ impl CookieLoginTable {
|
|||
Some(CookieLoginItem::new(item_data))
|
||||
}
|
||||
|
||||
pub async fn item_from_latest_usage(&self, user: &UserItem) -> Option<CookieLoginItem> {
|
||||
pub async fn _item_from_latest_usage(&self, user: &UserItem) -> Option<CookieLoginItem> {
|
||||
|
||||
let pool: SqlitePool;
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ impl SteamAccountItem {
|
|||
OptionalDateTime::new(data.row.last_login.clone())
|
||||
}
|
||||
|
||||
pub async fn set_last_login(&self, last_login: DateTime<Utc>) -> Result<(), SsloError> {
|
||||
pub async fn _set_last_login(&self, last_login: DateTime<Utc>) -> Result<(), SsloError> {
|
||||
let mut data = self.0.write().await;
|
||||
data.row.last_login = Some(last_login);
|
||||
let pool = data.pool.clone();
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ impl UserItem {
|
|||
}
|
||||
|
||||
pub async fn last_lap(&self) -> OptionalDateTime { OptionalDateTime::new(self.0.read().await.row.last_lap) }
|
||||
pub async fn set_last_lap(self: &mut Self, last_lap: DateTime<Utc>) {
|
||||
pub async fn _set_last_lap(self: &mut Self, last_lap: DateTime<Utc>) {
|
||||
self.user_grade_reset().await;
|
||||
let mut item_data = self.0.write().await;
|
||||
item_data.row.last_lap = Some(last_lap);
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ impl HtmlTemplate {
|
|||
&self.http_user
|
||||
}
|
||||
|
||||
pub fn user(&self) -> UserItem {
|
||||
pub fn _user(&self) -> UserItem {
|
||||
self.http_user.user.clone()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use std::fs::Permissions;
|
||||
use axum::extract::{FromRef, FromRequestParts};
|
||||
use axum::http::header;
|
||||
use axum::http::request::Parts;
|
||||
|
|
@ -32,12 +31,6 @@ impl HttpUser {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn permissions(&self) -> &PermissionContainer { &self.permissions }
|
||||
|
||||
pub fn user(&self) -> UserItem {
|
||||
self.user.clone()
|
||||
}
|
||||
|
||||
pub fn is_logged_in(&self) -> bool {
|
||||
self.cookie_login.is_some()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ pub async fn handler(State(app_state): State<AppState>,
|
|||
html.include_js("/rsc/js/league/classes.js");
|
||||
|
||||
// check permissions
|
||||
let user = html.user();
|
||||
let user_grade = user.user_grade().await;
|
||||
if !html.http_user_permissions.content.view().allowed() {
|
||||
return Err(StatusCode::FORBIDDEN)
|
||||
}
|
||||
|
|
@ -59,8 +57,6 @@ pub async fn handler_class(State(app_state): State<AppState>,
|
|||
html.include_js("/rsc/js/league/classes.js");
|
||||
|
||||
// check permissions
|
||||
let user = html.user();
|
||||
let user_grade = user.user_grade().await;
|
||||
if !html.http_user_permissions.content.view().allowed() {
|
||||
return Err(StatusCode::FORBIDDEN)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::future::Future;
|
|||
use std::pin::Pin;
|
||||
use axum::extract::{Path, State};
|
||||
use axum::http::StatusCode;
|
||||
use axum::response::{Html, Response};
|
||||
use axum::response::Response;
|
||||
use sslo_lib::html_modal::{Dialog, DialogButtonStyle};
|
||||
use sslo_lib::ndpc2::collection::NdpcCollection;
|
||||
use crate::app_state::AppState;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use axum::response::{IntoResponse, Response};
|
|||
use image::ImageFormat;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use utoipa::ToSchema;
|
||||
use sslo_lib::http::http2https_background_service;
|
||||
use sslo_lib::pathbuf::PathBufSslo;
|
||||
use sslo_lib::rest_api::{EmptyResponse, ErrorResponse};
|
||||
use crate::app_state::AppState;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use axum::http::StatusCode;
|
|||
use axum::Json;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::task::id;
|
||||
use utoipa::ToSchema;
|
||||
use sslo_lib::ndpc2::collection::{NdpcCollection, NdpcCollectionIO};
|
||||
use sslo_lib::rest_api::ErrorResponse;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ impl UiJson {
|
|||
struct UiCarJson {
|
||||
name: String,
|
||||
brand: String,
|
||||
description: Option<String>,
|
||||
_description: Option<String>,
|
||||
}
|
||||
|
||||
impl UiCarJson {
|
||||
|
|
@ -90,8 +90,8 @@ impl UiCarJson {
|
|||
let json = UiJson::new(file_path)?;
|
||||
let name = json.get_value("name")?;
|
||||
let brand = json.get_value("brand")?;
|
||||
let description = json.try_get_value("description");
|
||||
Ok(Self { name, brand, description })
|
||||
let _description = json.try_get_value("description");
|
||||
Ok(Self { name, brand, _description })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -503,10 +503,10 @@ async fn scan_track_variants(app_state: AppState, ac_track_dir: &PathBuf) {
|
|||
.map_err(|e| { log::error!("Failed reading '{:?}/ui': {}", ac_track_dir, e); return; }).unwrap() {
|
||||
if let Ok(track_variant_dir) = track_variant_dir {
|
||||
|
||||
let variant_id: String = match track_variant_dir.file_name().to_str() {
|
||||
None => continue,
|
||||
Some(x) => x.to_owned(),
|
||||
};
|
||||
// let variant_id: String = match track_variant_dir.file_name().to_str() {
|
||||
// None => continue,
|
||||
// Some(x) => x.to_owned(),
|
||||
// };
|
||||
|
||||
// parse ui_track.json
|
||||
let file_ui_track = track_variant_dir.path().push_vec(&["ui_track.json"]);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use clap::Parser;
|
||||
use std::net::{Ipv6Addr, SocketAddr};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use app_state::LeagueAppState;
|
||||
use sslo_lib::chrono::{TimeDeltaPrecision, TimeFormat};
|
||||
use crate::shutdown_control::ShutdownControl;
|
||||
|
|
@ -76,7 +74,7 @@ async fn main() {
|
|||
let thread_slot_control_handle = match std::thread::Builder::new()
|
||||
.name("Slot Control".to_owned())
|
||||
.spawn(|| {
|
||||
thread_lobby::worker(shutdown_clone, app_state_clone);
|
||||
thread_slot_control::worker(shutdown_clone, app_state_clone);
|
||||
}) {
|
||||
Ok(h) => h,
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -106,15 +106,6 @@ impl CollPreset {
|
|||
html
|
||||
}
|
||||
|
||||
fn html_view_format_param(&self, param: &dyn NdpcParameter, icon: &str) -> String {
|
||||
format!("<div title=\"{}\" class=\"{}\">{} {}</div>",
|
||||
param.label(),
|
||||
css_class_unlock(param),
|
||||
icon,
|
||||
param.value2str(),
|
||||
)
|
||||
}
|
||||
|
||||
fn html_view_general(&self) -> String {
|
||||
let mut html = "<div class=\"PresetViewTableBox\">".to_string();
|
||||
html += &format!("<label>{}</label>", self.coll_general.label());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
use crate::db2::content::classes::ClassesTable;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq)]
|
||||
enum Damage {
|
||||
pub enum Damage {
|
||||
None,
|
||||
Neglectable,
|
||||
Tolerant,
|
||||
|
|
@ -52,5 +51,5 @@ impl ParamDamage {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: Damage::None,
|
||||
} }
|
||||
pub fn value(&self) -> &Damage { &self.value }
|
||||
pub fn _value(&self) -> &Damage { &self.value }
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq)]
|
||||
enum DrivingAids {
|
||||
pub enum DrivingAids {
|
||||
Amateur,
|
||||
Intermediate,
|
||||
Professional,
|
||||
|
|
@ -51,5 +50,5 @@ impl ParamDrivingAids {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: DrivingAids::Amateur,
|
||||
} }
|
||||
pub fn value(&self) -> &DrivingAids { &self.value }
|
||||
pub fn _value(&self) -> &DrivingAids { &self.value }
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
use sslo_lib::parameters::SupportedSim;
|
||||
use strum::IntoEnumIterator;
|
||||
use crate::user_grade::License;
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ impl ParamLicense {
|
|||
description,
|
||||
} }
|
||||
|
||||
pub fn value(&self) -> License { self.value.clone() }
|
||||
pub fn _value(&self) -> License { self.value.clone() }
|
||||
}
|
||||
|
||||
impl NdpcParameter for ParamLicense {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum Penalties {
|
||||
pub enum Penalties {
|
||||
None,
|
||||
Tolerant,
|
||||
Fair,
|
||||
|
|
@ -51,5 +50,5 @@ impl ParamPenalties {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: Penalties::None,
|
||||
} }
|
||||
pub fn value(&self) -> Penalties { self.value.clone() }
|
||||
pub fn _value(&self) -> Penalties { self.value.clone() }
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum Puddles {
|
||||
pub enum Puddles {
|
||||
Dry,
|
||||
Few,
|
||||
Many,
|
||||
|
|
@ -22,7 +21,7 @@ impl ParamPuddles {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: Puddles::Dry,
|
||||
} }
|
||||
pub fn value(&self) -> Puddles { self.value.clone() }
|
||||
pub fn _value(&self) -> Puddles { self.value.clone() }
|
||||
}
|
||||
|
||||
impl NdpcParameter for ParamPuddles {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
|
@ -49,5 +48,5 @@ impl ParamRaceEval {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: RaceEvaluation::Fun,
|
||||
} }
|
||||
pub fn value(&self) -> &RaceEvaluation { &self.value }
|
||||
pub fn _value(&self) -> &RaceEvaluation { &self.value }
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum Registration {
|
||||
pub enum Registration {
|
||||
None,
|
||||
FirstComeFirstServed,
|
||||
ByQualification,
|
||||
|
|
@ -51,5 +50,5 @@ impl ParamRegistration {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: Registration::None,
|
||||
} }
|
||||
pub fn value(&self) -> Registration { self.value.clone() }
|
||||
pub fn _value(&self) -> Registration { self.value.clone() }
|
||||
}
|
||||
|
|
@ -43,5 +43,5 @@ impl ParamSim {
|
|||
value: SupportedSim::NoSim,
|
||||
} }
|
||||
|
||||
pub fn value(&self) -> SupportedSim { self.value.clone() }
|
||||
pub fn _value(&self) -> SupportedSim { self.value.clone() }
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum Sky {
|
||||
pub enum Sky {
|
||||
Clear,
|
||||
BrokenClouds,
|
||||
Cloudy,
|
||||
|
|
@ -23,7 +22,7 @@ impl ParamSky {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: Sky::Clear,
|
||||
} }
|
||||
pub fn value(&self) -> Sky { self.value.clone() }
|
||||
pub fn _value(&self) -> Sky { self.value.clone() }
|
||||
}
|
||||
|
||||
impl NdpcParameter for ParamSky {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum TempRoad {
|
||||
pub enum TempRoad {
|
||||
Cold,
|
||||
Cool,
|
||||
Realistic,
|
||||
|
|
@ -23,7 +22,7 @@ impl ParamTempRoad {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: TempRoad::Realistic,
|
||||
} }
|
||||
pub fn value(&self) -> TempRoad { self.value.clone() }
|
||||
pub fn _value(&self) -> TempRoad { self.value.clone() }
|
||||
}
|
||||
|
||||
impl NdpcParameter for ParamTempRoad {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum WeatherOffset {
|
||||
pub enum WeatherOffset {
|
||||
Live,
|
||||
BeforeOneWeek,
|
||||
BeforeThreeMonths,
|
||||
|
|
@ -23,7 +22,7 @@ impl ParamWeatherOffset {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: WeatherOffset::Live,
|
||||
} }
|
||||
pub fn value(&self) -> WeatherOffset { self.value.clone() }
|
||||
pub fn _value(&self) -> WeatherOffset { self.value.clone() }
|
||||
}
|
||||
|
||||
impl NdpcParameter for ParamWeatherOffset {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum WindDirection {
|
||||
pub enum WindDirection {
|
||||
North,
|
||||
NorthEast,
|
||||
East,
|
||||
|
|
@ -26,7 +25,7 @@ impl ParamWindDir {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: WindDirection::East,
|
||||
} }
|
||||
pub fn value(&self) -> WindDirection { self.value.clone() }
|
||||
pub fn _value(&self) -> WindDirection { self.value.clone() }
|
||||
}
|
||||
|
||||
impl NdpcParameter for ParamWindDir {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use axum::response::IntoResponse;
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use sslo_lib::error::SsloError;
|
||||
use sslo_lib::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
||||
#[derive(AsRefStr, EnumIter, EnumString, PartialEq, Clone)]
|
||||
enum WindSpeed {
|
||||
pub enum WindSpeed {
|
||||
Calm,
|
||||
Gust,
|
||||
Windy,
|
||||
|
|
@ -22,7 +21,7 @@ impl ParamWindSpeed {
|
|||
meta: NdpcParameterMetaData::new(),
|
||||
value: WindSpeed::Calm,
|
||||
} }
|
||||
pub fn value(&self) -> WindSpeed { self.value.clone() }
|
||||
pub fn _value(&self) -> WindSpeed { self.value.clone() }
|
||||
}
|
||||
|
||||
impl NdpcParameter for ParamWindSpeed {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ impl ShutdownControl {
|
|||
}
|
||||
|
||||
/// ensures that a forced shutdown is commanded
|
||||
#[allow(dead_code)]
|
||||
pub fn shutdown_force(self) {
|
||||
let mut data = match self.0.write() {
|
||||
Ok(data) => data,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use std::path::Path;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use serde::Serialize;
|
||||
use crate::app_state::AppState;
|
||||
use crate::shutdown_control::ShutdownStatus;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::app_state::AppState;
|
|||
use crate::shutdown_control::ShutdownStatus;
|
||||
use crate::ShutdownControl;
|
||||
|
||||
pub(super) fn worker(sc: ShutdownControl, app_state: AppState) {
|
||||
pub(super) fn worker(sc: ShutdownControl, _app_state: AppState) {
|
||||
|
||||
loop {
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@ pub enum License {
|
|||
|
||||
impl License {
|
||||
|
||||
pub fn list() -> Vec<Self> {
|
||||
vec![Self::Green, Self::Bronze, Self::Silver, Self::Gold, Self::Platinum, Self::Alien]
|
||||
}
|
||||
|
||||
/// The string portion that is used to compose the user title
|
||||
pub fn title_str(&self) -> &'static str {
|
||||
match self {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ macro_rules! define_permissions {
|
|||
$(
|
||||
#[derive(Clone)]
|
||||
pub struct $group_type {
|
||||
promotion_actual: Promotion,
|
||||
driving_actual: DrivingActivity,
|
||||
label: &'static str,
|
||||
$( $perm: Permission, )+
|
||||
}
|
||||
|
|
@ -49,8 +47,6 @@ macro_rules! define_permissions {
|
|||
impl $group_type {
|
||||
pub fn new(promotion: Promotion, driving_activity: DrivingActivity) -> Self {
|
||||
Self {
|
||||
promotion_actual: promotion.clone(),
|
||||
driving_actual: driving_activity.clone(),
|
||||
label: $group_label,
|
||||
$(
|
||||
$perm: Permission {
|
||||
|
|
@ -137,21 +133,21 @@ define_permissions! {
|
|||
drv_min: Some(DrivingActivity::Recent),
|
||||
label: "View Content"
|
||||
},
|
||||
edit_deo_coordinates => {
|
||||
promo_min: Promotion::Marshal,
|
||||
drv_min: None,
|
||||
label: "Edit Geo Coordinates"
|
||||
},
|
||||
edit_downloads => {
|
||||
promo_min: Promotion::Officer,
|
||||
drv_min: None,
|
||||
label: "Edit Downloads"
|
||||
},
|
||||
classes_bop => {
|
||||
promo_min: Promotion::Commissar,
|
||||
drv_min: None,
|
||||
label: "Balance Car Classes"
|
||||
},
|
||||
// edit_deo_coordinates => {
|
||||
// promo_min: Promotion::Marshal,
|
||||
// drv_min: None,
|
||||
// label: "Edit Geo Coordinates"
|
||||
// },
|
||||
// edit_downloads => {
|
||||
// promo_min: Promotion::Officer,
|
||||
// drv_min: None,
|
||||
// label: "Edit Downloads"
|
||||
// },
|
||||
// classes_bop => {
|
||||
// promo_min: Promotion::Commissar,
|
||||
// drv_min: None,
|
||||
// label: "Balance Car Classes"
|
||||
// },
|
||||
classes_manage => {
|
||||
promo_min: Promotion::Director,
|
||||
drv_min: None,
|
||||
|
|
@ -166,46 +162,46 @@ define_permissions! {
|
|||
drv_min: Some(DrivingActivity::Obsolete),
|
||||
label: "View Slot States"
|
||||
},
|
||||
graceful => {
|
||||
promo_min: Promotion::Steward,
|
||||
drv_min: None,
|
||||
label: "Graceful Slot Control"
|
||||
},
|
||||
force => {
|
||||
promo_min: Promotion::Officer,
|
||||
drv_min: None,
|
||||
label: "Force Slot Control"
|
||||
},
|
||||
},
|
||||
Racing {
|
||||
racing,
|
||||
"Racing",
|
||||
register => {
|
||||
promo_min: Promotion::Steward,
|
||||
drv_min: Some(DrivingActivity::Recent),
|
||||
label: "Register"
|
||||
},
|
||||
schedule_race => {
|
||||
promo_min: Promotion::Marshal,
|
||||
drv_min: None,
|
||||
label: "Schedule Race"
|
||||
},
|
||||
manage_schedules => {
|
||||
promo_min: Promotion::Officer,
|
||||
drv_min: None,
|
||||
label: "Manage Schedules"
|
||||
},
|
||||
edit_series => {
|
||||
promo_min: Promotion::Commissar,
|
||||
drv_min: None,
|
||||
label: "Edit Race Series"
|
||||
},
|
||||
manage_series => {
|
||||
promo_min: Promotion::Director,
|
||||
drv_min: None,
|
||||
label: "Manage Race Series"
|
||||
},
|
||||
// graceful => {
|
||||
// promo_min: Promotion::Steward,
|
||||
// drv_min: None,
|
||||
// label: "Graceful Slot Control"
|
||||
// },
|
||||
// force => {
|
||||
// promo_min: Promotion::Officer,
|
||||
// drv_min: None,
|
||||
// label: "Force Slot Control"
|
||||
// },
|
||||
},
|
||||
// Racing {
|
||||
// racing,
|
||||
// "Racing",
|
||||
// register => {
|
||||
// promo_min: Promotion::Steward,
|
||||
// drv_min: Some(DrivingActivity::Recent),
|
||||
// label: "Register"
|
||||
// },
|
||||
// schedule_race => {
|
||||
// promo_min: Promotion::Marshal,
|
||||
// drv_min: None,
|
||||
// label: "Schedule Race"
|
||||
// },
|
||||
// manage_schedules => {
|
||||
// promo_min: Promotion::Officer,
|
||||
// drv_min: None,
|
||||
// label: "Manage Schedules"
|
||||
// },
|
||||
// edit_series => {
|
||||
// promo_min: Promotion::Commissar,
|
||||
// drv_min: None,
|
||||
// label: "Edit Race Series"
|
||||
// },
|
||||
// manage_series => {
|
||||
// promo_min: Promotion::Director,
|
||||
// drv_min: None,
|
||||
// label: "Manage Race Series"
|
||||
// },
|
||||
// },
|
||||
Presets {
|
||||
presets,
|
||||
"Presets",
|
||||
|
|
@ -225,20 +221,20 @@ define_permissions! {
|
|||
label: "Manage Presets"
|
||||
},
|
||||
},
|
||||
Penalties {
|
||||
penalties,
|
||||
"Penalties",
|
||||
impose => {
|
||||
promo_min: Promotion::Officer,
|
||||
drv_min: None,
|
||||
label: "Impose Penalties"
|
||||
},
|
||||
ratify => {
|
||||
promo_min: Promotion::Commissar,
|
||||
drv_min: None,
|
||||
label: "Ratify Penalties"
|
||||
},
|
||||
},
|
||||
// Penalties {
|
||||
// penalties,
|
||||
// "Penalties",
|
||||
// impose => {
|
||||
// promo_min: Promotion::Officer,
|
||||
// drv_min: None,
|
||||
// label: "Impose Penalties"
|
||||
// },
|
||||
// ratify => {
|
||||
// promo_min: Promotion::Commissar,
|
||||
// drv_min: None,
|
||||
// label: "Ratify Penalties"
|
||||
// },
|
||||
// },
|
||||
PermGrpDebug {
|
||||
debug,
|
||||
"Debugging",
|
||||
|
|
@ -252,11 +248,11 @@ define_permissions! {
|
|||
drv_min: None,
|
||||
label: "View Database IDs"
|
||||
},
|
||||
beta_features => {
|
||||
promo_min: Promotion::Admin,
|
||||
drv_min: None,
|
||||
label: "Beta Features"
|
||||
},
|
||||
// beta_features => {
|
||||
// promo_min: Promotion::Admin,
|
||||
// drv_min: None,
|
||||
// label: "Beta Features"
|
||||
// },
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ pub trait NdpcCollection : Send {
|
|||
fn state_import_str(&mut self, string: &str) {
|
||||
let io: NdpcCollectionIO = match serde_json::from_str(string) {
|
||||
Ok(io) => io,
|
||||
Err(e) => return,
|
||||
Err(_e) => return,
|
||||
};
|
||||
self.state_import(&io);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ impl NdpcParameter for ParamBool {
|
|||
Ok(value) => {
|
||||
self.value = value; Ok(())
|
||||
},
|
||||
Err(e) => {
|
||||
Err(_e) => {
|
||||
Err(SsloError::NdpcValueMismatch(self.upid.to_string(), value.to_string()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use chrono::{DateTime, ParseResult, Utc};
|
||||
use chrono::DateTime;
|
||||
use crate::chrono::OptionalDateTime;
|
||||
use crate::error::SsloError;
|
||||
use crate::ndpc2::parameter::{NdpcParameter, NdpcParameterMetaData};
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl NdpcParameter for ParamI64 {
|
|||
}
|
||||
self.value = value; Ok(())
|
||||
},
|
||||
Err(e) => {
|
||||
Err(_e) => {
|
||||
Err(SsloError::NdpcValueMismatch(self.upid.to_string(), value.to_string()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ pub trait NdpcParameter : Send {
|
|||
|
||||
// take value from other
|
||||
if other_meta.access == NdpcAccess::Locked || self.meta().inheritance == NdpcValueInheritance::Inherit {
|
||||
if let Err(e) = self.value_from_string(&other_value_str) {
|
||||
if let Err(_e) = self.value_from_string(&other_value_str) {
|
||||
log::warn!("Ignore importing value='{}' into parameter upid={}", &other_value_str, self.upid())
|
||||
}
|
||||
}
|
||||
|
|
@ -250,7 +250,7 @@ pub trait NdpcParameter : Send {
|
|||
|
||||
if let Some(value) = &io.value {
|
||||
if let Err(e) = self.value_from_string(value) {
|
||||
log::warn!("Cannot import value='{}' into parameter upid={}", &value, self.upid())
|
||||
log::warn!("Cannot import value='{}' into parameter upid={}: {}", &value, self.upid(), e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use enum_primitive_derive::Primitive;
|
||||
use num_traits::{FromPrimitive, ToPrimitive};
|
||||
use strum::{AsRefStr, EnumIter, EnumString, IntoEnumIterator};
|
||||
use strum::{AsRefStr, EnumIter, EnumString};
|
||||
|
||||
/// The url of the official SSLO lobby (without protocol-prefix)
|
||||
pub const DEFAULT_LOBBY_URL: &str = "https://lobby.sslo.net";
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub enum TokenType {
|
|||
|
||||
impl TokenType {
|
||||
|
||||
pub fn get_config(&self) -> argon2::Config {
|
||||
pub fn get_config(&'_ self) -> argon2::Config<'_> {
|
||||
match self {
|
||||
Self::Strong => {
|
||||
argon2::Config::default()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue