Skip to content

Commit

Permalink
Merge pull request #3 from jadson179/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
gtjadsonsantos authored Feb 8, 2020
2 parents db2d30c + 9783a31 commit 7c315f1
Show file tree
Hide file tree
Showing 95 changed files with 777 additions and 48 deletions.
7 changes: 6 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@
**Observação**: Se você fizer o provisinamento do banco de dados, pelo arquivo `provisioning.sql`, não clique no botão para provisionar o banco de dados
a ação irá duplicar o usuário administrador e assim o servidor irá para de funcionar;

- `solução de contorno`: exluir o registro adicional do usuário que foi duplicado
- `solução de contorno`: excluir o registro adicional do usuário que foi duplicado

## VERSÃO 1.0.2

* Atualização da view quando quando realizando um upload de imagem ao servidor
* Informação de data e horário
* Cotação de moedas
1 change: 1 addition & 0 deletions backend/controllers/RoomController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {

await connection.query(sql,(err, results, fields)=>{
connection.query(` INSERT INTO Floors (NumberFloor, RoomsID ) VALUES( '${request.body.floor}','${results.insertId}');`,(err, results, fields)=>{
return response.json({results})
})
})

Expand Down
1 change: 0 additions & 1 deletion backend/controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = {
async index (request,response) {
const sql = ` SELECT * FROM Users; `
await connection.query(sql,(err, results, fields)=>{
console.log(results)
results.forEach(user => {
if (user.UserName == request.body.username && user.UserPassword == request.body.password ){
return response.json(user)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/imgs/Thunderstorms.png
Binary file added backend/imgs/dolar.png
Binary file added backend/imgs/partly_cloudy.png
Binary file added backend/imgs/rain.png
Binary file added backend/imgs/rain_e_cloudy.png
11 changes: 11 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ const path = require('path')
const cors = require('cors')
const app = express()
const server = http.Server(app)
const io = require('socket.io')(server)

app.use(cors({}))
app.use(express.json())
app.use(express.urlencoded({extended: true}))

io.on('connection', socket => {
socket.on('send-image', obj=>{
console.log(obj)
if (obj.data == 'send-image'){
socket.broadcast.emit('update', { action: 'update-window' })
}
})
})

app.use(routes)
app.use(express.static(path.join('imgs')))
Expand All @@ -18,3 +27,5 @@ app.use(express.static(path.join('imgs')))
server.listen(3333, ()=>{
console.log('http://0.0.0.0:3333')
})

module.exports = server
Empty file added backend/utils/websocket.js
Empty file.
4 changes: 4 additions & 0 deletions frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');
const path = require('path');
const app = express();


app.use(express.static(path.join(__dirname, 'build')));

app.get('/', function(req, res) {
Expand All @@ -10,6 +11,9 @@ app.get('/', function(req, res) {
app.get('/view', function(req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.get('/view-2', function(req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});

app.listen(8080,()=>{
console.log('https://localhost:8080')
Expand Down
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"node-fetch": "^2.6.0",
"oauth": "^0.9.15",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.3.0"
"react-scripts": "3.3.0",
"socket.io-client": "^2.3.0"
},
"scripts": {
"server": "node index.js",
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/components/AddRoom/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React, { useState } from 'react';
import io from 'socket.io-client'
import api from '../../services/api'
import Themes from '../../global/Themes'
import config from '../../config'

import './style.css'

const socket = io(`${config.backend.url}`)

function AddRoom() {
const [ room, setRoom ] = useState('')
Expand All @@ -18,12 +21,20 @@ function AddRoom() {
data.append('room', room)
data.append('floor', floor)

const response = api.post('/room', data)
const response = await api.post('/room', data)

if(response.status === 200){
document.querySelector('#submit').innerText = 'Sala Adicionada'
document.getElementById('submit').style.cssText = Themes.button.validated


socket.emit('send-image', { data: 'send-image' } )

setInterval(()=>{
document.querySelector('#submit').innerText = 'Enviar'
document.getElementById('submit').style.cssText = Themes.button.reset
},300)


}else {
document.querySelector('#submit').innerText = `Error: ${(await response).status}`
document.getElementById('submit').style.cssText = Themes.button.error
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/components/AlterPassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ function AlterPassword() {

const response = await api.post('/update/user',{ username: sessionStorage.getItem('username'), oldPassword: sessionStorage.getItem('password'), password })

if(!response.data){
document.querySelector('#submit').innerText = 'Senha Alterada'
if(response.data === 200){
document.getElementById('#submit').innerText = 'Senha Alterada'
document.getElementById('submit').style.cssText = Themes.button.validated

setInterval(()=>{
document.getElementById('#submit').innerText = 'Enviar'
document.getElementById('submit').style.cssText = Themes.button.reset
},300)

}else {
document.querySelector('#submit').innerText = `Error: ${response.status}`
document.getElementById('#submit').innerText = `Error: ${response.status}`
document.getElementById('submit').style.cssText = Themes.button.error
}
}else {
document.querySelector('#incorret').innerText = "Preencher todos os campos!!"
document.getElementById('#incorret').innerText = "Preencher todos os campos!!"
}
}

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/CreateUser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function CreateUser() {
if(response.data.status === 'Usuário criado'){
document.querySelector('#submit').innerText = 'Usuário Criado'
document.getElementById('submit').style.cssText = Themes.button.validated

setInterval(()=>{
document.querySelector('#submit').innerText = 'Enviar'
document.getElementById('submit').style.cssText = Themes.button.reset
},300)

}else {
document.querySelector('#submit').innerText = `${response.data.status}`
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Login/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, createContext, useEffect} from 'react';
import React, { useState, useEffect} from 'react';

import history from '../../history'
import history from '../../global/history'
import api from '../../services/api'
import './style.css'

Expand Down
33 changes: 33 additions & 0 deletions frontend/src/components/Price/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState, useEffect } from 'react'
import config from '../../config'
import axios from 'axios'
import './style.css'

function Price() {
const [ price, setPrice] = useState({})

useEffect(()=>{
async function getPrice() {
const response = await axios.get('https://economia.awesomeapi.com.br/all/USD')
const { USD } = response.data
setPrice(USD)
}
getPrice()
},[])
return (
<>
<div className="containerPrice">
<header>
<h2>{ price.name }</h2>
<p>Atualizado em: { price.create_date }</p>
</header>
<section>
<img src={`${config.backend.url}/dolar.png`} alt=""/>
<p>{ price.high }</p>
</section>
</div>
</>
)
}

export default Price
20 changes: 20 additions & 0 deletions frontend/src/components/Price/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.containerPrice {
width: 100%;
height: 90%;
}
.containerPrice header {
height: 110px !important;
width: 100%;
padding: 0;
margin: 0 0 0 0;
}
.containerPrice section {
display: flex;
color: rgb(0, 0, 0);
}
.containerPrice section img {
width: 20px !important;
height: 20px !important;
margin: 0 25px 0 0 !important;

}
54 changes: 36 additions & 18 deletions frontend/src/components/Section/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React, {useState, useEffect} from 'react';

import io from 'socket.io-client';
import api from '../../services/api'
import config from '../../config'
import Weather from '../Weather'

import './style.css';

function Sessao() {
const socket = io(`${config.backend.url}`)

function Sessao() {
const [floor1, setFloor1] = useState([])
const [floor2, setFloor2] = useState([])
const [floor3, setFloor3] = useState([])
Expand All @@ -17,7 +20,7 @@ import './style.css';
const [floor9, setFloor9] = useState([])
const [floor10, setFloor10] = useState([])
const [floor11, setFloor11] = useState([])

const [showWeather, setShowWeather] = useState(false)
const url = config.backend.url

useEffect(()=>{
Expand All @@ -33,7 +36,6 @@ import './style.css';
const res_floor9 = await api.get('/floors/9');
const res_floor10 = await api.get('/floors/10');
const res_floor11 = await api.get('/floors/11');

setFloor1(res_floor1.data)
setFloor2(res_floor2.data)
setFloor3(res_floor3.data)
Expand All @@ -45,12 +47,27 @@ import './style.css';
setFloor9(res_floor9.data)
setFloor10(res_floor10.data)
setFloor11(res_floor11.data)

}
getDatas()
},[])
},[])

useEffect(()=>{
socket.on('update', obj =>{
if(obj.action === "update-window"){
window.location.reload()
}
})
},[])

setTimeout(()=>{
if (showWeather === false){
setShowWeather(true)
document.getElementById('containerInfo').style.display = 'flex';
}else {
setShowWeather(false)
document.getElementById('containerInfo').style.display = 'none';
}
}, 60000)
return (
<>
<div id="container" >
Expand All @@ -59,7 +76,7 @@ import './style.css';
{
floor1.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -70,7 +87,7 @@ import './style.css';
{
floor2.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -81,7 +98,7 @@ import './style.css';
{
floor3.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -92,7 +109,7 @@ import './style.css';
{
floor4.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -103,7 +120,7 @@ import './style.css';
{
floor5.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -114,7 +131,7 @@ import './style.css';
{
floor6.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -125,7 +142,7 @@ import './style.css';
{
floor7.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -136,7 +153,7 @@ import './style.css';
{
floor8.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -147,7 +164,7 @@ import './style.css';
{
floor9.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -158,7 +175,7 @@ import './style.css';
{
floor10.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
))
Expand All @@ -169,13 +186,14 @@ import './style.css';
{
floor11.map(item => (
<>
<img className="imageCostumer" alt={item.NameImage} key={item.RoomID} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<img key={item.RoomID} className="imageCostumer" alt={item.NameImage} id={item.NumberRoom} src={`${url}/${item.NameImage}`} />
<li className="numberRoom" >{item.NumberRoom}</li>
</>
</>
))
}
</ul>
</div>
<Weather />
</>
);
}
Expand Down
Loading

0 comments on commit 7c315f1

Please sign in to comment.