added login component & routing
This commit is contained in:
parent
6fd7c76c24
commit
87ce212451
8 changed files with 58 additions and 5 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
@if (this.isLoggedIn === undefined) {
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
} @else {
|
||||||
<div [ngClass]="{ 'blur-background': sharedService.isAnyDialogOpen }">
|
<div [ngClass]="{ 'blur-background': sharedService.isAnyDialogOpen }">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<app-sidebar></app-sidebar>
|
<app-sidebar></app-sidebar>
|
||||||
|
|
@ -22,3 +25,4 @@
|
||||||
></app-contact-delete>
|
></app-contact-delete>
|
||||||
}
|
}
|
||||||
<app-overlay></app-overlay>
|
<app-overlay></app-overlay>
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { CommonModule } from '@angular/common';
|
||||||
import { SharedService } from './services/shared.service';
|
import { SharedService } from './services/shared.service';
|
||||||
import { ContactDeleteComponent } from './components/contacts/contact-delete/contact-delete.component';
|
import { ContactDeleteComponent } from './components/contacts/contact-delete/contact-delete.component';
|
||||||
import { OverlayComponent } from './shared/components/overlay/overlay.component';
|
import { OverlayComponent } from './shared/components/overlay/overlay.component';
|
||||||
|
import { FirebaseService } from './services/firebase.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
|
|
@ -28,16 +29,26 @@ import { OverlayComponent } from './shared/components/overlay/overlay.component'
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
title = 'join';
|
title = 'join';
|
||||||
|
isLoggedIn: string = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public langService: LanguageService,
|
public langService: LanguageService,
|
||||||
private router: Router,
|
public sharedService: SharedService,
|
||||||
public sharedService: SharedService
|
private firebaseService: FirebaseService,
|
||||||
|
private router: Router
|
||||||
) {
|
) {
|
||||||
this.router.events.subscribe((event) => {});
|
this.isLoggedIn = this.firebaseService.getCurrentUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.getUserIdInLocalStorage();
|
console.log(this.isLoggedIn);
|
||||||
|
|
||||||
|
if (this.isLoggedIn === undefined) {
|
||||||
|
this.router.navigate(['/login']);
|
||||||
|
} else {
|
||||||
|
this.getUserIdInLocalStorage();
|
||||||
|
this.router.navigate(['/summary']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserIdInLocalStorage() {
|
getUserIdInLocalStorage() {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,11 @@ import { ContactsComponent } from './components/contacts/contacts.component';
|
||||||
import { OverlayComponent } from './shared/components/overlay/overlay.component';
|
import { OverlayComponent } from './shared/components/overlay/overlay.component';
|
||||||
import { TaskOverlayComponent } from './shared/components/overlay/task-overlay/task-overlay.component';
|
import { TaskOverlayComponent } from './shared/components/overlay/task-overlay/task-overlay.component';
|
||||||
import { TaskEditOverlayComponent } from './shared/components/overlay/task-edit-overlay/task-edit-overlay.component';
|
import { TaskEditOverlayComponent } from './shared/components/overlay/task-edit-overlay/task-edit-overlay.component';
|
||||||
|
import { LoginComponent } from './components/login/login.component';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: '', component: SummaryComponent },
|
{ path: '', component: SummaryComponent },
|
||||||
|
{ path: 'login', component: LoginComponent },
|
||||||
{ path: 'summary', component: SummaryComponent },
|
{ path: 'summary', component: SummaryComponent },
|
||||||
{ path: 'add-task', component: AddTaskComponent },
|
{ path: 'add-task', component: AddTaskComponent },
|
||||||
{ path: 'add-task/:id', component: AddTaskComponent },
|
{ path: 'add-task/:id', component: AddTaskComponent },
|
||||||
|
|
|
||||||
1
src/app/components/login/login.component.html
Normal file
1
src/app/components/login/login.component.html
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<p>login works!</p>
|
||||||
0
src/app/components/login/login.component.scss
Normal file
0
src/app/components/login/login.component.scss
Normal file
23
src/app/components/login/login.component.spec.ts
Normal file
23
src/app/components/login/login.component.spec.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LoginComponent } from './login.component';
|
||||||
|
|
||||||
|
describe('LoginComponent', () => {
|
||||||
|
let component: LoginComponent;
|
||||||
|
let fixture: ComponentFixture<LoginComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [LoginComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(LoginComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
12
src/app/components/login/login.component.ts
Normal file
12
src/app/components/login/login.component.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-login',
|
||||||
|
standalone: true,
|
||||||
|
imports: [],
|
||||||
|
templateUrl: './login.component.html',
|
||||||
|
styleUrl: './login.component.scss'
|
||||||
|
})
|
||||||
|
export class LoginComponent {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -22,7 +22,7 @@ export class FirebaseService implements OnDestroy {
|
||||||
allTasks: Task[] = [];
|
allTasks: Task[] = [];
|
||||||
filteredTasks: Task[] = [];
|
filteredTasks: Task[] = [];
|
||||||
allUsers: User[] = [];
|
allUsers: User[] = [];
|
||||||
isUserLogin: boolean = true;
|
isUserLogin: boolean = false;
|
||||||
|
|
||||||
unsubTask;
|
unsubTask;
|
||||||
unsubUser;
|
unsubUser;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue