Readme #19

Merged
Maathias merged 6 commits from readme into master 2022-04-19 20:27:21 +02:00
15 changed files with 11732 additions and 16689 deletions

No files matched your search

-12
View File
@@ -1,12 +0,0 @@
FROM node:14-stretch AS build
WORKDIR /build
COPY package-lock.json package.json ./
RUN npm ci
COPY . .
FROM node:14-alpine AS deploy
USER node
WORKDIR /home/node/src
COPY --from=build --chown=node:node /build .
CMD ["npm", "start"]
+15 -3
View File
@@ -1,10 +1,16 @@
# radio-rolnik Website
# radio-rolnik
<p float="left">
<img src="img/ss_history.png" width="49%" />
<img src="img/ss_track.png" width="49%" />
</p>
## Resources
API - https://github.com/Maathias/radio-rolnik-api/
API - [Maathias/radio-rolnik-api/](https://github.com/Maathias/radio-rolnik-api/)
Player - https://github.com/Maathias/radio-rolnik-player/
Player - [Maathias/radio-rolnik-player/](https://github.com/Maathias/radio-rolnik-player/)
## .env
@@ -15,3 +21,9 @@ REACT_APP_NAME=radio-rolnik
REACT_APP_FB_REDIRECTURI=https://radio.rolniknysa.pl/api/login/token
```
## Usage
`yarn start` for develompent server
`yarn build` for production build
-7
View File
@@ -1,7 +0,0 @@
version: '3'
services:
web:
build: .
ports:
- 3000:3000
Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

-16648
View File
File diff suppressed because it is too large. Load diff
+4
View File
@@ -12,6 +12,10 @@
text-align: center;
}
.history > .history-section:first-child > span {
margin-top: unset;
}
.history-section > .header {
border-bottom: 1px solid #eeec;
text-align: left;
+1 -2
View File
@@ -11,8 +11,7 @@
height: var(--side);
width: var(--side);
flex-shrink: 0;
margin: auto;
margin-bottom: 1em;
margin: 1em auto;
box-shadow: 0px 4px 16px 0px #000000b8;
}
+4 -4
View File
@@ -87,8 +87,8 @@ function Info({ top }) {
setModalReport(false)
}
const total = track.stats.total,
percent = total > 0 ? (track.stats.up / total) * 100 : 50
const total = track.stats?.up + track.stats?.down,
percent = total > 0 ? (track.stats?.up / total) * 100 : 50
document.setTitle(track.title)
@@ -210,8 +210,8 @@ function Info({ top }) {
<span className="info-data">{id}</span>
{modalReport && (
<Modal>
<div class="modal-title">Czy na pewno chcesz zgłosić utwór?</div>
<div class="modal-body">
<div className="modal-title">Czy na pewno chcesz zgłosić utwór?</div>
<div className="modal-body">
Zgłoszone utwory trafiają do sprawdzenia przez administrację. Jeżeli
<b> {track.title}</b> zawiera treści nieodpowiednie lub
<i> bardzo</i> nie chciałbyś go usłyszeć na korytarzu, zalecamy
+2 -1
View File
@@ -12,6 +12,7 @@
/* max-height: 100%; */
margin: auto;
box-sizing: border-box;
padding-bottom: 8em;
padding-top: 3em;
padding-bottom: 7em;
/* overflow-y: auto; */
}
+7 -5
View File
@@ -2,13 +2,15 @@ nav {
width: 100%;
display: flex;
background-color: var(--white);
border-radius: 0.5em 0.5em 0 0;
padding: 0.5em;
/* border-radius: 0.5em 0.5em 0 0; */
padding: 0.3em 0.5em;
box-sizing: border-box;
user-select: none;
z-index: 5;
position: fixed;
bottom: 0;
top: 0;
box-shadow: 0px 4px 6px 2px #00000026;
border-bottom: 1px solid var(--main);
}
.nav-button {
@@ -29,12 +31,12 @@ nav {
.nav-button.active {
color: var(--main);
font-weight: bold;
padding-top: 0;
/* padding-top: 0; */
position: relative;
}
.nav-button.active:before {
content: '';
/* content: ''; */
width: 80%;
left: 10%;
bottom: 0;
+4 -2
View File
@@ -45,13 +45,15 @@
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid var(--light);
padding: 0.4em 0.2em;
margin-bottom: 0.2em;
text-decoration: none;
color: inherit;
}
.settings-sub:not(:last-child) {
border-bottom: 1px solid var(--light);
}
.settings-sub i {
color: var(--dark);
}
+116 -3
View File
@@ -1,15 +1,58 @@
import { useContext, useState } from 'react'
import ky from 'ky'
import { useContext, useEffect, useState } from 'react'
import { useLocation } from 'react-router'
import { promptLogin, credentials, clearCredentials } from '../../Auth'
import SettingsContext from '../../contexts/Settings'
import Modal from '../Modal/Modal'
import './Settings.css'
function checkCode(code) {
return ky
.get(`/api/code/info/${code}`, {
headers: { authorization: credentials.token },
})
.json()
}
function claimCode(code) {
return new Promise((resolve, reject) => {
ky.post(`/api/code/claim/${code}`, {
headers: { authorization: credentials.token },
})
.json()
.then((ok) => {
resolve(ok)
})
})
}
function listCodes() {
return ky
.get(`/api/code/list`, {
headers: { authorization: credentials.token },
})
.json()
}
const defaults = {
hueFromArt: true,
}
function CodeListing({ code: { value, type, used } }) {
return (
<div className="settings-sub plain">
<span>
<b>{value}</b> - {type}
</span>
<i className={used ? 'icon-star-empty' : 'icon-star'}></i>
</div>
)
}
function Toggle({ value }) {
return (
<div className="toggle">
@@ -54,7 +97,32 @@ function SettingToggle({ children, id }) {
}
function Settings() {
const [creds, setCreds] = useState({ ...credentials })
const [creds, setCreds] = useState({ ...credentials }),
[code, setCode] = useState(null),
[modalCode, setModalCode] = useState(false),
[codes, setCodes] = useState([])
useEffect(() => {
if (credentials.token) {
listCodes().then((list) => setCodes(list))
}
}, [])
const { search } = useLocation()
useEffect(() => {
let params = new URLSearchParams(search),
c = params.get('c')
if (c) {
checkCode(c)
.then((info) => {
setCode(info)
setModalCode(true)
})
.catch((err) => console.error(err))
}
}, [search])
return (
<div className="wrapper settings">
@@ -82,10 +150,55 @@ function Settings() {
{creds.token ? null : (
<div className="settings-part body">
<b>Zaloguj się</b> aby móc głosować więcej niż na jeden utwór
<b>Zaloguj się</b> aby móc głosować na utwory
</div>
)}
{codes.length > 0 && (
<div className="settings-part body">
<span>Zebrane kody: </span>
{codes.map((code) => (
<CodeListing code={code} />
))}
</div>
)}
{modalCode && (
<Modal>
<div className="modal-title">Znalazłeś kod do aktywacji!</div>
<div className="modal-body">
<p>
Kod "{code.value}" jest
<b> {code.claimed ? 'Zajęty 😥' : 'Wolny 😁'}</b>.<br />
</p>
{!credentials.token && <p>Zaloguj się aby móc go zająć.</p>}
Kod typu
<i> {code.type}</i>: {code.desc}
</div>
<div className="modal-buttons">
<button
onClick={() => setModalCode(false)}
className="modal-button"
>
Zamknij
</button>
{!code.claimed && credentials.token && (
<button
onClick={() => {
setModalCode(false)
claimCode(code.value).then((ok) => {
listCodes().then((list) => setCodes(list))
})
}}
className="modal-button"
>
Zajmij
</button>
)}
</div>
</Modal>
)}
<div className="settings-part">
<SettingToggle id="hueFromArt">
Ustawiaj kolorystyke strony na podstawie okładki albumu
+2 -2
View File
@@ -1,9 +1,9 @@
.status {
position: fixed;
bottom: 3.5rem;
bottom: 2.5rem;
left: 0;
right: 0;
width: 95%;
width: 80%;
background: var(--dark);
color: var(--white);
padding: 0.5em;
+11577
View File
File diff suppressed because it is too large. Load diff