johndutter / metube

The new YouTube
MIT License
0 stars 0 forks source link

Todo Week of January 27th #8

Closed Jassiem closed 10 years ago

Jassiem commented 10 years ago

Read up on/ Think about: user levels. How to handle in Angular & rails. Promises possibly. nested states overall ui layout

johndutter commented 10 years ago

Might not get my new login/signup partials pushed this evening. I'll let you know when I do.

Hopefully by the time I push them I can also confirm that they are properly creating/logging in users.

Jassiem commented 10 years ago

I have the api service and the user data service working. Do you want me to push first or wait for you? I forgot exactly what you changed. I've made a couple of small changes to the login/dashboard controllers, but it was just for testing. It can all be removed.

On Sun, Jan 26, 2014 at 11:50 PM, johndutter notifications@github.comwrote:

Might not get my new login/signup partials pushed this evening. I'll let you know when I do.

Hopefully by the time I push them I can also confirm that they are properly creating/logging in users.

— Reply to this email directly or view it on GitHubhttps://github.com/johndutter/metube/issues/8#issuecomment-33341986 .

Jassiem commented 10 years ago

I merged my AngularService branch with master and pushed. I made use of the api service and the user data service in the dashboard controller and the login controller. I left the test stuff in there so you could see that it worked.

johndutter commented 10 years ago

Do you think api call should just call whatever URL you give it and not tack it onto /api?

johndutter commented 10 years ago

I merged your stuff into mine and pushed to master.

Tomorrow I plan to work on secured/unsecured partials.

I also need to work on actually using that global userdata to display/not display some things like login/logout in the dashboard.

I have some homework so we'll see how quickly I can get it done.

johndutter commented 10 years ago

@Jassiem I just pushed to master with my latest.

This includes a logout function that works. It also includes a get-user-info route and controller in rails that work.

The problem is that our global service isn't working quite how we expected (the update won't propagate to all controllers using that UserData). Unless I'm doing something wrong. Look here: https://variadic.me/posts/2013-10-15-share-state-between-controllers-in-angularjs.html

johndutter commented 10 years ago

It would work if say Nav was waiting to look at UserData until a function.

I.e. 'click me' does $scope.data = UserData

then Nav would show an update that occurred if you clicked 'click me'. But if UserData was already $scope.data = UserData then someone else changes UserData Nav won't see the difference in $scope.data.

Unless I'm doing something wrong I very well may be.

johndutter commented 10 years ago

Either way you can pull when you have the time this is pretty much all working other than this UserData problem.

I cleaned up the controllers as well.

Jassiem commented 10 years ago

Ok so I just pushed a few changes to master.

  1. I got the 401 redirect working. It is based on promises so I had to do a little reading on that to figure it out. http://wiki.commonjs.org/wiki/Promises http://docs.angularjs.org/api/ng.$q If you try to go to dashboard without being logged in you will be redirected to login.
  2. I got the UserData service working. In some controllers the UserData object was being overwritten again by the response data. But something else was wrong too. It was only saving if pages were accessed via ui-sref. That was because the app was being reloaded when the page was refreshed or accessed directly from browser. I just uncommented the call to get-user-data in app.run and that took care of things.
  3. I am returning a status code in the check_login function in session_helper. It makes it easier to work with the 401 redirect. I was reading up on RESTful APIs and I also think sending the status headers is good practice. Say someone wanted to user our API, and replace an old one. Status headers are common and expected so they wouldn't have to change their code much to consume our api. It's a contrived example, but it so easy to send status headers that I think we might as well. render :json => {user: 'data', userid: 2}, :status => ok

Let me know what you think.

johndutter commented 10 years ago
  1. I like it but it flickers (trys to go to dashboard then redirects). Would you have a problem putting checkLogin back in? We could leave in all the code you have just checkLogin would hopefully prevent the flicker on our (hopefully not that many) secured pages.
  2. Great job! This is perfect.
  3. You are probably right--we can stop using success: true/false and go over to :status ok. What is a good status code we can use that won't make angular think there was an error (i.e. angular still gets the data).
johndutter commented 10 years ago

Overall I think we've made some really good progress this week already. Come this weekend we should be in a good position to really dive into the complexities of a master layout.

Jassiem commented 10 years ago

Yea you're right. The flicker is kind of annoying. Let's put the check login back in.

With that function I don't think we'll need interceptors right? Unless you can think of another use.

I think we'll be able to come up with a layout and start on the video model this weekend. On Jan 29, 2014 10:37 AM, "johndutter" notifications@github.com wrote:

Overall I think we've made some really good progress this week already. Come this weekend we should be in a good position to really dive into the complexities of a master layout.

Reply to this email directly or view it on GitHubhttps://github.com/johndutter/metube/issues/8#issuecomment-33595295 .

johndutter commented 10 years ago

How I had the interceptor before (not sure what changes were made) was for the API (like if you hit an API when you were supposed to be logged in and then the server sends back a 401 then angular is like "oops redirect to login somehow you got logged out and should have not triggered that api call").

So I think we should keep that we would still want that behavior if someone ever calls some api somehow and is not logged in--we'd return a 401 in rails and they would get redirected to /login. This wouldn't flicker because they'd be doing an api call from a controller/partial that is already loaded.

Does that sound right?

Jassiem commented 10 years ago

Oh I see. Ok yea, we'll need both then. On Jan 29, 2014 10:56 AM, "johndutter" notifications@github.com wrote:

How I had the interceptor before (not sure what changes were made) was for the API (like if you hit an API when you were supposed to be logged in and then the server sends back a 401 then angular is like "oops redirect to login somehow you got logged out and should have not triggered that api call").

So I think we should keep that we would still want that behavior if someone ever calls some api somehow and is not logged in--we'd return a 401 in rails and they would get redirected to /login. This wouldn't flicker because they'd be doing an api call from a controller/partial that is already loaded.

Does that sound right?

Reply to this email directly or view it on GitHubhttps://github.com/johndutter/metube/issues/8#issuecomment-33597469 .

Jassiem commented 10 years ago

I'll go ahead and add the check login function back and then push On Jan 29, 2014 10:56 AM, "johndutter" notifications@github.com wrote:

How I had the interceptor before (not sure what changes were made) was for the API (like if you hit an API when you were supposed to be logged in and then the server sends back a 401 then angular is like "oops redirect to login somehow you got logged out and should have not triggered that api call").

So I think we should keep that we would still want that behavior if someone ever calls some api somehow and is not logged in--we'd return a 401 in rails and they would get redirected to /login. This wouldn't flicker because they'd be doing an api call from a controller/partial that is already loaded.

Does that sound right?

Reply to this email directly or view it on GitHubhttps://github.com/johndutter/metube/issues/8#issuecomment-33597469 .

Jassiem commented 10 years ago

Ok I added it back in and pushed. Its much better without the flicker.