From 8741b6b85d1f3586fe564ff7fe144c908f1f43d8 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Sat, 16 Feb 2019 22:02:21 -0500 Subject: [PATCH] Got the repository time line working and pretty. --- public/TimeLineGraph.html | 14 ++++- public/js/profileTimeLine.js | 111 ++++++++++++++++++++++++++++++++--- 2 files changed, 116 insertions(+), 9 deletions(-) diff --git a/public/TimeLineGraph.html b/public/TimeLineGraph.html index 9c70585..ca3f301 100644 --- a/public/TimeLineGraph.html +++ b/public/TimeLineGraph.html @@ -67,6 +67,14 @@ border-width: 2px; border-color: #0B002B; } + + .containerCustom { + width: 100%; + padding-right: 0px; + padding-left: 0px; + margin-right: 0px; + margin-left: 0px; + } @@ -96,7 +104,7 @@ -
+
-
+


+
+            
diff --git a/public/js/profileTimeLine.js b/public/js/profileTimeLine.js index 477e516..ab48659 100644 --- a/public/js/profileTimeLine.js +++ b/public/js/profileTimeLine.js @@ -1,36 +1,132 @@ var events = []; +var repositoryData; + + +function addEvent(group, date, content) +{ + var dateFormat = new Date(date); + var dd = new Date(dateFormat.getFullYear(), dateFormat.getMonth(), dateFormat.getDay()); + events.push({id: events.length, group: group, start: dd, content: content}); +} + // {id: 0, group: 0, start: new Date(2013,7,1), end: new Date(2017,5,15), content: 'High School'}, function addRepositories(userName, groupID) { return new Promise(function(resolve, reject) { - + queryAPIByUser(API_REPOSITORIES, userName, + function(data) + { + repositoryData = data; + for(var i = 0; i < data.length; i++) + { + data[i].id = events.length; + addEvent(groupID, data[i]['created_at'], data[i]['name']) + } + resolve(); + }, + function(error) + { + console.log(error); + reject(error); + }) }) } -function addOrgs(userName, groupID) +function timeLineClickEvent(properties) { - return new Promise(function(resolve, reject) + if(properties.item !== null && typeof repositoryData[properties.item].name !== 'undefined') { + var item = repositoryData[properties.item]; - }) -} + var html = "
\n" + + "
\n" + + item.name + + "
\n" + + "
\n"; + + html += "

" + item.description + "

"; + + console.log(item.license); + if(item.license === null) + { + item.license = new Object(); + item.license.name = 'none'; + } + html += "
\n" + + "
    \n" + + "
  • \n" + + "
    Fork Count
    \n" + + "
    " + + item.forks + + "
    \n" + + "
  • \n" + + "
  • \n" + + "
    Languages
    \n" + + "
    " + + item.language+ + "
    \n" + + "
  • \n" + + "
  • \n" + + "
    Liscense
    \n" + + "
    " + + item.license.name + + "
    \n" + + "
  • \n" + + "
  • \n" + + "
    Home Page
    \n" + + "
    " + + "" +item.homepage + "" + + "
    \n" + + "
  • \n" + + "
\n" + + "
"; + + html += "
\n" + + "
    \n" + + "
  • \n" + + "
    Repository URL
    \n" + + "
    " + + "" +item.html_url + "" + + "
    \n" + + "
  • \n" + + "
  • \n" + + "
    Open Issues
    \n" + + "
    " + + item.open_issues_count + + "
    \n" + + "
  • \n" + + "
  • \n" + + "
    Watchers
    \n" + + "
    " + + item.watchers + + "
    \n" + + "
  • \n" + + "
\n" + + "
"; + + html +="
\n" + + "
"; + + $("#repositoryInformation").html(html); + } +} function createProfileTimeLine(username, containerName) { var container = document.getElementById(containerName); - var prom = [addRepositories(username, 1), addOrgs(username, 1)]; + var prom = [addRepositories(username, 1)]; var groups = new vis.DataSet([ - {id: 0, content: 'Organizations', value: 1}, {id: 1, content: 'Repositories', value: 2} ]); + console.log("up up duper"); Promise.all(prom).then(function() { // note that months are zero-based in the JavaScript Date object @@ -53,5 +149,6 @@ function createProfileTimeLine(username, containerName) timeline.setOptions(options); timeline.setGroups(groups); timeline.setItems(items); + timeline.on('click', timeLineClickEvent); }); } \ No newline at end of file