mirror of https://github.com/portainer/portainer
fix(logs): extra CRs in downloading container logs EE-1973 (#6041)
parent
33871eb447
commit
b596d0febd
|
@ -32,3 +32,5 @@ angular
|
||||||
export const PORTAINER_FADEOUT = 1500;
|
export const PORTAINER_FADEOUT = 1500;
|
||||||
export const STACK_NAME_VALIDATION_REGEX = '^[-_a-z0-9]+$';
|
export const STACK_NAME_VALIDATION_REGEX = '^[-_a-z0-9]+$';
|
||||||
export const TEMPLATE_NAME_VALIDATION_REGEX = '^[-_a-z0-9]+$';
|
export const TEMPLATE_NAME_VALIDATION_REGEX = '^[-_a-z0-9]+$';
|
||||||
|
export const BROWSER_OS_PLATFORM = navigator.userAgent.indexOf('Windows NT') > -1 ? 'win' : 'lin';
|
||||||
|
export const NEW_LINE_BREAKER = BROWSER_OS_PLATFORM === 'win' ? '\r\n' : '\n';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import _ from 'lodash-es';
|
import _ from 'lodash-es';
|
||||||
|
import { NEW_LINE_BREAKER } from '@/constants';
|
||||||
|
|
||||||
angular.module('portainer.docker').controller('LogViewerController', [
|
angular.module('portainer.docker').controller('LogViewerController', [
|
||||||
'clipboard',
|
'clipboard',
|
||||||
|
@ -48,7 +49,8 @@ angular.module('portainer.docker').controller('LogViewerController', [
|
||||||
};
|
};
|
||||||
|
|
||||||
this.downloadLogs = function () {
|
this.downloadLogs = function () {
|
||||||
const data = new Blob([_.reduce(this.state.filteredLogs, (acc, log) => acc + '\n' + log.line, '')]);
|
// To make the feature of downloading container logs working both on Windows and Linux, we need to use correct new line breakers on corresponding OS.
|
||||||
|
const data = new Blob([_.reduce(this.state.filteredLogs, (acc, log) => acc + log.line + NEW_LINE_BREAKER, '')]);
|
||||||
FileSaver.saveAs(data, this.resourceName + '_logs.txt');
|
FileSaver.saveAs(data, this.resourceName + '_logs.txt');
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,7 +46,7 @@ angular.module('portainer.docker').factory('LogHelper', [
|
||||||
|
|
||||||
function stripHeaders(logs) {
|
function stripHeaders(logs) {
|
||||||
logs = logs.substring(8);
|
logs = logs.substring(8);
|
||||||
logs = logs.replace(/\n(.{8})/g, '\n\r');
|
logs = logs.replace(/\r?\n(.{8})/g, '\n');
|
||||||
|
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue