Commit 2882bd96 authored by Maxime Chaillet's avatar Maxime Chaillet

first version with a modal dialogue.

parent a6f4ae7c
......@@ -329,6 +329,24 @@ div.collapsedEventPanel-heading:hover {
right: 10px;
}
.autoRefreshOverlayClass {
background-color: transparent;
top: 0px;
height: 100px;
width: 200px;
left: unset;
padding-right: 0px;
}
.autoRefreshModalClass {
max-width: unset;
margin: unset;
width: 100%;
height: 100%;
padding: unset;
}
/* TinyMCE editor */
#editorContainer .mce-tinymce, #editorContainer .mce-tinymce .mce-container-body {
......
......@@ -19,6 +19,8 @@ import OverlayBox from '../../components/Event/OverlayBox.js';
import NewOrEditEventPanel from '../../components/Event/NewOrEditEventPanel.js';
import "../../components/Event/event.css"
import { INFO_MESSAGE_TYPE } from '../../constants/UserMessages.js';
import PeriodicRefresher from './PeriodicRefresher.js';
import PeriodicRefresherDialogue from './PeriodicRefresherDialogue.js';
/**
* This class represents the event container component. It's role is to retrieve events from the server asynchronuously.
......@@ -132,14 +134,18 @@ class LogbookContainer extends React.Component {
{(this.state.pageEvents.length === 0) ?
<UserMessage message='The logbook is empty.' type={INFO_MESSAGE_TYPE} isTextCentered={true} />
: <PeriodicHTTPRequester isEnabled={true}
intervalInMilliSeconds={3}
repeatedCallback={() => this.getEventsByInvestigationId(investigationId, user.sessionId, GUI_CONFIG().EVENTS_PER_DOWNLOAD, 0, selectionFilter, sortingFilter, this.onEventsReceptionFailure)}>
:
<div>
<PeriodicRefresher isEnabled={true}
initialValue={this.state.pageEvents.length}
intervalInMilliSeconds={2000}
periodicCallback={(onSuccess, onFailure) => this.getEventsByInvestigationIdCopy(investigationId, user.sessionId, GUI_CONFIG().EVENTS_PER_DOWNLOAD, 0, selectionFilter, GUI_CONFIG().DEFAULT_SORTING_FILTER, onFailure, onSuccess)}>
<PeriodicRefresherDialogue />
</PeriodicRefresher>
<EventList
events={this.state.pageEvents}
onEventClicked={this.onEventClicked}
/>
</PeriodicHTTPRequester>
onEventClicked={this.onEventClicked} />
</div>
}
<EventPager
......@@ -320,6 +326,32 @@ class LogbookContainer extends React.Component {
}
}
getEventsByInvestigationIdCopy = (investigationId, sessionId, limit, offset, selectionFilter, sortingFilter, onError, onSuccess) => {
if (investigationId && sessionId) {
axios({
method: 'post',
url: getEventsByInvestigationId(sessionId, investigationId),
data: {
find: selectionFilter.find,
sort: sortingFilter,
limit: limit,
skip: offset
}
})
.then(data => {
return onSuccess(data.data)
})
.catch((error) => {
console.log('[ERROR] An error occured while retrieving the event list.');
return onError(error);
});
} else {
onError('[ERROR] Missing query parameters in the request handled by getEventsByInvestigationId()');
}
//return onSuccess(5);
}
/**
* Request total number of events associated to the given investigationId
* @param {string} investigationId the investigation id
......
import React from 'react';
class PeriodicHTTPRequester extends React.Component {
class PeriodicRefresher extends React.Component {
constructor(props) {
super(props);
this.state = {
data: this.props.data
}
}
render() {
let timer = setTimeout(() => {
}, 100);
let timer = setTimeout(() => { return this.props.periodicCallback(this.onSuccess, this.onFailure) }, this.props.intervalInMilliSeconds);
return React.cloneElement(this.props.children, { data: this.state.data, initialValue: this.props.initialValue });
}
onSuccess = (data) => {
this.setState({ data: data })
}
onFailure = () => {
}
}
export default PeriodicHTTPRequester;
\ No newline at end of file
export default PeriodicRefresher;
\ No newline at end of file
import React from 'react';
import OverlayBox from '../../components/Event/OverlayBox';
class PeriodicRefresherDialogue extends React.Component {
render() {
return (<div>
<OverlayBox open={true} onClose={() => null} showCloseIcon={false} classNames={{ overlay: 'autoRefreshOverlayClass', modal: 'autoRefreshModalClass' }}>
There are {this.props.data ? this.props.data.length : this.props.initialValue} events in the list
</OverlayBox>
</div>)
}
}
export default PeriodicRefresherDialogue;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment