Compare commits
12
Commits
optimisation
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb1dc891e2 | ||
|
|
0cd0b3920c | ||
|
|
a0f7acfecf | ||
|
|
21d1c45c94 | ||
|
|
b57fc7bd80 | ||
|
|
ed3673bbbe | ||
|
|
e71cc10f91 | ||
|
|
7b98f02f0e | ||
|
|
f5cde7a24c | ||
|
|
4ceb4694cc | ||
|
|
04d6c4a0be | ||
|
|
9364444a03 |
No files matched your search
-12
@@ -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"]
|
|
||||||
@@ -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
|
## 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
|
## .env
|
||||||
|
|
||||||
@@ -15,3 +21,9 @@ REACT_APP_NAME=radio-rolnik
|
|||||||
|
|
||||||
REACT_APP_FB_REDIRECTURI=https://radio.rolniknysa.pl/api/login/token
|
REACT_APP_FB_REDIRECTURI=https://radio.rolniknysa.pl/api/login/token
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
`yarn start` for develompent server
|
||||||
|
|
||||||
|
`yarn build` for production build
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
version: '3'
|
|
||||||
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- 3000:3000
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 104 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
Generated
-16648
File diff suppressed because it is too large.
Load diff
@@ -12,6 +12,10 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.history > .history-section:first-child > span {
|
||||||
|
margin-top: unset;
|
||||||
|
}
|
||||||
|
|
||||||
.history-section > .header {
|
.history-section > .header {
|
||||||
border-bottom: 1px solid #eeec;
|
border-bottom: 1px solid #eeec;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|||||||
@@ -11,8 +11,7 @@
|
|||||||
height: var(--side);
|
height: var(--side);
|
||||||
width: var(--side);
|
width: var(--side);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin: auto;
|
margin: 1em auto;
|
||||||
margin-bottom: 1em;
|
|
||||||
box-shadow: 0px 4px 16px 0px #000000b8;
|
box-shadow: 0px 4px 16px 0px #000000b8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,10 +87,8 @@ function Info({ top }) {
|
|||||||
setModalReport(false)
|
setModalReport(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(track.stats)
|
const total = track.stats?.up + track.stats?.down,
|
||||||
|
percent = total > 0 ? (track.stats?.up / total) * 100 : 50
|
||||||
const total = track.stats.total,
|
|
||||||
percent = total > 0 ? (track.stats.up / total) * 100 : 50
|
|
||||||
|
|
||||||
document.setTitle(track.title)
|
document.setTitle(track.title)
|
||||||
|
|
||||||
@@ -212,8 +210,8 @@ function Info({ top }) {
|
|||||||
<span className="info-data">{id}</span>
|
<span className="info-data">{id}</span>
|
||||||
{modalReport && (
|
{modalReport && (
|
||||||
<Modal>
|
<Modal>
|
||||||
<div class="modal-title">Czy na pewno chcesz zgłosić utwór?</div>
|
<div className="modal-title">Czy na pewno chcesz zgłosić utwór?</div>
|
||||||
<div class="modal-body">
|
<div className="modal-body">
|
||||||
Zgłoszone utwory trafiają do sprawdzenia przez administrację. Jeżeli
|
Zgłoszone utwory trafiają do sprawdzenia przez administrację. Jeżeli
|
||||||
<b> {track.title}</b> zawiera treści nieodpowiednie lub
|
<b> {track.title}</b> zawiera treści nieodpowiednie lub
|
||||||
<i> bardzo</i> nie chciałbyś go usłyszeć na korytarzu, zalecamy
|
<i> bardzo</i> nie chciałbyś go usłyszeć na korytarzu, zalecamy
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
/* max-height: 100%; */
|
/* max-height: 100%; */
|
||||||
margin: auto;
|
margin: auto;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-bottom: 8em;
|
padding-top: 3em;
|
||||||
|
padding-bottom: 7em;
|
||||||
/* overflow-y: auto; */
|
/* overflow-y: auto; */
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,15 @@ nav {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
background-color: var(--white);
|
background-color: var(--white);
|
||||||
border-radius: 0.5em 0.5em 0 0;
|
/* border-radius: 0.5em 0.5em 0 0; */
|
||||||
padding: 0.5em;
|
padding: 0.3em 0.5em;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
top: 0;
|
||||||
|
box-shadow: 0px 4px 6px 2px #00000026;
|
||||||
|
border-bottom: 1px solid var(--main);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-button {
|
.nav-button {
|
||||||
@@ -29,12 +31,12 @@ nav {
|
|||||||
.nav-button.active {
|
.nav-button.active {
|
||||||
color: var(--main);
|
color: var(--main);
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding-top: 0;
|
/* padding-top: 0; */
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-button.active:before {
|
.nav-button.active:before {
|
||||||
content: '';
|
/* content: ''; */
|
||||||
width: 80%;
|
width: 80%;
|
||||||
left: 10%;
|
left: 10%;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
@@ -45,13 +45,15 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 1px solid var(--light);
|
|
||||||
padding: 0.4em 0.2em;
|
padding: 0.4em 0.2em;
|
||||||
margin-bottom: 0.2em;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-sub:not(:last-child) {
|
||||||
|
border-bottom: 1px solid var(--light);
|
||||||
|
}
|
||||||
|
|
||||||
.settings-sub i {
|
.settings-sub i {
|
||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 { promptLogin, credentials, clearCredentials } from '../../Auth'
|
||||||
|
|
||||||
import SettingsContext from '../../contexts/Settings'
|
import SettingsContext from '../../contexts/Settings'
|
||||||
|
|
||||||
|
import Modal from '../Modal/Modal'
|
||||||
|
|
||||||
import './Settings.css'
|
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 = {
|
const defaults = {
|
||||||
hueFromArt: true,
|
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 }) {
|
function Toggle({ value }) {
|
||||||
return (
|
return (
|
||||||
<div className="toggle">
|
<div className="toggle">
|
||||||
@@ -54,7 +97,32 @@ function SettingToggle({ children, id }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Settings() {
|
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 (
|
return (
|
||||||
<div className="wrapper settings">
|
<div className="wrapper settings">
|
||||||
@@ -82,10 +150,55 @@ function Settings() {
|
|||||||
|
|
||||||
{creds.token ? null : (
|
{creds.token ? null : (
|
||||||
<div className="settings-part body">
|
<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>
|
</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">
|
<div className="settings-part">
|
||||||
<SettingToggle id="hueFromArt">
|
<SettingToggle id="hueFromArt">
|
||||||
Ustawiaj kolorystyke strony na podstawie okładki albumu
|
Ustawiaj kolorystyke strony na podstawie okładki albumu
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
.status {
|
.status {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 3.5rem;
|
bottom: 2.5rem;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
width: 95%;
|
width: 80%;
|
||||||
background: var(--dark);
|
background: var(--dark);
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
|
|||||||
+2
-2
@@ -23,10 +23,10 @@ function open() {
|
|||||||
socket.onmessage = (e) => {
|
socket.onmessage = (e) => {
|
||||||
let data = JSON.parse(e.data)
|
let data = JSON.parse(e.data)
|
||||||
|
|
||||||
console.debug(data)
|
|
||||||
|
|
||||||
if (!Array.isArray(data)) data = [data]
|
if (!Array.isArray(data)) data = [data]
|
||||||
|
|
||||||
|
console.debug(data.map(({ cat }) => cat).join(' '), data)
|
||||||
|
|
||||||
for (let chunk of data) {
|
for (let chunk of data) {
|
||||||
let category = events[chunk.cat]
|
let category = events[chunk.cat]
|
||||||
if (category)
|
if (category)
|
||||||
|
|||||||
Reference in new issue
Block a user