Skip to content
This repository was archived by the owner on Jul 6, 2020. It is now read-only.

Load Base Components only once#233

Open
jayaike wants to merge 13 commits into
Cloud-CV:masterfrom
jayaike:Base-Component-Features
Open

Load Base Components only once#233
jayaike wants to merge 13 commits into
Cloud-CV:masterfrom
jayaike:Base-Component-Features

Conversation

@jayaike

@jayaike jayaike commented Dec 9, 2019

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request:

  • Load the base components like header and footer only once, instead of on every page load

@codecov-io

codecov-io commented Dec 9, 2019

Copy link
Copy Markdown

Codecov Report

Merging #233 into master will decrease coverage by 0.05%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
- Coverage   51.73%   51.68%   -0.06%     
==========================================
  Files          66       66              
  Lines        3659     3659              
  Branches      413      413              
==========================================
- Hits         1893     1891       -2     
- Misses       1671     1672       +1     
- Partials       95       96       +1
Impacted Files Coverage Δ
src/app/components/nav/footer/footer.component.ts 57.57% <0%> (-6.07%) ⬇️
Impacted Files Coverage Δ
src/app/components/nav/footer/footer.component.ts 57.57% <0%> (-6.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b03bdc4...d7b5f33. Read the comment docs.

</div>
<app-footer></app-footer>
</div>
</div>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should only be 1-2 line changes. Other changes are due to spaces, indentation etc. Please remove unnecessary changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the line changes is I had to format the code after removing the footer.

@lunayach

Copy link
Copy Markdown
Member

You may want to check the conditions correctly when the user is logged in. For example, when I am logged in, in the dashboard, two footers are appearing:

out

@jayaike

jayaike commented Dec 10, 2019

Copy link
Copy Markdown
Contributor Author

I have removed the extra footer

@jayaike

jayaike commented Dec 10, 2019

Copy link
Copy Markdown
Contributor Author

I also noticed there was an extra header in the dashboard so I removed that too

@pushkalkatara

Copy link
Copy Markdown

Hi @nsjcorps Please remove all the extra lines which are left after removing the header and footer from individual components and format the files.

</div>
</div>
<app-footer></app-footer>
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format the file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file is already formatted. See the screenshot below. I guess what you are seeing is the second to the last line.

Screenshot (124)

<div class="clearfix"></div>

<app-footer *ngIf="!authService.isAuth"></app-footer>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the extra line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done that now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also made some more changes @lunayach which I have explained below. Please let me know your opinion

</div>
</div>

<app-footer *ngIf="!authService.isAuth"></app-footer>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now we do not need to check these conditions?

@lunayach

Copy link
Copy Markdown
Member

@nsjcorps, It would be great if you could review the UI on your side before pushing the PRs.

Since you permanently added <app-header-static></app-header-static> and <app-footer></app-footer> for all the components, something like this is happening,
12
and,
11

@jayaike

jayaike commented Dec 11, 2019

Copy link
Copy Markdown
Contributor Author

Ok thanks, but how will I do it in this case since all components inherit from the base component

@jayaike

jayaike commented Dec 11, 2019

Copy link
Copy Markdown
Contributor Author

How would I test the condition now that it is in the main module?

@jayaike

jayaike commented Dec 11, 2019

Copy link
Copy Markdown
Contributor Author

Should I use the URL as a test?

@jayaike

jayaike commented Dec 11, 2019

Copy link
Copy Markdown
Contributor Author

Here is what I have concluded with.

I will give the sidebar a fixed color identical to the background.
That way it will overlay the footer and still not cut off any content.

Then as for the header, I will set a condition to check if the URL contains "auth".
If it does, it should not show.

How does it look to you? Please let me know your opinion.

Thank you, it's really fun contributing to EvalAI.

@jayaike

jayaike commented Dec 11, 2019

Copy link
Copy Markdown
Contributor Author

For the header, I used "auth" because auth is the base URL for the components that don't use the header.

@jayaike

jayaike commented Dec 11, 2019

Copy link
Copy Markdown
Contributor Author

Let me give a break down of my changes.

For the issue with the header:
I first subscribed to the auth events filtering out the NavigationEnd to see where the URL stops.
I then tested to see if the route had 'auth' in them; if they did it should not show the header as that means it is either on the login page, the signup page, the reset password page, etc.
Hence, it should not show the header.

For the issue of the footer:
When the user is logged in (authenticated) it shows the footer that accommodates the sidebar.
When the user is not logged in it shows the full-length footer as it should.

All of this was accomplished while still loading the components just once instead of on every page.

I hope this is a good fix. Please let me know if you have any comments.

It took some thinking ut I believe this is an optimal solution.

@jayaike

jayaike commented Dec 11, 2019

Copy link
Copy Markdown
Contributor Author

I made 'authService' public so as to make it accessible it in app.component.html

@lunayach

Copy link
Copy Markdown
Member

@nsjcorps Thanks a lot for making changes. And, great job thinking through the solution. Checking for URL is nice but feels hardcoded, and we should avoid that. Making sidebar's colour identical to the background also feels hacky.

@lunayach

Copy link
Copy Markdown
Member

@nsjcorps I guess this is more complex than we initially thought. It might end up making the code-base more complicated than simplifying it. If you don't mind, maybe you could try solving other tasks, and meanwhile, we'll try to make this task more concrete with more specific objectives. Happy Hacking!! 😄

@jayaike

jayaike commented Dec 12, 2019

Copy link
Copy Markdown
Contributor Author

@lunayach , Alright not a problem. Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants