Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed the broken production version due to a missing package (#123).
- Corrected the counting of the total number of items in the result list (#120).
- Avoided extending query objects in the configuration (#126).

## [1.2.0] - 2024-05-07

Expand Down
4 changes: 1 addition & 3 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ function App() {
authProvider={authenticationProvider}
loginPage={SolidLoginForm}
requireAuth={false}
dashboard={() => {
return Dashboard({ title: config.title, text: config.introductionText })
}}
dashboard={Dashboard}
>
{config.queries.map((query) => {
return (
Expand Down
9 changes: 4 additions & 5 deletions src/components/ActionBar/ActionBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import SourceFetchStatusIcon from "./SourceFetchStatusIcon/SourceFetchStatusIcon
import SourceVerificationIcon from "./SourceVerificationIcon/SourceVerificationIcon.jsx";

import configManager from "../../configManager/configManager.js";
const config = configManager.getConfig();

/**
*
Expand All @@ -31,10 +30,6 @@ function ActionBar() {
const [time, setTime] = useState(0);
const [sourceInfoOpen, setSourceInfoOpen] = useState(false);

const context = config.queries.filter((query) => query.id === resource)[0]
.comunicaContext;

const sources = context.sources;
useEffect(() => {
if (isLoading) {
setTime(0);
Expand All @@ -49,6 +44,10 @@ function ActionBar() {
return () => clearInterval(intervalId);
}, [time, isLoading]);

const config = configManager.getConfig();
const query = configManager.getQueryWorkingCopyById(resource);
const context = query.comunicaContext;
const sources = context.sources;
const resultCount = total <= perPage ? total : perPage;

return (
Expand Down
20 changes: 7 additions & 13 deletions src/components/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import {Title} from 'react-admin';
import PropTypes from 'prop-types';
import './Dashboard.css';

import configManager from '../../configManager/configManager';

/**
* This function returns a function that creates a dashboard with an introduction for <Admin>.
* @param {object} props - This has the properties `title` (text for the app bar) and `text` (the introduction text).
* @returns {function(): *} - A function that creates a dashboard with an introduction for <Admin>.
*/
function Dashboard(props) {
let {title, text} = props;

title = title || 'You change this title via the config file.';
text = text || 'You change this text via the config file.';
function Dashboard() {
const config = configManager.getConfig();
const title = config.title || 'You change this title via the config file.';
const introductionText = config.introductionText || 'You change this introduction text via the config file.';

return (
<Card>
<Title title={title}/>
<CardContent>{text}</CardContent>
<CardContent>{introductionText}</CardContent>
</Card>
);
}

Dashboard.propTypes = {
title: PropTypes.string,
text: PropTypes.string
};

export default Dashboard;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { IconButton } from '@mui/material';
import { Tooltip } from '@mui/material';

import configManager from "../../../configManager/configManager";
const config = configManager.getConfig();

function InvalidateButton() {
const refresh = useRefresh();
Expand All @@ -31,6 +30,7 @@ function InvalidateButton() {
* @returns {Component} custom AppBar as defined by react-admin
*/
function NavigationBar(props) {
const config = configManager.getConfig();
return (
<AppBar {...props} userMenu={<AuthenticationMenu />}>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import IconProvider from "../../../IconProvider/IconProvider";
import ListAltIcon from '@mui/icons-material/ListAlt';

import configManager from '../../../configManager/configManager';
const config = configManager.getConfig();

/**
* A custom menu as defined in React Admin for selecting the query the user whishes to execute.
* @returns {Component} the selection menu component
*/
function SelectionMenu() {

const resources = useResourceDefinitions();
const config = configManager.getConfig();
const queryGroups = config.queryGroups || [];
const resources = useResourceDefinitions();

// adding a list to the group that will contain all the queries for said group
queryGroups.forEach(group => group.queries = [])
Expand Down
12 changes: 7 additions & 5 deletions src/components/ListResultTable/ListResultTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import PropTypes from "prop-types";
import {Component} from "react";
import QueryResultList from "./QueryResultList/QueryResultList";

import configManager from "../../configManager/configManager";

/**
* @param {object} props - the props passed down to the component
* @returns {Component} custom List as defined by react-admin which either shows a loading indicator or the query results
Expand All @@ -18,8 +20,6 @@ function ListResultTable(props) {
resource,
sort,
variables,
changeVariables,
submitted,
...rest
} = props;

Expand All @@ -31,6 +31,8 @@ function ListResultTable(props) {
}
});

const query = configManager.getQueryWorkingCopyById(resource);

return (
<ListBase
debounce={debounce}
Expand All @@ -45,7 +47,7 @@ function ListResultTable(props) {
sort={sort}
>
{isLoading && <Loading loadingSecondary={"The page is loading. Just a moment please."} />}
{!isLoading && <QueryResultList {...rest} changeVariables={changeVariables} submitted={submitted} />}
{!isLoading && <QueryResultList resource={resource} { ...rest } />}
</ListBase>
);
}
Expand All @@ -59,9 +61,9 @@ ListResultTable.propTypes = {
filterDefaultValues: PropTypes.object,
perPage: PropTypes.number,
queryOptions: PropTypes.object,
resource: PropTypes.string,
resource: PropTypes.string.isRequired,
sort: PropTypes.object,
variables: PropTypes.object,
variables: PropTypes.object.isRequired
};

export default ListResultTable;
25 changes: 17 additions & 8 deletions src/components/ListResultTable/QueryResultList/QueryResultList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import TableHeader from "./TableHeader/TableHeader";
import Button from '@mui/material/Button';
import SearchOffIcon from '@mui/icons-material/SearchOff';
import { SvgIcon, Box, Typography } from "@mui/material";
import PropTypes from "prop-types";

import configManager from "../../../configManager/configManager";
const config = configManager.getConfig();

/**
* @param {object} props - the props passed down to the component
* @returns {Component} custom ListViewer as defined by react-admin containing the results of the query with each variable its generic field.
*/
function QueryResultList(props) {
const QueryTitle = useResourceDefinition().options.label;
const queryTitle = useResourceDefinition().options.label;
const { data } = useListContext(props);
const {changeVariables, submitted} = props;
const { resource, changeVariables, submitted} = props;
const [values, setValues] = useState(undefined);
useEffect(() => {
if (data && data.length > 0) {
Expand All @@ -28,15 +28,18 @@ function QueryResultList(props) {
}
}, [data]);

const config = configManager.getConfig();
const query = configManager.getQueryWorkingCopyById(resource);

return (
<div style={{ paddingLeft: '20px' , paddingRight: '10px' }}>
<Title title={config.title} />

{submitted && <Aside changeVariables={changeVariables}/> /* Adding button to make a new query - top left corner */ }
<Typography fontSize={"2rem"} mt={2} > {QueryTitle} </Typography>
<Typography fontSize={"2rem"} mt={2} > {queryTitle} </Typography>
{values ?(
<ListView title=" " actions={<ActionBar />} {...props} >
<Datagrid header={<TableHeader config={config}/>} bulkActionButtons={false}>
<ListView title=" " actions={<ActionBar />} {...props} >
<Datagrid header={<TableHeader query={query}/>} bulkActionButtons={false}>
{Object.keys(values).map((key) => {
return (
<GenericField
Expand All @@ -49,12 +52,18 @@ function QueryResultList(props) {
</Datagrid>
</ListView>
):
<NoValuesDiplay/>
<NoValuesDisplay/>
}
</div>
);
}

QueryResultList.propTypes = {
resource: PropTypes.string.isRequired,
changeVariables: PropTypes.func.isRequired,
submitted: PropTypes.bool.isRequired
};

/**
*
* @param {Array<Term>} data - a list of data objects
Expand All @@ -81,7 +90,7 @@ const Aside = (props) => {
</div>
)}

const NoValuesDiplay = () => {
const NoValuesDisplay = () => {
return(
<div>
<Box display="flex" alignItems="center" sx={{m:3}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import LinkIcon from "@mui/icons-material/Link";
import PropTypes from "prop-types";
import { Component } from "react";

import configManager from "../../../../configManager/configManager";

/**
*
* @param {object} props - the props passed down to the component
* @param {Array<Component>} props.children - the children of the component
* @param {object} props.config - the config object of the application
* @returns {Component} the header of the table containing the column names, the sort icons and ontology links
*/
function TableHeader({ children, config }) {
function TableHeader({ children }) {
const { sort, setSort, resource } = useListContext();
const { variableOntology } = config.queries.filter(
(query) => query.id === resource
)[0];

/**
* Handles the click on a header and sets the sort state accordingly
Expand All @@ -37,6 +35,9 @@ function TableHeader({ children, config }) {
setSort(newSort);
}

const query = configManager.getQueryWorkingCopyById(resource);
const variableOntology = query.variableOntology;

return (
<TableHead>
<TableRow>
Expand Down Expand Up @@ -90,8 +91,6 @@ function TableHeader({ children, config }) {
}

TableHeader.propTypes = {
children: PropTypes.node,
config: PropTypes.object.isRequired,

children: PropTypes.node
}
export default TableHeader;
10 changes: 2 additions & 8 deletions src/components/ListResultTable/TemplatedListResultTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import TemplatedQueryForm from "./TemplatedQueryForm.jsx";
import ListResultTable from "./ListResultTable.jsx";

import configManager from '../../configManager/configManager.js';
const config = configManager.getConfig();

/**
* A wrapper component around ListResultTable, to support templated queries
Expand All @@ -22,15 +21,10 @@ const TemplatedListResultTable = (props) => {
const [submitted, setSubmitted] = useState(false);
const [searchPar, setSearchPar] = useState({});

const query = config.queries.filter(
(query) => query.id === resource
)[0];

const query = configManager.getQueryWorkingCopyById(resource);
const isTemplatedQuery = query.variables !== undefined;
let tableEnabled = !isTemplatedQuery;



if (isTemplatedQuery) {
// Update variables from query parameters
const queryParams = new URLSearchParams(location.search);
Expand Down Expand Up @@ -83,7 +77,7 @@ const TemplatedListResultTable = (props) => {
searchPar={searchPar}
/>
}
{tableEnabled && <ListResultTable {...props} variables={variables} changeVariables={changeVariables} submitted={submitted}/>}
{tableEnabled && <ListResultTable {...props} resource={resource} variables={variables} changeVariables={changeVariables} submitted={submitted}/>}
</>
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/LoginPage/LoginPage.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "./LoginPage.css";
import { useLogin, useNotify } from "react-admin";
import { Component, useState } from "react";

import configManager from "../../configManager/configManager";

/**
* @returns {Component} a login form for logging into your Identity Provider.
*/
function SolidLoginForm() {
const config = configManager.getConfig();
const login = useLogin();
const notify = useNotify();
const [isIdp, setIsIdp] = useState(true);
Expand All @@ -25,6 +25,8 @@ function SolidLoginForm() {
}
}

const config = configManager.getConfig();

return (
<form onSubmit={handleLogin} className="login-form">
<div className="login-form-type-selection-box">
Expand Down
Loading