Skip to content

Commit 1f23708

Browse files
committed
server address connection + error handling + bug fix
1 parent ef4f76f commit 1f23708

File tree

6 files changed

+81
-11
lines changed

6 files changed

+81
-11
lines changed

apis/siocon.js

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ if (typeof module !== 'undefined' && module.exports) {
99
var serverVerifier = 'StockParty Server by David Ehlen, Robin Frischmann, Nils Hirsekorn, Dustin Hoffner';
1010

1111
var siocon = function (url, views, devices, error, connect) {
12+
if ( url === ''){
13+
return error('Invalid server address!');
14+
}
1215
if (url[url.length - 1] !== '/') {
1316
url += '/';
1417
}

config.json

+68-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,68 @@
1-
{"global":{"configmode":false,"devicenameprefix":"device","clientnameprefix":"client","configfilepath":"/Users/david/Desktop/Zeugs/StockParty/app/config.json","port":4217,"interval":30,"stockcrash":false,"running":false},"clients":{"client000":{"_id":"client000","name":"ADMIN","type":"adminpanel","maxsockets":99999,"view":"adminpanel"},"client001":{"_id":"client001","name":"Kasse 1","type":"cashpanel","maxsockets":1,"idd":"device000","view":"cashpanel"},"client002":{"_id":"client002","name":"Kasse 2","type":"cashpanel","maxsockets":1,"idd":"device002","view":"cashpanel"},"client003":{"_id":"client003","name":"Connectors","type":"connector","maxsockets":99999,"view":"connector"},"client004":{"_id":"client004","name":"Monitor 1","type":"monitor","maxsockets":1,"drinks":["drinkid1","drinkid2"],"fontsize":14,"theme":"dark","view":"monitor"}},"devices":{"device000":{"_id":"device000","type":"idd","name":"IDD Device","hid":"3c:15:c2:ba:7b:94-0"},"device001":{"_id":"device001","type":"idd","name":"IDD Device","hid":"3c:15:c2:ba:7b:94-1"}}}
1+
{
2+
"global": {
3+
"configmode": false,
4+
"devicenameprefix": "device",
5+
"clientnameprefix": "client",
6+
"configfilepath": "/Users/david/Desktop/Zeugs/StockParty/app/config.json",
7+
"port": 4217,
8+
"interval": 30,
9+
"stockcrash": false,
10+
"running": false
11+
},
12+
"clients": {
13+
"client000": {
14+
"_id": "client000",
15+
"name": "ADMIN",
16+
"type": "adminpanel",
17+
"maxsockets": 99999,
18+
"view": "adminpanel"
19+
},
20+
"client001": {
21+
"_id": "client001",
22+
"name": "Kasse 1",
23+
"type": "cashpanel",
24+
"maxsockets": 1,
25+
"idd": "device000",
26+
"view": "cashpanel"
27+
},
28+
"client002": {
29+
"_id": "client002",
30+
"name": "Kasse 2",
31+
"type": "cashpanel",
32+
"maxsockets": 1,
33+
"idd": "device002",
34+
"view": "cashpanel"
35+
},
36+
"client003": {
37+
"_id": "client003",
38+
"name": "Connectors",
39+
"type": "connector",
40+
"maxsockets": 99999,
41+
"view": "connector"
42+
},
43+
"client004": {
44+
"_id": "client004",
45+
"name": "Monitor 1",
46+
"type": "monitor",
47+
"maxsockets": 1,
48+
"drinks": ["drinkid1", "drinkid2"],
49+
"fontsize": 14,
50+
"theme": "dark",
51+
"view": "monitor"
52+
}
53+
},
54+
"devices": {
55+
"device000": {
56+
"_id": "device000",
57+
"type": "idd",
58+
"name": "IDD Device",
59+
"hid": "3c:15:c2:ba:7b:94-0"
60+
},
61+
"device001": {
62+
"_id": "device001",
63+
"type": "idd",
64+
"name": "IDD Device",
65+
"hid": "3c:15:c2:ba:7b:94-1"
66+
}
67+
}
68+
}

public/cashPanel.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
<td class="button">CANCEL</td>
4545
<td class="button">OK</td>
4646
</tr>
47-
</tr>
48-
</tr>
4947
</table>
5048
</div>
5149
<div id="userOrderTable">
@@ -66,4 +64,4 @@
6664
</div>
6765
</body>
6866

69-
</html>
67+
</html>

public/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<!-- First ALL Controllers -->
1212
<script src="listView.js"></script>
1313
<script src="adminPanelView.js"></script>
14+
<script src="cashPanelView.js"></script>
15+
<script src="monitorView.js"></script>
1416
<!-- <script src="scanner.js"></script>-->
1517

1618
<!-- Register Devices and Views -->

public/javascript/UIHandler.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ function login() {
128128
function connectServer(inputBox) {
129129
uiConnector.connect(inputBox.value, function (success) {
130130
if (success) {
131-
alert("success");
131+
console.log("success");
132132
} else {
133-
alert("not success")
133+
console.log("not success")
134134
};
135135
});
136136
}
@@ -202,4 +202,4 @@ function addPoint() {
202202
}
203203

204204
window.onload = loadPage;
205-
window.onresize = loadPage;
205+
window.onresize = loadPage;

public/script.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ var url = 'http://localhost:4217/';
22

33
var uiConnector = {};
44

5-
uiConnector.connect = function(url){
5+
uiConnector.connect = function(url, cb){
66
console.log('Starting Connection...');
77
siocon(url, views, devices, function error(err) {
88
console.log('UI: Show connecting to server loading circle');
99
// UI: Show connecting to server loading circle
1010
if(err === 'Invalid server address!'){
1111
console.log('Connection failed! Please try again!', err);
1212
console.log('UI: Show Invalid Server Address please again');
13-
// UI: Show Invalid Server Address please again
13+
cb(false); // UI: Show Invalid Server Address please again
1414
} else {
1515
var msg = 'Connection error!';
1616
console.log('UI: Show Error Page', msg);
17-
// UI: Show Error Page with message msg
17+
showErrorPage(); // UI: Show Error Page with message msg
1818
}
1919
}, function connect(socket) {
2020
uiConnector.socket = socket;
2121
console.log('UI: Show Login fields');
22-
// UI: Show Login fields
22+
cb(true); // UI: Show Login fields
2323
});
2424
};
2525

0 commit comments

Comments
 (0)