Commit 81e594cb authored by Dileep Bapat's avatar Dileep Bapat
Browse files

Adding entity to registry

No related merge requests found
Showing with 141 additions and 31 deletions
+141 -31
{
"realm": "divoc",
"auth-server-url": "/auth/",
"auth-server-url": "https://divoc.xiv.in/auth/",
"ssl-required": "external",
"resource": "facility-admin-portal",
"public-client": true,
......
......@@ -23,6 +23,7 @@ import FacilityInfo from './components/FacilityInfo/FacilityInfo';
import {addFacilityDetails} from "./redux/reducers/facilityReducer";
import {useAxios} from "./utils/useAxios";
import FacilityConfigureSlot from "./components/FacilityConfigureSlot";
import Add from "./components/Add/Add";
export default function App() {
const {initialized, keycloak} = useKeycloak();
......@@ -68,7 +69,9 @@ export default function App() {
<Route exact path={config.urlPath + "/analytics/map"} component={MapView}/>
<PrivateRoute exact path={config.urlPath + "/dashboard"} component={Dashboard}/>
<PrivateRoute exact path={config.urlPath + "/about"} component={About}/>
<PrivateRoute exact path={config.urlPath + "/admin"} component={Admin}
<PrivateRoute exact path={config.urlPath + "/admin/:entity?"} component={Admin}
role={CONSTANTS.ADMIN_ROLE} clientId={CONSTANTS.PORTAL_CLIENT}/>
<PrivateRoute exact path={config.urlPath + "/registry/:entity"} component={Add}
role={CONSTANTS.ADMIN_ROLE} clientId={CONSTANTS.PORTAL_CLIENT}/>
<PrivateRoute exact path={config.urlPath + "/analytics"} component={Analytics}
role={CONSTANTS.MONITORING} clientId={CONSTANTS.PORTAL_CLIENT}/>
......
import React, {useEffect, useState} from 'react';
import {TabPanels} from "../TabPanel/TabPanel";
import Entities from "../EntityRegistry/EntityRegistry";
import {Button, Col} from "react-bootstrap";
import {API_URL, SampleCSV} from "../../utils/constants";
import DownloadImg from "../../assets/img/download.svg";
import "./Add.module.css"
import {useAxios} from "../../utils/useAxios";
import AppBar from "@material-ui/core/AppBar";
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
import Form from "@rjsf/core";
import {useHistory} from "react-router-dom";
const schema = {
title: "Todo",
type: "object",
required: ["title"],
properties: {
title: {type: "string", title: "Title", default: "A new task"},
done: {type: "boolean", title: "Done?", default: false}
}
};
const log = (type) => console.log.bind(console, type);
export default function Add(props) {
const axiosInstance = useAxios("");
const [schema, setSchema] = useState({});
const entityType = props.match.params.entity;
const history = useHistory();
useEffect(x=>{
axiosInstance.current.get(API_URL.SCHEMA_BASE + entityType + ".json")
.then((res) => {
setSchema(res.data);
})
.catch((e) => {
console.log(e);
})
}, []);
const onSubmit = function (form) {
const data = form.formData[entityType];
axiosInstance.current.post(API_URL.REST_BASE + entityType, data)
.then(res => {
if (res.status === 200) {
alert('Saved!');
history.push('/portal/admin/')
}
else
alert("Something went wrong while saving!");
});
alert('submit' + form.formData[entityType]);
};
return <div className={"container"}>
<Form schema={schema}
onChange={log("changed")}
onSubmit={onSubmit}
onError={log("errors")} />
</div>
}
.btn-template {
border-radius: 6px;
border: none;
color: #FFFFFF;
background: #88C6A9;
text-align: center;
padding-top: 10px;
}
.btn-template h6 {
text-align: center;
font-weight: bold;
font-size: 12px;
margin: 0;
padding: 5px;
}
.btn-template a {
padding: 0;
margin: 0;
}
.btn-template img {
width: 25px;
height: 25px;
padding: 4px;
}
......@@ -6,17 +6,22 @@ import {API_URL, SampleCSV} from "../../utils/constants";
import DownloadImg from "../../assets/img/download.svg";
import "./Admin.module.css"
import {useAxios} from "../../utils/useAxios";
import AppBar from "@material-ui/core/AppBar";
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
export default function Admin() {
export default function Admin(props) {
const axiosInstance = useAxios("");
const [entities, setEntities] = useState([]);
const entityType = props.match.params.entity;
useEffect(() => {
axiosInstance.current.get(API_URL.REGISTRY_LIST)
.then((res) => {
setEntities(res.data.result);
const entities = res.data.result.filter(x=> x[0] != x[0].toLowerCase())
setEntities(entities);
})
.catch((e) => {
console.log(e);
......@@ -36,13 +41,13 @@ export default function Admin() {
return entities.map(ent => {
return {
title: ent,
component: <Entities type={ent}/>,
rightTabContent: renderDownloadTemplateButton(SampleCSV.FACILITY_REGISTRY)
component: <Entities type={ent}/>
// , rightTabContent: renderDownloadTemplateButton(SampleCSV.FACILITY_REGISTRY)
}
});
}
return entities.length > 0 && (
<TabPanels tabs={fetchTabs()}/>
<TabPanels tabs={fetchTabs()} />
);
}
......@@ -58,6 +58,7 @@ function Entities({type}) {
emptyListMessage={"No Entity Found"}
tableData={data}
tableHeader={HeaderData}
entityType={type}
onRefresh={() => fetchTableDetails()}
/>
}
......
......@@ -12,6 +12,10 @@ import "./UploadHistory.css";
import {TotalRecords} from "../TotalRecords";
import Modal from "react-bootstrap/Modal";
import IconButton from "@material-ui/core/IconButton";
import Checkbox from "@material-ui/core/Checkbox";
import { useHistory } from 'react-router-dom';
import {identity} from "ramda";
const UploadHistory = ({
fileUploadAPI,
......@@ -24,12 +28,13 @@ const UploadHistory = ({
tableData,
tableHeader,
onRefresh,
entityType
}) => {
const axiosInstance = useAxios("");
const [uploadHistory, setUploadHistory] = useState([]);
const [selectedHistory, setSelectedHistory] = useState(null);
const [show, setShow] = useState(false);
const history = useHistory();
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
useEffect(() => {
......@@ -86,6 +91,9 @@ const UploadHistory = ({
}
return 0;
}
const handleAdd = function () {
history.push('/portal/registry/' + entityType)
};
return (
<div>
......@@ -96,18 +104,19 @@ const UploadHistory = ({
count={getTotalRegistryUploadCount()}
/>
)}
<UploadComponent
fileUploadAPI={fileUploadAPI}
onUploadComplete={() => {
fetchUploadHistory();
if (onRefresh) {
onRefresh();
}
}}
uploadHistoryCount={selectedHistory && selectedHistory.success}
errorCount={selectedHistory && selectedHistory.errors}
handleShow={handleShow}
/>
<IconButton onClick={handleAdd}>Add / Invite</IconButton>
{/*<UploadComponent*/}
{/* fileUploadAPI={fileUploadAPI}*/}
{/* onUploadComplete={() => {*/}
{/* fetchUploadHistory();*/}
{/* if (onRefresh) {*/}
{/* onRefresh();*/}
{/* }*/}
{/* }}*/}
{/* uploadHistoryCount={selectedHistory && selectedHistory.success}*/}
{/* errorCount={selectedHistory && selectedHistory.errors}*/}
{/* handleShow={handleShow}*/}
{/*/>*/}
</div>
<div className="upload-csv-container">
<div className="upload-history">
......@@ -118,17 +127,17 @@ const UploadHistory = ({
emptyListMessage={emptyListMessage}
/>
</div>
<div className="upload-history">
<UploadHistoryTable
data={uploadHistory}
headerData={uploadCSVHeaderData}
onCellClicked={(value) => {
setSelectedHistory(value);
handleShow();
}}
title="Uploads History"
/>
</div>
{/*<div className="upload-history">*/}
{/* <UploadHistoryTable*/}
{/* data={uploadHistory}*/}
{/* headerData={uploadCSVHeaderData}*/}
{/* onCellClicked={(value) => {*/}
{/* setSelectedHistory(value);*/}
{/* handleShow();*/}
{/* }}*/}
{/* title="Uploads History"*/}
{/* />*/}
{/*</div>*/}
<div className="error-temp">
{selectedHistory && (
<UploadErrors uploadHistory={selectedHistory}
......
......@@ -22,6 +22,8 @@ export const FACILITY_TYPE = Object.freeze({
export const API_URL = Object.freeze({
REGISTRY_SEARCH: "http://localhost:8080/search",
REGISTRY_LIST: "http://localhost:8080/registers",
SCHEMA_BASE: "http://localhost:8080/api/docs/",
REST_BASE: "http://localhost:8080/api/v1/",
FACILITY_API: "/divoc/admin/api/v1/facilities",
USER_FACILITY_API: "/divoc/admin/api/v1/facility",
FACILITY_NOTIFY_API: "/divoc/admin/api/v1/facilities/notify",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment