fix(ui): Dynamically generate path to config in warning message (#851)

pull/842/head^2
TheCatLady 4 years ago committed by GitHub
parent e4f9b8a984
commit b531a642f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1479,14 +1479,14 @@ paths:
type: string type: string
/status/appdata: /status/appdata:
get: get:
summary: Get /app/data volume status summary: Get application data volume status
description: For Docker installs, returns whether or not the /app/data volume mount was configured properly. Always returns true for non-Docker installs. description: For Docker installs, returns whether or not the volume mount was configured properly. Always returns true for non-Docker installs.
security: [] security: []
tags: tags:
- public - public
responses: responses:
'200': '200':
description: /app/data volume status description: Application data volume status and path
content: content:
application/json: application/json:
schema: schema:
@ -1495,6 +1495,9 @@ paths:
appData: appData:
type: boolean type: boolean
example: true example: true
appDataPath:
type: string
example: /app/config
/settings/main: /settings/main:
get: get:
summary: Get main settings summary: Get main settings

@ -8,7 +8,9 @@ const UPDATE_INTERVAL_MSEC = 24 * 3600 * 1000; // how often to download new mapp
// originally at https://raw.githubusercontent.com/ScudLee/anime-lists/master/anime-list.xml // originally at https://raw.githubusercontent.com/ScudLee/anime-lists/master/anime-list.xml
const MAPPING_URL = const MAPPING_URL =
'https://raw.githubusercontent.com/Anime-Lists/anime-lists/master/anime-list.xml'; 'https://raw.githubusercontent.com/Anime-Lists/anime-lists/master/anime-list.xml';
const LOCAL_PATH = path.join(__dirname, '../../config/anime-list.xml'); const LOCAL_PATH = process.env.CONFIG_DIRECTORY
? `${process.env.CONFIG_DIRECTORY}/anime-list.xml`
: path.join(__dirname, '../../config/anime-list.xml');
const mappingRegexp = new RegExp(/;[0-9]+-([0-9]+)/g); const mappingRegexp = new RegExp(/;[0-9]+-([0-9]+)/g);

@ -15,7 +15,7 @@ import personRoutes from './person';
import collectionRoutes from './collection'; import collectionRoutes from './collection';
import { getAppVersion, getCommitTag } from '../utils/appVersion'; import { getAppVersion, getCommitTag } from '../utils/appVersion';
import serviceRoutes from './service'; import serviceRoutes from './service';
import { appDataStatus } from '../utils/appDataVolume'; import { appDataStatus, appDataPath } from '../utils/appDataVolume';
const router = Router(); const router = Router();
@ -31,6 +31,7 @@ router.get('/status', (req, res) => {
router.get('/status/appdata', (_req, res) => { router.get('/status/appdata', (_req, res) => {
return res.status(200).json({ return res.status(200).json({
appData: appDataStatus(), appData: appDataStatus(),
appDataPath: appDataPath(),
}); });
}); });

@ -1,8 +1,16 @@
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import path from 'path'; import path from 'path';
const DOCKER_PATH = path.join(__dirname, '../../config/DOCKER'); const CONFIG_PATH = process.env.CONFIG_DIRECTORY
? process.env.CONFIG_DIRECTORY
: path.join(__dirname, '../../config');
const DOCKER_PATH = `${CONFIG_PATH}/DOCKER`;
export const appDataStatus = (): boolean => { export const appDataStatus = (): boolean => {
return !existsSync(DOCKER_PATH); return !existsSync(DOCKER_PATH);
}; };
export const appDataPath = (): string => {
return CONFIG_PATH;
};

@ -6,12 +6,12 @@ import Alert from '../Common/Alert';
const messages = defineMessages({ const messages = defineMessages({
dockerVolumeMissing: 'Docker Volume Mount Missing', dockerVolumeMissing: 'Docker Volume Mount Missing',
dockerVolumeMissingDescription: dockerVolumeMissingDescription:
'The <code>/app/config</code> volume mount was not configured properly. All data will be cleared when the container is stopped or restarted.', 'The <code>{appDataPath}</code> volume mount was not configured properly. All data will be cleared when the container is stopped or restarted.',
}); });
const AppDataWarning: React.FC = () => { const AppDataWarning: React.FC = () => {
const intl = useIntl(); const intl = useIntl();
const { data, error } = useSWR<{ appData: boolean }>( const { data, error } = useSWR<{ appData: boolean; appDataPath: string }>(
'/api/v1/status/appdata' '/api/v1/status/appdata'
); );
@ -31,6 +31,7 @@ const AppDataWarning: React.FC = () => {
code: function code(msg) { code: function code(msg) {
return <code className="bg-opacity-50">{msg}</code>; return <code className="bg-opacity-50">{msg}</code>;
}, },
appDataPath: data.appDataPath,
})} })}
</Alert> </Alert>
)} )}

@ -1,6 +1,6 @@
{ {
"components.AppDataWarning.dockerVolumeMissing": "Docker Volume Mount Missing", "components.AppDataWarning.dockerVolumeMissing": "Docker Volume Mount Missing",
"components.AppDataWarning.dockerVolumeMissingDescription": "The <code>/app/config</code> volume mount was not configured properly. All data will be cleared when the container is stopped or restarted.", "components.AppDataWarning.dockerVolumeMissingDescription": "The <code>{appDataPath}</code> volume mount was not configured properly. All data will be cleared when the container is stopped or restarted.",
"components.CollectionDetails.movies": "Movies", "components.CollectionDetails.movies": "Movies",
"components.CollectionDetails.numberofmovies": "Number of Movies: {count}", "components.CollectionDetails.numberofmovies": "Number of Movies: {count}",
"components.CollectionDetails.overview": "Overview", "components.CollectionDetails.overview": "Overview",

Loading…
Cancel
Save