@@ -43,47 +43,6 @@ function alreadyInGraph(userID)
4343}
4444
4545
46-
47- /**
48- * Adds the followers/following of a person
49- * to the graph
50- *
51- * @param username
52- * @param apiPath
53- * @returns {Promise<any> }
54- */
55- function addRepos ( orgName , apiPath , page )
56- {
57- console . log ( orgName + " page=" + page ) ;
58- updateProgress ( ) ;
59- return new Promise ( function ( resolve , reject ) {
60- queryAPIByOrg ( apiPath + "?page=" + page , orgName , function ( data ) {
61- console . log ( data ) ;
62- console . log ( data . length ) ;
63- var prom = [ ] ;
64- for ( var i = 0 ; i < data . length ; i ++ ) {
65- if ( ! alreadyInGraph ( data [ i ] . id ) ) {
66- prom . push ( addRepoToGraph ( data [ i ] ) ) ;
67- }
68- }
69- Promise . all ( prom ) . then ( ( ) => {
70- if ( data . length === 30 ) {
71- addRepos ( orgName , apiPath , page + 1 ) . then ( function ( ) {
72- resolve ( ) ;
73- } )
74- }
75- else {
76- resolve ( ) ;
77- }
78- } )
79- } ,
80- function ( error ) {
81- reject ( error ) ;
82- } )
83- } ) ;
84- }
85-
86-
8746/**
8847 * Greedy function which checks to see if a edge is in the graphs
8948 *
@@ -173,11 +132,11 @@ function processUserConnections(user)
173132{
174133 return new Promise ( function ( resolve , reject )
175134 {
176-
177135 processConnections ( user , API_FOLLOWING , 1 ) . then ( function ( )
178136 {
179137 processConnections ( user , API_FOLLOWERS , 1 ) . then ( function ( )
180138 {
139+ updateProgress ( ) ;
181140 resolve ( ) ;
182141 } )
183142 } )
@@ -213,26 +172,6 @@ function createConnections()
213172}
214173
215174
216- var total = 1 ;
217- var indexed = 0 ;
218- var progressID ;
219-
220-
221- function updateProgress ( )
222- {
223- indexed ++ ;
224-
225- var percent = parseInt ( ( indexed / total ) * 100 ) ;
226-
227- $ ( "#" + progressID ) . html ( "<div class=\"progress\">\n" +
228- " <div class=\"progress-bar progress-bar-striped progress-bar-animated\" role=\"progressbar\" style=\"width: " + percent + "%\" aria-valuenow=\"" + percent + "\" aria-valuemin=\"0\" aria-valuemax=\"100\"></div>\n" +
229- "</div>" ) ;
230-
231- console . log ( ) ;
232- }
233-
234-
235-
236175function bringUpProfileView ( id )
237176{
238177 for ( var i = 0 ; i < nodes . length ; i ++ )
@@ -285,6 +224,7 @@ function addOrgUsers(orgname, page)
285224 }
286225 else
287226 {
227+ total = 2 * ( data . length + ( page * 30 ) ) ;
288228 resolve ( ) ;
289229 }
290230
@@ -307,6 +247,23 @@ function bringUpProfileView(id)
307247 }
308248}
309249
250+
251+ var total = 1 ;
252+ var indexed = 0 ;
253+
254+ function updateProgress ( )
255+ {
256+ indexed ++ ;
257+
258+ var percent = parseInt ( ( indexed / total ) * 100 ) ;
259+
260+ $ ( "#graphLoading" ) . html ( "<div class=\"progress\">\n" +
261+ " <div class=\"progress-bar progress-bar-striped progress-bar-animated\" role=\"progressbar\" style=\"width: " + percent + "%\" aria-valuenow=\"" + percent + "\" aria-valuemin=\"0\" aria-valuemax=\"100\"></div>\n" +
262+ "</div>" ) ;
263+
264+ console . log ( ) ;
265+ }
266+
310267/**
311268 * Creates a graph
312269 * @param username
@@ -322,7 +279,6 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle)
322279
323280 addOrgUsers ( orgname , 1 ) . then ( function ( )
324281 {
325- $ ( "#" + progressID ) . html ( "" ) ;
326282
327283 createConnections ( ) . then ( ( ) => {
328284 var container = document . getElementById ( containerName ) ;
@@ -331,13 +287,14 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle)
331287 edges : edges
332288 } ;
333289 var network = new vis . Network ( container , data , options ) ;
334-
335290 network . on ( "click" , function ( params ) {
336291 params . event = "[original event]" ;
337292 if ( Number ( this . getNodeAt ( params . pointer . DOM ) ) !== NaN ) {
338293 bringUpProfileView ( Number ( this . getNodeAt ( params . pointer . DOM ) ) ) ;
339294 }
340295 } ) ;
296+
297+ $ ( "#graphLoading" ) . html ( "" ) ;
341298 } ) ;
342299 } ) . catch ( function ( error ) {
343300 alert ( "Invalid Organization" ) ;
0 commit comments