Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7618bc4e1f | ||
|
|
7937a16a9d | ||
|
|
f3de28642f | ||
|
|
664374e9cc | ||
|
|
d32c384232 | ||
|
|
81149369df | ||
|
|
5b453c829e | ||
|
|
efd564d6db | ||
|
|
35df8c6d26 | ||
|
|
a822e44b16 | ||
|
|
4a0a717d99 | ||
|
|
b95453b614 | ||
|
|
c587bd4bf1 | ||
|
|
770b19243d | ||
|
|
3cbc7683e8 | ||
|
|
7040760a84 | ||
|
|
ff2fd2febd | ||
|
|
84b7d4bbdc | ||
|
|
98e4da5a3b | ||
|
|
3ce9c98e03 | ||
|
|
91f636ca97 | ||
|
|
e61e986028 | ||
|
|
85a863e1eb | ||
|
|
fce9b297df | ||
|
|
e3af7629aa | ||
|
|
5dee33284d | ||
|
|
cc3e1ce848 | ||
|
|
74e735608f | ||
|
|
f2f2a3df39 | ||
|
|
bb61a19c16 | ||
|
|
2c225c308d | ||
|
|
153693b3e8 | ||
|
|
a1094be40b | ||
|
|
bcb9669e44 | ||
|
|
07c088507d | ||
|
|
d5377423b1 | ||
|
|
e38c4f6be0 | ||
|
|
8469d1c477 | ||
|
|
99a9aef4a3 | ||
|
|
8f3ba2a709 | ||
|
|
4c042ccb05 | ||
|
|
8ae8cb7d5a | ||
|
|
0b34abc7d5 | ||
|
|
07869ae3ed | ||
|
|
91a6b6972a | ||
|
|
9a6607f736 | ||
|
|
36e308d11d | ||
|
|
9597a8bb93 | ||
|
|
fac7dd1fae | ||
|
|
d7a052c1b1 | ||
|
|
bdb9711c19 | ||
|
|
1f6b2756c4 | ||
|
|
3db65dbb1f | ||
|
|
0c7606793a | ||
|
|
5d01fb353b | ||
|
|
49241f5614 | ||
|
|
86590e7279 | ||
|
|
c914b54a43 |
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
README.md
|
||||||
|
.git
|
||||||
52
.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
52
.github/ISSUE_TEMPLATE/bug.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
name: 🐛 Bug Report
|
||||||
|
description: Report something that's broken, or not working like intented!
|
||||||
|
title: '[🐛 Bug] <title>'
|
||||||
|
labels: ['🐛 Bug']
|
||||||
|
assignees:
|
||||||
|
- ajnart
|
||||||
|
body:
|
||||||
|
- type: dropdown
|
||||||
|
id: environment
|
||||||
|
attributes:
|
||||||
|
label: Environment
|
||||||
|
description: How have you deployed Homarr?
|
||||||
|
options:
|
||||||
|
- Docker
|
||||||
|
- NodeJS
|
||||||
|
- Cloud Service (Static)
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: version
|
||||||
|
attributes:
|
||||||
|
label: Version
|
||||||
|
description: What version of Homarr are you running?
|
||||||
|
placeholder: 0.1.0
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
id: repro
|
||||||
|
attributes:
|
||||||
|
label: Describe the problem
|
||||||
|
description: Please describe the problem exactly, how to reproduce it, actual results, and expected results.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Additional info
|
||||||
|
description: Logs? Screenshots? More info?
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: checkboxes
|
||||||
|
id: idiot-check
|
||||||
|
attributes:
|
||||||
|
label: Please tick the boxes
|
||||||
|
description: Before submitting, please ensure that
|
||||||
|
options:
|
||||||
|
- label: You've read the [docs](https://github.com/ajnart/homarr#readme)
|
||||||
|
required: true
|
||||||
|
- label: You've checked for [duplicate issues](https://github.com/ajnart/homarr/issues)
|
||||||
|
required: true
|
||||||
|
- label: You've tried to debug yourself
|
||||||
|
required: true
|
||||||
25
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
25
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
name: ✨ Feature Request
|
||||||
|
description: Request a feature to help improve Homarr!
|
||||||
|
title: '[✨ Feature] <title>'
|
||||||
|
labels: ['✨ Feature']
|
||||||
|
assignees:
|
||||||
|
- ajnart
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: feature
|
||||||
|
attributes:
|
||||||
|
label: Describe the feature you would like to see
|
||||||
|
placeholder: An outline of the feature you would like to see implemented, include as much detail as possible!
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: priority
|
||||||
|
attributes:
|
||||||
|
label: Priority
|
||||||
|
description: How urgent is the development of this feature?
|
||||||
|
options:
|
||||||
|
- Low (Nice-to-have)
|
||||||
|
- Medium (Would be very useful)
|
||||||
|
- High (App breaking feature)
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
69
.github/workflows/docker.yml
vendored
69
.github/workflows/docker.yml
vendored
@@ -7,7 +7,7 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE_NAME: mhp
|
IMAGE_NAME: homarr
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Push image to GitHub Packages.
|
# Push image to GitHub Packages.
|
||||||
@@ -15,14 +15,44 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-node@v3
|
- name: Setup
|
||||||
- uses: actions/checkout@v3
|
uses: actions/setup-node@v3
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||||
|
- name: Yarn cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: ${{ runner.os }}-yarn-
|
||||||
|
- name: Nextjs cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
|
||||||
|
path: |
|
||||||
|
~/.npm
|
||||||
|
${{ github.workspace }}/.next/cache
|
||||||
|
# Generate a new cache whenever packages or source files change.
|
||||||
|
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
|
||||||
|
# If source files changed but packages didn't, rebuild from a prior cache.
|
||||||
|
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
|
||||||
- run: yarn install --frozen-lockfile
|
- run: yarn install --frozen-lockfile
|
||||||
- run: yarn export
|
- run: yarn build
|
||||||
- uses: actions/cache@v2
|
- name: Cache build output
|
||||||
|
uses: actions/cache@v2
|
||||||
id: restore-build
|
id: restore-build
|
||||||
with:
|
with:
|
||||||
path: ./out/
|
path: |
|
||||||
|
./next.config.js
|
||||||
|
./pages/
|
||||||
|
./public/
|
||||||
|
./.next/static/
|
||||||
|
./.next/standalone/
|
||||||
|
./packages.jsan
|
||||||
key: ${{ github.sha }}
|
key: ${{ github.sha }}
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
@@ -37,35 +67,28 @@ jobs:
|
|||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
id: restore-build
|
id: restore-build
|
||||||
with:
|
with:
|
||||||
path: ./out/
|
path: |
|
||||||
|
./next.config.js
|
||||||
|
./pages/
|
||||||
|
./public/
|
||||||
|
./.next/static/
|
||||||
|
./.next/standalone/
|
||||||
|
./packages.jsan
|
||||||
key: ${{ github.sha }}
|
key: ${{ github.sha }}
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
# list of Docker images to use as base name for tags
|
# list of Docker images to use as base name for tags
|
||||||
images: |
|
images: ghcr.io/${{ github.repository }}
|
||||||
ajnart/mhp
|
|
||||||
ghcr.io/ajnart/mhp
|
|
||||||
# generate Docker tags based on the following events/attributes
|
# generate Docker tags based on the following events/attributes
|
||||||
tags: |
|
tags: |
|
||||||
type=schedule
|
type=raw,value=latest
|
||||||
type=ref,event=branch
|
type=pep440,pattern={{version}}
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=sha
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
- name: Login to DockerHub
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
- name: Login to GHCR
|
- name: Login to GHCR
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
|
|||||||
9
.prettierrc
Normal file
9
.prettierrc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 100,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"parser": "typescript",
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"useTabs": false,
|
||||||
|
"endOfLine": "lf"
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
module.exports = require('eslint-config-mantine/.prettierrc.js');
|
|
||||||
22
Dockerfile
22
Dockerfile
@@ -1,2 +1,20 @@
|
|||||||
FROM nginx:1.21.6
|
FROM node:16-alpine
|
||||||
COPY ./out /usr/share/nginx/html
|
WORKDIR /app
|
||||||
|
ENV NODE_ENV production
|
||||||
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
|
COPY /next.config.js ./
|
||||||
|
COPY /public ./public
|
||||||
|
COPY /package.json ./package.json
|
||||||
|
|
||||||
|
# Automatically leverage output traces to reduce image size
|
||||||
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||||
|
COPY --chown=nextjs:nodejs /.next/standalone ./
|
||||||
|
COPY --chown=nextjs:nodejs /.next/static ./.next/static
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
EXPOSE 7575
|
||||||
|
ENV PORT 7575
|
||||||
|
VOLUME /app/data/configs
|
||||||
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
111
README.md
111
README.md
@@ -1,33 +1,86 @@
|
|||||||
# MyHomePage, a home page for your home server
|
<p align = "center">
|
||||||
### Do not hesitate to star ⭐ this repo if you like the project ! 
|
<h3 align = "center"> Homarr <h3>
|
||||||
### Join the discord ! : https://discord.gg/C2WTXkzkwK
|
|
||||||
## What is MyHomePage ?
|
|
||||||
|
|
||||||
HomePage is a web page for your home server, it provides a user friendly interface to access docker containers or other services.
|
<p align = "center">
|
||||||
|
A homepage for <i>your</i> server.
|
||||||
|
<br/>
|
||||||
|
<a href = "https://github.com/ajnart/homarr/deployments/activity_log?environment=Production" > <strong> Demo ↗️ </strong> </a> • <a href = "#install" > <strong> Install ➡️ </strong> </a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<a href = "https://discord.gg/aCsmEV5RgA" > <img src="https://discordapp.com/api/guilds/972958686051962910/widget.png?style=shield" > </a>
|
||||||
|
</p>
|
||||||
|
</p>
|
||||||
|
|
||||||
## Install
|
# 📃 Table of Contents
|
||||||
### Docker installation
|
- [📃 Table of Contents](#-table-of-contents)
|
||||||
Required : Docker
|
- [🚀 Getting Started](#-getting-started)
|
||||||
#### Standard docker install
|
- [ℹ️ About](#ℹ️-about)
|
||||||
To install the MyHomePage docker image simply execute ``docker pull ghcr.io/ajnart/mhp``
|
- [⚡ Installation](#-installation)
|
||||||
To run the docker file ``docker run --name my-home-page -p 7575:80 -d ghcr.io/ajnart/mhp``
|
- [Deploying from Docker Image 🐳](#deploying-from-docker-image-)
|
||||||
|
- [Building from Source 🛠️](#building-from-source-️)
|
||||||
|
- [💖 Contributing](#-contributing)
|
||||||
|
|
||||||
*Note: Currently the port used is 80 (Nginx default port) It will change to be 7575 by default*
|
<!-- Getting Started -->
|
||||||
#### Docker compose
|
# 🚀 Getting Started
|
||||||
Here's a docker compose example on how to integrate MHP into your container stack
|
|
||||||
```docker
|
## ℹ️ About
|
||||||
services:
|
|
||||||
mhp:
|
Homarr is a simple and lightweight homepage for your server, that helps you easily access all of your services in one place.
|
||||||
image: ghcr.io/ajnart/mhp
|
|
||||||
ports:
|
**[⤴️ Back to Top](#-table-of-contents)**
|
||||||
- '7575:80'
|
|
||||||
restart: always
|
## ⚡ Installation
|
||||||
|
|
||||||
|
### Deploying from Docker Image 🐳
|
||||||
|
> Supported architectures: x86-64, ARM, ARM64
|
||||||
|
|
||||||
|
_Requirements_:
|
||||||
|
- [Docker](https://docs.docker.com/get-docker/)
|
||||||
|
|
||||||
|
**Standard Docker Install**
|
||||||
|
```sh
|
||||||
|
docker run --name homarr -p 7575:7575 -d ghcr.io/ajnart/homarr
|
||||||
```
|
```
|
||||||
### Local installation
|
|
||||||
Required: Node (LTS)
|
**Docker Compose**
|
||||||
#### Install using node
|
```yml
|
||||||
To install MyHomePage locally:
|
---
|
||||||
- Clone the source code or download it.
|
version: '3'
|
||||||
- Execute ``npm install`` or ``yarn install`` *(prefered)* to install the dependencies
|
#--------------------------------------------------------------------------------------------#
|
||||||
- Execute ``yarn export`` to build the source code into the final HTML pages in the ``./out`` folder
|
# Homarr - A homepage for your server. #
|
||||||
- Run a web server to serve the content of the ``./out`` folder. Example: ``python -m http.server 7575 --directory out``
|
#--------------------------------------------------------------------------------------------#
|
||||||
|
services:
|
||||||
|
homarr:
|
||||||
|
container_name: homarr
|
||||||
|
image: ghcr.io/ajnart/homarr
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- '7575:7575'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Building from Source 🛠️
|
||||||
|
|
||||||
|
_Requirements_:
|
||||||
|
- [Git](https://git-scm.com/downloads)
|
||||||
|
- [NodeJS](https://nodejs.org/en/) _(Latest or LTS)_
|
||||||
|
- [Yarn](https://yarnpkg.com/)
|
||||||
|
- Some web server
|
||||||
|
|
||||||
|
**Installing**
|
||||||
|
|
||||||
|
- Clone the GitHub repo: `git clone https://github.com/ajnart/homarr.git` & `cd homarr`
|
||||||
|
- Install all dependencies: `yarn install`
|
||||||
|
- Build the source: `yarn export`
|
||||||
|
- Start a web server (Any web server will work):
|
||||||
|
- _Examples:_
|
||||||
|
- NodeJS serve: `npm i -g serve` or `yarn global add serve` & `serve ./out`
|
||||||
|
- python http.server: `python -m http.server 7474 --directory out`
|
||||||
|
|
||||||
|
**[⤴️ Back to Top](#-table-of-contents)**
|
||||||
|
|
||||||
|
# 💖 Contributing
|
||||||
|
You can contribute by [Starting a discussion](https://github.com/ajnart/homarr/discussions), [Submitting Bugs](https://github.com/ajnart/homarr/issues/new), [Requesting Features](https://github.com/ajnart/homarr/issues/new), or [Making a pull request](https://github.com/ajnart/homarr/compare)!
|
||||||
|
|
||||||
|
All contributions are highly appreciated.
|
||||||
|
|
||||||
|
**[⤴️ Back to Top](#-table-of-contents)**
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
useMantineTheme,
|
|
||||||
Modal,
|
Modal,
|
||||||
Center,
|
Center,
|
||||||
Group,
|
Group,
|
||||||
@@ -21,9 +20,7 @@ import { ServiceTypeList } from '../../tools/types';
|
|||||||
import { AppShelfItemWrapper } from './AppShelfItemWrapper';
|
import { AppShelfItemWrapper } from './AppShelfItemWrapper';
|
||||||
|
|
||||||
export default function AddItemShelfItem(props: any) {
|
export default function AddItemShelfItem(props: any) {
|
||||||
const { addService } = useConfig();
|
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
const theme = useMantineTheme();
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal
|
<Modal
|
||||||
@@ -73,17 +70,17 @@ export default function AddItemShelfItem(props: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function MatchIcon(name: string, form: any) {
|
function MatchIcon(name: string, form: any) {
|
||||||
// TODO: In order to avoid all the requests, we could fetch
|
fetch(
|
||||||
// https://data.jsdelivr.com/v1/package/gh/IceWhaleTech/AppIcon@main
|
`https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name
|
||||||
// and then iterate over the files -> files -> name and then remove the extension (.png)
|
.replace(/\s+/g, '-')
|
||||||
// Compare it to the input and then fetch the icon
|
.toLowerCase()}.png`
|
||||||
fetch(`https://cdn.jsdelivr.net/gh/IceWhaleTech/AppIcon@main/all/${name.toLowerCase()}.png`)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
form.setFieldValue('icon', res.url);
|
form.setFieldValue('icon', res.url);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch(() => {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,7 +89,7 @@ function MatchIcon(name: string, form: any) {
|
|||||||
|
|
||||||
export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) {
|
export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) {
|
||||||
const { setOpened } = props;
|
const { setOpened } = props;
|
||||||
const { addService, config, setConfig } = useConfig();
|
const { config, setConfig } = useConfig();
|
||||||
const [isLoading, setLoading] = useState(false);
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
@@ -104,7 +101,7 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
apiKey: props.apiKey ?? (undefined as unknown as string),
|
apiKey: props.apiKey ?? (undefined as unknown as string),
|
||||||
},
|
},
|
||||||
validate: {
|
validate: {
|
||||||
apiKey: (value: string) => null,
|
apiKey: () => null,
|
||||||
// Validate icon with a regex
|
// Validate icon with a regex
|
||||||
icon: (value: string) => {
|
icon: (value: string) => {
|
||||||
if (!value.match(/^https?:\/\/.+\.(png|jpg|jpeg|gif)$/)) {
|
if (!value.match(/^https?:\/\/.+\.(png|jpg|jpeg|gif)$/)) {
|
||||||
@@ -143,7 +140,10 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addService(form.values);
|
setConfig({
|
||||||
|
...config,
|
||||||
|
services: [...config.services, form.values],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
setOpened(false);
|
setOpened(false);
|
||||||
form.reset();
|
form.reset();
|
||||||
|
|||||||
@@ -1,35 +1,18 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import {
|
import { Text, AspectRatio, SimpleGrid, Card, Image, Group, Space } from '@mantine/core';
|
||||||
Text,
|
|
||||||
AspectRatio,
|
|
||||||
SimpleGrid,
|
|
||||||
Card,
|
|
||||||
useMantineTheme,
|
|
||||||
Image,
|
|
||||||
Group,
|
|
||||||
Space,
|
|
||||||
} from '@mantine/core';
|
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { serviceItem } from '../../tools/types';
|
import { serviceItem } from '../../tools/types';
|
||||||
import AddItemShelfItem from './AddAppShelfItem';
|
import AddItemShelfItem from './AddAppShelfItem';
|
||||||
import { AppShelfItemWrapper } from './AppShelfItemWrapper';
|
import { AppShelfItemWrapper } from './AppShelfItemWrapper';
|
||||||
import AppShelfMenu from './AppShelfMenu';
|
import AppShelfMenu from './AppShelfMenu';
|
||||||
|
|
||||||
const AppShelf = (props: any) => {
|
const AppShelf = () => {
|
||||||
const { config, addService, removeService, setConfig } = useConfig();
|
const { config } = useConfig();
|
||||||
|
|
||||||
/* A hook that is used to load the config from local storage. */
|
|
||||||
useEffect(() => {
|
|
||||||
const localConfig = localStorage.getItem('config');
|
|
||||||
if (localConfig) {
|
|
||||||
setConfig(JSON.parse(localConfig));
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SimpleGrid m="xl" cols={5} spacing="xl">
|
<SimpleGrid m="xl" cols={5} spacing="xl">
|
||||||
{config.services.map((service, i) => (
|
{config.services.map((service) => (
|
||||||
<AppShelfItem key={service.name} service={service} />
|
<AppShelfItem key={service.name} service={service} />
|
||||||
))}
|
))}
|
||||||
<AddItemShelfItem />
|
<AddItemShelfItem />
|
||||||
@@ -39,16 +22,14 @@ const AppShelf = (props: any) => {
|
|||||||
|
|
||||||
export function AppShelfItem(props: any) {
|
export function AppShelfItem(props: any) {
|
||||||
const { service }: { service: serviceItem } = props;
|
const { service }: { service: serviceItem } = props;
|
||||||
const theme = useMantineTheme();
|
|
||||||
const { removeService } = useConfig();
|
|
||||||
const [hovering, setHovering] = useState(false);
|
const [hovering, setHovering] = useState(false);
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
key={service.name}
|
key={service.name}
|
||||||
onHoverStart={(e) => {
|
onHoverStart={() => {
|
||||||
setHovering(true);
|
setHovering(true);
|
||||||
}}
|
}}
|
||||||
onHoverEnd={(e) => {
|
onHoverEnd={() => {
|
||||||
setHovering(false);
|
setHovering(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -79,7 +60,7 @@ export function AppShelfItem(props: any) {
|
|||||||
opacity: hovering ? 1 : 0,
|
opacity: hovering ? 1 : 0,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<AppShelfMenu service={service} removeitem={removeService} />
|
<AppShelfMenu service={service} />
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</Group>
|
</Group>
|
||||||
</Card.Section>
|
</Card.Section>
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import { Menu, Modal, Text } from '@mantine/core';
|
|||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Check, Edit, Trash } from 'tabler-icons-react';
|
import { Check, Edit, Trash } from 'tabler-icons-react';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
import { AddAppShelfItemForm } from './AddAppShelfItem';
|
import { AddAppShelfItemForm } from './AddAppShelfItem';
|
||||||
|
|
||||||
export default function AppShelfMenu(props: any) {
|
export default function AppShelfMenu(props: any) {
|
||||||
const { service, removeitem: removeItem } = props;
|
const { service } = props;
|
||||||
|
const { config, setConfig } = useConfig();
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -40,7 +42,10 @@ export default function AppShelfMenu(props: any) {
|
|||||||
<Menu.Item
|
<Menu.Item
|
||||||
color="red"
|
color="red"
|
||||||
onClick={(e: any) => {
|
onClick={(e: any) => {
|
||||||
removeItem(service.name);
|
setConfig({
|
||||||
|
...config,
|
||||||
|
services: config.services.filter((s) => s.name !== service.name),
|
||||||
|
});
|
||||||
showNotification({
|
showNotification({
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
title: (
|
title: (
|
||||||
|
|||||||
37
components/Config/ConfigChanger.tsx
Normal file
37
components/Config/ConfigChanger.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Center, Loader, Select, Tooltip } from '@mantine/core';
|
||||||
|
import { setCookies } from 'cookies-next';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useConfig } from '../../tools/state';
|
||||||
|
|
||||||
|
export default function ConfigChanger() {
|
||||||
|
const { config, loadConfig, setConfig, getConfigs } = useConfig();
|
||||||
|
const [configList, setConfigList] = useState([] as string[]);
|
||||||
|
useEffect(() => {
|
||||||
|
getConfigs().then((configs) => setConfigList(configs));
|
||||||
|
// setConfig(initialConfig);
|
||||||
|
}, [config]);
|
||||||
|
// If configlist is empty, return a loading indicator
|
||||||
|
if (configList.length === 0) {
|
||||||
|
return (
|
||||||
|
<Center>
|
||||||
|
<Tooltip label={"Loading your configs. This doesn't load in vercel."}>
|
||||||
|
<Loader />
|
||||||
|
</Tooltip>
|
||||||
|
</Center>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
defaultValue={config.name}
|
||||||
|
label="Config loader"
|
||||||
|
onChange={(e) => {
|
||||||
|
loadConfig(e ?? 'default');
|
||||||
|
setCookies('config-name', e ?? 'default', { maxAge: 60 * 60 * 24 * 30 });
|
||||||
|
}}
|
||||||
|
data={
|
||||||
|
// If config list is empty, return the current config
|
||||||
|
configList.length === 0 ? [config.name] : configList
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone';
|
|||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
|
import { setCookies } from 'cookies-next';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { Config } from '../../tools/types';
|
import { Config } from '../../tools/types';
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ export const dropzoneChildren = (status: DropzoneStatus, theme: MantineTheme) =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
export default function LoadConfigComponent(props: any) {
|
export default function LoadConfigComponent(props: any) {
|
||||||
const { saveConfig, setConfig } = useConfig();
|
const { setConfig } = useConfig();
|
||||||
const theme = useMantineTheme();
|
const theme = useMantineTheme();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const openRef = useRef<() => void>();
|
const openRef = useRef<() => void>();
|
||||||
@@ -69,15 +70,21 @@ export default function LoadConfigComponent(props: any) {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const newConfig: Config = JSON.parse(e);
|
||||||
showNotification({
|
showNotification({
|
||||||
autoClose: 5000,
|
autoClose: 5000,
|
||||||
radius: 'md',
|
radius: 'md',
|
||||||
title: <Text>Config loaded successfully</Text>,
|
title: (
|
||||||
|
<Text>
|
||||||
|
Config <b>{newConfig.name}</b> loaded successfully
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
color: 'green',
|
color: 'green',
|
||||||
icon: <Check />,
|
icon: <Check />,
|
||||||
message: undefined,
|
message: undefined,
|
||||||
});
|
});
|
||||||
setConfig(JSON.parse(e));
|
setCookies('config-name', newConfig.name, { maxAge: 60 * 60 * 24 * 30 });
|
||||||
|
setConfig(newConfig);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
accept={['application/json']}
|
accept={['application/json']}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export default function SaveConfigComponent(props: any) {
|
|||||||
const { config } = useConfig();
|
const { config } = useConfig();
|
||||||
function onClick(e: any) {
|
function onClick(e: any) {
|
||||||
if (config) {
|
if (config) {
|
||||||
fileDownload(JSON.stringify(config, null, '\t'), 'config.json');
|
fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|||||||
16
components/Config/SelectConfig.tsx
Normal file
16
components/Config/SelectConfig.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { Select } from '@mantine/core';
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
export default function SelectConfig(props: any) {
|
||||||
|
const [value, setValue] = useState<string | null>('');
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
|
data={[
|
||||||
|
{ value: 'default', label: 'Default' },
|
||||||
|
{ value: 'yourmom', label: 'Your mom' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -48,7 +48,7 @@ export default function SearchBar(props: any) {
|
|||||||
if (isYoutube) {
|
if (isYoutube) {
|
||||||
window.open(`https://www.youtube.com/results?search_query=${querry.substring(3)}`);
|
window.open(`https://www.youtube.com/results?search_query=${querry.substring(3)}`);
|
||||||
} else if (isTorrent) {
|
} else if (isTorrent) {
|
||||||
window.open(`https://thepiratebay.org/search.php?q=${querry.substring(3)}`);
|
window.open(`https://bitsearch.to/search?q=${querry.substring(3)}`);
|
||||||
} else {
|
} else {
|
||||||
window.open(`${querryUrl}${values.querry}`);
|
window.open(`${querryUrl}${values.querry}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,23 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
SegmentedControl,
|
SegmentedControl,
|
||||||
|
Indicator,
|
||||||
|
Alert,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { useColorScheme } from '@mantine/hooks';
|
import { useColorScheme } from '@mantine/hooks';
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Settings as SettingsIcon } from 'tabler-icons-react';
|
import { AlertCircle, Settings as SettingsIcon } from 'tabler-icons-react';
|
||||||
|
import { CURRENT_VERSION, REPO_URL } from '../../data/constants';
|
||||||
import { useConfig } from '../../tools/state';
|
import { useConfig } from '../../tools/state';
|
||||||
import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch';
|
import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch';
|
||||||
|
import ConfigChanger from '../Config/ConfigChanger';
|
||||||
import SaveConfigComponent from '../Config/SaveConfig';
|
import SaveConfigComponent from '../Config/SaveConfig';
|
||||||
import ModuleEnabler from './ModuleEnabler';
|
import ModuleEnabler from './ModuleEnabler';
|
||||||
|
|
||||||
function SettingsMenu(props: any) {
|
function SettingsMenu(props: any) {
|
||||||
const { config, setConfig } = useConfig();
|
const { config, setConfig } = useConfig();
|
||||||
const colorScheme = useColorScheme();
|
const colorScheme = useColorScheme();
|
||||||
|
const { current, latest } = props;
|
||||||
const matches = [
|
const matches = [
|
||||||
{ label: 'Google', value: 'https://google.com/search?q=' },
|
{ label: 'Google', value: 'https://google.com/search?q=' },
|
||||||
{ label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' },
|
{ label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' },
|
||||||
@@ -26,12 +31,20 @@ function SettingsMenu(props: any) {
|
|||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<Group direction="column" grow>
|
<Group direction="column" grow>
|
||||||
|
<Alert
|
||||||
|
icon={<AlertCircle size={16} />}
|
||||||
|
title="Update available"
|
||||||
|
radius="lg"
|
||||||
|
hidden={current === latest}
|
||||||
|
>
|
||||||
|
Version {latest} is available. Current : {current}
|
||||||
|
</Alert>
|
||||||
<Group>
|
<Group>
|
||||||
<SegmentedControl
|
<SegmentedControl
|
||||||
title="Search engine"
|
title="Search engine"
|
||||||
defaultValue={
|
value={
|
||||||
// Match config.settings.searchUrl with a key in the matches array
|
// Match config.settings.searchUrl with a key in the matches array
|
||||||
matches.find((match) => match.value === config.settings.searchUrl)?.value || 'Google'
|
matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Google'
|
||||||
}
|
}
|
||||||
onChange={
|
onChange={
|
||||||
// Set config.settings.searchUrl to the value of the selected item
|
// Set config.settings.searchUrl to the value of the selected item
|
||||||
@@ -66,6 +79,7 @@ function SettingsMenu(props: any) {
|
|||||||
</Group>
|
</Group>
|
||||||
<ModuleEnabler />
|
<ModuleEnabler />
|
||||||
<ColorSchemeSwitch />
|
<ColorSchemeSwitch />
|
||||||
|
<ConfigChanger />
|
||||||
<SaveConfigComponent />
|
<SaveConfigComponent />
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
@@ -82,7 +96,20 @@ function SettingsMenu(props: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function SettingsMenuButton(props: any) {
|
export function SettingsMenuButton(props: any) {
|
||||||
|
const [update, setUpdate] = useState(false);
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
|
const [latestVersion, setLatestVersion] = useState(CURRENT_VERSION);
|
||||||
|
useEffect(() => {
|
||||||
|
// Fetch Data here when component first mounted
|
||||||
|
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => {
|
||||||
|
res.json().then((data) => {
|
||||||
|
setLatestVersion(data.tag_name);
|
||||||
|
if (data.tag_name !== CURRENT_VERSION) {
|
||||||
|
setUpdate(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal
|
<Modal
|
||||||
@@ -91,7 +118,7 @@ export function SettingsMenuButton(props: any) {
|
|||||||
opened={props.opened || opened}
|
opened={props.opened || opened}
|
||||||
onClose={() => setOpened(false)}
|
onClose={() => setOpened(false)}
|
||||||
>
|
>
|
||||||
<SettingsMenu />
|
<SettingsMenu current={CURRENT_VERSION} latest={latestVersion} />
|
||||||
</Modal>
|
</Modal>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
variant="default"
|
variant="default"
|
||||||
@@ -102,7 +129,14 @@ export function SettingsMenuButton(props: any) {
|
|||||||
onClick={() => setOpened(true)}
|
onClick={() => setOpened(true)}
|
||||||
>
|
>
|
||||||
<Tooltip label="Settings">
|
<Tooltip label="Settings">
|
||||||
<SettingsIcon />
|
<Indicator
|
||||||
|
size={12}
|
||||||
|
disabled={CURRENT_VERSION === latestVersion}
|
||||||
|
offset={-3}
|
||||||
|
position="top-end"
|
||||||
|
>
|
||||||
|
<SettingsIcon />
|
||||||
|
</Indicator>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export function Footer({ links }: FooterCenteredProps) {
|
|||||||
>
|
>
|
||||||
<Group className={classes.links}>{items}</Group>
|
<Group className={classes.links}>{items}</Group>
|
||||||
<Group spacing="xs" position="right" noWrap>
|
<Group spacing="xs" position="right" noWrap>
|
||||||
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/myhomepage" size="lg">
|
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/homarr" size="lg">
|
||||||
<BrandGithub size={18} />
|
<BrandGithub size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export function Logo({ style }: any) {
|
|||||||
variant="gradient"
|
variant="gradient"
|
||||||
gradient={{ from: 'red', to: 'orange', deg: 145 }}
|
gradient={{ from: 'red', to: 'orange', deg: 145 }}
|
||||||
>
|
>
|
||||||
MyHomePage
|
Homarr
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ function DayComponent(props: any) {
|
|||||||
{sonarrFiltered.length > 0 && <Indicator size={7} offset={8} color="blue" children={null} />}
|
{sonarrFiltered.length > 0 && <Indicator size={7} offset={8} color="blue" children={null} />}
|
||||||
<Popover
|
<Popover
|
||||||
position="left"
|
position="left"
|
||||||
|
radius="lg"
|
||||||
|
shadow="xl"
|
||||||
|
transition="pop"
|
||||||
width={700}
|
width={700}
|
||||||
onClose={() => setOpened(false)}
|
onClose={() => setOpened(false)}
|
||||||
opened={opened}
|
opened={opened}
|
||||||
|
|||||||
@@ -15,7 +15,14 @@ function MediaDisplay(props: { media: IMedia }) {
|
|||||||
const { media }: { media: IMedia } = props;
|
const { media }: { media: IMedia } = props;
|
||||||
return (
|
return (
|
||||||
<Group noWrap align="self-start" mr={15}>
|
<Group noWrap align="self-start" mr={15}>
|
||||||
<Image fit="cover" src={media.poster} alt={media.title} width={300} height={400} />
|
<Image
|
||||||
|
radius="md"
|
||||||
|
fit="cover"
|
||||||
|
src={media.poster}
|
||||||
|
alt={media.title}
|
||||||
|
width={300}
|
||||||
|
height={400}
|
||||||
|
/>
|
||||||
<Stack
|
<Stack
|
||||||
justify="space-between"
|
justify="space-between"
|
||||||
sx={(theme) => ({
|
sx={(theme) => ({
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export default function ModuleWrapper(props: any) {
|
|||||||
shadow="sm"
|
shadow="sm"
|
||||||
style={{
|
style={{
|
||||||
// Make background color of the card depend on the theme
|
// Make background color of the card depend on the theme
|
||||||
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white',
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : 'white',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<module.component />
|
<module.component />
|
||||||
|
|||||||
12
data/configs/config.json
Normal file
12
data/configs/config.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "config",
|
||||||
|
"services": [],
|
||||||
|
"settings": {
|
||||||
|
"searchBar": true,
|
||||||
|
"searchUrl": "https://duckduckgo.com/?q=",
|
||||||
|
"enabledModules": [
|
||||||
|
"Date",
|
||||||
|
"Calendar"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
16
data/configs/config_new.json
Normal file
16
data/configs/config_new.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "config_new",
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "example",
|
||||||
|
"icon": "https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif",
|
||||||
|
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"searchBar": true,
|
||||||
|
"searchUrl": "https://google.com/search?q=",
|
||||||
|
"enabledModules": []
|
||||||
|
}
|
||||||
|
}
|
||||||
16
data/configs/default.json
Normal file
16
data/configs/default.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "example",
|
||||||
|
"icon": "https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif",
|
||||||
|
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"searchBar": true,
|
||||||
|
"searchUrl": "https://bing.com/search?q=",
|
||||||
|
"enabledModules": []
|
||||||
|
}
|
||||||
|
}
|
||||||
2
data/constants.ts
Normal file
2
data/constants.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const REPO_URL = 'ajnart/homarr';
|
||||||
|
export const CURRENT_VERSION = 'v0.2.0';
|
||||||
@@ -7,4 +7,7 @@ module.exports = withBundleAnalyzer({
|
|||||||
eslint: {
|
eslint: {
|
||||||
ignoreDuringBuilds: true,
|
ignoreDuringBuilds: true,
|
||||||
},
|
},
|
||||||
|
experimental: {
|
||||||
|
outputStandalone: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
19
package.json
19
package.json
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "homarr",
|
"name": "homarr",
|
||||||
"version": "0.1.3",
|
"version": "0.1.6",
|
||||||
"private": "false",
|
"private": "false",
|
||||||
"description": "Customizable browser's home page to interact with your homeserver's Docker containers (i.e. Sonarr/Radarr)",
|
"description": "Homarr - A homepage for your server.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/ajnart/myhomepage"
|
"url": "https://github.com/ajnart/homarr"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"analyze": "ANALYZE=true next build",
|
"analyze": "ANALYZE=true next build",
|
||||||
"start": "next start",
|
"start": "next start --port 7575",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"export": "next build && next export",
|
"export": "next build && next export",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
"@mantine/rte": "^4.2.4",
|
"@mantine/rte": "^4.2.4",
|
||||||
"@mantine/spotlight": "^4.2.4",
|
"@mantine/spotlight": "^4.2.4",
|
||||||
"@modulz/radix-icons": "^4.0.0",
|
"@modulz/radix-icons": "^4.0.0",
|
||||||
|
"axios": "^0.27.2",
|
||||||
"cookies-next": "^2.0.4",
|
"cookies-next": "^2.0.4",
|
||||||
"dayjs": "^1.11.2",
|
"dayjs": "^1.11.2",
|
||||||
"framer-motion": "^6.3.1",
|
"framer-motion": "^6.3.1",
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) {
|
|||||||
const toggleColorScheme = (value?: ColorScheme) => {
|
const toggleColorScheme = (value?: ColorScheme) => {
|
||||||
const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark');
|
const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark');
|
||||||
setColorScheme(nextColorScheme);
|
setColorScheme(nextColorScheme);
|
||||||
setCookies('mantine-color-scheme', nextColorScheme, { maxAge: 60 * 60 * 24 * 30 });
|
setCookies('color-scheme', nextColorScheme, { maxAge: 60 * 60 * 24 * 30 });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>MyHomePage - Your new browser homepage!</title>
|
<title>Homarr - A homepage for your server!</title>
|
||||||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
|
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
|
||||||
<link rel="shortcut icon" href="/favicon.svg" />
|
<link rel="shortcut icon" href="/favicon.svg" />
|
||||||
</Head>
|
</Head>
|
||||||
@@ -50,5 +50,5 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => ({
|
App.getInitialProps = ({ ctx }: { ctx: GetServerSidePropsContext }) => ({
|
||||||
colorScheme: getCookie('mantine-color-scheme', ctx) || 'light',
|
colorScheme: getCookie('color-scheme', ctx) || 'light',
|
||||||
});
|
});
|
||||||
|
|||||||
61
pages/api/configs/[slug].ts
Normal file
61
pages/api/configs/[slug].ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
function Put(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
// Get the slug of the request
|
||||||
|
const { slug } = req.query as { slug: string };
|
||||||
|
// Get the body of the request
|
||||||
|
const { body }: { body: string } = req;
|
||||||
|
if (!slug || !body) {
|
||||||
|
res.status(400).json({
|
||||||
|
error: 'Wrong request',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Save the body in the /data/config folder with the slug as filename
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join('data/configs', `${slug}.json`),
|
||||||
|
JSON.stringify(body, null, 2),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
return res.status(200).json({
|
||||||
|
message: 'Configuration saved with success',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
// Get the slug of the request
|
||||||
|
const { slug } = req.query as { slug: string };
|
||||||
|
if (!slug) {
|
||||||
|
return res.status(400).json({
|
||||||
|
message: 'Wrong request',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Loop over all the files in the /data/configs directory
|
||||||
|
const files = fs.readdirSync('data/configs');
|
||||||
|
// Strip the .json extension from the file name
|
||||||
|
const configs = files.map((file) => file.replace('.json', ''));
|
||||||
|
// If the target is not in the list of files, return an error
|
||||||
|
if (!configs.includes(slug)) {
|
||||||
|
return res.status(404).json({
|
||||||
|
message: 'Target not found',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Return the content of the file
|
||||||
|
return res.status(200).json(fs.readFileSync(path.join('data/configs', `${slug}.json`), 'utf8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
|
// Filter out if the reuqest is a Put or a GET
|
||||||
|
if (req.method === 'PUT') {
|
||||||
|
return Put(req, res);
|
||||||
|
}
|
||||||
|
if (req.method === 'GET') {
|
||||||
|
return Get(req, res);
|
||||||
|
}
|
||||||
|
return res.status(405).json({
|
||||||
|
statusCode: 405,
|
||||||
|
message: 'Method not allowed',
|
||||||
|
});
|
||||||
|
};
|
||||||
28
pages/api/configs/index.ts
Normal file
28
pages/api/configs/index.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
// Loop over all the files in the /data/configs directory
|
||||||
|
const files = fs.readdirSync('data/configs');
|
||||||
|
// Strip the .json extension from the file name
|
||||||
|
const configs = files.map((file) => file.replace('.json', ''));
|
||||||
|
|
||||||
|
return res.status(200).json(configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||||
|
// Filter out if the reuqest is a POST or a GET
|
||||||
|
if (req.method === 'POST') {
|
||||||
|
return res.status(405).json({
|
||||||
|
statusCode: 405,
|
||||||
|
message: 'Method not allowed',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (req.method === 'GET') {
|
||||||
|
return Get(req, res);
|
||||||
|
}
|
||||||
|
return res.status(405).json({
|
||||||
|
statusCode: 405,
|
||||||
|
message: 'Method not allowed',
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -1,9 +1,57 @@
|
|||||||
import { Group } from '@mantine/core';
|
import { Group } from '@mantine/core';
|
||||||
|
import { getCookie, setCookies } from 'cookies-next';
|
||||||
|
import { GetServerSidePropsContext } from 'next';
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import AppShelf from '../components/AppShelf/AppShelf';
|
import AppShelf from '../components/AppShelf/AppShelf';
|
||||||
import LoadConfigComponent from '../components/Config/LoadConfig';
|
import LoadConfigComponent from '../components/Config/LoadConfig';
|
||||||
import SearchBar from '../components/SearchBar/SearchBar';
|
import SearchBar from '../components/SearchBar/SearchBar';
|
||||||
|
import { Config } from '../tools/types';
|
||||||
|
import { useConfig } from '../tools/state';
|
||||||
|
|
||||||
export default function HomePage() {
|
export async function getServerSideProps({
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
}: GetServerSidePropsContext): Promise<{ props: { config: Config } }> {
|
||||||
|
let cookie = getCookie('config-name', { req, res });
|
||||||
|
if (!cookie) {
|
||||||
|
setCookies('config-name', 'default', { req, res, maxAge: 60 * 60 * 24 * 30 });
|
||||||
|
cookie = 'default';
|
||||||
|
}
|
||||||
|
// Check if the config file exists
|
||||||
|
const configPath = path.join(process.cwd(), 'data/configs', `${cookie}.json`);
|
||||||
|
if (!fs.existsSync(configPath)) {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
config: {
|
||||||
|
name: cookie.toString(),
|
||||||
|
services: [],
|
||||||
|
settings: {
|
||||||
|
enabledModules: [],
|
||||||
|
searchBar: true,
|
||||||
|
searchUrl: 'https://www.google.com/search?q=',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = fs.readFileSync(configPath, 'utf8');
|
||||||
|
// Print loaded config
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
config: JSON.parse(config),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function HomePage(props: any) {
|
||||||
|
const { config: initialConfig }: { config: Config } = props;
|
||||||
|
const { config, loadConfig, setConfig, getConfigs } = useConfig();
|
||||||
|
useEffect(() => {
|
||||||
|
setConfig(initialConfig);
|
||||||
|
}, [initialConfig]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SearchBar />
|
<SearchBar />
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
// src/context/state.js
|
// src/context/state.js
|
||||||
|
import { showNotification } from '@mantine/notifications';
|
||||||
|
import axios from 'axios';
|
||||||
import { createContext, ReactNode, useContext, useState } from 'react';
|
import { createContext, ReactNode, useContext, useState } from 'react';
|
||||||
import { Config, serviceItem } from './types';
|
import { Check, X } from 'tabler-icons-react';
|
||||||
|
import { Config } from './types';
|
||||||
|
|
||||||
type configContextType = {
|
type configContextType = {
|
||||||
config: Config;
|
config: Config;
|
||||||
setConfig: (newconfig: Config) => void;
|
setConfig: (newconfig: Config) => void;
|
||||||
addService: (service: serviceItem) => void;
|
loadConfig: (name: string) => void;
|
||||||
removeService: (name: string) => void;
|
getConfigs: () => Promise<string[]>;
|
||||||
saveConfig: (newconfig: Config) => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const configContext = createContext<configContextType>({
|
const configContext = createContext<configContextType>({
|
||||||
config: {
|
config: {
|
||||||
|
name: 'default',
|
||||||
services: [],
|
services: [],
|
||||||
settings: {
|
settings: {
|
||||||
searchBar: true,
|
searchBar: true,
|
||||||
@@ -20,9 +23,8 @@ const configContext = createContext<configContextType>({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setConfig: () => {},
|
setConfig: () => {},
|
||||||
addService: () => {},
|
loadConfig: async (name: string) => {},
|
||||||
removeService: () => {},
|
getConfigs: async () => [],
|
||||||
saveConfig: () => {},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export function useConfig() {
|
export function useConfig() {
|
||||||
@@ -39,14 +41,8 @@ type Props = {
|
|||||||
|
|
||||||
export function ConfigProvider({ children }: Props) {
|
export function ConfigProvider({ children }: Props) {
|
||||||
const [config, setConfigInternal] = useState<Config>({
|
const [config, setConfigInternal] = useState<Config>({
|
||||||
services: [
|
name: 'default',
|
||||||
{
|
services: [],
|
||||||
type: 'Other',
|
|
||||||
name: 'example',
|
|
||||||
icon: 'https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif',
|
|
||||||
url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
settings: {
|
settings: {
|
||||||
searchBar: true,
|
searchBar: true,
|
||||||
searchUrl: 'https://www.google.com/search?q=',
|
searchUrl: 'https://www.google.com/search?q=',
|
||||||
@@ -54,49 +50,45 @@ export function ConfigProvider({ children }: Props) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function setConfig(newConfig: Config) {
|
async function loadConfig(configName: string) {
|
||||||
setConfigInternal(newConfig);
|
try {
|
||||||
saveConfig(newConfig);
|
const response = await axios.get(`/api/configs/${configName}`);
|
||||||
|
setConfigInternal(response.data);
|
||||||
|
showNotification({
|
||||||
|
title: 'Config',
|
||||||
|
icon: <Check />,
|
||||||
|
color: 'green',
|
||||||
|
autoClose: 1500,
|
||||||
|
radius: 'md',
|
||||||
|
message: `Loaded config : ${configName}`,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
showNotification({
|
||||||
|
title: 'Config',
|
||||||
|
icon: <X />,
|
||||||
|
color: 'red',
|
||||||
|
autoClose: 1500,
|
||||||
|
radius: 'md',
|
||||||
|
message: `Error loading config : ${configName}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addService(item: serviceItem) {
|
function setConfig(newconfig: Config) {
|
||||||
setConfigInternal({
|
axios.put(`/api/configs/${newconfig.name}`, newconfig);
|
||||||
...config,
|
setConfigInternal(newconfig);
|
||||||
services: [...config.services, item],
|
|
||||||
});
|
|
||||||
saveConfig({
|
|
||||||
...config,
|
|
||||||
services: [...config.services, item],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeService(name: string) {
|
async function getConfigs(): Promise<string[]> {
|
||||||
// Remove the service with name in config item
|
const response = await axios.get('/api/configs');
|
||||||
setConfigInternal({
|
return response.data;
|
||||||
...config,
|
|
||||||
services: config.services.filter((service) => service.name !== name),
|
|
||||||
});
|
|
||||||
saveConfig({
|
|
||||||
...config,
|
|
||||||
services: config.services.filter((service) => service.name !== name),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveConfig(newconfig: Config) {
|
|
||||||
if (!newconfig) return;
|
|
||||||
localStorage.setItem('config', JSON.stringify(newconfig));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
config,
|
config,
|
||||||
setConfig,
|
setConfig,
|
||||||
addService,
|
loadConfig,
|
||||||
removeService,
|
getConfigs,
|
||||||
saveConfig,
|
|
||||||
};
|
};
|
||||||
return (
|
return <configContext.Provider value={value}>{children}</configContext.Provider>;
|
||||||
<>
|
|
||||||
<configContext.Provider value={value}>{children}</configContext.Provider>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export interface Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
|
name: string;
|
||||||
services: serviceItem[];
|
services: serviceItem[];
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
}
|
}
|
||||||
|
|||||||
22
yarn.lock
22
yarn.lock
@@ -3909,6 +3909,14 @@ axe-core@^4.3.5:
|
|||||||
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.1.tgz#7dbdc25989298f9ad006645cd396782443757413"
|
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.1.tgz#7dbdc25989298f9ad006645cd396782443757413"
|
||||||
integrity sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw==
|
integrity sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw==
|
||||||
|
|
||||||
|
axios@^0.27.2:
|
||||||
|
version "0.27.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
|
||||||
|
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
|
||||||
|
dependencies:
|
||||||
|
follow-redirects "^1.14.9"
|
||||||
|
form-data "^4.0.0"
|
||||||
|
|
||||||
axobject-query@^2.2.0:
|
axobject-query@^2.2.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
|
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
|
||||||
@@ -6485,6 +6493,11 @@ flush-write-stream@^1.0.0:
|
|||||||
inherits "^2.0.3"
|
inherits "^2.0.3"
|
||||||
readable-stream "^2.3.6"
|
readable-stream "^2.3.6"
|
||||||
|
|
||||||
|
follow-redirects@^1.14.9:
|
||||||
|
version "1.15.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4"
|
||||||
|
integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==
|
||||||
|
|
||||||
for-in@^1.0.2:
|
for-in@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
||||||
@@ -6539,6 +6552,15 @@ form-data@^3.0.0:
|
|||||||
combined-stream "^1.0.8"
|
combined-stream "^1.0.8"
|
||||||
mime-types "^2.1.12"
|
mime-types "^2.1.12"
|
||||||
|
|
||||||
|
form-data@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||||
|
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||||
|
dependencies:
|
||||||
|
asynckit "^0.4.0"
|
||||||
|
combined-stream "^1.0.8"
|
||||||
|
mime-types "^2.1.12"
|
||||||
|
|
||||||
format@^0.2.0:
|
format@^0.2.0:
|
||||||
version "0.2.2"
|
version "0.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b"
|
resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b"
|
||||||
|
|||||||
Reference in New Issue
Block a user