From 244e437cebbb428911b3dba3c04e9d9ad7dcd5d1 Mon Sep 17 00:00:00 2001 From: Alfred Ortega Date: Mon, 20 Apr 2015 18:04:01 -0500 Subject: [PATCH 1/3] Updated to include retrieval of data, find by id, search, and paging. --- views/api/ExternalApiController.js | 8 + views/project/ProjectController.js | 2 +- views/project/projectIdeaService.js | 224 ++++++++++++++-------------- 3 files changed, 124 insertions(+), 110 deletions(-) diff --git a/views/api/ExternalApiController.js b/views/api/ExternalApiController.js index 1dbb79f..f3fa45f 100644 --- a/views/api/ExternalApiController.js +++ b/views/api/ExternalApiController.js @@ -20,4 +20,12 @@ cfahubControllers.controller('GoogleProjectsController',function($scope,GooglePr $scope.getItems = function() { $scope.items = GoogleProjectsApiDaoService.getHttpItems(); } +}); + +cfahubControllers.controller('GoogleIdeasController',function($scope,GoogleIdeasApiDaoService){ + $scope.getItems = function() { + $scope.items = GoogleIdeasApiDaoService.getHttpItems(); + //I think it should be .ideas instead of .items to avoid conflict and readability: + //$scope.ideas = GoogleIdeasApiDaoService.getHttpItems(); + } }); \ No newline at end of file diff --git a/views/project/ProjectController.js b/views/project/ProjectController.js index 25c8856..03e3b92 100644 --- a/views/project/ProjectController.js +++ b/views/project/ProjectController.js @@ -8,7 +8,7 @@ cfahubControllers.controller('ProjectIdeaListController', function($scope, $rout }); cfahubControllers.controller('ProjectIdeaController', function($scope, $routeParams, ProjectIdeaService) { - var ideaId = $routeParams.iid; + var ideaId = $routeParams.id; $scope.project = $scope.idea = ProjectIdeaService.getIdea(ideaId); }); diff --git a/views/project/projectIdeaService.js b/views/project/projectIdeaService.js index b9feeb3..7a5f175 100644 --- a/views/project/projectIdeaService.js +++ b/views/project/projectIdeaService.js @@ -1,114 +1,120 @@ +/* + * + */ cfahubServices.service('ProjectIdeaService', function(){ - var ideas = [{ - "id":"0", - "projecttype":"idea", - "image":"assets/images/OK_lightbulb.png", - "city":"Project City", - "title":"Project Idea", - "subtitle":"Project Subtitle", - "category":"Civic category", - "suggester":"Jane Doe", - "goals":"The first paragraph from GitHb readme. Project goals. One paragraph of text describing why people need to use this app/website. The first four lines of text are displayed in the card view. The rest is available in details.", - "targetaudience":"1. New brigade members
2. Established brigade members
3. Brigades across the nation
4. Civic-minded public", - "userstories":"

Dave is a member of brigade living in Kansas City. He does not have time to follow the latest developments in the brigade on a daily basis. He would like to choose where he can apply his skills for a few hours during Monday hack night. Dave does not need to see project details, rather where the help is needed. He opens Projects Hub and chooses an active project with relevant Help Wanted issues, where he can contribute.

Ashley has a great idea about building up community spaces in Kansas City. She does not know how to build an app for it, and thinks Code for America might help. Ashley opens the Projects Hub, filters Community projects and sees that similar, but not quite the same project is under development in Munich, Germany. She presses the big blue button on the Projects Hub and adds the idea for KC brigade to develop.

Kevin, DB admin at MicroBucks, Inc., has found out about Code for America on a date with Ashley. He is curious about Ashley and the idea behind civic coding, and would like to learn more about both. He also would like to improve his JavaScript skills. Kevin opens the ProjectsHub, finds all the projects in Kansas City, where Javascript help is wanted. One of them has Ashley as a contributor. Kevin chooses to work on this project.

Jim, is geomapping guru, has been out of work for a few months. He is looking for a challenging project to showcase his skills and to build up his portfolio. He finds one under development in Buenos Aires brigade.

", - "maintenanceplan":"

Project leaders for active projects will be able to keep the the data updated on GitHub, using the usual GitHub tools. Additional requirement for GitHub is making custom set of GitHub repo labels (see Custom Labels for Repos on GitHub).

Project Definition information can be updated either via Google form, when the project is created, or via Google miniforms, once project is established, or by editing Google spreasheet directly.

", - "blockers":"

Maintanence related blockers: The workflow for updating project information in Google spreadsheet is clumsy (Google form does not pull data back from the spreadsheet, if data exists already).

The initial effort of creating custom repo labels and then applying them to repo issue, when the issue is created requires some discipline from project leader.

", - "stars":"#", - "followers":"#", - "comments":"#", - "active":"Idea", - "platform":"platform", - "techstack":"technology stack", - "url":"#/", - "issues":[{"id":"30","descrip":"links to issues on GitHub where the help is wanted"}], - "contributers":[ - {"leader":1,"img":"assets/images/person_thumb_40x40.png"}, - {"img":"assets/images/person_thumb_40x40.png"}, - {"img":"https://avatars3.githubusercontent.com/u/10410203?v=3&s=460"}] - }, + var ideas; + var count; + $http({method : 'GET',url : 'https://spreadsheets.google.com/feeds/list/1PGM2P9o0bkJ_xCkoH2ps_Dp5xnBDrPxmIB-jnJWAwhE/1/public/values?alt=json'}) + .success(function(data, status) { + /* + *Because ideas have no PK we need to create a hack to work around it. + *We create an array to loop through which does 2 things. First of all it removes + *excess crap from google's json feed. + *Second it lets us loop throught the items and convert the timestamp to + *float which we use as an PK in memory in the app. + */ + var tempIdeas = data.feeed.entry; + count = tempIdeas.length; + var ideasJson = "{\"App.Model.Project\":["; + for (i = 0; i < tempIdeas.length; i++) { + if(i==0) + { + ideasJson += "{"; + } + else + { + ideasJson += ",{"; + } + var id = new Date(tempIdeas[i]['gsx$timestamp']['$t']).valueOf(); + ideasJson += "\"id\":\"" + id + "\","; + ideasJson += "\"timestamp\":\"" + tempIdeas[i]['gsx$timestamp']['$t'] + "\","; + ideasJson += "\"title\":\"" + tempIdeas[i]['gsx$giveyourideaatitle']['$t'] + "\","; + ideasJson += "\"subtitle\":\"" + tempIdeas[i]['gsx$giveyourideaasubtitle']['$t'] + "\","; + ideasJson += "\"location\":\"" + tempIdeas[i]['gsx$location']['$t'] + "\","; + ideasJson += "\"email_address\":\"" + tempIdeas[i]['gsx$whatisyouremailaddress']['$t'] + "\","; + ideasJson += "\"civic_engagement_area\":\"" + tempIdeas[i]['gsx$whatareaofcivicengagementdescribesyourideathebest']['$t'] + "\","; + ideasJson += "\"civic_request\":\"" + tempIdeas[i]['gsx$civicrequest']['$t'] + "\","; + ideasJson += "\"organization_name\":\"" + tempIdeas[i]['gsx$nameoftheorganization']['$t'] + "\","; + ideasJson += "\"github_url\":\"" + tempIdeas[i]['gsx$heyihaveaprojectrepoongithubalreadyhereisthelink']['$t'] + "\","; + ideasJson += "\"target_audiences\":\"" + tempIdeas[i]['gsx$targetaudience']['$t'] + "\","; + ideasJson += "\"user_stories\":\"" + tempIdeas[i]['gsx$userstory']['$t'] + "\","; + ideasJson += "\"maintenance_plan\":\"" + tempIdeas[i]['gsx$maintenanceplan']['$t'] + "\","; + ideasJson += "\"potential_blockers\":\"" + tempIdeas[i]['gsx$potentialblockers']['$t'] + "\""; //no trailing comma + ideasJson += "}"; + + } + ideasJson += "]}"; + console.log(ideasJson); + ideas = JSON.parse(ideasJson); + }) + .error(function(data, status) { + alert("HTTP Error"); + }); + + factory.getHttpItems = function() { - "id":"1", - "projecttype":"idea", - "image":"assets/images/OK_lightbulb.png", - "city":"Kansas City", - "title":"Epic Idea", - "subtitle":"sort government data", - "category":"Government", - "suggester":"Joe Blow", - "goals":"The Community Capital Fund and our partners have realized through our work that a map of existing community-based projects does not exist and that often, neighborhood associations and organizations are not aware of projects/programs occurring near them, and often do not know of other organizations doing similar work. CCF believes that neighborhoods that partner with and learn from others doing similar work will have greater capacity, opportunities, and resources to carry out their work; will have a greater impact on community development and revitalization than when working in a silo; and will have a more sustained, long-term impact.", - "targetaudience":"1. New brigade members
2. Established brigade members
3. Brigades across the nation
4. Civic-minded public", - "userstories":"

Dave is a member of brigade living in Kansas City. He does not have time to follow the latest developments in the brigade on a daily basis. He would like to choose where he can apply his skills for a few hours during Monday hack night. Dave does not need to see project details, rather where the help is needed. He opens Projects Hub and chooses an active project with relevant Help Wanted issues, where he can contribute.

Ashley has a great idea about building up community spaces in Kansas City. She does not know how to build an app for it, and thinks Code for America might help. Ashley opens the Projects Hub, filters Community projects and sees that similar, but not quite the same project is under development in Munich, Germany. She presses the big blue button on the Projects Hub and adds the idea for KC brigade to develop.

Kevin, DB admin at MicroBucks, Inc., has found out about Code for America on a date with Ashley. He is curious about Ashley and the idea behind civic coding, and would like to learn more about both. He also would like to improve his JavaScript skills. Kevin opens the ProjectsHub, finds all the projects in Kansas City, where Javascript help is wanted. One of them has Ashley as a contributor. Kevin chooses to work on this project.

Jim, is geomapping guru, has been out of work for a few months. He is looking for a challenging project to showcase his skills and to build up his portfolio. He finds one under development in Buenos Aires brigade.

", - "maintenanceplan":"

Project leaders for active projects will be able to keep the the data updated on GitHub, using the usual GitHub tools. Additional requirement for GitHub is making custom set of GitHub repo labels (see Custom Labels for Repos on GitHub).

Project Definition information can be updated either via Google form, when the project is created, or via Google miniforms, once project is established, or by editing Google spreasheet directly.

", - "blockers":"

Maintanence related blockers: The workflow for updating project information in Google spreadsheet is clumsy (Google form does not pull data back from the spreadsheet, if data exists already).

The initial effort of creating custom repo labels and then applying them to repo issue, when the issue is created requires some discipline from project leader.

", - "stars":"1", - "followers":"7", - "comments":"0", - "active":"Idea", - "platform":"Web App", - "techstack":"JavaScript, HTML, CSS", - "url":"http://codeforkc.org/civic-project-mapping/", - "issues":[{"id":"58","descrip":"Organizations with multiple locations, what is the best way to input and display."}, - {"id":"56","descrip":"When there are to many pins on the map, cluster them."}, - {"id":"54","descrip":"Consider BootLeaf"}, - {"id":"52","descrip":"Make it easier to change the Question Labels"}, - {"id":"31","descrip":"Test usage on phones"}, - {"id":"29","descrip":"Search by project name"}, - {"id":"27","descrip":"Usability/Interaction Design/Visual Design/Information Architecture"}, - {"id":"26","descrip":"Update About page"}, - {"id":"24","descrip":"Add neighborhood names on the map."}, - {"id":"20","descrip":"satellite/earth view/street view"}, - {"id":"14","descrip":"Add a project detail page"}], - "contributers":[ - {"leader":1,"img":"https://avatars1.githubusercontent.com/u/447024?v=3&s=460"}, - {"img":"https://avatars1.githubusercontent.com/u/4423980?v=3&s=460"}, - {"img":"https://avatars1.githubusercontent.com/u/9424270?v=3&s=460"}, - {"img":"https://avatars2.githubusercontent.com/u/5474002?v=3&s=460"}] - }, - { - "id":"2", - "projecttype":"idea", - "image":"assets/images/OK_lightbulb.png", - "city":"Kansas City", - "title":"One type of Idea", - "subtitle":"this idea is helpful", - "category":"Politics", - "suggester":"Jack Black", - "goals":"To help brigade members to find projects to work on. Multi-brigade collaboration. New members onboarding. Let public contribute ideas. Karma. Code for America scope view. Provide filtered and sorted card list of projects and ideas for development. The list should be available nation-wide and by city.", - "targetaudience":"1. New brigade members
2. Established brigade members
3. Brigades across the nation
4. Civic-minded public", - "userstories":"

Dave is a member of brigade living in Kansas City. He does not have time to follow the latest developments in the brigade on a daily basis. He would like to choose where he can apply his skills for a few hours during Monday hack night. Dave does not need to see project details, rather where the help is needed. He opens Projects Hub and chooses an active project with relevant Help Wanted issues, where he can contribute.

Ashley has a great idea about building up community spaces in Kansas City. She does not know how to build an app for it, and thinks Code for America might help. Ashley opens the Projects Hub, filters Community projects and sees that similar, but not quite the same project is under development in Munich, Germany. She presses the big blue button on the Projects Hub and adds the idea for KC brigade to develop.

Kevin, DB admin at MicroBucks, Inc., has found out about Code for America on a date with Ashley. He is curious about Ashley and the idea behind civic coding, and would like to learn more about both. He also would like to improve his JavaScript skills. Kevin opens the ProjectsHub, finds all the projects in Kansas City, where Javascript help is wanted. One of them has Ashley as a contributor. Kevin chooses to work on this project.

Jim, is geomapping guru, has been out of work for a few months. He is looking for a challenging project to showcase his skills and to build up his portfolio. He finds one under development in Buenos Aires brigade.

", - "maintenanceplan":"

Project leaders for active projects will be able to keep the the data updated on GitHub, using the usual GitHub tools. Additional requirement for GitHub is making custom set of GitHub repo labels (see Custom Labels for Repos on GitHub).

Project Definition information can be updated either via Google form, when the project is created, or via Google miniforms, once project is established, or by editing Google spreasheet directly.

", - "blockers":"

Maintanence related blockers: The workflow for updating project information in Google spreadsheet is clumsy (Google form does not pull data back from the spreadsheet, if data exists already).

The initial effort of creating custom repo labels and then applying them to repo issue, when the issue is created requires some discipline from project leader.

", - "stars":"2", - "followers":"8", - "comments":"1", - "active":"Idea", - "platform":"Web App", - "techstack":"HTML, CSS", - "url":"http://codeforkc.org/Code-for-America-Projects-Hub/", - "issues":[ - {"id":"17","descrip":"Projects Hub filter. Where does the data come from?"}, - {"id":"16","descrip":"Script to display entered project data from Google spreadsheet in Google form to edit the data"}, - {"id":"11","descrip":"Add infinite scroll to the hub"}, - {"id":"7","descrip":"Usability evaluation"}, - {"id":"8","descrip":"Custom labels for repo issues"}, - {"id":"9","descrip":"Project card data. Where does the data come from?"}, - {"id":"6","descrip":"Coding projects filter"}, - {"id":"4","descrip":"Map geolocation filter"}], - "contributers":[ - {"leader":1,"img":"https://avatars2.githubusercontent.com/u/10410203?v=3&s=460"}, - {"img":"https://avatars1.githubusercontent.com/u/447024?v=3&s=460"}, - {"img":"https://avatars1.githubusercontent.com/u/212227?v=3&s=460"}, - {"img":"https://avatars3.githubusercontent.com/u/3280502?v=3&s=460"}, - {"img":"https://avatars0.githubusercontent.com/u/2244915?v=3&s=460"}] - }]; - this.list = function () { + /*This is used to initially load the ideas and then + * everything else is used because the records are cached. + */ + return ideas; + }//end getHttpItems; + + + this.list = function () + { return ideas; - } - this.getIdea = function(ideaId){ - for(i=0;i Date: Wed, 22 Apr 2015 17:58:05 -0500 Subject: [PATCH 2/3] simplified paging method --- views/project/projectIdeaService.js | 33 +++++++++++------------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/views/project/projectIdeaService.js b/views/project/projectIdeaService.js index 7a5f175..cb1f86e 100644 --- a/views/project/projectIdeaService.js +++ b/views/project/projectIdeaService.js @@ -1,5 +1,5 @@ /* - * + * /view/project/projectideasService.js */ cfahubServices.service('ProjectIdeaService', function(){ var ideas; @@ -59,7 +59,6 @@ cfahubServices.service('ProjectIdeaService', function(){ return ideas; }//end getHttpItems; - this.list = function () { return ideas; @@ -93,28 +92,20 @@ cfahubServices.service('ProjectIdeaService', function(){ } }//end getIdea - - this.pagedList = function(startingIndex, pageSize) + this.pagedList = function(pageNumber) { - var endIndex = startingIndex + pageSize; - var loopCount = pageSize; - if(endIndex < count) + var pageSize = 6; + var ideasIndex = pageNumber * pageSize; + var endIndex = ideasIndex + pageSize; + var records=[]; + var recordsIndex = 0; + while(index < endIndex) { - var loopCount = count - endIndex; - }//end if - var maxRecord = loopCount + startingIndex; - var records[]; - var x=0; - for(i = startingIndex; i < maxRecord; i++ ) - { - record[x] = ideas[i]; - x++; - i++; - }//end for + record[recordsIndex] = ideas[ideasIndex]; + index++; + recordsIndex++; + } return records; }//end pagedList - - - }); From 978b723c056f02576ee02df05350a40b8e4f1abf Mon Sep 17 00:00:00 2001 From: Alfred Ortega Date: Wed, 22 Apr 2015 18:07:23 -0500 Subject: [PATCH 3/3] added ?alt=json to pull data as json vice xml. --- views/api/googleDataApiService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/api/googleDataApiService.js b/views/api/googleDataApiService.js index e15aae1..8e28b7a 100644 --- a/views/api/googleDataApiService.js +++ b/views/api/googleDataApiService.js @@ -1,11 +1,11 @@ /*** Data Access Object Model for fetching Google Spreadsheet api data ***/ -//@TODO Feed returns XML, so replace this with Tabletop, etc. +//added 'alt=json. It now returns json with no need for tabletop cfahubServices.factory('GoogleProjectsApiDaoService',function($http){ var factory = {}; var items; - $http({method : 'GET',url : 'https://spreadsheets.google.com/feeds/worksheets/1tnW2fTcPEQG93oebrCfvjZw4Vjtn6vkzvqyovxebKlI/public/full'}) + $http({method : 'GET',url : 'https://spreadsheets.google.com/feeds/worksheets/1tnW2fTcPEQG93oebrCfvjZw4Vjtn6vkzvqyovxebKlI/public/full?alt=json'}) .success(function(data, status) { items = data.objects; })