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:
parent
a452599829
commit
c9e8021fe8
4 changed files with 31 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue