Show a localized message if the program was killed.

* This will most likely happen by the OOM killer, thus we inform the user about the memory restriction.
This commit is contained in:
Sebastian Serth
2022-04-15 21:29:55 +02:00
parent 5f7838ef46
commit 19bd742bc9
10 changed files with 37 additions and 7 deletions

View File

@@ -743,6 +743,13 @@ var CodeOceanEditor = {
});
},
showOutOfMemoryMessage: function () {
$.flash.info({
icon: ['fa', 'fa-clock-o'],
text: $('#editor').data('message-out-of-memory')
});
},
showTimeoutMessage: function () {
$.flash.info({
icon: ['fa', 'fa-clock-o'],

View File

@@ -102,6 +102,11 @@ CodeOceanEditorEvaluation = {
})) {
this.showTimeoutMessage();
}
if (_.some(response, function (result) {
return result.status === 'out_of_memory';
})) {
this.showOutOfMemoryMessage();
}
if (_.some(response, function (result) {
return result.status === 'container_depleted';
})) {

View File

@@ -47,6 +47,7 @@ CodeOceanEditorWebsocket = {
this.websocket.on('render', this.renderWebsocketOutput.bind(this));
this.websocket.on('exit', this.handleExitCommand.bind(this));
this.websocket.on('timeout', this.showTimeoutMessage.bind(this));
this.websocket.on('out_of_memory', this.showOutOfMemoryMessage.bind(this));
this.websocket.on('status', this.showStatus.bind(this));
this.websocket.on('hint', this.showHint.bind(this));
},

View File

@@ -29,10 +29,14 @@ $(document).on('turbolinks:load', function () {
};
const handleResponse = function (response) {
// Always print stdout and stderr
printOutput(response);
// If an error occurred, print it too
if (response.status === 'timeout') {
printTimeout(response);
} else {
printOutput(response);
} else if (response.status === 'out_of_memory') {
printOutOfMemory(response);
}
};
@@ -71,12 +75,19 @@ $(document).on('turbolinks:load', function () {
};
const printTimeout = function (output) {
const element = $.append('<p>');
const element = $('<p>');
element.addClass('text-danger');
element.text($('#shell').data('message-timeout'));
$('#output').append(element);
};
const printOutOfMemory = function (output) {
const element = $('<p>');
element.addClass('text-danger');
element.text($('#shell').data('message-out-of-memory'));
$('#output').append(element);
};
if ($('#shell').isPresent()) {
const command = $('#command')
command.focus();