Compare commits
9 Commits
market-cap
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d436942617 | |||
| f50380313e | |||
| 2183ecb560 | |||
| 6167326e0f | |||
| 9dbf0de7d0 | |||
| 47d2f4c75d | |||
| bba412b0d1 | |||
| 0d104f3136 | |||
| 6616cec0e7 |
@@ -1,19 +0,0 @@
|
|||||||
# Backend for the Simcompanies-Dashboard
|
|
||||||
|
|
||||||
## Available Scripts
|
|
||||||
|
|
||||||
In the project directory, you can run:
|
|
||||||
|
|
||||||
### `yarn start`
|
|
||||||
|
|
||||||
Runs the app in the production mode.<br />
|
|
||||||
Access the API and frontend files on [http://localhost:3001](http://localhost:3001) to view it in the browser.
|
|
||||||
|
|
||||||
### `npm run debug`
|
|
||||||
|
|
||||||
Runs the app in the developement mode.<br />
|
|
||||||
Access the API and frontend files on [http://localhost:3001](http://localhost:3001) to view it in the browser.
|
|
||||||
No database needed. Mock data is used.
|
|
||||||
You can only login with the credentials "test" "test".
|
|
||||||
|
|
||||||
The server reloads on changes you still need to refresh your browserpage yourself.
|
|
||||||
@@ -199,7 +199,7 @@ app.delete("/API/user/logout", function (req, res) {
|
|||||||
return res.status(status.OK).send("logout success");
|
return res.status(status.OK).send("logout success");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/API/price/day', function (req, res) {
|
app.get('/API/day', function (req, res) {
|
||||||
const kind = parseInt(req.query.kind);
|
const kind = parseInt(req.query.kind);
|
||||||
if (Number.isInteger(kind)) {
|
if (Number.isInteger(kind)) {
|
||||||
//Mock Data:
|
//Mock Data:
|
||||||
@@ -226,34 +226,7 @@ app.get('/API/price/day', function (req, res) {
|
|||||||
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/API/amount/day', function (req, res) {
|
app.get('/API/week', function (req, res) {
|
||||||
const kind = parseInt(req.query.kind);
|
|
||||||
if (Number.isInteger(kind)) {
|
|
||||||
//Mock Data:
|
|
||||||
if (kind === -1 || DEBUG) return res.send(mockDataDay);
|
|
||||||
|
|
||||||
if (kind >= 1 && kind <= 113) {
|
|
||||||
var dayend = new Date().toMysqlFormat();
|
|
||||||
var daybegin = new Date();
|
|
||||||
daybegin.setDate(daybegin.getDate() - 1);
|
|
||||||
daybegin = daybegin.toMysqlFormat();
|
|
||||||
const querystring = `SELECT time, quality, amount FROM marketcap WHERE kind = ${kind} AND time > "${daybegin}" AND time < "${dayend}" ORDER BY time, quality`;
|
|
||||||
connection.query(querystring, function (error, results, fields) {
|
|
||||||
if (error) {
|
|
||||||
return res.status(status.INTERNAL_SERVER_ERROR).send("database connection failed");
|
|
||||||
}
|
|
||||||
return res.send(results);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return res.status(status.BAD_REQUEST).send("invalid data range provided");
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/API/price/week', function (req, res) {
|
|
||||||
const kind = parseInt(req.query.kind);
|
const kind = parseInt(req.query.kind);
|
||||||
if (Number.isInteger(kind)) {
|
if (Number.isInteger(kind)) {
|
||||||
//Mock Data:
|
//Mock Data:
|
||||||
@@ -286,40 +259,7 @@ app.get('/API/price/week', function (req, res) {
|
|||||||
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/API/amount/week', function (req, res) {
|
app.get('/API/month', function (req, res) {
|
||||||
const kind = parseInt(req.query.kind);
|
|
||||||
if (Number.isInteger(kind)) {
|
|
||||||
//Mock Data:
|
|
||||||
if (kind === -1 || DEBUG) return res.send(mockDataWeek);
|
|
||||||
|
|
||||||
if (kind >= 1 && kind <= 113) {
|
|
||||||
var day = new Date();
|
|
||||||
day.setDate(day.getDate() - 6)
|
|
||||||
var querying = "";
|
|
||||||
for (let i = 0; i < 7; i++) {
|
|
||||||
let currentday = day.toMysqlFormat().split(" ")[0];
|
|
||||||
querying += `SELECT "${currentday + " 3:00:00"}" as time,kind,quality,AVG(amount) as amount FROM marketcap WHERE kind = ${kind} AND TIME > "${currentday} 00:00:00" AND TIME <= "${currentday} 05:59:59" GROUP BY kind,quality UNION `;
|
|
||||||
querying += `SELECT "${currentday + " 09:00:00"}" as time,kind,quality,AVG(amount) as amount FROM marketcap WHERE kind = ${kind} AND TIME > "${currentday} 6:00:00" AND TIME <= "${currentday} 11:59:59" GROUP BY kind,quality UNION `;
|
|
||||||
querying += `SELECT "${currentday + " 15:00:00"}" as time,kind,quality,AVG(amount) as amount FROM marketcap WHERE kind = ${kind} AND TIME > "${currentday} 12:00:00" AND TIME <= "${currentday} 17:59:59" GROUP BY kind,quality UNION `;
|
|
||||||
querying += `SELECT "${currentday + " 21:00:00"}" as time,kind,quality,AVG(amount) as amount FROM marketcap WHERE kind = ${kind} AND TIME > "${currentday} 18:00:00" AND TIME <= "${currentday} 23:59:59" GROUP BY kind,quality ${i === 6 ? "" : "UNION"} `;
|
|
||||||
day.setDate(day.getDate() + 1);
|
|
||||||
}
|
|
||||||
connection.query(querying, function (error, results, fields) {
|
|
||||||
if (error) {
|
|
||||||
return res.status(status.INTERNAL_SERVER_ERROR).send("database connection failed");
|
|
||||||
}
|
|
||||||
return res.send(results);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return res.status(status.BAD_REQUEST).send("invalid data range provided");
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/API/price/month', function (req, res) {
|
|
||||||
const kind = parseInt(req.query.kind);
|
const kind = parseInt(req.query.kind);
|
||||||
if (Number.isInteger(kind)) {
|
if (Number.isInteger(kind)) {
|
||||||
//Mock Data:
|
//Mock Data:
|
||||||
@@ -349,36 +289,6 @@ app.get('/API/price/month', function (req, res) {
|
|||||||
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/API/amount/month', function (req, res) {
|
|
||||||
const kind = parseInt(req.query.kind);
|
|
||||||
if (Number.isInteger(kind)) {
|
|
||||||
//Mock Data:
|
|
||||||
if (kind === -1 || DEBUG) return res.send(mockDataMonth);
|
|
||||||
|
|
||||||
if (kind >= 1 && kind <= 113) {
|
|
||||||
var day = new Date();
|
|
||||||
day.setDate(day.getDate() - 29);
|
|
||||||
var querying = "";
|
|
||||||
for (let i = 0; i < 30; i++) {
|
|
||||||
let currentday = day.toMysqlFormat().split(" ")[0];
|
|
||||||
querying += `SELECT "${currentday}" as time,kind,quality,AVG(amount) as amount FROM marketcap WHERE kind = ${kind} AND TIME >= "${currentday} 00:00:00" AND TIME <= "${currentday} 23:59:59" GROUP BY kind,quality ${i === 29 ? "" : "UNION"} `;
|
|
||||||
day.setDate(day.getDate() + 1);
|
|
||||||
}
|
|
||||||
connection.query(querying, function (error, results, fields) {
|
|
||||||
if (error) {
|
|
||||||
return res.status(status.INTERNAL_SERVER_ERROR).send("database connection failed");
|
|
||||||
}
|
|
||||||
return res.send(results);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return res.status(status.BAD_REQUEST).send("invalid data range provided");
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get('/API/resourcelist', function (req, res) {
|
app.get('/API/resourcelist', function (req, res) {
|
||||||
return res.send(resourceList);
|
return res.send(resourceList);
|
||||||
});
|
});
|
||||||
|
|||||||
BIN
frontend/public/android-chrome-512x512.png
Normal file
BIN
frontend/public/android-chrome-512x512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
BIN
frontend/public/android-icon-192x192.png
Normal file
BIN
frontend/public/android-icon-192x192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
frontend/public/apple-icon-180x180.png
Normal file
BIN
frontend/public/apple-icon-180x180.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
<link rel="icon" sizes="64x64" href="%PUBLIC_URL%/favicon.ico" />
|
||||||
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/apple-icon-180x180.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="%PUBLIC_URL%/android-icon-192x192.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="512x512" href="%PUBLIC_URL%/android-chrome-512x512.png">
|
||||||
|
<meta name="theme-color" content="#0B1929" />
|
||||||
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
|
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
|
||||||
<meta name="description" content="This is the dashboard for sim companies ">
|
<meta name="description" content="This is the dashboard for sim companies ">
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
|
|||||||
@@ -5,9 +5,22 @@
|
|||||||
"src": "favicon.ico",
|
"src": "favicon.ico",
|
||||||
"sizes": "64x64 32x32 24x24 16x16",
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
"type": "image/x-icon"
|
"type": "image/x-icon"
|
||||||
}],
|
},
|
||||||
|
{
|
||||||
|
"src": "android-icon-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png",
|
||||||
|
"density": "4.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "android-chrome-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"density": "4.0"
|
||||||
|
}
|
||||||
|
],
|
||||||
"start_url": ".",
|
"start_url": ".",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"theme_color": "#000000",
|
"theme_color": "#0B1929",
|
||||||
"background_color": "#ffffff"
|
"background_color": "#0B1929"
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ export default function ResourceChart(props) {
|
|||||||
if (loading === null) {
|
if (loading === null) {
|
||||||
setLoading(<LinearProgress />)
|
setLoading(<LinearProgress />)
|
||||||
}
|
}
|
||||||
let dayData = await fetch(`/simcompanies/API/price/${interval}?kind=${id}`);
|
let dayData = await fetch(`/simcompanies/API/${interval}?kind=${id}`);
|
||||||
let dataWithDate = await dayData.json();
|
let dataWithDate = await dayData.json();
|
||||||
let qualitySortedData = [];
|
let qualitySortedData = [];
|
||||||
for (let i = 0; i < dataWithDate.length; i++) {
|
for (let i = 0; i < dataWithDate.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user