-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
875 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React from 'react'; | ||
| import { SourcesActions } from '../../admin/container/SourcesActions'; | ||
| import UserActions from '../../admin/container/UserActions'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| export function ActionsTab({ sources, users, reloadSources, reloadUsers }) { | ||
|
|
||
| return ( | ||
| <> | ||
| <section className="section"> | ||
| <div className="section-body border border-top-0 border-primary"> | ||
| <div className="section-header bg-primary p-2 text-light"> | ||
| <div className="row justify-content-between"> | ||
| <div className="col-12"> | ||
| <span className="lead"><Translate value="label.enable-metadata-sources">Enable Metadata Sources</Translate></span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="p-3"> | ||
| <SourcesActions sources={sources} reloadSources={reloadSources} /> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| <section className="section"> | ||
| <div className="section-body border border-top-0 border-primary"> | ||
| <div className="section-header bg-primary p-2 text-light"> | ||
| <div className="row justify-content-between"> | ||
| <div className="col-12"> | ||
| <span className="lead"><Translate value="label.user-access-request">User Access Request</Translate></span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <UserActions users={users} reloadUsers={reloadUsers} /> | ||
| </div> | ||
| </section> | ||
| </> | ||
|
|
||
| ); | ||
| } | ||
|
|
||
| export default ActionsTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import React from 'react'; | ||
| import useFetch from 'use-http'; | ||
| import UserManagement from '../../admin/container/UserManagement'; | ||
| import UserMaintenance from '../../admin/component/UserMaintenance'; | ||
| import API_BASE_PATH from '../../App.constant'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| export function AdminTab () { | ||
|
|
||
| const [users, setUsers] = React.useState([]); | ||
|
|
||
| const { get, response } = useFetch(`${API_BASE_PATH}/admin/users`, { | ||
| cachePolicy: 'no-cache' | ||
| }, []); | ||
|
|
||
| async function loadUsers() { | ||
| const users = await get('') | ||
| if (response.ok) { | ||
| setUsers(users); | ||
| } | ||
| } | ||
|
|
||
| /*eslint-disable react-hooks/exhaustive-deps*/ | ||
| React.useEffect(() => { | ||
| loadUsers(); | ||
| }, []); | ||
|
|
||
|
|
||
| return ( | ||
| <section className="section"> | ||
| <div className="section-body border border-top-0 border-primary"> | ||
| <div className="section-header bg-primary p-2 text-light"> | ||
| <div className="row justify-content-between"> | ||
| <div className="col-12"> | ||
| <span className="lead"><Translate value="label.user-maintenance">User Maintenance</Translate></span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="p-3"> | ||
| <UserManagement users={users} reload={loadUsers}> | ||
| {(u, roles, onChangeUserRole, onDeleteUser) => | ||
| <UserMaintenance users={ u } roles={roles} onChangeUserRole={onChangeUserRole} onDeleteUser={onDeleteUser} />} | ||
| </UserManagement> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| ); | ||
| } | ||
|
|
||
| export default AdminTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { Nav, NavItem } from 'reactstrap'; | ||
| import { Switch, Route, Redirect, useRouteMatch } from 'react-router-dom'; | ||
| import { NavLink } from 'react-router-dom'; | ||
|
|
||
| import Translate from '../../i18n/components/translate'; | ||
| import { AdminRoute } from '../../core/components/AdminRoute'; | ||
|
|
||
| import './Dashboard.scss'; | ||
| import { SourcesTab } from './SourcesTab'; | ||
| import { ProvidersTab } from './ProvidersTab'; | ||
| import { AdminTab } from './AdminTab'; | ||
| import { ActionsTab } from './ActionsTab'; | ||
| import { useIsAdmin } from '../../core/user/UserContext'; | ||
| import useFetch from 'use-http'; | ||
| import API_BASE_PATH from '../../App.constant'; | ||
| import { getMetadataPath } from '../../metadata/hooks/api'; | ||
|
|
||
| export function Dashboard () { | ||
|
|
||
| const { path } = useRouteMatch(); | ||
|
|
||
| const isAdmin = useIsAdmin(); | ||
|
|
||
| const [actions, setActions] = React.useState(0); | ||
| const [users, setUsers] = React.useState([]); | ||
| const [sources, setSources] = React.useState([]); | ||
|
|
||
| const { get, response } = useFetch(`${API_BASE_PATH}`, { | ||
| cachePolicy: 'no-cache' | ||
| }); | ||
|
|
||
| async function loadUsers() { | ||
| const users = await get('/admin/users') | ||
| if (response.ok) { | ||
| setUsers(users.filter(u => u.role === 'ROLE_NONE')); | ||
| } | ||
| } | ||
|
|
||
| async function loadSources() { | ||
| const s = await get(`/${getMetadataPath('source')}/disabledNonAdmin`); | ||
| if (response.ok) { | ||
| setSources(s); | ||
| } | ||
| } | ||
|
|
||
| /*eslint-disable react-hooks/exhaustive-deps*/ | ||
| React.useEffect(() => { | ||
| loadSources(); | ||
| loadUsers(); | ||
| }, []); | ||
|
|
||
| React.useEffect(() => { | ||
| setActions(users.length + sources.length); | ||
| }, [users, sources]); | ||
|
|
||
| return ( | ||
| <div className="container-fluid p-3" role="navigation"> | ||
|
|
||
| <Nav tabs> | ||
| <NavItem> | ||
| <NavLink className="nav-link" to={`${path}/metadata/manager/resolvers`}> | ||
| <Translate value="label.metadata-sources">Metadata Sources</Translate> | ||
| </NavLink> | ||
| </NavItem> | ||
| {isAdmin && | ||
| <> | ||
| <NavItem> | ||
| <NavLink className="nav-link" to={`${path}/metadata/manager/providers`}> | ||
| <Translate value="label.metadata-providers">Metadata Providers</Translate> | ||
| </NavLink> | ||
| </NavItem> | ||
| <NavItem> | ||
| <NavLink className="nav-link" to={`${path}/admin/management`}> | ||
| <Translate value="label.admin">Admin</Translate> | ||
| </NavLink> | ||
| </NavItem> | ||
| <NavItem> | ||
| <NavLink className="nav-link d-flex align-items-center" to={`${path}/admin/actions`}> | ||
| <Translate value="label.action-required">Action Required</Translate> | ||
| <span className="badge badge-pill badge-danger ml-1">{actions}</span> | ||
| </NavLink> | ||
| </NavItem> | ||
| </> | ||
| } | ||
| </Nav> | ||
| <Switch> | ||
| <Route exact path={`${path}`}> | ||
| <Redirect to={`${path}/metadata/manager/resolvers`} /> | ||
| </Route> | ||
| <Route path={`${path}/metadata/manager/resolvers`} component={SourcesTab} /> | ||
| <AdminRoute path={`${path}/metadata/manager/providers`} component={ProvidersTab} /> | ||
| <AdminRoute path={`${path}/admin/management`} component={AdminTab} /> | ||
| <Route path={`${path}/admin/actions`}> | ||
| <ActionsTab sources={sources} users={users} reloadSources={loadSources} reloadUsers={loadUsers} /> | ||
| </Route> | ||
| </Switch> | ||
| </div> | ||
| ); | ||
| } | ||
| /* | ||
| <ng-container * ngIf="hasActions$" > | ||
| & nbsp; | ||
| <span className="badge badge-pill badge-danger">{{ actionsRequired$ | async}}</span> | ||
| </ng - container > | ||
| */ | ||
| export default Dashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @import '../../../theme/variables.scss'; | ||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { useMetadataEntities } from '../../metadata/hooks/api'; | ||
| import Translate from '../../i18n/components/translate'; | ||
| import ProviderList from '../../metadata/domain/provider/component/ProviderList'; | ||
| import {Search} from '../component/Search'; | ||
| import { Ordered } from '../component/Ordered'; | ||
| import { useIsAdmin } from '../../core/user/UserContext'; | ||
| import { Alert } from 'reactstrap'; | ||
|
|
||
| const searchProps = ['name', '@type', 'createdBy']; | ||
|
|
||
| export function ProvidersTab () { | ||
|
|
||
| const [providers, setProviders] = React.useState([]); | ||
|
|
||
| const { get, response } = useMetadataEntities('provider'); | ||
|
|
||
| async function loadProviders() { | ||
| const providers = await get('') | ||
| if (response.ok) { | ||
| setProviders(providers); | ||
| } | ||
| } | ||
|
|
||
| /*eslint-disable react-hooks/exhaustive-deps*/ | ||
| React.useEffect(() => { loadProviders() }, []); | ||
|
|
||
| const isAdmin = useIsAdmin(); | ||
|
|
||
| return ( | ||
| <section className="section"> | ||
| <div className="section-body border border-top-0 border-primary"> | ||
| {isAdmin ? | ||
| <> | ||
| <div className="section-header bg-primary p-2 text-light"> | ||
| <span className="lead"> | ||
| <Translate value="label.current-metadata-providers">Current Metadata Providers</Translate> | ||
| </span> | ||
| </div> | ||
| <div className="p-3"> | ||
| <Ordered entities={providers} prop="resourceIds"> | ||
| {(ordered, first, last, onOrderUp, onOrderDown) => | ||
| <Search entities={ordered} searchable={searchProps}> | ||
| {(searched) => <ProviderList | ||
| entities={searched} | ||
| reorder={providers.length === searched.length} | ||
| first={first} | ||
| last={last} | ||
| onOrderUp={onOrderUp} | ||
| onOrderDown={onOrderDown}></ProviderList>} | ||
| </Search> | ||
| } | ||
| </Ordered> | ||
| </div> | ||
| </> | ||
| : | ||
| <Alert color="danger">Access Denied</Alert>} | ||
| </div> | ||
| </section> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import React from 'react'; | ||
| import Translate from '../../i18n/components/translate'; | ||
|
|
||
| import SourceList from '../../metadata/domain/source/component/SourceList'; | ||
| import { useMetadataEntities } from '../../metadata/hooks/api'; | ||
| import { Search } from '../component/Search'; | ||
|
|
||
| const searchProps = ['serviceProviderName', 'entityId', 'createdBy']; | ||
|
|
||
| export function SourcesTab () { | ||
|
|
||
| const [sources, setSources] = React.useState([]); | ||
|
|
||
| const { get, response } = useMetadataEntities('source', { | ||
| cachePolicy: 'no-cache' | ||
| }); | ||
|
|
||
| async function loadSources() { | ||
| const sources = await get('/'); | ||
| if (response.ok) { | ||
| setSources(sources); | ||
| } | ||
| } | ||
|
|
||
| const updateSources = () => loadSources(); | ||
|
|
||
| /*eslint-disable react-hooks/exhaustive-deps*/ | ||
| React.useEffect(() => { loadSources() }, []); | ||
|
|
||
| return ( | ||
| <section className="section"> | ||
| <div className="section-body border border-top-0 border-primary"> | ||
| <div className="section-header bg-primary p-2 text-light"> | ||
| <span className="lead"> | ||
| <Translate value="label.current-metadata-sources">Current Metadata Sources</Translate> | ||
| </span> | ||
| </div> | ||
| <div className="p-3"> | ||
| <Search entities={sources} searchable={searchProps}> | ||
| {(searched) => <SourceList entities={ searched } onDelete={ updateSources }></SourceList>} | ||
| </Search> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from 'react'; | ||
| import { useMetadataConfiguration } from '../hooks/configuration'; | ||
|
|
||
| export function Configuration ({entities, schema, definition, limited, children}) { | ||
|
|
||
| const config = useMetadataConfiguration(entities, schema, definition, limited); | ||
|
|
||
| console.log(config) | ||
|
|
||
| return ( | ||
| <>{children(config)}</> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import React from 'react'; | ||
| import { useParams } from 'react-router'; | ||
| import { getMetadataPath } from '../hooks/api'; | ||
| import API_BASE_PATH from '../../App.constant'; | ||
| import useFetch from 'use-http'; | ||
| import { last } from 'lodash'; | ||
|
|
||
| export function MetadataVersionLoader ({versions, children}) { | ||
|
|
||
| const ref = React.useRef({}); | ||
| const [list, setList] = React.useState({}); | ||
|
|
||
| const { type, id } = useParams(); | ||
|
|
||
| const { get, response } = useFetch(`/${API_BASE_PATH}${getMetadataPath(type)}/${id}/Versions`, { | ||
| cachePolicy: 'no-cache', | ||
| }, []); | ||
|
|
||
| async function loadVersion(v) { | ||
| const l = await get(`/${v}`); | ||
| if (response.ok) { | ||
| addToList(v, l); | ||
| if (last(versions) !== v) { | ||
| loadNext(versions[versions.indexOf(v) + 1]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function addToList(version, item) { | ||
| ref.current = { | ||
| ...ref.current, | ||
| [version]: item | ||
| }; | ||
| setList(ref.current); | ||
| } | ||
|
|
||
| function loadNext (v) { | ||
| loadVersion(v); | ||
| } | ||
|
|
||
| React.useEffect(() => { | ||
| loadNext(versions[0]); | ||
| }, []); | ||
|
|
||
| return (<React.Fragment> | ||
| {children(versions.map(v => list[v]).filter(v => !!v))} | ||
| </React.Fragment>); | ||
| } |
Oops, something went wrong.