Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release #202

Merged
merged 17 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 🐛 Bug report
description: Report a problem
labels: ['type:bug', 'awaiting-triage']
labels: ['type:bug', 'awaiting triage']
body:
- type: input
id: version
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/enhancement.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ✨ Feature request
description: Suggest an enhancement, improvement or idea
labels: ['type:enhancement', 'awaiting-triage']
labels: ['type:enhancement', 'awaiting triage']
body:
- type: textarea
id: description
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ services:
container_name: plex-rewind
environment:
- NEXTAUTH_SECRET= # (required) used to encrypt auth JWT token, generate one with `openssl rand -base64 32`
- NEXTAUTH_URL=http://localhost:8383 # change to your domain if you are exposing the app to the internet
- NEXT_PUBLIC_SITE_URL=http://localhost:8383 # change to your domain if you are exposing the app to the internet
- NEXT_PUBLIC_STATISTICS_START_DATE=2018-01-01 # starting date for "all time" option (YYYY-MM-DD)
- NEXTAUTH_URL=http://localhost:8383 # (required) change to your domain if you are exposing the app to the internet
- NEXT_PUBLIC_SITE_URL=http://localhost:8383 # (required) change to your domain if you are exposing the app to the internet
- NEXT_PUBLIC_STATISTICS_START_DATE=2018-01-01 # (optional) starting date for "all time" option (YYYY-MM-DD)
volumes:
- ./config:/app/config
ports:
Expand All @@ -58,7 +58,11 @@ services:

Plex Rewind is available in the Community Apps store for Unraid. Search for "Plex Rewind" and install it from grtgbln's repository.

As noted in the installation instructions, you will need to download a copy of "settings.json" into the associated settings path **before** running the application. To download the file, you can open a terminal, enter the directory and run `curl -o settings.json https://raw.githubusercontent.com/RaunoT/plex-rewind/main/config/settings.example.json`.
As noted in the installation instructions, you will need to download a copy of `settings.json` into the associated settings path **before** running the application. To download the file, you can open a terminal, enter the directory and run the following command:

```sh
curl -o settings.json https://raw.githubusercontent.com/RaunoT/plex-rewind/main/config/settings.example.json
```

## Updating

Expand Down
8 changes: 5 additions & 3 deletions config/settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"connection": {
"tautulliUrl": "",
"tautulliApiKey": "",
"plexUrl": "",
"overseerrUrl": "",
"overseerrApiKey": "",
"tmdbApiKey": ""
"overseerrApiKey": ""
},
"features": {
"isRewindActive": true,
Expand All @@ -22,7 +22,9 @@
"activeDashboardTotalStatistics": ["size", "duration", "count", "requests"],
"dashboardDefaultPeriod": "custom",
"dashboardCustomPeriod": "30",
"googleAnalyticsId": ""
"googleAnalyticsId": "",
"isPostersTmdbOnly": false,
"isRewindLibrariesSizeAndCountActive": true
},
"test": false
}
50 changes: 23 additions & 27 deletions src/actions/update-connection-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const schema = z.object({
tautulliApiKey: z.string(),
overseerrUrl: z.string().url().optional().or(z.literal('')),
overseerrApiKey: z.string().optional(),
tmdbApiKey: z.string().optional(),
plexUrl: z.string().url(),
})

export async function saveConnectionSettings(
Expand All @@ -24,7 +24,7 @@ export async function saveConnectionSettings(
tautulliApiKey: formData.get('tautulliApiKey') as string,
overseerrUrl: formData.get('overseerrUrl') as string,
overseerrApiKey: formData.get('overseerrApiKey') as string,
tmdbApiKey: formData.get('tmdbApiKey') as string,
plexUrl: formData.get('plexUrl') as string,
}

try {
Expand All @@ -38,15 +38,19 @@ export async function saveConnectionSettings(
)

if (!res.ok) {
console.error('Error testing Tautulli connection!', res.status)
console.error(
'[CONFIG] - Error testing Tautulli connection!',
res.status,
res.statusText,
)
return {
message: 'Tautulli - invalid API key!',
status: 'error',
fields: data,
}
}
} catch (error) {
console.error('Error testing Tautulli connection!', error)
console.error('[CONFIG] - Error testing Tautulli connection!', error)
return {
message: 'Tautulli - unable to connect!',
status: 'error',
Expand All @@ -65,15 +69,19 @@ export async function saveConnectionSettings(
})

if (!res.ok) {
console.error('Error testing Overseerr connection!', res.status)
console.error(
'[CONFIG] - Error testing Overseerr connection!',
res.status,
res.statusText,
)
return {
message: 'Overseerr - invalid API key!',
status: 'error',
fields: data,
}
}
} catch (error) {
console.error('Error testing Overseerr connection!', error)
console.error('[CONFIG] - Error testing Overseerr connection!', error)
return {
message: 'Overseerr - unable to connect!',
status: 'error',
Expand All @@ -82,33 +90,21 @@ export async function saveConnectionSettings(
}
}

// Test TMDB
// Test Plex
try {
const res = await fetch(
`https://api.themoviedb.org/3/authentication?api_key=${data.tmdbApiKey}`,
{
cache: 'no-store',
},
)

if (!res.ok) {
console.error('Error testing TMDB connection!', res.status)
return {
message: 'TMDB - invalid API key!',
status: 'error',
fields: data,
}
}
await fetch(data.plexUrl, {
cache: 'no-store',
})
} catch (error) {
console.error('Error testing TMDB connection!', error)
console.error('[CONFIG] - Error testing Plex connection!', error)
return {
message: 'TMDB - unable to connect!',
message: 'Plex - unable to connect!',
status: 'error',
fields: data,
}
}
} catch (error) {
console.error('Error testing connection!', error)
console.error('[CONFIG] - Error testing connection!', error)
return {
message: 'Something went wrong!',
status: 'error',
Expand All @@ -118,7 +114,7 @@ export async function saveConnectionSettings(

// Save settings
try {
const settings = await getSettings()
const settings = getSettings()
schema.parse(data)
settings.connection = data
settings.test = true
Expand All @@ -133,7 +129,7 @@ export async function saveConnectionSettings(
fields: data,
}
} catch (error) {
console.error('Error writing to settings file!', error)
console.error('[CONFIG] - Error writing to settings file!', error)

if (error instanceof ZodError) {
return {
Expand Down
9 changes: 7 additions & 2 deletions src/actions/update-feature-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const schema = z.object({
},
),
googleAnalyticsId: z.string(),
isPostersTmdbOnly: z.boolean(),
isRewindLibrariesSizeAndCountActive: z.boolean(),
})

export async function saveFeaturesSettings(
Expand All @@ -50,11 +52,14 @@ export async function saveFeaturesSettings(
dashboardDefaultPeriod: formData.get('dashboardDefaultPeriod') as string,
dashboardCustomPeriod: formData.get('dashboardCustomPeriod') as string,
googleAnalyticsId: formData.get('googleAnalyticsId') as string,
isPostersTmdbOnly: formData.get('isPostersTmdbOnly') === 'on',
isRewindLibrariesSizeAndCountActive:
formData.get('isRewindLibrariesSizeAndCountActive') === 'on',
}

// Save settings
try {
const settings = await getSettings()
const settings = getSettings()

schema.parse(data)
settings.features = data
Expand All @@ -69,7 +74,7 @@ export async function saveFeaturesSettings(
fields: data,
}
} catch (error) {
console.error('Error writing to settings file!', error)
console.error('[CONFIG] - Error writing to settings file!', error)

if (error instanceof ZodError) {
return {
Expand Down
7 changes: 4 additions & 3 deletions src/app/_components/AppProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client'

import { Settings, Version } from '@/types'
import { checkRequiredSettings } from '@/utils/helpers'
import {
ArrowPathIcon,
CogIcon,
Expand Down Expand Up @@ -29,7 +30,7 @@ export default function AppProvider({ children, settings, version }: Props) {
setIsSettings(pathname.startsWith('/settings'))
}, [pathname])

if (!settings.test && pathname !== '/settings/connection') {
if (!checkRequiredSettings(settings) && pathname !== '/settings/connection') {
redirect('/settings/connection')
}

Expand All @@ -40,7 +41,7 @@ export default function AppProvider({ children, settings, version }: Props) {
{ 'justify-center': pathname === '/' },
)}
>
<div className='fixed inset-0 -z-10 overflow-hidden bg-black after:absolute after:inset-0 after:bg-black/50 after:content-[""]'>
<div className='fixed inset-0 -z-10 select-none overflow-hidden bg-black after:absolute after:inset-0 after:bg-black/50 after:content-[""]'>
<div className='relative h-screen w-screen'>
<Image
src={stars}
Expand All @@ -65,7 +66,7 @@ export default function AppProvider({ children, settings, version }: Props) {
<ArrowPathIcon className='size-6' />
</a>
)}
{settings.test && session?.user?.isAdmin && (
{checkRequiredSettings(settings) && session?.user?.isAdmin && (
<Link
href={isSettings ? '/' : '/settings/features'}
aria-label={isSettings ? 'Close settings' : 'Open settings'}
Expand Down
12 changes: 6 additions & 6 deletions src/app/_components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export default function Home({ settings }: Props) {
})

if (res?.error) {
console.error('Failed to sign in!', res.error)
console.error('[AUTH] - Failed to sign in!', res.error)
}

setIsLoading(false)
} catch (error) {
console.error('Error during sign-in!', error)
console.error('[AUTH] - Error during sign-in!', error)
setIsLoading(false)
}
}
Expand All @@ -70,7 +70,7 @@ export default function Home({ settings }: Props) {

setLibraries(data)
} catch (error) {
console.error('Error fetching libraries!', error)
console.error('[HOME] - Error fetching libraries!', error)
}

setIsLoading(false)
Expand All @@ -86,7 +86,7 @@ export default function Home({ settings }: Props) {

setManagedUsers(data)
} catch (error) {
console.error('Error fetching libraries!', error)
console.error('[HOME] - Error fetching managed users!', error)
}

setIsLoading(false)
Expand Down Expand Up @@ -118,7 +118,7 @@ export default function Home({ settings }: Props) {
</div>
)}

<h1 className='animate-fade-up animation-delay-300 mb-6 text-[2.5rem] font-bold leading-none'>
<h1 className='animate-fade-up mb-6 text-[2.5rem] font-bold leading-none animation-delay-300'>
<Image
src={plexSvg}
className='mb-0.5 mr-3 inline h-[2.25rem] w-auto'
Expand All @@ -128,7 +128,7 @@ export default function Home({ settings }: Props) {
<span>rewind</span>
</h1>

<div className='animate-fade-in animation-delay-600'>
<div className='animate-fade-in animation-delay-700'>
{!isLoggedIn && (
<button
className='button button-sm button--plex mx-auto'
Expand Down
2 changes: 1 addition & 1 deletion src/app/dashboard/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function DashboardContent({ params, searchParams }: Props) {
const library = libraries.find(
(library) => kebabCase(library.section_name) === params.slug,
)
const settings = await getSettings()
const settings = getSettings()

if (!library || !library.is_active) {
return notFound()
Expand Down
2 changes: 1 addition & 1 deletion src/app/dashboard/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = {

export default function Error({ error, reset }: Props) {
useEffect(() => {
console.error(error)
console.error('[DASHBOARD] - ', error)
}, [error])

return (
Expand Down
2 changes: 1 addition & 1 deletion src/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Props = {
}

export default async function DashboardLayout({ children }: Props) {
const settings = await getSettings()
const settings = getSettings()

if (!settings.features.isDashboardActive) {
return notFound()
Expand Down
4 changes: 2 additions & 2 deletions src/app/dashboard/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function getUsers(
return
}

const settings = await getSettings()
const settings = getSettings()
const [moviesLib, showsLib, audioLib] = await Promise.all([
getLibrariesByType('movie'),
getLibrariesByType('show'),
Expand Down Expand Up @@ -184,7 +184,7 @@ type Props = {
}

async function DashboardUsersContent({ searchParams }: Props) {
const settings = await getSettings()
const settings = getSettings()

if (!settings.features.isUsersPageActive) {
return notFound()
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Props = {
}

export default async function RootLayout({ children }: Props) {
const settings = await getSettings()
const settings = getSettings()
const version = await getVersion()

return (
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import getSettings from '@/utils/getSettings'
import { Suspense } from 'react'
import Home from './_components/Home'

export default async function HomePage() {
const settings = await getSettings()
export default function HomePage() {
const settings = getSettings()

return (
<Suspense>
Expand Down
4 changes: 2 additions & 2 deletions src/app/rewind/_components/RewindStat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function Loader() {
animate='show'
>
<span className='size-1 animate-pulse rounded-full bg-white'></span>
<span className='animation-delay-300 size-1 animate-pulse rounded-full bg-white'></span>
<span className='animation-delay-600 size-1 animate-pulse rounded-full bg-white'></span>
<span className='size-1 animate-pulse rounded-full bg-white animation-delay-300'></span>
<span className='size-1 animate-pulse rounded-full bg-white animation-delay-700'></span>
</motion.div>
)
}
Loading