Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Reorder domains
Browse files Browse the repository at this point in the history
On branch 22.02
Your branch is up to date with 'origin/22.02'.

Changes to be committed:
	modified:   package.json
	new file:   src/components/Etag.js
	modified:   src/components/JsonView.js
	modified:   src/components/PermissionTools.js
	modified:   src/components/ValidateSchema.js
	modified:   src/views/builder/BuilderView/ColorCoded/ErrorDomain.js
	modified:   src/views/builder/BuilderView/ColorCoded/IoDomain.js
	modified:   src/views/builder/BuilderView/ColorCoded/Meta.js
	modified:   src/views/builder/BuilderView/ColorCoded/index.js
	modified:   src/views/builder/BuilderView/Views.js
	modified:   src/views/builder/BuilderView/index.js
  • Loading branch information
HadleyKing committed Feb 17, 2022
1 parent c89ed28 commit d3f91fa
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 78 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"depcheck": "^1.4.2",
"formik": "^2.1.5",
"moment": "^2.27.0",
"object-hash": "^2.2.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-async": "^10.0.1",
Expand Down
12 changes: 12 additions & 0 deletions src/components/Etag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// src/components/Etag.js

import React from 'react';
import PropTypes from 'prop-types';

export default function Etag(contents) {
console.log('contents', contents);
}

Etag.propTypes = {
contents: PropTypes.object.isRequired,
};
2 changes: 1 addition & 1 deletion src/components/JsonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function JsonView({
const rawContents = JSON.stringify(jsonContents, null, 4);
const [jsonErrors, setJsonErrors] = useState('');
const setInput = (value) => {
console.log('working?', 'hadley');
console.log('working?', 'hadley', value);
let holder = {};
holder = JSON.parse(value);
setJsonContents(holder);
Expand Down
36 changes: 18 additions & 18 deletions src/components/PermissionTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CardContent from '@material-ui/core/CardContent';
import { Grid } from '@material-ui/core';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';

import PropTypes from 'prop-types';
import CreateDraftObject from './API/CreateDraftObject';
import ModifyDraftObject from './API/ModifyDraftObject';
import PublishDraftObject from './API/PublishDraftObject';
Expand All @@ -38,19 +38,11 @@ const useStyles = makeStyles((theme) => ({
}));

export default function PermissionTools({
contents, publish, newDraft, objectInformation, setPublish, publishedObjectId,
receivedDefault, serverLock }) {
contents, publish, objectInformation, newDraft, setPublish
}) {
// State
const [saveDraftTo, setSaveDraftTo] = useState('');
const [savePublishTo, setSavePublishTo] = useState('');
const fc = useContext(FetchContext);

// For publishing
const [open, setOpen] = useState(false);
const [retainDraft, setRetainDraft] = useState(false);

// Is the user logged in?
const [loggedInWithServers, setLoggedInWithServers] = useState(false);
const [userInfo, setUserInfo] = useState(null);
const classes = useStyles();
let ApiInfo = JSON.parse(localStorage.getItem('user'));
Expand All @@ -62,6 +54,7 @@ export default function PermissionTools({
// There was a user.
ApiInfo = ApiInfo.apiinfo;
}

// Define the actions for each click.
function clickActions(which) {
if (which === 'saveDraft') {
Expand All @@ -73,8 +66,8 @@ export default function PermissionTools({
} else if (which === 'publishDraft') {
PublishDraftObject(objectInformation, contents);
} else if (which === 'downloadDraft') {
const bco = localStorage.getItem("bco");
const blob = new Blob([bco],{type:'application/json'});
const bco = localStorage.getItem('bco');
const blob = new Blob([bco], { type: 'application/json' });
const href = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = href;
Expand All @@ -98,7 +91,6 @@ export default function PermissionTools({

if (userInfoCheck !== null) {
if (userInfoCheck.apiinfo.length > 0) {
setLoggedInWithServers(true);
setUserInfo(userInfoCheck);
}
}
Expand Down Expand Up @@ -142,7 +134,8 @@ export default function PermissionTools({
3) SAVE CURRENT DRAFT
</Typography>
<Typography gutterBottom>
This button will be available if you are working on a DRAFT currently in a BCODB.
This button will be available if you are working on a DRAFT
currently in a BCODB.
</Typography>
<Typography gutterBottom variant="h4">
4) VALIDATE DRAFT
Expand Down Expand Up @@ -180,7 +173,6 @@ export default function PermissionTools({
<ServerList
disabledValue={(newDraft === false)}
options={userInfo === null ? null : userInfo.apiinfo}
receivedDefault={receivedDefault}
setter={setSaveDraftTo}
type="draft"
/>
Expand Down Expand Up @@ -217,7 +209,7 @@ export default function PermissionTools({
variant="contained"
color="primary"
disableElevation
disabled={newDraft === true} //publish === false}
disabled={publish === false}
fullWidth
onClick={() => clickActions('publishDraft')}
>
Expand Down Expand Up @@ -255,7 +247,7 @@ export default function PermissionTools({
variant="contained"
color="secondary"
disableElevation
disabled={!serverLock}
disabled
fullWidth
onClick={() => clickActions('deleteDraft')}
>
Expand All @@ -270,3 +262,11 @@ export default function PermissionTools({
</div>
);
}

PermissionTools.propTypes = {
contents: PropTypes.object.isRequired,
publish: PropTypes.bool.isRequired,
objectInformation: PropTypes.object.isRequired,
newDraft: PropTypes.bool,
setPublish: PropTypes.func.isRequired,
};
7 changes: 3 additions & 4 deletions src/components/ValidateSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
/* validates a JSON against a SCHEMA */

import Ajv from 'ajv';

import object from 'src/utils/ieee2791/2791object';

const ajv = Ajv();

export default function ValidateSchema(contents, setPublish, publish, setMeEtagSet) {
export default function ValidateSchema(contents, setPublish) {
const BcoSchema = object;
console.log('objectContents', setPublish, contents);
console.log('objectContents', contents);
// 'https://opensource.ieee.org/2791-object/ieee-2791-schema/raw/master/2791object.json';
// 'https://w3id.org/ieee/ieee-2791-schema/2791object.json';
// fetch(BcoSchema, { mode: 'no-cors' });

const valid = ajv.validate(BcoSchema, contents);
if (valid) {
setPublish(true);
console.log('BCO is valid', publish);
console.log('BCO is valid');
// eslint-disable-next-line no-alert
alert('BCO is valid');
} else {
Expand Down
70 changes: 52 additions & 18 deletions src/views/builder/BuilderView/ColorCoded/ErrorDomain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import {
makeStyles, withStyles, Typography
Expand Down Expand Up @@ -36,7 +36,25 @@ const StyledCell = withStyles({
export default function ErrorDomain({ items }) {
const inputClasses = useStyles();
const classes = withStyles();
console.log('working', items);
const [algorithmic, setAlgorithmic] = useState(items.errd ? items.errd.algorithmic_error : {});
const [empirical, setEmpirical] = useState(items.errd ? items.errd.empirical_error : {});
const [updates, setUpdates] = useState(false);

const addErrors = () => {
console.log('working click', setAlgorithmic);
setUpdates(true);
};

useEffect(() => {
if (updates === true) {
items.setErrd(
{
empirical_error: empirical,
algorithmic_error: algorithmic
}
);
}
}, [empirical, algorithmic, updates]);

return (
<Table size="small">
Expand All @@ -58,22 +76,38 @@ export default function ErrorDomain({ items }) {
</TableRow>
</TableHead>
<TableBody>
<TableRow>
<JsonView
jsonContents={items.empirical}
setJsonContents={items.setEmpirical}
header="Empirical Error Subdomain"
rows={4}
/>
</TableRow>
<TableRow>
<JsonView
jsonContents={items.algorithmic}
setJsonContents={items.setAlgorithmic}
header="Algorithmic Error Subdomain"
rows={4}
/>
</TableRow>
{
(!items.errd)
? (
<TableRow>
<Button
variant="contained"
color="primary"
disableElevation
fullWidth
onClick={() => addErrors()}
>
Add Error Domain
</Button>
</TableRow>
)
: (
<TableRow>
<JsonView
jsonContents={algorithmic}
setJsonContents={setAlgorithmic}
header="Algorithmic Error Subdomain"
rows={4}
/>
<JsonView
jsonContents={empirical}
setJsonContents={setEmpirical}
header="Empirical Error Subdomain"
rows={4}
/>
</TableRow>
)
}
</TableBody>
</Table>
);
Expand Down
2 changes: 2 additions & 0 deletions src/views/builder/BuilderView/ColorCoded/IoDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ export default function IoDomain({ items, cF }) {
return (
<Card>
<UriObject
link={'https://docs.biocomputeobject.org/io-domain/'}
header={'Input Subdomain'}
list={items.iodInputSubdomain}
setList={items.setIodInputSubdomain}
setRerender={items.setRerender}
rerender={items.rerender}
/>
<UriObject
link={'https://docs.biocomputeobject.org/io-domain/'}
header={'Output Subdomain'}
list={items.iodOutputSubdomain}
setList={items.setIodOutputSubdomain}
Expand Down
7 changes: 7 additions & 0 deletions src/views/builder/BuilderView/ColorCoded/Meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@


import React, { useContext, useEffect, useState } from 'react';
import {
Button, makeStyles, withStyles, Typography
} from '@material-ui/core';
import PropTypes from 'prop-types';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
Expand Down Expand Up @@ -117,3 +120,7 @@ export default function Meta({ items }) {
</Table>
);
}

Meta.propTypes = {
items: PropTypes.object.isRequired
};
32 changes: 13 additions & 19 deletions src/views/builder/BuilderView/ColorCoded/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ function ColorCoded({
const [pad, setPad] = useState(objectContents.parametric_domain);

// Error domain
const [errd, setErrd] = useState(objectContents.error_domain ? objectContents.error_domain : {});
const [empirical, setEmpirical] = useState(errd.empirical_error);
const [algorithmic, setAlgorithmic] = useState(errd.algorithmic_error);
const [errd, setErrd] = useState(objectContents.error_domain);

// Extension domain
const [exd, setExd] = useState(objectContents.extension_domain);
Expand All @@ -148,38 +146,37 @@ function ColorCoded({
// Note that meta attributes have no setters as they
// are set in the parent.
const renderList = [

{
complianceCheck, checkBlank, iodInputSubdomain, iodOutputSubdomain, setIodInputSubdomain, setIodOutputSubdomain, rerender, setRerender
complianceCheck, meObjectId, meEtagSet, setMeEtagSet, meEtag, setMeEtag, rerender, setRerender, objectContents
},
{
complianceCheck, checkBlank, empirical, setEmpirical, algorithmic, setAlgorithmic
complianceCheck, checkBlank, pdName, pdVersion, pdLicense, pdDerivedFrom, pdCreated, pdModifed, pdObsoleteAfter, pdEmbargoStartTime, pdEmbargoEndTime, pdReview, pdContributors, rerender, setRerender, setPdName, setPdVersion, setPdLicense, setPdDerivedFrom, setPdCreated, setPdModified, setPdObsoleteAfter, setPdEmbargoStartTime, setPdEmbargoEndTime, setPdReview, setPdContributors
},
{
complianceCheck, checkBlank, ddKeywords, ddPlatform, ddXref, ddPipelineSteps, rerender, setDdKeywords, setDdPlatform, setDdXref, setDdPipelineSteps, setRerender
complianceCheck, checkBlank, ud, setUd, rerender, setRerender
},
{
complianceCheck, checkBlank, edScript, edScriptDriver, edSoftwarePrerequisites, edExternalDataEndpoints, edEnvironmentVariables, rerender, setEdScript, setEdScriptDriver, setEdSoftwarePrerequisites, setEdExternalDataEndpoints, setEdEnvironmentVariables, setRerender
complianceCheck, checkBlank, exd, setExd, setRerender
},
{
complianceCheck, checkBlank, ud, setUd, rerender, setRerender
complianceCheck, checkBlank, ddKeywords, ddPlatform, ddXref, ddPipelineSteps, rerender, setDdKeywords, setDdPlatform, setDdXref, setDdPipelineSteps, setRerender
},
{
complianceCheck, meObjectId, meEtagSet, setMeEtagSet, meEtag, setMeEtag, rerender, setRerender, objectContents
complianceCheck, checkBlank, edScript, edScriptDriver, edSoftwarePrerequisites, edExternalDataEndpoints, edEnvironmentVariables, rerender, setEdScript, setEdScriptDriver, setEdSoftwarePrerequisites, setEdExternalDataEndpoints, setEdEnvironmentVariables, setRerender
},
{
complianceCheck, checkBlank, pdName, pdVersion, pdLicense, pdDerivedFrom, pdCreated, pdModifed, pdObsoleteAfter, pdEmbargoStartTime, pdEmbargoEndTime, pdReview, pdContributors, rerender, setRerender, setPdName, setPdVersion, setPdLicense, setPdDerivedFrom, setPdCreated, setPdModified, setPdObsoleteAfter, setPdEmbargoStartTime, setPdEmbargoEndTime, setPdReview, setPdContributors
complianceCheck, checkBlank, iodInputSubdomain, iodOutputSubdomain, setIodInputSubdomain, setIodOutputSubdomain, rerender, setRerender
},
{
complianceCheck, checkBlank, pad, rerender, setPad, setRerender
},
{
complianceCheck, checkBlank, exd, setExd, setRerender
complianceCheck, checkBlank, errd, setErrd
}
];

const compList = [IoDomain, ErrorDomain, DescriptionDomain, ExecutionDomain, UsabilityDomain, Meta, ProvenanceDomain, ParametricDomain, ExtensionDomain];
const classNames = ['ioDomain', 'errorDomain', 'descriptionDomain', 'executionDomain', 'usabilityDomain', 'meta', 'provenanceDomain', 'parametricDomain', 'extensionDomain'];
const compList = [Meta, ProvenanceDomain, UsabilityDomain, ExtensionDomain, DescriptionDomain, ExecutionDomain, IoDomain, ParametricDomain, ErrorDomain];
const classNames = ['meta', 'provenanceDomain', 'usabilityDomain', 'extensionDomain', 'descriptionDomain', 'executionDomain', 'ioDomain', 'parametricDomain', 'errorDomain'];

// Listeners
// Listen for ANY change to the object,
Expand Down Expand Up @@ -218,18 +215,15 @@ function ColorCoded({
output_subdomain: iodOutputSubdomain
},
parametric_domain: pad,
error_domain: {
empirical_error: empirical,
algorithmic_error: algorithmic
},
error_domain: errd,
extension_domain: exd
});
// localStorage.setItem('bco', JSON.stringify(objectContents));
}, [meEtag, pdName, pdVersion, pdLicense, pdDerivedFrom, pdCreated, pdModifed,
pdObsoleteAfter, pdEmbargoStartTime, pdEmbargoEndTime, pdReview,
pdContributors, ud, ddKeywords, ddPlatform, ddXref, ddPipelineSteps,
edScript, edScriptDriver, edSoftwarePrerequisites, edExternalDataEndpoints,
edEnvironmentVariables, iodInputSubdomain, iodOutputSubdomain, pad, empirical, algorithmic, exd]);
edEnvironmentVariables, iodInputSubdomain, iodOutputSubdomain, pad, errd, exd]);

return (
<ColorCodedContext.Provider value={{
Expand Down
2 changes: 1 addition & 1 deletion src/views/builder/BuilderView/Views.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function Views({
// Define a variable for switching views within
// the component (as opposed to getting the value)
// from the parent).
const [componentView, setComponentView] = useState(2);
const [componentView, setComponentView] = useState(0);

const handleChange = (event, newValue) => {
setComponentView(newValue);
Expand Down
Loading

0 comments on commit d3f91fa

Please sign in to comment.