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

format eslint #4

Merged
merged 1 commit into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</a>

<div *ngIf="loggedIn$ | async">
<mat-divider></mat-divider>
<mat-divider></mat-divider>
<h3 matSubheader>User</h3>
<span *ngFor="let item of navigationUser">
<a mat-list-item *ngIf="item.children === undefined || item.children.length === 0" (click)="sidenav.close()"
Expand All @@ -25,7 +25,7 @@ <h3 matSubheader>{{item.label}}</h3>
</mat-nav-list>
</span>
</div>

</mat-nav-list>
</mat-sidenav>

Expand Down
4 changes: 2 additions & 2 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed, waitForAsync } from '@angular/core/testing';
import {TestBed, waitForAsync} from '@angular/core/testing';

import { AppComponent } from './app.component';
import {AppComponent} from './app.component';

describe('AppComponent', () => {
beforeEach(waitForAsync(() => {
Expand Down
106 changes: 53 additions & 53 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
import { Component, HostBinding, OnDestroy, OnInit } from '@angular/core'
import { Title } from '@angular/platform-browser'
import { ActivationEnd, Router } from '@angular/router'
import { select, Store } from '@ngrx/store'
import { environment as env } from '@env'
import { selectorSettings } from '@app/settings'
import { OverlayContainer } from '@angular/cdk/overlay'
import * as fromAuth from '@app/auth/reducers'
import * as Auth from '@app/auth/actions/auth'
import { RefreshToken } from '@app/auth/actions/auth'
import { Observable, Subject } from 'rxjs'
import { filter, map, takeUntil } from 'rxjs/operators'
import { User } from '@app/auth/models/user'
import {Component, HostBinding, OnDestroy, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {ActivationEnd, Router} from '@angular/router';
import {select, Store} from '@ngrx/store';
import {environment as env} from '@env';
import {selectorSettings} from '@app/settings';
import {OverlayContainer} from '@angular/cdk/overlay';
import * as fromAuth from '@app/auth/reducers';
import * as Auth from '@app/auth/actions/auth';
import {RefreshToken} from '@app/auth/actions/auth';
import {Observable, Subject} from 'rxjs';
import {filter, map, takeUntil} from 'rxjs/operators';
import {User} from '@app/auth/models/user';

@Component({
selector: 'ndfsm-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit, OnDestroy {
@HostBinding('class') componentCssClass
@HostBinding('class') componentCssClass;
// TODO EXTRACT
navigation = [
{ link: 'tools', label: 'Tools' },
]
{link: 'tools', label: 'Tools'},
];
// navigationDev = [
// { link: 'games', label: 'Games' },
// { link: 'scripts', label: 'Scripts' },
// ]

// todo move to module
navigationUser = [
{ link: 'finance', label: 'Finance',
{
link: 'finance', label: 'Finance',
children: [
{ link: 'finance/dashboard', label: 'Dashboard'},
{ link: 'finance/transaction', label: 'Transactions'},
]},
]
{link: 'finance/dashboard', label: 'Dashboard'},
{link: 'finance/transaction', label: 'Transactions'},
]
},
];
navigationSideMenu = [
...this.navigation,
{ link: 'settings', label: 'Settings' },
]
loggedIn$: Observable<boolean>
userName$: Observable<User>
{link: 'settings', label: 'Settings'},
];
loggedIn$: Observable<boolean>;
userName$: Observable<User>;

private unsubscribe$: Subject<void> = new Subject<void>()
private unsubscribe$: Subject<void> = new Subject<void>();

constructor (
constructor(
public overlayContainer: OverlayContainer,
private store: Store<any>,
private router: Router,
private titleService: Title) {

this.store.dispatch(new RefreshToken(true))
this.store.dispatch(new RefreshToken(true));

this.loggedIn$ = this.store.pipe(select(fromAuth.getLoggedIn))
this.userName$ = this.store.pipe(select(fromAuth.getUser))
this.loggedIn$ = this.store.pipe(select(fromAuth.getLoggedIn));
this.userName$ = this.store.pipe(select(fromAuth.getUser));
}

ngOnInit () {
ngOnInit() {
// TODO extract
document.getElementById('global-spinner').
setAttribute('style', 'display: none;')
document.getElementById('global-spinner').setAttribute('style', 'display: none;');

this.store.select(selectorSettings).pipe(
takeUntil(this.unsubscribe$),
map(({ theme }) => theme.toLowerCase()),
map(({theme}) => theme.toLowerCase()),
).subscribe(theme => {
this.componentCssClass = theme
this.overlayContainer.getContainerElement().classList.add(theme)
})
this.componentCssClass = theme;
this.overlayContainer.getContainerElement().classList.add(theme);
});

this.router.events.pipe(filter(event => event instanceof ActivationEnd)).
subscribe((event: ActivationEnd) => {
let lastChild = event.snapshot
while (lastChild.children.length) {
lastChild = lastChild.children[0]
}
const { title } = lastChild.data
this.titleService.setTitle(
title ? `${title} - ${env.appName}` : env.appName,
)
})
this.router.events.pipe(filter(event => event instanceof ActivationEnd)).subscribe((event: ActivationEnd) => {
let lastChild = event.snapshot;
while (lastChild.children.length) {
lastChild = lastChild.children[0];
}
const {title} = lastChild.data;
this.titleService.setTitle(
title ? `${title} - ${env.appName}` : env.appName,
);
});
}

ngOnDestroy (): void {
this.unsubscribe$.next()
this.unsubscribe$.complete()
ngOnDestroy(): void {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}

onLogoutClick () {
this.store.dispatch(new Auth.Logout())
onLogoutClick() {
this.store.dispatch(new Auth.Logout());
}
}
43 changes: 22 additions & 21 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { BrowserModule } from '@angular/platform-browser'
import { NgModule } from '@angular/core'
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';

import { AppComponent } from './app.component'
import { HttpClientModule } from '@angular/common/http'
import { RouterModule } from '@angular/router'
import {AppComponent} from './app.component';
import {HttpClientModule} from '@angular/common/http';
import {RouterModule} from '@angular/router';

import { appRoutes } from './app.routes'
import { SharedModule } from '@app/shared'
import { CoreModule } from '@app/core'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { SettingsModule } from '@app/settings'
import { AuthModule } from '@app/auth/auth.module'
import { metaReducers, reducers } from '@app/reducers'
import { StoreModule } from '@ngrx/store'
import {appRoutes} from './app.routes';
import {SharedModule} from '@app/shared';
import {CoreModule} from '@app/core';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {SettingsModule} from '@app/settings';
import {AuthModule} from '@app/auth/auth.module';
import {metaReducers, reducers} from '@app/reducers';
import {StoreModule} from '@ngrx/store';
import {
DefaultRouterStateSerializer,
NavigationActionTiming,
RouterStateSerializer,
StoreRouterConfig,
StoreRouterConnectingModule,
} from '@ngrx/router-store'
import { environment } from '@env'
import { EffectsModule } from '@ngrx/effects'
import { CustomRouterStateSerializer } from '@app/shared/utils'
import { StoreDevtoolsModule } from '@ngrx/store-devtools'
import { ServiceWorkerModule } from '@angular/service-worker'
} from '@ngrx/router-store';
import {environment} from '@env';
import {EffectsModule} from '@ngrx/effects';
import {CustomRouterStateSerializer} from '@app/shared/utils';
import {StoreDevtoolsModule} from '@ngrx/store-devtools';
import {ServiceWorkerModule} from '@angular/service-worker';

export const routerStateConfig: StoreRouterConfig = {
stateKey: 'router', // state-slice name for routing state
Expand All @@ -37,7 +37,7 @@ export const routerStateConfig: StoreRouterConfig = {
BrowserAnimationsModule,
BrowserModule,
HttpClientModule,
RouterModule.forRoot(appRoutes, { relativeLinkResolution: 'legacy' }),
RouterModule.forRoot(appRoutes, {relativeLinkResolution: 'legacy'}),
StoreModule.forRoot(reducers, {metaReducers, runtimeChecks: {strictStateImmutability: true, strictActionImmutability: true}}),

StoreRouterConnectingModule.forRoot(routerStateConfig),
Expand Down Expand Up @@ -66,4 +66,5 @@ export const routerStateConfig: StoreRouterConfig = {
],
bootstrap: [AppComponent],
})
export class AppModule {}
export class AppModule {
}
6 changes: 3 additions & 3 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Routes } from '@angular/router';
import { NotFoundPageComponent } from '@app/core';
import { SettingsComponent } from '@app/settings';
import {Routes} from '@angular/router';
import {NotFoundPageComponent} from '@app/core';
import {SettingsComponent} from '@app/settings';

export const appRoutes: Routes = [
{path: 'notes', loadChildren: () => import('./notes/notes.module').then(m => m.NotesModule)},
Expand Down
42 changes: 29 additions & 13 deletions src/app/auth/actions/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action } from '@ngrx/store';
import {Action} from '@ngrx/store';
import {User, Authenticate, UserTokenResponse} from '../models/user';

export enum AuthActionTypes {
Expand All @@ -19,69 +19,85 @@ export enum AuthActionTypes {
export class Login implements Action {
readonly type = AuthActionTypes.Login;

constructor(public payload: Authenticate) {}
constructor(public payload: Authenticate) {
}
}

export class LoginSuccess implements Action {
readonly type = AuthActionTypes.LoginSuccess;

constructor(public payload: UserTokenResponse ) {}
constructor(public payload: UserTokenResponse) {
}
}

export class LoginFailure implements Action {
readonly type = AuthActionTypes.LoginFailure;

constructor(public payload: any) {}
constructor(public payload: any) {
}
}

export class GetUserInfo implements Action {
readonly type = AuthActionTypes.GetUserInfo;
constructor (public sync: boolean = false) {}

constructor(public sync: boolean = false) {
}
}

export class GetUserInfoSuccess implements Action {
readonly type = AuthActionTypes.GetUserInfoSuccess;
constructor(public payload: User) {}

constructor(public payload: User) {
}
}

export class GetUserInfoFailure implements Action {
readonly type = AuthActionTypes.GetUserInfoFailure;
constructor(public payload: any) {}

constructor(public payload: any) {
}
}

export class LoginRedirect implements Action {
readonly type = AuthActionTypes.LoginRedirect;
constructor(public payload: any) {}

constructor(public payload: any) {
}
}

export class Logout implements Action {
readonly type = AuthActionTypes.Logout;

constructor (public sync: boolean = false) {}
constructor(public sync: boolean = false) {
}
}

export class LogoutSuccess implements Action {
readonly type = AuthActionTypes.LogoutSuccess;

constructor (public sync: boolean = false) {}
constructor(public sync: boolean = false) {
}
}

export class LogoutFailure implements Action {
readonly type = AuthActionTypes.LogoutFailure;

constructor (public sync: boolean = false, public error: any) {}
constructor(public sync: boolean = false, public error: any) {
}
}

export class RefreshToken implements Action {
readonly type = AuthActionTypes.RefreshToken;

constructor (public silent: boolean = false) {}
constructor(public silent: boolean = false) {
}
}

export class RefreshTokenFailure implements Action {
readonly type = AuthActionTypes.RefreshTokenFailure;

constructor (public payload: any) {}
constructor(public payload: any) {
}
}

export type AuthActions =
Expand Down
3 changes: 2 additions & 1 deletion src/app/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ export class AuthModule {
EffectsModule.forFeature([AuthEffects]),
],
})
export class RootAuthModule {}
export class RootAuthModule {
}
10 changes: 5 additions & 5 deletions src/app/auth/components/login-form.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { StoreModule, Store, combineReducers } from '@ngrx/store';
import { LoginFormComponent } from './login-form.component';
import {TestBed, ComponentFixture} from '@angular/core/testing';
import {NO_ERRORS_SCHEMA} from '@angular/core';
import {StoreModule, Store, combineReducers} from '@ngrx/store';
import {LoginFormComponent} from './login-form.component';
import * as Auth from '../actions/auth';
import * as fromAuth from '../reducers';
import { ReactiveFormsModule } from '@angular/forms';
import {ReactiveFormsModule} from '@angular/forms';

describe('Login Page', () => {
let fixture: ComponentFixture<LoginFormComponent>;
Expand Down
Loading