|
|
@@ -0,0 +1,47 @@ |
|
|
|
import { h, Component } from 'preact';
|
|
|
|
import makeArvadosRequest from 'make-arvados-request';
|
|
|
|
|
|
|
|
class WBLiveLogs extends Component {
|
|
|
|
componentDidMount() {
|
|
|
|
this.fetchData();
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
if (nextProps.uuid === this.props.uuid);
|
|
|
|
return;
|
|
|
|
this.props = nextProps;
|
|
|
|
this.fetchData();
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchData() {
|
|
|
|
const { uuid, app } = this.props;
|
|
|
|
const { arvHost, arvToken } = app.state;
|
|
|
|
const filters = [
|
|
|
|
[ 'object_uuid', '=', uuid ]
|
|
|
|
];
|
|
|
|
let prom = makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/logs?filters=' + encodeURIComponent(JSON.stringify(filters)));
|
|
|
|
prom = prom.then(xhr => {
|
|
|
|
const { items } = xhr.response;
|
|
|
|
this.setState({
|
|
|
|
content: items.filter(a => ('text' in a.properties)).map(a => a.properties.text.trim()).join('\n')
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render({}, { content }) {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<a href="#" onclick={ e => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.fetchData();
|
|
|
|
} }>Refresh</a>
|
|
|
|
<pre class="word-warp terminal">
|
|
|
|
{ content }
|
|
|
|
</pre>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default WBLiveLogs;
|