|
|
@ -1,11 +1,11 @@
|
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { NextPage } from "next";
|
|
|
|
import { NextPage } from "next";
|
|
|
|
import { NextSeo } from "next-seo";
|
|
|
|
import { NextSeo } from "next-seo";
|
|
|
|
|
|
|
|
|
|
|
|
import { FC, useState } from "react";
|
|
|
|
import { FC, useState } from "react";
|
|
|
|
|
|
|
|
|
|
|
|
import { useQuery } from "react-query";
|
|
|
|
import { useMutation, useQuery } from "react-query";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
|
|
|
|
import Box from "@mui/material/Box";
|
|
|
|
import Box from "@mui/material/Box";
|
|
|
|
import Button from "@mui/material/Button";
|
|
|
|
import Button from "@mui/material/Button";
|
|
|
@ -18,104 +18,35 @@ import InputLabel from "@mui/material/InputLabel";
|
|
|
|
import MenuItem from "@mui/material/MenuItem";
|
|
|
|
import MenuItem from "@mui/material/MenuItem";
|
|
|
|
import Modal from "@mui/material/Modal";
|
|
|
|
import Modal from "@mui/material/Modal";
|
|
|
|
import Select from "@mui/material/Select";
|
|
|
|
import Select from "@mui/material/Select";
|
|
|
|
|
|
|
|
import TextField from "@mui/material/TextField";
|
|
|
|
import Typography from "@mui/material/Typography";
|
|
|
|
import Typography from "@mui/material/Typography";
|
|
|
|
import {
|
|
|
|
import { red, green } from "@mui/material/colors/";
|
|
|
|
blue,
|
|
|
|
|
|
|
|
red,
|
|
|
|
|
|
|
|
green,
|
|
|
|
|
|
|
|
cyan,
|
|
|
|
|
|
|
|
purple,
|
|
|
|
|
|
|
|
yellow,
|
|
|
|
|
|
|
|
orange
|
|
|
|
|
|
|
|
} from "@mui/material/colors/";
|
|
|
|
|
|
|
|
import { useTheme } from "@mui/material/styles/";
|
|
|
|
import { useTheme } from "@mui/material/styles/";
|
|
|
|
|
|
|
|
|
|
|
|
import Done from "@mui/icons-material/Done";
|
|
|
|
import Done from "@mui/icons-material/Done";
|
|
|
|
import Error from "@mui/icons-material/Error";
|
|
|
|
import Error from "@mui/icons-material/Error";
|
|
|
|
|
|
|
|
import Refresh from "@mui/icons-material/Refresh";
|
|
|
|
import { toCamelCase } from "@src/utils";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
ServerInstance,
|
|
|
|
ServerInstance,
|
|
|
|
ServerInstanceType,
|
|
|
|
ServerInstanceType,
|
|
|
|
Stats
|
|
|
|
Stats
|
|
|
|
} from "@interfaces/api/instances";
|
|
|
|
} from "@interfaces/api/instances";
|
|
|
|
|
|
|
|
import { StorageType } from "@interfaces/settings";
|
|
|
|
|
|
|
|
|
|
|
|
import { useSettings } from "@utils/hooks";
|
|
|
|
import { useSettings } from "@utils/hooks";
|
|
|
|
|
|
|
|
|
|
|
|
import Layout from "@components/Layout";
|
|
|
|
import Layout from "@components/Layout";
|
|
|
|
|
|
|
|
import MaterialColorPicker from "@components/MaterialColorPicker";
|
|
|
|
|
|
|
|
import ColorBox from "@components/MaterialColorPicker/ColorBox";
|
|
|
|
|
|
|
|
import ModalBox from "@components/ModalBox";
|
|
|
|
|
|
|
|
|
|
|
|
const Settings: NextPage = () => {
|
|
|
|
const InfoModal: FC<{
|
|
|
|
const [settings, setSettings] = useSettings();
|
|
|
|
modalIsOpen: boolean;
|
|
|
|
|
|
|
|
setModalState: (isOpen: boolean) => void;
|
|
|
|
const setSetting = (key: string, value?: string): void => {
|
|
|
|
data: Stats;
|
|
|
|
setSettings({ ...settings, [key]: value });
|
|
|
|
}> = ({ modalIsOpen, setModalState, data }) => {
|
|
|
|
};
|
|
|
|
const [settings] = useSettings();
|
|
|
|
|
|
|
|
|
|
|
|
const [modalIsOpen, setModalState] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const instances = useQuery<[string, ServerInstance][]>(
|
|
|
|
|
|
|
|
"invidiousInstances",
|
|
|
|
|
|
|
|
() =>
|
|
|
|
|
|
|
|
axios
|
|
|
|
|
|
|
|
.get("https://api.invidious.io/instances.json")
|
|
|
|
|
|
|
|
.then((res) => res.data),
|
|
|
|
|
|
|
|
{ retry: false }
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const invidiousServerResponse = useQuery<Stats>("invidiousInstance", () =>
|
|
|
|
|
|
|
|
axios
|
|
|
|
|
|
|
|
.get(`https://${settings.invidiousServer}/api/v1/stats`)
|
|
|
|
|
|
|
|
.then((res) => res.data)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ColorSetting: FC<{ type: string }> = ({ type }) => {
|
|
|
|
|
|
|
|
const camelCase = toCamelCase(type) as "primaryColor" | "accentColor";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<Box sx={{ my: 3, display: "flex" }}>
|
|
|
|
|
|
|
|
<Typography variant="h5" sx={{ flexGrow: 1 }}>
|
|
|
|
|
|
|
|
{type}
|
|
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
{[
|
|
|
|
|
|
|
|
blue[800],
|
|
|
|
|
|
|
|
red[800],
|
|
|
|
|
|
|
|
green[800],
|
|
|
|
|
|
|
|
cyan[800],
|
|
|
|
|
|
|
|
purple[800],
|
|
|
|
|
|
|
|
yellow[800],
|
|
|
|
|
|
|
|
orange[800]
|
|
|
|
|
|
|
|
].map((color) => (
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
|
|
|
onClick={() => setSetting(camelCase, color)}
|
|
|
|
|
|
|
|
key={color}
|
|
|
|
|
|
|
|
component="span"
|
|
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
|
|
width: 24,
|
|
|
|
|
|
|
|
height: 24,
|
|
|
|
|
|
|
|
backgroundColor: color,
|
|
|
|
|
|
|
|
borderRadius: "50%",
|
|
|
|
|
|
|
|
border:
|
|
|
|
|
|
|
|
color == settings[camelCase]
|
|
|
|
|
|
|
|
? {
|
|
|
|
|
|
|
|
borderColor: theme.palette.text.primary,
|
|
|
|
|
|
|
|
borderWidth: 1,
|
|
|
|
|
|
|
|
borderStyle: "solid"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
|
|
|
ml: 1.5
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const InfoModal: FC = () => {
|
|
|
|
|
|
|
|
const data = invidiousServerResponse.data!;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const lastUpdated = new Date(data.metadata.updatedAt * 1000);
|
|
|
|
const lastUpdated = new Date(data.metadata.updatedAt * 1000);
|
|
|
|
|
|
|
|
|
|
|
@ -123,21 +54,10 @@ const Settings: NextPage = () => {
|
|
|
|
<Modal
|
|
|
|
<Modal
|
|
|
|
open={modalIsOpen}
|
|
|
|
open={modalIsOpen}
|
|
|
|
onClose={() => setModalState(false)}
|
|
|
|
onClose={() => setModalState(false)}
|
|
|
|
aria-labelledby="modal-modal-title"
|
|
|
|
aria-labelledby="stats-modal"
|
|
|
|
aria-describedby="modal-modal-description"
|
|
|
|
aria-describedby="Shows server stats"
|
|
|
|
>
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
|
|
p: 4,
|
|
|
|
|
|
|
|
position: "absolute",
|
|
|
|
|
|
|
|
left: "50%",
|
|
|
|
|
|
|
|
top: "50%",
|
|
|
|
|
|
|
|
transform: "translate(-50%, -50%)",
|
|
|
|
|
|
|
|
backgroundColor: theme.palette.background.paper,
|
|
|
|
|
|
|
|
borderRadius: 1,
|
|
|
|
|
|
|
|
outline: "none"
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
|
|
|
|
<ModalBox>
|
|
|
|
<Typography id="modal-modal-title" variant="h4">
|
|
|
|
<Typography id="modal-modal-title" variant="h4">
|
|
|
|
Stats for {settings.invidiousServer}
|
|
|
|
Stats for {settings.invidiousServer}
|
|
|
|
</Typography>
|
|
|
|
</Typography>
|
|
|
@ -146,22 +66,71 @@ const Settings: NextPage = () => {
|
|
|
|
Software name: {data.software.name} <br />
|
|
|
|
Software name: {data.software.name} <br />
|
|
|
|
Software version: {data.software.version} <br />
|
|
|
|
Software version: {data.software.version} <br />
|
|
|
|
Software branch: {data.software.branch} <br /> <br />
|
|
|
|
Software branch: {data.software.branch} <br /> <br />
|
|
|
|
Is accepting registrations: {data.openRegistrations
|
|
|
|
Is accepting registrations: {data.openRegistrations ? "Yes" : "No"}
|
|
|
|
? "Yes"
|
|
|
|
|
|
|
|
: "No"}{" "}
|
|
|
|
|
|
|
|
<br /> <br />
|
|
|
|
<br /> <br />
|
|
|
|
Total users: {data.usage.users.total} <br />
|
|
|
|
Total users: {data.usage.users.total} <br />
|
|
|
|
Active in the past half year: {data.usage.users.activeHalfyear}
|
|
|
|
Active in the past half year: {data.usage.users.activeHalfyear}
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
Active in the past month: {data.usage.users.activeMonth} <br />{" "}
|
|
|
|
Active in the past month: {data.usage.users.activeMonth} <br /> <br />
|
|
|
|
<br />
|
|
|
|
|
|
|
|
Stats updated at: {lastUpdated.toLocaleDateString()} -{" "}
|
|
|
|
Stats updated at: {lastUpdated.toLocaleDateString()} -{" "}
|
|
|
|
{lastUpdated.toLocaleTimeString()}
|
|
|
|
{lastUpdated.toLocaleTimeString()}
|
|
|
|
</Typography>
|
|
|
|
</Typography>
|
|
|
|
</Box>
|
|
|
|
</ModalBox>
|
|
|
|
</Modal>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Setting: FC<{ title: string; description?: string }> = ({
|
|
|
|
|
|
|
|
title,
|
|
|
|
|
|
|
|
children,
|
|
|
|
|
|
|
|
description
|
|
|
|
|
|
|
|
}) => {
|
|
|
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<Box sx={{ my: 3, display: "flex", alignItems: "center" }}>
|
|
|
|
|
|
|
|
<Box sx={{ flexGrow: 1 }}>
|
|
|
|
|
|
|
|
<Typography variant="h5">{title}</Typography>
|
|
|
|
|
|
|
|
{description && (
|
|
|
|
|
|
|
|
<Typography variant="subtitle1" color={theme.palette.text.secondary}>
|
|
|
|
|
|
|
|
{description}
|
|
|
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
{children}
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Settings: NextPage = () => {
|
|
|
|
|
|
|
|
const [settings, setSettings] = useSettings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const setSetting = (key: string, value?: string): void =>
|
|
|
|
|
|
|
|
setSettings({ ...settings, [key]: value });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [primaryColorModalIsOpen, setPrimaryColorModal] = useState(false);
|
|
|
|
|
|
|
|
const [accentColorModalIsOpen, setAccentColorModal] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [modalIsOpen, setModalState] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const instances = useQuery<[string, ServerInstance][]>(
|
|
|
|
|
|
|
|
"invidiousInstances",
|
|
|
|
|
|
|
|
() =>
|
|
|
|
|
|
|
|
axios
|
|
|
|
|
|
|
|
.get("https://api.invidious.io/instances.json")
|
|
|
|
|
|
|
|
.then((res) => res.data),
|
|
|
|
|
|
|
|
{ retry: false }
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const invidiousServerResponse = useMutation<Stats, unknown, string>(
|
|
|
|
|
|
|
|
"invidiousInstance",
|
|
|
|
|
|
|
|
(server) =>
|
|
|
|
|
|
|
|
axios.get(`https://${server}/api/v1/stats`).then((res) => res.data)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const allowsRegistrations = invidiousServerResponse.data?.openRegistrations;
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
@ -179,10 +148,10 @@ const Settings: NextPage = () => {
|
|
|
|
|
|
|
|
|
|
|
|
<Typography variant="h4">Theme</Typography>
|
|
|
|
<Typography variant="h4">Theme</Typography>
|
|
|
|
|
|
|
|
|
|
|
|
<Box sx={{ my: 3, display: "flex" }}>
|
|
|
|
<Setting
|
|
|
|
<Typography variant="h5" sx={{ flexGrow: 1 }}>
|
|
|
|
title="General Theme"
|
|
|
|
General theme
|
|
|
|
description="Sets the background color"
|
|
|
|
</Typography>
|
|
|
|
>
|
|
|
|
<ButtonGroup
|
|
|
|
<ButtonGroup
|
|
|
|
variant="contained"
|
|
|
|
variant="contained"
|
|
|
|
color="primary"
|
|
|
|
color="primary"
|
|
|
@ -194,11 +163,39 @@ const Settings: NextPage = () => {
|
|
|
|
<Button onClick={() => setSetting("theme")}>System</Button>
|
|
|
|
<Button onClick={() => setSetting("theme")}>System</Button>
|
|
|
|
<Button onClick={() => setSetting("theme", "dark")}>Dark</Button>
|
|
|
|
<Button onClick={() => setSetting("theme", "dark")}>Dark</Button>
|
|
|
|
</ButtonGroup>
|
|
|
|
</ButtonGroup>
|
|
|
|
</Box>
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
|
|
|
|
<ColorSetting type="Primary Color" />
|
|
|
|
<Setting title="Primary Color">
|
|
|
|
|
|
|
|
<ColorBox marginRight={1} color={settings.primaryColor} />
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
onClick={() => setPrimaryColorModal(true)}
|
|
|
|
|
|
|
|
variant="contained"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Pick Color
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<MaterialColorPicker
|
|
|
|
|
|
|
|
setState={setPrimaryColorModal}
|
|
|
|
|
|
|
|
isOpen={primaryColorModalIsOpen}
|
|
|
|
|
|
|
|
setColor={(color) => setSetting("primaryColor", color)}
|
|
|
|
|
|
|
|
selectedColor={settings.primaryColor}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
|
|
|
|
<ColorSetting type="Accent Color" />
|
|
|
|
<Setting title="Accent Color">
|
|
|
|
|
|
|
|
<ColorBox marginRight={1} color={settings.accentColor} />
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
onClick={() => setAccentColorModal(true)}
|
|
|
|
|
|
|
|
variant="contained"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Pick Color
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<MaterialColorPicker
|
|
|
|
|
|
|
|
setState={setAccentColorModal}
|
|
|
|
|
|
|
|
isOpen={accentColorModalIsOpen}
|
|
|
|
|
|
|
|
setColor={(color) => setSetting("accentColor", color)}
|
|
|
|
|
|
|
|
selectedColor={settings.accentColor}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
|
|
|
|
<Divider sx={{ my: 4 }} />
|
|
|
|
<Divider sx={{ my: 4 }} />
|
|
|
|
|
|
|
|
|
|
|
@ -206,13 +203,28 @@ const Settings: NextPage = () => {
|
|
|
|
|
|
|
|
|
|
|
|
<Divider sx={{ my: 4 }} />
|
|
|
|
<Divider sx={{ my: 4 }} />
|
|
|
|
|
|
|
|
|
|
|
|
<Typography variant="h4">Miscellaneous</Typography>
|
|
|
|
<Typography variant="h4">Data</Typography>
|
|
|
|
|
|
|
|
|
|
|
|
<Box sx={{ my: 3, display: "flex", alignItems: "center" }}>
|
|
|
|
<Setting
|
|
|
|
<Typography variant="h5" sx={{ flexGrow: 1 }}>
|
|
|
|
title="Invidious Server"
|
|
|
|
Invidious Server
|
|
|
|
description={`Where to fetch data from ${
|
|
|
|
</Typography>
|
|
|
|
settings.storageType == "invidious" ? "and login into" : ""
|
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
>
|
|
|
|
<Box sx={{ mr: 2 }}>
|
|
|
|
<Box sx={{ mr: 2 }}>
|
|
|
|
|
|
|
|
{!invidiousServerResponse.data &&
|
|
|
|
|
|
|
|
!invidiousServerResponse.error &&
|
|
|
|
|
|
|
|
!invidiousServerResponse.isLoading && (
|
|
|
|
|
|
|
|
<Refresh
|
|
|
|
|
|
|
|
sx={{
|
|
|
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
|
|
|
color: theme.palette.text.secondary
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
|
|
invidiousServerResponse.mutate(settings.invidiousServer)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
{invidiousServerResponse.data &&
|
|
|
|
{invidiousServerResponse.data &&
|
|
|
|
!invidiousServerResponse.isLoading && (
|
|
|
|
!invidiousServerResponse.isLoading && (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
@ -220,9 +232,14 @@ const Settings: NextPage = () => {
|
|
|
|
onClick={() => setModalState(true)}
|
|
|
|
onClick={() => setModalState(true)}
|
|
|
|
sx={{ color: green[800], cursor: "pointer" }}
|
|
|
|
sx={{ color: green[800], cursor: "pointer" }}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<InfoModal />
|
|
|
|
<InfoModal
|
|
|
|
|
|
|
|
modalIsOpen={modalIsOpen}
|
|
|
|
|
|
|
|
setModalState={setModalState}
|
|
|
|
|
|
|
|
data={invidiousServerResponse.data!}
|
|
|
|
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{invidiousServerResponse.error && (
|
|
|
|
{invidiousServerResponse.error && (
|
|
|
|
<Error sx={{ color: red[800] }} />
|
|
|
|
<Error sx={{ color: red[800] }} />
|
|
|
|
)}
|
|
|
|
)}
|
|
|
@ -238,6 +255,8 @@ const Settings: NextPage = () => {
|
|
|
|
onChange={(e) => {
|
|
|
|
onChange={(e) => {
|
|
|
|
const server = e.target.value;
|
|
|
|
const server = e.target.value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invidiousServerResponse.mutate(server);
|
|
|
|
|
|
|
|
|
|
|
|
setSetting("invidiousServer", server);
|
|
|
|
setSetting("invidiousServer", server);
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
MenuProps={{ sx: { maxHeight: 300 } }}
|
|
|
|
MenuProps={{ sx: { maxHeight: 300 } }}
|
|
|
@ -256,7 +275,89 @@ const Settings: NextPage = () => {
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
</Select>
|
|
|
|
</FormControl>
|
|
|
|
</FormControl>
|
|
|
|
</Box>
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Setting
|
|
|
|
|
|
|
|
title="Data Storage Location"
|
|
|
|
|
|
|
|
description="Where your personal data will be stored"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<FormControl sx={{ minWidth: 200 }}>
|
|
|
|
|
|
|
|
<InputLabel id="location-select-label">Location</InputLabel>
|
|
|
|
|
|
|
|
<Select
|
|
|
|
|
|
|
|
labelId="location-select-label"
|
|
|
|
|
|
|
|
id="location-select"
|
|
|
|
|
|
|
|
value={settings.storageType}
|
|
|
|
|
|
|
|
label="Location"
|
|
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
|
|
const location = e.target.value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setSetting("storageType", location);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
MenuProps={{ sx: { maxHeight: 300 } }}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{[
|
|
|
|
|
|
|
|
{ name: "Locally", value: StorageType.Local },
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "Invidious server using auth",
|
|
|
|
|
|
|
|
value: StorageType.Invidious
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: `A custom ${process.env.NEXT_PUBLIC_APP_NAME} auth server`,
|
|
|
|
|
|
|
|
value: StorageType.RemoteServer
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
].map((location, i) => (
|
|
|
|
|
|
|
|
<MenuItem key={i} value={location.value}>
|
|
|
|
|
|
|
|
{location.name}
|
|
|
|
|
|
|
|
</MenuItem>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
</FormControl>
|
|
|
|
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{settings.storageType != StorageType.Local && (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{settings.storageType == "invidious" && allowsRegistrations && (
|
|
|
|
|
|
|
|
<Setting
|
|
|
|
|
|
|
|
title="Username"
|
|
|
|
|
|
|
|
description="The username for your Invidious account"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<TextField label="Username" color="primary" />
|
|
|
|
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{settings.storageType == StorageType.RemoteServer && (
|
|
|
|
|
|
|
|
<Setting
|
|
|
|
|
|
|
|
title="Server address"
|
|
|
|
|
|
|
|
description={`The address for your ${process.env.NEXT_PUBLIC_APP_NAME} auth server`}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<TextField label="Server adress" color="primary" />
|
|
|
|
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Setting
|
|
|
|
|
|
|
|
title={
|
|
|
|
|
|
|
|
settings.storageType == StorageType.Invidious
|
|
|
|
|
|
|
|
? "Password"
|
|
|
|
|
|
|
|
: "Passphrase"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
description={
|
|
|
|
|
|
|
|
settings.storageType == StorageType.Invidious
|
|
|
|
|
|
|
|
? "The password for your invidious account"
|
|
|
|
|
|
|
|
: "The passphrase for your account"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<TextField
|
|
|
|
|
|
|
|
type="password"
|
|
|
|
|
|
|
|
label={
|
|
|
|
|
|
|
|
settings.storageType == StorageType.Invidious
|
|
|
|
|
|
|
|
? "Password"
|
|
|
|
|
|
|
|
: "Passphrase"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
color="primary"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Setting>
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</Container>
|
|
|
|
</Container>
|
|
|
|
</Layout>
|
|
|
|
</Layout>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|