Browse Source

Got the repository time line working and pretty.

pull/11/head
Jeffery Russell 5 years ago
parent
commit
8741b6b85d
2 changed files with 116 additions and 9 deletions
  1. +12
    -2
      public/TimeLineGraph.html
  2. +104
    -7
      public/js/profileTimeLine.js

+ 12
- 2
public/TimeLineGraph.html View File

@ -67,6 +67,14 @@
border-width: 2px; border-width: 2px;
border-color: #0B002B; border-color: #0B002B;
} }
.containerCustom {
width: 100%;
padding-right: 0px;
padding-left: 0px;
margin-right: 0px;
margin-left: 0px;
}
</style> </style>
</head> </head>
<body> <body>
@ -96,7 +104,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="main container">
<div class="containerCustom">
<div class="row align-center" id="searchBarTop"> <div class="row align-center" id="searchBarTop">
<nav class="navbar navbar-light bg-light justify-content-between"> <nav class="navbar navbar-light bg-light justify-content-between">
@ -108,11 +116,13 @@
</nav> </nav>
</div> </div>
<div class="row">
<div class="row containerCustom">
<div class="col-md-10 col-12"> <div class="col-md-10 col-12">
<h2 id="graphLabel"></h2> <h2 id="graphLabel"></h2>
<div id="myGraph" class="w-100"></div> <div id="myGraph" class="w-100"></div>
<pre id="eventSpan"></pre> <pre id="eventSpan"></pre>
<div id="repositoryInformation" class="w-100"></div>
</div> </div>
<div class="col-md-2 col-12 w-100"> <div class="col-md-2 col-12 w-100">
<div id="profileGen"></div> <div id="profileGen"></div>

+ 104
- 7
public/js/profileTimeLine.js View File

@ -1,36 +1,132 @@
var events = []; 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'}, // {id: 0, group: 0, start: new Date(2013,7,1), end: new Date(2017,5,15), content: 'High School'},
function addRepositories(userName, groupID) function addRepositories(userName, groupID)
{ {
return new Promise(function(resolve, reject) 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 = "<div class=\"card\">\n" +
" <div class=\"card-header\">\n" +
item.name +
" </div>\n" +
" <div class=\"card-body\">\n";
html += "<p>" + item.description + "</p>";
console.log(item.license);
if(item.license === null)
{
item.license = new Object();
item.license.name = 'none';
}
html += "<div class='row'><div class=\"col-6\">\n" +
" <ul class=\"list-group\">\n" +
" <li class=\"row\">\n" +
" <div class=\"col-md-6\"><b>Fork Count</b></div>\n" +
" <div class=\"col-md-6\">" +
item.forks +
"</div>\n" +
" </li>\n" +
" <li class=\"row\">\n" +
" <div class=\"col-md-6\"><b>Languages</b></div>\n" +
" <div class=\"col-md-6\">" +
item.language+
"</div>\n" +
" </li>\n" +
" <li class=\"row\">\n" +
" <div class=\"col-md-6\"><b>Liscense</b></div>\n" +
" <div class=\"col-md-6\">" +
item.license.name +
"</div>\n" +
" </li>\n" +
" <li class=\"row\">\n" +
" <div class=\"col-md-6\"><b>Home Page</b></div>\n" +
" <div class=\"col-md-6\">" +
"<a href='" + item.homepage + "'>" +item.homepage + "</a>" +
"</div>\n" +
" </li>\n" +
" </ul>\n" +
" </div>";
html += "<div class=\"col-6\">\n" +
" <ul class=\"list-group\">\n" +
" <li class=\"row\">\n" +
" <div class=\"col-md-6\"><b>Repository URL</b></div>\n" +
" <div class=\"col-md-6\">" +
"<a href='" + item.html_url + "'>" +item.html_url + "</a>" +
"</div>\n" +
" </li>\n" +
" <li class=\"row\">\n" +
" <div class=\"col-md-6\"><b>Open Issues</b></div>\n" +
" <div class=\"col-md-6\">" +
item.open_issues_count +
"</div>\n" +
" </li>\n" +
" <li class=\"row\">\n" +
" <div class=\"col-md-6\"><b>Watchers</b></div>\n" +
" <div class=\"col-md-6\">" +
item.watchers +
"</div>\n" +
" </li>\n" +
" </ul>\n" +
" </div></div>";
html +=" </div>\n" +
"</div>";
$("#repositoryInformation").html(html);
}
}
function createProfileTimeLine(username, containerName) function createProfileTimeLine(username, containerName)
{ {
var container = document.getElementById(containerName); var container = document.getElementById(containerName);
var prom = [addRepositories(username, 1), addOrgs(username, 1)];
var prom = [addRepositories(username, 1)];
var groups = new vis.DataSet([ var groups = new vis.DataSet([
{id: 0, content: 'Organizations', value: 1},
{id: 1, content: 'Repositories', value: 2} {id: 1, content: 'Repositories', value: 2}
]); ]);
console.log("up up duper");
Promise.all(prom).then(function() Promise.all(prom).then(function()
{ {
// note that months are zero-based in the JavaScript Date object // note that months are zero-based in the JavaScript Date object
@ -53,5 +149,6 @@ function createProfileTimeLine(username, containerName)
timeline.setOptions(options); timeline.setOptions(options);
timeline.setGroups(groups); timeline.setGroups(groups);
timeline.setItems(items); timeline.setItems(items);
timeline.on('click', timeLineClickEvent);
}); });
} }

Loading…
Cancel
Save