Closed tpitman closed 7 years ago
yeah!
I probably could have made this more clear. If you notice, every file in the api directory references a file called "config.php" but that file doesn't exist (because it's ignored. There IS a file called "config_sample.php" and this needs to be renamed to "config.php" (which will then be ignored) and input with your credentials to the location of the mysql database. Once you have that, the api should work.
Super fast response. Awesome. What comes next? I probably need to write some html to call the php, right?
Any chance I could get a copy of your site code or can the api stand on its own? I am getting errors about things not existing.
You shouldn't, no. All the html is ready, but it needs to be built by node
npm install grunt
https://rankedchoices.com/ You can actually have the entire site running without any api, but no results will be saved
Building now. Hopefully I have the right versions of stuff. Getting some warnings. I am trying to do this on a Raspberry Pi with Raspbian (Debian based). Crossing fingers...
Thanks again for the quick responses.
I did npm install and it install a bunch of stuff. I then type grunt and it says it can't find it. I tried npm install grunt and it install grunt, so not sure what now.
npm install -g grunt-cli
I appreciate you being the guinea pig here. This clearly was not ready for consumption yet. I've tried doing a fresh pull and install and seeing the errors you are referring to. I'm making changes on the fly as well
It is stuck here:
Running "jade:compile" (jade) task
1 file created.
Running "less:dev" (less) task
1 stylesheet created.
Running "copy:copy" (copy) task Copied 27 files
Running "replace:dev" (replace) task
1 replacement in 1 file.
Running "pleeease:dev" (pleeease) task
Running "concat:js" (concat) task
Running "jshint:all" (jshint) task
✔ No problems
Running "watch" task Waiting...
If I browse to the "dist" folder I get the index.html, but it is blank even though the source shows a bunch of stuff.
that's where I am at too. The "missing" files are not being pathed correctly. I'm working on it at the moment. Again, I appreciate you bringing this to my attention. Give me 24 hours and I'll try to get it consumption worthy. In the meantime, feel free to tinker with it and if you find any answers, I'd like to hear them. RankedChoices.com is hosted on a LAMP stack shared hosting server, so I have "localhost" has the db location. I have tested this with an external db location, and it worked perfectly.
essentially, the "dist" folder contents populate the "public_html" folder of your server. Then, all the pathing works because everything is at the root level
I am using a local raspbian (debian) server running LAMP as well. Being raspbian I am hoping I have good versions of things.
I copied everything from dist into root. Now when I browse there I get the pages. There are errors, however.
It takes me to the main page and I hit create ballot. I enter a name and hit submit and nothing happens, but I do get an exception in the console. Here is the exception.
angular.js:130 TypeError: $http(...).success is not a function
at m.MainCtrl.$s.newBallot (main.js:380)
at fn (eval at compile (angular.js:246),
I really really appreciate you working on this because I need it pretty badly. I have been searching for days for something that will basically be turn key web site and yours is the best so far. Others are very much not ready.
Thank you thank you thank you....
It seems that Angular has updated it's $http protocol. Instead of "success", it uses "then" https://docs.angularjs.org/api/ng/service/$http
Well that's awfully nice to say. I hope when this is all up and running that I'll earn a star from you!
You will win many stars.
The other thing I will need to do with it, however, is add the ability to register voters so they can only vote once.
If you don't have time to do that, then I can dive into your code and try to figure that out.
I have that ability currently commented out because it's only 95% of the way there. I already have, built-in (currently commented) the ability to sign in with Facebook or Gmail. It was working pretty well, but not production worthy. Check out lines 16 - 39 of app.js
uncomment line 14 of index.jade and take a look at the "register" page. It's mostly there. Anything you want to do to get it the rest of the way would be awesome!
Awesome.
I went in and changed all instances of success to then in the main.js file and ran it again. Now it lets me create the ballot and enter the candidates.
When I hit submit all entries I get this exception:
angular.js:130 TypeError: Converting circular structure to JSON
at JSON.stringify (
This may be too simplistic, but I hope you didn't blindly replace all instances of "success" with "then". It only needs to change on lines 53, 328, 365, and 383
My thoughts are for an election night Caucus meeting. I don't want people to have to log in or sign up or anything like that. I was thinking about something simpler:
This relies on the voter keeping their code secret, which is fine for my use.
Optionally you could allow the person to change their vote up until the voting is done, but it only records the last one as the actual vote. This allows people to change their minds until voting closes.
LOL, I did change all of them. I will revert and change just those lines. thanks for your patience.
I really like your idea of the unique code approach! To me, the simplest way to accomplish this would be to create another table with ballotId and unique code. Please submit whatever you come up with!
I might have slightly different code. There are other places with $http(...).success like line 53.
Also the first one you mention is 328, for me it is 326.
I just barely got the code about an hour ago.
ok, you are correct, I was reading the number wrong. The places of "success" are 53, 328, 365, and 383
I reverted back to the main.js with success in it. I went through the success entries again and changed the 3 lines you mentioned (adjusted a little because they were different). I also changed line 53 because it was part of $http(...).
I am still getting
TypeError: Converting circular structure to JSON
at JSON.stringify (
So, this is happening on line 379 of main.js Can you put a breakpoint and inspect to see what "$s.candidates" is at that moment?
What should that line say? I think my code is different.
for me stringify is used on line 429
So, trying to debug remotely isn't easy, but it looks like "JSON.stringify" is running into a problem. That is only found on line 379 (of the raw file; 429 of the compiled file) when I take the array of candidates and stringify it before inserting it into the database.
Put a breakpoint on line 425 (of the compiled file) and look at "$s.candidates" in the console to see if it's a simple array or something complex. I am not sure why it would be anything different than me, yet here we are.
I understand about remote debugging. Hate it. Never works well.
It is not hitting that break point because that is inside the submitVote. That doesn't make sense because I am hitting the Submit All Entries when trying to create a ballot. I am not even to voting yet.
OH! I think I know. And shame on me for not thinking of this earlier. My guess is that the database needs to be built property before any of this is going to work!
I need to provide the schema so someone creating a new database can just run it and have it work
I was just starting to think about that. I went to my database and noticed there are not any tables in it.
Let me know when you have the schema and I will try again. Now rush. Tomorrow or whenever is fine.
Thanks again...
I have the db with tables now. It created an entry in the ballots table that looks correct. Nothing in the entries table and I am still getting that darn stringify exception :-(
Where do you store the short code? I don't see it in the db anywhere.
The thing is we are never hitting the stringify line of code.
There must be another place its used then. The stack you gave me didn't reference any of my code, did it? Put a break point right when you click "submit" and walk through the code slowly until it breaks On Tue, Apr 25, 2017 at 4:56 PM tpitman notifications@github.com wrote:
The thing is we are never hitting the stringify line of code.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/DavidMoritz/rcv/issues/3#issuecomment-297177233, or mute the thread https://github.com/notifications/unsubscribe-auth/ADe-iJ2kljShNQYUHUSfg3xX74REBHw_ks5rzmwkgaJpZM4NIAi- .
Sadly it gets into the minified angular code and I can't follow it very well.
I did remove your use of stringify and just put vote: '' just as a test and still get the exception, so something weird is going on. Not sure what to do at this point.
I need to head home. Let me know tomorrow if you find anything...
OK! I think I figured it out for real this time! I originally built this app quite a while ago and I mistakenly had "latest" as all the version numbers. I have replaced those with the versions that were still sitting in my local version way back when. You'll have to pull the latest changes from master, then run npm update bower update but you should be good to go after that!
I am not at that computer now. I will try it first thing in the morning and let you know.
Thank you
Oh, the "shortcode" is the "key" in the ballot table. I look forward to seeing your implementation of the unique code concept!
I envision a file called api/code.php that receives a GET param of "ballotId". The api adds an entry to the codes table and returns the generated code. You would also need to add a column in the votes table for the unique code and make (ballotId, code) be a unique index. Make sure you modify api/vote.php accordingly so that the provided code must match an entry in the codes table. You could also add other information like the username of the worker who generated the code and a timestamp.
I am from Iowa and went to the presidential caucus. The system was ridiculous. We were handed a colored index card (the color representing our district) and told to write the name of the person on it. They had no way, once inside, to determine if someone had brought additional index cards in their pocket to vote additional times. And, they would have had to read thousands of peoples' handwritten names to tally the votes!
I think you are very wise to take an electronic approach and wise to use RCV. I definitely want to help make this happen for you. Great street cred!
Also, if you don't mind, I'd like to receive an email from you (davidmoritz@gmail.com) detailing more information like where you are holding this, what kind of environment, expected attendance etc.
I did a clean checkout of your code. I am running npm install. It is asking me the following during the bower install. How should I answer:
Unable to find a suitable version for angular, please choose one by typing one of the numbers below: 1) angular#1.5.3 which resolved to 1.5.3 and is required by init-angular 2) angular#1.6.4 which resolved to 1.6.4 and is required by angular-animate#1.6.4 3) angular#>=1.4.0 which resolved to 1.6.4 and is required by angular-bootstrap#1.2.5 4) angular#^1.2.27 which resolved to 1.6.4 and is required by ng-pattern-restrict#0.2.3 5) angular#>=1.2.x which resolved to 1.6.4 and is required by angular-ui-sortable#0.13.4
Prefix the choice with ! to persist it to bower.json
? Answer
I decided to choose 1.6.4 since it was the latest.
Now I am getting the exception about success is not a function. Did I choose the wrong version of angular?
What now?
I'd suggest 1.5.3. I don't remember using angular animate for anything On Wed, Apr 26, 2017 at 9:02 AM tpitman notifications@github.com wrote:
I decided to choose 1.6.4 since it was the latest.
Now I am getting the exception about success is not a function. Did I choose the wrong version of angular?
What now?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/DavidMoritz/rcv/issues/3#issuecomment-297418073, or mute the thread https://github.com/notifications/unsubscribe-auth/ADe-iJtE4u2xOYZx2dvxwByikEbrgQoQks5rz05YgaJpZM4NIAi- .
That's the version being used in rankedchoices.com On Wed, Apr 26, 2017 at 9:02 AM David Moritz davidmoritz@gmail.com wrote:
I'd suggest 1.5.3. I don't remember using angular animate for anything On Wed, Apr 26, 2017 at 9:02 AM tpitman notifications@github.com wrote:
I decided to choose 1.6.4 since it was the latest.
Now I am getting the exception about success is not a function. Did I choose the wrong version of angular?
What now?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/DavidMoritz/rcv/issues/3#issuecomment-297418073, or mute the thread https://github.com/notifications/unsubscribe-auth/ADe-iJtE4u2xOYZx2dvxwByikEbrgQoQks5rz05YgaJpZM4NIAi- .
Sorry if this is a stupid question, but can you tell me how to use the RCV repository on an actual web server?
I am running apache2 with php7 (can install php5 if needed).