+
-
Loading...
+
Loading...
diff --git a/src-ui/src/app/components/admin/logs/logs.component.spec.ts b/src-ui/src/app/components/admin/logs/logs.component.spec.ts
index a9c4b4613..690bbcdde 100644
--- a/src-ui/src/app/components/admin/logs/logs.component.spec.ts
+++ b/src-ui/src/app/components/admin/logs/logs.component.spec.ts
@@ -1,4 +1,9 @@
-import { ComponentFixture, TestBed } from '@angular/core/testing'
+import {
+ ComponentFixture,
+ TestBed,
+ fakeAsync,
+ tick,
+} from '@angular/core/testing'
import { LogService } from 'src/app/services/rest/log.service'
import { PageHeaderComponent } from '../../common/page-header/page-header.component'
import { LogsComponent } from './logs.component'
@@ -26,6 +31,7 @@ describe('LogsComponent', () => {
let fixture: ComponentFixture
let logService: LogService
let logSpy
+ let reloadSpy
beforeEach(async () => {
TestBed.configureTestingModule({
@@ -42,7 +48,9 @@ describe('LogsComponent', () => {
})
fixture = TestBed.createComponent(LogsComponent)
component = fixture.componentInstance
+ reloadSpy = jest.spyOn(component, 'reloadLogs')
window.HTMLElement.prototype.scroll = function () {} // mock scroll
+ jest.useFakeTimers()
fixture.detectChanges()
})
@@ -68,4 +76,14 @@ describe('LogsComponent', () => {
component.reloadLogs()
expect(component.logs).toHaveLength(0)
})
+
+ it('should auto refresh, allow toggle', () => {
+ jest.advanceTimersByTime(6000)
+ expect(reloadSpy).toHaveBeenCalledTimes(2)
+
+ component.toggleAutoRefresh()
+ expect(component.autoRefreshInterval).toBeNull()
+ jest.advanceTimersByTime(6000)
+ expect(reloadSpy).toHaveBeenCalledTimes(2)
+ })
})
diff --git a/src-ui/src/app/components/admin/logs/logs.component.ts b/src-ui/src/app/components/admin/logs/logs.component.ts
index cf88077e7..2ca259218 100644
--- a/src-ui/src/app/components/admin/logs/logs.component.ts
+++ b/src-ui/src/app/components/admin/logs/logs.component.ts
@@ -27,6 +27,8 @@ export class LogsComponent implements OnInit, AfterViewChecked, OnDestroy {
public isLoading: boolean = false
+ public autoRefreshInterval: any
+
@ViewChild('logContainer') logContainer: ElementRef
ngOnInit(): void {
@@ -41,6 +43,7 @@ export class LogsComponent implements OnInit, AfterViewChecked, OnDestroy {
this.activeLog = this.logFiles[0]
this.reloadLogs()
}
+ this.toggleAutoRefresh()
})
}
@@ -91,4 +94,15 @@ export class LogsComponent implements OnInit, AfterViewChecked, OnDestroy {
behavior: 'auto',
})
}
+
+ toggleAutoRefresh(): void {
+ if (this.autoRefreshInterval) {
+ clearInterval(this.autoRefreshInterval)
+ this.autoRefreshInterval = null
+ } else {
+ this.autoRefreshInterval = setInterval(() => {
+ this.reloadLogs()
+ }, 5000)
+ }
+ }
}
diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.html b/src-ui/src/app/components/admin/tasks/tasks.component.html
index 62799c9f6..7e0ac4cae 100644
--- a/src-ui/src/app/components/admin/tasks/tasks.component.html
+++ b/src-ui/src/app/components/admin/tasks/tasks.component.html
@@ -1,5 +1,5 @@
-