Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eddy the co patch 1 #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Proof of Work has to be performed by the node.
This application is meant to be used on the testnet.
If using the mainnet **you are the ONLY responsible for the eventual loss of your funds**.

One can download the client application from the releases of this repo or use the [web app](https://eddytheco.github.io/Dlockers/Client/)
One can download the client application from the releases of this repo or use the [web app](https://eddytheco.github.io/DLockers/Client/)

## How to use it

Expand Down
8 changes: 4 additions & 4 deletions Client/ServerMap/src/wasmmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
EM_JS(void, js_setVisible, (const bool visible), {
if(visible)
{
document.getElementById("map").style.zIndex = "1000";
document.getElementById("qtrootDiv").style.zIndex = "1";
document.getElementById("map").style.visibility = "visible";
document.getElementById("qtrootDiv").style.visibility = "hidden";
}
else
{
document.getElementById("map").style.zIndex = "1";
document.getElementById("qtrootDiv").style.zIndex = "1000";
document.getElementById("map").style.visibility = "hidden";
document.getElementById("qtrootDiv").style.visibility = "visible";
}
});

Expand Down
2 changes: 1 addition & 1 deletion Client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char *argv[])
engine.addImportPath("qrc:/esterVtech.com/imports");


const QUrl url(u"qrc:/esterVtech.com/imports/Esterv/DLockers/Client/qml/window.qml"_qs);
const QUrl url("qrc:/esterVtech.com/imports/Esterv/DLockers/Client/qml/window.qml");
engine.load(url);
return app.exec();
}
2 changes: 1 addition & 1 deletion Client/qml/window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Esterv.DLockers.Client


ApplicationWindow {
visible: true
id:window
visible:true
FontLoader {
id: webFont
source: "qrc:/esterVtech.com/imports/Esterv/DLockers/Client/qml/fonts/DeliciousHandrawn-Regular.ttf"
Expand Down
17 changes: 11 additions & 6 deletions Server/include/server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class BookServer : public QObject
{
Q_OBJECT
Q_PROPERTY(bool open READ isOpen NOTIFY openChanged)
Q_PROPERTY(std::vector<qreal> coords READ coords NOTIFY coordsChanged)
Q_PROPERTY(float latitude READ latitude NOTIFY latitudeChanged)
Q_PROPERTY(float longitude READ longitude NOTIFY longitudeChanged)
Q_PROPERTY(DayModel* dayModel READ dayModel CONSTANT)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(QString openAddress READ getOpenAddress NOTIFY openAddressChanged)
Expand All @@ -37,11 +38,14 @@ class BookServer : public QObject
Q_ENUM(State)
static BookServer* instance(){return m_instance;}
DayModel* dayModel(void)const{return m_dayModel;}
std::vector<qreal> coords()const{return m_coords;}
qreal longitude()const{return m_longitude;}
qreal latitude()const{return m_latitude;}
void setCoords(float lat,float lon)
{
m_coords.at(0)=lat;
m_coords.at(1)=lon;
m_latitude=lat;
m_longitude=lon;
emit latitudeChanged();
emit longitudeChanged();
}
void setOpen(bool op){if(op!=m_open){m_open=op;emit openChanged();}}
bool isOpen()const{return m_open;}
Expand All @@ -54,7 +58,8 @@ class BookServer : public QObject


signals:
void coordsChanged();
void latitudeChanged();
void longitudeChanged();
void stateChanged();
void openChanged();
void openAddressChanged();
Expand All @@ -79,7 +84,7 @@ class BookServer : public QObject
void checkLPermission();
void initGPS();

std::vector<qreal> m_coords;
qreal m_latitude,m_longitude;
DayModel* m_dayModel;
State m_state;
c_array m_pubId;
Expand Down
6 changes: 3 additions & 3 deletions Server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
#if defined(FORCE_STYLE)
QQuickStyle::setStyle(FORCE_STYLE);
QQuickStyle::setStyle(FORCE_STYLE);
#endif

QQmlApplicationEngine engine;
engine.addImportPath("qrc:/esterVtech.com/imports");
engine.addImageProvider(QLatin1String("qrcode"), new QRImageProvider(1));
const QUrl url(u"qrc:/esterVtech.com/imports/Esterv/DLockers/Server/qml/window.qml"_qs);
engine.addImageProvider(QLatin1String("qrcode"), new QRImageProvider(1));
const QUrl url("qrc:/esterVtech.com/imports/Esterv/DLockers/Server/qml/window.qml");
engine.load(url);
return app.exec();
}
3 changes: 2 additions & 1 deletion Server/qml/ConfDrawer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ Drawer

NodeConnectionSettings
{
id:conn_
id:conn
Layout.fillWidth: true
}


}

}
15 changes: 8 additions & 7 deletions Server/qml/window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ ApplicationWindow {
});
}


ConfDrawer
{
id:drawer
width: Math.max(parent.width*0.2,350)
height: window.height
}

ColumnLayout
{
anchors.fill: parent
Expand All @@ -64,9 +62,9 @@ ApplicationWindow {
}
Timer {
id:goback
interval: 60000; running: false; repeat: false
onTriggered: openbut.inOpenBox=false;
}
interval: 60000; running: false; repeat: false
onTriggered: openbut.inOpenBox=false;
}
}
RowLayout
{
Expand Down Expand Up @@ -137,14 +135,17 @@ ApplicationWindow {
Layout.minimumHeight: 150
Layout.maximumHeight: width
Layout.alignment: Qt.AlignCenter
latitude:BookServer.coords[0]
longitude:BookServer.coords[1]
latitude: BookServer.latitude
longitude: BookServer.longitude
color:Style.frontColor2
}


}



}

}

16 changes: 6 additions & 10 deletions Server/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ EM_JS(void, js_getPos, (), {
function success(pos) {
const crd = pos.coords;

console.log("Your current position is:");
console.log(`Latitude : ${crd.latitude}`);
console.log(`Longitude: ${crd.longitude}`);
console.log(`More or less ${crd.accuracy} meters.`);
Module.BookServer.instance().setCoords(crd.latitude,crd.longitude);

}
Expand Down Expand Up @@ -213,7 +209,7 @@ void BookServer::restart(void)

#include <QRandomGenerator>

BookServer::BookServer(QObject *parent):QObject(parent),m_pph(10000),m_coords({-90+QRandomGenerator::system()->generateDouble()*180,-180+QRandomGenerator::system()->generateDouble()*360}),m_state(Ready),m_open(false),m_dayModel(new DayModel(this)),
BookServer::BookServer(QObject *parent):QObject(parent),m_pph(10000),m_latitude(-90+QRandomGenerator::system()->generateDouble()*180),m_longitude(-180+QRandomGenerator::system()->generateDouble()*360),m_state(Ready),m_open(false),m_dayModel(new DayModel(this)),
m_timer(new QTimer(this)),receiver(nullptr)
{
Account::instance()->setVaultFile(
Expand All @@ -228,7 +224,6 @@ BookServer::BookServer(QObject *parent):QObject(parent),m_pph(10000),m_coords({-
Account::instance()->readFromVault(VAULT_PASS);
}

//Account::instance()->setSeed("marriage casual adjust trim rail jungle impact view lyrics ginger taxi upset edit negative crystal base amount food wine suit vendor scrub arrow basket");
m_instance=this;
connect(Wallet::instance(),&Wallet::synced,this,[=](){
restart();
Expand All @@ -248,9 +243,10 @@ void BookServer::initGPS(void)
connect(PosSource,&QGeoPositionInfoSource::positionUpdated,
this, [=](const QGeoPositionInfo &update){
const auto geoCoord=update.coordinate();
m_coords.at(0)=geoCoord.latitude();
m_coords.at(1)=geoCoord.longitude();
emit coordsChanged();
m_latitude=geoCoord.latitude();
m_longitude=geoCoord.longitude();
emit latitudeChanged();
emit longitudeChanged();
});
connect(PosSource,&QGeoPositionInfoSource::errorOccurred,
this, [=](QGeoPositionInfoSource::Error _t1){
Expand Down Expand Up @@ -598,7 +594,7 @@ QByteArray BookServer::serializeState()const
var.insert("b",bookings);
var.insert("pph",QString::number(m_pph));
var.insert("pt",(++Wallet::instance()->addresses().begin())->second->getAddressHash());
var.insert("c",QJsonArray({m_coords.at(0),m_coords.at(1)}));
var.insert("c",QJsonArray({m_latitude,m_longitude}));
auto state = QJsonDocument(var);
return state.toJson();
}
2 changes: 1 addition & 1 deletion wasm/Client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<body onload="init()">
<div id="qtrootDiv"></div>
<div id="map" style="visibility: hidden;">
<img src="img/centerButton.png" id="recenter" style="visibility: inherit; position: absolute;top: 10px;right: 10px;z-index: 10001; width:32px; height:32px;">
<img src="img/centerButton.png" id="recenter" style="visibility: hidden; position: absolute;top: 10px;right: 10px;z-index: 10001; width:32px; height:32px;">
</div>
<footer>
<div class="fdiv" id="gitrepo" style="text-align:center;" >
Expand Down
78 changes: 37 additions & 41 deletions wasm/Client/js/scripts.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var mapsPlaceholder = [];
var serverMarkers = [];
var mine;
let qtModule = undefined;
async function init() {




document.body.innerHTML += '<figure id="qtspinner"> <center > <img id="logo" crossorigin="anonymous" src="img/esterlogo.png" ></img> <div id="qtstatus"></div> </center> </figure>';


Expand All @@ -27,44 +27,41 @@ async function init() {
showUi(spinner);
status.innerHTML = 'Loading...';

qtModule = await qtLoad({
const instance = await qtLoad({
qt: {
onLoaded: () =>
{
document.getElementById("map").style.visibility = "visible";
L.Map.addInitHook(function () {
mapsPlaceholder.push(this);
});
const map = L.map('map').setView([51.505, -0.09], 13);

L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
crossOrigin: "",
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
},
).addTo(map);
showUi(screen);
resized = function() {
if(document.documentElement.clientWidth<600)
{
document.getElementById("map").style.zIndex = "1000";
document.getElementById("qtrootDiv").style.zIndex = "1";
qtModule.BookClient.instance().setOneColumn(1);
document.getElementById("map").style.visibility = "visible";
document.getElementById("qtrootDiv").style.visibility = "hidden";
instance.BookClient.instance().setOneColumn(1);
}
else
{
qtModule.BookClient.instance().setOneColumn(0);
document.getElementById("map").style.visibility = "visible";
document.getElementById("qtrootDiv").style.visibility = "visible";
instance.BookClient.instance().setOneColumn(0);
}

var canvas = document.getElementById("screen");
qtModule.qtResizeContainerElement(canvas);
instance.qtResizeContainerElement(canvas);
}
window.addEventListener("resize", resized);
L.Map.addInitHook(function () {
mapsPlaceholder.push(this);
});
document.getElementById("map").style.visibility = "visible";
const map = L.map('map').setView([51.505, -0.09], 13);

const mineMarker = L.icon({
iconUrl: 'img/mineMarker.png',
iconSize: [24, 24],
});

L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
crossOrigin: "",
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
},
).addTo(map);
const options = {
enableHighAccuracy: true,
timeout: 5000,
Expand All @@ -73,30 +70,29 @@ async function init() {

function success(pos) {
const crd = pos.coords;
mine.setLatLng([crd.latitude,crd.longitude]);
}
function initmapview(pos) {
const crd = pos.coords;

mine = new L.marker([crd.latitude,crd.longitude],{icon: mineMarker});
map.addLayer(mine);
map.setView([crd.latitude,crd.longitude],13);
const recButt = document.querySelector("#recenter");
recButt.style.visibility="visible";
recButt.onclick = () => {
map.setView(mine.getLatLng(),13);

};


if ( typeof success.mine == 'undefined' ) {
const mineMarker = L.icon({
iconUrl: 'img/mineMarker.png',
iconSize: [24, 24],
});
success.mine = new L.marker([crd.latitude,crd.longitude],{icon: mineMarker});
map.addLayer(success.mine);
map.setView([crd.latitude,crd.longitude],13);
const recButt = document.querySelector("#recenter");
recButt.style.visibility="inherit";
recButt.onclick = () => {
map.setView(success.mine.getLatLng(),13);
};
}
success.mine.setLatLng([crd.latitude,crd.longitude]);
}
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);

}

id = navigator.geolocation.watchPosition(success, error, options);
navigator.geolocation.getCurrentPosition(initmapview, error, options);

},
onExit: exitData =>
Expand Down
1 change: 0 additions & 1 deletion wasm/Client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ html,body{
height: 100%;
width: 100%;
position: absolute;
z-index:1;
}
a{
text-decoration: underline;
Expand Down
Loading