2025-02-21 14:15:25 -09:00
|
|
|
import React, { useEffect, useState } from 'react'
|
2020-09-30 16:36:51 -08:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Link from '@material-ui/core/Link'
|
|
|
|
|
import Dialog from '@material-ui/core/Dialog'
|
|
|
|
|
import IconButton from '@material-ui/core/IconButton'
|
|
|
|
|
import TableContainer from '@material-ui/core/TableContainer'
|
|
|
|
|
import Table from '@material-ui/core/Table'
|
|
|
|
|
import TableBody from '@material-ui/core/TableBody'
|
|
|
|
|
import TableRow from '@material-ui/core/TableRow'
|
|
|
|
|
import TableCell from '@material-ui/core/TableCell'
|
|
|
|
|
import Paper from '@material-ui/core/Paper'
|
|
|
|
|
import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder'
|
2025-03-10 10:50:16 -08:00
|
|
|
import { humanize, underscore } from 'inflection'
|
2024-12-17 13:10:55 -09:00
|
|
|
import { useGetOne, usePermissions, useTranslate } from 'react-admin'
|
2020-09-30 16:36:51 -08:00
|
|
|
import config from '../config'
|
2021-02-03 15:08:03 -09:00
|
|
|
import { DialogTitle } from './DialogTitle'
|
|
|
|
|
import { DialogContent } from './DialogContent'
|
2024-12-17 13:10:55 -09:00
|
|
|
import { INSIGHTS_DOC_URL } from '../consts.js'
|
2025-02-21 14:15:25 -09:00
|
|
|
import subsonic from '../subsonic/index.js'
|
|
|
|
|
import { Typography } from '@material-ui/core'
|
2020-09-30 16:36:51 -08:00
|
|
|
|
|
|
|
|
const links = {
|
|
|
|
|
homepage: 'navidrome.org',
|
|
|
|
|
reddit: 'reddit.com/r/Navidrome',
|
|
|
|
|
twitter: 'twitter.com/navidrome',
|
|
|
|
|
discord: 'discord.gg/xh7j7yF',
|
|
|
|
|
source: 'github.com/navidrome/navidrome',
|
2023-03-08 08:41:51 -09:00
|
|
|
bugReports: 'github.com/navidrome/navidrome/issues/new/choose',
|
|
|
|
|
featureRequests: 'github.com/navidrome/navidrome/discussions/new',
|
2020-09-30 16:36:51 -08:00
|
|
|
}
|
|
|
|
|
|
2021-03-22 19:34:34 -08:00
|
|
|
const LinkToVersion = ({ version }) => {
|
|
|
|
|
if (version === 'dev') {
|
2025-02-21 14:15:25 -09:00
|
|
|
return <>{version}</>
|
2021-03-22 19:34:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const parts = version.split(' ')
|
|
|
|
|
const commitID = parts[1].replace(/[()]/g, '')
|
|
|
|
|
const isSnapshot = version.includes('SNAPSHOT')
|
|
|
|
|
const url = isSnapshot
|
|
|
|
|
? `https://github.com/navidrome/navidrome/compare/v${
|
|
|
|
|
parts[0].split('-')[0]
|
|
|
|
|
}...${commitID}`
|
|
|
|
|
: `https://github.com/navidrome/navidrome/releases/tag/v${parts[0]}`
|
|
|
|
|
return (
|
2025-02-21 14:15:25 -09:00
|
|
|
<>
|
2021-03-22 19:34:34 -08:00
|
|
|
<Link href={url} target="_blank" rel="noopener noreferrer">
|
|
|
|
|
{parts[0]}
|
|
|
|
|
</Link>
|
|
|
|
|
{' (' + commitID + ')'}
|
2025-02-21 14:15:25 -09:00
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ShowVersion = ({ uiVersion, serverVersion }) => {
|
|
|
|
|
const translate = useTranslate()
|
|
|
|
|
|
|
|
|
|
const showRefresh = uiVersion !== serverVersion
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<TableRow>
|
|
|
|
|
<TableCell align="right" component="th" scope="row">
|
|
|
|
|
{translate('menu.version')}:
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell align="left">
|
|
|
|
|
<LinkToVersion version={serverVersion} />
|
|
|
|
|
</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
{showRefresh && (
|
|
|
|
|
<TableRow>
|
|
|
|
|
<TableCell align="right" component="th" scope="row">
|
|
|
|
|
UI {translate('menu.version')}:
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell align="left">
|
|
|
|
|
<LinkToVersion version={uiVersion} />
|
|
|
|
|
<Link onClick={() => window.location.reload()}>
|
|
|
|
|
<Typography variant={'caption'}>
|
|
|
|
|
{' ' + translate('ra.notification.new_version')}
|
|
|
|
|
</Typography>
|
|
|
|
|
</Link>
|
|
|
|
|
</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2021-03-22 19:34:34 -08:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 16:36:51 -08:00
|
|
|
const AboutDialog = ({ open, onClose }) => {
|
|
|
|
|
const translate = useTranslate()
|
2024-12-17 13:10:55 -09:00
|
|
|
const { permissions } = usePermissions()
|
|
|
|
|
const { data, loading } = useGetOne('insights', 'insights_status')
|
2025-02-21 14:15:25 -09:00
|
|
|
const [serverVersion, setServerVersion] = useState('')
|
|
|
|
|
const uiVersion = config.version
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
subsonic
|
|
|
|
|
.ping()
|
|
|
|
|
.then((resp) => resp.json['subsonic-response'])
|
|
|
|
|
.then((data) => {
|
|
|
|
|
if (data.status === 'ok') {
|
|
|
|
|
setServerVersion(data.serverVersion)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((e) => {
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.error('error pinging server', e)
|
|
|
|
|
})
|
|
|
|
|
}, [setServerVersion])
|
2024-12-17 13:10:55 -09:00
|
|
|
|
2024-12-19 13:21:08 -09:00
|
|
|
const lastRun = !loading && data?.lastRun
|
|
|
|
|
let insightsStatus = 'N/A'
|
|
|
|
|
if (lastRun === 'disabled') {
|
|
|
|
|
insightsStatus = translate('about.links.insights.disabled')
|
|
|
|
|
} else if (lastRun && lastRun?.startsWith('1969-12-31')) {
|
|
|
|
|
insightsStatus = translate('about.links.insights.waiting')
|
|
|
|
|
} else if (lastRun) {
|
|
|
|
|
insightsStatus = lastRun
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 16:36:51 -08:00
|
|
|
return (
|
2023-05-17 11:48:22 -08:00
|
|
|
<Dialog onClose={onClose} aria-labelledby="about-dialog-title" open={open}>
|
2020-10-02 08:18:00 -08:00
|
|
|
<DialogTitle id="about-dialog-title" onClose={onClose}>
|
2020-09-30 16:36:51 -08:00
|
|
|
Navidrome Music Server
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
<DialogContent dividers>
|
|
|
|
|
<TableContainer component={Paper}>
|
2021-02-03 15:08:03 -09:00
|
|
|
<Table aria-label={translate('menu.about')} size="small">
|
2020-09-30 16:36:51 -08:00
|
|
|
<TableBody>
|
2025-02-21 14:15:25 -09:00
|
|
|
<ShowVersion
|
|
|
|
|
uiVersion={uiVersion}
|
|
|
|
|
serverVersion={serverVersion}
|
|
|
|
|
/>
|
2020-09-30 16:36:51 -08:00
|
|
|
{Object.keys(links).map((key) => {
|
|
|
|
|
return (
|
|
|
|
|
<TableRow key={key}>
|
|
|
|
|
<TableCell align="right" component="th" scope="row">
|
|
|
|
|
{translate(`about.links.${key}`, {
|
2025-03-10 10:50:16 -08:00
|
|
|
_: humanize(underscore(key)),
|
2020-09-30 16:36:51 -08:00
|
|
|
})}
|
|
|
|
|
:
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell align="left">
|
|
|
|
|
<Link
|
|
|
|
|
href={`https://${links[key]}`}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
>
|
|
|
|
|
{links[key]}
|
|
|
|
|
</Link>
|
|
|
|
|
</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
)
|
|
|
|
|
})}
|
2024-12-17 13:10:55 -09:00
|
|
|
{permissions === 'admin' ? (
|
|
|
|
|
<TableRow>
|
|
|
|
|
<TableCell align="right" component="th" scope="row">
|
|
|
|
|
{translate(`about.links.lastInsightsCollection`)}:
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell align="left">
|
2024-12-19 13:21:08 -09:00
|
|
|
<Link href={INSIGHTS_DOC_URL}>{insightsStatus}</Link>
|
2024-12-17 13:10:55 -09:00
|
|
|
</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
) : null}
|
2020-09-30 16:36:51 -08:00
|
|
|
<TableRow>
|
|
|
|
|
<TableCell align="right" component="th" scope="row">
|
|
|
|
|
<Link
|
|
|
|
|
href={'https://github.com/sponsors/deluan'}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
>
|
|
|
|
|
<IconButton size={'small'}>
|
|
|
|
|
<FavoriteBorderIcon fontSize={'small'} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Link>
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell align="left">
|
|
|
|
|
<Link
|
|
|
|
|
href={'https://ko-fi.com/deluan'}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
>
|
|
|
|
|
ko-fi.com/deluan
|
|
|
|
|
</Link>
|
|
|
|
|
</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
</TableBody>
|
|
|
|
|
</Table>
|
|
|
|
|
</TableContainer>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AboutDialog.propTypes = {
|
|
|
|
|
open: PropTypes.bool.isRequired,
|
|
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 19:34:34 -08:00
|
|
|
export { AboutDialog, LinkToVersion }
|