File tree Expand file tree Collapse file tree 3 files changed +36
-16
lines changed
Expand file tree Collapse file tree 3 files changed +36
-16
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
3+ import { NotAuthorizedPage } from '../../../../ui-admin/client/components/settings/NotAuthorizedPage' ;
4+ import { usePermission } from '../../../../../client/contexts/AuthorizationContext' ;
5+
6+ import { ViewLogs } from '.' ;
7+
8+ export default function ViewLogsRoute ( ) {
9+ const canAccessMailer = usePermission ( 'view-logs' ) ;
10+ return canAccessMailer ? < ViewLogs /> : < NotAuthorizedPage /> ;
11+ }
Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import { Meteor } from 'meteor/meteor' ;
2+ import React , { useEffect , useState } from 'react' ;
23import { Box } from '@rocket.chat/fuselage' ;
34
4- import { APIClient } from '../../../../utils/client/index' ;
55import { useTranslation } from '../../../../../client/contexts/TranslationContext' ;
66import { Page } from '../../../../../client/components/basic/Page' ;
7+ import { ansispan } from '../../ansispan' ;
8+ import { APIClient } from '../../../../utils/client' ;
79
810export function ViewLogs ( ) {
9- // const { queue } = await APIClient.v1.get('stdout.queue');
10- const test = APIClient . v1 . get ( 'stdout.queue' ) ;
11+ const [ stdout , setStdout ] = useState ( [ ] ) ;
12+ useEffect ( ( ) => {
13+ ( async ( ) => {
14+ const data = await APIClient . v1 . get ( 'stdout.queue' ) ;
15+
16+ setStdout ( data . queue ) ;
17+ } ) ( ) ;
18+
19+ const stdoutStreamer = new Meteor . Streamer ( 'stdout' ) ;
20+
21+ stdoutStreamer . on ( 'stdout' , ( item ) => stdout . push ( item ) ) ;
22+
23+ return ( ) => {
24+ stdoutStreamer . removeListener ( 'stdout' ) ;
25+ } ;
26+ } , [ ] ) ;
27+
1128 const t = useTranslation ( ) ;
29+
1230 return < Page _id = 'viewlogs' i18nLabel = 'ViewLogs' >
1331 < Page . Header title = { t ( 'View Logs' ) } > </ Page . Header >
14- < Box componentClassName = 'mongo-logs' width = 'full' height = 'full' >
15- { console . log ( test ) }
16- </ Box >
32+ < Box componentClassName = 'view-logs__terminal' width = 'full' height = 'full' dangerouslySetInnerHTML = { { __html : stdout . map ( ( { string } ) => ansispan ( string ) ) . join ( '\n' ) } } />
1733 </ Page > ;
1834}
Original file line number Diff line number Diff line change @@ -19,15 +19,8 @@ Meteor.startup(function() {
1919 } ) ;
2020} ) ;
2121
22+
2223registerAdminRoute ( '/view-logs' , {
2324 name : 'admin-view-logs' ,
24- async action ( ) {
25- await import ( './views/viewLogs' ) ;
26- return BlazeLayout . render ( 'main' , {
27- center : 'pageSettingsContainer' ,
28- pageTitle : t ( 'View_Logs' ) ,
29- pageTemplate : 'viewLogs' ,
30- noScroll : true ,
31- } ) ;
32- } ,
25+ lazyRouteComponent : ( ) => import ( './components/ViewLogs/ViewLogsRoute' ) ,
3326} ) ;
You can’t perform that action at this time.
0 commit comments