Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Apr 7, 2023
2 parents 448d27c + edbb541 commit b8e9936
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 11 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build release binaries

on:
workflow_dispatch:

jobs:
release:
name: release ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: tar.gz tar.xz tar.zst
- target: x86_64-apple-darwin
archive: zip
steps:
- uses: actions/checkout@master
- name: Compile and release
uses: rust-build/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ podcasts
static/*
.env

!static/default.jpg
!static/default.jpg
podcast.db-shm
podcast.db-wal
28 changes: 28 additions & 0 deletions src/config/dbconfig.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
use diesel::prelude::*;
use dotenvy::dotenv;
use std::env;
use std::time::Duration;
use diesel::connection::SimpleConnection;

#[derive(Debug)]
pub struct ConnectionOptions {
pub enable_wal: bool,
pub enable_foreign_keys: bool,
pub busy_timeout: Option<Duration>,
}

impl r2d2::CustomizeConnection<SqliteConnection, diesel::r2d2::Error>
for ConnectionOptions
{
fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), diesel::r2d2::Error> {
(|| {
if self.enable_wal {
conn.batch_execute("PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;")?;
}
if self.enable_foreign_keys {
conn.batch_execute("PRAGMA foreign_keys = ON;")?;
}
if let Some(d) = self.busy_timeout {
conn.batch_execute(&format!("PRAGMA busy_timeout = {};", d.as_millis()))?;
}
Ok(())
})()
.map_err(diesel::r2d2::Error::QueryError)
}
}
pub fn establish_connection() -> SqliteConnection {
dotenv().ok();
let database_url = &get_database_url();
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use r2d2::Pool;
use regex::Regex;

mod controllers;
use crate::config::dbconfig::{establish_connection, get_database_url};
use crate::config::dbconfig::{ConnectionOptions, establish_connection, get_database_url};
use crate::constants::constants::ERROR_LOGIN_MESSAGE;
use crate::controllers::api_doc::ApiDoc;
use crate::controllers::notification_controller::{
Expand Down Expand Up @@ -455,6 +455,11 @@ pub fn check_server_config(service1: EnvironmentService) {
async fn init_db_pool(database_url: &str)-> Result<Pool<ConnectionManager<SqliteConnection>>,
String> {
let manager = ConnectionManager::<SqliteConnection>::new(database_url);
let pool = Pool::new(manager).unwrap();
let pool = Pool::builder().max_size(16)
.connection_customizer(Box::new(ConnectionOptions {
enable_wal: true,
enable_foreign_keys: true,
busy_timeout: Some(Duration::from_secs(120)),
})).build(manager).unwrap();
Ok(pool)
}
6 changes: 4 additions & 2 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import {apiURL, configWSUrl, isJsonString} from "./utils/Utilities";
import {LoginComponent} from "./components/LoginComponent";
import {enqueueSnackbar} from "notistack";
import {useTranslation} from "react-i18next";


export const router = createBrowserRouter(createRoutesFromElements(
Expand Down Expand Up @@ -48,6 +49,7 @@ const App:FC<PropsWithChildren> = ({children}) => {
const podcasts = useAppSelector(state => state.common.podcasts)
const [socket, setSocket] = useState<any>()
const config = useAppSelector(state=>state.common.configModel)
const {t} = useTranslation()

useEffect(() => {
if(socket) {
Expand All @@ -64,10 +66,10 @@ const App:FC<PropsWithChildren> = ({children}) => {
if (checkIfPodcastAdded(parsed)) {
const podcast = parsed.podcast
dispatch(addPodcast(podcast))
enqueueSnackbar("New podcast added: " + podcast.name, {variant: "success"})
enqueueSnackbar(t('new-podcast-added',{name: podcast.name}), {variant: "success"})
} else if (checkIfPodcastEpisodeAdded(parsed)) {
if (store.getState().common.currentDetailedPodcastId === parsed.podcast_episode.podcast_id) {
enqueueSnackbar("New episode added: " + parsed.podcast_episode.name, {variant: "success"})
enqueueSnackbar(t('new-podcast-episode-added', {name: parsed.podcast_episode.name}), {variant: "success"})
const downloadedPodcastEpisode = parsed.podcast_episode
let res = store.getState().common.selectedEpisodes.find(p => p.id === downloadedPodcastEpisode.id)
if (res == undefined) {
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/AddPodcast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const AddPodcast = ()=>{
content: files[0].content
})
.then((v)=>{

console.log(v)
})
.catch((e)=>{
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/I18nDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const Dropdown = ()=>{
value={language}>
<option value="de-DE">Deutsch</option>
<option value="en">English</option>
</select></>
<option value="fr">Français</option>
</select></>
}
5 changes: 4 additions & 1 deletion ui/src/language/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import {initReactI18next} from "react-i18next";
import LanguageDetector from 'i18next-browser-languagedetector'
import de_translation from './json/de.json'
import en_translation from './json/en.json'

import fr_translation from './json/fr.json'

const resources = {
de: {
translation:de_translation
},
en:{
translation: en_translation
},
fr:{
translation: fr_translation
}
}

Expand Down
5 changes: 4 additions & 1 deletion ui/src/language/json/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@
"upload-opml": "OPML-Datei hochladen",
"logout": "Abmelden",
"oidc-login": "OIDC Login",
"settings-saved": "Einstellungen gespeichert"
"settings-saved": "Einstellungen gespeichert",
"new-podcast-added": "Neuer Podcast {{name}} hinzugefügt",
"new-podcast-episode-added": "Neue Episode {{name}} hinzugefügt",
"error-occured": "Ein Fehler ist aufgetreten"
}
5 changes: 4 additions & 1 deletion ui/src/language/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@
"upload-opml": "Upload OPML",
"logout": "Logout",
"oidc-login": "OIDC Login",
"settings-saved": "Settings saved"
"settings-saved": "Settings saved",
"new-podcast-added": "New podcast {{name}} added",
"new-podcast-episode-added": "New episode {{name}} added",
"error-occured": "An error has occurred"
}
55 changes: 55 additions & 0 deletions ui/src/language/json/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"homepage" : "Page d'accueil",
"podcasts" : "Podcast",
"last-listened" : "Récemment écouté",
"no-notifications" : "Pas de notifications",
"download-computer" : "Télécharger sur l'ordinateur",
"download-to-server" : "Télécharger sur le serveur",
"cpu-info" : "Info CPU",
"cpu-brand" : "Marque du processeur",
"cpu-cores" : "Noyaux de CPU",
"podcast-size" : "Taille du répertoire podcast",
"cpu-usage" : "Utilisation du CPU",
"used-cpu" : "CPU utilisé",
"free-cpu" : "CPU libre",
"memory-usage" : "Utilisation de la mémoire",
"used-memory" : "Mémoire utilisée",
"loading" : "Chargement",
"free-memory" : "Mémoire libre",
"disk-usage" : "Utilisation du disque dur",
"used-disk" : "Disque dur utilisé",
"free-disk" : "Disque dur libre",
"info" : "Info",
"add-podcast" : "Ajouter un podcast",
"search-podcast" : "Rechercher un podcast",
"favorites" : "Favoris",
"show-more" : "Afficher plus",
"show-less" : "Afficher moins",
"settings" : "Paramètres",
"auto-cleanup" : "Nettoyage automatique",
"days-to-keep" : "Jours à conserver",
"auto-update" : "Mise à jour automatique des podcasts",
"auto-download" : "Téléchargement automatique d'épisodes de podcasts",
"save" : "Enregistrer",
"active" : "Actif",
"run-cleanup" : "Exécuter le nettoyage maintenant",
"podindex-configured" : "Podindex configuré",
"podfetch-status" : "État de configuration de Podfetch",
"rss-feed" : "Flux RSS",
"sign-in-to-podfetch" : "Se connecter à Podfetch",
"error-authenticating" : "Erreur de connexion",
"your-username" : "Votre nom d'utilisateur",
"username" : "Nom d'utilisateur",
"password" : "Mot de passe",
"remember-me" : "Se souvenir du compte",
"sign-in" : "Se connecter",
"drag-here" : "Glisser ici",
"following-file-uploaded" : "Le fichier suivant sera téléchargé :",
"upload-opml" : "Télécharger le fichier OPML",
"logout" : "Déconnexion",
"oidc-login" : "Connexion OIDC",
"settings-saved" : "Paramètres sauvegardés",
"new-podcast-added" : "nouveau podcast {{nom}} ajouté",
"new-podcast-episode-added" : "Nouvel épisode {{nom}} ajouté",
"error-occured" : "Une erreur est survenue"
}
5 changes: 3 additions & 2 deletions ui/src/pages/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {apiURL} from "../utils/Utilities";
import axios, {AxiosResponse} from "axios";
import {Setting} from "../models/Setting";
import {useSnackbar} from "notistack";
import {Loading} from "../components/Loading";

export const SettingsPage = () => {
const {t} = useTranslation()
Expand All @@ -17,13 +18,13 @@ export const SettingsPage = () => {
},[])

if(settings===undefined){
return <div>Loading...</div>
return <Loading/>
}


return (
<div className="p-6">
<h1 className="text-2xl text-center font-bold">Settings</h1>
<h1 className="text-2xl text-center font-bold">{t('settings')}</h1>

<div className="bg-slate-900 rounded p-5 text-white">
<div className="grid grid-cols-2 gap-5">
Expand Down

0 comments on commit b8e9936

Please sign in to comment.