Skip to content

Commit e29029a

Browse files
committed
Created the organization repository table view.
1 parent 8cb2f55 commit e29029a

3 files changed

Lines changed: 70 additions & 84 deletions

File tree

public/OrgRepoGraph.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<script src="js/createOrgRepoGraph.js"></script>
1818
<script src="js/utilities.js"></script>
1919
<script src="js/profileGen.js"></script>
20+
<script src="js/createOrgTable.js"></script>
2021

2122
<script type="text/javascript" src="js/vis/vis.js"></script>
2223
<link href="js/vis/vis-network.min.css" rel="stylesheet" type="text/css" />
@@ -57,11 +58,28 @@
5758
<div class="col-md-2 col-12">
5859
<div id="profileGen"></div>
5960
</div>
60-
<div class="col-md-8 col-12">
61+
<div class="col-md-6 col-12">
6162
<h2 id="graphLabel"></h2>
6263
<div id="myGraph" class="w-100"></div>
6364
<pre id="eventSpan"></pre>
6465
</div>
66+
<div class="col-md-4 col-12 bg-light">
67+
<div class="w-100"></div>
68+
<center><h1>Repositories</h1></center>
69+
<table class="table table-striped" id="dataTable">
70+
<thead class="thead-dark">
71+
<tr>
72+
<td>Name</td>
73+
<td>Forks</td>
74+
<td>Language</td>
75+
</tr>
76+
</thead>
77+
<tbody id="repositoryTable">
78+
79+
</tbody>
80+
</table>
81+
82+
</div>
6583
</div>
6684

6785
<script>
@@ -71,7 +89,7 @@ <h2 id="graphLabel"></h2>
7189
options.height = "700px";
7290

7391
createOrgRepoGraph(orgname, "myGraph", "graphLoading");
74-
//orgRepoGen(orgname, "orgRepoGen");
92+
createOrgTable(orgname, 'repositoryTable');
7593
}
7694

7795
if(findGetParameter("name") !== null) {

public/js/createOrgRepoGraph.js

Lines changed: 19 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,6 @@ function alreadyInGraph(userID)
4343
}
4444

4545

46-
/**
47-
* adds a person to the nodes list
48-
*
49-
* @param profileData
50-
*/
51-
function addSelfAsOrg(orgData) {
52-
nodes.push( {
53-
id:0,
54-
name:orgData.login,
55-
image:orgData.avatar_url,
56-
background: '#eeeeee',
57-
size:100,
58-
label: orgData.name,
59-
});
60-
console.log(orgData.name);
61-
}
62-
63-
function addSelfAsRepo(repoData) {
64-
nodes.push( {
65-
id:repoData.id,
66-
name:repoData.name,
67-
label: repoData.name,
68-
});
69-
70-
edges.push(
71-
{
72-
to: 0,
73-
from: repoData.id
74-
});
75-
}
76-
7746

7847
/**
7948
* Adds the followers/following of a person
@@ -262,33 +231,6 @@ function updateProgress()
262231
console.log();
263232
}
264233

265-
/**
266-
* Adds the base person to the graph.
267-
*
268-
* @param username
269-
* @returns {Promise<any>}
270-
*/
271-
function addOrgToGraph(orgname) {
272-
return new Promise(function(resolve, reject) {
273-
queryAPIByOrg("", orgname, function(data) {
274-
total = (data.public_repos) * 2;
275-
addSelfAsOrg(data);
276-
resolve();
277-
},
278-
function(error) {
279-
reject(error);
280-
});
281-
282-
});
283-
}
284-
285-
function addRepoToGraph(repo) {
286-
return new Promise(function(resolve, reject) {
287-
console.log(repo);
288-
addSelfAsRepo(repo);
289-
resolve();
290-
});
291-
}
292234

293235

294236
function bringUpProfileView(id)
@@ -377,31 +319,26 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle)
377319

378320
nodes = [];
379321
edges = [];
380-
addOrgToGraph(orgname).then(function() {
381-
addRepos(orgname, API_REPOS,1).then(function()
382-
{
383-
addOrgUsers(orgname, 1).then(function()
384-
{
385-
$("#" + progressID).html("");
386-
387-
createConnections().then( () => {
388-
var container = document.getElementById(containerName);
389-
var data = {
390-
nodes: nodes,
391-
edges: edges
392-
};
393-
var network = new vis.Network(container, data, options);
394-
395-
network.on("click", function (params) {
396-
params.event = "[original event]";
397-
if(Number(this.getNodeAt(params.pointer.DOM)) !== NaN) {
398-
bringUpProfileView(Number(this.getNodeAt(params.pointer.DOM)));
399-
}
400-
});
401-
});
322+
323+
addOrgUsers(orgname, 1).then(function()
324+
{
325+
$("#" + progressID).html("");
326+
327+
createConnections().then( () => {
328+
var container = document.getElementById(containerName);
329+
var data = {
330+
nodes: nodes,
331+
edges: edges
332+
};
333+
var network = new vis.Network(container, data, options);
334+
335+
network.on("click", function (params) {
336+
params.event = "[original event]";
337+
if(Number(this.getNodeAt(params.pointer.DOM)) !== NaN) {
338+
bringUpProfileView(Number(this.getNodeAt(params.pointer.DOM)));
339+
}
402340
});
403-
404-
})
341+
});
405342
}).catch(function(error) {
406343
alert("Invalid Organization");
407344
});

public/js/createOrgTable.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function generateHtmlRow(repoData)
2+
{
3+
var html = "<tr class=\"table_row\">";
4+
html+="<td><a href='" + repoData.url + "'>" + repoData.name + "</a></td>";
5+
html+="<td>" + repoData.forks + "</td>";
6+
html+="<td>" + repoData.language + "</td>";
7+
html +="</tr>";
8+
return html;
9+
}
10+
11+
12+
function createOrgTable(orgName, tableContainer)
13+
{
14+
var html = "";
15+
16+
queryAPIByOrg(API_REPOSITORIES, orgName,
17+
function(data)
18+
{
19+
for(var i=0; i < data.length; i++)
20+
{
21+
html += generateHtmlRow(data[i]);
22+
}
23+
24+
$("#" + tableContainer).html(html);
25+
},
26+
function(error)
27+
{
28+
console.log("Unable to load table data");
29+
});
30+
31+
}

0 commit comments

Comments
 (0)