Skip to content

Commit 28656d9

Browse files
committed
help
1 parent f4a93a1 commit 28656d9

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
}
Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1-
import React from 'react';
1+
import { Meteor } from 'meteor/meteor';
2+
import React, { useEffect, useState } from 'react';
23
import { Box } from '@rocket.chat/fuselage';
34

4-
import { APIClient } from '../../../../utils/client/index';
55
import { useTranslation } from '../../../../../client/contexts/TranslationContext';
66
import { Page } from '../../../../../client/components/basic/Page';
7+
import { ansispan } from '../../ansispan';
8+
import { APIClient } from '../../../../utils/client';
79

810
export 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
}

app/logger/client/viewLogs.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,8 @@ Meteor.startup(function() {
1919
});
2020
});
2121

22+
2223
registerAdminRoute('/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
});

0 commit comments

Comments
 (0)