Skip to content

Commit

Permalink
handle invalid session (close #206)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed May 12, 2019
1 parent e3851ff commit bd1d8f1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
14 changes: 14 additions & 0 deletions addon_files/redmatic/www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,18 @@ iframe {

.pkg-remove, .pkg-install {
width: 100px;
}

#invalidSession {
display: none;
background: white;
z-index: 100000;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
padding: 16px;
font-size: 2em;
}
25 changes: 25 additions & 0 deletions addon_files/redmatic/www/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ $(document).ready(() => {
}, 1600);
}

function invalidSession() {
$('#invalidSession').show();
clearTimeout(psTimeout);
}

function save() {
console.log('save', config)
$.post({
Expand All @@ -237,6 +242,10 @@ $(document).ready(() => {
if ($.trim(data) === 'ok') {
alert($alertSaved);
} else {
if ($.trim(data) === 'error: invalid session') {
invalidSession();
return;
}
alert($alertError);
}
}
Expand All @@ -246,6 +255,10 @@ $(document).ready(() => {
}

$.get('getconfig.cgi' + location.search, (data, success) => {
if ($.trim(data) === 'error: invalid session') {
invalidSession();
return;
}
config = JSON.parse(data);
$loglevel.val(config.logging.ain.level);

Expand Down Expand Up @@ -563,6 +576,9 @@ $(document).ready(() => {
success: data => {
if (data.match(/Starting Node-RED: OK/)) {
alert($alertExec);
} else if ($.trim(data) === 'error: invalid session') {
invalidSession();
return;
} else {
alert($alertError);
}
Expand Down Expand Up @@ -598,6 +614,11 @@ $(document).ready(() => {
$.get({
url: `service.cgi?sid=${sid}&cmd=start`,
success: data => {
if ($.trim(data) === 'error: invalid session') {
invalidSession();
return;
}

if (data.match(/Starting Node-RED: OK/)) {
psInterval = 2000;
setTimeout(() => {
Expand Down Expand Up @@ -629,6 +650,10 @@ $(document).ready(() => {
$.get({
url: `service.cgi?sid=${sid}&cmd=stop`,
success: data => {
if ($.trim(data) === 'error: invalid session') {
invalidSession();
return;
}
if (data.match(/Stopping Node-RED: OK/)) {
alert($alertExec);
psInterval = 2000;
Expand Down
6 changes: 6 additions & 0 deletions addon_files/redmatic/www/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.css">
<link rel="stylesheet" href="css/style.css">

<div id="invalidSession">
Sitzung ungültig. Bitte diese Seite schließen.
</div>

<nav class="navbar sticky-top navbar-light bg-light mb-4" >
<a href="https://github.com/rdmtc/RedMatic" target="_blank"><img src="logo-x-120.png" style="height: 42px; "></a>

Expand Down Expand Up @@ -332,6 +336,8 @@
<div class="tab-pane fade show" id="licenses" role="tabpanel" aria-labelledby="licenses-tab">
<iframe src="licenses.html"></iframe>
</div>


</div>
</div>

Expand Down

0 comments on commit bd1d8f1

Please sign in to comment.