Mostly added Add movie functionality. Removed calendar functions for now. Want to add the ability to modify settings and quality profiles first

This commit is contained in:
2023-08-08 10:50:04 -06:00
parent ae6e19a414
commit 08cde20359
14 changed files with 475 additions and 98 deletions
-55
View File
@@ -113,61 +113,6 @@ impl<T> Scrollable for StatefulTable<T> {
}
}
#[derive(Default)]
pub struct StatefulMatrix<T> {
pub selection: (usize, usize),
pub items: Vec<Vec<T>>,
}
impl<T> Scrollable for StatefulMatrix<T> {
fn scroll_down(&mut self) {
if self.selection.0 >= self.items.len() - 1 {
self.selection.0 = 0;
} else {
self.selection.0 += 1;
}
}
fn scroll_up(&mut self) {
if self.selection.0 == 0 {
self.selection.0 = self.items.len() - 1;
} else {
self.selection.0 -= 1;
}
}
fn scroll_to_top(&mut self) {
self.selection.0 = 0;
}
fn scroll_to_bottom(&mut self) {
self.selection.0 = self.items.len() - 1;
}
}
impl<T> StatefulMatrix<T> {
pub fn current_selection(&self) -> &T {
let (x, y) = self.selection;
&self.items[x][y]
}
pub fn scroll_left(&mut self) {
if self.selection.1 == 0 {
self.selection.1 = self.items[0].len() - 1;
} else {
self.selection.1 -= 1;
}
}
pub fn scroll_right(&mut self) {
if self.selection.1 >= self.items[0].len() - 1 {
self.selection.1 = 0;
} else {
self.selection.1 += 1;
}
}
}
#[derive(Default)]
pub struct ScrollableText {
pub items: Vec<String>,
+37 -1
View File
@@ -1,6 +1,6 @@
use chrono::{DateTime, Utc};
use derivative::Derivative;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use serde_json::Number;
use crate::models::HorizontallyScrollableText;
@@ -199,3 +199,39 @@ pub struct Credit {
#[serde(rename(deserialize = "type"))]
pub credit_type: CreditType,
}
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct AddMovieBody {
pub tmdb_id: Number,
pub title: String,
pub root_folder_path: String,
pub quality_profile_id: Number,
pub minimum_availability: String,
pub monitored: bool,
pub add_options: AddOptions,
}
#[derive(Serialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct AddOptions {
pub search_for_movie: bool,
}
#[derive(Derivative, Deserialize, Debug, Clone, PartialEq, Eq)]
#[derivative(Default)]
#[serde(rename_all = "camelCase")]
pub struct AddMovieSearchResult {
#[derivative(Default(value = "Number::from(0)"))]
pub tmdb_id: Number,
pub title: String,
pub original_language: Language,
pub status: String,
pub overview: String,
pub genres: Vec<String>,
#[derivative(Default(value = "Number::from(0)"))]
pub year: Number,
#[derivative(Default(value = "Number::from(0)"))]
pub runtime: Number,
pub ratings: RatingsList,
}