1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-30 18:59:41 +02:00

feat(log-viewer): introduce the log viewer component (#1666)

This commit is contained in:
Anthony Lapenna 2018-02-28 07:19:28 +01:00 committed by GitHub
parent 81de2a5afb
commit 0c5152fb5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 458 additions and 304 deletions

View file

@ -44,6 +44,18 @@ function genericHandler(data) {
return response;
}
// The Docker API returns the logs as a single string.
// This handler will return an array with each line being an entry.
// It will also strip the 8 first characters of each line and remove any ANSI code related character sequences.
function logsHandler(data) {
var logs = data;
logs = logs.substring(8);
logs = logs.replace(/\n(.{8})/g, '\n\r');
logs = logs.replace(
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
return logs.split('\n');
}
// Image delete API returns an array on success (Docker 1.9 -> Docker 1.12).
// On error, it returns either an error message as a string (Docker < 1.12) or a JSON object with the field message
// container the error (Docker = 1.12).