feat: integrate LAN option with quicksettings

This commit is contained in:
bsourisse 2023-06-11 15:39:11 +02:00
parent f1fdbc47fc
commit fb9d84226d
3 changed files with 21 additions and 3 deletions

View file

@ -5,6 +5,23 @@ import classes from './QuickCommands.module.css';
import { IconSettingsAutomation, IconCopy } from '@tabler/icons';
export default function QuickCommands(props) {
////Vars
//Needed to generate command for borg over LAN instead of WAN if env vars are set and option enabled.
let HOSTNAME;
let SSH_SERVER_PORT;
console.log(props.lanCommand);
if (
props.lanCommand &&
process.env.NEXT_PUBLIC_HOSTNAME_LAN &&
process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN
) {
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME_LAN;
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT_LAN;
} else {
HOSTNAME = process.env.NEXT_PUBLIC_HOSTNAME;
SSH_SERVER_PORT = process.env.NEXT_PUBLIC_SSH_SERVER_PORT;
}
//State
const [isCopied, setIsCopied] = useState(false);
@ -13,7 +30,7 @@ export default function QuickCommands(props) {
// Asynchronously call copy to clipboard
navigator.clipboard
.writeText(
`borg init -e repokey-blake2 ssh://${props.unixUser}@${process.env.NEXT_PUBLIC_HOSTNAME}:${process.env.NEXT_PUBLIC_SSH_SERVER_PORT}/./${props.repository}`
`borg init -e repokey-blake2 ssh://${props.unixUser}@${HOSTNAME}:${SSH_SERVER_PORT}/./${props.repository}`
)
.then(() => {
// If successful, update the isCopied state value
@ -34,8 +51,7 @@ export default function QuickCommands(props) {
) : (
<div className={classes.tooltip}>
borg init -e repokey-blake2 ssh://{props.unixUser}@
{process.env.NEXT_PUBLIC_HOSTNAME}:
{process.env.NEXT_PUBLIC_SSH_SERVER_PORT}/./
{HOSTNAME}:{SSH_SERVER_PORT}/./
{props.repository}
</div>
)}

View file

@ -34,6 +34,7 @@ export default function Repo(props) {
<QuickCommands
unixUser={props.unixUser}
repository={props.repository}
lanCommand={props.lanCommand}
/>
</div>

View file

@ -136,6 +136,7 @@ export default function RepoList() {
displayDetails={repo.displayDetails}
unixUser={repo.unixUser}
comment={repo.comment}
lanCommand={repo.lanCommand}
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
></Repo>
{repo.displayDetails ? (