Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to view admin_audit log files #476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
['name' => 'log#get', 'url' => '/get', 'verb' => 'GET'],
['name' => 'log#poll', 'url' => '/poll', 'verb' => 'GET'],
['name' => 'log#search', 'url' => '/search', 'verb' => 'GET'],
['name' => 'log#download', 'url' => '/download', 'verb' => 'GET'],
['name' => 'log#getSettings', 'url' => '/settings', 'verb' => 'GET'],
['name' => 'log#getLevels', 'url' => '/levels', 'verb' => 'GET'],
['name' => 'log#setLevels', 'url' => '/levels', 'verb' => 'PUT'],
['name' => 'log#setRelative', 'url' => '/relative', 'verb' => 'PUT'],
['name' => 'log#setLive', 'url' => '/live', 'verb' => 'PUT'],
['name' => 'log#setLogFile', 'url' => '/logFile', 'verb' => 'PUT']
]];
16 changes: 11 additions & 5 deletions build/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/main.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/main.js.map

Large diffs are not rendered by default.

26 changes: 21 additions & 5 deletions js/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export class App extends Component {
provider: null,
relative: true,
dateFormat: 'Y-m-d\TH:i:sO',
live: false
live: false,
availableLogFiles: []
};

constructor (props) {
Expand All @@ -43,11 +44,15 @@ export class App extends Component {
const relative = await this.logProvider.getRelative();
const dateFormat = await this.logProvider.getDateFormat();
const live = await this.logProvider.getLive();
const availableLogFiles = await this.logProvider.getAvailableLogFiles();
const logFile = await this.logProvider.getLogFile();
this.setState({
levels,
relative,
dateFormat,
live,
availableLogFiles,
logFile,
provider: this.logProvider
});
await this.logProvider.load();
Expand Down Expand Up @@ -76,7 +81,7 @@ export class App extends Component {
this.logProvider.load();
}

onLogFile = async (content) => {
onCustomLogFile = async (content) => {
const logFile = new LogFile(content);
logFile.on('entries', entries => {
if (this.state.provider === logFile) {
Expand Down Expand Up @@ -107,14 +112,22 @@ export class App extends Component {
this.saveLive(live);
};

async setLogFile (logFile) {
this.setState({logFile, loading: true});
await this.logProvider.setLogFile(logFile);
this.logProvider.reset();
this.logProvider.load();
this.setState({loading: false});
}

handlePaste = (event) => {
let data = event.clipboardData.getData('Text');
if (!data) {
data = event.clipboardData.getData('text/plain');
}
data = data.trim();
if (data.indexOf('{') !== -1 && data.indexOf('}')) {
this.onLogFile(data);
this.onCustomLogFile(data);
}
};

Expand Down Expand Up @@ -151,6 +164,7 @@ export class App extends Component {
isLoading={this.state.loading}>
<div className={styles.content}>
<LogTable
availableLogFiles={this.state.availableLogFiles}
inlineSettings={this.props.inlineSettings}
levels={this.state.levels}
setRelative={this.setRelative}
Expand All @@ -161,7 +175,9 @@ export class App extends Component {
hidden={this.state.entries.length - entries.length}
live={this.state.live}
setLive={this.setLive.bind(this)}
onLogFile={this.onLogFile}
logFile={this.state.logFile}
setLogFile={this.setLogFile.bind(this)}
onCustomLogFile={this.onCustomLogFile}
/>
</div>
</ReactScrolla>
Expand All @@ -172,7 +188,7 @@ export class App extends Component {
<div>
{!this.props.inlineSettings ?
<SideBar><LogUploader
onLogFile={this.onLogFile}/>
onCustomLogFile={this.onCustomLogFile}/>
<Separator/>
{filters}
<Settings>
Expand Down
6 changes: 5 additions & 1 deletion js/Components/LogTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,15 @@ export class LogTable extends Component {
{
this.state.showLevelSettings ?
<Settings
availableLogFiles={this.props.availableLogFiles}
setLevel={this.props.setLevel}
levels={this.props.levels}
live={this.props.live}
setLive={this.props.setLive}
onLogFile={this.props.onLogFile}
live={this.props.live}
setLogFile={this.props.setLogFile}
logFile={this.props.logFile}
onCustomLogFile={this.props.onCustomLogFile}
/> :
<div className="hidden"/>
}
Expand Down
2 changes: 1 addition & 1 deletion js/Components/LogUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class LogUploader extends Component {
this.setState({message: 'Invalid log file'});
return;
}
this.props.onLogFile(content);
this.props.onCustomLogFile(content);
};
reader.readAsText(file);
};
Expand Down
Loading