mirror of
https://github.com/TheGreyDiamond/elevatormapRewritten.git
synced 2025-12-16 23:10:45 +01:00
Compare commits
5 Commits
5f7385a1b6
...
bc2a66236e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc2a66236e | ||
|
|
7d5fdcef9b | ||
|
|
b2708329c1 | ||
|
|
51d92c139d | ||
|
|
b05241f493 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -80,7 +80,6 @@ typings/
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
@@ -104,3 +103,5 @@ dist
|
||||
.tern-port
|
||||
|
||||
testingDONOTCOMMITME.json
|
||||
|
||||
static/uploads/*
|
||||
|
||||
7
LICENSE
Normal file
7
LICENSE
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright © 2021 TheGreydiamond
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
BIN
etc/elevatormapLogo.png
Normal file
BIN
etc/elevatormapLogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 198 KiB |
BIN
etc/elevatormapLogo.xcf
Normal file
BIN
etc/elevatormapLogo.xcf
Normal file
Binary file not shown.
120
index.js
120
index.js
@@ -189,7 +189,7 @@ function checkIfMySQLStructureIsReady() {
|
||||
const sql =
|
||||
"CREATE TABLE `" +
|
||||
mysqlData.database +
|
||||
"`.`elevators` ( `id` INT NOT NULL AUTO_INCREMENT , `lat` FLOAT NOT NULL , `lng` FLOAT NOT NULL , `manufacturer` VARCHAR(512) NOT NULL , `modell` VARCHAR(512) NOT NULL , `info` VARCHAR(512) NOT NULL , `visitabilty` INT NOT NULL , `technology` INT NOT NULL , `images` JSON NOT NULL , `amountOfFloors` INT NOT NULL , `maxPassangers` INT NOT NULL , `maxWeight` INT NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;";
|
||||
"`.`elevators` ( `id` INT NOT NULL AUTO_INCREMENT , `lat` FLOAT NOT NULL , `lng` FLOAT NOT NULL , `manufacturer` VARCHAR(512) NOT NULL , `modell` VARCHAR(512) NOT NULL , `info` VARCHAR(512) NOT NULL , `visitabilty` INT NOT NULL , `technology` INT NOT NULL , `images` JSON NOT NULL , `amountOfFloors` INT NOT NULL , `maxPassangers` INT NOT NULL , `maxWeight` INT NOT NULL , `creator` INT NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB;";
|
||||
const newSql =
|
||||
"CREATE TABLE `" +
|
||||
mysqlData.database +
|
||||
@@ -291,19 +291,33 @@ app.post("/login", function (req, res) {
|
||||
if (response) {
|
||||
// Login okay
|
||||
sess.username = result[0].username;
|
||||
sess.id = result[0].id;
|
||||
sess.uid = String(result[0].id);
|
||||
sess.mail = result[0].email;
|
||||
|
||||
const data = fs.readFileSync("templates/redirect.html", "utf8");
|
||||
res.send(
|
||||
Eta.render(data, {
|
||||
author: author,
|
||||
desc: desc,
|
||||
siteTitel: sitePrefix + "Ok",
|
||||
fontawesomeKey: fontawesomeKey,
|
||||
url: "/profile",
|
||||
})
|
||||
);
|
||||
if(req.query.r != undefined && req.query.r != ""){
|
||||
res.send(
|
||||
Eta.render(data, {
|
||||
author: author,
|
||||
desc: desc,
|
||||
siteTitel: sitePrefix + "Ok",
|
||||
fontawesomeKey: fontawesomeKey,
|
||||
url: req.query.r,
|
||||
})
|
||||
);
|
||||
|
||||
}else{
|
||||
res.send(
|
||||
Eta.render(data, {
|
||||
author: author,
|
||||
desc: desc,
|
||||
siteTitel: sitePrefix + "Ok",
|
||||
fontawesomeKey: fontawesomeKey,
|
||||
url: "/profile",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Password falsch
|
||||
const data = fs.readFileSync("templates/login.html", "utf8");
|
||||
@@ -544,7 +558,7 @@ app.post("/register", function (req, res) {
|
||||
var token = buffer.toString("hex");
|
||||
con.query(
|
||||
stmt,
|
||||
[req.body.email, req.body.username, token],
|
||||
[req.body.email, req.body.username, hash],
|
||||
(err, results1, fields) => {
|
||||
if (err) {
|
||||
res.send(
|
||||
@@ -562,7 +576,7 @@ app.post("/register", function (req, res) {
|
||||
// Create mail verification
|
||||
con.query(
|
||||
stmt2,
|
||||
[req.body.email, results1.insertId, hash],
|
||||
[req.body.email, results1.insertId, token],
|
||||
(err, results, fields) => {
|
||||
if (err) {
|
||||
res.send(
|
||||
@@ -772,7 +786,9 @@ app.get("/map", function (req, res) {
|
||||
|
||||
app.get("/createElevator", function (req, res) {
|
||||
if (mysqlIsUpAndOkay) {
|
||||
const data = fs.readFileSync("templates/createElevator.html", "utf8");
|
||||
|
||||
if (req.session.username != undefined) {
|
||||
const data = fs.readFileSync("templates/createElevator.html", "utf8");
|
||||
res.send(
|
||||
Eta.render(data, {
|
||||
author: author,
|
||||
@@ -782,6 +798,21 @@ app.get("/createElevator", function (req, res) {
|
||||
mapboxAccessToken: mapboxAccessToken,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
const data = fs.readFileSync("templates/redirect.html", "utf8");
|
||||
res.send(
|
||||
Eta.render(data, {
|
||||
author: author,
|
||||
desc: desc,
|
||||
siteTitel: sitePrefix + "Profile",
|
||||
fontawesomeKey: fontawesomeKey,
|
||||
url: "/login?r=/createElevator",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
const data = fs.readFileSync("templates/dbError.html", "utf8");
|
||||
var displayText =
|
||||
@@ -939,11 +970,12 @@ const getAppCookies = (req) => {
|
||||
};
|
||||
|
||||
app.post("/api/saveNewElevatorMeta", function (req, res) {
|
||||
var sess = req.session;
|
||||
console.log(req.headers.cookie);
|
||||
tempJs = JSON.parse(decodeURIComponent(getAppCookies(req, res)["tempStore"]));
|
||||
console.log(tempJs);
|
||||
const sql =
|
||||
"INSERT INTO elevators (lat, lng, manufacturer, modell, info, visitabilty, technology, amountOfFloors, maxPassangers, maxWeight, images) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '{ \"images\": []}')";
|
||||
"INSERT INTO elevators (lat, lng, manufacturer, modell, info, visitabilty, technology, amountOfFloors, maxPassangers, maxWeight, images, creator) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '{ \"images\": []}', ?)";
|
||||
con.query(
|
||||
sql,
|
||||
[
|
||||
@@ -957,6 +989,7 @@ app.post("/api/saveNewElevatorMeta", function (req, res) {
|
||||
tempJs.flor,
|
||||
tempJs.pepl,
|
||||
tempJs.weig,
|
||||
sess.uid
|
||||
],
|
||||
function (err, result) {
|
||||
if (err) throw err;
|
||||
@@ -1027,6 +1060,63 @@ app.get("/api/getElevatorLocation", function (req, res) {
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/api/resolveNameById", function (req, res) {
|
||||
if (mysqlIsUpAndOkay) {
|
||||
if(req.query.id != undefined && req.query.id != ""){
|
||||
|
||||
const sql = "SELECT username FROM users WHERE id=?";
|
||||
con.query(sql, [req.query.id], function (err, result, fields) {
|
||||
if (err) {
|
||||
res.status(500);
|
||||
res.send(
|
||||
JSON.stringify({
|
||||
state: "Failed",
|
||||
message: "A server side error occured.",
|
||||
results: [],
|
||||
})
|
||||
);
|
||||
logger.error("The server failed to execute a request");
|
||||
mysqlIsUpAndOkay = false;
|
||||
} else {
|
||||
console.log(result[0]);
|
||||
res.status(200);
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.send(
|
||||
JSON.stringify({ state: "Ok", message: "", results: result })
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}else{
|
||||
res.status(400);
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.send(JSON.stringify({ state: "Failed", message: "Missing argument: id" }));
|
||||
}
|
||||
} else {
|
||||
const data = fs.readFileSync("templates/dbError.html", "utf8");
|
||||
var displayText =
|
||||
"This might be an artifact of a recent restart. Maybe wait a few minutes and reload this page.";
|
||||
if (startUpTime + 60 <= Math.floor(new Date().getTime() / 1000)) {
|
||||
displayText =
|
||||
"The server failed to connect to the MySQL server. This means it was unable to load any data.";
|
||||
}
|
||||
if (mySQLstate == 1) {
|
||||
displayText =
|
||||
"There is a problem with the database servers setup. Please check the log for more info.";
|
||||
}
|
||||
|
||||
res.send(
|
||||
Eta.render(data, {
|
||||
author: author,
|
||||
desc: desc,
|
||||
siteTitel: sitePrefix + "Error",
|
||||
fontawesomeKey: fontawesomeKey,
|
||||
displayText: displayText,
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/api/getElevatorById", function (req, res) {
|
||||
console.log(req.query);
|
||||
if (req.query.id != undefined) {
|
||||
|
||||
60
static/leafletCluster/dist/MarkerCluster.Default.css
vendored
Normal file
60
static/leafletCluster/dist/MarkerCluster.Default.css
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
.marker-cluster-small {
|
||||
background-color: rgba(181, 226, 140, 0.6);
|
||||
}
|
||||
.marker-cluster-small div {
|
||||
background-color: rgba(110, 204, 57, 0.6);
|
||||
}
|
||||
|
||||
.marker-cluster-medium {
|
||||
background-color: rgba(241, 211, 87, 0.6);
|
||||
}
|
||||
.marker-cluster-medium div {
|
||||
background-color: rgba(240, 194, 12, 0.6);
|
||||
}
|
||||
|
||||
.marker-cluster-large {
|
||||
background-color: rgba(253, 156, 115, 0.6);
|
||||
}
|
||||
.marker-cluster-large div {
|
||||
background-color: rgba(241, 128, 23, 0.6);
|
||||
}
|
||||
|
||||
/* IE 6-8 fallback colors */
|
||||
.leaflet-oldie .marker-cluster-small {
|
||||
background-color: rgb(181, 226, 140);
|
||||
}
|
||||
.leaflet-oldie .marker-cluster-small div {
|
||||
background-color: rgb(110, 204, 57);
|
||||
}
|
||||
|
||||
.leaflet-oldie .marker-cluster-medium {
|
||||
background-color: rgb(241, 211, 87);
|
||||
}
|
||||
.leaflet-oldie .marker-cluster-medium div {
|
||||
background-color: rgb(240, 194, 12);
|
||||
}
|
||||
|
||||
.leaflet-oldie .marker-cluster-large {
|
||||
background-color: rgb(253, 156, 115);
|
||||
}
|
||||
.leaflet-oldie .marker-cluster-large div {
|
||||
background-color: rgb(241, 128, 23);
|
||||
}
|
||||
|
||||
.marker-cluster {
|
||||
background-clip: padding-box;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.marker-cluster div {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-left: 5px;
|
||||
margin-top: 5px;
|
||||
|
||||
text-align: center;
|
||||
border-radius: 15px;
|
||||
font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.marker-cluster span {
|
||||
line-height: 30px;
|
||||
}
|
||||
14
static/leafletCluster/dist/MarkerCluster.css
vendored
Normal file
14
static/leafletCluster/dist/MarkerCluster.css
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
|
||||
-webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-in;
|
||||
-moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in;
|
||||
-o-transition: -o-transform 0.3s ease-out, opacity 0.3s ease-in;
|
||||
transition: transform 0.3s ease-out, opacity 0.3s ease-in;
|
||||
}
|
||||
|
||||
.leaflet-cluster-spider-leg {
|
||||
/* stroke-dashoffset (duration and function) should match with leaflet-marker-icon transform in order to track it exactly */
|
||||
-webkit-transition: -webkit-stroke-dashoffset 0.3s ease-out, -webkit-stroke-opacity 0.3s ease-in;
|
||||
-moz-transition: -moz-stroke-dashoffset 0.3s ease-out, -moz-stroke-opacity 0.3s ease-in;
|
||||
-o-transition: -o-stroke-dashoffset 0.3s ease-out, -o-stroke-opacity 0.3s ease-in;
|
||||
transition: stroke-dashoffset 0.3s ease-out, stroke-opacity 0.3s ease-in;
|
||||
}
|
||||
5
static/leafletCluster/dist/WhereAreTheJavascriptFiles.txt
vendored
Normal file
5
static/leafletCluster/dist/WhereAreTheJavascriptFiles.txt
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
We don't ship the .js files in the git master branch.
|
||||
They are only present in version tags and in npm.
|
||||
|
||||
See how to get the JS files here: https://github.com/Leaflet/Leaflet.markercluster#using-the-plugin
|
||||
Or how to build them: https://github.com/Leaflet/Leaflet.markercluster#building-testing-and-linting-scripts
|
||||
2677
static/leafletCluster/dist/leaflet.markercluster-src.js
vendored
Normal file
2677
static/leafletCluster/dist/leaflet.markercluster-src.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
static/leafletCluster/dist/leaflet.markercluster.js
vendored
Normal file
7
static/leafletCluster/dist/leaflet.markercluster.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -12,5 +12,7 @@
|
||||
|
||||
<b>Type:</b> #TYPE <br>
|
||||
<b>Max. Passerngers:</b> #MAXPASS / #MASSWEIGH (kg) <br>
|
||||
<b>Visitable:</b> #VISIT
|
||||
<b>Visitable:</b> #VISIT <br>
|
||||
|
||||
<i>Created by: #CREATOR</i>
|
||||
</center>
|
||||
@@ -160,6 +160,8 @@
|
||||
</aside>
|
||||
<script type="text/javascript">
|
||||
|
||||
var lockMap = false;
|
||||
|
||||
function noRestore() {
|
||||
off();
|
||||
Cookies.remove("tempStore")
|
||||
@@ -248,6 +250,7 @@
|
||||
}
|
||||
i++;
|
||||
}
|
||||
console.log("DONE!")
|
||||
});
|
||||
|
||||
|
||||
@@ -276,6 +279,7 @@
|
||||
document.getElementById("step2").style.display = 'none';
|
||||
document.getElementById("step3").style.display = 'block';
|
||||
document.getElementById("step4").style.display = 'none';
|
||||
lockMap = false;
|
||||
}
|
||||
if (currentPage == 3) {
|
||||
document.getElementById("step1").style.display = 'none';
|
||||
@@ -284,6 +288,7 @@
|
||||
document.getElementById("step4").style.display = 'block';
|
||||
document.getElementById("step5").style.display = 'none';
|
||||
document.getElementById("missingAlert").style.display = 'none';
|
||||
lockMap = true;
|
||||
}
|
||||
if (currentPage == 4) {
|
||||
document.getElementById("step1").style.display = 'none';
|
||||
@@ -346,17 +351,21 @@
|
||||
var lngElm = document.getElementById("lng");
|
||||
|
||||
latElm.addEventListener('input', function (evt) {
|
||||
markers.clearLayers();
|
||||
console.log(evt.target.value)
|
||||
const lat = evt.target.value;
|
||||
const lng = lngElm.value;
|
||||
var marker = new theMarker([lat, lng])
|
||||
//marker.addTo(mymap)
|
||||
markers.addLayer(marker);
|
||||
markers.addTo(mymap);
|
||||
if(!lockMap){
|
||||
markers.clearLayers();
|
||||
console.log(evt.target.value)
|
||||
const lat = evt.target.value;
|
||||
const lng = lngElm.value;
|
||||
var marker = new theMarker([lat, lng])
|
||||
//marker.addTo(mymap)
|
||||
markers.addLayer(marker);
|
||||
markers.addTo(mymap);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
lngElm.addEventListener('input', function (evt) {
|
||||
if(!lockMap){
|
||||
markers.clearLayers();
|
||||
console.log(evt.target.value)
|
||||
const lat = latElm.value;
|
||||
@@ -365,6 +374,7 @@
|
||||
//marker.addTo(mymap)
|
||||
markers.addLayer(marker);
|
||||
markers.addTo(mymap);
|
||||
}
|
||||
});
|
||||
|
||||
var amountOfImages = 0;
|
||||
@@ -405,6 +415,7 @@
|
||||
home()
|
||||
|
||||
mymap.on('click', function (e) {
|
||||
if(!lockMap){
|
||||
markers.clearLayers();
|
||||
var coord = e.latlng;
|
||||
var lat = coord.lat;
|
||||
@@ -416,6 +427,9 @@
|
||||
document.getElementById("lat").value = lat
|
||||
document.getElementById("lng").value = lng
|
||||
console.log("You clicked the map at latitude: " + lat + " and longitude: " + lng);
|
||||
}else{
|
||||
console.log("The map is locked.")
|
||||
}
|
||||
});
|
||||
|
||||
function addPin(item, index) {
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
<h5>
|
||||
Check it out now <br>
|
||||
<a href= "/map" ><button class="button-primary">Visit the map <i class="fas fa-arrow-right"></i> </button></a>
|
||||
<a href= "/createElevator" ><button class="button-primary">Create a new elevator <i class="fas fa-arrow-right"></i> </button></a>
|
||||
</h5>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -72,11 +72,17 @@
|
||||
class="fas fa-map-marker-alt"
|
||||
onclick="home()"
|
||||
></i>
|
||||
<i style="color: black; cursor: pointer" class="fas fas fa-plus" onclick="createNewElev()"></i>
|
||||
</aside>
|
||||
|
||||
<!-- End Document
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<script type="text/javascript">
|
||||
|
||||
function createNewElev(){
|
||||
window.location.href = "/createElevator";
|
||||
}
|
||||
|
||||
var amountOfImages = 0;
|
||||
var markers = L.markerClusterGroup();
|
||||
slideIndex = 1;
|
||||
@@ -119,7 +125,7 @@
|
||||
res = JSON.parse(httpGet("/api/getElevatorById?id=" + this.options.id));
|
||||
if (res.state == "Ok") {
|
||||
visitStates = [
|
||||
"Test elevator",
|
||||
"Test elevator",
|
||||
"Public",
|
||||
"On private property",
|
||||
"Public but locked",
|
||||
@@ -148,6 +154,13 @@
|
||||
"#VISIT",
|
||||
visitStates[res.results[0].visitabilty]
|
||||
);
|
||||
try{
|
||||
var username = JSON.parse(httpGet("/api/resolveNameById?id=" + res.results[0].creator)).results[0].username
|
||||
}catch{
|
||||
username = "Unknown"
|
||||
}
|
||||
|
||||
inspector = inspector.replace("#CREATOR", username);
|
||||
document.getElementById("inspector").innerHTML = inspector;
|
||||
|
||||
// Make gallery
|
||||
|
||||
Reference in New Issue
Block a user