Skip to content

Commit

Permalink
Bump utoipa from 4.2.3 to 5.1.3 (#986)
Browse files Browse the repository at this point in the history
* Bump utoipa from 4.2.3 to 5.1.3

Bumps [utoipa](https://github.com/juhaku/utoipa) from 4.2.3 to 5.1.3.
- [Release notes](https://github.com/juhaku/utoipa/releases)
- [Changelog](https://github.com/juhaku/utoipa/blob/master/utoipa-rapidoc/CHANGELOG.md)
- [Commits](juhaku/utoipa@utoipa-4.2.3...utoipa-5.1.3)

---
updated-dependencies:
- dependency-name: utoipa
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Updated to latest utoipa

* Updated to latest utoipa with cargo fixes

* Updated cargo lock

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: SamTV12345 <40429738+samtv12345@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and SamTV12345 authored Oct 31, 2024
1 parent 18c78d9 commit cc8b737
Show file tree
Hide file tree
Showing 13 changed files with 374 additions and 462 deletions.
703 changes: 269 additions & 434 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ regex = "1.11.0"
xml-builder = "0.5.2"
diesel = { version = "2.2.4", features = ["chrono", "r2d2"] }
r2d2 = "0.8.10"
utoipa = { version = "4.2.3", features = ["actix_extras"] }
utoipa = { version = "5.1.3", features = ["actix_extras", "chrono"] }
futures = "0.3.31"
utoipa-swagger-ui = {version = "7.1.0", features = ["actix-web"] }
utoipa-swagger-ui = {version = "8.0.3", features = ["actix-web"] }
clokwerk= "0.4.0"
tokio = {version = "1.40.0", features = ["full"]}
serde = "1.0.210"
Expand Down
3 changes: 2 additions & 1 deletion src/constants/inner_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ pub const TELEGRAM_BOT_TOKEN: &str = "TELEGRAM_BOT_TOKEN";
pub const TELEGRAM_BOT_CHAT_ID: &str = "TELEGRAM_BOT_CHAT_ID";
pub const TELEGRAM_API_ENABLED: &str = "TELEGRAM_API_ENABLED";

use utoipa::ToSchema;
// User management roles
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Debug, PartialEq, ToSchema)]
#[serde(rename_all = "lowercase")]
pub enum Role {
Admin,
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/notification_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use actix_web::web::Data;
use actix_web::{get, put, web, HttpResponse};
use std::ops::DerefMut;
use std::sync::Mutex;

use utoipa::ToSchema;
use crate::mutex::LockResultExt;
use crate::service::notification_service::NotificationService;
use crate::utils::error::{map_r2d2_error, CustomError};

use crate::models::notification::Notification;
#[utoipa::path(
context_path="/api/v1",
responses(
Expand All @@ -26,7 +26,7 @@ pub async fn get_unread_notifications(
Ok(HttpResponse::Ok().json(notifications))
}

#[derive(Deserialize)]
#[derive(Deserialize, ToSchema)]
pub struct NotificationId {
id: i32,
}
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/podcast_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub async fn search_podcasts(
#[utoipa::path(
context_path="/api/v1",
responses(
(status = 200, description = "Find a podcast by its collection id", body = [(Podcast, Tags)])
(status = 200, description = "Find a podcast by its collection id", body = [PodcastDto])
),
tag="podcasts"
)]
Expand Down Expand Up @@ -189,7 +189,7 @@ pub async fn find_all_podcasts(

Ok(HttpResponse::Ok().json(podcasts))
}

use crate::models::itunes_models::ItunesModel;
#[utoipa::path(
context_path="/api/v1",
responses(
Expand Down Expand Up @@ -738,6 +738,7 @@ use crate::models::tag::Tag;
use crate::controllers::podcast_episode_controller::EpisodeFormatDto;
use crate::controllers::server::ChatServerHandle;
use crate::controllers::websocket_controller::RSSAPiKey;
use crate::models::podcast_dto::PodcastDto;
use crate::models::podcast_settings::PodcastSetting;
use crate::models::settings::Setting;
use crate::models::tags_podcast::TagsPodcast;
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/podcast_episode_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::models::messages::BroadcastMessage;
use crate::models::podcast_episode::PodcastEpisode;
use crate::models::podcasts::Podcast;
use crate::models::user::User;

use utoipa::ToSchema;
use crate::service::mapping_service::MappingService;
use crate::service::podcast_episode_service::PodcastEpisodeService;
use crate::utils::error::{map_r2d2_error, CustomError};
Expand All @@ -29,7 +29,7 @@ pub struct OptionalId {

impl OptionalId {}

#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct PodcastEpisodeWithHistory {
pub podcast_episode: PodcastEpisode,
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/settings_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl From<UpdateNameSettings> for Setting {
}
}

#[derive(Deserialize, Clone)]
#[derive(Deserialize, Clone, ToSchema)]
#[serde(rename_all = "kebab-case")]
pub enum ReplacementStrategy {
ReplaceWithDashAndUnderscore,
Expand Down
81 changes: 73 additions & 8 deletions src/controllers/sys_info_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use actix_web::{web, HttpResponse, Responder};
use fs_extra::dir::get_size;
use sha256::digest;

use sysinfo::{Disks, System};
use sysinfo::{Disk, Disks, System};
pub mod built_info {
// The file has been placed there by the build script.
include!(concat!(env!("OUT_DIR"), "/built.rs"));
Expand All @@ -27,20 +27,17 @@ pub async fn get_sys_info() -> Result<HttpResponse, CustomError> {

let sim_disks = disks
.iter()
.map(|disk| SimplifiedDisk {
name: disk.name().to_str().unwrap().to_string(),
total_space: disk.total_space(),
available_space: disk.available_space(),
})
.map(|disk| disk.into())
.collect::<Vec<SimplifiedDisk>>();

sys.refresh_all();
sys.refresh_cpu_all();

const PATH: &str = "podcasts";
let podcast_byte_size =
get_size(PATH).map_err(|e| map_io_extra_error(e, Some(PATH.to_string())))?;
Ok(HttpResponse::Ok().json(SysExtraInfo {
system: sys,
system: sys.into(),
disks: sim_disks,
podcast_directory: podcast_byte_size,
}))
Expand All @@ -51,18 +48,86 @@ use utoipa::ToSchema;

#[derive(Debug, Serialize, ToSchema)]
pub struct SysExtraInfo {
pub system: System,
pub system: SystemDto,
pub disks: Vec<SimplifiedDisk>,
pub podcast_directory: u64,
}


impl From<System> for SystemDto {
fn from(sys: System) -> Self {
SystemDto {
mem_total: sys.total_memory(),
mem_available: sys.available_memory(),
swap_total: sys.total_swap(),
swap_used: sys.used_swap(),
cpus: CpusWrapperDto {
global: sys.global_cpu_usage(),
cpus: sys
.cpus()
.iter()
.map(|cpu| Cpu {
name: cpu.name().to_string(),
vendor_id: cpu.vendor_id().to_string(),
usage: CpuUsageDto {
percent: cpu.cpu_usage(),
},
brand: cpu.brand().to_string(),
frequency: cpu.frequency(),
})
.collect(),
},
}
}
}

#[derive(Debug, Serialize, ToSchema)]
pub struct SystemDto {
mem_total: u64,
mem_available: u64,
swap_total: u64,
swap_used: u64,
cpus: CpusWrapperDto,
}

#[derive(Debug, Serialize, ToSchema)]
pub struct CpusWrapperDto {
global: f32,
cpus: Vec<Cpu>
}

#[derive(Debug, Serialize, ToSchema)]
pub struct Cpu {
name: String,
vendor_id: String,
usage: CpuUsageDto,
brand: String,
frequency: u64,
}

#[derive(Debug, Serialize, ToSchema)]
pub struct CpuUsageDto {
percent: f32
}

#[derive(Debug, Serialize, ToSchema)]
pub struct SimplifiedDisk {
pub name: String,
pub total_space: u64,
pub available_space: u64,
}


impl From<&Disk> for SimplifiedDisk {
fn from(disk: &Disk) -> Self {
SimplifiedDisk {
name: disk.name().to_str().unwrap_or("").to_string(),
total_space: disk.total_space(),
available_space: disk.available_space(),
}
}
}

#[utoipa::path(
context_path="/api/v1",
responses(
Expand Down
1 change: 1 addition & 0 deletions src/controllers/user_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub async fn update_user(
Ok(HttpResponse::Ok().json(User::map_to_api_dto(user)))
}

use crate::models::invite::Invite;
#[utoipa::path(
context_path="/api/v1",
request_body=InvitePostModel,
Expand Down
3 changes: 2 additions & 1 deletion src/models/podcast_dto.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use utoipa::ToSchema;
use crate::models::tag::Tag;

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, ToSchema)]
pub struct PodcastDto {
pub(crate) id: i32,
pub(crate) name: String,
Expand Down
4 changes: 3 additions & 1 deletion src/models/podcast_rssadd_model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[derive(Debug, Serialize, Deserialize, Clone)]
use utoipa::ToSchema;

#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
pub struct PodcastRSSAddModel {
#[serde(rename = "rssFeedUrl")]
pub rss_feed_url: String,
Expand Down
11 changes: 8 additions & 3 deletions ui/src/models/SysInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export interface SysInfo {
nanos: number
},
global_cpu_usage: number
cpus: CPUModel[],
cpus: CPUModelAggregate,
physical_core_count: number,
total_memory: number,
free_memory: number,
mem_total: number,
mem_available: number,
used_memory: number,
total_swap: number,
free_swap: number,
Expand All @@ -29,6 +29,11 @@ export interface SysInfo {

}

type CPUModelAggregate = {
cpus: CPUModel[],
global: number
}


export interface ConfigModel {
podindexConfigured: boolean,
Expand Down
9 changes: 5 additions & 4 deletions ui/src/pages/SystemInfoPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const SystemInfoPage: FC = () => {
}
}


return (
<>
<Heading1 className="mb-10">{t('system-info')}</Heading1>
Expand All @@ -83,7 +84,7 @@ export const SystemInfoPage: FC = () => {
<Heading3>{t('cpu-usage')}</Heading3>
</span>

<CustomGaugeChart fill={['#10b981', '#064e3b']} labels={[t('used-cpu'), t('free-cpu')]} labelUnit="percent" max={100} value={systemInfo.system.global_cpu_usage} />
<CustomGaugeChart fill={['#10b981', '#064e3b']} labels={[t('used-cpu'), t('free-cpu')]} labelUnit="percent" max={100} value={systemInfo.system.cpus.global} />
</div>

{/* Memory */}
Expand All @@ -93,7 +94,7 @@ export const SystemInfoPage: FC = () => {
<Heading3>{t('memory-usage')}</Heading3>
</span>

<CustomGaugeChart fill={['#c4b5fd', '#6d28d9']} labels={[t('used-memory'), t('free-memory')]} labelUnit="capacity" max={systemInfo.system.total_memory} value={systemInfo.system.total_memory - systemInfo.system.free_memory} />
<CustomGaugeChart fill={['#c4b5fd', '#6d28d9']} labels={[t('used-memory'), t('free-memory')]} labelUnit="capacity" max={systemInfo.system.mem_total} value={systemInfo.system.mem_total - systemInfo.system.mem_available} />
</div>

{/* Disk */}
Expand All @@ -112,10 +113,10 @@ export const SystemInfoPage: FC = () => {

<dl className="grid lg:grid-cols-2 gap-2 lg:gap-6 text-sm">
<dt className="font-medium text-[--fg-color]">{t('cpu-brand')}</dt>
<dd className="text-[--fg-secondary-color]">{systemInfo.system.cpus[0].brand}</dd>
<dd className="text-[--fg-secondary-color]">{systemInfo.system.cpus.cpus[0].brand}</dd>

<dt className="font-medium text-[--fg-color]">{t('cpu-cores')}</dt>
<dd className="text-[--fg-secondary-color]">{systemInfo.system.cpus.length}</dd>
<dd className="text-[--fg-secondary-color]">{systemInfo.system.cpus.cpus.length}</dd>

<dt className="font-medium text-[--fg-color]">{t('podcast-size')}</dt>
<dd className="text-[--fg-secondary-color]">{calcPodcastSize()}</dd>
Expand Down

0 comments on commit cc8b737

Please sign in to comment.