File tree Expand file tree Collapse file tree
webapp/packages/plugin-log-viewer/src/LogViewer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ export class LogViewerService {
6363
6464 toggle ( ) : void {
6565 if ( this . isActive ) {
66- this . stopLog ( ) ;
66+ this . settings . active = false ;
6767 } else {
68- this . startLog ( ) ;
68+ this . settings . active = true ;
6969 }
7070 }
7171
@@ -74,14 +74,14 @@ export class LogViewerService {
7474 }
7575
7676 async startLog ( ) : Promise < void > {
77- if ( this . isActive ) {
77+ if ( this . timeoutTaskId !== null ) {
7878 return ;
7979 }
80+
8081 if ( ! this . isLogViewerAvailable ( ) ) {
8182 throw new Error ( 'Access denied' ) ;
8283 }
8384 this . failedRequestsCount = 0 ;
84- this . settings . active = true ;
8585
8686 const refreshInterval = this . logViewerSettingsService . settings . isValueDefault ( 'refreshTimeout' )
8787 ? this . coreSettingsService . settings . getValue ( 'app.logViewer.refreshTimeout' )
@@ -100,7 +100,6 @@ export class LogViewerService {
100100 clearTimeout ( this . timeoutTaskId ) ;
101101 this . timeoutTaskId = null ;
102102 }
103- this . settings . active = false ;
104103 }
105104
106105 clearLog ( ) : void {
Original file line number Diff line number Diff line change 77 */
88
99import { observable } from 'mobx' ;
10+ import { useEffect } from 'react' ;
1011
1112import { useObjectRef , useObservableRef } from '@cloudbeaver/core-blocks' ;
1213import { useService } from '@cloudbeaver/core-di' ;
@@ -22,6 +23,13 @@ interface Props {
2223export function useLogViewer ( ) {
2324 const logViewerService = useService ( LogViewerService ) ;
2425
26+ useEffect ( ( ) => {
27+ logViewerService . startLog ( ) ;
28+ return ( ) => {
29+ logViewerService . stopLog ( ) ;
30+ } ;
31+ } , [ ] ) ;
32+
2533 const props : Props = useObservableRef (
2634 ( ) => ( { selectedItem : null } ) ,
2735 { selectedItem : observable . ref } ,
You can’t perform that action at this time.
0 commit comments