v0.31.0
This commit is contained in:
1 parent
f213d853e2
commit
76b8bb7ee2
78 files changed
+7750
-5204
No files matched your search
@@ -0,0 +1,41 @@
|
||||
// Stored inside the existing per-account administration preferences document.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
struct RefreshPreferences {
|
||||
live_enabled: bool,
|
||||
overview_seconds: u16,
|
||||
traffic_seconds: u16,
|
||||
cache_seconds: u16,
|
||||
system_info_seconds: u16,
|
||||
}
|
||||
|
||||
impl Default for RefreshPreferences {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
live_enabled: true,
|
||||
overview_seconds: 2,
|
||||
traffic_seconds: 5,
|
||||
cache_seconds: 5,
|
||||
system_info_seconds: 60,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_refresh_preferences(refresh: &RefreshPreferences) -> Result<(), ApiError> {
|
||||
if ![1, 2, 5, 10].contains(&refresh.overview_seconds)
|
||||
|| ![0, 3, 5, 10, 30].contains(&refresh.traffic_seconds)
|
||||
|| ![0, 3, 5, 10, 30].contains(&refresh.cache_seconds)
|
||||
|| ![0, 15, 30, 60, 300].contains(&refresh.system_info_seconds)
|
||||
{
|
||||
return Err(ApiError(
|
||||
StatusCode::UNPROCESSABLE_ENTITY,
|
||||
"invalid administration refresh interval".into(),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn default_live_log_columns() -> Vec<String> {
|
||||
LIVE_LOG_COLUMNS.iter().map(|column| (*column).to_owned()).collect()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user