feat(network): Support for fetching Sonarr updates
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::{models::HorizontallyScrollableText, serde_enum_from};
|
||||
|
||||
use super::servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper,
|
||||
QueueEvent, Release, RootFolder, SecurityConfig, Tag,
|
||||
QueueEvent, Release, RootFolder, SecurityConfig, Tag, Update,
|
||||
};
|
||||
use super::{EnumDisplayStyle, Serdeable};
|
||||
|
||||
@@ -471,24 +471,6 @@ impl Display for RadarrTaskName {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Update {
|
||||
pub version: String,
|
||||
pub release_date: DateTime<Utc>,
|
||||
pub installed: bool,
|
||||
pub latest: bool,
|
||||
pub installed_on: Option<DateTime<Utc>>,
|
||||
pub changes: UpdateChanges,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateChanges {
|
||||
pub new: Option<Vec<String>>,
|
||||
pub fixed: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(untagged)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::models::{
|
||||
},
|
||||
stateful_list::StatefulList,
|
||||
stateful_table::StatefulTable,
|
||||
HorizontallyScrollableText, Route,
|
||||
HorizontallyScrollableText, Route, ScrollableText,
|
||||
};
|
||||
|
||||
use super::modals::SeasonDetailsModal;
|
||||
@@ -37,6 +37,7 @@ pub struct SonarrData {
|
||||
pub start_time: DateTime<Utc>,
|
||||
pub tags_map: BiMap<i64, String>,
|
||||
pub tasks: StatefulTable<SonarrTask>,
|
||||
pub updates: ScrollableText,
|
||||
pub version: String,
|
||||
}
|
||||
|
||||
@@ -61,6 +62,7 @@ impl Default for SonarrData {
|
||||
start_time: DateTime::default(),
|
||||
tags_map: BiMap::default(),
|
||||
tasks: StatefulTable::default(),
|
||||
updates: ScrollableText::default(),
|
||||
version: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ mod tests {
|
||||
assert_eq!(sonarr_data.start_time, <DateTime<Utc>>::default());
|
||||
assert!(sonarr_data.tags_map.is_empty());
|
||||
assert!(sonarr_data.tasks.is_empty());
|
||||
assert!(sonarr_data.updates.is_empty());
|
||||
assert!(sonarr_data.version.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,3 +249,21 @@ pub struct UnmappedFolder {
|
||||
pub name: String,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Update {
|
||||
pub version: String,
|
||||
pub release_date: DateTime<Utc>,
|
||||
pub installed: bool,
|
||||
pub latest: bool,
|
||||
pub installed_on: Option<DateTime<Utc>>,
|
||||
pub changes: UpdateChanges,
|
||||
}
|
||||
|
||||
#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateChanges {
|
||||
pub new: Option<Vec<String>>,
|
||||
pub fixed: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ use crate::serde_enum_from;
|
||||
use super::{
|
||||
servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, Language, LogResponse, QualityProfile, QualityWrapper,
|
||||
QueueEvent, Release, RootFolder, SecurityConfig, Tag,
|
||||
QueueEvent, Release, RootFolder, SecurityConfig, Tag, Update,
|
||||
},
|
||||
EnumDisplayStyle, HorizontallyScrollableText, Serdeable,
|
||||
};
|
||||
@@ -430,7 +430,7 @@ impl Display for SonarrTaskName {
|
||||
#[serde(untagged)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum SonarrSerdeable {
|
||||
Value(Value),
|
||||
BlocklistResponse(BlocklistResponse),
|
||||
DownloadsResponse(DownloadsResponse),
|
||||
DiskSpaces(Vec<DiskSpace>),
|
||||
Episode(Episode),
|
||||
@@ -438,6 +438,7 @@ pub enum SonarrSerdeable {
|
||||
HostConfig(HostConfig),
|
||||
IndexerSettings(IndexerSettings),
|
||||
Indexers(Vec<Indexer>),
|
||||
LogResponse(LogResponse),
|
||||
QualityProfiles(Vec<QualityProfile>),
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
Releases(Vec<Release>),
|
||||
@@ -451,8 +452,8 @@ pub enum SonarrSerdeable {
|
||||
Tag(Tag),
|
||||
Tags(Vec<Tag>),
|
||||
Tasks(Vec<SonarrTask>),
|
||||
BlocklistResponse(BlocklistResponse),
|
||||
LogResponse(LogResponse),
|
||||
Updates(Vec<Update>),
|
||||
Value(Value),
|
||||
}
|
||||
|
||||
impl From<SonarrSerdeable> for Serdeable {
|
||||
@@ -469,7 +470,7 @@ impl From<()> for SonarrSerdeable {
|
||||
|
||||
serde_enum_from!(
|
||||
SonarrSerdeable {
|
||||
Value(Value),
|
||||
BlocklistResponse(BlocklistResponse),
|
||||
DownloadsResponse(DownloadsResponse),
|
||||
DiskSpaces(Vec<DiskSpace>),
|
||||
Episode(Episode),
|
||||
@@ -477,6 +478,7 @@ serde_enum_from!(
|
||||
HostConfig(HostConfig),
|
||||
IndexerSettings(IndexerSettings),
|
||||
Indexers(Vec<Indexer>),
|
||||
LogResponse(LogResponse),
|
||||
QualityProfiles(Vec<QualityProfile>),
|
||||
QueueEvents(Vec<QueueEvent>),
|
||||
Releases(Vec<Release>),
|
||||
@@ -490,8 +492,8 @@ serde_enum_from!(
|
||||
Tag(Tag),
|
||||
Tags(Vec<Tag>),
|
||||
Tasks(Vec<SonarrTask>),
|
||||
BlocklistResponse(BlocklistResponse),
|
||||
LogResponse(LogResponse),
|
||||
Updates(Vec<Update>),
|
||||
Value(Value),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ mod tests {
|
||||
use crate::models::{
|
||||
servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, Log, LogResponse, QualityProfile, QueueEvent, Release,
|
||||
RootFolder, SecurityConfig, Tag,
|
||||
RootFolder, SecurityConfig, Tag, Update,
|
||||
},
|
||||
sonarr_models::{
|
||||
BlocklistItem, BlocklistResponse, DownloadRecord, DownloadsResponse, Episode,
|
||||
@@ -426,4 +426,16 @@ mod tests {
|
||||
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::Tasks(tasks));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sonarr_serdeable_from_updates() {
|
||||
let updates = vec![Update {
|
||||
version: "test".to_owned(),
|
||||
..Update::default()
|
||||
}];
|
||||
|
||||
let sonarr_serdeable: SonarrSerdeable = updates.clone().into();
|
||||
|
||||
assert_eq!(sonarr_serdeable, SonarrSerdeable::Updates(updates));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user