mirror of https://github.com/portainer/portainer
feat(app/logs): add download button on container logs and service logs views (#4529)
parent
b67c0e870c
commit
4bc958f865
|
@ -7,5 +7,6 @@ angular.module('portainer.docker').component('logViewer', {
|
|||
logCollectionChange: '<',
|
||||
sinceTimestamp: '=',
|
||||
lineCount: '=',
|
||||
resourceName: '<',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
Actions
|
||||
</label>
|
||||
<div class="col-sm-11">
|
||||
<button class="btn btn-primary btn-sm" type="button" ng-click="$ctrl.downloadLogs()" style="margin-left: 0;"><i class="fa fa-download"></i> Download logs</button>
|
||||
<button
|
||||
class="btn btn-primary btn-sm"
|
||||
ng-click="$ctrl.copy()"
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import moment from 'moment';
|
||||
import _ from 'lodash-es';
|
||||
|
||||
angular.module('portainer.docker').controller('LogViewerController', [
|
||||
'clipboard',
|
||||
function (clipboard) {
|
||||
'Blob',
|
||||
'FileSaver',
|
||||
function (clipboard, Blob, FileSaver) {
|
||||
this.state = {
|
||||
availableSinceDatetime: [
|
||||
{ desc: 'Last day', value: moment().subtract(1, 'days').format() },
|
||||
|
@ -43,5 +46,10 @@ angular.module('portainer.docker').controller('LogViewerController', [
|
|||
this.state.selectedLines.splice(idx, 1);
|
||||
}
|
||||
};
|
||||
|
||||
this.downloadLogs = function () {
|
||||
const data = new Blob([_.reduce(this.state.filteredLogs, (acc, log) => acc + '\n' + log, '')]);
|
||||
FileSaver.saveAs(data, this.resourceName + '_logs.txt');
|
||||
};
|
||||
},
|
||||
]);
|
||||
|
|
|
@ -12,4 +12,5 @@
|
|||
display-timestamps="state.displayTimestamps"
|
||||
line-count="state.lineCount"
|
||||
since-timestamp="state.sinceTimestamp"
|
||||
resource-name="container.Name"
|
||||
></log-viewer>
|
||||
|
|
|
@ -12,4 +12,5 @@
|
|||
display-timestamps="state.displayTimestamps"
|
||||
line-count="state.lineCount"
|
||||
since-timestamp="state.sinceTimestamp"
|
||||
resource-name="service.Name"
|
||||
></log-viewer>
|
||||
|
|
|
@ -13,4 +13,5 @@
|
|||
display-timestamps="state.displayTimestamps"
|
||||
line-count="state.lineCount"
|
||||
since-timestamp="state.sinceTimestamp"
|
||||
resource-name="task.Id"
|
||||
></log-viewer>
|
||||
|
|
Loading…
Reference in New Issue