Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ICAT
Datahub
Commits
16dad433
Commit
16dad433
authored
May 28, 2021
by
Alejandro De Maria Antolinos
Browse files
PDF exporter works again
parent
86487995
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/api/icat-plus/logbook.js
View file @
16dad433
import
ICATPLUS
from
'
../../config/icatPlus
'
;
/**
* Get URL needed to retrieve events for a given investigation
* @param {String} sessionId the session identifier
* @param {String} investigationId the session identifier
* @return {String} the URL to get the requested events. Null if investigationId or sessionId is missing.
*/
export
function
getEventsByInvestigationId
(
sessionId
,
investigationId
)
{
return
`
${
ICATPLUS
.
server
}
/logbook/
${
sessionId
}
/investigation/id/
${
investigationId
}
/event/query`
;
}
/**
* Get URL needed to retrieve the event count for a given investigation
* @param {string} sessionId the session identifier
* @param {String} investigationId the investigation identifier
* @return {String} the URL to get the requested event count
*/
export
function
getEventCountByInvestigationId
(
sessionId
,
investigationId
)
{
return
`
${
ICATPLUS
.
server
}
/logbook/
${
sessionId
}
/investigation/id/
${
investigationId
}
/event/count`
;
}
/**
* Get URL used to create a new event for a given investigation on ICAT+
* @param {*} investigationId investigation indentifier
* @param {String} sessionId session identifier
* @return {String} URL to get the requested events
*/
export
function
createEvent
(
sessionId
,
investigationId
)
{
return
`
${
ICATPLUS
.
server
}
/logbook/
${
sessionId
}
/investigation/id/
${
investigationId
}
/event/create`
;
}
/**
* Get URL used to update an event on a given investigation on ICAT+
* @param {String} sessionId the session identifier
* @param {String} investigationId the investigation indentifier
* @return {String} the URL to get the requested events
*/
export
function
updateEvent
(
sessionId
,
investigationId
)
{
return
`
${
ICATPLUS
.
server
}
/logbook/
${
sessionId
}
/investigation/id/
${
investigationId
}
/event/update`
;
}
/**
* Get URL used to download a PDF file for a given investigation from the logbook
* @param {string} sessionId session identifier
* @param {*} investigationId investigation identifier
* @param {object} selectionFilter selection filter used to retrieve part of the logbook. This is URI encoded and passed as query string
*/
export
function
getPDF
(
sessionId
,
investigationId
,
selectionFilter
)
{
return
`
${
ICATPLUS
.
server
}
/logbook/
${
sessionId
}
/investigation/id/
${
investigationId
}
/event/pdf?find=&sort=&skip=&limit=`
.
replace
(
'
find=
'
,
()
=>
{
return
`find=
${
selectionFilter
&&
selectionFilter
.
find
?
JSON
.
stringify
(
selectionFilter
.
find
)
:
''
}
`
;
})
.
replace
(
'
&sort=
'
,
()
=>
{
return
`&sort=
${
selectionFilter
&&
selectionFilter
.
sort
?
JSON
.
stringify
(
selectionFilter
.
sort
)
:
''
}
`
;
})
.
replace
(
'
&skip=
'
,
()
=>
{
return
`&skip=
${
selectionFilter
&&
selectionFilter
.
skip
!==
undefined
?
JSON
.
stringify
(
selectionFilter
.
skip
)
:
''
}
`
;
})
.
replace
(
'
&limit=
'
,
()
=>
{
return
`&limit=
${
selectionFilter
&&
selectionFilter
.
limit
!==
undefined
?
JSON
.
stringify
(
selectionFilter
.
limit
)
:
''
}
`
;
});
export
function
getEventURL
(
sessionId
,
investigationId
,
skip
,
limit
,
sortOrder
,
sortBy
,
types
,
format
)
{
const
params
=
new
URLSearchParams
();
params
.
set
(
'
investigationId
'
,
investigationId
);
if
(
limit
)
params
.
set
(
'
limit
'
,
limit
);
if
(
sortBy
)
params
.
set
(
'
sortBy
'
,
sortBy
);
if
(
sortOrder
)
params
.
set
(
'
sortOrder
'
,
sortOrder
);
if
(
types
)
params
.
set
(
'
types
'
,
types
);
if
(
skip
)
params
.
set
(
'
skip
'
,
skip
);
if
(
format
)
params
.
set
(
'
format
'
,
format
);
return
`
${
ICATPLUS
.
server
}
/logbook/
${
sessionId
}
/event?
${
params
.
toString
()}
`
;
}
/** Get the tags associated to a given investigation
...
...
src/components/Logbook/Menu/EventListMenu.js
View file @
16dad433
...
...
@@ -4,7 +4,7 @@ import { useQuery } from '../../../helpers/hooks';
import
React
,
{
useState
}
from
'
react
'
;
import
{
Nav
,
Navbar
,
NavItem
,
Well
}
from
'
react-bootstrap
'
;
import
{
ComboSearch
}
from
'
react-combo-search
'
;
import
{
get
PDF
}
from
'
../../../api/icat-plus/logbook
'
;
import
{
get
EventURL
}
from
'
../../../api/icat-plus/logbook
'
;
import
{
NEW_EVENT_VISIBLE
}
from
'
../../../constants/eventTypes
'
;
import
LogbookPager
from
'
../LogbookPager
'
;
import
EventListMenuButton
from
'
./EventListMenuButton
'
;
...
...
@@ -25,7 +25,6 @@ function EventListMenu(props) {
eventCountBySelectionFilter
,
investigationId
,
isNewButtonEnabled
,
selectionFilter
,
sessionId
,
getEvents
,
periodicdata
,
...
...
@@ -33,6 +32,11 @@ function EventListMenu(props) {
eventCountSinceLastRefresh
,
activePage
,
categoryTypes
,
skip
,
limit
,
sortOrder
,
sortBy
,
types
,
automaticCollapsing
,
automaticRefresh
,
isSortingLatestEventsFirst
,
...
...
@@ -136,7 +140,16 @@ function EventListMenu(props) {
href
=
{
!
isNewButtonEnabled
||
eventCountBySelectionFilter
===
0
?
null
:
getPDF
(
sessionId
,
investigationId
,
selectionFilter
)
:
getEventURL
(
sessionId
,
investigationId
,
skip
,
limit
,
sortOrder
,
sortBy
,
types
,
'
pdf
'
)
}
target
=
"
_blank
"
className
=
"
logbookNavItem
"
...
...
src/containers/EventsPage.js
View file @
16dad433
...
...
@@ -35,7 +35,6 @@ function EventsPage() {
const
page
=
query
.
get
(
'
page
'
)
||
1
;
const
{
categoryTypes
}
=
useSelector
((
state
)
=>
state
.
logbook
);
const
investigation
=
useResource
(
InvestigationResource
.
detailShape
(),
{
id
:
investigationId
,
});
...
...
@@ -104,6 +103,7 @@ function EventsPage() {
<
Col
sm
=
{
12
}
>
<
TabContainerMenu
/>
<
EventListMenu
types
=
{
fetchingParams
.
types
}
categoryTypes
=
{
categoryTypes
}
activePage
=
{
page
}
eventCountBySelectionFilter
=
{
totalEventCount
}
...
...
@@ -112,6 +112,10 @@ function EventsPage() {
isNewButtonEnabled
=
{
!
isReleased
}
isReleased
=
{
isReleased
}
sessionId
=
{
sessionId
}
skip
=
{
fetchingParams
.
skip
}
limit
=
{
fetchingParams
.
limit
}
sortOrder
=
{
fetchingParams
.
sortOrder
}
sortBy
=
{
fetchingParams
.
sortBy
}
/
>
<
EventList
events
=
{
events
}
isReleased
=
{
isReleased
}
/
>
...
...
src/resources/events.js
View file @
16dad433
import
{
Resource
}
from
'
rest-hooks
'
;
import
ICATPLUS
from
'
../config/icatPlus
'
;
import
{
store
}
from
'
../store
'
;
import
{
getEventURL
}
from
'
../api/icat-plus/logbook
'
;
export
default
class
EventResource
extends
Resource
{
_id
=
undefined
;
...
...
@@ -14,21 +15,18 @@ export default class EventResource extends Resource {
}
static
listUrl
(
params
)
{
const
{
investigationId
,
skip
,
limit
,
sortOrder
,
sortBy
,
types
}
=
params
;
const
{
sessionId
}
=
store
.
getState
().
user
;
if
(
investigationId
)
{
const
params
=
new
URLSearchParams
();
params
.
set
(
'
investigationId
'
,
investigationId
);
if
(
limit
)
params
.
set
(
'
limit
'
,
limit
);
if
(
sortBy
)
params
.
set
(
'
sortBy
'
,
sortBy
);
if
(
sortOrder
)
params
.
set
(
'
sortOrder
'
,
sortOrder
);
if
(
types
)
params
.
set
(
'
types
'
,
types
);
if
(
skip
)
params
.
set
(
'
skip
'
,
skip
);
const
{
investigationId
,
skip
,
limit
,
sortOrder
,
sortBy
,
types
}
=
params
;
return
`
${
ICATPLUS
.
server
}
/logbook/
${
sessionId
}
/event?
${
params
.
toString
()}
`
;
}
return
getEventURL
(
sessionId
,
investigationId
,
skip
,
limit
,
sortOrder
,
sortBy
,
types
);
}
static
url
(
params
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment