Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo #199

Merged
merged 9 commits into from
Aug 26, 2024
Merged

Demo #199

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
2 changes: 1 addition & 1 deletion apps/4tu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</html>
1 change: 0 additions & 1 deletion apps/ohsmart/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@
-->
</body>
</html>

48 changes: 42 additions & 6 deletions apps/rda/src/config/elasticSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const fieldConfig: Partial<RDTSearchUIProps> = {
export const elasticConfig = [
{
name: "RDA Catalogue",
url: "https://es.ohsmart.dansdemo.nl/dans-rda2",
url: "https://tiger.laurenstobias.com/rda",
fullTextFields: fieldConfig.fullTextFields,
fullTextHighlight: fieldConfig.fullTextHighlight,
resultBodyComponent: Rda2Result,
Expand All @@ -33,7 +33,7 @@ export const elasticConfig = [
<ListFacet
config={{
id: "indi",
field: "individuals.fullname.keyword",
field: "individuals.fullName.keyword",
title: {
en: "Individuals",
nl: "Individuen",
Expand Down Expand Up @@ -96,7 +96,7 @@ export const elasticConfig = [
<ListFacet
config={{
id: "wf",
field: "workflows.workflowstate.keyword",
field: "workflows.WorkflowState.keyword",
title: {
en: "Workflows",
nl: "Workflows",
Expand All @@ -108,7 +108,7 @@ export const elasticConfig = [
<PieChartFacet
config={{
id: "uritype",
field: "uritype.uritype.keyword",
field: "uri_type.uri_type.keyword",
title: {
en: "URI types",
nl: "URI types",
Expand All @@ -120,7 +120,7 @@ export const elasticConfig = [
<PieChartFacet
config={{
id: "subjects",
field: "subjects.keyword",
field: "subjects.keyword.keyword",
title: {
en: "Subjects",
nl: "Onderwerp",
Expand Down Expand Up @@ -165,6 +165,42 @@ export const elasticConfig = [
rows: 1,
}}
/>,
<ListFacet
config={{
id: "keywords-vocab",
field: "keywords.keyword.keyword",
title: {
en: "Keywords",
nl: "Trefwoorden",
},
cols: 2,
rows: 1,
}}
/>,
<PieChartFacet
config={{
id: "gorc-elements",
field: "gorc_elements.element.keyword",
title: {
en: "GORC Elements",
nl: "GORC Elementen",
},
cols: 3,
rows: 1,
}}
/>,
<PieChartFacet
config={{
id: "gorc-attributes",
field: "gorc_attributes.attribute.keyword",
title: {
en: "GORC Attributes",
nl: "GORC Attributen",
},
cols: 3,
rows: 1,
}}
/>,
<ListFacet
config={{
id: "pw",
Expand Down Expand Up @@ -205,7 +241,7 @@ export const elasticConfig = [
<ListFacet
config={{
id: "insttype",
field: "institutions.english_name.keyword",
field: "related_institutions.english_name.keyword",
title: {
en: "Related institutions",
nl: "Gerelateerde instellingen",
Expand Down
10 changes: 7 additions & 3 deletions apps/rda/src/pages/record/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ function Metadata({
}) {
if (value == null) return null;

const _value = Array.isArray(value) ? value.join(" || ") : value;
let _value = Array.isArray(value) ? value.join(" || ") : value;

if (_value.length < 1) {
_value = "-"
}

return (
<div style={style}>
Expand All @@ -224,9 +228,9 @@ function Metadata({

export function MetadataList({ record }: { record: RdaRecord | Result }) {
const individuals =
record.individuals ? record.individuals.map((i: any) => i.fullname) : [];
record.individuals ? record.individuals.map((i: any) => i.fullName) : [];
const workflows =
record.workflows ? record.workflows.map((w: any) => w.workflowstate) : [];
record.workflows ? record.workflows.map((w: any) => w.WorkflowState) : [];
const rights =
record.rights ? record.rights.map((r: any) => r.description) : [];
const pathways =
Expand Down
7 changes: 6 additions & 1 deletion packages/deposit/src/features/files/FilesUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ const FilesUpload = () => {
}

// No files with these file names
if (file.name.indexOf("__generated__") !== -1) {
if (
file.name.indexOf("__generated__form-metadata") !== -1
// oh smart specific. todo: move this all to form config.
|| file.name.toLowerCase() === "oral history metadata private.txt"
|| file.name.toLowerCase() === "oral history metadata public.txt"
) {
return {
code: "file-not-allowed",
message: t("fileNotAllowed"),
Expand Down
1 change: 1 addition & 0 deletions packages/file-mapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"version": "1.0.0",
"dependencies": {
"@dans-framework/utils": "workspace:*",
"@mui/icons-material": "^5.14.3",
"@mui/material": "^5.14.3",
"@reduxjs/toolkit": "^1.9.5",
"i18next": "^23.4.1",
Expand Down
13 changes: 7 additions & 6 deletions packages/file-mapper/src/features/FileMapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
import StepLabel from '@mui/material/StepLabel';
import { useTranslation } from "react-i18next";
import { Step1, Step2, Step3 } from './Steps';
import SelectFile from './SelectFile';
import SetMapping from './SetMapping';
import SaveMapping from './SaveMapping';
import { getActiveStep, setActiveStep, getFile, getSavedMap, getMapping, getFileError } from './fileMapperSlice';
import { useSubmitMapMutation } from './fileMapperApi';
import { useAppSelector, useAppDispatch } from "../redux/hooks";
Expand All @@ -18,8 +20,7 @@ import { useSiteTitle, setSiteTitle } from "@dans-framework/utils/sitetitle";
import { lookupLanguageString } from "@dans-framework/utils/language";
import { type Page } from "@dans-framework/pages";
import type { FormConfig } from "@dans-framework/deposit";

const steps = ['selectFile', 'createMapping', 'finish'];
import { steps } from "./Steps";

const FileMapper = ({setMappedForm, page}: {
setMappedForm: Dispatch<SetStateAction<FormConfig | undefined>>;
Expand Down Expand Up @@ -85,10 +86,10 @@ const FileMapper = ({setMappedForm, page}: {
</Stepper>
{
activeStep === 0
? <Step1 />
? <SelectFile />
: activeStep === 1
? <Step2 />
: <Step3 />
? <SetMapping />
: <SaveMapping />
}
<Box sx={{
display: 'flex',
Expand Down
17 changes: 17 additions & 0 deletions packages/file-mapper/src/features/SaveMapping.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useTranslation } from "react-i18next";
import TextField from '@mui/material/TextField';
import Typography from "@mui/material/Typography";
import { StepWrap } from "./Steps";

export const SaveMapping = () => {
const { t } = useTranslation("steps");

return (
<StepWrap title={t("finish")}>
<Typography mb={3}>{t("saveMappingExtra")}</Typography>
<TextField label={t('saveMapping')} sx={{ width: '30rem', maxWidth: '100%' }} />
</StepWrap>
)
}

export default SaveMapping;
136 changes: 136 additions & 0 deletions packages/file-mapper/src/features/SelectFile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { useDropzone } from "react-dropzone";
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import Alert from "@mui/material/Alert";
import { useTranslation } from "react-i18next";
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemText from '@mui/material/ListItemText';
import ListItemIcon from '@mui/material/ListItemIcon';
import Checkbox from '@mui/material/Checkbox';
import Divider from '@mui/material/Divider';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTheme } from '@mui/material/styles';
import type { Saves, SerializedFile } from "../types";
import {
getFile,
setFile,
getSavedMap,
setSavedMap,
resetMapping,
getFileError,
resetFileError,
resetFileData,
} from './fileMapperSlice';
import { useAppSelector, useAppDispatch } from "../redux/hooks";
import { StepWrap, maxRows, saves } from "./Steps";

const SelectFile = () => {
const { t } = useTranslation("steps");
const theme = useTheme();
const matches = useMediaQuery(theme.breakpoints.up('md'));
const dispatch = useAppDispatch();
const file = useAppSelector(getFile);
const savedMap = useAppSelector(getSavedMap);
const fileError = useAppSelector(getFileError);

const onDrop = async (files: File[]) => {
// serialize files to store in redux
const serializedFile: SerializedFile = {
name: files[0].name,
size: files[0].size,
url: URL.createObjectURL(files[0]),
};

dispatch(setFile(serializedFile));

// reset saved mapping and column values after selecting a different file
dispatch(resetMapping());
dispatch(resetFileData());
dispatch(resetFileError());
}

const {
getRootProps,
getInputProps,
isDragActive,
} = useDropzone({
onDrop,
multiple: false,
accept: {
"text/csv": [".csv"],
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
},
});

return (
<StepWrap title={t("selectFile")}>
<Stack
direction={{xs: "column", md: "row"}}
spacing={{xs: 3, md: 4}}
divider={<Divider orientation={matches ? "vertical" : "horizontal"} flexItem />}
>
<Box sx={{flex: 1}}>
<Typography variant="h4">{t("uploadNew")}</Typography>
<Box
sx={{
border: "1px dashed",
borderColor: "neutral.main",
backgroundColor: isDragActive ? "primary.light" : "transparent",
mb: matches ? 3 : 0,
}}
p={3}
{...getRootProps({ className: "dropzone" })}
>
<input {...getInputProps()} />
<Typography
color="neutral.contrastText"
sx={{ textAlign: "center", cursor: "pointer" }}
>
{isDragActive ? t("dropNow") : t("drop")}
</Typography>
</Box>
{ file &&
<Box key={file.name}>
<Alert severity="success">
{t("selectedFile", { name: file.name, size: (file.size / 1024).toFixed(0) })}
</Alert>
{fileError &&
<Alert severity="error">
{t(fileError, {max: maxRows})}
</Alert>
}
</Box>
}
</Box>
{saves.length > 0 &&
<Box sx={{flex: 1}}>
<Typography variant="h4" mb={1}>{t("selectSave")}</Typography>
<List>
{saves.map( (save: Saves) =>
<ListItem key={save.id} disablePadding>
<ListItemButton onClick={() => dispatch(setSavedMap(savedMap === save.id ? "" : save.id))} dense>
<ListItemIcon>
<Checkbox
edge="start"
checked={savedMap === save.id}
tabIndex={-1}
disableRipple
inputProps={{ 'aria-labelledby': save.id }}
/>
</ListItemIcon>
<ListItemText id={save.id} primary={save.name} secondary={t("savedOn", {date: save.date})} />
</ListItemButton>
</ListItem>
)}
</List>
</Box>
}
</Stack>
</StepWrap>
)
}

export default SelectFile;
Loading