Skip to content

Commit 5c00be0

Browse files
committed
Improved loading bar of the graphs.
1 parent 5a2a0ac commit 5c00be0

3 files changed

Lines changed: 24 additions & 26 deletions

File tree

public/OrgRepoGraph.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<div id="profileGen"></div>
6565
</div>
6666
<div class="col-md-6 col-12">
67-
<h2 id="graphLabel"></h2>
67+
<div id="graphLoading"></div>
6868
<div id="myGraph" class="w-100"></div>
6969
<pre id="eventSpan"></pre>
7070
</div>

public/js/createOrgRepoGraph.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ function processUserConnections(user)
173173
{
174174
return new Promise(function(resolve, reject)
175175
{
176-
177176
processConnections(user, API_FOLLOWING, 1).then(function()
178177
{
179178
processConnections(user, API_FOLLOWERS, 1).then(function()
180179
{
180+
updateProgress();
181181
resolve();
182182
})
183183
})
@@ -213,26 +213,6 @@ function createConnections()
213213
}
214214

215215

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-
236216
function bringUpProfileView(id)
237217
{
238218
for(var i = 0; i < nodes.length; i++)
@@ -285,6 +265,7 @@ function addOrgUsers(orgname, page)
285265
}
286266
else
287267
{
268+
total = 2*(data.length + (page * 30));
288269
resolve();
289270
}
290271

@@ -307,6 +288,23 @@ function bringUpProfileView(id)
307288
}
308289
}
309290

291+
292+
var total = 1;
293+
var indexed = 0;
294+
295+
function updateProgress()
296+
{
297+
indexed++;
298+
299+
var percent = parseInt((indexed/total)*100);
300+
301+
$("#graphLoading").html("<div class=\"progress\">\n" +
302+
" <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" +
303+
"</div>");
304+
305+
console.log();
306+
}
307+
310308
/**
311309
* Creates a graph
312310
* @param username
@@ -322,7 +320,6 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle)
322320

323321
addOrgUsers(orgname, 1).then(function()
324322
{
325-
$("#" + progressID).html("");
326323

327324
createConnections().then( () => {
328325
var container = document.getElementById(containerName);
@@ -331,13 +328,14 @@ function createOrgRepoGraph(orgname, containerName, graphsTitle)
331328
edges: edges
332329
};
333330
var network = new vis.Network(container, data, options);
334-
335331
network.on("click", function (params) {
336332
params.event = "[original event]";
337333
if(Number(this.getNodeAt(params.pointer.DOM)) !== NaN) {
338334
bringUpProfileView(Number(this.getNodeAt(params.pointer.DOM)));
339335
}
340336
});
337+
338+
$("#graphLoading").html("");
341339
});
342340
}).catch(function(error) {
343341
alert("Invalid Organization");

public/js/friendsGraph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ function addConnection(person1, person2)
151151

152152
function processConnections(user, apiPoint, page)
153153
{
154-
updateProgress();
155154
return new Promise(function(resolve, reject)
156155
{
157156
queryAPIByUser(apiPoint + "?page=" + page, user.name,
@@ -196,6 +195,7 @@ function processUserConnections(user)
196195
{
197196
processConnections(user, API_FOLLOWERS, 1).then(function()
198197
{
198+
updateProgress();
199199
resolve();
200200
})
201201
})
@@ -261,7 +261,7 @@ function addSelfToGraph(username)
261261
{
262262
queryAPIByUser("", username, function(data)
263263
{
264-
total = (data.followers + data.following) * 2;
264+
total = (data.followers + data.following);
265265
addPersonToGraph(data);
266266
resolve();
267267
},

0 commit comments

Comments
 (0)