mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 00:29:41 +00:00
refactor: add nif to navigation
This commit is contained in:
committed by
Carlos Valente
parent
ab847a324b
commit
dd4a165b08
@@ -8,5 +8,5 @@
|
|||||||
.linkIcon {
|
.linkIcon {
|
||||||
margin-left: $element-inner-spacing;
|
margin-left: $element-inner-spacing;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
transform: rotate(45deg);
|
@include rotate-fourty-five;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,9 +72,33 @@ $button-size: 3rem;
|
|||||||
|
|
||||||
.linkIcon {
|
.linkIcon {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
transform: rotate(45deg);
|
@include rotate-fourty-five;
|
||||||
}
|
}
|
||||||
|
|
||||||
.separator {
|
.separator {
|
||||||
border-color: $border-color-ondark;
|
border-color: $border-color-ondark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sectionHeader {
|
||||||
|
font-size: calc(1rem - 2px);
|
||||||
|
margin-left: 1rem;
|
||||||
|
color: $gray-700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom {
|
||||||
|
margin-top: auto;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.interfaces {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goIcon {
|
||||||
|
@include rotate-fourty-five;
|
||||||
|
margin-left: 0.25rem;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,14 +18,17 @@ import { IoLockClosedOutline } from '@react-icons/all-files/io5/IoLockClosedOutl
|
|||||||
import { IoSwapVertical } from '@react-icons/all-files/io5/IoSwapVertical';
|
import { IoSwapVertical } from '@react-icons/all-files/io5/IoSwapVertical';
|
||||||
|
|
||||||
import { navigatorConstants } from '../../../viewerConfig';
|
import { navigatorConstants } from '../../../viewerConfig';
|
||||||
|
import { isLocalhost, serverPort } from '../../api/constants';
|
||||||
import useClickOutside from '../../hooks/useClickOutside';
|
import useClickOutside from '../../hooks/useClickOutside';
|
||||||
import useElectronEvent from '../../hooks/useElectronEvent';
|
import useElectronEvent from '../../hooks/useElectronEvent';
|
||||||
|
import useInfo from '../../hooks-query/useInfo';
|
||||||
import { useClientStore } from '../../stores/clientStore';
|
import { useClientStore } from '../../stores/clientStore';
|
||||||
import { useViewOptionsStore } from '../../stores/viewOptions';
|
import { useViewOptionsStore } from '../../stores/viewOptions';
|
||||||
import { isKeyEnter } from '../../utils/keyEvent';
|
import { isKeyEnter } from '../../utils/keyEvent';
|
||||||
import { handleLinks } from '../../utils/linkUtils';
|
import { handleLinks, openLink } from '../../utils/linkUtils';
|
||||||
import { cx } from '../../utils/styleUtils';
|
import { cx } from '../../utils/styleUtils';
|
||||||
import { RenameClientModal } from '../client-modal/RenameClientModal';
|
import { RenameClientModal } from '../client-modal/RenameClientModal';
|
||||||
|
import CopyTag from '../copy-tag/CopyTag';
|
||||||
|
|
||||||
import style from './NavigationMenu.module.scss';
|
import style from './NavigationMenu.module.scss';
|
||||||
|
|
||||||
@@ -54,7 +57,7 @@ function NavigationMenu(props: NavigationMenuProps) {
|
|||||||
<RenameClientModal id={id} name={name} isOpen={isOpenRename} onClose={onCloseRename} />
|
<RenameClientModal id={id} name={name} isOpen={isOpenRename} onClose={onCloseRename} />
|
||||||
<Drawer placement='left' onClose={onClose} isOpen={isOpen} variant='ontime' data-testid='navigation__menu'>
|
<Drawer placement='left' onClose={onClose} isOpen={isOpen} variant='ontime' data-testid='navigation__menu'>
|
||||||
<DrawerOverlay />
|
<DrawerOverlay />
|
||||||
<DrawerContent>
|
<DrawerContent maxWidth='21rem'>
|
||||||
<DrawerHeader>
|
<DrawerHeader>
|
||||||
<DrawerCloseButton size='lg' />
|
<DrawerCloseButton size='lg' />
|
||||||
Ontime
|
Ontime
|
||||||
@@ -120,6 +123,7 @@ function NavigationMenu(props: NavigationMenuProps) {
|
|||||||
{route.label}
|
{route.label}
|
||||||
</ClientLink>
|
</ClientLink>
|
||||||
))}
|
))}
|
||||||
|
{isLocalhost && <OtherAddresses currentLocation={location.pathname} />}
|
||||||
</DrawerBody>
|
</DrawerBody>
|
||||||
</DrawerContent>
|
</DrawerContent>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
@@ -128,6 +132,45 @@ function NavigationMenu(props: NavigationMenuProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface OtherAddressesProps {
|
||||||
|
currentLocation: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function OtherAddresses(props: OtherAddressesProps) {
|
||||||
|
const { currentLocation } = props;
|
||||||
|
const { data } = useInfo();
|
||||||
|
|
||||||
|
// there is no point showing this if we only have one interface
|
||||||
|
if (data.networkInterfaces.length < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={style.bottom}>
|
||||||
|
<div className={style.sectionHeader}>Accessible on external networks</div>
|
||||||
|
<div className={style.interfaces}>
|
||||||
|
{data?.networkInterfaces?.map((nif) => {
|
||||||
|
if (nif.name === 'localhost') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const address = `http://${nif.address}:${serverPort}${currentLocation}`;
|
||||||
|
return (
|
||||||
|
<CopyTag
|
||||||
|
key={nif.name}
|
||||||
|
copyValue={address}
|
||||||
|
onClick={() => openLink(address)}
|
||||||
|
label='Copy IP or navigate to address'
|
||||||
|
>
|
||||||
|
{nif.address} <IoArrowUp className={style.goIcon} />
|
||||||
|
</CopyTag>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
interface ClientLinkProps {
|
interface ClientLinkProps {
|
||||||
current: boolean;
|
current: boolean;
|
||||||
to: string;
|
to: string;
|
||||||
|
|||||||
+2
-1
@@ -6,6 +6,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.goIcon {
|
.goIcon {
|
||||||
transform: rotate(45deg);
|
@include rotate-fourty-five;
|
||||||
margin-left: 0.25rem;
|
margin-left: 0.25rem;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.corner {
|
.corner {
|
||||||
transform: rotate(45deg);
|
@include rotate-fourty-five;
|
||||||
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0.5rem;
|
top: 0.5rem;
|
||||||
|
|||||||
@@ -21,3 +21,11 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@mixin rotate-fourty-five {
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fourtyfive {
|
||||||
|
@include rotate-fourty-five;
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,4 +30,4 @@ $external-color: rgba(white, 85%); // --external-color-override
|
|||||||
|
|
||||||
// properties of other timers (clock and countdown)
|
// properties of other timers (clock and countdown)
|
||||||
$timer-label-size: clamp(16px, 1.5vw, 24px);
|
$timer-label-size: clamp(16px, 1.5vw, 24px);
|
||||||
$timer-value-size: clamp(2rem, 3.5vw, 3.5rem);
|
$timer-value-size: clamp(2rem, 3.5vw, 3.5rem);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ export const ontimeDrawer = {
|
|||||||
backgroundColor: '#202020', // $gray-1250
|
backgroundColor: '#202020', // $gray-1250
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
color: '#fefefe', // $gray-50
|
color: '#fefefe', // $gray-50
|
||||||
backgroundColor: '#202020', // $gray-1250
|
backgroundColor: '#202020', // $gray-1250
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user