Browse Source

Added users to the org view and connected all the repositories in the org to the org.

pull/11/head
Jeffery Russell 5 years ago
parent
commit
81168d2099
2 changed files with 86 additions and 19 deletions
  1. +83
    -18
      public/js/createOrgRepoGraph.js
  2. +3
    -1
      public/js/githubAPI.js

+ 83
- 18
public/js/createOrgRepoGraph.js View File

@ -50,7 +50,7 @@ function alreadyInGraph(userID)
*/ */
function addSelfAsOrg(orgData) { function addSelfAsOrg(orgData) {
nodes.push( { nodes.push( {
id:orgData.id,
id:0,
name:orgData.login, name:orgData.login,
image:orgData.avatar_url, image:orgData.avatar_url,
background: '#eeeeee', background: '#eeeeee',
@ -66,6 +66,12 @@ function addSelfAsRepo(repoData) {
name:repoData.name, name:repoData.name,
label: repoData.name, label: repoData.name,
}); });
edges.push(
{
to: 0,
from: repoData.id
});
} }
@ -295,6 +301,61 @@ function bringUpProfileView(id)
} }
} }
function addOrgUserToGraph(profileData)
{
nodes.push(
{
id:profileData.id,
name:profileData.login,
shape: 'circularImage',
image:profileData.avatar_url
});
}
function connectOrgUsers()
{
return new Promise(function(resolve, reject)
{
resolve();
})
}
function addOrgUsers(orgname, page)
{
return new Promise(function(resolve, reject)
{
queryAPIByOrg(API_ORG_MEMBERS + "?page=" + page, orgname, function(data)
{
for(var i = 0;i < data.length; i++)
{
addOrgUserToGraph(data[i]);
}
if(data.length === 30)
{
addOrgUsers(orgname, page + 1).then(function()
{
resolve();
});
}
else
{
resolve();
}
}, function(error)
{
console.log(error);
resolve();
})
})
}
/** /**
* Creates a graph * Creates a graph
* @param username * @param username
@ -308,24 +369,28 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle)
nodes = []; nodes = [];
edges = []; edges = [];
addOrgToGraph(orgname).then(function() { addOrgToGraph(orgname).then(function() {
addRepos(orgname, API_REPOS,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)));
}
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)));
}
});
}); });
})
});
}) })
}).catch(function(error) { }).catch(function(error) {

+ 3
- 1
public/js/githubAPI.js View File

@ -13,7 +13,9 @@ const API_USER_PATH = "/users/";
const API_ORG_PATH = "/orgs/"; const API_ORG_PATH = "/orgs/";
const API_REPOS = "/repos/";
const API_ORG_MEMBERS = "/members";
const API_REPOS = "/repos";
const API_FOLLOWING = "/following"; const API_FOLLOWING = "/following";

Loading…
Cancel
Save