<nav ngbNav
#nav="ngbNav"
class="nav-tabs"
- cdStatefulTab="logs">
+ cdStatefulTab="logs"
+ [cdStatefulTabDefault]="defaultTab"
+ [hidden]="hideNavLinks">
<ng-container ngbNavItem="cluster-logs">
<a ngbNavLink
i18n>Cluster Logs</a>
*ngIf="clog">
<div class="btn-group"
role="group"
- *ngIf="clog.length">
+ *ngIf="clog.length && !hideClusterLogs">
<cd-download-button [objectItem]="clog"
[textItem]="clogText"
- fileName="cluster_log">
+ fileName="cluster_log"
+ *ngIf="!hideDwnldCpyBtn">
</cd-download-button>
<cd-copy-2-clipboard-button
[source]="clogText"
- [byId]="false">
+ [byId]="false"
+ *ngIf="!hideDwnldCpyBtn">
</cd-copy-2-clipboard-button>
</div>
<div class="card-body">
i18n>Audit Logs</a>
<ng-template ngbNavContent>
<div class="card bg-light mb-3"
- *ngIf="audit_log">
+ *ngIf="audit_log && !hideAuditLogs">
<div class="btn-group"
role="group"
*ngIf="audit_log.length">
<cd-download-button [objectItem]="audit_log"
[textItem]="auditLogText"
- fileName="audit_log">
+ fileName="audit_log"
+ *ngIf="!hideDwnldCpyBtn">
</cd-download-button>
<cd-copy-2-clipboard-button
[source]="auditLogText"
- [byId]="false">
+ [byId]="false"
+ *ngIf="!hideDwnldCpyBtn">
</cd-copy-2-clipboard-button>
</div>
<div class="card-body">
<a ngbNavLink
i18n>Daemon Logs</a>
<ng-template ngbNavContent>
- <ng-container *ngIf="lokiServiceStatus$ | async as lokiServiceStatus; else daemonLogsTpl">
+ <ng-container *ngIf="!hideDaemonLogs && lokiServiceStatus$ | async as lokiServiceStatus ; else daemonLogsTpl ">
<div *ngIf="promtailServiceStatus$ | async as promtailServiceStatus; else daemonLogsTpl">
<cd-grafana i18n-title
title="Daemon logs"
</div>
<ng-template #logFiltersTpl>
- <div class="row mb-3">
+ <div class="row mb-3"
+ *ngIf="!hideFilterTools">
<div class="col-lg-10 d-flex">
<div class="col-sm-1 me-3">
<label for="logs-priority"
import { DatePipe } from '@angular/common';
-import { Component, NgZone, OnDestroy, OnInit } from '@angular/core';
+import { Component, Input, NgZone, OnDestroy, OnInit } from '@angular/core';
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs';
styleUrls: ['./logs.component.scss']
})
export class LogsComponent implements OnInit, OnDestroy {
+ @Input()
+ hideClusterLogs = false;
+ @Input()
+ hideAuditLogs = false;
+ @Input()
+ hideDaemonLogs = false;
+ @Input()
+ hideNavLinks = false;
+ @Input()
+ hideFilterTools = false;
+ @Input()
+ hideDwnldCpyBtn = false;
+ @Input()
+ defaultTab = '';
+
contentData: any;
clog: Array<any>;
audit_log: Array<any>;
directive.onNavChange(event);
expect(window.localStorage.getItem('tabset_bar')).toBe('xyz');
});
+
+ it('should select the default tab if provided', () => {
+ const nav = new NgbNav('tablist', new NgbNavConfig(new NgbConfig()), <any>null, null);
+ spyOn(nav, 'select');
+ const directive = new StatefulTabDirective(nav);
+ directive.cdStatefulTab = 'bar';
+ directive.cdStatefulTabDefault = 'defaultTab';
+ directive.ngOnInit();
+ expect(nav.select).toHaveBeenCalledWith('defaultTab');
+ });
});
export class StatefulTabDirective implements OnInit {
@Input()
cdStatefulTab: string;
+ @Input()
+ cdStatefulTabDefault = '';
private localStorage = window.localStorage;
ngOnInit() {
// Is an activate tab identifier stored in the local storage?
- const activeId = this.localStorage.getItem(`tabset_${this.cdStatefulTab}`);
+ const activeId =
+ this.cdStatefulTabDefault || this.localStorage.getItem(`tabset_${this.cdStatefulTab}`);
if (activeId) {
this.nav.select(activeId);
}