Skip to content

Commit 7936c91

Browse files
committed
fix:commit and remove all the commit
1 parent e6c46aa commit 7936c91

File tree

7 files changed

+173
-22
lines changed

7 files changed

+173
-22
lines changed

backend/family_tree/node_modules/django/package.json

+39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/family_tree/package-lock.json

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/family_tree/src/App.css

+15
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,18 @@
4747
width: 150px;
4848
height: 170px;
4949
}
50+
51+
.button {
52+
border: 1px;
53+
border-radius: 6px;
54+
cursor: pointer;
55+
font-family: "JetBrains Mono";
56+
overflow: hidden;
57+
text-decoration: none;
58+
transition: box-shadow .15s, transform .15s;
59+
will-change: box-shadow, transform;
60+
}
61+
62+
.button:active {
63+
transform: translateY(1px);
64+
}

frontend/family_tree/src/App.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import React, { useEffect, useState } from "react";
22
import './App.css';
33
import Help from './Components/Help.js';
44
import SearchBar from "./Components/SearchBar";
5-
import StudentData from "./Data.json";
65
import PCard from "./Components/ProfileCard.js";
76
import { ThemeProvider, createTheme } from "@material-ui/core";
87
import D3Tree from "./Components/Tree";
98
import {client} from "./index.js";
10-
import {CHILDREN_QUERY, BATCH_QUERY, PATH_QUERY} from "./Queries.js";
9+
import {PATH_QUERY} from "./Queries.js";
1110

1211
function App() {
1312

@@ -21,7 +20,7 @@ function App() {
2120

2221
const [details, setDetails] = useState({ name:"name", branch:"branch", year:"year", email:"email", picture:"picture", linkedIn:"", hometown:"", coCurriculars:"", socialMedia:"", display:true});
2322
const [TreeData, setTreeData] = useState({});
24-
23+
2524
async function FetchPath(rollNo) {
2625
const response = await client.query({
2726
query: PATH_QUERY,
@@ -33,14 +32,14 @@ function App() {
3332
}
3433

3534
useEffect(() => {
36-
(FetchPath("B20AI054")).then(value => {setTreeData(value);})
35+
(FetchPath("Root"))
36+
.then(value => {setTreeData(value);})
3737
, [TreeData]})
3838

39-
4039
return (
4140
<ThemeProvider theme={theme}>
4241
<div className="App">
43-
<SearchBar placeholder="Enter the Name or Roll Number..." studentData={StudentData} />
42+
<SearchBar placeholder="Enter the Name or Roll Number..." />
4443
<div className="help">
4544
<Help />
4645
</div>

frontend/family_tree/src/Components/SearchBar.js

+22-13
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
import React, { useState } from "react";
22
import "../Styles/SearchBar.css";
33
import SearchIcon from "@material-ui/icons/Search";
4-
import CloseIcon from "@material-ui/icons/Close"
4+
import CloseIcon from "@material-ui/icons/Close";
5+
import {client} from "../index.js";
6+
import {SEARCH_QUERY} from "../Queries.js";
57

6-
function SearchBar({ placeholder, studentData }) {
7-
const [filteredData, setFilteredData] = useState([]);
8+
function SearchBar({ placeholder}) {
89
const [wordEntered, setWordEntered] = useState("");
10+
const [retrievedData, setRetrievedData] = useState([]);
11+
12+
async function FetchString(string) {
13+
const response = await client.query({
14+
query: SEARCH_QUERY,
15+
variables: {
16+
string,
17+
},
18+
})
19+
return response.data.studentSearch;
20+
}
921

1022
const handleFilter = (event) => {
1123
const searchWord = event.target.value;
1224
setWordEntered(searchWord);
1325
if (searchWord.length < 3) {
14-
setFilteredData([]);
26+
setRetrievedData([]);
1527
} else {
16-
const filteredResults = studentData.filter((query) => {
17-
return query.student.name.toLowerCase().includes(searchWord.toLowerCase()) + query.student.id.toLowerCase().includes(searchWord.toLowerCase());
18-
});
19-
setFilteredData(filteredResults);
28+
FetchString(searchWord).then(value => setRetrievedData(value));
2029
}
2130
};
2231

2332
const clearState = () => {
24-
setFilteredData([]);
33+
setRetrievedData([]);
2534
setWordEntered("");
2635
};
2736

@@ -42,11 +51,11 @@ function SearchBar({ placeholder, studentData }) {
4251
)}
4352
</div>
4453
</div>
45-
{filteredData.length !== 0 && (
54+
{retrievedData.length !== 0 && (
4655
<div className="dataResult">
47-
{filteredData.slice(0, 5).map((value) => {
56+
{retrievedData.slice(0, 5).map((value) => {
4857
return (
49-
<p className="dataItem">{`${value.student.name} (${value.student.id})`} </p>
58+
<p className="dataItem" >{`${value.name} (${value.rollNo})`} </p>
5059
);
5160
})}
5261
</div>
@@ -55,4 +64,4 @@ function SearchBar({ placeholder, studentData }) {
5564
);
5665
}
5766

58-
export default SearchBar;
67+
export default SearchBar;

frontend/family_tree/src/Components/Tree.js

+70-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as d3 from 'd3';
2-
import StudentData from "../Data1.json";
32
import React, { useLayoutEffect } from "react";
3+
import {CHILDREN_QUERY} from "../Queries.js";
4+
import {client} from "../index.js";
45

56
function D3Tree(props){
67
useLayoutEffect(() =>{
@@ -27,6 +28,16 @@ function D3Tree(props){
2728
root.x0 = height / 2;
2829
root.y0 = 0;
2930

31+
async function FetchChildren(parentId) {
32+
const response = await client.query({
33+
query: CHILDREN_QUERY,
34+
variables: {
35+
parentId,
36+
},
37+
})
38+
return response.data.children;
39+
}
40+
3041
if(root.children){
3142
root.children.forEach(collapse);}
3243
function collapse(d) {
@@ -58,6 +69,41 @@ function D3Tree(props){
5869
return "translate(" + source.x0 + "," + source.y0 + ")";
5970
})
6071
.on('click', click)
72+
.on("mouseover", function(d,node) {
73+
updateChildren(d,node)
74+
var g = d3.select(this);
75+
if(g.property("childNodes").length<3) {
76+
g.append('circle')
77+
.attr('class', 'button')
78+
.attr('fill', 'gray')
79+
.attr('r', 10)
80+
.attr("cx", -10)
81+
.attr("cy", -14);
82+
g.select('.button')
83+
.append('animate')
84+
.classed('animate', true)
85+
.attr('attributeName', 'r')
86+
.attr('values', '0;10')
87+
.attr('begin', 'indefinite')
88+
.attr('dur', '0.2s')
89+
.attr('repeatCount', 1);
90+
g.append('text')
91+
.classed('button', true)
92+
.attr('x', -16)
93+
.attr('y', -10)
94+
.text("FB")
95+
.style("border", "solid")
96+
.style("stroke", "white")
97+
.style("cursor", "pointer")
98+
.on('click', test);
99+
g._groups[0][0].getElementsByTagName("animate")[0].beginElement();
100+
}else{
101+
g.selectAll('.button').style("visibility", "visible");
102+
}
103+
})
104+
.on("mouseout", function() {
105+
d3.select(this).selectAll('.button').style("visibility", "hidden");
106+
})
61107
.on('contextmenu', function(node,d){
62108
props.setDetails({name: d.id,
63109
branch: d.data.branch,
@@ -77,6 +123,12 @@ function D3Tree(props){
77123
.attr('r', 1e-6)
78124
.style("fill", function(d) {
79125
return d._children ? "lightsteelblue" : "#fff";
126+
})
127+
.on('mouseover',(d)=>{
128+
var g=d.target.parentNode
129+
if(g.childNodes.length>3){
130+
g.getElementsByTagName("animate")[0].beginElement();
131+
}
80132
});
81133

82134
nodeEnter.append('text')
@@ -158,6 +210,10 @@ function D3Tree(props){
158210
return path;
159211
}
160212

213+
function test(){
214+
console.log("clicked");
215+
}
216+
161217
function click(d,node) {
162218
if (node.children) {
163219
node._children = node.children;
@@ -168,6 +224,19 @@ function D3Tree(props){
168224
}
169225
update(node);
170226
}
227+
228+
function updateChildren(d,node){
229+
if(!node.children && !node._children){
230+
FetchChildren(node.data.rollNo)
231+
.then(value=> {
232+
if(value.length!==0){
233+
data = data.concat(value);
234+
root = stratify(data);
235+
node._children = value;
236+
}
237+
})
238+
}
239+
}
171240
}
172241
},[])
173242

frontend/family_tree/src/Queries.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export const CHILDREN_QUERY = gql `
1414
export const BATCH_QUERY = gql `
1515
query StudentType($rollNo: String!) {
1616
studentBatch(roll: $rollNo) {
17-
id,
1817
name,
1918
rollNo,
19+
id,
2020
parentId,
2121
}
2222
}
@@ -25,10 +25,19 @@ export const BATCH_QUERY = gql `
2525
export const PATH_QUERY = gql `
2626
query StudentType($rollNo: String!) {
2727
studentPath(roll: $rollNo) {
28-
id,
2928
name,
3029
rollNo,
30+
id,
3131
parentId,
3232
}
3333
}
34+
`;
35+
36+
export const SEARCH_QUERY = gql `
37+
query StudentType($string: String!) {
38+
studentSearch(searchQuery: $string) {
39+
name,
40+
rollNo,
41+
}
42+
}
3443
`;

0 commit comments

Comments
 (0)