blob: b60a66ce6b83793e194321c3710a85b6915a76aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import LoadingScreen from 'components/loading_screen.jsx';
import React from 'react';
import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
export default class Logs extends React.PureComponent {
static propTypes = {
/*
* Array of logs to render
*/
logs: PropTypes.arrayOf(PropTypes.string).isRequired,
actions: PropTypes.shape({
/*
* Function to fetch logs
*/
getLogs: PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
this.state = {
loadingLogs: true
};
}
componentDidMount() {
this.refs.logPanel.focus();
this.props.actions.getLogs().then(
() => this.setState({loadingLogs: false})
);
}
componentDidUpdate() {
// Scroll Down to get the latest logs
var node = this.refs.logPanel;
node.scrollTop = node.scrollHeight;
node.focus();
}
reload = () => {
this.setState({loadingLogs: true});
this.props.actions.getLogs().then(
() => this.setState({loadingLogs: false})
);
}
render() {
let content = null;
if (this.state.loadingLogs) {
content = <LoadingScreen/>;
} else {
content = [];
for (let i = 0; i < this.props.logs.length; i++) {
const style = {
whiteSpace: 'nowrap',
fontFamily: 'monospace'
};
if (this.props.logs[i].indexOf('[EROR]') > 0) {
style.color = 'red';
}
content.push(<br key={'br_' + i}/>);
content.push(
<span
key={'log_' + i}
style={style}
>
{this.props.logs[i]}
</span>
);
}
}
return (
<div className='panel'>
<h3 className='admin-console-header'>
<FormattedMessage
id='admin.logs.title'
defaultMessage='Server Logs'
/>
</h3>
<div className='banner'>
<div className='banner__content'>
<FormattedMessage
id='admin.logs.bannerDesc'
defaultMessage='To look up users by User ID, go to Reporting > Users and paste the ID into the search filter.'
/>
</div>
</div>
<button
type='submit'
className='btn btn-primary'
onClick={this.reload}
>
<FormattedMessage
id='admin.logs.reload'
defaultMessage='Reload'
/>
</button>
<div
tabIndex='-1'
ref='logPanel'
className='log__panel'
>
{content}
</div>
</div>
);
}
}
|