Browse Source

Created the organization repository table view.

pull/11/head
Jeffery Russell 5 years ago
parent
commit
e29029a1cc
3 changed files with 70 additions and 84 deletions
  1. +20
    -2
      public/OrgRepoGraph.html
  2. +19
    -82
      public/js/createOrgRepoGraph.js
  3. +31
    -0
      public/js/createOrgTable.js

+ 20
- 2
public/OrgRepoGraph.html View File

@ -17,6 +17,7 @@
<script src="js/createOrgRepoGraph.js"></script> <script src="js/createOrgRepoGraph.js"></script>
<script src="js/utilities.js"></script> <script src="js/utilities.js"></script>
<script src="js/profileGen.js"></script> <script src="js/profileGen.js"></script>
<script src="js/createOrgTable.js"></script>
<script type="text/javascript" src="js/vis/vis.js"></script> <script type="text/javascript" src="js/vis/vis.js"></script>
<link href="js/vis/vis-network.min.css" rel="stylesheet" type="text/css" /> <link href="js/vis/vis-network.min.css" rel="stylesheet" type="text/css" />
@ -57,11 +58,28 @@
<div class="col-md-2 col-12"> <div class="col-md-2 col-12">
<div id="profileGen"></div> <div id="profileGen"></div>
</div> </div>
<div class="col-md-8 col-12">
<div class="col-md-6 col-12">
<h2 id="graphLabel"></h2> <h2 id="graphLabel"></h2>
<div id="myGraph" class="w-100"></div> <div id="myGraph" class="w-100"></div>
<pre id="eventSpan"></pre> <pre id="eventSpan"></pre>
</div> </div>
<div class="col-md-4 col-12 bg-light">
<div class="w-100"></div>
<center><h1>Repositories</h1></center>
<table class="table table-striped" id="dataTable">
<thead class="thead-dark">
<tr>
<td>Name</td>
<td>Forks</td>
<td>Language</td>
</tr>
</thead>
<tbody id="repositoryTable">
</tbody>
</table>
</div>
</div> </div>
<script> <script>
@ -71,7 +89,7 @@
options.height = "700px"; options.height = "700px";
createOrgRepoGraph(orgname, "myGraph", "graphLoading"); createOrgRepoGraph(orgname, "myGraph", "graphLoading");
//orgRepoGen(orgname, "orgRepoGen");
createOrgTable(orgname, 'repositoryTable');
} }
if(findGetParameter("name") !== null) { if(findGetParameter("name") !== null) {

+ 19
- 82
public/js/createOrgRepoGraph.js View File

@ -43,37 +43,6 @@ function alreadyInGraph(userID)
} }
/**
* adds a person to the nodes list
*
* @param profileData
*/
function addSelfAsOrg(orgData) {
nodes.push( {
id:0,
name:orgData.login,
image:orgData.avatar_url,
background: '#eeeeee',
size:100,
label: orgData.name,
});
console.log(orgData.name);
}
function addSelfAsRepo(repoData) {
nodes.push( {
id:repoData.id,
name:repoData.name,
label: repoData.name,
});
edges.push(
{
to: 0,
from: repoData.id
});
}
/** /**
* Adds the followers/following of a person * Adds the followers/following of a person
@ -262,33 +231,6 @@ function updateProgress()
console.log(); console.log();
} }
/**
* Adds the base person to the graph.
*
* @param username
* @returns {Promise<any>}
*/
function addOrgToGraph(orgname) {
return new Promise(function(resolve, reject) {
queryAPIByOrg("", orgname, function(data) {
total = (data.public_repos) * 2;
addSelfAsOrg(data);
resolve();
},
function(error) {
reject(error);
});
});
}
function addRepoToGraph(repo) {
return new Promise(function(resolve, reject) {
console.log(repo);
addSelfAsRepo(repo);
resolve();
});
}
function bringUpProfileView(id) function bringUpProfileView(id)
@ -377,31 +319,26 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle)
nodes = []; nodes = [];
edges = []; edges = [];
addOrgToGraph(orgname).then(function() {
addRepos(orgname, API_REPOS,1).then(function()
{
addOrgUsers(orgname, 1).then(function()
{
$("#" + progressID).html("");
createConnections().then( () => {
var container = document.getElementById(containerName);
var data = {
nodes: nodes,
edges: edges
};
var network = new vis.Network(container, data, options);
network.on("click", function (params) {
params.event = "[original event]";
if(Number(this.getNodeAt(params.pointer.DOM)) !== NaN) {
bringUpProfileView(Number(this.getNodeAt(params.pointer.DOM)));
}
});
});
addOrgUsers(orgname, 1).then(function()
{
$("#" + progressID).html("");
createConnections().then( () => {
var container = document.getElementById(containerName);
var data = {
nodes: nodes,
edges: edges
};
var network = new vis.Network(container, data, options);
network.on("click", function (params) {
params.event = "[original event]";
if(Number(this.getNodeAt(params.pointer.DOM)) !== NaN) {
bringUpProfileView(Number(this.getNodeAt(params.pointer.DOM)));
}
}); });
})
});
}).catch(function(error) { }).catch(function(error) {
alert("Invalid Organization"); alert("Invalid Organization");
}); });

+ 31
- 0
public/js/createOrgTable.js View File

@ -0,0 +1,31 @@
function generateHtmlRow(repoData)
{
var html = "<tr class=\"table_row\">";
html+="<td><a href='" + repoData.url + "'>" + repoData.name + "</a></td>";
html+="<td>" + repoData.forks + "</td>";
html+="<td>" + repoData.language + "</td>";
html +="</tr>";
return html;
}
function createOrgTable(orgName, tableContainer)
{
var html = "";
queryAPIByOrg(API_REPOSITORIES, orgName,
function(data)
{
for(var i=0; i < data.length; i++)
{
html += generateHtmlRow(data[i]);
}
$("#" + tableContainer).html(html);
},
function(error)
{
console.log("Unable to load table data");
});
}

Loading…
Cancel
Save