chooseNode(node)}
/>
}
@@ -50,7 +54,7 @@ function TreeNodeElement(props) {
>
@@ -83,8 +87,21 @@ function Organogram(props) {
const [orgDataTree, setOrgDataTree] = useState([]);
useEffect(() => {
- setOrgData(props.renderData);
- }, [props.renderData]);
+ fetch(process.env.NEXT_PUBLIC_BACKEND_ROOT + 'api/chart', {
+ 'method': 'GET',
+ 'headers': {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${getCookie('usercookie')}`
+ },
+ })
+ .then(response => response.json())
+ .then(data => {
+ const objectData = data.reduce((preData, node) => (
+ { ...preData, [node._id]: node }
+ ), {});
+ setOrgData(objectData)
+ });
+ }, []);
useEffect(() => {
makeTree(orgData);
@@ -99,49 +116,90 @@ function Organogram(props) {
setCardOpened(true);
}, [setSelectedOrgInfo, setCardOpened]);
- const createNode = useCallback((node) => {
- // node key generate
- const randomKey = Math.random().toString(36).substring(2, 10);
- node['key'] = randomKey;
-
- setOrgData(treeNode => ({ ...treeNode, [randomKey]: node }));
+ const createNode = useCallback(async (node) => {
+ await fetch(process.env.NEXT_PUBLIC_BACKEND_ROOT + 'api/chart/add', {
+ 'method': 'POST',
+ 'headers': {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${getCookie('usercookie')}`
+ },
+ 'body': JSON.stringify(node)
+ })
+ .then(response => {
+ if (response.status === 200 || response.status === 201)
+ return response.json()
+ })
+ .then(data => {
+ if (data)
+ setOrgData(treeNode => ({ ...treeNode, [data._id]: data }))
+ })
}, [setOrgData]);
- const updateNode = useCallback((node) => {
- setOrgData(treeNode => ({ ...treeNode, [node.key]: node }));
+ const updateNode = useCallback(async (node) => {
+ await fetch(process.env.NEXT_PUBLIC_BACKEND_ROOT + 'api/chart/edit', {
+ 'method': 'POST',
+ 'headers': {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${getCookie('usercookie')}`
+ },
+ 'body': JSON.stringify(node)
+ })
+ .then((response) => {
+ if (response.status === 200 || response.status === 201)
+ setOrgData(treeNode => ({ ...treeNode, [node._id]: node }))
+ })
}, [setOrgData]);
- const deleteNode = useCallback((node) => {
- setOrgData(treeNode => {
- const nodeCopy = { ...treeNode };
-
- // Redirection for children of removed node
- const nodeChildren = Object.values(nodeCopy).filter((data) => data.parent == node.key);
- for (let child of nodeChildren)
- child.parent = node.parent;
+ const deleteNode = useCallback(async (node) => {
+ const nodeCopy = { ...orgData };
+
+ // Redirection for children of removed node
+ const nodeChildren = Object.values(nodeCopy).filter((data) => data.Parent == node._id);
+ for (let child of nodeChildren) {
+ child.Parent = node.Parent;
+ await fetch(process.env.NEXT_PUBLIC_BACKEND_ROOT + 'api/chart/edit', {
+ 'method': 'POST',
+ 'headers': {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${getCookie('usercookie')}`
+ },
+ 'body': JSON.stringify(child)
+ });
+ }
- delete nodeCopy[node.key]
- return nodeCopy;
- });
- }, [setOrgData]);
+ await fetch(process.env.NEXT_PUBLIC_BACKEND_ROOT + 'api/chart/delete', {
+ 'method': 'POST',
+ 'headers': {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${getCookie('usercookie')}`
+ },
+ 'body': JSON.stringify(node)
+ })
+ .then((response) => {
+ if (response.status === 200 || response.status === 201) {
+ delete nodeCopy[node._id];
+ setOrgData(nodeCopy);
+ }
+ })
+ }, [orgData, setOrgData]);
const makeTree = useCallback((data) => {
// Deep Copy for object
const dataSet = {};
- for (let key in data)
- dataSet[key] = Object.assign({}, data[key]);
+ for (let id in data)
+ dataSet[id] = { ...data[id] };
const dataTree = [];
- for (let key in dataSet) {
- if (!dataSet[key].parent) {
- dataTree.push(dataSet[key]);
+ for (let id in dataSet) {
+ if (!dataSet[id].Parent) {
+ dataTree.push(dataSet[id]);
}
else {
- if (dataSet[dataSet[key].parent].children) {
- dataSet[dataSet[key].parent].children.push(dataSet[key]);
+ if (dataSet[dataSet[id].Parent].children) {
+ dataSet[dataSet[id].Parent].children.push(dataSet[id]);
}
else {
- dataSet[dataSet[key].parent].children = [dataSet[key]];
+ dataSet[dataSet[id].Parent].children = [dataSet[id]];
}
}
}
@@ -153,7 +211,7 @@ function Organogram(props) {
<>
{orgDataTree.map((dataNode) => (
-
+
{renderNode(dataNode, chooseOrgInfo)}
))}
@@ -166,7 +224,7 @@ function Organogram(props) {
onCreate={createNode}
onUpdate={updateNode}
onRemove={deleteNode}
- nodeList={props.renderData && Object.values(props.renderData).map((node) => ({ 'key': node.key, 'value': node.rank + ' ' + node.name }))}
+ nodeList={orgData && Object.values(orgData).map((node) => ({ 'key': node._id, 'value': node.Rank + ' ' + node.Name }))}
/>
>
)
diff --git a/front-end/web-next/styles/OrganizationCard.module.css b/front-end/web-next/styles/OrganizationCard.module.css
index aaba0e3f..b3db5680 100644
--- a/front-end/web-next/styles/OrganizationCard.module.css
+++ b/front-end/web-next/styles/OrganizationCard.module.css
@@ -1,26 +1,21 @@
.profileImage {
- width: 100px;
- height: 100px;
+ width: 150px;
+ height: 150px;
border: 1px solid #ddd;
border-radius: 100%;
}
.userName {
- font-size: 14pt;
+ font-size: 18pt;
font-weight: bold;
}
.milRank {
- font-size: 12pt;
+ font-size: 16pt;
font-weight: bold;
margin-left: 5pt;
}
-.userDodid {
- font-size: 12pt;
- color: #444;
-}
-
.infoLabel {
font-size: 14pt;
font-weight: bold;
@@ -32,9 +27,9 @@
.elementRow {
margin: 7px 0px;
- padding: 0px 15px;
+ padding: 0px 25px;
}
.userProfile {
- margin-left: 15px;
+ margin-bottom: 15px;
}
\ No newline at end of file
diff --git a/front-end/web-next/styles/OrganizationForm.module.css b/front-end/web-next/styles/OrganizationForm.module.css
index e82d584b..85c9c29b 100644
--- a/front-end/web-next/styles/OrganizationForm.module.css
+++ b/front-end/web-next/styles/OrganizationForm.module.css
@@ -1,14 +1,38 @@
.profileImage {
- width: 100px;
- height: 100px;
+ width: 150px;
+ height: 150px;
border: 1px solid #ddd;
border-radius: 100%;
}
+.userProfile {
+ margin-bottom: 15px;
+}
+
.formSelect {
width: 100px;
}
.parentSelect {
width: 300px;
+}
+
+.infoLabel {
+ font-size: 14pt;
+ font-weight: bold;
+}
+
+.infoContent {
+ font-size: 12pt;
+}
+
+.formInput {
+ width: 180px;
+ height: 30px;
+ border: 1px solid #d9d9d9;
+}
+
+.elementRow {
+ margin: 7px 0px;
+ padding: 0px 25px;
}
\ No newline at end of file
diff --git a/front-end/web-next/styles/Organogram.module.css b/front-end/web-next/styles/Organogram.module.css
index 7c5e463c..0bf27b2b 100644
--- a/front-end/web-next/styles/Organogram.module.css
+++ b/front-end/web-next/styles/Organogram.module.css
@@ -2,6 +2,8 @@
width: auto;
height: auto;
padding: 0;
+ margin-left: 15px;
+ margin-right: 15px;
border: transparent;
border-radius: 30pt;
background-color: transparent
@@ -11,13 +13,14 @@
width: 100px;
height: 100px;
border: 1px solid #ddd;
- border-radius: 100%
+ border-radius: 50px
}
.cardContent {
- padding: 10px;
- border: 1px solid #777;
- border-radius: 30pt;
+ padding-right: 50px;
+ border: 0;
+ border-radius: 50pt;
+ box-shadow: inset 0 -3em 3em rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(0, 128, 128, 0.5), 0.3em 0.3em 1em rgba(0, 0, 0, 0.3);
}
.userName {
@@ -32,5 +35,7 @@
}
.userPosition {
+ color: #555;
font-size: 13pt;
+ text-align: left;
}
\ No newline at end of file
diff --git a/front-end/web-next/styles/globals.css b/front-end/web-next/styles/globals.css
index bbc3936b..002502c6 100644
--- a/front-end/web-next/styles/globals.css
+++ b/front-end/web-next/styles/globals.css
@@ -116,4 +116,10 @@ a {
.ant-spin-dot-item {
background-color: #008080;
+}
+
+.organizationCard > .ant-modal-content,
+.organizationForm > .ant-modal-content {
+ border-radius: 30px;
+ padding: 5px;
}
\ No newline at end of file