These are chat archives for ushahidi/Community

7th
Apr 2016
Ushbot
@ushbot
Apr 07 2016 06:53
[Mariah, Ushahidi] Hello, I need help with adding fields to registration page
[Mariah, Ushahidi] we have hosted deployment on our own server
[Mariah, Ushahidi] @Jason can you help me? Thanks.
Ushbot
@ushbot
Apr 07 2016 07:04
[Angela Oduor Lungati, Ushahidi] hey @Jason and @Robbie see above request from @MathiasAntonsson
[Angela Oduor Lungati, Ushahidi] sorry, @MariahGuest
[Mariah, Ushahidi] Yes please help thanks
Ushbot
@ushbot
Apr 07 2016 07:20
[Jason Mule, Ushahidi] @MariaGuest Hi, do you mean adding fields for a post type?
Ushbot
@ushbot
Apr 07 2016 07:35
[Mariah, Ushahidi] nope
[Mariah, Ushahidi] @Jason nope, I meant in the registration page
[Mariah, Ushahidi] When user wants to sign up for an account. I'll attach a screenshot
[Mariah, Ushahidi] File uploaded
[Mariah, Ushahidi] please check it @Jason
[Mariah, Ushahidi] I added a Location and Vocation fields but it's displaying a user_createvocation placeholder
[Mariah, Ushahidi] I also want to add a phone number field to send SMS notifications to them
Ushbot
@ushbot
Apr 07 2016 07:49
[Jason Mule, Ushahidi] Sorry. Let me take a look...
[Mariah, Ushahidi] @Jason okay thanks
Ushbot
@ushbot
Apr 07 2016 08:10
[Jason Mule, Ushahidi] Could you share the full screenshot of that page?
Ushbot
@ushbot
Apr 07 2016 08:15
[Mariah, Ushahidi] Sure
[Mariah, Ushahidi] @Jason please take a look
Ushbot
@ushbot
Apr 07 2016 08:24
[Jason Mule, Ushahidi] so, we have notifications set up for saved searches and collections. A user is already able to add their contact under the notifications menu when you click your username. Is that the functionality that you were looking for?
[Mariah, Ushahidi] Yes
[Jason Mule, Ushahidi] When adding fields to the form, you will notice that we use a library called angular-translate to translate the names and labels.
[Mariah, Ushahidi] As you can see, I need to get location, vocation and mobile number
[Mariah, Ushahidi] but in the screenshot I haven't added a number field yet
[Mariah, Ushahidi] so where will I find that library>
[Mariah, Ushahidi] ?
[Jason Mule, Ushahidi] the locale strings are in a file called app/common/locales/en.json
[Jason Mule, Ushahidi] you installed it when you ran `npm install`
[Mariah, Ushahidi] So what do I need to do with en.json?
[Jason Mule, Ushahidi] You can look at how the other fields are added on the form and do the same with yours
[Mariah, Ushahidi] So I will add location and others on that?
[Jason Mule, Ushahidi] en.json contains the translation strings. This is where you will put you labels and names so that they get translated when the form is displayed...
Ushbot
@ushbot
Apr 07 2016 08:29
[Jason Mule, Ushahidi] The best way to tackle this would be to follow what has been done for the rest of the form fields right through to the API calls. Does that make sense?
[Mariah, Ushahidi] Okay. I added 3 labels and names
[Mariah, Ushahidi] but it's not reflected on the site yet
[Mariah, Ushahidi] Still user_create.location
[Mariah, Ushahidi] I uploaded the changes
[Mariah, Ushahidi] "user_create" : {
"full_name": "Display Name",
"email": "Email Address",
"vocation" : "Vocation",
"location" : "Location",
"phone_number" : "Phone Number",
"role": "Role"
},
Ushbot
@ushbot
Apr 07 2016 08:35
[Jason Mule, Ushahidi] You need to call translate on the template e.g. the label for Name looks like this:
[Jason Mule, Ushahidi] <label class="input-label" ng-class="..." for="full\_name" translate>
[Jason Mule, Ushahidi] notice translate before the closing tag.
[Mariah, Ushahidi] register.html?
[Jason Mule, Ushahidi] yes.
[Jason Mule, Ushahidi] likewise, the placeholder for Name looks like this: placeholder="{{ 'user_create.full_name'|translate }}"
[Jason Mule, Ushahidi] note the call to translate once more.
[Mariah, Ushahidi] I have this
[Mariah, Ushahidi] <!-- Vocation -->
<label class="input-label" ng-class="{ 'error': form.vocation.$invalid && form.vocation.$dirty, 'success': form.vocation.$valid }" for="vocation" translate>user.vocation</label>
<input id="vocation" name="vocation" type="text" ng-class="{ 'error': form.vocation.$invalid && form.vocation.$dirty }" ng-disabled="state.processing" placeholder="{{ 'user\_create.vocation'|translate }}" ng-maxlength="150" ng-model="vocation" required>
<p ng-repeat="\(error, value\) in form.vocation.$error" ng-show="form.vocation.$dirty" class="alert error" translate="{{'user.valid.vocation.' + error}}"></p>
Ushbot
@ushbot
Apr 07 2016 08:43
[Jason Mule, Ushahidi] did you re-run gulp?
[Mariah, Ushahidi] Yes
[Mariah, Ushahidi] but only Email address is displaying its placeholder
[Mariah, Ushahidi] File uploaded
Ushbot
@ushbot
Apr 07 2016 08:59
[Jason Mule, Ushahidi] is en.json saved?
[Mariah, Ushahidi] yes
[Mariah, Ushahidi] I updated it
[Jason Mule, Ushahidi] ok, checking...
Ushbot
@ushbot
Apr 07 2016 09:05
[Jason Mule, Ushahidi] not sure why this is not updating for you. If you have the strings in en.json then they should be found...
[Mariah, Ushahidi] yes
[Mariah, Ushahidi] I have unexpected token
[Mariah, Ushahidi] in en.json
Ushbot
@ushbot
Apr 07 2016 09:12
[Mariah, Ushahidi] I tried to run gulp
Ushbot
@ushbot
Apr 07 2016 09:27
[Jason Mule, Ushahidi] you probably have a syntax error in there somewhere...
[Mariah, Ushahidi] it's okay now
[Mariah, Ushahidi] gulp run successfully
[Mariah, Ushahidi] but the labels are not updated
[Mariah, Ushahidi] but why is it that gulp is so slow?
[Jason Mule, Ushahidi] are you using gulp to watch for changes as you edit or are you running a gulp build at the end and uploading that...
[Mariah, Ushahidi] I'm using gulp build at the end
Ushbot
@ushbot
Apr 07 2016 09:35
[Jason Mule, Ushahidi] it might be more convenient to change code and use gulp to watch for changes...but if you have a new build, you should have your new strings.
[Mariah, Ushahidi] How?
[Mariah, Ushahidi] I just type gulp
[Mariah, Ushahidi] do I need to type gulp build?
Ushbot
@ushbot
Apr 07 2016 09:41
[Jason Mule, Ushahidi] to watch for changes, create a .env file at the root of your platform-client and add:
[Jason Mule, Ushahidi] NODE_SERVER=true
BACKEND_URL=
[Jason Mule, Ushahidi] BACKEND_URL should point to your API url. Then type gulp
[Mariah, Ushahidi] I already have that
[Jason Mule, Ushahidi] ok type gulp, and go to localhost:8080
Ushbot
@ushbot
Apr 07 2016 09:47
[Mariah, Ushahidi] Done that
[Jason Mule, Ushahidi] are you able to see the client?
[Mariah, Ushahidi] yes
[Mariah, Ushahidi] It's updated now when I appended 8080
[Jason Mule, Ushahidi] ok, good. You can use that and when you are happy with your changes you can create a new build and host it.
[Mariah, Ushahidi] But without 8080 it's not updated
[Mariah, Ushahidi] how can I create a new build?
Ushbot
@ushbot
Apr 07 2016 10:07
[Jason Mule, Ushahidi] You do that by running `gulp build`
Ushbot
@ushbot
Apr 07 2016 10:16
[Mariah, Ushahidi] okay
[Mariah, Ushahidi] I did it but nothing's changed
Ushbot
@ushbot
Apr 07 2016 10:32
[Jason Mule, Ushahidi] are you watching the changes using gulp?
[Mariah, Ushahidi] YEs
[Jason Mule, Ushahidi] so when you changed en.json, your changes should reflect...
[Mariah, Ushahidi] Until now it's not reflecting :(
[Mariah, Ushahidi] I'm disappointed
[Jason Mule, Ushahidi] I am assuming that you are running gulp on a terminal?
Ushbot
@ushbot
Apr 07 2016 10:39
[Mariah, Ushahidi] yes
[Mariah, Ushahidi] on putty
[Jason Mule, Ushahidi] On mine, I have this output when I try to add a string to en.json:
[Jason Mule, Ushahidi] [12:04:01]
/ushahidi/platform-client/app/common/locales/en.json:559
"vocation: "Vocation","
^
ParseError: Unexpected token
[12:04:01] gulp-notify: [Error running Gulp] Error: Unexpected token
[12:04:07]
/ushahidi/platform-client/app/common/locales/en.json:559
"vocation: "Vocation",
^
ParseError: Unexpected token
[12:04:07] gulp-notify: [Error running Gulp] Error: Unexpected token
[12:04:26] gulp-notify: [Gulp notification] JS compiled
[12:04:26] /ushahidi/platform-client/server/www/js/bundle.js.map reloaded.
[12:04:26] gulp-notify: [Gulp notification] JS compiled
[12:04:26] /ushahidi/platform-client/server/www/js/bundle.js reloaded.
[Jason Mule, Ushahidi] you can see that gulp tells me about the error and after I fix it it compiles and reloads a new bundle.js
[Jason Mule, Ushahidi] are you seeing the same kind of output?
[Mariah, Ushahidi] No
[Mariah, Ushahidi] gulp is very slow to view changes
[Jason Mule, Ushahidi] what are the last lines of your gulp output
[Mariah, Ushahidi] I'm not sure if it's already finished
[Mariah, Ushahidi] [06:21:21] /var/www/html/platform-client/server/www/fonts/Lato/fonts/Lato-regular/Lato-regular.eot reloaded.
[06:21:21] /var/www/html/platform-client/server/www/fonts/Lato/fonts/Lato-regular/Lato-regular.svg reloaded.
[06:21:21] /var/www/html/platform-client/server/www/fonts/Lato/fonts/Lato-regular/Lato-regular.ttf reloaded.
[06:21:21] /var/www/html/platform-client/server/www/fonts/Lato/fonts/Lato-regular/Lato-regular.woff reloaded.
[06:21:21] /var/www/html/platform-client/server/www/fonts/Lato/fonts/Lato-regular/Lato-regular.woff2 reloaded.
[06:21:21] Finished 'font' after 1.22 min
[06:21:21] Starting 'build'...
[06:21:21] Finished 'build' after 9.35 μs
[06:21:21] Starting 'default'...
[06:21:21] Finished 'default' after 8.15 μs
[Mariah, Ushahidi] Been stuck here for 2 weeks already
Ushbot
@ushbot
Apr 07 2016 10:44
[Mariah, Ushahidi] and still not proceeding
[Mariah, Ushahidi] hays :(
[Jason Mule, Ushahidi] so typing `gulp` like that means that gulp will stay watching for changes...
[Mariah, Ushahidi] I've done that many times
Ushbot
@ushbot
Apr 07 2016 10:52
[Jason Mule, Ushahidi] so this is different from running `gulp build` which will build and give you your prompt after the build is complete.
[Jason Mule, Ushahidi] running `gulp` will listen for changes so it won't exit. You stop it by running ctrl + c
[Jason Mule, Ushahidi] you can take a look at our gulpfile.js for details...
[Mariah, Ushahidi] yes I've done that
Ushbot
@ushbot
Apr 07 2016 11:05
[Mariah, Ushahidi] nothing's changed
[Mariah, Ushahidi] :(
[Mariah, Ushahidi] gulp is not progressing
[Mariah, Ushahidi] it's stuck in fonts
[Mariah, Ushahidi] reload
[Mariah, Ushahidi] worst case scenario I have to manually input the labels and placeholders
[Mariah, Ushahidi] it's time wasting
[Mariah, Ushahidi] grrr
[Jason Mule, Ushahidi] I don't think we are on the same page. Remember, `gulp` will not exit it will stay up watching for your changes
[Mariah, Ushahidi] Yes I know but it's not moving
[Mariah, Ushahidi] I've been waiting for it for an hour
[Mariah, Ushahidi] disappointing
[Jason Mule, Ushahidi] You will only see output when you change files in /var/www/html/platform-client
[Mariah, Ushahidi] I got error in Armenia
[Mariah, Ushahidi] "hy-AM": "Armenian (Armenia)",
[Mariah, Ushahidi] What's the error here
[Mariah, Ushahidi] I've never edited this
Ushbot
@ushbot
Apr 07 2016 11:11
[Jason Mule, Ushahidi] what's the error?
[Mariah, Ushahidi] unexpected token
[Jason Mule, Ushahidi] ok, could you fix and retry.
[Mariah, Ushahidi] File uploaded
[Mariah, Ushahidi] check the screenshot
Ushbot
@ushbot
Apr 07 2016 11:35
[Mariah, Ushahidi] Anyway, this wasted my time. I just manually typed placeholders and labels without using en.json
[Mariah, Ushahidi] How can I now save values of these fields to db?
Ushbot
@ushbot
Apr 07 2016 11:41
[Jason Mule, Ushahidi] That's not a good idea. You should at least lint the file to check for those errors and fix them to get your translations to work. Saving the values involves calling the API. The best way to tackle this is to look at how the other values are saved.
[Mariah, Ushahidi] How to save values?
[Mariah, Ushahidi] How? I don't have an ideas
[Mariah, Ushahidi] idea*
Ushbot
@ushbot
Apr 07 2016 11:52
[Jason Mule, Ushahidi] take a look at platform-client/app/common/controllers/register-controller.js.
[Jason Mule, Ushahidi] From there you will see that /home/jason/opensourceprojects/ushahidi/platform-client/app/common/services/registration.js is called.
[Jason Mule, Ushahidi] And this particular line makes the HTTP request:
[Jason Mule, Ushahidi] $http.post(Util.apiUrl('/register'), payload).then(handleRequestSuccess, handleRequestError);
[Jason Mule, Ushahidi] You will need to add the fields to the DB as well.
[Jason Mule, Ushahidi] for the API that is...
[Mariah, Ushahidi] I already added fields to the DB
[Jason Mule, Ushahidi] Have you been able to look at the Entities as well on the API?
[Mariah, Ushahidi] Nope
[Mariah, Ushahidi] I don't see any registration.js in register-controller.js
Ushbot
@ushbot
Apr 07 2016 11:59
[Mariah, Ushahidi] What's my next step?
[Jason Mule, Ushahidi] could you look at your paths again.
[Mariah, Ushahidi] what path?
Ushbot
@ushbot
Apr 07 2016 12:05
[Jason Mule, Ushahidi] Go to the where you installed your client and look for app/common/services/registration.js and app/common/controllers/register-controller.js
[Mariah, Ushahidi] I have them
[Mariah, Ushahidi] now what's next
[Jason Mule, Ushahidi] yes, please note how the other fields are handled. I have pointed out the call to the endpoint that eventually happens: $http.post(Util.apiUrl('/register'), payload).then(handleRequestSuccess, handleRequestError);
[Mariah, Ushahidi] okay
[Mariah, Ushahidi] In registration.js, I have made something like this: register: function (realname, location, vocation, email, password) {
var payload = {
realname: realname,
location: location,
vocation: vocation,
email: email,
password: password
},
[Mariah, Ushahidi] is this correct?
Ushbot
@ushbot
Apr 07 2016 12:13
[Mariah, Ushahidi] In register-controller.js, I changed to this: $scope.registerSubmit = function () {
$scope.processing = true;
    Registration
        .register\($scope.realname, $scope.location, $scope.vocation, $scope.email, $scope.password\)
        .then\(registerSuccess, registerFailed\);
};
[Jason Mule, Ushahidi] Yes. And ofcourse for this to work you need to make changes to the API that handles registration...
[Mariah, Ushahidi] how?
Ushbot
@ushbot
Apr 07 2016 12:19
[Jason Mule, Ushahidi] Have you looked at the API code yet?
[Mariah, Ushahidi] I
[Mariah, Ushahidi] I'm looking at the API code
[Mariah, Ushahidi] but no idea where the API that handles registration
[Mariah, Ushahidi] or the thing that makes changes to db
[Jason Mule, Ushahidi] sorry, will be back in a bit. Yeah, that might be a bit difficult to follow...
[Mariah, Ushahidi] Please point me to the API
[Mariah, Ushahidi] so I can work on it now
Ushbot
@ushbot
Apr 07 2016 12:24
[Jason Mule, Ushahidi] Please go to application/classes/Controller/Api/Register.php
[Mariah, Ushahidi] OKay I"m here now
[Jason Mule, Ushahidi] We use usecases and entities to move data around...use the namespaces to try to follow.
[Mariah, Ushahidi] where are usecases and entities?
Ushbot
@ushbot
Apr 07 2016 16:12
[Jason Mule, Ushahidi] Hi Mariah. Were you able to look at the API code?
[Mariah, Ushahidi] Hello
[Mariah, Ushahidi] @Jason are you there?
[Jason Mule, Ushahidi] Yes. Were you able to follow the code?
[Mariah, Ushahidi] No unfortunately
[Mariah, Ushahidi] I'm stuck with API
Ushbot
@ushbot
Apr 07 2016 16:32
[Jason Mule, Ushahidi] It might be a bit difficult to follow, but the controller eventually calls this usecase with the payload src/Core/Usecase/User/RegisterUser.php
[Mariah, Ushahidi] Okay I check the registeruser.php
do i need to change?
[Jason Mule, Ushahidi] nope, in there that calls application/classes/Ushahidi/Repository/User.php
[Mariah, Ushahidi] What do I need to change in User.php?
Ushbot
@ushbot
Apr 07 2016 16:38
[Jason Mule, Ushahidi] look at the register method in there but before that we need to talk about Entities :-)
[Mariah, Ushahidi] okay I'm seeing register method
[Jason Mule, Ushahidi] Entities is how data get moved around so you need to add you new fields to src/Core/Entity/User.php
[Mariah, Ushahidi] okay
[Mariah, Ushahidi] So what do I need to do in Entity?
Ushbot
@ushbot
Apr 07 2016 16:45
[Jason Mule, Ushahidi] Add your new fields as properties.
[Jason Mule, Ushahidi] You can see that this has been done for password for example.
[Mariah, Ushahidi] okay it's now working!
[Mariah, Ushahidi] thanks
[Mariah, Ushahidi] but another one
[Jason Mule, Ushahidi] cool...
[Mariah, Ushahidi] How do I display this in the profile? or list of users?
[Jason Mule, Ushahidi] You might need to change this in the client code. Again, I urge you to look at the other properties as an example...
[Jason Mule, Ushahidi] and maybe when you have time, look at how the API code is tied together...
Ushbot
@ushbot
Apr 07 2016 16:50
[Mariah, Ushahidi] okay. Another one how do I get list of user's specific info like username?
[Mariah, Ushahidi] I only need to get usernames
[Mariah, Ushahidi] in the form of array
[Mariah, Ushahidi] something like that
Ushbot
@ushbot
Apr 07 2016 17:19
[Mariah, Ushahidi] Where is the profile here?