Working through start error messages

This commit is contained in:
Andrew 2021-08-07 14:25:47 -04:00
parent e86998e57d
commit 85fe2c9d21
3 changed files with 36 additions and 67 deletions

View File

@ -219,6 +219,40 @@
var webSocket;
// {% end%}
if (webSocket) {
webSocket.on('send_start_error', function (start_error) {
var closeEl = document.createElement('span');
var strongEL = document.createElement('strong');
var msgEl = document.createElement('div');
closeEl.innerHTML = '×';
strongEL.textContent = 'Warning: ';
msgEl.append(strongEL, start_error.error);
closeEl.style.marginLeft = '15px';
closeEl.style.fontWeight = 'bold';
closeEl.style.float = 'right';
closeEl.style.fontSize = '22px';
closeEl.style.lineHeight = '20px';
closeEl.style.cursor = 'pointer';
closeEl.addEventListener('click', function () {this.parentElement.style.display='none';});
var parentEl = document.createElement('div');
parentEl.style.padding = '20px';
parentEl.style.backgroundColor = '#f7970f';
parentEl.appendChild(closeEl);
parentEl.appendChild(msgEl);
document.querySelector('.warnings').appendChild(parentEl);
});
}
function warn(message) {
var closeEl = document.createElement('span');
var strongEL = document.createElement('strong');

View File

@ -229,45 +229,12 @@ function send_command (server_id, command){
success: function(data){
console.log("got response:");
console.log(data);
setTimeout(function(){ location.reload(); }, 10000);
setTimeout(function(){ location.reload() }, 10000);
}
});
}
if (webSocket) {
webSocket.on('send_start_error', function (start_error) {
var closeEl = document.createElement('span');
var strongEL = document.createElement('strong');
var msgEl = document.createElement('div');
closeEl.innerHTML = '×';
strongEL.textContent = 'Warning: ';
msgEl.append(strongEL, start_error.error);
closeEl.style.marginLeft = '15px';
closeEl.style.fontWeight = 'bold';
closeEl.style.float = 'right';
closeEl.style.fontSize = '22px';
closeEl.style.lineHeight = '20px';
closeEl.style.cursor = 'pointer';
closeEl.addEventListener('click', function () {this.parentElement.style.display='none';});
var parentEl = document.createElement('div');
parentEl.style.padding = '20px';
parentEl.style.backgroundColor = '#f7970f';
parentEl.appendChild(closeEl);
parentEl.appendChild(msgEl);
document.querySelector('.warnings').appendChild(parentEl);
});
}
$( document ).ready(function() {
console.log('ready for JS!')

View File

@ -127,7 +127,7 @@
success: function(data){
console.log("got response:");
console.log(data);
setTimeout(function(){ location.reload(); }, 10000);
setTimeout(function(){ }, 10000);
}
});
@ -144,38 +144,6 @@
}
});
}
if (webSocket) {
webSocket.on('send_start_error', function (start_error) {
var closeEl = document.createElement('span');
var strongEL = document.createElement('strong');
var msgEl = document.createElement('div');
closeEl.innerHTML = '×';
strongEL.textContent = 'Warning: ';
msgEl.append(strongEL, start_error.error);
closeEl.style.marginLeft = '15px';
closeEl.style.fontWeight = 'bold';
closeEl.style.float = 'right';
closeEl.style.fontSize = '22px';
closeEl.style.lineHeight = '20px';
closeEl.style.cursor = 'pointer';
closeEl.addEventListener('click', function () {this.parentElement.style.display='none';});
var parentEl = document.createElement('div');
parentEl.style.padding = '20px';
parentEl.style.backgroundColor = '#f7970f';
parentEl.appendChild(closeEl);
parentEl.appendChild(msgEl);
document.querySelector('.warnings').appendChild(parentEl);
});
}
// Convert running to lower case (example: 'True' converts to 'true') and
// then to boolean via JSON.parse()
let online = JSON.parse('{{ data['server_stats']['running'] }}'.toLowerCase());