feat(ui): make need for refresh more visible when upgrading server
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import Link from '@material-ui/core/Link'
|
import Link from '@material-ui/core/Link'
|
||||||
import Dialog from '@material-ui/core/Dialog'
|
import Dialog from '@material-ui/core/Dialog'
|
||||||
@@ -16,6 +16,8 @@ import config from '../config'
|
|||||||
import { DialogTitle } from './DialogTitle'
|
import { DialogTitle } from './DialogTitle'
|
||||||
import { DialogContent } from './DialogContent'
|
import { DialogContent } from './DialogContent'
|
||||||
import { INSIGHTS_DOC_URL } from '../consts.js'
|
import { INSIGHTS_DOC_URL } from '../consts.js'
|
||||||
|
import subsonic from '../subsonic/index.js'
|
||||||
|
import { Typography } from '@material-ui/core'
|
||||||
|
|
||||||
const links = {
|
const links = {
|
||||||
homepage: 'navidrome.org',
|
homepage: 'navidrome.org',
|
||||||
@@ -29,7 +31,7 @@ const links = {
|
|||||||
|
|
||||||
const LinkToVersion = ({ version }) => {
|
const LinkToVersion = ({ version }) => {
|
||||||
if (version === 'dev') {
|
if (version === 'dev') {
|
||||||
return <TableCell align="left">{version}</TableCell>
|
return <>{version}</>
|
||||||
}
|
}
|
||||||
|
|
||||||
const parts = version.split(' ')
|
const parts = version.split(' ')
|
||||||
@@ -41,12 +43,46 @@ const LinkToVersion = ({ version }) => {
|
|||||||
}...${commitID}`
|
}...${commitID}`
|
||||||
: `https://github.com/navidrome/navidrome/releases/tag/v${parts[0]}`
|
: `https://github.com/navidrome/navidrome/releases/tag/v${parts[0]}`
|
||||||
return (
|
return (
|
||||||
<TableCell align="left">
|
<>
|
||||||
<Link href={url} target="_blank" rel="noopener noreferrer">
|
<Link href={url} target="_blank" rel="noopener noreferrer">
|
||||||
{parts[0]}
|
{parts[0]}
|
||||||
</Link>
|
</Link>
|
||||||
{' (' + commitID + ')'}
|
{' (' + commitID + ')'}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
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>
|
||||||
|
<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>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +90,23 @@ const AboutDialog = ({ open, onClose }) => {
|
|||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
const { permissions } = usePermissions()
|
const { permissions } = usePermissions()
|
||||||
const { data, loading } = useGetOne('insights', 'insights_status')
|
const { data, loading } = useGetOne('insights', 'insights_status')
|
||||||
|
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])
|
||||||
|
|
||||||
const lastRun = !loading && data?.lastRun
|
const lastRun = !loading && data?.lastRun
|
||||||
let insightsStatus = 'N/A'
|
let insightsStatus = 'N/A'
|
||||||
@@ -74,12 +127,10 @@ const AboutDialog = ({ open, onClose }) => {
|
|||||||
<TableContainer component={Paper}>
|
<TableContainer component={Paper}>
|
||||||
<Table aria-label={translate('menu.about')} size="small">
|
<Table aria-label={translate('menu.about')} size="small">
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow>
|
<ShowVersion
|
||||||
<TableCell align="right" component="th" scope="row">
|
uiVersion={uiVersion}
|
||||||
{translate('menu.version')}:
|
serverVersion={serverVersion}
|
||||||
</TableCell>
|
/>
|
||||||
<LinkToVersion version={config.version} />
|
|
||||||
</TableRow>
|
|
||||||
{Object.keys(links).map((key) => {
|
{Object.keys(links).map((key) => {
|
||||||
return (
|
return (
|
||||||
<TableRow key={key}>
|
<TableRow key={key}>
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ import { LinkToVersion } from './AboutDialog'
|
|||||||
import TableBody from '@material-ui/core/TableBody'
|
import TableBody from '@material-ui/core/TableBody'
|
||||||
import TableRow from '@material-ui/core/TableRow'
|
import TableRow from '@material-ui/core/TableRow'
|
||||||
import Table from '@material-ui/core/Table'
|
import Table from '@material-ui/core/Table'
|
||||||
|
import TableCell from '@material-ui/core/TableCell'
|
||||||
|
|
||||||
const Wrapper = ({ version }) => (
|
const Wrapper = ({ version }) => (
|
||||||
<Table>
|
<Table>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
<TableCell>
|
||||||
<LinkToVersion version={version} />
|
<LinkToVersion version={version} />
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ const url = (command, id, options) => {
|
|||||||
return `/rest/${command}?${params.toString()}`
|
return `/rest/${command}?${params.toString()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ping = () => httpClient(url('ping'))
|
||||||
|
|
||||||
const scrobble = (id, time, submission = true) =>
|
const scrobble = (id, time, submission = true) =>
|
||||||
httpClient(
|
httpClient(
|
||||||
url('scrobble', id, {
|
url('scrobble', id, {
|
||||||
@@ -88,6 +90,7 @@ const streamUrl = (id, options) => {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
url,
|
url,
|
||||||
|
ping,
|
||||||
scrobble,
|
scrobble,
|
||||||
nowPlaying,
|
nowPlaying,
|
||||||
download,
|
download,
|
||||||
|
|||||||
Reference in New Issue
Block a user