Feature: Lazy loading
Lazy loaded everything TODO: The cash flow module when clicking on sub-links, it reloads the whole page, it needs to be diagnosed and fixed, this problem also exists in the other modules TODO: Rename folders and modules such as account to accounts to match the url
This commit is contained in:
@@ -2,12 +2,11 @@ import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
|
||||
import {UserService} from '../user.service';
|
||||
import {User} from '../user';
|
||||
import {User} from '../../core/user';
|
||||
import {ToasterService} from '../../core/toaster.service';
|
||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import {FormArray, FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {Account} from "../../account/account";
|
||||
|
||||
@Component({
|
||||
selector: 'app-user-detail',
|
||||
@@ -74,7 +73,7 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/Users');
|
||||
this.router.navigateByUrl('/users');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
@@ -87,7 +86,7 @@ export class UserDetailComponent implements OnInit, AfterViewInit {
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/Users');
|
||||
this.router.navigateByUrl('/users');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {User} from './user';
|
||||
import {User} from '../core/user';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {UserService} from './user.service';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {merge, Observable, of as observableOf} from 'rxjs';
|
||||
import {User} from '../user';
|
||||
import {User} from '../../core/user';
|
||||
|
||||
export class UserListDataSource extends DataSource<User> {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Users</mat-card-title>
|
||||
<a mat-button [routerLink]="['/User']">
|
||||
<a mat-button [routerLink]="['/users', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/User', row.name]">{{row.name}}</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/users', row.name]">{{row.name}}</a></mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Locked Out Column -->
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {UserListComponent} from './user-list.component';
|
||||
|
||||
describe('UserListComponent', () => {
|
||||
let component: UserListComponent;
|
||||
let fixture: ComponentFixture<UserListComponent>;
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [UserListComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UserListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should compile', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import {UserListDataSource} from './user-list-datasource';
|
||||
import {User} from '../user';
|
||||
import {User} from '../../core/user';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {User} from './user';
|
||||
import {User} from '../core/user';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {UserService} from './user.service';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import {AuthGuard} from '../auth/auth-guard.service';
|
||||
|
||||
const userRoutes: Routes = [
|
||||
{
|
||||
path: 'Users',
|
||||
path: '',
|
||||
component: UserListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
@@ -20,7 +20,7 @@ const userRoutes: Routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'User',
|
||||
path: 'new',
|
||||
component: UserDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
@@ -31,7 +31,7 @@ const userRoutes: Routes = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'User/:id',
|
||||
path: ':id',
|
||||
component: UserDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
resolve: {
|
||||
|
||||
@@ -3,13 +3,12 @@ import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {User} from './user';
|
||||
import {Group} from '../group/group';
|
||||
import {User} from '../core/user';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
const url = '/api/User';
|
||||
const url = '/api/users';
|
||||
const serviceName = 'UserService';
|
||||
|
||||
@Injectable({
|
||||
@@ -20,7 +19,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
get(id: string): Observable<User> {
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
|
||||
return <Observable<User>>this.http.get<User>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
@@ -44,7 +43,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
save(user: User): Observable<User> {
|
||||
return <Observable<User>>this.http.post<User>(url, user, httpOptions)
|
||||
return <Observable<User>>this.http.post<User>(`${url}/new`, user, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
export class User {
|
||||
id: string;
|
||||
name: string;
|
||||
password: string;
|
||||
lockedOut: boolean;
|
||||
groups: UserGroup[];
|
||||
perms: string[];
|
||||
isAuthenticated: boolean;
|
||||
|
||||
public constructor(init?: Partial<User>) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class UserGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user