Skip to content

Commit

Permalink
Implemented upload and copy
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed May 12, 2021
1 parent 768f6a5 commit d370a02
Show file tree
Hide file tree
Showing 28 changed files with 765 additions and 88 deletions.
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react-bootstrap": "^1.5.2",
"react-bootstrap-typeahead": "^5.1.4",
"react-dom": "^17.0.2",
"react-hook-form": "^7.5.2",
"react-infinite-scroll-component": "^6.1.0",
"react-jsonschema-form-layout-grid": "^2.1.0",
"react-router-dom": "^5.2.0",
Expand Down
12 changes: 12 additions & 0 deletions ui/public/assets/schema/provider/dynamic-http.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@
"id": "fieldset"
},
"properties": {
"@type": {
"type": "string",
"default": "RequiredValidUntil"
},
"maxValidityInterval": {
"title": "label.max-validity-interval",
"description": "tooltip.max-validity-interval",
Expand All @@ -416,6 +420,10 @@
"id": "fieldset"
},
"properties": {
"@type": {
"type": "string",
"default": "SignatureValidation"
},
"requireSignedRoot": {
"title": "label.require-signed-root",
"description": "tooltip.require-signed-root",
Expand Down Expand Up @@ -459,6 +467,10 @@
"id": "fieldset"
},
"properties": {
"@type": {
"type": "string",
"default": "EntityRoleWhiteList"
},
"retainedRoles": {
"title": "label.retained-roles",
"description": "tooltip.retained-roles",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Metadata } from './metadata/Metadata';
import { Notifications } from './notifications/hoc/Notifications';
import { NotificationList } from './notifications/component/NotificationList';
import { UserConfirmation, ConfirmWindow } from './core/components/UserConfirmation';
import { NewSource } from './metadata/NewSource';



Expand Down Expand Up @@ -53,6 +54,7 @@ function App() {
<Redirect to="/dashboard" />
</Route>
<Route path="/dashboard" component={Dashboard} />
<Route path="/metadata/source/new" component={NewSource} />
<Route path="/metadata/:type/:id" component={Metadata} />
</Switch>
<NotificationList />
Expand Down
27 changes: 18 additions & 9 deletions ui/src/app/core/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Link } from 'react-router-dom';

import Nav from 'react-bootstrap/Nav';
import Navbar from 'react-bootstrap/Navbar';
import NavDropdown from 'react-bootstrap/NavDropdown';
import Dropdown from 'react-bootstrap/Dropdown';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faTh, faSignOutAlt } from '@fortawesome/free-solid-svg-icons';
import { faTh, faSignOutAlt, faPlusCircle, faCube, faCubes } from '@fortawesome/free-solid-svg-icons';

import Translate from '../../i18n/components/translate';
import { useTranslation } from '../../i18n/hooks';
Expand All @@ -26,13 +26,22 @@ export function Header () {
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="ml-auto align-items-center" navbar>
<NavDropdown title="Dropdown" id="basic-nav-dropdown">
<NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
<NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
<NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
<NavDropdown.Divider />
<NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
</NavDropdown>
<Dropdown className="" id="basic-nav-dropdown">
<Dropdown.Toggle variant="outline-primary" id="dropdown-basic" size="sm">
<FontAwesomeIcon icon={faPlusCircle} className="mr-2" />
<Translate value={'action.add-new'} />
</Dropdown.Toggle>
<Dropdown.Menu>
<Link to="/metadata/source/new" className="dropdown-item text-primary">
<FontAwesomeIcon icon={faCube} className="mr-2" />
Metadata Source
</Link>
<Link to="/metadata/provider/new" className="dropdown-item text-primary">
<FontAwesomeIcon icon={faCubes} className="mr-2" />
Metadata Provider
</Link>
</Dropdown.Menu>
</Dropdown>
<Link to="/dashboard" className="nav-link" aria-label="Metadata Dashboard">
<i className="fa fa-th fa-fw" aria-hidden="true"></i>
<FontAwesomeIcon icon={faTh} className="mr-2" />
Expand Down
15 changes: 15 additions & 0 deletions ui/src/app/core/utility/read_file_contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


export function readFileContents(file) {
return new Promise(function (resolve, reject) {
const fileReader = new FileReader();

fileReader.onload = (evt) => {
const reader = evt.target;
const txt = reader.result;
resolve(txt);
};
fileReader.onerror = reject;
fileReader.readAsText(file);
});
}
80 changes: 41 additions & 39 deletions ui/src/app/metadata/Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,46 @@ export function Metadata () {
let { path } = useRouteMatch();

return (
<MetadataSelector>
{(entity) =>
<MetadataXmlLoader>
<MetadataSchema entity={ entity }>
<Switch>
<Route path={`${path}/configuration/options`} render={ () =>
<MetadataDetail>
<MetadataOptions></MetadataOptions>
</MetadataDetail>
} />
<Route path={`${path}/configuration/xml`} render={() =>
<MetadataDetail>
<MetadataXml></MetadataXml>
</MetadataDetail>
} />
<Route path={`${path}/configuration/history`} render={ () =>
<MetadataDetail>
<MetadataHistory></MetadataHistory>
</MetadataDetail>
} />
<Route path={`${path}/configuration/compare`} render={ () =>
<MetadataDetail>
<MetadataComparison></MetadataComparison>
</MetadataDetail>
} />
<Route path={`${path}/configuration/version/:versionId/options`} render={ () =>
<MetadataDetail>
<MetadataVersion></MetadataVersion>
</MetadataDetail>
} />
<Route path={`${path}/edit/:section`} render={ () =>
<MetadataEdit />
} />
<Redirect exact path={`${path}`} to={`${path}/configuration/options`} />
</Switch>
</MetadataSchema>
</MetadataXmlLoader>
}
</MetadataSelector>
<>
<MetadataSelector>
{(entity) =>
<MetadataXmlLoader>
<MetadataSchema type={entity['@type'] ? entity['@type'] : 'source'}>
<Switch>
<Route path={`${path}/configuration/options`} render={ () =>
<MetadataDetail>
<MetadataOptions></MetadataOptions>
</MetadataDetail>
} />
<Route path={`${path}/configuration/xml`} render={() =>
<MetadataDetail>
<MetadataXml></MetadataXml>
</MetadataDetail>
} />
<Route path={`${path}/configuration/history`} render={ () =>
<MetadataDetail>
<MetadataHistory></MetadataHistory>
</MetadataDetail>
} />
<Route path={`${path}/configuration/compare`} render={ () =>
<MetadataDetail>
<MetadataComparison></MetadataComparison>
</MetadataDetail>
} />
<Route path={`${path}/configuration/version/:versionId/options`} render={ () =>
<MetadataDetail>
<MetadataVersion></MetadataVersion>
</MetadataDetail>
} />
<Route path={`${path}/edit/:section`} render={ () =>
<MetadataEdit />
} />
<Redirect exact path={`${path}`} to={`${path}/configuration/options`} />
</Switch>
</MetadataSchema>
</MetadataXmlLoader>
}
</MetadataSelector>
</>
);
}
92 changes: 92 additions & 0 deletions ui/src/app/metadata/NewSource.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import React from 'react';
import { NavLink, Redirect, Route, Switch, useRouteMatch } from 'react-router-dom';
import Translate from '../i18n/components/translate';
import { MetadataSchema } from './hoc/MetadataSchema';
import { MetadataWizard } from './view/MetadataWizard';
import { MetadataCopy } from './view/MetadataCopy';
import { MetadataUpload } from './view/MetadataUpload';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCopy, faLink, faPlusSquare } from '@fortawesome/free-solid-svg-icons';

export function NewSource() {

let { path } = useRouteMatch();

return (
<div className="container-fluid p-3">
<section className="section" aria-label="Add a new metadata source - how are you adding the metadata information?" tabIndex="0">
<div className="section-header bg-info p-2 text-white">
<div className="row justify-content-between">
<div className="col-md-12">
<span className="display-6"><Translate value="label.add-a-new-metadata-resolver">Add a new metadata source</Translate></span>
</div>
</div>
</div>
<div className="section-body p-4 border border-top-0 border-info">
<h3><Translate value="label.how-are-you-adding-the-metadata-information">How are you adding the metadata information?</Translate></h3>
<br />
<div className="row">
<div className="col col-xl-6 col-lg-9 col-xs-12">
<div className="d-flex justify-content-between">
<div className="resolver-nav-option">
<NavLink type="button"
to="upload"
className="btn btn-lg btn-block btn-secondary d-flex flex-column justify-content-center align-items-center"
aria-label="Upload local metadata file or use a metadata URL"
role="button"
activeClassName='btn-success'>
<Translate value="label.upload-url">Upload/URL</Translate>
<FontAwesomeIcon icon={faLink} size="2x" />
</NavLink>
</div>
<div className="">
<span className="subheading-1">&nbsp;<Translate value="label.or">or</Translate>&nbsp;</span>
</div>
<div className="resolver-nav-option">
<NavLink type="button"
className="btn btn-lg btn-block btn-secondary d-flex flex-column justify-content-center align-items-center"
aria-label="Create metadata source using the wizard"
role="button"
to="blank"
activeClassName='btn-info'>
<Translate value="action.create">Create</Translate>
<FontAwesomeIcon icon={faPlusSquare} size="2x" />
</NavLink>
</div>
<div className="">
<span className="subheading-1">&nbsp;<Translate value="label.or">or</Translate>&nbsp;</span>
</div>
<div className="resolver-nav-option">
<NavLink type="button"
className="btn btn-lg btn-block btn-secondary d-flex flex-column justify-content-center align-items-center"
aria-label="Copy a metadata source"
role="button"
to="copy"
activeClassName='btn-warning'>
<Translate value="action.copy">Copy</Translate>
<FontAwesomeIcon icon={faCopy} size="2x"/>
</NavLink>
</div>
</div>
<hr />
</div>
</div>
<MetadataSchema type={'source'}>
<Switch>
<Route path={`${path}/blank`} render={() =>
<MetadataWizard></MetadataWizard>
} />
<Route path={`${path}/upload`} render={() =>
<MetadataUpload></MetadataUpload>
} />
<Route path={`${path}/copy`} render={() =>
<MetadataCopy></MetadataCopy>
} />
<Redirect exact path={`${path}`} to={`${path}/blank`} />
</Switch>
</MetadataSchema>
</div>
</section>
</div>
);
}
2 changes: 0 additions & 2 deletions ui/src/app/metadata/component/MetadataConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export function MetadataConfiguration ({ configuration, onEdit }) {
const columns = configuration.dates?.length || 1;
const width = usePropertyWidth(columns);

console.log(configuration)

return (
<>
{ configuration && configuration.sections.map((section, sidx) =>
Expand Down
Loading

0 comments on commit d370a02

Please sign in to comment.