Skip to content

Commit

Permalink
fix css; implement error detection interval and handling; enhance tra…
Browse files Browse the repository at this point in the history
…nslation
  • Loading branch information
GPlay97 committed Nov 14, 2017
1 parent f38c803 commit 0512b09
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 9 deletions.
6 changes: 5 additions & 1 deletion app/www/css/evnotify.css
Expand Up @@ -58,6 +58,9 @@
.charging-info-list .material-icons.mdl-list__item-icon {
float: left;
}
.mdl-layout__drawer {
overflow: hidden;
}
.navigation-icon {
position: absolute;
right: 16px;
Expand All @@ -73,7 +76,8 @@
}
.navigation-element {
position: absolute;
width: 160px;
width: 100%;
box-sizing: border-box;
z-index: 1;
}
.navigation-element.dashboard {
Expand Down
13 changes: 7 additions & 6 deletions app/www/js/obd2.js
Expand Up @@ -4,7 +4,7 @@
function startWatch() {
var config = JSON.parse(getValue('config', '{}'));

watchSoC(config.device, config.car, config.soc, config.polling);
watchSoC(config.device, config.car, config.soc, config.polling, config.errorDetection);
}

function stopWatch() {
Expand Down Expand Up @@ -47,10 +47,11 @@ function toggleDebug() {
* Function which handles the bluetooth connection and communication with the car and sends the notifications
* @param {String} device the device uuid/adress of the OBD2-Dongle
* @param {String} car the car (EVNotify will support more cars soon)
* @param {Integer} soc the soc value on which the user should be notified
* @param {Integer} interval the given interval to check for new soc
* @param {Number} soc the soc value on which the user should be notified
* @param {Number} interval the given interval to check for new soc
* @param {Number} errorinterval the given interal to check for charging errors / interrupts to notify user
*/
function watchSoC(device, car, soc, interval) {
function watchSoC(device, car, soc, interval, errorinterval) {
/**
* Function which shows message on the snackbar
* @param {String} text The text to show
Expand Down Expand Up @@ -125,7 +126,7 @@ function watchSoC(device, car, soc, interval) {
* the car response is good - if there was a charging error or a connection error
* send a notification to user and inform it about the issue
*/
if(LAST_CAR_ACTIVITY && (new Date().getTime() / 1000 > LAST_CAR_ACTIVITY + (((interval)? interval : 60) * 5)) && !NOTIFICATION_SENT) {
if(LAST_CAR_ACTIVITY && errorinterval && (new Date().getTime() / 1000 > LAST_CAR_ACTIVITY + errorinterval) && !NOTIFICATION_SENT) {
bluetooth.setInfoState('unknown');
// send error notification
sendRequest('notification', {akey: getValue('akey'), token: getValue('token'), error: true}, function(err, notificationRes) {
Expand Down Expand Up @@ -205,7 +206,7 @@ function convertSoC(data, callback) {
RAWDATA = RAWDATA.trim().replace(/\s/g, '');

// detect interface errors - re-initialize the obd interface again
if(RAWDATA.indexOf('CANERROR') !== -1 || RAWDATA.indexOf('SEARCHING') !== -1 || RAWDATA.indexOf('UNABLETOCONNECT') !== -1) {
if(RAWDATA.indexOf('CANERROR') !== -1 || RAWDATA.indexOf('STOPPED') !== -1 || RAWDATA.indexOf('UNABLETOCONNECT') !== -1) {
resetDongle(function(err, reset) {
RAWDATA = ''; // reset raw data tracking
});
Expand Down
14 changes: 13 additions & 1 deletion app/www/js/settings.js
Expand Up @@ -19,6 +19,8 @@ function loadSettings() {
pollingDiv = document.getElementById('pollingDiv'),
sync = document.getElementById('sync'),
syncDiv = document.getElementById('syncDiv'),
errorDetection = document.getElementById('chargingerror'),
errorDetectionDiv = document.getElementById('errorDetectionDiv'),
language = document.getElementById('language'),
languageDiv = document.getElementById('languageDiv');

Expand Down Expand Up @@ -49,6 +51,11 @@ function loadSettings() {
sync.value = config.syncObj.title;
sync.setAttribute('data-val', config.syncObj.val);
}
if(config.chargingerrorObj) {
errorDetectionDiv.className += ' is-dirty is-focused';
errorDetection.value = config.chargingerrorObj.title;
errorDetection.setAttribute('data-val', config.chargingerrorObj.val);
}
if(config.lngObj) {
languageDiv.className += ' is-dirty is-focused';
language.value = translate(config.lngObj.name, config.lngObj.lng);
Expand Down Expand Up @@ -95,7 +102,12 @@ function saveSettings() {
val: parseInt(document.getElementById('sync').getAttribute('data-val')),
title: document.getElementById('sync').value
},
autoSync: parseInt(document.getElementById('sync').getAttribute('data-val'))
autoSync: parseInt(document.getElementById('sync').getAttribute('data-val')),
chargingerrorObj: {
val: parseInt(document.getElementById('chargingerror').getAttribute('data-val')),
title: document.getElementById('chargingerror').value
},
errorDetection: parseInt(document.getElementById('chargingerror').getAttribute('data-val')),
});

translatePage(lng);
Expand Down
3 changes: 3 additions & 0 deletions app/www/lng/de.js
Expand Up @@ -114,6 +114,7 @@ de = JSON.parse('{\
"SETTINGS_DEVICES": "Bluetooth-Gerät",\
"SETTINGS_POLLING": "Abfrage-Intervall",\
"SETTINGS_SYNC": "Automatische Synchronisierung",\
"SETTINGS_CHARGINGERROR_DETECTION": "Ladeabbruchs-Erkennung",\
"INTERVAL_0": "deaktiviert",\
"INTERVAL_2": "alle 2 Sekunden",\
"INTERVAL_5": "alle 5 Sekunden",\
Expand All @@ -122,12 +123,14 @@ de = JSON.parse('{\
"INTERVAL_20": "alle 20 Sekunden",\
"INTERVAL_30": "alle 30 Sekunden",\
"INTERVAL_60": "jede Minute",\
"INTERVAL_120": "alle 2 Minuten",\
"INTERVAL_300": "alle 5 Minuten",\
"INTERVAL_600": "alle 10 Minuten",\
"INTERVAL_1800": "jede halbe Stunde",\
"INTERVAL_3600": "jede Stunde",\
"POLLING_WARNING": "Kurze Abfrage-Intervalle führen zu erhöhtem Akkuverbrauch, haben dafür aber eine bessere Genauigkeit.",\
"SYNC_WARNING": "Kurze Synchronisierungs-Intervalle führen zu erhöhtem Datenverbrauch.",\
"CHARGINGERROR_WARNING": "Kurze Fehlerkennungs-Intervalle können eventuell zu Falschmeldungen führen, informieren dafür aber am schnellsten über einen eventuellen Ladeabbruch.",\
"SWITCH_ACCOUNT": "Account wechseln",\
"SWITCH_ACCOUNT_TEXT": "Verbinde beliebig viele Geräte miteinander. Einfach mit einem bestehenden Account hier anmelden. Dazu den AKey des zu nutzenden Accounts angeben.",\
"SYNC_SETTINGS_FAILED": "Synchronisation fehlgeschlagen.",\
Expand Down
3 changes: 3 additions & 0 deletions app/www/lng/en.js
Expand Up @@ -113,6 +113,7 @@ en = JSON.parse('{\
"SETTINGS_DEVICES": "Bluetooth-Device",\
"SETTINGS_POLLING": "Polling-Interval",\
"SETTINGS_SYNC": "Automatic syncronization",\
"SETTINGS_CHARGINGERROR_DETECTION": "Charging error detection",\
"INTERVAL_0": "deactivated",\
"INTERVAL_2": "every 2 seconds",\
"INTERVAL_5": "every 5 seconds",\
Expand All @@ -121,12 +122,14 @@ en = JSON.parse('{\
"INTERVAL_20": "every 20 seconds",\
"INTERVAL_30": "every 30 seconds",\
"INTERVAL_60": "every minute",\
"INTERVAL_120": "every 2 minutes",\
"INTERVAL_300": "every 5 minutes",\
"INTERVAL_600": "every 10 minutes",\
"INTERVAL_1800": "every half an hour",\
"INTERVAL_3600": "every hour",\
"POLLING_WARNING": "Short polling intervals lead to increased battery consumption, but they have a higher accuracy.",\
"SYNC_WARNING": "Short syncronization intervals leads to increased data usage",\
"CHARGINGERROR_WARNING": "Short misrecognition intervals can possibly lead to false alarms, but inform the fastest about a possible aborted loading.",\
"SWITCH_ACCOUNT": "Change account",\
"SWITCH_ACCOUNT_TEXT": "Connect as many devices as you want. Just register with an existing account here. Specify the AKey of the account to be used.",\
"SYNC_SETTINGS_FAILED": "Syncronization failed.",\
Expand Down
17 changes: 16 additions & 1 deletion app/www/settings.html
Expand Up @@ -222,7 +222,22 @@
<li class="mdl-menu__item translate" data-val="3600" id="INTERVAL_3600"></li>
</ul>
</div>
<span style="visibility: visible" class="mdl-textfield__error marginLeft translate" id="SYNC_WARNING"></span><br>
<span style="visibility: visible" class="mdl-textfield__error marginLeft translate" id="SYNC_WARNING"></span><br><br><br>
<!-- Charging Error Detection -->
<div id="errorDetectionDiv" class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label getmdl-select getmdl-select__fix-height marginLeft">
<input class="mdl-textfield__input" type="text" id="chargingerror" readonly tabIndex="-1">
<label for="chargingerror">
<img class="mdl-icon-toggle__label material-icons" src="./icons/keyboard_arrow_down.svg"></img>
</label>
<label for="chargingerror" class="mdl-textfield__label translate" id="SETTINGS_CHARGINGERROR_DETECTION"></label>
<ul for="chargingerror" class="mdl-menu mdl-menu--bottom-left mdl-js-menu" id="chargingerrorList">
<li class="mdl-menu__item translate" data-val="0" id="INTERVAL_0"></li>
<li class="mdl-menu__item translate" data-val="120" id="INTERVAL_120"></li>
<li class="mdl-menu__item translate" data-val="300" id="INTERVAL_300"></li>
<li class="mdl-menu__item translate" data-val="600" id="INTERVAL_600"></li>
</ul>
</div>
<span style="visibility: visible" class="mdl-textfield__error marginLeft translate" id="CHARGINGERROR_WARNING"></span><br>
<!-- Save Button -->
<button onclick="event.preventDefault(); saveSettings()" style="width: 100%; margin-top: 5%"
class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect translate" id="SAVE_SETTINGS">
Expand Down

0 comments on commit 0512b09

Please sign in to comment.