mirror of
https://github.com/Ravinou/borgwarehouse
synced 2026-03-14 14:25:46 +01:00
chore: 🧹 clean up some imports
This commit is contained in:
parent
7266ea464e
commit
73842a8d62
74 changed files with 109 additions and 226 deletions
|
|
@ -1,9 +1,8 @@
|
|||
//Lib
|
||||
import React from 'react';
|
||||
import { useState } from 'react';
|
||||
import classes from './QuickCommands.module.css';
|
||||
import { IconSettingsAutomation, IconCopy } from '@tabler/icons-react';
|
||||
import lanCommandOption from '~/helpers/functions/lanCommandOption';
|
||||
import { lanCommandOption } from '~/helpers/functions';
|
||||
import { WizardEnvType } from '~/types/domain/config.types';
|
||||
|
||||
type QuickCommandsProps = {
|
||||
|
|
@ -13,15 +12,12 @@ type QuickCommandsProps = {
|
|||
};
|
||||
|
||||
export default function QuickCommands(props: QuickCommandsProps) {
|
||||
////Vars
|
||||
const wizardEnv = props.wizardEnv;
|
||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||
const { FQDN, SSH_SERVER_PORT } = lanCommandOption(wizardEnv, props.lanCommand);
|
||||
|
||||
//State
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
|
||||
//Functions
|
||||
const handleCopy = async () => {
|
||||
// Asynchronously call copy to clipboard
|
||||
navigator.clipboard
|
||||
|
|
@ -29,7 +25,6 @@ export default function QuickCommands(props: QuickCommandsProps) {
|
|||
`ssh://${wizardEnv?.UNIX_USER}@${FQDN}${SSH_SERVER_PORT}/./${props.repositoryName}`
|
||||
)
|
||||
.then(() => {
|
||||
// If successful, update the isCopied state value
|
||||
setIsCopied(true);
|
||||
setTimeout(() => {
|
||||
setIsCopied(false);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import { useState } from 'react';
|
||||
import classes from './Repo.module.css';
|
||||
import {
|
||||
|
|
@ -9,11 +8,10 @@ import {
|
|||
IconBellOff,
|
||||
IconLockPlus,
|
||||
} from '@tabler/icons-react';
|
||||
import { timestampConverter } from '~/helpers/functions/timestampConverter';
|
||||
import StorageBar from '../UI/StorageBar/StorageBar';
|
||||
import QuickCommands from './QuickCommands/QuickCommands';
|
||||
import { Repository, WizardEnvType } from '~/types/domain/config.types';
|
||||
import { Optional } from '~/types';
|
||||
import { Repository, WizardEnvType, Optional } from '~/types';
|
||||
import { fromUnixTime } from 'date-fns';
|
||||
|
||||
type RepoProps = Omit<Repository, 'unixUser' | 'displayDetails'> & {
|
||||
repoManageEditHandler: () => void;
|
||||
|
|
@ -126,7 +124,7 @@ export default function Repo(props: RepoProps) {
|
|||
</th>
|
||||
<th>
|
||||
<div className={classes.lastSave}>
|
||||
{props.lastSave === 0 ? '-' : timestampConverter(props.lastSave)}
|
||||
{props.lastSave === 0 ? '-' : fromUnixTime(props.lastSave).toLocaleString()}
|
||||
</div>
|
||||
</th>
|
||||
<th>#{props.id}</th>
|
||||
|
|
@ -160,7 +158,7 @@ export default function Repo(props: RepoProps) {
|
|||
)}
|
||||
</div>
|
||||
<div className={classes.lastSave}>
|
||||
{props.lastSave === 0 ? null : timestampConverter(props.lastSave)}
|
||||
{props.lastSave === 0 ? null : fromUnixTime(props.lastSave).toLocaleString()}
|
||||
<span style={{ marginLeft: '20px', color: '#637381' }}>#{props.id}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import classes from './CopyButton.module.css';
|
||||
import { useState, ReactNode } from 'react';
|
||||
import { IconChecks, IconCopy } from '@tabler/icons-react';
|
||||
|
|
@ -12,10 +11,8 @@ type CopyButtonProps = {
|
|||
};
|
||||
|
||||
export default function CopyButton(props: CopyButtonProps) {
|
||||
//State
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
|
||||
//Function
|
||||
const handleCopy = async (data: string) => {
|
||||
navigator.clipboard
|
||||
.writeText(data)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import classes from './Error.module.css';
|
||||
|
||||
type ErrorProps = {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import { ReactNode } from 'react';
|
||||
import classes from './Info.module.css';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import classes from './Footer.module.css';
|
||||
import packageInfo from '~/package.json';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
//Lib
|
||||
import classes from './Header.module.css';
|
||||
|
||||
//Components
|
||||
import Nav from './Nav/Nav';
|
||||
|
||||
function Header() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import classes from './Nav.module.css';
|
||||
import { IconUser, IconLogout } from '@tabler/icons-react';
|
||||
import Link from 'next/link';
|
||||
|
|
@ -6,13 +5,10 @@ import { useRouter } from 'next/router';
|
|||
import { useSession, signOut } from 'next-auth/react';
|
||||
|
||||
export default function Nav() {
|
||||
////Var
|
||||
//Get the current route to light the right Item
|
||||
const router = useRouter();
|
||||
const currentRoute = router.pathname;
|
||||
const { status, data } = useSession();
|
||||
|
||||
//Function
|
||||
const onLogoutClickedHandler = async () => {
|
||||
//This bug is open : https://github.com/nextauthjs/next-auth/issues/1542
|
||||
//I put redirect to false and redirect with router.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import Footer from './Footer/Footer';
|
||||
import Header from './Header/Header';
|
||||
import NavSide from './NavSide/NavSide';
|
||||
|
|
@ -10,7 +9,6 @@ type LayoutProps = {
|
|||
};
|
||||
|
||||
function Layout(props: LayoutProps) {
|
||||
//Var
|
||||
const { status } = useSession();
|
||||
|
||||
if (status === 'authenticated') {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
//Lib
|
||||
import classes from './NavSide.module.css';
|
||||
import { IconServer, IconSettingsAutomation, IconActivityHeartbeat } from '@tabler/icons-react';
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
//Composants
|
||||
|
||||
export default function NavSide() {
|
||||
////Var
|
||||
//Get the current route to light the right Item
|
||||
const router = useRouter();
|
||||
const currentRoute = router.pathname;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
//Lib
|
||||
import classes from './ShimmerRepoList.module.css';
|
||||
|
||||
const LOADING_REPO_COUNT = 5;
|
||||
|
||||
function ShimmerRepoItem() {
|
||||
return <div className={classes.repoIsLoading} />;
|
||||
}
|
||||
|
||||
export default function ShimmerRepoList() {
|
||||
return (
|
||||
<div className={classes.container}>
|
||||
|
|
@ -8,11 +13,9 @@ export default function ShimmerRepoList() {
|
|||
<div className={classes.buttonIsLoading} />
|
||||
</div>
|
||||
<div className={classes.loadingRepoContainer}>
|
||||
<div className={classes.repoIsLoading} />
|
||||
<div className={classes.repoIsLoading} />
|
||||
<div className={classes.repoIsLoading} />
|
||||
<div className={classes.repoIsLoading} />
|
||||
<div className={classes.repoIsLoading} />
|
||||
{Array.from({ length: LOADING_REPO_COUNT }, (_, i) => (
|
||||
<ShimmerRepoItem key={i} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import classes from './StorageBar.module.css';
|
||||
|
||||
type StorageBarProps = {
|
||||
|
|
@ -7,7 +6,6 @@ type StorageBarProps = {
|
|||
};
|
||||
|
||||
export default function StorageBar(props: StorageBarProps) {
|
||||
//Var
|
||||
//storageUsed is in kB, storageSize is in GB. Round to 1 decimal for %.
|
||||
const storageUsedPercent = (((props.storageUsed / 1024 ** 2) * 100) / props.storageSize).toFixed(
|
||||
1
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import { Optional } from '~/types';
|
||||
import classes from './Switch.module.css';
|
||||
import { SpinnerCircularFixed } from 'spinners-react';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import React from 'react';
|
||||
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||
import { IconDeviceDesktopAnalytics, IconTerminal2 } from '@tabler/icons-react';
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
//Lib
|
||||
import { IconAlertCircle, IconTool } from '@tabler/icons-react';
|
||||
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||
import { WizardStepProps } from '../wizard.types';
|
||||
import { WizardStepProps } from '~/types';
|
||||
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||
import { lanCommandOption } from '~/helpers/functions';
|
||||
|
||||
function WizardStep2(props: WizardStepProps) {
|
||||
////Vars
|
||||
const wizardEnv = props.wizardEnv;
|
||||
const UNIX_USER = wizardEnv?.UNIX_USER;
|
||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
//Lib
|
||||
import React from 'react';
|
||||
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||
import { IconChecks, IconPlayerPlay } from '@tabler/icons-react';
|
||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||
import { WizardStepProps } from '../wizard.types';
|
||||
import { WizardStepProps } from '~/types';
|
||||
import { lanCommandOption } from '~/helpers/functions';
|
||||
|
||||
function WizardStep3(props: WizardStepProps) {
|
||||
////Vars
|
||||
const wizardEnv = props.wizardEnv;
|
||||
const UNIX_USER = wizardEnv?.UNIX_USER;
|
||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
//Lib
|
||||
import React from 'react';
|
||||
import classes from '../WizardStep1/WizardStep1.module.css';
|
||||
import { IconWand } from '@tabler/icons-react';
|
||||
import CopyButton from '../../UI/CopyButton/CopyButton';
|
||||
import lanCommandOption from '../../../helpers/functions/lanCommandOption';
|
||||
import { WizardStepProps } from '../wizard.types';
|
||||
import { WizardStepProps } from '~/types';
|
||||
import { lanCommandOption } from '~/helpers/functions';
|
||||
|
||||
function WizardStep4(props: WizardStepProps) {
|
||||
////Vars
|
||||
const wizardEnv = props.wizardEnv;
|
||||
const UNIX_USER = wizardEnv?.UNIX_USER;
|
||||
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import React from 'react';
|
||||
import classes from './WizardStepBar.module.css';
|
||||
import { IconChevronLeft, IconChevronRight } from '@tabler/icons-react';
|
||||
|
|
@ -11,7 +10,6 @@ type WizardStepBarProps = {
|
|||
};
|
||||
|
||||
function WizardStepBar(props: WizardStepBarProps) {
|
||||
////Functions
|
||||
//Color onClick on a step
|
||||
const colorHandler = (step: number) => {
|
||||
if (step <= props.step) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import {
|
||||
Chart as ChartJS,
|
||||
CategoryScale,
|
||||
|
|
@ -10,14 +9,11 @@ import {
|
|||
} from 'chart.js';
|
||||
import { Bar } from 'react-chartjs-2';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
import { Optional } from '~/types';
|
||||
import { Repository, Optional } from '~/types';
|
||||
|
||||
export default function StorageUsedChartBar() {
|
||||
//States
|
||||
const [data, setData] = useState<Optional<Array<Repository>>>();
|
||||
|
||||
//LifeCycle
|
||||
useEffect(() => {
|
||||
const dataFetch = async () => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import classes from './RepoList.module.css';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { IconPlus } from '@tabler/icons-react';
|
||||
|
|
@ -9,11 +8,10 @@ import { ToastContainer, ToastOptions, toast } from 'react-toastify';
|
|||
import 'react-toastify/dist/ReactToastify.css';
|
||||
|
||||
//Composants
|
||||
import Repo from '../../Components/Repo/Repo';
|
||||
import Repo from '~/Components/Repo/Repo';
|
||||
import RepoManage from '../RepoManage/RepoManage';
|
||||
import ShimmerRepoList from '../../Components/UI/ShimmerRepoList/ShimmerRepoList';
|
||||
import { Repository, WizardEnvType } from '~/types/domain/config.types';
|
||||
import { Optional } from '~/types';
|
||||
import ShimmerRepoList from '~/Components/UI/ShimmerRepoList/ShimmerRepoList';
|
||||
import { Repository, WizardEnvType, Optional } from '~/types';
|
||||
|
||||
export default function RepoList() {
|
||||
////Var
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import classes from './RepoManage.module.css';
|
||||
import { IconAlertCircle, IconX } from '@tabler/icons-react';
|
||||
import { useState } from 'react';
|
||||
|
|
@ -10,9 +9,7 @@ import { SpinnerDotted } from 'spinners-react';
|
|||
import Select from 'react-select';
|
||||
import Link from 'next/link';
|
||||
import { IconExternalLink } from '@tabler/icons-react';
|
||||
import { alertOptions } from '../../types/domain/constants';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
import { Optional } from '~/types';
|
||||
import { alertOptions, Repository, Optional } from '~/types';
|
||||
|
||||
type RepoManageProps = {
|
||||
mode: 'add' | 'edit';
|
||||
|
|
@ -31,7 +28,6 @@ type DataForm = {
|
|||
};
|
||||
|
||||
export default function RepoManage(props: RepoManageProps) {
|
||||
////Var
|
||||
const router = useRouter();
|
||||
const targetRepo =
|
||||
props.mode === 'edit' && router.query.slug
|
||||
|
|
@ -55,11 +51,9 @@ export default function RepoManage(props: RepoManageProps) {
|
|||
progress: undefined,
|
||||
};
|
||||
|
||||
////State
|
||||
const [deleteDialog, setDeleteDialog] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
////Functions
|
||||
//router.query.slug is undefined for few milliseconds on first render for a direct URL access (https://github.com/vercel/next.js/discussions/11484).
|
||||
//If I call repoManage with edit mode (props), i'm firstly waiting that router.query.slug being available before rendering.
|
||||
if (props.mode === 'edit') {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
//Lib
|
||||
import { useRouter } from 'next/router';
|
||||
import { useEffect, useState } from 'react';
|
||||
import Select, { SingleValue } from 'react-select';
|
||||
import classes from './SetupWizard.module.css';
|
||||
import { Optional, SelectedRepoWizard, Repository, WizardEnvType } from '~/types';
|
||||
|
||||
//Components
|
||||
import { SelectedRepoWizard } from '~/Components/WizardSteps/wizard.types';
|
||||
import { Repository, WizardEnvType } from '~/types/domain/config.types';
|
||||
import { Optional } from '~/types';
|
||||
import WizardStep1 from '../../Components/WizardSteps/WizardStep1/WizardStep1';
|
||||
import WizardStep2 from '../../Components/WizardSteps/WizardStep2/WizardStep2';
|
||||
import WizardStep3 from '../../Components/WizardSteps/WizardStep3/WizardStep3';
|
||||
|
|
@ -19,10 +16,8 @@ type SetupWizardProps = {
|
|||
};
|
||||
|
||||
function SetupWizard(props: SetupWizardProps) {
|
||||
////Var
|
||||
const router = useRouter();
|
||||
|
||||
////States
|
||||
const [repoList, setRepoList] = useState<Optional<Array<Repository>>>();
|
||||
const [repoListIsLoading, setRepoListIsLoading] = useState<boolean>(true);
|
||||
const [step, setStep] = useState<number>(1);
|
||||
|
|
@ -70,15 +65,13 @@ function SetupWizard(props: SetupWizardProps) {
|
|||
props.step && setStep(props.step);
|
||||
}, [props.step]);
|
||||
|
||||
////Functions
|
||||
|
||||
//Options for react-select
|
||||
const options: Optional<Array<SelectedRepoWizard>> = repoList?.map((repo) => ({
|
||||
label: `${repo.alias} - #${repo.id}`,
|
||||
value: `${repo.alias} - #${repo.id}`,
|
||||
id: repo.id.toString(),
|
||||
repositoryName: repo.repositoryName,
|
||||
lanCommand: repo.lanCommand,
|
||||
lanCommand: repo.lanCommand ? repo.lanCommand : false,
|
||||
}));
|
||||
|
||||
//Step button (free selection of user)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import { IconExternalLink } from '@tabler/icons-react';
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
|
@ -10,7 +9,7 @@ import classes from '../UserSettings.module.css';
|
|||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import Switch from '~/Components/UI/Switch/Switch';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
import { Optional } from '~/types';
|
||||
import AppriseMode from './AppriseMode/AppriseMode';
|
||||
import AppriseURLs from './AppriseURLs/AppriseURLs';
|
||||
|
|
@ -20,7 +19,6 @@ type AppriseAlertDataForm = {
|
|||
};
|
||||
|
||||
export default function AppriseAlertSettings() {
|
||||
//Var
|
||||
const toastOptions: ToastOptions = {
|
||||
position: 'top-right',
|
||||
autoClose: 5000,
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
//Lib
|
||||
import { useEffect } from 'react';
|
||||
import classes from '../../UserSettings.module.css';
|
||||
import { useState } from 'react';
|
||||
import { SpinnerCircularFixed } from 'spinners-react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { AppriseModeEnum } from '~/types/domain/config.types';
|
||||
import { Optional, AppriseModeEnum, AppriseModeDTO } from '~/types';
|
||||
|
||||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import { Optional } from '~/types';
|
||||
import { AppriseModeDTO } from '~/types/api/notification.types';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
|
||||
type AppriseModeDataForm = {
|
||||
appriseMode: string;
|
||||
|
|
@ -18,7 +15,6 @@ type AppriseModeDataForm = {
|
|||
};
|
||||
|
||||
export default function AppriseMode() {
|
||||
//Var
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
|
|
@ -28,14 +24,12 @@ export default function AppriseMode() {
|
|||
const { isLoading, isSaved, error, setIsLoading, handleSuccess, handleError, clearError } =
|
||||
useFormStatus();
|
||||
|
||||
////State
|
||||
const [displayStatelessURL, setDisplayStatelessURL] = useState<boolean>(false);
|
||||
const [appriseMode, setAppriseMode] = useState<Optional<AppriseModeEnum>>(
|
||||
AppriseModeEnum.STATELESS
|
||||
);
|
||||
const [appriseStatelessURL, setAppriseStatelessURL] = useState<Optional<string>>();
|
||||
|
||||
////LifeCycle
|
||||
//Component did mount
|
||||
useEffect(() => {
|
||||
//Initial fetch to get Apprise Mode enabled
|
||||
|
|
|
|||
|
|
@ -1,22 +1,19 @@
|
|||
//Lib
|
||||
import { useEffect } from 'react';
|
||||
import classes from '../../UserSettings.module.css';
|
||||
import { useState } from 'react';
|
||||
import { SpinnerCircularFixed } from 'spinners-react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Optional, AppriseServicesDTO } from '~/types';
|
||||
|
||||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import { Optional } from '~/types';
|
||||
import { AppriseServicesDTO } from '~/types/api/notification.types';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
|
||||
type AppriseURLsDataForm = {
|
||||
appriseURLs: string;
|
||||
};
|
||||
|
||||
export default function AppriseURLs() {
|
||||
//Var
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
|
|
@ -26,11 +23,9 @@ export default function AppriseURLs() {
|
|||
const { isLoading, isSaved, error, setIsLoading, handleSuccess, handleError, clearError } =
|
||||
useFormStatus();
|
||||
|
||||
////State
|
||||
const [appriseServicesList, setAppriseServicesList] = useState<Optional<string>>();
|
||||
const [fetchError, setFetchError] = useState<Optional<boolean>>();
|
||||
|
||||
////LifeCycle
|
||||
//Component did mount
|
||||
useEffect(() => {
|
||||
//Initial fetch to build the list of Apprise Services enabled
|
||||
|
|
@ -55,7 +50,6 @@ export default function AppriseURLs() {
|
|||
getAppriseServices();
|
||||
}, []);
|
||||
|
||||
////Functions
|
||||
//Form submit handler to modify Apprise services
|
||||
const urlsFormSubmitHandler = async (data: AppriseURLsDataForm) => {
|
||||
clearError();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import { IconExternalLink } from '@tabler/icons-react';
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
|
@ -6,16 +5,14 @@ import { toast, ToastOptions } from 'react-toastify';
|
|||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import { SpinnerCircularFixed } from 'spinners-react';
|
||||
import classes from '../UserSettings.module.css';
|
||||
import { Optional, EmailAlertDTO } from '~/types';
|
||||
|
||||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import Switch from '~/Components/UI/Switch/Switch';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { Optional } from '~/types';
|
||||
import { EmailAlertDTO } from '~/types/api/notification.types';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
|
||||
export default function EmailAlertSettings() {
|
||||
//Var
|
||||
const toastOptions: ToastOptions = {
|
||||
position: 'top-right',
|
||||
autoClose: 5000,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import { toast, ToastOptions } from 'react-toastify';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import classes from '../UserSettings.module.css';
|
||||
|
|
@ -9,11 +8,10 @@ import { SpinnerDotted } from 'spinners-react';
|
|||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import Info from '~/Components/UI/Info/Info';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
import { EmailSettingDTO } from '~/types/api/setting.types';
|
||||
|
||||
export default function EmailSettings(props: EmailSettingDTO) {
|
||||
//Var
|
||||
const toastOptions: ToastOptions = {
|
||||
position: 'top-right',
|
||||
autoClose: 8000,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import { toast, ToastOptions } from 'react-toastify';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import classes from '../UserSettings.module.css';
|
||||
|
|
@ -8,25 +7,19 @@ import { SpinnerDotted } from 'spinners-react';
|
|||
import { fromUnixTime } from 'date-fns';
|
||||
import { IconTrash, IconExternalLink } from '@tabler/icons-react';
|
||||
import Link from 'next/link';
|
||||
import { Optional, IntegrationTokenType, TokenPermissionEnum, TokenPermissionsType } from '~/types';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
|
||||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import CopyButton from '~/Components/UI/CopyButton/CopyButton';
|
||||
import Info from '~/Components/UI/Info/Info';
|
||||
import {
|
||||
IntegrationTokenType,
|
||||
TokenPermissionEnum,
|
||||
TokenPermissionsType,
|
||||
} from '~/types/api/integration.types';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { Optional } from '~/types';
|
||||
|
||||
type IntegrationsDataForm = {
|
||||
tokenName: string;
|
||||
};
|
||||
|
||||
export default function Integrations() {
|
||||
//Var
|
||||
const toastOptions: ToastOptions = {
|
||||
position: 'top-right',
|
||||
autoClose: 5000,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
//Lib
|
||||
import { toast, ToastOptions } from 'react-toastify';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import classes from '../UserSettings.module.css';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { SpinnerDotted } from 'spinners-react';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
import { PasswordSettingDTO } from '~/types';
|
||||
|
||||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { PasswordSettingDTO } from '~/types/api/setting.types';
|
||||
|
||||
export default function PasswordSettings() {
|
||||
//Var
|
||||
const toastOptions: ToastOptions = {
|
||||
position: 'top-right',
|
||||
autoClose: 5000,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
//Lib
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import classes from './UserSettings.module.css';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Session } from 'next-auth';
|
||||
import { Optional, WizardEnvType, SessionStatus } from '~/types';
|
||||
|
||||
//Components
|
||||
import EmailSettings from './EmailSettings/EmailSettings';
|
||||
|
|
@ -10,10 +11,6 @@ import UsernameSettings from './UsernameSettings/UsernameSettings';
|
|||
import EmailAlertSettings from './EmailAlertSettings/EmailAlertSettings';
|
||||
import AppriseAlertSettings from './AppriseAlertSettings/AppriseAlertSettings';
|
||||
import Integrations from './Integrations/Integrations';
|
||||
import { SessionStatus } from '~/types/api/next-auth.types';
|
||||
import { Session } from 'next-auth';
|
||||
import { WizardEnvType } from '~/types/domain/config.types';
|
||||
import { Optional } from '~/types';
|
||||
|
||||
type UserSettingsProps = {
|
||||
status: SessionStatus;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
//Lib
|
||||
import { toast, ToastOptions } from 'react-toastify';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import classes from '../UserSettings.module.css';
|
||||
import { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { SpinnerDotted } from 'spinners-react';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
import { UsernameSettingDTO } from '~/types';
|
||||
|
||||
//Components
|
||||
import Error from '~/Components/UI/Error/Error';
|
||||
import Info from '~/Components/UI/Info/Info';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { UsernameSettingDTO } from '~/types/api/setting.types';
|
||||
|
||||
export default function UsernameSettings(props: UsernameSettingDTO) {
|
||||
//Var
|
||||
const toastOptions: ToastOptions = {
|
||||
position: 'top-right',
|
||||
autoClose: 8000,
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
export * from './isSshPubKeyDuplicate';
|
||||
export * from './lanCommandOption';
|
||||
import lanCommandOption from './lanCommandOption';
|
||||
import isSshPubKeyDuplicate from './isSshPubKeyDuplicate';
|
||||
|
||||
export { lanCommandOption, isSshPubKeyDuplicate };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { Optional } from '~/types';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
import { Optional, Repository } from '~/types';
|
||||
|
||||
/**
|
||||
* Checks if the given SSH public key is duplicated in the provided repository list by removing the comment part.
|
||||
|
|
@ -9,10 +8,10 @@ import { Repository } from '~/types/domain/config.types';
|
|||
* @returns {boolean} - Returns true if the SSH public key is duplicated, otherwise false.
|
||||
* @throws {Error} - Throws an error if required parameters are missing or invalid.
|
||||
*/
|
||||
export const isSshPubKeyDuplicate = (
|
||||
export default function isSshPubKeyDuplicate(
|
||||
pubKey: string,
|
||||
repoList: Array<Optional<Repository>>
|
||||
): boolean => {
|
||||
): boolean {
|
||||
if (!pubKey || !repoList || !Array.isArray(repoList)) {
|
||||
throw new Error('Missing or invalid parameters for duplicate SSH public key check.');
|
||||
}
|
||||
|
|
@ -25,4 +24,4 @@ export const isSshPubKeyDuplicate = (
|
|||
const repoSshKeyWithoutComment = repo?.sshPublicKey.split(' ').slice(0, 2).join(' ');
|
||||
return repoSshKeyWithoutComment === pubKeyWithoutComment;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { WizardEnvType } from '~/types/domain/config.types';
|
||||
import { Optional } from '~/types';
|
||||
import { Optional, WizardEnvType } from '~/types';
|
||||
|
||||
export default function lanCommandOption(
|
||||
wizardEnv?: WizardEnvType,
|
||||
|
|
@ -13,11 +12,9 @@ export default function lanCommandOption(
|
|||
|
||||
const isPortHidden = HIDE_SSH_PORT === 'true';
|
||||
|
||||
// Sélection des valeurs en fonction de lanCommand
|
||||
const selectedFQDN = lanCommand && FQDN_LAN ? FQDN_LAN : FQDN;
|
||||
const selectedPort = lanCommand ? SSH_SERVER_PORT_LAN : SSH_SERVER_PORT;
|
||||
|
||||
// Construire le port final uniquement si disponible et non masqué
|
||||
const formattedPort = !isPortHidden && selectedPort ? `:${selectedPort}` : undefined;
|
||||
|
||||
return {
|
||||
|
|
|
|||
1
hooks/index.ts
Normal file
1
hooks/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export * from './useFormStatus';
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
//Lib
|
||||
import Head from 'next/head';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { useRouter } from 'next/router';
|
||||
import Image from 'next/image';
|
||||
|
||||
export default function Error404() {
|
||||
//Var
|
||||
const { status } = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//Lib
|
||||
import '../styles/default.css';
|
||||
import Head from 'next/head';
|
||||
import { ToastContainer } from 'react-toastify';
|
||||
|
|
|
|||
|
|
@ -1,20 +1,17 @@
|
|||
//Lib
|
||||
import Head from 'next/head';
|
||||
import 'react-toastify/dist/ReactToastify.css';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { authOptions } from '../api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
import { SessionStatus } from '~/types/api/next-auth.types';
|
||||
import { SessionStatus } from '~/types';
|
||||
|
||||
//Components
|
||||
import UserSettings from '~/Containers/UserSettings/UserSettings';
|
||||
|
||||
export default function Account() {
|
||||
////Var
|
||||
const { status, data } = useSession();
|
||||
|
||||
//Function
|
||||
if (status == 'unauthenticated' || status == 'loading' || !data) {
|
||||
return <p>Loading...</p>;
|
||||
}
|
||||
|
|
@ -30,7 +27,6 @@ export default function Account() {
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
//Var
|
||||
const session = await getServerSession(context.req, context.res, authOptions);
|
||||
|
||||
if (!session) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { ConfigService } from '~/services';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { AppriseAlertResponse } from '~/types/api/notification.types';
|
||||
import { ErrorResponse, AppriseAlertResponse } from '~/types';
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
|
||||
export default async function handler(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { ConfigService } from '~/services';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { AppriseModeDTO } from '~/types/api/notification.types';
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { AppriseModeDTO, ErrorResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { ConfigService } from '~/services';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { AppriseServicesDTO } from '~/types/api/notification.types';
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { AppriseServicesDTO, ErrorResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
//Lib
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { ConfigService } from '~/services';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { EmailAlertDTO } from '~/types/api/notification.types';
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { EmailAlertDTO, ErrorResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
//Lib
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { WizardEnvEnum, WizardEnvType } from '~/types/domain/config.types';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { ErrorResponse, WizardEnvEnum, WizardEnvType } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
|
|||
import { getServerSession } from 'next-auth/next';
|
||||
import { promisify } from 'util';
|
||||
import { ConfigService } from '~/services';
|
||||
import { ErrorResponse, SuccessResponse } from '~/types/api/error.types';
|
||||
import { ErrorResponse, SuccessResponse } from '~/types';
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { IntegrationTokenType, TokenPermissionsType } from '~/types/api/integration.types';
|
||||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { ConfigService } from '~/services';
|
||||
import { getUnixTime } from 'date-fns';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { BorgWarehouseApiResponse } from '~/types/api/error.types';
|
||||
import { BorgWarehouseApiResponse, IntegrationTokenType, TokenPermissionsType } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: Partial<IntegrationTokenType> },
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ import { ConfigService } from '~/services';
|
|||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { AppriseAlertDTO, AppriseAlertResponse } from '~/types/api/notification.types';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { ErrorResponse, AppriseAlertDTO, AppriseAlertResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: AppriseAlertDTO },
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import { ConfigService } from '~/services';
|
|||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { AppriseModeDTO } from '~/types/api/notification.types';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { AppriseModeDTO, ErrorResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: AppriseModeDTO },
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
//Lib
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { AppriseServicesDTO } from '~/types/api/notification.types';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { ConfigService } from '~/services';
|
||||
import { AppriseServicesDTO, ErrorResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: AppriseServicesDTO },
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import { ConfigService } from '~/services';
|
|||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { EmailSettingDTO } from '~/types/api/setting.types';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { EmailSettingDTO, ErrorResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: EmailSettingDTO },
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { ConfigService } from '~/services';
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { EmailAlertDTO } from '~/types/api/notification.types';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { EmailAlertDTO, ErrorResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: EmailAlertDTO },
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import { authOptions } from '../auth/[...nextauth]';
|
|||
import { ConfigService, AuthService } from '~/services';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { PasswordSettingDTO } from '~/types/api/setting.types';
|
||||
import { ErrorResponse, PasswordSettingDTO } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: PasswordSettingDTO },
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { ConfigService } from '~/services';
|
||||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { UsernameSettingDTO } from '~/types/api/setting.types';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { ErrorResponse } from '~/types/api/error.types';
|
||||
import { ErrorResponse, UsernameSettingDTO } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest & { body: UsernameSettingDTO },
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { promisify } from 'util';
|
|||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { ConfigService, NotifService, ShellService } from '~/services';
|
||||
import emailAlertStatus from '~/helpers/templates/emailAlertStatus';
|
||||
import { BorgWarehouseApiResponse } from '~/types/api/error.types';
|
||||
import { BorgWarehouseApiResponse } from '~/types';
|
||||
|
||||
const exec = promisify(execCallback);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { ConfigService, ShellService } from '~/services';
|
||||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { BorgWarehouseApiResponse } from '~/types/api/error.types';
|
||||
import { BorgWarehouseApiResponse } from '~/types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { isSshPubKeyDuplicate } from '~/helpers/functions';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
import { Repository } from '~/types';
|
||||
import { getUnixTime } from 'date-fns';
|
||||
import { ConfigService, ShellService, AuthService } from '~/services';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { ConfigService, ShellService, AuthService } from '~/services';
|
||||
|
||||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { BorgWarehouseApiResponse } from '~/types/api/error.types';
|
||||
import { authOptions } from '../../../auth/[...nextauth]';
|
||||
import { BorgWarehouseApiResponse } from '~/types';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { authOptions } from '../../../auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { isSshPubKeyDuplicate } from '~/helpers/functions';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
import { Repository } from '~/types';
|
||||
import { ConfigService, ShellService, AuthService } from '~/services';
|
||||
|
||||
export default async function handler(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { authOptions } from '../../../auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { BorgWarehouseApiResponse } from '~/types/api/error.types';
|
||||
import { BorgWarehouseApiResponse, Repository } from '~/types';
|
||||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
import { ConfigService, AuthService } from '~/services';
|
||||
|
||||
export default async function handler(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { authOptions } from '../auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { BorgWarehouseApiResponse } from '~/types/api/error.types';
|
||||
import { BorgWarehouseApiResponse, Repository } from '~/types';
|
||||
import ApiResponse from '~/helpers/functions/apiResponse';
|
||||
import { ConfigService, AuthService } from '~/services';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { createMocks } from 'node-mocks-http';
|
|||
import handler from '~/pages/api/repo';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { ConfigService, AuthService } from '~/services';
|
||||
import { Repository } from '~/types/domain/config.types';
|
||||
import { Repository } from '~/types';
|
||||
|
||||
vi.mock('next-auth/next', () => ({
|
||||
getServerSession: vi.fn(),
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
//Lib
|
||||
import { authOptions } from './api/auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import Head from 'next/head';
|
||||
|
||||
//Lib
|
||||
import RepoList from '../Containers/RepoList/RepoList';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
|
||||
|
|
@ -32,7 +29,6 @@ export default function Index() {
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
//Var
|
||||
const session = await getServerSession(context.req, context.res, authOptions);
|
||||
|
||||
if (!session) {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
//Lib
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { signIn, useSession } from 'next-auth/react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { SpinnerDotted } from 'spinners-react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { authOptions } from './api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { useFormStatus } from '~/hooks/useFormStatus';
|
||||
import { signIn, useSession } from 'next-auth/react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useEffect } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { SpinnerDotted } from 'spinners-react';
|
||||
import { useFormStatus } from '~/hooks';
|
||||
import { authOptions } from './api/auth/[...nextauth]';
|
||||
|
||||
//Components
|
||||
import Error from '../Components/UI/Error/Error';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
import Error from '../Components/UI/Error/Error';
|
||||
|
||||
type LoginForm = {
|
||||
username: string;
|
||||
|
|
@ -18,7 +17,6 @@ type LoginForm = {
|
|||
};
|
||||
|
||||
export default function Login() {
|
||||
//Var
|
||||
const { status } = useSession();
|
||||
const {
|
||||
register,
|
||||
|
|
@ -175,7 +173,6 @@ export default function Login() {
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
//Var
|
||||
const session = await getServerSession(context.req, context.res, authOptions);
|
||||
|
||||
//Here, if I am connected, I redirect to the home page.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { GetServerSidePropsContext } from 'next';
|
||||
import RepoList from '~/Containers/RepoList/RepoList';
|
||||
import { authOptions } from '../api/auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
|
||||
export default function Add() {
|
||||
|
|
@ -8,7 +8,6 @@ export default function Add() {
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
//Var
|
||||
const session = await getServerSession(context.req, context.res, authOptions);
|
||||
|
||||
if (!session) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { GetServerSidePropsContext } from 'next';
|
||||
import RepoList from '~/Containers/RepoList/RepoList';
|
||||
import { authOptions } from '../../api/auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
|
||||
export default function Add() {
|
||||
|
|
@ -8,7 +8,6 @@ export default function Add() {
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
//Var
|
||||
const session = await getServerSession(context.req, context.res, authOptions);
|
||||
|
||||
if (!session) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import Head from 'next/head';
|
||||
import { authOptions } from '../api/auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
|
||||
|
|
@ -47,7 +47,6 @@ export default function Monitoring() {
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
//Var
|
||||
const session = await getServerSession(context.req, context.res, authOptions);
|
||||
|
||||
if (!session) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
//Lib
|
||||
import SetupWizard from '../../Containers/SetupWizard/SetupWizard';
|
||||
import { useRouter } from 'next/router';
|
||||
import Head from 'next/head';
|
||||
import { authOptions } from '../api/auth/[...nextauth]';
|
||||
import { authOptions } from '~/pages/api/auth/[...nextauth]';
|
||||
import { getServerSession } from 'next-auth/next';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
|
||||
|
|
@ -23,7 +22,6 @@ export default function SetupWizardStep() {
|
|||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
//Var
|
||||
const session = await getServerSession(context.req, context.res, authOptions);
|
||||
|
||||
if (!session) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { hash, compare } from 'bcryptjs';
|
||||
import { compare, hash } from 'bcryptjs';
|
||||
import { IncomingHttpHeaders } from 'http2';
|
||||
import { Optional } from '~/types';
|
||||
import { TokenPermissionsType } from '~/types/api/integration.types';
|
||||
import { ConfigService } from '~/services';
|
||||
import { Optional, TokenPermissionsType } from '~/types';
|
||||
|
||||
export const AuthService = {
|
||||
hashPassword: async (password: string): Promise<string> => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { promises as fs } from 'fs';
|
|||
import { JSONFile } from 'lowdb/node';
|
||||
import path from 'path';
|
||||
import { Mutex } from 'async-mutex';
|
||||
import { BorgWarehouseUser, Repository } from '~/types/domain/config.types';
|
||||
import { BorgWarehouseUser, Repository } from '~/types';
|
||||
|
||||
const jsonDirectory = path.join(process.cwd(), '/config');
|
||||
const usersDbPath = path.join(jsonDirectory, 'users.json');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import path from 'path';
|
||||
import { promisify } from 'util';
|
||||
import { exec as execCallback } from 'node:child_process';
|
||||
import { LastSaveDTO, StorageUsedDTO } from '~/types/api/shell.types';
|
||||
import { LastSaveDTO, StorageUsedDTO } from '~/types';
|
||||
|
||||
const exec = promisify(execCallback);
|
||||
const shellsDirectory = path.join(process.cwd(), '/helpers/shells');
|
||||
|
|
|
|||
6
types/api/index.ts
Normal file
6
types/api/index.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export * from './error.types';
|
||||
export * from './integration.types';
|
||||
export * from './next-auth.types';
|
||||
export * from './notification.types';
|
||||
export * from './setting.types';
|
||||
export * from './shell.types';
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
export type EmailSettingDTO = {
|
||||
email: string;
|
||||
email?: string;
|
||||
};
|
||||
|
||||
export type UsernameSettingDTO = {
|
||||
username: string;
|
||||
username?: string;
|
||||
};
|
||||
|
||||
export type PasswordSettingDTO = {
|
||||
|
|
|
|||
3
types/domain/index.ts
Normal file
3
types/domain/index.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export * from './config.types';
|
||||
export * from './constants';
|
||||
export * from './wizard.types';
|
||||
|
|
@ -1 +1,3 @@
|
|||
export * from './optional';
|
||||
export * from './api';
|
||||
export * from './domain';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue