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

feat(k8s/logs): Add the ability to download application/stack logs (#4046)

* feat(logs): Add the ability to download application/stack logs

* feat(kubernetes): minor UI update

Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
Maxime Bajeux 2020-07-16 23:59:27 +02:00 committed by GitHub
parent a452599829
commit c9e8021fe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 2 deletions

View file

@ -1,14 +1,17 @@
import angular from 'angular';
import _ from 'lodash-es';
class KubernetesApplicationLogsController {
/* @ngInject */
constructor($async, $state, $interval, Notifications, KubernetesApplicationService, KubernetesPodService) {
constructor($async, $state, $interval, Notifications, KubernetesApplicationService, KubernetesPodService, Blob, FileSaver) {
this.$async = $async;
this.$state = $state;
this.$interval = $interval;
this.Notifications = Notifications;
this.KubernetesApplicationService = KubernetesApplicationService;
this.KubernetesPodService = KubernetesPodService;
this.Blob = Blob;
this.FileSaver = FileSaver;
this.onInit = this.onInit.bind(this);
this.stopRepeater = this.stopRepeater.bind(this);
@ -35,6 +38,11 @@ class KubernetesApplicationLogsController {
this.repeater = this.$interval(this.getApplicationLogsAsync, this.state.refreshRate);
}
downloadLogs() {
const data = new this.Blob([_.reduce(this.applicationLogs, (acc, log) => acc + '\n' + log, '')]);
this.FileSaver.saveAs(data, this.podName + '_logs.txt');
}
async getApplicationLogsAsync() {
try {
this.applicationLogs = await this.KubernetesPodService.logs(this.application.ResourcePool, this.podName);