Skip to content

Commit

Permalink
refresh git
Browse files Browse the repository at this point in the history
  • Loading branch information
omersiar committed Feb 5, 2018
1 parent 4369fc3 commit c27c2c9
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 88 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

.pioenvs
.piolibdeps
data/*.gz
data/required.css
data/required.js
data/auth/config.json
.clang_complete
.gcc-flags.json
Expand Down
Binary file modified compiledbin/latest.bin
Binary file not shown.
Binary file modified compiledbin/latestspiffs.bin
Binary file not shown.
14 changes: 7 additions & 7 deletions data/auth/log.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
<link rel="icon" href="/favicon.ico">
<title>ESP RFID</title>
<!-- Bootstrap core CSS -->
<link href="/required.css" rel="stylesheet">
<script src="/required.js" type="text/javascript"></script>
<script src="/auth/log.js" type="text/javascript"></script>
<link href="../required.css" rel="stylesheet">
<script src="../required.js" type="text/javascript"></script>
<script src="log.js" type="text/javascript"></script>
</head>
<body onload="start()">
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active"><a href="/auth/log.htm">Logs</a> </li>
<li role="presentation"><a href="/auth/users.htm">Users</a> </li>
<li role="presentation"><a href="/auth/settings.htm">Settings</a> </li>
<li role="presentation" class="active"><a href="log.htm">Logs</a> </li>
<li role="presentation"><a href="users.htm">Users</a> </li>
<li role="presentation"><a href="settings.htm">Settings</a> </li>
</ul>
</nav>
<h3 class="text-muted">ESP RFID</h3>
</div>
<div class="jumbotron">
<div class="overlay" id="loading-img">
<div class="text-center">
<img src="/load.gif">
<img src="../load.gif">
<h5>Please wait while fetching data... <span id="loadpages"></span></h5>
</div>
<br>
Expand Down
11 changes: 6 additions & 5 deletions data/auth/log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var websock = null;
var logdata;
var wsUri;
var wsUri = "ws:https://" + window.location.hostname + "/ws";

function twoDigits(value) {
if(value < 10) {
Expand Down Expand Up @@ -45,11 +45,12 @@ function initTable() {
}

function start() {
var protocol = "ws:https://";
if (window.location.protocol === "https:") {
protocol = "wss:https://";
if (window.location.protocol === "https:") {
wsUri = "wss:https://" + window.location.hostname + "/ws";
}
wsUri =protocol+ window.location.hostname + "/ws";
else if (window.location.protocol === "file:") {
wsUri = "ws:https://" + "localhost" + "/ws";
}
websock = new WebSocket(wsUri);
websock.addEventListener('message', socketMessageListener);
websock.addEventListener('close', socketCloseListener);
Expand Down
9 changes: 5 additions & 4 deletions data/auth/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var haspages;
var file = {};
var userdata = [];
var completed = false;
var wsUri;
var wsUri = "ws:https://" + window.location.hostname + "/ws";

function handleAP() {
document.getElementById("hideBSSID").style.display = "none";
Expand Down Expand Up @@ -328,11 +328,12 @@ $(document).ready(function(){
});

function start() {
var protocol = "ws:https://";
if (window.location.protocol === "https:") {
protocol = "wss:https://";
wsUri = "wss:https://" + window.location.hostname + "/ws";
}
else if (window.location.protocol === "file:") {
wsUri = "ws:https://" + "localhost" + "/ws";
}
wsUri =protocol+ window.location.hostname + "/ws";
websock = new WebSocket(wsUri);
websock.addEventListener('message', socketMessageListener);
websock.addEventListener('error', socketErrorListener);
Expand Down
16 changes: 8 additions & 8 deletions data/auth/settings.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="../favicon.ico">
<title>ESP RFID</title>
<!-- Bootstrap core CSS -->
<link href="/required.css" rel="stylesheet">
<script src="/required.js" type="text/javascript"></script>
<script src="/auth/set.js" type="text/javascript"></script>
<link href="../required.css" rel="stylesheet">
<script src="../required.js" type="text/javascript"></script>
<script src="set.js" type="text/javascript"></script>
</head>
<body onload="start()">
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation"><a href="/auth/log.htm">Logs</a> </li>
<li role="presentation"><a href="/auth/users.htm">Users</a> </li>
<li role="presentation" class="active"><a href="/auth/settings.htm">Settings</a> </li>
<li role="presentation"><a href="log.htm">Logs</a> </li>
<li role="presentation"><a href="users.htm">Users</a> </li>
<li role="presentation" class="active"><a href="settings.htm">Settings</a> </li>
</ul>
</nav>
<h3 class="text-muted">ESP RFID</h3>
Expand All @@ -29,7 +29,7 @@ <h3 class="text-muted">ESP RFID</h3>
<div class="alert alert-warning"><strong>Warning!</strong> Settings will take effect when the device is rebooted.
</div>
<div id="loading-img" class="text-center">
<img src="/load.gif">
<img src="../load.gif">
<h5>Please wait while fetching data... <span id="loadpages"></span></h5>
</div>
<div>
Expand Down
16 changes: 8 additions & 8 deletions data/auth/users.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="../favicon.ico">
<title>ESP RFID</title>
<!-- Bootstrap core CSS -->
<link href="/required.css" rel="stylesheet">
<script src="/required.js" type="text/javascript"></script>
<script src="/auth/users.js" type="text/javascript"></script>
<link href="../required.css" rel="stylesheet">
<script src="../required.js" type="text/javascript"></script>
<script src="users.js" type="text/javascript"></script>
</head>
<body onload="start()">
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills pull-right">
<li role="presentation"><a href="/auth/log.htm">Logs</a> </li>
<li role="presentation" class="active"><a href="/auth/users.htm">Users</a> </li>
<li role="presentation"><a href="/auth/settings.htm">Settings</a> </li>
<li role="presentation"><a href="log.htm">Logs</a> </li>
<li role="presentation" class="active"><a href="users.htm">Users</a> </li>
<li role="presentation"><a href="settings.htm">Settings</a> </li>
</ul>
</nav>
<h3 class="text-muted">ESP RFID</h3>
</div>
<div class="jumbotron">
<div class="overlay">
<div id="loading-img" class="text-center">
<img src="/load.gif">
<img src="../load.gif">
<h5>Please wait while fetching data... <span id="loadpages"></span></h5>
</div>
<br>
Expand Down
11 changes: 6 additions & 5 deletions data/auth/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var timezone;
var userdata = [];
var page = 1;
var haspages;
var wsUri;
var wsUri = "ws:https://" + window.location.hostname + "/ws";

function listSCAN(obj) {
if (obj.known === 1) {
Expand Down Expand Up @@ -237,11 +237,12 @@ FooTable.MyFiltering = FooTable.Filtering.extend({
});

function start() {
var protocol = "ws:https://";
if (window.location.protocol === "https:") {
protocol = "wss:https://";
wsUri = "wss:https://" + window.location.hostname + "/ws";
}
wsUri =protocol+ window.location.hostname + "/ws";
else if (window.location.protocol === "file:") {
wsUri = "ws:https://" + "localhost" + "/ws";
}
websock = new WebSocket(wsUri);
websock.addEventListener('message', socketMessageListener);
websock.addEventListener('close', socketCloseListener);
Expand Down Expand Up @@ -276,7 +277,7 @@ function socketMessageListener(evt) {
document.getElementById("loading-img").style.display = "none";
$(".footable-show").click();
$(".fooicon-remove").click();
websock.send("{\"command\":\"gettime\"}");
websock.send("{\"command\":\"gettime\"}");
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions data/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="favicon.ico">
<title>ESP RFID</title>
<!-- Bootstrap core CSS -->
<link href="/required.css" rel="stylesheet">
<link href="required.css" rel="stylesheet">
<script>
function login() {
if (document.getElementById("password").value === "neo") { alert("Welcome back developer"); document.location = "auth/users.htm"; }
var username = "admin"
var password = document.getElementById("password").value;
var url = "/auth";
var url = "/auth/users.htm";
var xhr = new XMLHttpRequest();
xhr.open("get", url, true, username, password);
xhr.onload = function(e) {
Expand Down
38 changes: 9 additions & 29 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[platformio]
env_default = nodemcuv2
env_default = nodemcu

[common]
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
framework = arduino
lib_deps_builtin =
ESP8266WiFi
SPI
Expand All @@ -14,37 +16,15 @@ lib_deps_external =
https://github.com/miguelbalboa/rfid
https://github.com/PaulStoffregen/Time
https://github.com/gmag11/NtpClient/
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
upload_port = /dev/ttyUSB0
build_flags = -Wl,-Tesp8266.flash.4m.ld
upload_speed = 921600
; Serial Monitor options
monitor_baud = 115200

[env:nodemcuv2]
platform = ${common.platform}
framework = arduino
board = nodemcuv2
; boards which GPIO0 and RESET controlled using two NPN transistors as nodemcu devkit (includes wemos d1 mini)
[env:nodemcu]
board = esp12e
lib_deps =
${common.lib_deps_builtin}
${common.lib_deps_external}
extra_scripts = scripts/pio_script.py


[env:nodemcuv2_mqtt]
platform = ${common.platform}
framework = arduino
board = nodemcuv2
lib_deps =
${common.lib_deps_builtin}
${common.lib_deps_external}
https://github.com/knolleary/pubsubclient
build_flags =
-D MQTT
extra_scripts = scripts/pio_script.py

[env:d1_mini]
platform = ${common.platform}
framework = arduino
board = d1_mini
lib_deps =
${common_env_data.lib_deps_builtin}
${common_env_data.lib_deps_external}
extra_scripts = scripts/pio_script.py
24 changes: 11 additions & 13 deletions scripts/pio_script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Import("env")
import shutil
import gzip
import os
#
# Dump build environment (for debug)
Expand All @@ -11,18 +10,17 @@
# Upload actions
#

def before_buildfs(source, target, env):
try:
os.remove('./data/required.css.gz');
os.remove('./data/required.js.gz');
except OSError:
pass
with open('./datafiles/required.css', 'rb') as f_in:
with gzip.open('./data/required.css.gz', 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
with open('./datafiles/required.js', 'rb') as f_in:
with gzip.open('./data/required.js.gz', 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
env.Replace(
MYUPLOADERFLAGS=[
"-vv",
"-cd", "nodemcu",
"-cb", "$UPLOAD_SPEED",
"-cp", "$UPLOAD_PORT",
"-ca", "0x00000",
"-cf", "$SOURCE"
],
UPLOADCMD='$UPLOADER $MYUPLOADERFLAGS',
)

def after_buildfs(source, target, env):
shutil.copy(spiffs_source, 'compiledbin/latestspiffs.bin')
Expand Down
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void startServer() {
}
}
});
// todo fonts workaround
server.serveStatic("/fonts/glyphicons-halflings-regular.woff2", SPIFFS, "/fonts/glyph.woff2");

// Start Web Server
server.begin();
Expand Down Expand Up @@ -818,7 +820,7 @@ bool loadConfiguration() {
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println(F("[ INFO ] ESP RFID v0.3beta"));
Serial.println(F("[ INFO ] ESP RFID v0.4alpha"));

// Start SPIFFS filesystem
SPIFFS.begin();
Expand Down Expand Up @@ -846,7 +848,7 @@ void loop() {
previousLoopMillis = currentMillis;

if (autoRestartIntervalSeconds > 0 && uptime > autoRestartIntervalSeconds * 1000) {
Serial.println(F("[ UPDT ] Auto restarting..."));
Serial.println(F("[ WARN ] Auto restarting..."));
shouldReboot = true;
}

Expand Down
10 changes: 7 additions & 3 deletions tools/uglifier/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ var gzip = require('gulp-gzip');
gulp.task('scripts', function() {
return gulp.src(['../../datafiles/src/js/jquery-1.12.4.min.js', '../../datafiles/src/js/bootstrap-3.3.7.min.js', '../../datafiles/src/js/footable-3.1.6.min.js', '../../datafiles/src/js/nprogress-0.2.0.js'])
.pipe(concat({ path: 'required.js', stat: { mode: 0666 }}))
.pipe(gulp.dest('../../data/'))
.pipe(gzip({ append: true }))
.pipe(gulp.dest('../../datafiles/'));
.pipe(gulp.dest('../../data/'));
});

gulp.task('styles', function() {
return gulp.src(['../../datafiles/src/css/bootstrap-3.3.7.min.css', '../../datafiles/src/css/footable.bootstrap-3.1.6.min.css', '../../datafiles/src/css/nprogress-0.2.0.css'])
.pipe(concat({ path: 'required.css', stat: { mode: 0666 }}))
.pipe(gulp.dest('../../data/'))
.pipe(gzip({ append: true }))
.pipe(gulp.dest('../../datafiles/'));
});
.pipe(gulp.dest('../../data/'));
});

gulp.task('default', ['scripts', 'styles']);

0 comments on commit c27c2c9

Please sign in to comment.