From dcb471901d39b252453a52bfe55e7be08e4e096e Mon Sep 17 00:00:00 2001 From: Alejandro De Maria Antolinos Date: Mon, 20 Jul 2020 14:46:41 +0200 Subject: [PATCH 1/4] WIP icat/E-DataPortal#324 --- src/api/icat/icatPlus.js | 4 + .../Investigation/InvestigationWidget.js | 4 + src/components/Investigation/SamplesTable.js | 77 +++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 src/components/Investigation/SamplesTable.js diff --git a/src/api/icat/icatPlus.js b/src/api/icat/icatPlus.js index 6e8fe462..2059b2cf 100644 --- a/src/api/icat/icatPlus.js +++ b/src/api/icat/icatPlus.js @@ -178,6 +178,10 @@ export function getDatasetStatus(sessionId, datasetIds) { return ICATPLUS.server + "/catalogue/sessionId/dataset/id/datasetIds/status".replace("sessionId", sessionId).replace("datasetIds", datasetIds); } +export function getSamplesByInvestigationId(sessionId, investigationId) { + return `${ICATPLUS.server}/catalogue/${sessionId}/investigation/id/${investigationId}/sample`; +} + export function getDataCollections(sessionId) { return ICATPLUS.server + "/catalogue/sessionId/datacollection".replace("sessionId", sessionId); } diff --git a/src/components/Investigation/InvestigationWidget.js b/src/components/Investigation/InvestigationWidget.js index 2e73c1ee..87e2d724 100644 --- a/src/components/Investigation/InvestigationWidget.js +++ b/src/components/Investigation/InvestigationWidget.js @@ -3,6 +3,7 @@ import { Tab, Tabs, Panel } from "react-bootstrap"; import { getInvestigationUsersByInvestigationId } from "../../api/icat/icatPlus.js"; import axios from "axios"; import ResponsiveTable from "../Table/ResponsiveTable.js"; +import SamplesTable from "./SamplesTable.js"; class InvestigationWidget extends React.Component { constructor(props) { @@ -59,6 +60,9 @@ class InvestigationWidget extends React.Component { + + + diff --git a/src/components/Investigation/SamplesTable.js b/src/components/Investigation/SamplesTable.js new file mode 100644 index 00000000..d1240d99 --- /dev/null +++ b/src/components/Investigation/SamplesTable.js @@ -0,0 +1,77 @@ +import React, { useState, useEffect, Suspense } from "react"; +import ResponsiveTable from "../Table/ResponsiveTable.js"; +import { getSamplesByInvestigationId } from "../../api/icat/icatPlus.js"; +import axios from "axios"; +import { useSelector } from "react-redux"; + +const COLUMNS = [ + { text: "", dataField: "_id", hidden: true }, + { + text: "Address", + formatter: (cell, address) => { + return "asdad"; + }, + sort: true, + responsiveHeaderStyle: { + xs: { width: "100%" }, + sm: { width: "100%" }, + md: { hidden: true }, + lg: { hidden: true }, + }, + }, + { + text: "Proposal", + dataField: "investigationName", + sort: true, + responsiveHeaderStyle: { + xs: { hidden: true }, + sm: { hidden: true }, + }, + }, + { + text: "", + dataField: "investigationId", + hidden: true, + responsiveHeaderStyle: { + xs: { hidden: true }, + sm: { hidden: true }, + }, + }, + { + text: "Name", + dataField: "name", + sort: true, + responsiveHeaderStyle: { + xs: { hidden: true }, + sm: { hidden: true }, + }, + }, +]; + +function SamplesTable(props) { + const { investigationId } = props; + + const [samples, setSamples] = useState([]); + + const sessionId = useSelector((state) => { + return state.user.sessionId; + }); + useEffect(() => { + axios + .get(getSamplesByInvestigationId(sessionId, investigationId)) + .then((res) => { + setSamples(res.data); + }) + .catch((error) => { + console.log(error); + }); + }, [investigationId, sessionId]); + + return ( + <> + + + ); +} + +export default SamplesTable; -- GitLab From 5059950d53e4e4354e267a3068a4826d29ef0378 Mon Sep 17 00:00:00 2001 From: Alejandro De Maria Antolinos Date: Tue, 21 Jul 2020 07:20:42 +0200 Subject: [PATCH 2/4] Working on 324 --- .env | 1 + .gitignore | 2 +- src/components/Investigation/SamplesTable.js | 49 +++++++++----------- src/components/Login/UserPasswordForm.js | 1 + src/config/icat/icat.example.js | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 00000000..ba7cc18d --- /dev/null +++ b/.env @@ -0,0 +1 @@ +GENERATE_SOURCEMAP=false diff --git a/.gitignore b/.gitignore index 8bdf9436..4717aa21 100644 --- a/.gitignore +++ b/.gitignore @@ -91,7 +91,7 @@ typings/ .yarn-integrity # dotenv environment variables file -.env +#.env # next.js build output .next diff --git a/src/components/Investigation/SamplesTable.js b/src/components/Investigation/SamplesTable.js index d1240d99..8dc1115b 100644 --- a/src/components/Investigation/SamplesTable.js +++ b/src/components/Investigation/SamplesTable.js @@ -1,27 +1,14 @@ -import React, { useState, useEffect, Suspense } from "react"; +import React, { useState, useEffect } from "react"; import ResponsiveTable from "../Table/ResponsiveTable.js"; import { getSamplesByInvestigationId } from "../../api/icat/icatPlus.js"; import axios from "axios"; import { useSelector } from "react-redux"; const COLUMNS = [ - { text: "", dataField: "_id", hidden: true }, + { text: "", dataField: "id", hidden: true }, { - text: "Address", - formatter: (cell, address) => { - return "asdad"; - }, - sort: true, - responsiveHeaderStyle: { - xs: { width: "100%" }, - sm: { width: "100%" }, - md: { hidden: true }, - lg: { hidden: true }, - }, - }, - { - text: "Proposal", - dataField: "investigationName", + text: "Name", + dataField: "name", sort: true, responsiveHeaderStyle: { xs: { hidden: true }, @@ -29,21 +16,31 @@ const COLUMNS = [ }, }, { - text: "", - dataField: "investigationId", - hidden: true, + text: "Description", + formatter: (cell, sample) => { + if (sample.parameters) { + let parameter = sample.parameters.find((parameter) => parameter.name === "Sample_description"); + if (parameter) return parameter.value; + } + }, + sort: true, responsiveHeaderStyle: { - xs: { hidden: true }, - sm: { hidden: true }, + md: { hidden: false }, + lg: { hidden: false }, }, }, { - text: "Name", - dataField: "name", + text: "Safety Mode", + formatter: (cell, sample) => { + if (sample.parameters) { + let parameter = sample.parameters.find((parameter) => parameter.name === "SafetyLevel"); + if (parameter) return parameter.value; + } + }, sort: true, responsiveHeaderStyle: { - xs: { hidden: true }, - sm: { hidden: true }, + md: { hidden: false }, + lg: { hidden: false }, }, }, ]; diff --git a/src/components/Login/UserPasswordForm.js b/src/components/Login/UserPasswordForm.js index 24a296ba..dd52578c 100644 --- a/src/components/Login/UserPasswordForm.js +++ b/src/components/Login/UserPasswordForm.js @@ -65,6 +65,7 @@ export default class UserPasswordForm extends React.Component {