Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ PODS:
- fmt (6.2.1)
- glog (0.3.5)
- libevent (2.1.12)
- LicensePlist (3.17.0)
- LicensePlist (3.22.0)
- lottie-ios (3.2.3)
- lottie-react-native (5.0.1):
- lottie-ios (~> 3.2.3)
Expand Down Expand Up @@ -289,9 +289,9 @@ PODS:
- React-jsinspector (0.68.1)
- React-logger (0.68.1):
- glog
- react-native-riden-ssh (1.8.19):
- react-native-riden-ssh (1.8.22):
- React
- SwifterSwiftSSH (~> 1.2.5)
- SwifterSwiftSSH (~> 1.3.0)
- react-native-safe-area-context (3.4.0):
- React-Core
- react-native-version-info (1.1.1):
Expand Down Expand Up @@ -413,7 +413,7 @@ PODS:
- RNVectorIcons (9.1.0):
- React-Core
- SocketRocket (0.6.0)
- SwifterSwiftSSH (1.2.5)
- SwifterSwiftSSH (1.3.0)
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)
Expand Down Expand Up @@ -631,13 +631,13 @@ SPEC CHECKSUMS:
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 85ecdd10ee8d8ec362ef519a6a45ff9aa27b2e85
glog: 476ee3e89abb49e07f822b48323c51c57124b572
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LicensePlist: f7eaf6d1d39746d49415ab30f104b734d5163519
LicensePlist: be4f67fadceeba970ed2f13e198592a4f420d2be
lottie-ios: c058aeafa76daa4cf64d773554bccc8385d0150e
lottie-react-native: a029a86e1689c86a07169c520ae770e84348cd20
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685
RCT-Folly: 4d8508a426467c48885f1151029bc15fa5d7b3b8
RCTRequired: 00581111c53531e39e3c6346ef0d2c0cf52a5a37
RCTTypeSafety: 07e03ee7800e7dd65cba8e52ad0c2edb06c96604
React: e61f4bf3c573d0c61c56b53dc3eb1d9daf0768a0
Expand All @@ -650,7 +650,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 4a4bae5671b064a2248a690cf75957669489d08c
React-jsinspector: 218a2503198ff28a085f8e16622a8d8f507c8019
React-logger: f79dd3cc0f9b44f5611c6c7862badd891a862cf8
react-native-riden-ssh: b4adf98dd6b489b1defcfef1ccf3561bbe416a65
react-native-riden-ssh: 988bbae663a42f2d7ee5fcbd3a2a68fe1172096a
react-native-safe-area-context: f4f7cc09d81ae2d39dfd13e764d718969af07080
react-native-version-info: a106f23009ac0db4ee00de39574eb546682579b9
react-native-zeroconf: 8c7f309c76f95264d20e95270eb8366c57272894
Expand Down Expand Up @@ -678,10 +678,10 @@ SPEC CHECKSUMS:
RNSVG: 551acb6562324b1d52a4e0758f7ca0ec234e278f
RNVectorIcons: 7923e585eaeb139b9f4531d25a125a1500162a0b
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
SwifterSwiftSSH: bd29d6534fd1d524634e18bf6ce0259a53b1a70f
SwifterSwiftSSH: d7807d5b505e3c79ae66af2fb85cb67bf9a7a75c
Yoga: 17cd9a50243093b547c1e539c749928dd68152da
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 285940e8cac36e75db6f9d9494822d4f2031ef48

COCOAPODS: 1.11.3
COCOAPODS: 1.11.2
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"pod": "(cd ios && pod install)",
"pod:update": "(cd ios && pod update)",
"pod": "(cd ios && bundle exec pod install)",
"pod:update": "(cd ios && bundle exec pod update)",
"xcode": "open ios/RIDEN.xcworkspace",
"icons": "yarn svgr --out-dir src/assets/cases --index-template svgr.indextemplate.js src/assets/cases/svgs",
"ios:beta": "fastlane ios beta",
Expand All @@ -26,8 +26,8 @@
"@react-navigation/drawer": "^6.3.0",
"@react-navigation/native": "^6.0.6",
"@react-navigation/stack": "^6.0.11",
"@ridenui/react-native-riden-ssh": "^1.8.19",
"@ridenui/unraid": "^0.16.7",
"@ridenui/react-native-riden-ssh": "^1.8.22",
"@ridenui/unraid": "^0.17.0",
"@types/react": "^17.0.39",
"async": "^3.2.2",
"axios": "^0.26.0",
Expand Down Expand Up @@ -57,7 +57,7 @@
"react-native-version-info": "^1.1.1",
"react-native-zeroconf": "^0.13.6",
"react-refresh": "^0.11.0",
"styled-components": "^5.3.3",
"styled-components": "^5.3.5",
"ts-mixer": "^6.0.0",
"yup": "^0.32.11"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export function AutoDiscoverCard({ device, onPress }: AutoDiscoverCardProps): JS
<S.AutoDiscoverCard onPress={() => onPress(device)} width={width}>
<View>
<Typography variant={TypographyVariants.H3}>{device.name}</Typography>
{device.description && <Typography variant={TypographyVariants.Paragraph}>{device.description}</Typography>}
{device.description ? (
<Typography variant={TypographyVariants.Paragraph}>{device.description}</Typography>
) : null}
<S.HostnameText variant={TypographyVariants.Paragraph}>Found at {device.ssh.hostname}</S.HostnameText>
</View>
<View />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ export function CpuUsageWidget(): JSX.Element {
// 0 means no refresh
if (dashboard.cpuRefresh !== 0) {
interval = setInterval(() => {
console.log('refreshing...');
fetchUsage();
}, dashboard.cpuRefresh);
}

return () => (interval ? clearInterval(interval) : undefined);
return () => {
if (interval) {
console.log('Clearing inv');
clearInterval(interval);
}
};
}, [instance, dashboard.cpuRefresh]);

if (!cpuUsage) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Typography } from '@atoms/Typography/Typography';
import styled from 'styled-components/native';

export const FeatureNotInstalled = styled.View`
display: flex;
justify-content: center;
align-items: center;
`;

export const Text = styled(Typography)`
color: ${({ theme }) => theme['400']};
text-align: center;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { View } from 'react-native';
import { Icon } from '@atoms/Icon/Icon';
import { TypographyVariants } from '@atoms/Typography/Typography';
import { useTheme } from 'styled-components';
import * as S from './FeatureNotInstalled.styled';

export interface FeatureNotInstalledProps {
featureName: string;
installationDescription: string;
}

export function FeatureNotInstalled({ featureName, installationDescription }: FeatureNotInstalledProps): JSX.Element {
const theme = useTheme();

return (
<S.FeatureNotInstalled>
<Icon name={'help-circle'} size={150} color={theme[700]} />
<View>
<S.Text variant={TypographyVariants.H3}>You don't have {featureName} installed.</S.Text>
<S.Text variant={TypographyVariants.Paragraph}>{installationDescription}</S.Text>
</View>
</S.FeatureNotInstalled>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Box } from '@atoms/Box/Box';
import styled from 'styled-components/native';

export const UserScriptCard = styled(Box)`
display: flex;
flex-direction: row;
align-items: center;
`;
16 changes: 16 additions & 0 deletions src/components/molecules/UserScriptCard/UserScriptCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { Typography, TypographyVariants } from '@atoms/Typography/Typography';
import type { UserScript } from '@ridenui/unraid/dist/modules/unraid/extensions/userscripts/user-script';
import * as S from './UserScriptCard.styled';

export interface UserScriptCardProps {
script: UserScript;
}

export function UserScriptCard({ script }: UserScriptCardProps): JSX.Element {
return (
<S.UserScriptCard>
<Typography variant={TypographyVariants.Paragraph}>{script.name}</Typography>
</S.UserScriptCard>
);
}
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { LogBox } from 'react-native';

LogBox.ignoreLogs(['ViewPropTypes', 'react-native-gesture-handler']);

export const DEBUG = false;

export enum ConfigValues {
Expand Down
21 changes: 20 additions & 1 deletion src/contexts/Server.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { log } from '@helpers/Logger';
import type { Container } from '@ridenui/unraid/dist/modules/docker/container';
import type { IDiskFreeReturn, IInfoResult } from '@ridenui/unraid/dist/modules/system/extensions';
import type { IdentConfig, RichNotification } from '@ridenui/unraid/dist/modules/unraid/extensions';
import type { UserScript } from '@ridenui/unraid/dist/modules/unraid/extensions/userscripts/user-script';
import { parse } from 'date-fns';
import { DEBUG } from '../constants';
import { useUnraid } from './Unraid.context';
Expand All @@ -21,7 +22,7 @@ type ServerProviderProps = {
children: ReactNode;
};

export type ReloadableProperties = 'notifications' | 'docker:containers';
export type ReloadableProperties = 'notifications' | 'docker:containers' | 'userscripts:all';

export type ServerProviderValue = {
hostname: string;
Expand All @@ -38,6 +39,10 @@ export type ServerProviderValue = {
reloadProperty: (property: ReloadableProperties) => void;
resetProperties: () => void;
isReloading: boolean;
userScripts: {
installed: boolean;
scripts: UserScript[];
};
};

const initialServerState: ServerProviderValue = {
Expand All @@ -50,6 +55,10 @@ const initialServerState: ServerProviderValue = {
docker: {
containers: [],
},
userScripts: {
installed: false,
scripts: [],
},
reloadProperties: () => {},
reloadProperty: () => {},
resetProperties: () => {},
Expand All @@ -69,6 +78,8 @@ export function ServerProvider({ children }: ServerProviderProps): JSX.Element {
const [diskUsage, setDiskUsage] = useState<IDiskFreeReturn[] | null>(null);
const [notifications, setNotifications] = useState<RichNotification[]>([]);
const [containers, setContainers] = useState<Container[]>([]);
const [hasUserScripts, setHasUserScripts] = useState(false);
const [userScriptList, setUserScriptList] = useState<UserScript[]>([]);
const { instance } = useUnraid();

const reloadProperties = useCallback(async () => {
Expand All @@ -83,6 +94,8 @@ export function ServerProvider({ children }: ServerProviderProps): JSX.Element {
[async () => setDiskUsage(await instance.system.diskfree()), 'diskfree'],
[async () => setNotifications(await instance.unraid.getNotifications()), 'notifications'],
[async () => setContainers(await instance.docker.list()), 'containers'],
[async () => setHasUserScripts(await instance.unraid.hasUserScriptsInstalled()), 'hasUserScripts'],
[async () => setUserScriptList(await instance.unraid.getUserScripts()), 'getUserScripts'],
[
async () => {
const { raw } = await instance.system.uptime();
Expand Down Expand Up @@ -130,6 +143,8 @@ export function ServerProvider({ children }: ServerProviderProps): JSX.Element {
setDiskUsage(null);
setNotifications([]);
setContainers([]);
setHasUserScripts(false);
setUserScriptList([]);
}, []);

const reloadProperty = useCallback(
Expand Down Expand Up @@ -181,6 +196,10 @@ export function ServerProvider({ children }: ServerProviderProps): JSX.Element {
docker: {
containers,
},
userScripts: {
installed: hasUserScripts,
scripts: userScriptList,
},
}}
>
{children}
Expand Down
1 change: 1 addition & 0 deletions src/navigation/DashboardStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Icon } from '@atoms/Icon/Icon';
import { createStackNavigator } from '@react-navigation/stack';
import { useTheme } from 'styled-components/native';
import { useServer } from '../contexts/Server.context';
import { useUnraid } from '../contexts/Unraid.context';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [eslint] <@typescript-eslint/no-unused-vars> reported by reviewdog 🐶
'useUnraid' is defined but never used.

import { DashboardScreen } from '../screens/dashboard/Dashboard.screen';
import { NotificationsScreen } from '../screens/notifications/Notifications';

Expand Down
3 changes: 3 additions & 0 deletions src/navigation/SideMenuStack.helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export function getDrawerIcon(route: string, focused: boolean, color: string, si
case 'Logout':
icon = 'log-out';
break;
case 'UserScripts':
icon = 'file-text';
break;
default:
icon = 'help-circle';
}
Expand Down
7 changes: 7 additions & 0 deletions src/navigation/SideMenuStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import { createDrawerNavigator } from '@react-navigation/drawer';
import { getNavigationStyle } from '@styles/NavigationStyle';
import { useTheme } from 'styled-components/native';
import { DEBUG } from '../constants';
import { useServer } from '../contexts/Server.context';
import { DebugScreen } from '../screens/debug/Debug.screen';
import { DockerContainerListScreen } from '../screens/dockercontainerlist/DockerContainerList';
import { SettingsScreen } from '../screens/settings/Settings.screen';
import { UserScriptsScreen } from '../screens/userscripts/UserScripts';
import { Dashboard } from './DashboardStack';
import { getDrawerIcon } from './SideMenuStack.helpers';

export type SideMenuStackParamList = {
DashboardStack: undefined;
DockerContainerList: undefined;
UserScripts: undefined;
Settings: undefined;
Debug: undefined;
};
Expand All @@ -25,6 +28,7 @@ export const SideMenuStack = createDrawerNavigator<SideMenuStackParamList>();

export function SideMenuNavigation() {
const theme = useTheme();
const { userScripts } = useServer();

return (
<SideMenuStack.Navigator
Expand All @@ -49,6 +53,9 @@ export function SideMenuNavigation() {
component={DockerContainerListScreen}
options={{ title: 'Docker' }}
/>
{userScripts.installed && (
<SideMenuStack.Screen name={'UserScripts'} component={UserScriptsScreen} options={{ title: 'User Scripts' }} />
)}
<SideMenuStack.Screen name={'Settings'} component={SettingsScreen} />
{DEBUG && <SideMenuStack.Screen name={'Debug'} component={DebugScreen} />}
</SideMenuStack.Navigator>
Expand Down
7 changes: 7 additions & 0 deletions src/screens/userscripts/UserScripts.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styled from 'styled-components/native';

export const Container = styled.SafeAreaView`
background: ${({ theme }) => theme['600']};
flex: 1;
flex-direction: column;
`;
38 changes: 38 additions & 0 deletions src/screens/userscripts/UserScripts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import { FlatList, RefreshControl } from 'react-native';
import { FeatureNotInstalled } from '@molecules/FeatureNotInstalled/FeatureNotInstalled';
import { ListEmptyComponent } from '@molecules/ListEmptyComponent/ListEmptyComponent';
import { UserScriptCard } from '@molecules/UserScriptCard/UserScriptCard';
import { useServer } from '../../contexts/Server.context';
import * as S from './UserScripts.styled';

/**
* Lists all your userscripts
*/
export function UserScriptsScreen(): JSX.Element {
const { userScripts, isReloading, reloadProperty } = useServer();

if (!userScripts.installed) {
return (
<S.Container>
<FeatureNotInstalled
featureName={'User Scripts'}
installationDescription={'Install it via Community Applications'}
/>
</S.Container>
);
}

return (
<S.Container>
<FlatList
refreshing={isReloading}
onRefresh={() => reloadProperty('userscripts:all')}
refreshControl={<RefreshControl refreshing={isReloading} onRefresh={() => reloadProperty('userscripts:all')} />}
data={userScripts.scripts}
renderItem={(item) => <UserScriptCard script={item} />}
ListEmptyComponent={<ListEmptyComponent />}
/>
</S.Container>
);
}
Loading