Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,38 @@ <h2>All active projects</h2>
<th>Type</th>
<th>Name</th>
<th>Last activity</th>
<th>Branch</th>
<th>Up to Date</th>
</tr>
</thead>
<tbody>
</tbody>
</table>

<div class='gitRepos'>

</div>

<hr>

<h2>Add new project</h2>
<form id="add-project-form">

<div class="form-group">
<label for="project-branch">Project Branch</label>
<input type="text" class="form-control" id="project-branch" list="type-list" autofocus>
<datalist id="type-list">
<option>master</option>
<option>gitbranches</option>
<option>outdated-branch-1</option>
<option>outdated-branch-2</option>
<option>outdated-branch-3</option>
<option>baseline-branch</option>
<option>up-to-date-branch-1</option>
<option>up-to-date-branch-2</option>
</datalist>
</div>

<div class="form-group">
<label for="project-type">Project type</label>
<input type="text" class="form-control" id="project-type" list="type-list" autofocus>
Expand All @@ -44,6 +68,7 @@ <h2>Add new project</h2>
<option>Analysis</option>
</datalist>
</div>

<div class="form-group">
<label for="project-name">Project name</label>
<input type="text" class="form-control" id="project-name">
Expand Down
101 changes: 98 additions & 3 deletions src/projects.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,98 @@
function Project(id, type, name, lastActivity) {
$(document).ready(function() {
getBranches();
});

//// here I call an index of the branches (very minimal information)
var getBranches = function(){

var request = $.ajax({
url: "https://api.github.com/repos/andrewdonato/webdev-exercise/branches",
type: "get"
})
request.done(function(serverData){
var branches = serverData;
viewEachBranch(branches);
})
request.fail(function(serverData){
console.log(serverData);
console.log('server request failed');
})
};


//// Warning!! This makes many queries at once. Watch your rate limit ~ 60/hr
//// Here I view the show of each branch and add it to an array of all of the branch shows
var allBranchShows = [];
var viewEachBranch = function(branches){
for (var i = 0; i < branches.length; i++){

var branchName = branches[i].name

if (branchName === "master"){
indexOfMaster = i
};

var request = $.ajax({
url: "https://api.github.com/repos/andrewdonato/webdev-exercise/branches/" + branchName,
type: "get"
})
request.done(function(serverData){
var branchShow = serverData;
allBranchShows.push(branchShow)
})
request.fail(function(serverData){
console.log(serverData);
console.log('server request failed');
})
};
compareBranchDatesToMaster(allBranchShows, indexOfMaster)
};

//// here I compare the date of each branch with the date of master.
//// I added "upToDateStatus" to each branch show object
var compareBranchDatesToMaster = function(allBranches, indexOfMaster){

dateOfMaster = allBranches[indexOfMaster].commit.commit.author.date

for (var i = 0; i < allBranches.length; i++){
var dateOfBranch

if (dateOfBranch < dateOfMaster){
allBranches[i].upToDateStatus = false
}
else {
allBranches[i].upToDateStatus = true
};
};

updateDOM(allBranches)
};

//// here I update the branch name and whether or it "Up To Date"
var updateDOM = function (allBranches) {
debugger

// I've run out of time.
// To finish, I would use jquery to determine the branch of each project.
// I would also use jqeury to populate the branch drop down menu
// I would then go to the parent row, and then append the "upToDateStatus" which would be either true or false.


}








function Project(id, type, name, lastActivity, branch, upToDate) {
this.id = id;
this.type = type;
this.name = name;
this.lastActivity = lastActivity;
this.branch = branch;
}

// The list of all projects currently in the system.
Expand All @@ -17,13 +107,15 @@ var CURRENT_PROJECTS = [
var MAX_ID = Math.max.apply(null, $.map(CURRENT_PROJECTS, function(pj) { return pj.id; }));

$(function(){

var loadProjects = function($container, projects) {
$.fn.append.apply($container, $.map(projects, function(pj) {
return $("<tr>").append(
$("<td>").text(pj.id),
$("<td>").text(pj.type),
$("<td>").text(pj.name),
$("<td>").text(pj.lastActivity.toString())
$("<td>").text(pj.lastActivity.toString()),
$("<td>").text(pj.branch)
);
}));
};
Expand All @@ -34,14 +126,17 @@ $(function(){
MAX_ID + 1,
$form.find("#project-type").val(),
$form.find("#project-name").val(),
new Date()
new Date(),
$form.find("#project-branch").val()
// this is where I would put whether or not the project is up to date with master
);
};

// Clears the data in the form so that it's easy to enter a new project.
var resetForm = function($form) {
$form.find("#project-type").val("");
$form.find("#project-name").val("");
$form.find("#project-branch").val("");
$form.find("input:first").focus();
};

Expand Down