big update && resolve problems and bugs

front
TBS093A 2020-07-09 16:51:13 +02:00
parent b65e868b91
commit 6536fcc1bb
71 changed files with 205 additions and 145 deletions

0
README.md 100644 → 100755
View File

1
run.sh
View File

@ -1,2 +1,3 @@
sudo sysctl fs.inotify.max_user_watches=524288
gatsby clean
gatsby develop

View File

View File

0
src/components/chat/indexChat.js 100644 → 100755
View File

View File

View File

View File

View File

@ -13,16 +13,16 @@ import '../../styles/indexExchange.scss'
const IndexExchange = ({
user,
exchange, getChart, getUserTriggers, getUserNotifications, getUserTransactions }) => {
exchange, getChart, getUserTriggers, getUserNotifications, getUserTransactions }) => {
let fifteenMinuts = 1500000
useInterval( () => {
useInterval(() => {
getChart()
}, fifteenMinuts )
}, fifteenMinuts)
const [candleInfo, setCandleInfo] = useState( { Open: 0, Close: 0, Min: 0, Max: 0, Vol: 0 } )
const [mousePosition, setMousePosition] = useState( { x: 0, y: 0 } )
const [candleInfo, setCandleInfo] = useState({ Open: 0, Close: 0, Min: 0, Max: 0, Vol: 0 })
const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 })
const [triggerValue, setTriggerValue] = useState(0)
const colorGreen = {
@ -34,119 +34,129 @@ const IndexExchange = ({
}
const getCandleInformation = (candle) => {
setCandleInfo( {
Open: candle.Open,
Close: candle.Close,
Min: candle.Min,
Max: candle.Max,
Vol: candle.Volume,
Date: candle.Date
}
)
}
let pixelScale = ( exchange.candles.graphMax - exchange.candles.graphMin ) / 590
let cursorValue = exchange.candles.graphMax - ( pixelScale * ( mousePosition.y - 175 ) )
setCandleInfo({
Open: candle.Open,
Close: candle.Close,
Min: candle.Min,
Max: candle.Max,
Vol: candle.Volume,
Date: candle.Date
}
)
}
let pixelScale = (exchange.candles.graphMax - exchange.candles.graphMin) / 590
let cursorValue = exchange.candles.graphMax - (pixelScale * (mousePosition.y - 175))
const getMousePosition = (event) => {
setMousePosition( { x: event.pageX, y: event.pageY } )
}
const getMousePosition = (event) => {
setMousePosition({ x: event.pageX, y: event.pageY })
}
useEffect( () => responsiveIntrface())
const responsiveIntrface = () => {
if ( user.id != -1) {
let chartHeight = 600
let chartPaddingTop = 175
let exchangeInterfaceHeight = window.innerHeight - (chartHeight + chartPaddingTop)
document.getElementById('exchangeInterfaceTwo').style = 'height: ' + exchangeInterfaceHeight + 'px;'
}
}
return (
<div className='indexExchange'>
<div className={ user.id > -1 ? 'exchangeChartUser' : 'exchangeChartGuest' }>
<div className={user.id > -1 ? 'exchangeChartUser' : 'exchangeChartGuest'}>
<div className='chart'
onMouseOver={ event => getMousePosition(event) }
onClick={ () => setTriggerValue( parseInt(cursorValue) ) }
style={ { width: exchange.candles.candlesCount * 15 + 'px' } }>
{ user.id > -1 ? (
onMouseOver={event => getMousePosition(event)}
onClick={() => setTriggerValue(parseInt(cursorValue))}
style={{ width: exchange.candles.candlesCount * 15 + 'px' }}>
{user.id > -1 ? (
<div>
<div className='exchangeTriggerDativeY'
style={ { transform: 'translateY(' + (mousePosition.y - 175) + 'px)' } }>
<p>{ parseInt(cursorValue) } PLN</p>
style={{ transform: 'translateY(' + (mousePosition.y - 175) + 'px)' }}>
<p>{parseInt(cursorValue)} PLN</p>
</div>
<div className='exchangeTriggerDativeX'
style={ { transform: 'translateX(' + (mousePosition.x) + 'px)' } }>
style={{ transform: 'translateX(' + (mousePosition.x) + 'px)' }}>
</div>
</div>
) : (
<div></div>
) }
{ exchange.candles.candles.map( (candle, key) => {
<div></div>
)}
{exchange.candles.candles.map((candle, key) => {
const color = candle.Open > candle.Close ? colorRed.background : colorGreen.background
const color = candle.Open > candle.Close ? colorRed.background : colorGreen.background
let highValue = candle.Open > candle.Close ? candle.Open : candle.Close
let lowValue = candle.Open < candle.Close ? candle.Open : candle.Close
let highValue = candle.Open > candle.Close ? candle.Open : candle.Close
let lowValue = candle.Open < candle.Close ? candle.Open : candle.Close
let scaleProperties = 10
let scaleProperties = 10
let chartScaleY = (exchange.candles.graphMax - candle.Max) / pixelScale
let chartScaleY = (exchange.candles.graphMax - candle.Max) / pixelScale
let onePercentScaleY = 100 / chartScaleY
let difference = ( highValue - lowValue ) / pixelScale
let onePercentScaleY = 100 / chartScaleY
let difference = (highValue - lowValue) / pixelScale
if ( parseInt(difference) === 0 )
difference = 1
if (parseInt(difference) === 0)
difference = 1
return (
return (
<div
key={key}
className='sectionChart'
onMouseOver={() => getCandleInformation(candle)}>
<div className='sectionCandle'>
<div
key={ key }
className='sectionChart'
onMouseOver={ () => getCandleInformation(candle) }>
<div className='sectionCandle'>
<div
className='candle'
style={ { paddingTop: chartScaleY + 'px' } }>
<div
className='candleMaxValue'
style={ { height: parseInt( (candle.Max - highValue ) / pixelScale ) + 'px', background: color }}>
</div>
<div
className='candleHigh'
style={{ height: parseInt( difference ) + 'px', background: color }}>
</div>
<div
className='candleMinValue'
style={ { height: parseInt( ( lowValue - candle.Min ) / pixelScale ) + 'px', background: color }}>
</div>
</div>
className='candle'
style={{ paddingTop: chartScaleY + 'px' }}>
<div
className='candleMaxValue'
style={{ height: parseInt((candle.Max - highValue) / pixelScale) + 'px', background: color }}>
</div>
<div className='sectionVolumen'>
<div className='volumen'
style={ { height: candle.Volume / 1.5 + 'px' } }>
</div>
<div
className='candleHigh'
style={{ height: parseInt(difference) + 'px', background: color }}>
</div>
<div
className='candleMinValue'
style={{ height: parseInt((lowValue - candle.Min) / pixelScale) + 'px', background: color }}>
</div>
</div>
)
}
</div>
<div className='sectionVolumen'>
<div className='volumen'
style={{ height: candle.Volume / 1.5 + 'px' }}>
</div>
</div>
</div>
)
}
)
}
</div>
</div>
<div className={ user.id > -1 ? 'exchangeInterface' : 'exchangeEmptySpace' }>
<div className={user.id > -1 ? 'exchangeInterface' : 'exchangeEmptySpace'}>
<div className='candleInformation'>
<p>Open: { candleInfo.Open } PLN,</p>
<p>Close: { candleInfo.Close } PLN,</p>
<p>Max: { candleInfo.Max } PLN,</p>
<p>Min: { candleInfo.Min } PLN,</p>
<p>Volume: { candleInfo.Vol },</p>
<p>Date: { candleInfo.Date }</p>
<p>Open: {candleInfo.Open} PLN</p>
<p>Close: {candleInfo.Close} PLN</p>
<p>Max: {candleInfo.Max} PLN</p>
<p>Min: {candleInfo.Min} PLN</p>
<p>Volume: {candleInfo.Vol}</p>
<p>Date: {candleInfo.Date}</p>
</div>
{ user.id > -1 ? (
<div>
<ExchangeTriggerAdd triggerValue={ triggerValue } />
<ExchangePrognosis />
<ExchangeNotifications />
</div>
) : (
<div></div>
)
}
</div>
{user.id > -1 ? (
<div id='exchangeInterfaceTwo'>
<ExchangeTriggerAdd triggerValue={triggerValue} />
<ExchangePrognosis />
<ExchangeNotifications />
</div>
) : (
<div></div>
)
}
</div>
)
}
@ -158,10 +168,10 @@ const mapStateToProps = state => ({
})
const mapDispatchToProps = dispatch => ({
getChart: exchange => dispatch( getChart(exchange) ),
getUserTriggers: exchange => dispatch( getUserTriggers(exchange) ),
getUserNotifications: exchange => dispatch( getUserNotifications(exchange) ),
getUserTransactions: exchange => dispatch( getUserTransactions(exchange) )
getChart: exchange => dispatch(getChart(exchange)),
getUserTriggers: exchange => dispatch(getUserTriggers(exchange)),
getUserNotifications: exchange => dispatch(getUserNotifications(exchange)),
getUserTransactions: exchange => dispatch(getUserTransactions(exchange))
})
export default connect(mapStateToProps,mapDispatchToProps)(IndexExchange)
export default connect(mapStateToProps, mapDispatchToProps)(IndexExchange)

View File

@ -16,7 +16,15 @@ const ForumCommentUpdate = ({
const updateCommentTextArea = React.createRef()
const updateOldComment = (event) => {
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms))
}
let subjectLoad = {
id: subjects.actualSubjectID
}
const updateOldComment = async (event) => {
event.preventDefault()
if ( updateCommentTextArea.current.value !== '' ) {
let commentData = {
@ -25,7 +33,9 @@ const ForumCommentUpdate = ({
text: updateCommentTextArea.current.value
}
updateCommentTextArea.current.value = ''
updateComment(commentData)
await updateComment(commentData)
await sleep(100)
await refreshSubjectComments(subjectLoad)
}
}

View File

@ -23,7 +23,15 @@ const ForumComments = ({
const addCommentTextArea = React.createRef()
const addNewComment = (event) => {
let subjectLoad = {
id: subjects.actualSubjectID
}
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms))
}
const addNewComment = async (event) => {
event.preventDefault()
if ( addCommentTextArea.current.value !== '' ) {
let newComment = {
@ -33,25 +41,21 @@ const ForumComments = ({
token: user.token
}
addCommentTextArea.current.value = ''
addComment(newComment)
await addComment( newComment )
await sleep(100)
await refreshSubjectComments(subjectLoad)
setFormDiv( !formDiv )
let actualSubject = {
id: subjects.actualSubjectID
}
refreshSubjectComments(actualSubject)
}
}
const deleteOldComment = (commentID) => {
const deleteOldComment = async(commentID) => {
let delComment = {
id: commentID,
token: user.token
}
deleteComment(delComment)
let actualSubject = {
id: subjects.actualSubjectID
}
refreshSubjectComments(actualSubject)
await deleteComment(delComment)
await sleep(100)
await refreshSubjectComments(subjectLoad)
}
const [commentText, setCommentText] = useState(0)

View File

@ -57,21 +57,22 @@ const ForumRatings = ({
let divYPositionOnPage = ratingDiv.getBoundingClientRect().top + 72
let yPosition = event.screenY - divYPositionOnPage
if ( yPosition > 200 ) {
if ( yPosition > 270 ) {
setValue(5)
}
else if ( yPosition > 150 && yPosition < 200 ) {
else if ( yPosition > 215 && yPosition < 270 ) {
setValue(4)
}
else if ( yPosition > 100 && yPosition < 150 ) {
else if ( yPosition > 168 && yPosition < 215 ) {
setValue(3)
}
else if ( yPosition > 50 && yPosition < 150 ) {
else if ( yPosition > 120 && yPosition < 168 ) {
setValue(2)
}
else if ( yPosition > 0 && yPosition < 50 ) {
else if ( yPosition > 60 && yPosition < 120 ) {
setValue(1)
}
console.log(yPosition)
}
const [updateRating, setUpdate] = useState(false)

View File

View File

@ -23,6 +23,7 @@ const ForumSubjects = ({
const addSubjectTitle = React.createRef()
const addSubjectComment = React.createRef()
const addNewSubject = (event) => {
event.preventDefault()
if ( addSubjectTitle.current.value !== '' && addSubjectComment.current.value !== '' ) {

View File

View File

0
src/components/indexInterface.js 100644 → 100755
View File

0
src/components/menuBar/menuBar.js 100644 → 100755
View File

0
src/components/useInterval.js 100644 → 100755
View File

0
src/images/BtcLogo.png 100644 → 100755
View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

0
src/images/ForumLogo.png 100644 → 100755
View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

0
src/images/gatsby-astronaut.png 100644 → 100755
View File

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 163 KiB

0
src/images/gatsby-icon.png 100644 → 100755
View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

0
src/images/stockExchange.mp4 100644 → 100755
View File

0
src/pages/index.js 100644 → 100755
View File

0
src/stores/apiAddress.js 100644 → 100755
View File

0
src/stores/chat/duck/actions.js 100644 → 100755
View File

0
src/stores/chat/duck/index.js 100644 → 100755
View File

View File

0
src/stores/chat/duck/reducers.js 100644 → 100755
View File

0
src/stores/chat/duck/types.js 100644 → 100755
View File

View File

@ -4,6 +4,11 @@ const getRatingsComment = item => ({
type: types.GET_COMMENTS_RATINGS, item
})
const addComment = item => ({
type: types.ADD_COMMENT, item
})
export default {
getRatingsComment
getRatingsComment,
addComment
}

0
src/stores/comments/duck/index.js 100644 → 100755
View File

View File

View File

4
src/stores/comments/duck/types.js 100644 → 100755
View File

@ -1,5 +1,7 @@
const GET_COMMENTS_RATINGS = 'GET_COMMENTS_RATINGS'
const ADD_COMMENT = 'ADD_COMMENT'
export default {
GET_COMMENTS_RATINGS
GET_COMMENTS_RATINGS,
ADD_COMMENT
}

View File

0
src/stores/exchange/duck/index.js 100644 → 100755
View File

View File

View File

0
src/stores/exchange/duck/types.js 100644 → 100755
View File

0
src/stores/localStorage.js 100644 → 100755
View File

View File

View File

View File

View File

0
src/stores/reducers.js 100644 → 100755
View File

2
src/stores/store.js 100644 → 100755
View File

@ -11,7 +11,7 @@ const persistedState = loadState();
export const store = createStore(rootReducer, persistedState, composeWithDevTools(applyMiddleware(thunk)))
console.log(store.getState())
// console.log(store.getState())
store.subscribe(() => {
saveState({

View File

@ -12,8 +12,13 @@ const deactivate = item => ({
type: types.DEACTIVATE, item
})
const addComment = item => ({
type: types.ADD_COMMENT, item
})
export default {
getSubjectComments,
activate,
deactivate
deactivate,
addComment
}

0
src/stores/subjects/duck/index.js 100644 → 100755
View File

View File

View File

@ -34,6 +34,11 @@ const subjectReducer = (state = INITIAL_STATE, action) => {
actualSubjectAuthorID: -1,
isActive: false
}
case types.ADD_COMMENT:
return {
...state,
commentsList: [...state.commentsList, action.item]
}
default:
return state;
}

4
src/stores/subjects/duck/types.js 100644 → 100755
View File

@ -1,9 +1,11 @@
const GET_SUBJECT_COMMENTS = 'GET_SUBJECT_COMMENTS'
const ACTIVATE = 'ACTIVATE'
const DEACTIVATE = 'DEACTIVATE'
const ADD_COMMENT = 'ADD_COMMENT'
export default{
GET_SUBJECT_COMMENTS,
ACTIVATE,
DEACTIVATE
DEACTIVATE,
ADD_COMMENT
}

View File

0
src/stores/threads/duck/index.js 100644 → 100755
View File

View File

View File

0
src/stores/threads/duck/types.js 100644 → 100755
View File

0
src/stores/user/duck/actions.js 100644 → 100755
View File

0
src/stores/user/duck/index.js 100644 → 100755
View File

View File

0
src/stores/user/duck/reducers.js 100644 → 100755
View File

0
src/stores/user/duck/types.js 100644 → 100755
View File

0
src/styles/elements.scss 100644 → 100755
View File

5
src/styles/forumRatings.scss 100644 → 100755
View File

@ -14,11 +14,14 @@ $widthRT: 40px;
width: 1px;
height: 250px;
background-color: rgba(117,82,29,1);
border: solid 1px;
border-color: rgba(117,82,29,1);
margin: auto;
}
.ratingValue {
width: $widthRT;
height: 250px;
transition-duration: 0.5s;
}

0
src/styles/general.scss 100644 → 100755
View File

0
src/styles/index.scss 100644 → 100755
View File

0
src/styles/indexChat.scss 100644 → 100755
View File

67
src/styles/indexExchange.scss 100644 → 100755
View File

@ -4,12 +4,11 @@
position: relative;
z-index: 0;
overflow-y: hidden;
overflow: hidden;
width: 100%;
height: auto;
padding-top: 175px;
padding-top: 175px; //175px
margin-left: auto;
margin-right: auto;
@ -22,14 +21,14 @@
@mixin exchangeChart {
width: 100%;
height: 600px;
height: 600px; //600px
overflow: hidden;
overflow-x: scroll;
.chart {
height: 100%;
@include centerEx
@include centerEx;
.sectionChart {
width: 10px;
height: 100%;
@ -44,14 +43,14 @@
.sectionCandle {
width: 100%;
height: 400px;
@include centerEx
@include centerEx;
.candle {
width: 100%;
height: auto;
.candleMaxValue {
@include centerEx
@include centerEx;
width: 1px;
}
@ -65,7 +64,7 @@
}
.candleMinValue {
@include centerEx
@include centerEx;
width: 1px;
}
@ -75,7 +74,7 @@
width: 100%;
height: 200px;
@include centerEx
@include centerEx;
.volumen {
width: 100%;
@ -88,41 +87,46 @@
}
.exchangeChartGuest {
@include exchangeChart
@include exchangeChart;
margin-top: 5vh;
}
.exchangeChartUser {
@include exchangeChart
@include exchangeChart;
}
@mixin exchangeInterface {
z-index: -1;
width: 100%;
height: auto;
background: rgba(0,0,0,0.2);
height: 70%;
position: fixed;
top: 15%;
right: 0px;
.candleInformation {
width: 1500px;
height: 20px;
width: 100%;
height: auto;
padding-top: 10px;
padding-bottom: 20px;
padding-bottom: 30px;
margin-left: auto;
margin-right: auto;
p {
width: 250px;
width: 16.66%;
text-align: center;
float: left;
font-size: 15px;
}
}
}
.exchangeEmptySpace {
@include exchangeInterface
@include exchangeInterface;
}
.exchangeInterface {
@include exchangeInterface
@include exchangeInterface;
}
.exchangeTriggerDativeY {
@ -143,25 +147,32 @@
transform: margin 700ms;
}
#exchangeInterfaceTwo {
background: rgba(0,0,0,0.1);
}
@mixin gapBetweenSectionsEx {
border-right: 2px dashed;
border-color: rgba(117,82,29,0.7);
}
@mixin exchangeDivInterface {
width: 32%;
height: 160px;
padding-left: 10px;
padding-right: 10px;
float:left;
background: rgba(0,0,0,0.2);
width: 31.25%;
height: 94%;
float: left;
padding-left: 1%;
padding-right: 1%;
padding-top: 10px;
overflow: hidden;
p {
font-size: 16px;
}
@include gapBetweenSectionsEx
}
.exchangeTriggerDiv {
@include exchangeDivInterface
@include exchangeDivInterface;
form {
width: 100%;
@ -201,7 +212,7 @@
}
.exchangePrognosisDiv {
@include exchangeDivInterface
@include exchangeDivInterface;
input {
width: 100%;
@ -222,7 +233,7 @@
}
.exchangeNotificationsDiv {
@include exchangeDivInterface
@include exchangeDivInterface;
border-right: 0px;
p {

0
src/styles/indexForum.scss 100644 → 100755
View File

0
src/styles/menuBar.scss 100644 → 100755
View File