Merge branch 'master' into master

This commit is contained in:
Bastian Meissner 2020-05-21 09:49:50 +02:00 committed by GitHub
commit 8a39463caa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 376 additions and 447 deletions

View file

@ -2,7 +2,7 @@
![screenshot](screenshot.png 'screenshot') ![screenshot](screenshot.png 'screenshot')
Dashboard is just that - a dashboard. It's inspired by [SUI](https://github.com/jeroenpardon/sui) and has all the same features as SUI. Dashboard is just that - a dashboard. It's inspired by [SUI](https://github.com/jeroenpardon/sui) and has all the same features as SUI, such as simple customization through JSON-files and a handy search bar to search the internet more efficiently.
## Features ## Features

View file

@ -1,13 +1,13 @@
import React from 'react'; import React from "react";
import styled, { createGlobalStyle } from 'styled-components'; import styled, { createGlobalStyle } from "styled-components";
import SearchBar from './components/searchBar'; import SearchBar from "./components/searchBar";
import Greeter from './components/greeter'; import Greeter from "./components/greeter";
import AppList from './components/appList'; import AppList from "./components/appList";
import BookmarkList from './components/bookmarkList'; import BookmarkList from "./components/bookmarkList";
import SettingsModal from './components/settingsModal'; import SettingsModal from "./components/settingsModal";
import { selectedTheme } from './selectedTheme'; import selectedTheme from "./components/themeManager";
const GlobalStyle = createGlobalStyle` const GlobalStyle = createGlobalStyle`
body { body {

View file

@ -1,72 +1,48 @@
import React, { useCallback, useEffect, useState } from 'react'; import React from "react";
import MaterialIcon from 'material-icons-react'; import MaterialIcon from "material-icons-react";
import styled from 'styled-components'; import styled from "styled-components";
import { Button } from './button'; import appData from "./data/apps.json";
import { selectedTheme } from '../selectedTheme';
const AppListContainer = styled.div` import selectedTheme from "./themeManager";
padding: 2rem 0 2rem 0;
`;
const AppsContainer = styled.div` import { Headline, ListContainer, ItemList, Item } from "./elements";
display: flex;
flex-direction: row;
flex-wrap: wrap;
@media (max-width: 600px) {
flex-direction: column;
}
`;
const AppContainer = styled.div`
display: flex;
flex-direction: row;
flex: 1 0 21%;
padding: 1rem 0 1rem 0;
@media (max-width: 750px) {
flex: 1 0 42%;
}
`;
const IconContainer = styled.div` const IconContainer = styled.div`
margin-right: 5px; margin-right: 0.5vh;
`; `;
const AppDetails = styled.div` const DetailsContainer = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
`; `;
const ApplicationsText = styled.h3`
font-family: Roboto, sans-serif;
font-weight: 900;
text-transform: uppercase;
margin: 0px;
font-size: 20px;
color: ${selectedTheme.mainColor};
`;
const Link = styled.a` const Link = styled.a`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
flex: 1 0 auto;
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
font-weight: 500; font-weight: 500;
text-transform: uppercase; text-transform: uppercase;
margin: 0px; margin: 0;
text-decoration: none; text-decoration: none;
font-size: 15px; font-size: 1rem;
`; `;
const Description = styled.p` const Description = styled.p`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
text-transform: uppercase; text-transform: uppercase;
margin: 0px; margin: 0;
font-size: 10px; font-size: 0.65rem;
font-weight: 400; font-weight: 400;
color: ${selectedTheme.accentColor}; color: ${selectedTheme.accentColor};
`; `;
const App = styled.div`
display: flex;
flex-basis: 25%;
padding: 1rem;
`;
const ErrorMessage = styled.p` const ErrorMessage = styled.p`
color: red; color: red;
`; `;

View file

@ -1,19 +1,12 @@
import React from 'react'; import React from "react";
import styled from 'styled-components'; import styled from "styled-components";
import bookmarkData from './data/bookmarks.json'; import bookmarkData from "./data/bookmarks.json";
import { selectedTheme } from '../selectedTheme'; import selectedTheme from "./themeManager";
import { Headline, ListContainer, ItemList, Item } from "./elements";
const BookmarksText = styled.h3` const Group = styled.h4`
font-family: Roboto, sans-serif;
text-transform: uppercase;
margin: 0;
font-size: 20px;
color: ${selectedTheme.mainColor};
`;
const GroupText = styled.h4`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 700; font-weight: 700;
margin: 0; margin: 0;
@ -21,27 +14,11 @@ const GroupText = styled.h4`
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
`; `;
const BookmarkListContainer = styled.div` const BookmarkGroup = styled.div`
padding: 2rem 0 2rem 0;
`;
const BookmarksContainer = styled.div`
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
@media (max-width: 600px) {
flex-direction: column;
}
`;
const BookmarkGroupContainer = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1 0 21%; flex: 2 1 auto;
padding-top: 2rem; padding: 1rem 0 1rem 0;
font-size: 15px;
`; `;
const Bookmark = styled.a` const Bookmark = styled.a`
@ -53,24 +30,24 @@ const Bookmark = styled.a`
font-size: 14px; font-size: 14px;
`; `;
const BookmarkList = () => ( const bookmarkList = () => (
<BookmarkListContainer> <ListContainer>
<BookmarksText>Bookmarks</BookmarksText> <Headline>Bookmarks</Headline>
<BookmarksContainer> <ItemList>
{bookmarkData.groups.map(({ name, items }) => { {bookmarkData.groups.map(({ name, items }) => (
return ( <Item key={name}>
<BookmarkGroupContainer key={name}> <BookmarkGroup>
<GroupText>{name}</GroupText> <Group>{name}</Group>
{items.map(({ url, name: linkName }) => ( {group.items.map(({ url, name: linkName }) => (
<Bookmark key={linkName} href={url}> <Bookmark key={linkName} href={url}>
{linkName} {linkName}
</Bookmark> </Bookmark>
))} ))}
</BookmarkGroupContainer> </BookmarkGroup>
); </Item>
})} ))}
</BookmarksContainer> </ItemList>
</BookmarkListContainer> </ListContainer>
); );
export default BookmarkList; export default bookmarkList;

View file

@ -2,56 +2,56 @@
"apps": [ "apps": [
{ {
"name": "PiHole", "name": "PiHole",
"displayURL": "example.com", "displayURL": "192.168.1.253",
"URL": "https://example.com", "URL": "/admin/",
"icon": "vpn_lock" "icon": "vpn_lock"
}, },
{ {
"name": "Plex", "name": "Plex",
"displayURL": "example.com", "displayURL": "app.plex.tv",
"URL": "https://example.com", "URL": "https://app.plex.tv",
"icon": "tv" "icon": "tv"
}, },
{ {
"name": "NextCloud", "name": "NextCloud",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/cloud/",
"icon": "filter_drama" "icon": "filter_drama"
}, },
{ {
"name": "Ghost", "name": "Ghost",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/blog/",
"icon": "rss_feed" "icon": "rss_feed"
}, },
{ {
"name": "Minecraft", "name": "Minecraft",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/minecraft/index.html",
"icon": "games" "icon": "games"
}, },
{ {
"name": "pfSense", "name": "pfSense",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech:1111/",
"icon": "security" "icon": "security"
}, },
{ {
"name": "ESXi", "name": "ESXi",
"displayURL": "example.com", "displayURL": "rhsttpba1.ur.de",
"URL": "https://example.com", "URL": "https://rhsttpba1.ur.de",
"icon": "dns" "icon": "dns"
}, },
{ {
"name": "Tautulli", "name": "Tautulli",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/tautulli/",
"icon": "bar_chart" "icon": "bar_chart"
}, },
{ {
"name": "Grafana", "name": "Grafana",
"displayURL": "example.com", "displayURL": "phntxx.tech",
"URL": "https://example.com", "URL": "https://phntxx.tech/grafana/",
"icon": "show_chart" "icon": "show_chart"
} }
] ]

View file

@ -1,53 +1,15 @@
{ {
"groups": [ "groups": [
{ {
"name": "Communicate", "name": "Wikis",
"items": [ "items": [
{ {
"name": "Discord", "name": "Wikipedia",
"url": "https://example.com" "url": "https://en.wikipedia.org/"
}, },
{ {
"name": "Gmail", "name": "Arch Linux Wiki",
"url": "https://example.com" "url": "https://archlinux.org/"
},
{
"name": "Slack",
"url": "https://example.com"
}
]
},
{
"name": "Cloud",
"items": [
{
"name": "Box",
"url": "https://example.com"
},
{
"name": "Dropbox",
"url": "https://example.com"
},
{
"name": "Drive",
"url": "https://example.com"
}
]
},
{
"name": "Design",
"items": [
{
"name": "Awwwards",
"url": "https://example.com"
},
{
"name": "Dribbble",
"url": "https://example.com"
},
{
"name": "Muz.li",
"url": "https://example.com"
} }
] ]
}, },
@ -56,32 +18,15 @@
"items": [ "items": [
{ {
"name": "Codepen", "name": "Codepen",
"url": "https://example.com" "url": "https://codepen.io/"
}, },
{ {
"name": "Devdocs", "name": "JSFiddle",
"url": "https://example.com" "url": "https://jsfiddle.net/"
}, },
{ {
"name": "Devhints", "name": "Pastebin",
"url": "https://example.com" "url": "https://pastebin.com/"
}
]
},
{
"name": "Lifestyle",
"items": [
{
"name": "Design Milk",
"url": "https://example.com"
},
{
"name": "Dwell",
"url": "https://example.com"
},
{
"name": "Freshome",
"url": "https://example.com"
} }
] ]
}, },
@ -89,33 +34,46 @@
"name": "Media", "name": "Media",
"items": [ "items": [
{ {
"name": "Spotify", "name": "Soundcloud",
"url": "https://example.com" "url": "https://soundcloud.com"
},
{
"name": "Trakt",
"url": "https://example.com"
}, },
{ {
"name": "YouTube", "name": "YouTube",
"url": "https://example.com" "url": "https://youtube.com"
},
{
"name": "Twitch",
"url": "https://twitch.tv"
} }
] ]
}, },
{ {
"name": "Reading", "name": "Social Networks",
"items": [ "items": [
{ {
"name": "Instapaper", "name": "Facebook",
"url": "https://example.com" "url": "https://facebook.com"
}, },
{ {
"name": "Medium", "name": "Twitter",
"url": "https://example.com" "url": "https://twitter.com"
}, },
{
"name": "Instagram",
"url": "https://instagram.com"
}
]
},
{
"name": "Imageboards",
"items": [
{ {
"name": "Reddit", "name": "Reddit",
"url": "https://example.com" "url": "https://reddit.com"
},
{
"name": "4chan",
"url": "https://4chan.org"
} }
] ]
}, },
@ -123,16 +81,16 @@
"name": "Tech", "name": "Tech",
"items": [ "items": [
{ {
"name": "TheNextWeb", "name": "Hackernoon",
"url": "https://example.com" "url": "https://hackernoon.com"
}, },
{ {
"name": "The Verge", "name": "The Verge",
"url": "https://example.com" "url": "https://theverge.com"
}, },
{ {
"name": "MIT Technology Review", "name": "Hackernews",
"url": "https://example.com" "url": "https://news.ycombinator.com"
} }
] ]
} }

View file

@ -0,0 +1,32 @@
import styled from "styled-components";
import selectedTheme from "./themeManager";
const ListContainer = styled.div`
padding: 2rem 0 2rem 0;
`;
const Headline = styled.h3`
font-family: Roboto, sans-serif;
font-weight: 900;
text-transform: uppercase;
margin: 0px;
font-size: 1.5rem;
color: ${selectedTheme.mainColor};
`;
const ItemList = styled.ul`
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 1rem;
padding: 0;
list-style: none;
`;
const Item = styled.li`
max-height: 100px;
overflow: hidden;
position: relative;
list-style: none;
`;
export { Headline, ListContainer, ItemList, Item };

View file

@ -1,7 +1,7 @@
import React from 'react'; import React from "react";
import styled from 'styled-components'; import styled from "styled-components";
import { selectedTheme } from '../selectedTheme'; import selectedTheme from "./themeManager";
const GreeterContainer = styled.div` const GreeterContainer = styled.div`
padding: 2rem 0 2rem 0; padding: 2rem 0 2rem 0;

View file

@ -1,9 +1,9 @@
import React, { useState } from 'react'; import React, { useState } from "react";
import styled from 'styled-components'; import styled from "styled-components";
import searchData from './data/search.json'; import searchData from "./data/search.json";
import { selectedTheme } from '../selectedTheme'; import selectedTheme from "./themeManager";
const SearchInput = styled.input` const SearchInput = styled.input`
width: 100%; width: 100%;
@ -15,17 +15,17 @@ const SearchInput = styled.input`
color: ${selectedTheme.mainColor}; color: ${selectedTheme.mainColor};
`; `;
const handleQueryWithProvider = (query) => { const handleQueryWithProvider = query => {
let queryArray = query.split(' '); let queryArray = query.split(" ");
let prefix = queryArray[0]; let prefix = queryArray[0];
queryArray.shift(); queryArray.shift();
let searchQuery = queryArray.join(' '); let searchQuery = queryArray.join(" ");
var foundProvider = false; var foundProvider = false;
searchData.providers.forEach((provider) => { searchData.providers.forEach(provider => {
if (provider.prefix === prefix) { if (provider.prefix === prefix) {
foundProvider = true; foundProvider = true;
window.location = provider.url + searchQuery; window.location = provider.url + searchQuery;
@ -33,32 +33,30 @@ const handleQueryWithProvider = (query) => {
}); });
if (!foundProvider) { if (!foundProvider) {
window.location = 'https://google.com/search?q=' + query; window.location = "https://google.com/search?q=" + query;
} }
}; };
const SearchBar = () => { const SearchBar = () => {
let [input, setInput] = useState(); let [input, setInput] = useState();
const handleSearchQuery = (e) => { const handleSearchQuery = e => {
var query = input; var query = input;
console.log(query); if (query.split(" ")[0].includes("/")) {
if (query.split(' ')[0].includes('/')) {
handleQueryWithProvider(query); handleQueryWithProvider(query);
} else { } else {
window.location = 'https://google.com/search?q=' + query; window.location = "https://google.com/search?q=" + query;
} }
e.preventDefault(); e.preventDefault();
}; };
return ( return (
<form onSubmit={(e) => handleSearchQuery(e)}> <form onSubmit={e => handleSearchQuery(e)}>
<SearchInput <SearchInput
type="text" type="text"
onChange={(e) => setInput(e.target.value)} onChange={e => setInput(e.target.value)}
></SearchInput> ></SearchInput>
<button type="submit" hidden /> <button type="submit" hidden />
</form> </form>

View file

@ -1,20 +1,17 @@
import React, { useState } from 'react'; import React, { useState } from "react";
import MaterialIcon from 'material-icons-react'; import MaterialIcon from "material-icons-react";
import styled from 'styled-components'; import styled from "styled-components";
import Select from 'react-select'; import Select from "react-select";
import searchData from './data/search.json'; import searchData from './data/search.json';
import themeData from './data/themes.json'; import themeData from './data/themes.json';
import getTheme, { setTheme } from './themeManager'; import selectedTheme, { setTheme } from "./themeManager";
import { Button } from './button'; import { Button } from './button';
const selectedTheme = getTheme();
const ModalButton = styled.button` const ModalButton = styled.button`
float: right; float: right;
border: none; border: none;
background: none; background: none;
padding: 10px; padding: 10px;
@ -22,7 +19,6 @@ const ModalButton = styled.button`
const ExitButton = styled.button` const ExitButton = styled.button`
float: right; float: right;
border: none; border: none;
background: none; background: none;
`; `;
@ -48,8 +44,6 @@ const FormContainer = styled.div`
flex-wrap: nowrap; flex-wrap: nowrap;
`; `;
const ApplyButton = Button;
const Headline = styled.h3` const Headline = styled.h3`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 900; font-weight: 900;
@ -57,51 +51,6 @@ const Headline = styled.h3`
margin-top: 0; margin-top: 0;
`; `;
const SelectorStyle = {
control: (provided) => ({
...provided,
fontFamily: 'Roboto, sans-serif',
fontWeight: '500',
color: selectedTheme.mainColor,
textTransform: 'uppercase',
width: '200px',
background: 'none',
borderRadius: '0px',
border: '1px solid ' + selectedTheme.mainColor,
boxShadow: 0,
'&:hover': {
border: '1px solid ' + selectedTheme.mainColor,
},
}),
menu: (provided) => ({
...provided,
backgroundColor: selectedTheme.backgroundColor,
border: '1px solid ' + selectedTheme.mainColor,
borderRadius: '0px',
boxShadow: 0,
}),
option: (provided) => ({
...provided,
fontFamily: 'Roboto, sans-serif',
fontWeight: '500',
color: selectedTheme.mainColor,
textTransform: 'uppercase',
borderRadius: '0px',
boxShadow: 0,
backgroundColor: selectedTheme.backgroundColor,
'&:hover': {
backgroundColor: selectedTheme.mainColor,
color: selectedTheme.backgroundColor,
},
}),
singleValue: (provided) => {
return {
...provided,
color: selectedTheme.mainColor,
};
},
};
const Table = styled.table` const Table = styled.table`
font-family: Roboto, sans-serif; font-family: Roboto, sans-serif;
font-weight: 400; font-weight: 400;
@ -123,6 +72,51 @@ const HeadCell = styled.th`
background: none; background: none;
`; `;
const SelectorStyle = {
control: provided => ({
...provided,
fontFamily: "Roboto, sans-serif",
fontWeight: "500",
color: selectedTheme.mainColor,
textTransform: "uppercase",
width: "200px",
background: "none",
borderRadius: "0px",
border: "1px solid " + selectedTheme.mainColor,
boxShadow: 0,
"&:hover": {
border: "1px solid " + selectedTheme.mainColor
}
}),
menu: provided => ({
...provided,
backgroundColor: selectedTheme.backgroundColor,
border: "1px solid " + selectedTheme.mainColor,
borderRadius: "0px",
boxShadow: 0
}),
option: provided => ({
...provided,
fontFamily: "Roboto, sans-serif",
fontWeight: "500",
color: selectedTheme.mainColor,
textTransform: "uppercase",
borderRadius: "0px",
boxShadow: 0,
backgroundColor: selectedTheme.backgroundColor,
"&:hover": {
backgroundColor: selectedTheme.mainColor,
color: selectedTheme.backgroundColor
}
}),
singleValue: provided => {
return {
...provided,
color: selectedTheme.mainColor
};
}
};
const SettingsModal = () => { const SettingsModal = () => {
const [modalHidden, setModalHidden] = useState(true); const [modalHidden, setModalHidden] = useState(true);
const [newTheme, setNewTheme] = useState(); const [newTheme, setNewTheme] = useState();
@ -134,10 +128,7 @@ const SettingsModal = () => {
</ModalButton> </ModalButton>
<Modal hidden={modalHidden}> <Modal hidden={modalHidden}>
<ExitButton onClick={() => setModalHidden(!modalHidden)}> <ExitButton onClick={() => setModalHidden(!modalHidden)}>
<MaterialIcon <MaterialIcon icon="close" color={selectedTheme.mainColor} />
icon="close"
color={selectedTheme.mainColor}
/>
</ExitButton> </ExitButton>
<SelectContainer> <SelectContainer>
<Headline>Theme:</Headline> <Headline>Theme:</Headline>
@ -145,16 +136,14 @@ const SettingsModal = () => {
<Select <Select
options={themeData.themes} options={themeData.themes}
defaultValue={selectedTheme} defaultValue={selectedTheme}
onChange={(e) => { onChange={e => {
setNewTheme(e); setNewTheme(e);
}} }}
styles={SelectorStyle} styles={SelectorStyle}
/> />
<ApplyButton <Button onClick={() => setTheme(JSON.stringify(newTheme))}>
onClick={() => setTheme(JSON.stringify(newTheme))}
>
Apply Apply
</ApplyButton> </Button>
</FormContainer> </FormContainer>
</SelectContainer> </SelectContainer>
<Table> <Table>
@ -163,15 +152,12 @@ const SettingsModal = () => {
<HeadCell>Search Provider</HeadCell> <HeadCell>Search Provider</HeadCell>
<HeadCell>Prefix</HeadCell> <HeadCell>Prefix</HeadCell>
</TableRow> </TableRow>
{searchData.providers.map((provider) => { {searchData.providers.map((provider, index) => (
const { name, prefix } = provider; <TableRow key={provider.name + index}>
return ( <TableCell>{provider.name}</TableCell>
<TableRow key={name}> <TableCell>{provider.prefix}</TableCell>
<TableCell>{name}</TableCell>
<TableCell>{prefix}</TableCell>
</TableRow> </TableRow>
); ))}
})}
</tbody> </tbody>
</Table> </Table>
</Modal> </Modal>

View file

@ -1,27 +1,29 @@
import themeData from './data/themes.json'; import themeData from "./data/themes.json";
const setTheme = (theme) => { const setTheme = theme => {
localStorage.setItem('theme', theme); localStorage.setItem("theme", theme);
window.location.reload(); window.location.reload();
}; };
const resetTheme = () => { const resetTheme = () => {
localStorage.removeItem('theme'); localStorage.removeItem("theme");
}; };
const getTheme = () => { const getTheme = () => {
let selectedTheme = themeData.themes[0]; let selectedTheme = themeData.themes[0];
if ( if (
localStorage.getItem('theme') && localStorage.getItem("theme") &&
localStorage.getItem('theme') !== undefined localStorage.getItem("theme") !== undefined
) { ) {
selectedTheme = JSON.parse(localStorage.getItem('theme')); selectedTheme = JSON.parse(localStorage.getItem("theme"));
} }
return selectedTheme; return selectedTheme;
}; };
const selectedTheme = getTheme();
export { setTheme, resetTheme }; export { setTheme, resetTheme };
export default getTheme; export default selectedTheme;