Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: set up the login page as a starting page (DSP-1292) #370

Merged
merged 6 commits into from Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/app/app-routing.module.ts
Expand Up @@ -32,7 +32,8 @@ import { UsersComponent } from './system/users/users.component';
const routes: Routes = [
{
path: '',
component: MainComponent
component: LoginComponent
// component: MainComponent
},
{
path: 'help',
Expand Down
3 changes: 2 additions & 1 deletion src/app/main/login/login.component.html
@@ -1,3 +1,4 @@
<div class="login-page">
<dsp-login-form (loginSuccess)="refresh($event)"></dsp-login-form>
<dsp-login-form (loginSuccess)="refresh()"></dsp-login-form>
Copy link
Contributor

Choose a reason for hiding this comment

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

The LoginComponent emits a boolean value in loginSuccess. I do not understand why you removed it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reversed in 27bc05c

<!-- will be reactivated: <dsp-login-form (loginSuccess)="refresh($event)"></dsp-login-form> -->
</div>
14 changes: 12 additions & 2 deletions src/app/main/login/login.component.ts
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { SessionService } from '@dasch-swiss/dsp-ui';
import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service';

@Component({
Expand All @@ -15,6 +16,7 @@ export class LoginComponent implements OnInit {
constructor (private _titleService: Title,
private _route: ActivatedRoute,
private _router: Router,
private _session: SessionService,
private _componentCommsService: ComponentCommunicationEventService) {

// set the page title
Expand All @@ -26,13 +28,21 @@ export class LoginComponent implements OnInit {
ngOnInit() {
}

refresh(status: boolean) {
refresh() {
// check if a session is active
if (this._session.getSession()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could be if(status) {, because you get the status from login-form

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactored in 34e4acf

this._router.navigate(['dashboard']);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

After successful login the user will always be redirected to the dashboard page, right?
Why not keeping this._router.navigate([this.returnUrl]);? In case a user bookmarked his project page e.g. admin.dasch.swiss/project/1111/info but (s)he's no longer logged-in, then it would be nice to be redirected to this page after logging-in.
But it's just a detail... maybe not important 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is why I redirect explicitly to the dashboard, after logging in, I get this page (which I do not want):
Screenshot 2021-01-27 at 15 56 58

Copy link
Contributor

Choose a reason for hiding this comment

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

haha...yes true. The root path / was handled in the main component before. This component showed the landing page or the dashboard. Yes, as I said "it's just a little detail". I can live with it.
Another solution would have been to integrate the login page instead of the landing page. I.e. that still the main component handles the redirection.
But it's fine 😉

}

// TO REPLACE THE METHOD ABOVE ONCE WE WILL USE DSP-APP AS A RESEARCH PLATFORM AGAIN
/* refresh(status: boolean) {

// go to previous route:
if (status) {
this._router.navigate([this.returnUrl]);
this._componentCommsService.emit(new EmitEvent(Events.LoginSuccess, true));
}
}
} */

}