mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-01 21:42:29 +02:00
feat: integrate LAN option with quicksettings
This commit is contained in:
parent
f1fdbc47fc
commit
fb9d84226d
|
@ -5,6 +5,23 @@ import classes from './QuickCommands.module.css';
|
||||||
import { IconSettingsAutomation, IconCopy } from '@tabler/icons';
|
import { IconSettingsAutomation, IconCopy } from '@tabler/icons';
|
||||||
|
|
||||||
export default function QuickCommands(props) {
|
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
|
//State
|
||||||
const [isCopied, setIsCopied] = useState(false);
|
const [isCopied, setIsCopied] = useState(false);
|
||||||
|
|
||||||
|
@ -13,7 +30,7 @@ export default function QuickCommands(props) {
|
||||||
// Asynchronously call copy to clipboard
|
// Asynchronously call copy to clipboard
|
||||||
navigator.clipboard
|
navigator.clipboard
|
||||||
.writeText(
|
.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(() => {
|
.then(() => {
|
||||||
// If successful, update the isCopied state value
|
// If successful, update the isCopied state value
|
||||||
|
@ -34,8 +51,7 @@ export default function QuickCommands(props) {
|
||||||
) : (
|
) : (
|
||||||
<div className={classes.tooltip}>
|
<div className={classes.tooltip}>
|
||||||
borg init -e repokey-blake2 ssh://{props.unixUser}@
|
borg init -e repokey-blake2 ssh://{props.unixUser}@
|
||||||
{process.env.NEXT_PUBLIC_HOSTNAME}:
|
{HOSTNAME}:{SSH_SERVER_PORT}/./
|
||||||
{process.env.NEXT_PUBLIC_SSH_SERVER_PORT}/./
|
|
||||||
{props.repository}
|
{props.repository}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -34,6 +34,7 @@ export default function Repo(props) {
|
||||||
<QuickCommands
|
<QuickCommands
|
||||||
unixUser={props.unixUser}
|
unixUser={props.unixUser}
|
||||||
repository={props.repository}
|
repository={props.repository}
|
||||||
|
lanCommand={props.lanCommand}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ export default function RepoList() {
|
||||||
displayDetails={repo.displayDetails}
|
displayDetails={repo.displayDetails}
|
||||||
unixUser={repo.unixUser}
|
unixUser={repo.unixUser}
|
||||||
comment={repo.comment}
|
comment={repo.comment}
|
||||||
|
lanCommand={repo.lanCommand}
|
||||||
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
|
repoManageEditHandler={() => repoManageEditHandler(repo.id)}
|
||||||
></Repo>
|
></Repo>
|
||||||
{repo.displayDetails ? (
|
{repo.displayDetails ? (
|
||||||
|
|
Loading…
Reference in a new issue