These are chat archives for ushahidi/Community

6th
Aug 2017
Romina Suarez
@rowasc
Aug 06 2017 19:14
Hey Aziz, I'm back. Did you find a solution to any of your issues/questions?
This is where I'm at:
For question #1 ) Videos are supported only by embedding them from youtube/vimeo as far as I can tell from the field types in the app. Again, maybe someone from the staff can help here with better info but that's what I realized today.
2) Oh I'm just using the default ones from the test suite. You can add your own custom posts with the field types you need. This documentation might help : https://www.ushahidi.com/support/post-types
3) I'll test the POST form/stages endpoint when I finish understanding the flow. Have you looked at the .apib API docs? (under docs/api in the platform codebase) Maybe something there will be of help to you as well.
to see the apib docs, you can use the aglio cli. (
  1. npm install -g aglio
  2. go to the docs directory in the ushahidi platform.
  3. aglio -i index.apib -s
  4. you can see the docs in a nice ui at 127.0.0.1:3000
azizfall
@azizfall
Aug 06 2017 19:58
yeah I saw that you can add the key when submitting a request for form_attributes so problem 1 is somewhat solved. I also got to successfully post embbeded videos on my deployment, the only problem is the video does not show up with the pop up on the map.
but yeah so the only real problem I have now is that my post request for form_stages and form_attributes are causing me weird errors, it saying that my form_id and form_stage_id respectively do not exist even though they exist in my database when I check
Screen Shot 2017-08-06 at 4.00.43 PM.png
Screen Shot 2017-08-05 at 6.25.31 PM.png
the form_attributes request is saying Bad request: Invalid form stage used, stage 1 is not in form 0
azizfall
@azizfall
Aug 06 2017 20:03
I dont know what that means but all I know is that form_id = 2 and form_stage_id = 1 exist in my database
@ushbot
@rjmackay
@rowasc
Romina Suarez
@rowasc
Aug 06 2017 20:16
@azizfall
from what I see in the screenshot, the attributes POST request error states that stage 1 is invalid for form_id 0 , not that form_id 2 and form_stage_id 1 are an invalid combination.
Romina Suarez
@rowasc
Aug 06 2017 20:25
mmm... ok so I was able to reproduce this with dummy data. And obviously there is no form 0 since form ids are autoincremental starting at 1 ..
Romina Suarez
@rowasc
Aug 06 2017 20:34
@azizfall try changing form_id to formId please.

sorry, here's what I did.
Example body for a POST request to /forms/attributes so that it stops thinking you want to add to "form 0" :

{"required":false,"options":[],"config":{},"priority":5,"label":"whenplus","type":"datetime","input":"date","description":"A date with year, month, day","form_stage_id":1,"formId":1}

Basically you need to say what formId and form_stage_id the attribute will be added to

in your /forms/attributes request I don't see the formId field being sent.

also the app sends the POST request to an URI like this when creating a form attribute:

/api/v3/forms/1/attributes

notice the use of forms/:id/attributes format instead of simply /forms/attributes

So you need to do that, as well

Romina Suarez
@rowasc
Aug 06 2017 20:39
Screen Shot 2017-08-06 at 5.39.12 PM.png
azizfall
@azizfall
Aug 06 2017 20:59
Thank you so much Romina it worked, the documentation did not have the form id as part of the request so that confused me. But I really appreciate all the help. I cant express it enough
@rowasc
Romina Suarez
@rowasc
Aug 06 2017 20:59
sooo glad this worked!!! np.
azizfall
@azizfall
Aug 06 2017 20:59
btw
if you dont know how to do this its completly fine, but do you know how I can get the Map that shows up on the front page (perhaps javascript object) on a seperate server, I want to add more features to it, but it's been very hard for me to find the source code for it
on the platform-client
Romina Suarez
@rowasc
Aug 06 2017 21:03
mmm. You mean having the platform in 1 server and the platform-client in another?
azizfall
@azizfall
Aug 06 2017 21:03
no, just the Map that shows up, where it has the pop ups of all your post
I want it so that when you click the post on the Map it redirects you to a different link
not the one it defaults to
Romina Suarez
@rowasc
Aug 06 2017 21:07
I'm not sure I follow. I probably lack some context .
  • When I open the map, I see all the markers there (posts)
  • If I click on a post/marker it shows me a popup.
  • If I click on that popup it takes me to a page with the post's information <---- is this what you need to change ?
azizfall
@azizfall
Aug 06 2017 21:09
yeah change it from post information to a different link on my site.
but in order to do that I need somehow grab the source code for the Map on to my server,
but I can't find the relevant code
Romina Suarez
@rowasc
Aug 06 2017 21:11
oh. Ok that sounds like something we can change with a bit of javascript. I'll get back to you if I find where it is.
azizfall
@azizfall
Aug 06 2017 21:14
Oh thank you so much, I cant stress it enough
Romina Suarez
@rowasc
Aug 06 2017 21:18
no worries.
OK, so
app/main/posts/views/post-view-map.directive.js
Line 159 or so (onEachFeature function) has a click handler where you can change what it does when you click on a marker
Romina Suarez
@rowasc
Aug 06 2017 21:25

so you can replace the post popup there entirely.

But, since you want to change what the popup does when you click on it, you need to touch the app/main/posts/views/card.html file .

in line ~15 you will find the actual link that you can change . Try switching <a ng-href="/posts/{{post.id}}"> to something else to check that it works
ie : <a ng-href="/posts/{{post.id}}/romina">
if this doesn't help, just let me know :) I have a bit of spare time
Romina Suarez
@rowasc
Aug 06 2017 21:31
FYI: that also changes where the link in each post takes you while being on the timeline (timeline->click on post name-> you will be taken to the URI you placed there in card.html) .
azizfall
@azizfall
Aug 06 2017 21:43
wow it actually worked thanks!!
Romina Suarez
@rowasc
Aug 06 2017 21:43
yay!
azizfall
@azizfall
Aug 06 2017 21:44
I was wondering how to just get the Map, on my own server though
but since the code is so interdepndedent that might be hard, so I might just stick to doing <iframe
but how did you figure that out so quickly?
I am not familiar with angular Js and the code has so many folders?
Romina Suarez
@rowasc
Aug 06 2017 21:50
I'm just used to searching for stuff in "new " projects coz I work in a software factory, so I switch to new codebases A LOT.
you'll get familiar with angular and the codebase soon, the frontend code is pretty nice to navigate (tons of folders but it's pretty organized)
azizfall
@azizfall
Aug 06 2017 21:52
idk I am mainly just interfacing with it now with the API and my core logic is in ruby
Romina Suarez
@rowasc
Aug 06 2017 21:52
ohhhh, neat.
azizfall
@azizfall
Aug 06 2017 21:54
but I want to play around with it a bit to see if I get get a video embedded in the popup, because now you have to click the card for you to see the embedded video
I'll see how much angular JS I can learn in the meantime
to get this done
Romina Suarez
@rowasc
Aug 06 2017 21:55
:D cool. Let me know how that goes! I'll be around .
azizfall
@azizfall
Aug 06 2017 21:56
ok cool thanks a lot, I am finishing my software internship after this week, so after that I probably will look into it in more detail