Commit 868122d9 authored by Axel Bocciarelli's avatar Axel Bocciarelli

Merge branch 'api' into 'master'

Organise API endpoint utilities

See merge request !437
parents b0d0d89b c691e296
Pipeline #32559 passed with stages
in 7 minutes and 26 seconds
......@@ -41,6 +41,7 @@ Datahub configuration is spread among different files located in <kbd>src/config
- `icat.js` - configure access to metadata catalogue
- `icatPlus.js` - configure access to ICAT+ server
- `ids.js` - configure IDs server for downloading datasets
- [`techniques.js`](#techniquesjs) - configure known techniques
- [`ui.js`](#uijs) - general UI configuration
......
import axios from 'axios';
import { getDataCollections } from '../api/icat/icatPlus';
import { getDataCollections } from '../api/icat-plus/catalogue';
import { FETCH_DATACOLLECTIONS } from '../constants/actionTypes';
export function fetchDataCollections(sessionId) {
......
import axios from 'axios';
import {
getDatasetByDOI,
getDatasetsByInvestigationId,
} from '../api/icat/icatPlus';
import { getDatasetsByInvestigationId } from '../api/icat-plus/catalogue';
import {
FETCH_DATASETS_BY_DOI,
FETCH_DATASETS_BY_INVESTIGATION,
} from '../constants/actionTypes';
import { getDatasetByDOI } from '../api/icat-plus/doi';
export function fetchDatasetsByDOI(sessionId, doi) {
return function (dispatch) {
......
import axios from 'axios';
import { getInstrumentScientistsBySessionId } from '../api/icat/icatPlus';
import { getInstrumentScientistsBySessionId } from '../api/icat-plus/catalogue';
import { FETCH_INSTRUMENTSCIENTISTS } from '../constants/actionTypes';
export function fetchInstrumentScientistsBySessionId(sessionId) {
......
......@@ -4,7 +4,7 @@ import {
getInvestigationsByInstrumentScientist,
getInvestigationsByUser,
getReleasedInvestigations,
} from '../api/icat/icatPlus';
} from '../api/icat-plus/catalogue';
import {
FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS,
FETCH_INVESTIGATIONS,
......
import ICATPLUS from '../../config/icatPlus';
export function getFilesByDatasetId(sessionId, datasetIds) {
return `${ICATPLUS.server}/catalogue/${sessionId}/dataset/id/${datasetIds}/datafile`;
}
export function getUsers(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/user`;
}
export function getUsersByInvestigationIds(sessionId, investigationIds) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/id/${investigationIds}/investigationusers`;
}
export function getInvestigationById(sessionId, investigationId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/id/${investigationId}/investigation`;
}
export function getEmbargoedInvestigations(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/status/embargoed/investigation`;
}
export function getReleasedInvestigations(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/status/released/investigation`;
}
export function getInvestigationsByUser(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation?useris=participant`;
}
export function getInvestigationsByInstrumentScientist(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/useris/instrumentscientist/investigation`;
}
export function getDatasetsById(sessionId, datasetIds) {
return `${ICATPLUS.server}/catalogue/${sessionId}/dataset/id/${datasetIds}/dataset`;
}
export function getDatasetsByInvestigationId(sessionId, investigationId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/id/${investigationId}/dataset`;
}
export function getDatasetStatus(sessionId, datasetIds) {
return `${ICATPLUS.server}/catalogue/${sessionId}/dataset/id/${datasetIds}/status`;
}
export function getDataCollections(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/datacollection`;
}
export function getInvestigationUsersByInvestigationId(
sessionId,
investigationId
) {
return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/id/${investigationId}/investigationusers`;
}
export function getInstrumentScientistsBySessionId(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/instrumentscientist`;
}
export function createInstrumentScientists(sessionId) {
return `${ICATPLUS.server}/catalogue/${sessionId}/instrumentscientist`;
}
import ICATPLUS from '../../config/icatPlus';
/**
* Get the URL used to mint a DOI
* @param {*} sessionId session identifier
* @return {string} URL used to mint a DOI
*/
export function getMintDOI(sessionId) {
return `${ICATPLUS.server}/doi/${sessionId}/mint`;
}
export function getDatasetByDOI(sessionId, doi) {
return `${ICATPLUS.server}/doi/${doi}/datasets?sessionId=${sessionId}`;
}
import ICATPLUS from '../../config/icatPlus';
export function getDataStatistics(sessionId) {
return `${ICATPLUS.server}/elasticsearch/${sessionId}/stats/data/metrics`;
}
export function getInstrumentStatistics(sessionId) {
return `${ICATPLUS.server}/elasticsearch/${sessionId}/stats/instrument/metrics`;
}
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)
: ''
}`;
});
}
/** Get the tags associated to a given investigation
* @param {string} sessionId session identifier
* @param {*} investigationId investigation identifier
*/
export function getTagsByInvestigationId(sessionId, investigationId) {
return `${ICATPLUS.server}/logbook/${sessionId}/investigation/id/${investigationId}/tag`;
}
/** Create a given tag associated to a given investigation */
export function createTagsByInvestigationId(sessionId) {
return `${ICATPLUS.server}/logbook/${sessionId}/tag/create`;
}
/** Update a given tag associated to a given investigation */
export function updateTagsByInvestigationId(sessionId, investigationId, tagId) {
return `${ICATPLUS.server}/logbook/${sessionId}/investigation/id/${investigationId}/tag/id/${tagId}/tag/update`;
}
export function createEventFromBase64(sessionId, investigationId) {
return `${ICATPLUS.server}/logbook/${sessionId}/investigation/id/${investigationId}/event/createfrombase64`;
}
import ICATPLUS from '../../config/icatPlus';
/**
* Get URL used to upload data such as a file to ICAT+.
* @param {*} investigationId the investigationId
*/
export function uploadFile(sessionId, investigationId) {
return `${ICATPLUS.server}/resource/${sessionId}/file/investigation/id/${investigationId}/upload`;
}
/**
* Get URL used to retrieve the file of an event which category is 'file'
* @param {string} sessionId session identifier
* @param {*} investigationId investigation identifier
* @param {string} eventId event identifier where the file is stored
* @return {String} URL to get the file
*/
export function getFileByEventId(sessionId, investigationId, eventId) {
return `${ICATPLUS.server}/resource/${sessionId}/file/id/${eventId}/investigation/id/${investigationId}/download`;
}
This diff is collapsed.
import IDS from '../config/ids';
export function getDownloadURLByDatasetId(sessionId, datasetIds) {
return `${IDS.server}/ids/getData?sessionId=${sessionId}&datasetIds=${datasetIds}`;
}
export function getDownloadURLByDatafileId(sessionId, datafileIds) {
return `${IDS.server}/ids/getData?sessionId=${sessionId}&datafileIds=${datafileIds}`;
}
import axios, { CancelToken } from 'axios';
import React from 'react';
import { Button, Glyphicon } from 'react-bootstrap';
import {
getDatasetStatus,
getDownloadURLByDatasetId,
} from '../../api/icat/icatPlus';
import { getDatasetStatus } from '../../api/icat-plus/catalogue';
import { getDownloadURLByDatasetId } from '../../api/ids';
export default class DatasetDownloadButton extends React.Component {
constructor(props) {
......
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import ImageZoom from 'react-medium-image-zoom';
import { getFileByEventId } from '../../api/icat/icatPlus';
import { getFileByEventId } from '../../api/icat-plus/resource';
export default class GalleryDatasetThumbnail extends Component {
render() {
......
import React from 'react';
import { Col, Grid, Image, Row } from 'react-bootstrap';
import { getFileByEventId } from '../../api/icat/icatPlus';
import { getFileByEventId } from '../../api/icat-plus/resource';
class PublicationSummary extends React.Component {
getImageFromGalleyByIndex(index) {
......
import axios from 'axios';
import React from 'react';
import { Glyphicon } from 'react-bootstrap';
import {
getDownloadURLByDatafileId,
getFilesByDatasetId,
} from '../../api/icat/icatPlus';
import { getFilesByDatasetId } from '../../api/icat-plus/catalogue';
import { stringifyBytesSize } from '../../helpers';
import ResponsiveTable from '../Table/ResponsiveTable';
import { getDownloadURLByDatafileId } from '../../api/ids';
class DatasetFileTree extends React.Component {
constructor(props) {
......
import React, { useEffect, useState } from 'react';
import { Alert } from 'react-bootstrap';
import { getInvestigationUsersByInvestigationId } from '../../api/icat/icatPlus';
import { getInvestigationUsersByInvestigationId } from '../../api/icat-plus/catalogue';
import { groupBy } from 'lodash-es';
import axios from 'axios';
import ResponsiveTable from '../Table/ResponsiveTable';
......
......@@ -17,7 +17,7 @@ import {
LOCALSTORAGE_KEY_EDITED_EVENT_CONTENT_IN_HTML_FORMAT,
} from '../../../constants/eventTypes';
import UI from '../../../config/ui';
import { getFileByEventId, uploadFile } from '../../../api/icat/icatPlus';
import { getFileByEventId, uploadFile } from '../../../api/icat-plus/resource';
const EDITOR_ID_FOR_CREATION = 'myEditorForCreation';
const EDITOR_ID_FOR_EDITION = 'myEditorForEdition';
......
......@@ -10,7 +10,7 @@ import {
Well,
} from 'react-bootstrap';
import { ComboSearch } from 'react-combo-search';
import { getPDF } from '../../../api/icat/icatPlus';
import { getPDF } from '../../../api/icat-plus/logbook';
import {
DOC_VIEW,
LIST_VIEW,
......
import axios from 'axios';
import moment from 'moment';
import React from 'react';
import { getDataStatistics } from '../../../api/icat/icatPlus';
import { getDataStatistics } from '../../../api/icat-plus/elasticsearch';
import Loader from '../../Loader';
import ErrorUserMessage from '../../UserMessages/ErrorUserMessage';
import FileCountPanel from './FileCountPanel';
......
......@@ -2,7 +2,7 @@ import axios from 'axios';
import React, { Suspense, lazy } from 'react';
import { Col, Grid, Row } from 'react-bootstrap';
import createPlotlyComponent from 'react-plotly.js/factory';
import { getInstrumentStatistics } from '../../../api/icat/icatPlus';
import { getInstrumentStatistics } from '../../../api/icat-plus/elasticsearch';
import ParameterTableWidget from '../../Instrument/ParameterTableWidget';
import Loader from '../../Loader';
import ErrorUserMessage from '../../UserMessages/ErrorUserMessage';
......
......@@ -2,7 +2,10 @@ import axios from 'axios';
import React, { Component } from 'react';
import { Button, Col, Glyphicon, Grid, InputGroup, Row } from 'react-bootstrap';
import { Typeahead } from 'react-bootstrap-typeahead';
import { createInstrumentScientists, getUsers } from '../../api/icat/icatPlus';
import {
createInstrumentScientists,
getUsers,
} from '../../api/icat-plus/catalogue';
import {
ErrorUserMessage,
SuccessUserMessage,
......
import axios from 'axios';
import React from 'react';
import { Button } from 'react-bootstrap';
import { createInstrumentScientists } from '../../api/icat/icatPlus';
import { createInstrumentScientists } from '../../api/icat-plus/catalogue';
import Loader from '../Loader';
import ResponsiveTable from '../Table/ResponsiveTable';
......
......@@ -12,7 +12,7 @@ import {
Panel,
SplitButton,
} from 'react-bootstrap';
import { getMintDOI } from '../../api/icat/icatPlus';
import { getMintDOI } from '../../api/icat-plus/doi';
import BootstrapTable2 from 'react-bootstrap-table-next';
class DOIForm extends React.Component {
......
const IDS = {
//server: "https://ovm-icat-test.esrf.fr:8181",
server: 'https://ids.esrf.fr',
connection: {
plugins: ['esrf'],
},
};
export default IDS;
......@@ -3,7 +3,7 @@ import React, { Component } from 'react';
import Camera, { FACING_MODES } from 'react-html5-camera-photo';
import { connect } from 'react-redux';
import { setBreadCrumbs } from '../actions/breadcrumbs';
import { createEventFromBase64 } from '../api/icat/icatPlus';
import { createEventFromBase64 } from '../api/icat-plus/logbook';
class CameraPage extends Component {
/* TODO: This should be refactored */
......
......@@ -8,7 +8,7 @@ import {
getEventCountByInvestigationId,
getEventsByInvestigationId,
updateEvent as updateEventURL,
} from '../../api/icat/icatPlus';
} from '../../api/icat-plus/logbook';
import Loader from '../../components/Loader';
import EventList from '../../components/Logbook/List/EventList';
import EventListMenu from '../../components/Logbook/Menu/EventListMenu';
......
......@@ -8,7 +8,7 @@ import {
createTagsByInvestigationId,
getTagsByInvestigationId,
updateTagsByInvestigationId,
} from '../../../api/icat/icatPlus';
} from '../../../api/icat-plus/logbook';
import Loader from '../../../components/Loader';
import NewOrEditTagPanel from '../../../components/Logbook/Tag/NewOrEditTagPanel';
import TagListMenu from '../../../components/Logbook/Tag/TagListMenu';
......
......@@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import {
createTagsByInvestigationId,
getTagsByInvestigationId,
} from '../../../api/icat/icatPlus';
} from '../../../api/icat-plus/logbook';
import TagSelector from '../../../components/Logbook/Tag/TagSelector';
class TagsSelectorContainer extends Component {
......
......@@ -11,7 +11,7 @@ import React, { Component } from 'react';
import { Col, Grid, Label, Row } from 'react-bootstrap';
import { connect } from 'react-redux';
import { setBreadCrumbs } from '../actions/breadcrumbs';
import { getFileByEventId } from '../api/icat/icatPlus';
import { getFileByEventId } from '../api/icat-plus/resource';
import ICATPLUS from '../config/icatPlus';
import TECHNIQUES from '../config/techniques';
import { stringifyBytesSize } from '../helpers';
......
......@@ -11,7 +11,7 @@ import { addDatasetById, removeDatasetById } from '../../actions/selection';
import {
getDatasetsById,
getUsersByInvestigationIds,
} from '../../api/icat/icatPlus';
} from '../../api/icat-plus/catalogue';
import DOIForm from '../../components/doi/DOIForm';
import Loader from '../../components/Loader';
import { PERSPECTIVE } from '../../constants';
......
......@@ -13,7 +13,7 @@ import { bindActionCreators } from 'redux';
import { setBreadCrumbs } from '../../actions/breadcrumbs';
import { doSignIn, doLogOut } from '../../actions/login';
import { addDatasetById, removeDatasetById } from '../../actions/selection';
import { getDatasetsById } from '../../api/icat/icatPlus';
import { getDatasetsById } from '../../api/icat-plus/catalogue';
import DatasetTable from '../../components/Dataset/DatasetTable';
import Loader from '../../components/Loader';
import { PERSPECTIVE } from '../../constants';
......
......@@ -3,14 +3,13 @@ import {
createTagsByInvestigationId,
getEventCountByInvestigationId,
getEventsByInvestigationId,
getFileByEventId,
getPDF,
getTagsByInvestigationId,
updateEvent,
updateTagsByInvestigationId,
uploadFile,
} from '../../api/icat/icatPlus';
} from '../../api/icat-plus/logbook';
import ICATPLUS from '../../config/icatPlus';
import { getFileByEventId, uploadFile } from '../../api/icat-plus/resource';
describe('Tests URL generation used to hit ICAT+', () => {
describe('Events', () => {
......
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