mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat: add application url config to main settings ui
This commit is contained in:
@@ -54,8 +54,10 @@ components:
|
||||
apiKey:
|
||||
type: string
|
||||
example: 'anapikey'
|
||||
required:
|
||||
- apiKey
|
||||
readOnly: true
|
||||
applicationUrl:
|
||||
type: string
|
||||
example: https://os.example.com
|
||||
PlexLibrary:
|
||||
type: object
|
||||
properties:
|
||||
|
@@ -15,6 +15,7 @@ import logger from '../logger';
|
||||
import { scheduledJobs } from '../job/schedule';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import { isAuthenticated } from '../middleware/auth';
|
||||
import { merge } from 'lodash';
|
||||
|
||||
const settingsRoutes = Router();
|
||||
|
||||
@@ -27,7 +28,7 @@ settingsRoutes.get('/main', (_req, res) => {
|
||||
settingsRoutes.post('/main', (req, res) => {
|
||||
const settings = getSettings();
|
||||
|
||||
settings.main = req.body;
|
||||
settings.main = merge(settings.main, req.body);
|
||||
settings.save();
|
||||
|
||||
return res.status(200).json(settings.main);
|
||||
|
@@ -3,9 +3,21 @@ import useSWR from 'swr';
|
||||
import LoadingSpinner from '../Common/LoadingSpinner';
|
||||
import type { MainSettings } from '../../../server/lib/settings';
|
||||
import CopyButton from './CopyButton';
|
||||
import { Form, Formik, Field } from 'formik';
|
||||
import axios from 'axios';
|
||||
import Button from '../Common/Button';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
const messages = defineMessages({
|
||||
save: 'Save Changes',
|
||||
saving: 'Saving...',
|
||||
});
|
||||
|
||||
const SettingsMain: React.FC = () => {
|
||||
const { data, error } = useSWR<MainSettings>('/api/v1/settings/main');
|
||||
const intl = useIntl();
|
||||
const { data, error, revalidate } = useSWR<MainSettings>(
|
||||
'/api/v1/settings/main'
|
||||
);
|
||||
|
||||
if (!data && !error) {
|
||||
return <LoadingSpinner />;
|
||||
@@ -22,6 +34,26 @@ const SettingsMain: React.FC = () => {
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-6 sm:mt-5">
|
||||
<Formik
|
||||
initialValues={{
|
||||
apiKey: data?.apiKey,
|
||||
applicationUrl: data?.applicationUrl,
|
||||
}}
|
||||
onSubmit={async (values) => {
|
||||
try {
|
||||
await axios.post('/api/v1/settings/main', {
|
||||
applicationUrl: values.applicationUrl,
|
||||
});
|
||||
} catch (e) {
|
||||
// TODO show error
|
||||
} finally {
|
||||
revalidate();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{({ errors, touched, isSubmitting }) => {
|
||||
return (
|
||||
<Form>
|
||||
<div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5">
|
||||
<label
|
||||
htmlFor="username"
|
||||
@@ -56,6 +88,44 @@ const SettingsMain: React.FC = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-6 sm:mt-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:items-start sm:border-t sm:border-gray-800 sm:pt-5">
|
||||
<label
|
||||
htmlFor="name"
|
||||
className="block text-sm font-medium leading-5 text-gray-400 sm:mt-px sm:pt-2"
|
||||
>
|
||||
Application URL
|
||||
</label>
|
||||
<div className="mt-1 sm:mt-0 sm:col-span-2">
|
||||
<div className="max-w-lg flex rounded-md shadow-sm">
|
||||
<Field
|
||||
id="applicationUrl"
|
||||
name="applicationUrl"
|
||||
type="text"
|
||||
placeholder="https://os.example.com"
|
||||
className="flex-1 form-input block w-full min-w-0 rounded-md transition duration-150 ease-in-out sm:text-sm sm:leading-5 bg-gray-700 border border-gray-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-8 border-t border-gray-700 pt-5">
|
||||
<div className="flex justify-end">
|
||||
<span className="ml-3 inline-flex rounded-md shadow-sm">
|
||||
<Button
|
||||
buttonType="primary"
|
||||
type="submit"
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
{isSubmitting
|
||||
? intl.formatMessage(messages.saving)
|
||||
: intl.formatMessage(messages.save)}
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
}}
|
||||
</Formik>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
@@ -53,6 +53,15 @@ const SettingsNotifications: React.FC = ({ children }) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-6">
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-200">
|
||||
Notification Settings
|
||||
</h3>
|
||||
<p className="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
|
||||
Here you can pick and choose what types of notifications to send and
|
||||
through what types of services.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<div className="sm:hidden">
|
||||
<label htmlFor="tabs" className="sr-only">
|
||||
|
Reference in New Issue
Block a user