Migrate all getCookies to use main-axios.
This commit is contained in:
@@ -29,16 +29,10 @@ import {
|
|||||||
disableOIDCConfig,
|
disableOIDCConfig,
|
||||||
makeUserAdmin,
|
makeUserAdmin,
|
||||||
removeAdminStatus,
|
removeAdminStatus,
|
||||||
deleteUser
|
deleteUser,
|
||||||
|
getCookie
|
||||||
} from "@/ui/main-axios.ts";
|
} from "@/ui/main-axios.ts";
|
||||||
|
|
||||||
function getCookie(name: string) {
|
|
||||||
return document.cookie.split('; ').reduce((r, v) => {
|
|
||||||
const parts = v.split('=');
|
|
||||||
return parts[0] === name ? decodeURIComponent(parts[1]) : r;
|
|
||||||
}, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AdminSettingsProps {
|
interface AdminSettingsProps {
|
||||||
isTopbarOpen?: boolean;
|
isTopbarOpen?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {Unicode11Addon} from '@xterm/addon-unicode11';
|
|||||||
import {WebLinksAddon} from '@xterm/addon-web-links';
|
import {WebLinksAddon} from '@xterm/addon-web-links';
|
||||||
import {useTranslation} from 'react-i18next';
|
import {useTranslation} from 'react-i18next';
|
||||||
import {toast} from 'sonner';
|
import {toast} from 'sonner';
|
||||||
|
import {getCookie} from '@/ui/main-axios.ts';
|
||||||
|
|
||||||
interface SSHTerminalProps {
|
interface SSHTerminalProps {
|
||||||
hostConfig: any;
|
hostConfig: any;
|
||||||
@@ -131,12 +132,6 @@ export const Terminal = forwardRef<any, SSHTerminalProps>(function SSHTerminal(
|
|||||||
hardRefresh();
|
hardRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCookie(name: string) {
|
|
||||||
return document.cookie.split('; ').reduce((r, v) => {
|
|
||||||
const parts = v.split('=');
|
|
||||||
return parts[0] === name ? decodeURIComponent(parts[1]) : r;
|
|
||||||
}, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUseRightClickCopyPaste() {
|
function getUseRightClickCopyPaste() {
|
||||||
return getCookie("rightClickCopyPaste") === "true"
|
return getCookie("rightClickCopyPaste") === "true"
|
||||||
|
|||||||
@@ -21,18 +21,12 @@ import {
|
|||||||
getOIDCAuthorizeUrl,
|
getOIDCAuthorizeUrl,
|
||||||
verifyTOTPLogin,
|
verifyTOTPLogin,
|
||||||
setCookie,
|
setCookie,
|
||||||
|
getCookie,
|
||||||
getServerConfig,
|
getServerConfig,
|
||||||
type ServerConfig
|
type ServerConfig
|
||||||
} from "../../main-axios.ts";
|
} from "../../main-axios.ts";
|
||||||
import {ServerConfig as ServerConfigComponent} from "@/ui/Desktop/ElectronOnly/ServerConfig.tsx";
|
import {ServerConfig as ServerConfigComponent} from "@/ui/Desktop/ElectronOnly/ServerConfig.tsx";
|
||||||
|
|
||||||
function getCookie(name: string) {
|
|
||||||
return document.cookie.split('; ').reduce((r, v) => {
|
|
||||||
const parts = v.split('=');
|
|
||||||
return parts[0] === name ? decodeURIComponent(parts[1]) : r;
|
|
||||||
}, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HomepageAuthProps extends React.ComponentProps<"div"> {
|
interface HomepageAuthProps extends React.ComponentProps<"div"> {
|
||||||
setLoggedIn: (loggedIn: boolean) => void;
|
setLoggedIn: (loggedIn: boolean) => void;
|
||||||
setIsAdmin: (isAdmin: boolean) => void;
|
setIsAdmin: (isAdmin: boolean) => void;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {Checkbox} from "@/components/ui/checkbox.tsx";
|
|||||||
import {Separator} from "@/components/ui/separator.tsx";
|
import {Separator} from "@/components/ui/separator.tsx";
|
||||||
import {useTranslation} from "react-i18next";
|
import {useTranslation} from "react-i18next";
|
||||||
import {TabDropdown} from "@/ui/Desktop/Navigation/Tabs/TabDropdown.tsx";
|
import {TabDropdown} from "@/ui/Desktop/Navigation/Tabs/TabDropdown.tsx";
|
||||||
|
import {getCookie, setCookie} from "@/ui/main-axios.ts";
|
||||||
|
|
||||||
interface TopNavbarProps {
|
interface TopNavbarProps {
|
||||||
isTopbarOpen: boolean;
|
isTopbarOpen: boolean;
|
||||||
@@ -204,15 +205,8 @@ export function TopNavbar({isTopbarOpen, setIsTopbarOpen}: TopNavbarProps): Reac
|
|||||||
|
|
||||||
const terminalTabs = tabs.filter((tab: any) => tab.type === 'terminal');
|
const terminalTabs = tabs.filter((tab: any) => tab.type === 'terminal');
|
||||||
|
|
||||||
function getCookie(name: string) {
|
|
||||||
return document.cookie.split('; ').reduce((r, v) => {
|
|
||||||
const parts = v.split('=');
|
|
||||||
return parts[0] === name ? decodeURIComponent(parts[1]) : r;
|
|
||||||
}, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
const updateRightClickCopyPaste = (checked: boolean) => {
|
const updateRightClickCopyPaste = (checked: boolean) => {
|
||||||
document.cookie = `rightClickCopyPaste=${checked}; expires=2147483647; path=/`;
|
setCookie("rightClickCopyPaste", checked.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -18,17 +18,11 @@ import {
|
|||||||
completePasswordReset,
|
completePasswordReset,
|
||||||
getOIDCAuthorizeUrl,
|
getOIDCAuthorizeUrl,
|
||||||
verifyTOTPLogin,
|
verifyTOTPLogin,
|
||||||
setCookie
|
setCookie,
|
||||||
|
getCookie
|
||||||
} from "@/ui/main-axios.ts";
|
} from "@/ui/main-axios.ts";
|
||||||
import {PasswordInput} from "@/components/ui/password-input.tsx";
|
import {PasswordInput} from "@/components/ui/password-input.tsx";
|
||||||
|
|
||||||
function getCookie(name: string) {
|
|
||||||
return document.cookie.split('; ').reduce((r, v) => {
|
|
||||||
const parts = v.split('=');
|
|
||||||
return parts[0] === name ? decodeURIComponent(parts[1]) : r;
|
|
||||||
}, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HomepageAuthProps extends React.ComponentProps<"div"> {
|
interface HomepageAuthProps extends React.ComponentProps<"div"> {
|
||||||
setLoggedIn: (loggedIn: boolean) => void;
|
setLoggedIn: (loggedIn: boolean) => void;
|
||||||
setIsAdmin: (isAdmin: boolean) => void;
|
setIsAdmin: (isAdmin: boolean) => void;
|
||||||
|
|||||||
@@ -4,17 +4,10 @@ import {TerminalKeyboard} from "@/ui/Mobile/Apps/Terminal/TerminalKeyboard.tsx";
|
|||||||
import {BottomNavbar} from "@/ui/Mobile/Navigation/BottomNavbar.tsx";
|
import {BottomNavbar} from "@/ui/Mobile/Navigation/BottomNavbar.tsx";
|
||||||
import {LeftSidebar} from "@/ui/Mobile/Navigation/LeftSidebar.tsx";
|
import {LeftSidebar} from "@/ui/Mobile/Navigation/LeftSidebar.tsx";
|
||||||
import {TabProvider, useTabs} from "@/ui/Mobile/Navigation/Tabs/TabContext.tsx";
|
import {TabProvider, useTabs} from "@/ui/Mobile/Navigation/Tabs/TabContext.tsx";
|
||||||
import {getUserInfo} from "@/ui/main-axios.ts";
|
import {getUserInfo, getCookie} from "@/ui/main-axios.ts";
|
||||||
import {HomepageAuth} from "@/ui/Mobile/Homepage/HomepageAuth.tsx";
|
import {HomepageAuth} from "@/ui/Mobile/Homepage/HomepageAuth.tsx";
|
||||||
import {useTranslation} from "react-i18next";
|
import {useTranslation} from "react-i18next";
|
||||||
|
|
||||||
function getCookie(name: string) {
|
|
||||||
return document.cookie.split('; ').reduce((r, v) => {
|
|
||||||
const parts = v.split('=');
|
|
||||||
return parts[0] === name ? decodeURIComponent(parts[1]) : r;
|
|
||||||
}, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
const AppContent: FC = () => {
|
const AppContent: FC = () => {
|
||||||
const {t} = useTranslation();
|
const {t} = useTranslation();
|
||||||
const {tabs, currentTab, getTab, removeTab} = useTabs();
|
const {tabs, currentTab, getTab, removeTab} = useTabs();
|
||||||
|
|||||||
Reference in New Issue
Block a user