12 Commits
Author SHA1 Message Date
Mateusz Pstrucha eb1dc891e2 Merge pull request #19 from Maathias/readme
Readme
2022-04-19 20:27:20 +02:00
Mateusz Pstrucha 0cd0b3920c feat: better readme 2022-04-19 20:23:46 +02:00
Mateusz Pstrucha a0f7acfecf refactor: remove docker 2022-04-19 20:23:29 +02:00
Mateusz Pstrucha 21d1c45c94 refactor: move to yarn 2022-04-19 20:23:12 +02:00
Mateusz Pstrucha b57fc7bd80 feat: claim codes 2021-11-09 07:46:17 +01:00
Mateusz Pstrucha ed3673bbbe refactor: move navbar top 2021-11-09 07:41:52 +01:00
Mateusz Pstrucha e71cc10f91 fix: wrong total 2021-11-09 07:41:30 +01:00
Mateusz Pstrucha 7b98f02f0e Merge pull request #18 from Maathias/misc
fix: logging
2021-11-03 23:49:44 +01:00
Mateusz Pstrucha f5cde7a24c fix: logging 2021-11-03 23:48:59 +01:00
Mateusz Pstrucha 4ceb4694cc Merge pull request #17 from Maathias/optimisation
refactor: move fetching to Track
2021-11-03 23:02:29 +01:00
Mateusz Pstrucha 04d6c4a0be Merge pull request #16 from Maathias/finishing
Finishing
2021-11-03 23:02:04 +01:00
Mateusz Pstrucha 9364444a03 Merge pull request #15 from Maathias/finishing
Finishing
2021-10-21 01:43:13 +02:00
16 changed files with 11734 additions and 16693 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 ## 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
-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; 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;
+1 -2
View File
@@ -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;
} }
+4 -6
View File
@@ -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
+2 -1
View File
@@ -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; */
} }
+7 -5
View File
@@ -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;
+4 -2
View File
@@ -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);
} }
+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 { 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
+2 -2
View File
@@ -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
View File
@@ -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)
+11577
View File
File diff suppressed because it is too large. Load diff