From e29029a1cc22adf91933a62fff81da0a549e0185 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 17 Feb 2019 06:20:12 -0500 Subject: [PATCH 1/4] Created the organization repository table view. --- public/OrgRepoGraph.html | 22 ++++++- public/js/createOrgRepoGraph.js | 101 ++++++-------------------------- public/js/createOrgTable.js | 31 ++++++++++ 3 files changed, 70 insertions(+), 84 deletions(-) create mode 100644 public/js/createOrgTable.js diff --git a/public/OrgRepoGraph.html b/public/OrgRepoGraph.html index 793dd8a..4db0b13 100644 --- a/public/OrgRepoGraph.html +++ b/public/OrgRepoGraph.html @@ -17,6 +17,7 @@ + @@ -57,11 +58,28 @@
-
+


             
+
+
+

Repositories

+ + + + + + + + + + + +
NameForksLanguage
+ +
+ + + + + diff --git a/public/js/createOrgTable.js b/public/js/createOrgTable.js index 35fb89a..fd3085e 100644 --- a/public/js/createOrgTable.js +++ b/public/js/createOrgTable.js @@ -22,6 +22,8 @@ function createOrgTable(orgName, tableContainer) } $("#" + tableContainer).html(html); + $('#dataTable').DataTable(); + }, function(error) { From 5c00be042c2867bfbf14ea7d6de52f36dab6cf95 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 17 Feb 2019 06:49:14 -0500 Subject: [PATCH 3/4] Improved loading bar of the graphs. --- public/OrgRepoGraph.html | 2 +- public/js/createOrgRepoGraph.js | 44 ++++++++++++++++----------------- public/js/friendsGraph.js | 4 +-- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/public/OrgRepoGraph.html b/public/OrgRepoGraph.html index bc566d3..20f53ea 100644 --- a/public/OrgRepoGraph.html +++ b/public/OrgRepoGraph.html @@ -64,7 +64,7 @@
-

+

             
diff --git a/public/js/createOrgRepoGraph.js b/public/js/createOrgRepoGraph.js index 107d51a..b5626e1 100644 --- a/public/js/createOrgRepoGraph.js +++ b/public/js/createOrgRepoGraph.js @@ -173,11 +173,11 @@ function processUserConnections(user) { return new Promise(function(resolve, reject) { - processConnections(user, API_FOLLOWING, 1).then(function() { processConnections(user, API_FOLLOWERS, 1).then(function() { + updateProgress(); resolve(); }) }) @@ -213,26 +213,6 @@ function createConnections() } -var total = 1; -var indexed = 0; -var progressID; - - -function updateProgress() -{ - indexed++; - - var percent = parseInt((indexed/total)*100); - - $("#" + progressID).html("
\n" + - "
\n" + - "
"); - - console.log(); -} - - - function bringUpProfileView(id) { for(var i = 0; i < nodes.length; i++) @@ -285,6 +265,7 @@ function addOrgUsers(orgname, page) } else { + total = 2*(data.length + (page * 30)); resolve(); } @@ -307,6 +288,23 @@ function bringUpProfileView(id) } } + +var total = 1; +var indexed = 0; + +function updateProgress() +{ + indexed++; + + var percent = parseInt((indexed/total)*100); + + $("#graphLoading").html("
\n" + + "
\n" + + "
"); + + console.log(); +} + /** * Creates a graph * @param username @@ -322,7 +320,6 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle) addOrgUsers(orgname, 1).then(function() { - $("#" + progressID).html(""); createConnections().then( () => { var container = document.getElementById(containerName); @@ -331,13 +328,14 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle) 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))); } }); + + $("#graphLoading").html(""); }); }).catch(function(error) { alert("Invalid Organization"); diff --git a/public/js/friendsGraph.js b/public/js/friendsGraph.js index 6669834..48552f2 100644 --- a/public/js/friendsGraph.js +++ b/public/js/friendsGraph.js @@ -151,7 +151,6 @@ function addConnection(person1, person2) function processConnections(user, apiPoint, page) { - updateProgress(); return new Promise(function(resolve, reject) { queryAPIByUser(apiPoint + "?page=" + page, user.name, @@ -196,6 +195,7 @@ function processUserConnections(user) { processConnections(user, API_FOLLOWERS, 1).then(function() { + updateProgress(); resolve(); }) }) @@ -261,7 +261,7 @@ function addSelfToGraph(username) { queryAPIByUser("", username, function(data) { - total = (data.followers + data.following) * 2; + total = (data.followers + data.following); addPersonToGraph(data); resolve(); }, From 8d1b70bd1a03ed05b0f47fb39691962eb1f7d7b9 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sun, 17 Feb 2019 07:21:38 -0500 Subject: [PATCH 4/4] Fixed how the repository list was being generated for the organizations. --- public/js/createOrgRepoGraph.js | 41 ------------------------ public/js/createOrgTable.js | 55 ++++++++++++++++++++++++--------- public/js/friendsGraph.js | 5 --- 3 files changed, 41 insertions(+), 60 deletions(-) diff --git a/public/js/createOrgRepoGraph.js b/public/js/createOrgRepoGraph.js index b5626e1..aac0b4f 100644 --- a/public/js/createOrgRepoGraph.js +++ b/public/js/createOrgRepoGraph.js @@ -43,47 +43,6 @@ function alreadyInGraph(userID) } - -/** - * Adds the followers/following of a person - * to the graph - * - * @param username - * @param apiPath - * @returns {Promise} - */ -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 * diff --git a/public/js/createOrgTable.js b/public/js/createOrgTable.js index fd3085e..321818f 100644 --- a/public/js/createOrgTable.js +++ b/public/js/createOrgTable.js @@ -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"); + }); } \ No newline at end of file diff --git a/public/js/friendsGraph.js b/public/js/friendsGraph.js index 48552f2..32bcc63 100644 --- a/public/js/friendsGraph.js +++ b/public/js/friendsGraph.js @@ -66,14 +66,11 @@ function addPersonToGraph(profileData) */ function addFriends(username, apiPath, page) { - console.log(username + " page=" + page); updateProgress(); return new Promise(function(resolve, reject) { queryAPIByUser(apiPath + "?page=" + page, username, function(data) { - console.log(data); - console.log(data.length); for(var i = 0; i < data.length; i++) { if(!alreadyInGraph(data[i].id)) @@ -111,7 +108,6 @@ function addFriends(username, apiPath, page) */ function edgeInGraph(id1, id2) { - console.log("edge check"); for(var i = 0;i < edges.length; i++) { if(edges[i].from === id1 && edges[i].to === id2) @@ -305,7 +301,6 @@ function createFriendsGraph(username, containerName, graphsTitle) { createConnections().then(function() { - console.log("cleared div"); $("#" + progressID).html(""); var container = document.getElementById(containerName);