Skip to content

Commit

Permalink
Update 0.2.5
Browse files Browse the repository at this point in the history
Added Wifi Scanning
Added Socket Connection
Added Autologin
Added NOtifybox
Added configManager (realtime config)
  • Loading branch information
lucsoft committed Jun 29, 2019
1 parent 53be946 commit f2dd7f6
Show file tree
Hide file tree
Showing 15 changed files with 614 additions and 267 deletions.
18 changes: 0 additions & 18 deletions Mainframe/lib/config.js

This file was deleted.

32 changes: 32 additions & 0 deletions Mainframe/lib/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"infos": {
"mainframe":"0.2.5",
"moduleManager": "0.2"
},
"modules": {
"lucsoft.homeSYSWeb": {
"token": ""
},
"lucsoft.eventManager": {
"important": 250,
"high": 1000,
"mid": 2500,
"low": 10000
},
"lucsoft.webServer": {
"loginPassword": "Mqjz8Zy4LcY348KB",
"trending": "/v1/store.php?type=trending",
"token": "",
"hostname":"homesys.lucsoft.de",
"theme":"white"
},
"lucsoft.commandManager": {
"enableLED":"echo default-on > /sys/class/leds/led1/trigger",
"disableLED": "echo none > /sys/class/leds/led1/trigger"
},
"lucsoft.HAPWrapper": {
"username": "C1:23:4D:E3:CA:FA",
"pincode": "131-31-313"
}
}
}
19 changes: 19 additions & 0 deletions Mainframe/lib/configManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var fs = require("fs");
var config = module.exports = {};
config.config = {};
config.load = () => {
config.config = require("./config.json");
};
config.get = (id) => {
return config.config.modules[id];
};
config.infos = () => {
return config.config.infos;
};
config.set = (id,name) => {
config.config.modules[id][name];
};
config.push = (id,name) => {
config.config.modules[id][name];
fs.writeFileSync(process.cwd() + "/lib/config.json",JSON.stringify(config.config));
};
7 changes: 6 additions & 1 deletion Mainframe/lib/modulemanager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var fs = require('fs');
var tc = require("../lib/tools");
var config = require("../lib/config");
var config = require("../lib/configManager");

var mmang = module.exports = {};
mmang.onReady = (e) => {};
Expand Down Expand Up @@ -84,7 +84,12 @@ mmang.autoLoad = () => {
modulee.log = (msg) => mmang.logConsole(element.slice(0,element.length - 3),msg,0);
modulee.error = (msg) => mmang.logConsole(element.slice(0,element.length - 3),msg,1);
modulee.getModule = (e) => mmang.getModule(e);
modulee.config = {};
modulee.config.get = () => config.get(element.slice(0,element.length - 3));
modulee.config.set = (e) => config.set(element.slice(0,element.length - 3),e);
modulee.config.push = (e) => config.push(element.slice(0,element.length - 3),e);
modulee.getModules = () => mmang.getModules();
if(modulee.preinitModule != undefined) {modulee.preinitModule();}
mmang.modules.push({name: element.slice(0,element.length - 3),disabled:false,id: index, data: modulee});
mmang.onModuleInitializing({name: element.slice(0,element.length - 3),id: index,data: modulee});
} catch (errorr) {
Expand Down
118 changes: 81 additions & 37 deletions Mainframe/lib/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
<title>HomeSYS</title>
<script src="https://api.lucsoft.de/flatweb/beta/webgen"></script>
<script src="https://api.lucsoft.de/flatweb/beta/jquery.js"></script>
<script src="/lib/socket.io.js"></script>
<link href="https://fonts.googleapis.com/css?family=Material+Icons|Roboto:200,300,100" rel="stylesheet">
<link rel="stylesheet" href="https://api.lucsoft.de/flatweb/beta/init.php">
<theme><link rel="stylesheet" href="https://api.lucsoft.de/flatweb/beta/css/white.css"></theme>
</head>
<body class="FlatWeb nochange">
<span id='notifybox' class="notifybox">Reconnected</span>
<article id="page" class="">
</article>
<script>
var test;
var test,socket;
var ele = {titlew: "titlew",cardlist:"cardlist", imagelist:"imagelist",linebreak:"linebreak",titles:"titles",searchbox:"searchbox",buttons:"buttons", loginwindow:"loginwindow",window:"window", imglist:"imglist",applist:"applist"};
loadModule("lucsoft.database", () => {database.apiurl = "/";

loadModule("lucsoft.database", () => {database.apiurl = "/";
loadParticlesDefault();
elementscount++;
$("#page").append(`<cardlist id="${elementscount}" class="iconlist"></cardlist>`);
$(`#${elementscount}`).addClass("max-width");
Expand All @@ -29,42 +30,85 @@
$(`#${elementscountid}`).append(`<card id="${elementscount}"class="iconbox nohover"><img src="/imgs/homesys.png"></card>`);
var card = elementscount;
$(`#${card}`).addClass("blob");
changeSpaceing(1, 1);
waitFor(300, () => {
changeSpaceing(1, 2);
addElement("loginwindow", {text: {password: "Password", button: "Login", text:"Login to HomeSYS"},
beforelogin: () => {
$('#loginerrormsg').css("color", "black");
$('#loginerrormsg').css("margin", "1.6rem");
$('#loginerrormsg').css("font-weight", "300");
$('#loginerrormsg').html("Anmeldung Läuft...");
changeSpaceing(1, 2);
},afterlogin: () => {
removeLastElement();
removeLastElement();
hidee("#3");
$(`#${card}`).removeClass("blob");

database.login("admin", filterCookie("loginpassword"), (e) => {
changeSpaceing(1, 1);
$(`#${card}`).addClass("blobout");
waitFor(800,() => {
loadHome();
document.cookie["loginpass"] = "loginpassword=" + database.account.password;
$('nav').css("opacity", "100");

waitFor(300, () => {
changeSpaceing(1, 2);
addElement("loginwindow", {text: {password: "Password", button: "Login", text:"Login to HomeSYS"},
beforelogin: () => {
$('#loginerrormsg').css("color", "black");
$('#loginerrormsg').css("margin", "1.6rem");
$('#loginerrormsg').css("font-weight", "300");
$('#loginerrormsg').html("Anmeldung Läuft...");
changeSpaceing(1, 2);
},afterlogin: (e) => {
removeLastElement();
removeLastElement();
hidee("#3");
$(`#${card}`).removeClass("blob");
changeSpaceing(1, 1);
$(`#${card}`).addClass("blobout");
waitFor(800,() => {
loadHome();
socket = io();
socket.on('system', function(es) {
if(es == "logged in") {
triggerNotify("Logged in");
}
if(es == "trigger debug") {
triggerNotify("This is a Debug Message");
}
console.log(es);
});
socket.on('disconnect', () => {
triggerNotify("Connection lost");
});
socket.on('reconnect', (attemptNumber) => {
socket.emit("system", "login " + e);
triggerNotify("Connection established");
});
socket.emit("system", "login " + e);
document.cookie = "loginpassword=" + database.account.password;
$('nav').css("opacity", "100");
});
},onError: () => {
$('#loginerrormsg').css("color", "red");
$('#loginerrormsg').css("margin", "1rem");
$('#loginerrormsg').css("font-weight", "600");
$('#loginerrormsg').html("Deine Anmeldedaten sind falsch");
}}, (e)=> {
test=e;
});
newline();
newline();
newline();
});
},(e) => {
changeSpaceing(1, 1);
waitFor(1200, () => {
loadHome();
socket = io();
socket.on('system', function(es) {
if(es == "logged in") {
triggerNotify("Logged in");
}
if(es == "trigger debug") {
triggerNotify("This is a Debug Message");
}
console.log(es);
});
socket.on('disconnect', () => {
triggerNotify("Connection lost");
});
socket.on('reconnect', (attemptNumber) => {
socket.emit("system", "login " + e);
triggerNotify("Connection established");
});
socket.emit("system", "login " + filterCookie("loginpassword"));
$('nav').css("opacity", "100");
});
});
},onError: () => {
$('#loginerrormsg').css("color", "red");
$('#loginerrormsg').css("margin", "1rem");
$('#loginerrormsg').css("font-weight", "600");
$('#loginerrormsg').html("Deine Anmeldedaten sind falsch");
}}, (e)=> {
test=e;
});
newline();
newline();
newline();
});

});
var menu = `[
{
Expand Down
56 changes: 56 additions & 0 deletions Mainframe/lib/web/welcome.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HomeSYS Setup</title>
<script src="https://api.lucsoft.de/flatweb/beta/webgen"></script>
<script src="https://api.lucsoft.de/flatweb/beta/jquery.js"></script>
<script src="/lib/socket.io.js"></script>
<link href="https://fonts.googleapis.com/css?family=Material+Icons|Roboto:200,300,100" rel="stylesheet">
<link rel="stylesheet" href="https://api.lucsoft.de/flatweb/beta/init.php">
<theme><link rel="stylesheet" href="https://api.lucsoft.de/flatweb/beta/css/white.css"></theme>
</head>
<body class="FlatWeb nochange">
<article id="page" class="">
</article>
<script>
var test,socket;
elementscount++;
$("#page").append(`<cardlist id="${elementscount}" style="max-width:50rem" class="iconlist"></cardlist>`);
$(`#${elementscount}`).addClass("max-width");
$(`#${elementscount}`).addClass("grid_columns_1");

var elementscountid = elementscount;
elementscount++;
$(`#${elementscountid}`).append(`<card id="${elementscount}"class="iconbox nohover"><img src="/imgs/homesys.png"></card>`);

var card = elementscount;
$(`#${card}`).addClass("blob");

changeSpaceing(1, 2);
newline();
addElement("window", {
content: `<span class="text">There are some Steps required to use HomeSYS<br></span>
<list class="style2 nomargin">
<item><span class="left">Password<span class="desc">Required</span></span><span class="right"><input id="input_street" type="password" placeholder=""></span></item>
<item><span class="left">Dark-Theme</span><span class="right"><switch onclick="toggleDarkWhite(() => {});$('#input_theme_i').toggleClass('active');$('#input_theme').click();" id="input_theme_i"></switch><input id="input_theme" class="hide"type="checkbox" ></span></item>
</list>`,
text: {
title: "Finishing HomeSYS Installtion"
},
buttons: [
{
text:"Next",
color:"",
onclick: (ez) => {
}
}
]
},() => {});



</script>
</body>
</html>
7 changes: 3 additions & 4 deletions Mainframe/modules/lucsoft.HAPWrapper.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
var ed = module.exports = {};
ed.version = "0.1.0";
ed.name = "HAPWrapper";
ed.name = "HAP Wrapper";
ed.icon = false;

var fs = require('fs');
var path = require('path');
var config = require("../lib/config");
try {
var storage = require('node-persist');
var uuid = require('hap-nodejs').uuid;
Expand Down Expand Up @@ -367,9 +366,9 @@ ed.loadModule = () => {
callback();
});
bridge.publish({
username: config.homekit.username,
username: ed.config.get().username,
port: 51826,
pincode: config.homekit.pincode,
pincode: ed.config.get().pincode,
category: Accessory.Categories.BRIDGE
});
ed.cnsl.sendMessage("HomeKit Server is running...");
Expand Down
8 changes: 4 additions & 4 deletions Mainframe/modules/lucsoft.Mainframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
var fs = require("fs");
fs.writeFileSync(process.cwd() + "/lib/log.txt", "");

var config = require("../lib/config");
var config = require("../lib/configManager");
config.load();
var tc = require("../lib/tools");
tc.log(`
Expand All @@ -17,7 +17,7 @@ tc.log(`
## ## ## ## ## ## ## ██ ██ ██ ██ ██
## ## ####### ## ## ######## ██████ ██ ██████
Loading Mainframe ${config.mainframeVersion}
Loading Mainframe ${config.infos().mainframe}
Written by lucsoft 2019
`);
try {
Expand All @@ -42,7 +42,7 @@ try {
if(e.name == "lucsoft.webServer") {
e.data.loadDefaultPages();
function requireAuth(req, res,callback) {
if(req.headers['token'] == tc.SHA256(config.web.loginPassword)) {
if(req.headers['token'] == tc.SHA256(config.get("lucsoft.webServer").loginPassword)) {
callback();
} else {
res.status(403);
Expand Down

0 comments on commit f2dd7f6

Please sign in to comment.