Browse Source

Fixed how the repository list was being generated for the organizations.

pull/11/head
Jeffery Russell 5 years ago
parent
commit
8d1b70bd1a
3 changed files with 41 additions and 60 deletions
  1. +0
    -41
      public/js/createOrgRepoGraph.js
  2. +41
    -14
      public/js/createOrgTable.js
  3. +0
    -5
      public/js/friendsGraph.js

+ 0
- 41
public/js/createOrgRepoGraph.js View File

@ -43,47 +43,6 @@ function alreadyInGraph(userID)
} }
/**
* Adds the followers/following of a person
* to the graph
*
* @param username
* @param apiPath
* @returns {Promise<any>}
*/
function addRepos(orgName, apiPath, page)
{
console.log(orgName + " page=" + page);
updateProgress();
return new Promise(function(resolve, reject) {
queryAPIByOrg(apiPath + "?page=" + page, orgName, function(data) {
console.log(data);
console.log(data.length);
var prom = [];
for(var i = 0; i < data.length; i++) {
if(!alreadyInGraph(data[i].id)) {
prom.push(addRepoToGraph(data[i]));
}
}
Promise.all(prom).then( () => {
if(data.length === 30) {
addRepos(orgName, apiPath, page+ 1).then(function() {
resolve();
})
}
else {
resolve();
}
})
},
function(error) {
reject(error);
})
});
}
/** /**
* Greedy function which checks to see if a edge is in the graphs * Greedy function which checks to see if a edge is in the graphs
* *

+ 41
- 14
public/js/createOrgTable.js View File

@ -9,25 +9,52 @@ function generateHtmlRow(repoData)
} }
function createOrgTable(orgName, tableContainer)
var repos = [];
function fetchAllRepositories(orgName, page)
{ {
var html = "";
return new Promise(function(resolve, reject)
{
queryAPIByOrg(API_REPOSITORIES + "?page=" + page, orgName,
function(data)
{
repos.push(...data);
queryAPIByOrg(API_REPOSITORIES, orgName,
function(data)
{
for(var i=0; i < data.length; i++)
if (data.length === 30)
{
fetchAllRepositories(orgName, page + 1).then(function ()
{
resolve();
})
}
else {
resolve();
}
},
function(error)
{ {
html += generateHtmlRow(data[i]);
}
//console.log("Unable to load table data");
});
});
}
function createOrgTable(orgName, tableContainer)
{
var html = "";
$("#" + tableContainer).html(html);
$('#dataTable').DataTable();
},
function(error)
fetchAllRepositories(orgName, 1).then(function()
{
for(var i=0; i < repos.length; i++)
{ {
console.log("Unable to load table data");
});
html += generateHtmlRow(repos[i]);
}
$("#" + tableContainer).html(html);
$('#dataTable').DataTable();
}).catch(function(error)
{
//console.log("Unable to create table");
});
} }

+ 0
- 5
public/js/friendsGraph.js View File

@ -66,14 +66,11 @@ function addPersonToGraph(profileData)
*/ */
function addFriends(username, apiPath, page) function addFriends(username, apiPath, page)
{ {
console.log(username + " page=" + page);
updateProgress(); updateProgress();
return new Promise(function(resolve, reject) return new Promise(function(resolve, reject)
{ {
queryAPIByUser(apiPath + "?page=" + page, username, function(data) queryAPIByUser(apiPath + "?page=" + page, username, function(data)
{ {
console.log(data);
console.log(data.length);
for(var i = 0; i < data.length; i++) for(var i = 0; i < data.length; i++)
{ {
if(!alreadyInGraph(data[i].id)) if(!alreadyInGraph(data[i].id))
@ -111,7 +108,6 @@ function addFriends(username, apiPath, page)
*/ */
function edgeInGraph(id1, id2) function edgeInGraph(id1, id2)
{ {
console.log("edge check");
for(var i = 0;i < edges.length; i++) for(var i = 0;i < edges.length; i++)
{ {
if(edges[i].from === id1 && edges[i].to === id2) if(edges[i].from === id1 && edges[i].to === id2)
@ -305,7 +301,6 @@ function createFriendsGraph(username, containerName, graphsTitle)
{ {
createConnections().then(function() createConnections().then(function()
{ {
console.log("cleared div");
$("#" + progressID).html(""); $("#" + progressID).html("");
var container = document.getElementById(containerName); var container = document.getElementById(containerName);

Loading…
Cancel
Save