From c78871332a4cd2e36cc5e8b75dbfa25c56c49f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B01=3B31m=1B=5BK=22name=22=1B=5Bm=1B=5BK=3A=20=22Andrew?= =?UTF-8?q?=20Donato?= <[01;31m"email": "andrew.donato91@gmail.com> Date: Tue, 20 Oct 2015 21:28:34 -0700 Subject: [PATCH 1/7] able to request repo branches with ajax --- src/index.html | 6 ++++++ src/projects.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/index.html b/src/index.html index 4f13778..480e6a5 100644 --- a/src/index.html +++ b/src/index.html @@ -32,7 +32,13 @@

All active projects

+ +
+ +
+
+

Add new project

diff --git a/src/projects.js b/src/projects.js index 6c11b49..26ada63 100644 --- a/src/projects.js +++ b/src/projects.js @@ -1,3 +1,39 @@ +$(document).ready(function() { + getBranches(); +}); + + +var getBranches = function(){ + // https://api.github.com/repos/andrewdonato/webdev-exercise/branches + // var repos = $(".gitRepos").loadRepositories(andrewdonato) + + var request = $.ajax({ + url: "https://api.github.com/repos/andrewdonato/webdev-exercise/branches", + type: "get" + + }) + request.done(function(serverData){ + var branches=serverData; + console.log(branches[0].commit) + }) + request.fail(function(serverData){ + console.log(serverData); + console.log('server request failed'); + + }) + +}; + + + + + + + + + + + function Project(id, type, name, lastActivity) { this.id = id; this.type = type; @@ -17,6 +53,7 @@ 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 $("").append( From 9957e890ba3c3e97e25002c58d866439a8171791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B01=3B31m=1B=5BK=22name=22=1B=5Bm=1B=5BK=3A=20=22Andrew?= =?UTF-8?q?=20Donato?= <[01;31m"email": "andrew.donato91@gmail.com> Date: Tue, 20 Oct 2015 21:34:19 -0700 Subject: [PATCH 2/7] testing branch merge --- src/projects.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/projects.js b/src/projects.js index 26ada63..8cc5600 100644 --- a/src/projects.js +++ b/src/projects.js @@ -6,6 +6,7 @@ $(document).ready(function() { var getBranches = function(){ // https://api.github.com/repos/andrewdonato/webdev-exercise/branches // var repos = $(".gitRepos").loadRepositories(andrewdonato) + // why aren't my changes sticking? var request = $.ajax({ url: "https://api.github.com/repos/andrewdonato/webdev-exercise/branches", From 3be03a367f6e09c9762f5b626df504b4f57bc460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B01=3B31m=1B=5BK=22name=22=1B=5Bm=1B=5BK=3A=20=22Andrew?= =?UTF-8?q?=20Donato?= <[01;31m"email": "andrew.donato91@gmail.com> Date: Wed, 21 Oct 2015 12:02:12 -0700 Subject: [PATCH 3/7] added branch column and type-list --- src/index.html | 19 +++++++++++++++++++ src/projects.js | 27 ++++++++++++++++++++------- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/index.html b/src/index.html index 480e6a5..04d60b7 100644 --- a/src/index.html +++ b/src/index.html @@ -27,6 +27,8 @@

All active projects

Type Name Last activity + Branch + Up to Date @@ -41,6 +43,22 @@

All active projects

Add new project

+ +
+ + + + + + + + + + + + +
+
@@ -50,6 +68,7 @@

Add new project

+
diff --git a/src/projects.js b/src/projects.js index 8cc5600..95895f1 100644 --- a/src/projects.js +++ b/src/projects.js @@ -3,6 +3,13 @@ $(document).ready(function() { }); +var compareToMaster = function(){ + + // url: "https://api.github.com/repos/andrewdonato/webdev-exercise/compare/master...gitBranches", + +} + + var getBranches = function(){ // https://api.github.com/repos/andrewdonato/webdev-exercise/branches // var repos = $(".gitRepos").loadRepositories(andrewdonato) @@ -14,15 +21,13 @@ var getBranches = function(){ }) request.done(function(serverData){ - var branches=serverData; - console.log(branches[0].commit) + branches = serverData; + console.log(branches[2]) }) request.fail(function(serverData){ console.log(serverData); console.log('server request failed'); - }) - }; @@ -35,11 +40,15 @@ var getBranches = function(){ -function Project(id, type, name, lastActivity) { + + +function Project(id, type, name, lastActivity, branch, upToDate) { this.id = id; this.type = type; this.name = name; this.lastActivity = lastActivity; + this.branch = branch; + this.name = name; } // The list of all projects currently in the system. @@ -61,7 +70,8 @@ $(function(){ $("").text(pj.id), $("").text(pj.type), $("").text(pj.name), - $("").text(pj.lastActivity.toString()) + $("").text(pj.lastActivity.toString()), + $("").text(pj.branch) ); })); }; @@ -72,7 +82,9 @@ $(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 ); }; @@ -80,6 +92,7 @@ $(function(){ var resetForm = function($form) { $form.find("#project-type").val(""); $form.find("#project-name").val(""); + $form.find("#project-branch").val(""); $form.find("input:first").focus(); }; From 3ff73a0317b51fa1cdfb22546c7cf22a410df581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B01=3B31m=1B=5BK=22name=22=1B=5Bm=1B=5BK=3A=20=22Andrew?= =?UTF-8?q?=20Donato?= <[01;31m"email": "andrew.donato91@gmail.com> Date: Wed, 21 Oct 2015 14:06:57 -0700 Subject: [PATCH 4/7] Comparing the branches dates I have all the branch shows and now I need to find their dates and compare them to master. --- src/projects.js | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/src/projects.js b/src/projects.js index 95895f1..319ae12 100644 --- a/src/projects.js +++ b/src/projects.js @@ -3,26 +3,20 @@ $(document).ready(function() { }); -var compareToMaster = function(){ - - // url: "https://api.github.com/repos/andrewdonato/webdev-exercise/compare/master...gitBranches", - -} +// var compareToMaster = function(){ +// // url: "https://api.github.com/repos/andrewdonato/webdev-exercise/compare/master...gitBranches", +// } var getBranches = function(){ - // https://api.github.com/repos/andrewdonato/webdev-exercise/branches - // var repos = $(".gitRepos").loadRepositories(andrewdonato) - // why aren't my changes sticking? var request = $.ajax({ url: "https://api.github.com/repos/andrewdonato/webdev-exercise/branches", type: "get" - }) request.done(function(serverData){ - branches = serverData; - console.log(branches[2]) + var branches = serverData; + viewEachBranch(branches); }) request.fail(function(serverData){ console.log(serverData); @@ -31,6 +25,38 @@ var getBranches = function(){ }; +//// Warning!! This makes many queries at once. Watch your rate limit ~ 60/hr +var viewEachBranch = function(branches){ + + var allBranchShows = [] + + for (var i = 0; i < branches.length; i++){ + + var branchName = branches[i].name + + 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'); + }) + }; + + compareBranchShows(allBranchShows) +}; + +var compareBranchShows = function(allBranchShows) { + console.log(allBranchShows) + + // find master and what it's date is + // compare the dates of each branch to masters date +} From 32284824e3a288a11608aeb203fac1ec79b7aafa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B01=3B31m=1B=5BK=22name=22=1B=5Bm=1B=5BK=3A=20=22Andrew?= =?UTF-8?q?=20Donato?= <[01;31m"email": "andrew.donato91@gmail.com> Date: Wed, 21 Oct 2015 14:38:01 -0700 Subject: [PATCH 5/7] Able to show each individual branch. Now I am working on comparing the dates. --- src/projects.js | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/projects.js b/src/projects.js index 319ae12..d24d101 100644 --- a/src/projects.js +++ b/src/projects.js @@ -40,7 +40,10 @@ var viewEachBranch = function(branches){ }) request.done(function(serverData){ var branchShow = serverData; - allBranchShows.push(branchShow) + + console.log(branchShow) //// this is my most recent point + compareBranchDatesToMaster + // allBranchShows.push(branchShow) }) request.fail(function(serverData){ console.log(serverData); @@ -48,15 +51,35 @@ var viewEachBranch = function(branches){ }) }; - compareBranchShows(allBranchShows) + // compareBranchShows(allBranchShows) +}; + +var compareBranchDatesToMaster = function(){ + var branch = this + var date = Branchshow[i].commit[0].commit.author.date + if (date < masterDate){ + upToDateStatus = false + }; + else{ + upToDateStatus = true + }; }; -var compareBranchShows = function(allBranchShows) { - console.log(allBranchShows) +// var compareBranchShows = function(allBranchShows) { - // find master and what it's date is - // compare the dates of each branch to masters date -} +// // pretend this is working right now +// // console.log(allBranchShows.length) + +// allBranchDates = [] + +// for (var i = 0; i < allBranchShows.length; i++){ + +// } + + +// // find master and what it's date is +// // compare the dates of each branch to masters date +// } From 1db570f584ce907d3f90d0a78d5cc6cad0da9910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B01=3B31m=1B=5BK=22name=22=1B=5Bm=1B=5BK=3A=20=22Andrew?= =?UTF-8?q?=20Donato?= <[01;31m"email": "andrew.donato91@gmail.com> Date: Wed, 21 Oct 2015 16:06:23 -0700 Subject: [PATCH 6/7] able to grab date and index of master need to compare dates of other branches --- src/projects.js | 56 +++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/projects.js b/src/projects.js index d24d101..8c70f27 100644 --- a/src/projects.js +++ b/src/projects.js @@ -26,14 +26,19 @@ var getBranches = function(){ //// Warning!! This makes many queries at once. Watch your rate limit ~ 60/hr +var allBranchShows = []; var viewEachBranch = function(branches){ - var allBranchShows = [] 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" @@ -41,46 +46,37 @@ var viewEachBranch = function(branches){ request.done(function(serverData){ var branchShow = serverData; - console.log(branchShow) //// this is my most recent point - compareBranchDatesToMaster - // allBranchShows.push(branchShow) + allBranchShows.push(branchShow) + console.log(allBranchShows) + // console.log(branchShow) //// this is my most recent point }) request.fail(function(serverData){ console.log(serverData); console.log('server request failed'); }) }; + debugger + compareBranchDatesToMaster(allBranchShows, indexOfMaster) - // compareBranchShows(allBranchShows) -}; - -var compareBranchDatesToMaster = function(){ - var branch = this - var date = Branchshow[i].commit[0].commit.author.date - if (date < masterDate){ - upToDateStatus = false - }; - else{ - upToDateStatus = true - }; }; -// var compareBranchShows = function(allBranchShows) { - -// // pretend this is working right now -// // console.log(allBranchShows.length) +var compareBranchDatesToMaster = function(allBranchShows, indexOfMaster){ + debugger + dateOfMaster = allBranchShows[indexOfMaster].commit.commit.author.date -// allBranchDates = [] - -// for (var i = 0; i < allBranchShows.length; i++){ - -// } - - -// // find master and what it's date is -// // compare the dates of each branch to masters date -// } + for (var i = 0; i < allBranchShows.length; i++){ + var date = allBranchShows[i].commit.commit.author.date + if (date < dateOfMaster){ + allBranchShows.upToDateStatus = false + } + else { + allBranchShows.upToDateStatus = true + }; + console.log(allBranchShows.upToDateStatus) + debugger + }; +}; From 2a6a809363a94910b80ba723f5f4668d9d347112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5B01=3B31m=1B=5BK=22name=22=1B=5Bm=1B=5BK=3A=20=22Andrew?= =?UTF-8?q?=20Donato?= <[01;31m"email": "andrew.donato91@gmail.com> Date: Wed, 21 Oct 2015 16:53:02 -0700 Subject: [PATCH 7/7] Now at updating the dom with changes. Time to turn in challenge. --- src/projects.js | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/projects.js b/src/projects.js index 8c70f27..d723238 100644 --- a/src/projects.js +++ b/src/projects.js @@ -2,12 +2,7 @@ $(document).ready(function() { getBranches(); }); - -// var compareToMaster = function(){ -// // url: "https://api.github.com/repos/andrewdonato/webdev-exercise/compare/master...gitBranches", -// } - - +//// here I call an index of the branches (very minimal information) var getBranches = function(){ var request = $.ajax({ @@ -26,10 +21,9 @@ var getBranches = function(){ //// 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 @@ -38,47 +32,53 @@ var viewEachBranch = function(branches){ 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) - console.log(allBranchShows) - // console.log(branchShow) //// this is my most recent point }) request.fail(function(serverData){ console.log(serverData); console.log('server request failed'); }) }; - debugger compareBranchDatesToMaster(allBranchShows, indexOfMaster) - }; -var compareBranchDatesToMaster = function(allBranchShows, indexOfMaster){ - debugger - dateOfMaster = allBranchShows[indexOfMaster].commit.commit.author.date +//// 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 < allBranchShows.length; i++){ - var date = allBranchShows[i].commit.commit.author.date + for (var i = 0; i < allBranches.length; i++){ + var dateOfBranch - if (date < dateOfMaster){ - allBranchShows.upToDateStatus = false + if (dateOfBranch < dateOfMaster){ + allBranches[i].upToDateStatus = false } else { - allBranchShows.upToDateStatus = true + allBranches[i].upToDateStatus = true }; - console.log(allBranchShows.upToDateStatus) - debugger }; + + 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. + + +} @@ -93,7 +93,6 @@ function Project(id, type, name, lastActivity, branch, upToDate) { this.name = name; this.lastActivity = lastActivity; this.branch = branch; - this.name = name; } // The list of all projects currently in the system.