-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New components (connect plex, dark mode) + Started new Welcome screen (…
…#162) * add plex button component * wip * add dark mode to top bar * clean up loading on channels page * updated dark mode button
- Loading branch information
1 parent
193203c
commit 9819499
Showing
11 changed files
with
172 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions
7
web/src/components/channel_config/ChannelProgramConfigListItem.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { AddCircle } from '@mui/icons-material'; | ||
import { Button } from '@mui/material'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { InsertPlexServerRequest } from '@tunarr/types/api'; | ||
import { apiClient } from '../../external/api.ts'; | ||
import { checkNewPlexServers, plexLoginFlow } from '../../helpers/plexLogin.ts'; | ||
|
||
type AddPlexServer = { | ||
title?: string; | ||
}; | ||
|
||
export default function AddPlexServer(props: AddPlexServer) { | ||
const { title = 'Add', ...restProps } = props; | ||
const queryClient = useQueryClient(); | ||
|
||
const addPlexServerMutation = useMutation({ | ||
mutationFn: (newServer: InsertPlexServerRequest) => { | ||
return apiClient.createPlexServer(newServer); | ||
}, | ||
onSuccess: () => { | ||
return queryClient.invalidateQueries({ | ||
queryKey: ['settings', 'plex-servers'], | ||
}); | ||
}, | ||
}); | ||
|
||
const addPlexServer = () => { | ||
plexLoginFlow() | ||
.then(checkNewPlexServers) | ||
.then((connections) => { | ||
connections.forEach(({ server, connection }) => | ||
addPlexServerMutation.mutate({ | ||
name: server.name, | ||
uri: connection.uri, | ||
accessToken: server.accessToken, | ||
}), | ||
); | ||
}) | ||
.catch(console.error); | ||
}; | ||
|
||
return ( | ||
<Button | ||
onClick={() => addPlexServer()} | ||
variant="contained" | ||
startIcon={<AddCircle />} | ||
{...restProps} | ||
> | ||
{title} | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
Card, | ||
CardActions, | ||
CardContent, | ||
CardProps, | ||
Typography, | ||
} from '@mui/material'; | ||
import AddPlexServer from './AddPlexServer.tsx'; | ||
|
||
export default function ConnectPlex(props: CardProps) { | ||
const { | ||
sx = { | ||
p: 2, | ||
margin: '0 auto', | ||
textAlign: 'center', | ||
}, | ||
...restProps | ||
} = props; | ||
|
||
return ( | ||
<Card sx={sx} {...restProps}> | ||
<CardContent> | ||
<img src="/web/src/assets/plex.svg" width="75" /> | ||
<Typography sx={{ my: 2 }}> | ||
First things first, let's get your Plex Server connected. | ||
</Typography> | ||
<CardActions sx={{ justifyContent: 'center' }}> | ||
<AddPlexServer title="Connect Plex" /> | ||
</CardActions> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { DarkMode, LightMode } from '@mui/icons-material'; | ||
import { FormControlLabel, IconButton, Switch, Tooltip } from '@mui/material'; | ||
import useStore from '../../store/index.ts'; | ||
import { setDarkModeState } from '../../store/themeEditor/actions'; | ||
|
||
type DarkModeProps = { | ||
iconOnly?: boolean; | ||
}; | ||
|
||
export default function DarkModeButton(props: DarkModeProps) { | ||
const { iconOnly } = props; | ||
const darkMode = useStore((state) => state.theme.darkMode); | ||
|
||
return ( | ||
<> | ||
{iconOnly ? ( | ||
<Tooltip title={`Enable ${darkMode ? 'light' : 'dark'} Mode`}> | ||
<IconButton onClick={() => setDarkModeState()} sx={{ mx: 1 }}> | ||
{darkMode ? <LightMode /> : <DarkMode sx={{ color: '#fff' }} />} | ||
</IconButton> | ||
</Tooltip> | ||
) : ( | ||
<FormControlLabel | ||
control={ | ||
<Switch checked={darkMode} onClick={() => setDarkModeState()} /> | ||
} | ||
label="Dark Mode" | ||
/> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters