├── src
├── assets
│ ├── .gitkeep
│ └── img
│ │ └── home.jpg
├── app
│ ├── app.component.css
│ ├── home
│ │ ├── home.component.css
│ │ ├── login
│ │ │ ├── login.component.css
│ │ │ ├── login.component.spec.ts
│ │ │ ├── login.component.ts
│ │ │ └── login.component.html
│ │ ├── nuevo-usuario
│ │ │ ├── nuevo-usuario.component.css
│ │ │ ├── nuevo-usuario.ts
│ │ │ ├── minusculas.validator.ts
│ │ │ ├── userNamePassword.validator.ts
│ │ │ ├── nuevo-usuario.service.spec.ts
│ │ │ ├── usuario-existente.service.spec.ts
│ │ │ ├── nuevo-usuario.service.ts
│ │ │ ├── usuario-existente.service.ts
│ │ │ ├── nuevo-usuario.component.spec.ts
│ │ │ ├── nuevo-usuario.component.ts
│ │ │ └── nuevo-usuario.component.html
│ │ ├── home.component.ts
│ │ ├── home.component.html
│ │ ├── home.component.spec.ts
│ │ ├── home-routing.module.ts
│ │ └── home.module.ts
│ ├── components
│ │ ├── footer
│ │ │ ├── footer.component.css
│ │ │ ├── footer.component.ts
│ │ │ ├── footer.component.html
│ │ │ ├── footer.module.ts
│ │ │ └── footer.component.spec.ts
│ │ ├── header
│ │ │ ├── header.component.css
│ │ │ ├── header.module.ts
│ │ │ ├── header.component.html
│ │ │ ├── header.component.ts
│ │ │ └── header.component.spec.ts
│ │ └── message
│ │ │ ├── message.component.css
│ │ │ ├── message.component.html
│ │ │ ├── message.module.ts
│ │ │ ├── message.component.ts
│ │ │ └── message.component.spec.ts
│ ├── mascotas
│ │ ├── lista-mascotas
│ │ │ ├── lista-mascotas.component.css
│ │ │ ├── lista-mascotas.component.html
│ │ │ ├── lista-mascotas.component.ts
│ │ │ └── lista-mascotas.component.spec.ts
│ │ ├── mascotas-routing.module.ts
│ │ └── mascotas.module.ts
│ ├── app.component.html
│ ├── auth
│ │ ├── user
│ │ │ ├── user.ts
│ │ │ ├── user.service.spec.ts
│ │ │ └── user.service.ts
│ │ ├── auth.module.ts
│ │ ├── auth.service.spec.ts
│ │ ├── token.service.spec.ts
│ │ ├── token.service.ts
│ │ └── auth.service.ts
│ ├── app.component.ts
│ ├── app-routing.module.ts
│ ├── app.module.ts
│ └── app.component.spec.ts
├── styles.css
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── test.ts
└── polyfills.ts
├── .editorconfig
├── tsconfig.app.json
├── tsconfig.spec.json
├── .browserslistrc
├── .gitignore
├── tsconfig.json
├── README.md
├── package.json
├── karma.conf.js
└── angular.json
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/home/home.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/home/login/login.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/components/footer/footer.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/components/header/header.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/components/message/message.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/nuevo-usuario.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/mascotas/lista-mascotas/lista-mascotas.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/mascotas/lista-mascotas/lista-mascotas.component.html:
--------------------------------------------------------------------------------
1 |
lista-mascotas works!
2 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alura-es-cursos/1867-Angular-Formularios/master/src/favicon.ico
--------------------------------------------------------------------------------
/src/app/components/message/message.component.html:
--------------------------------------------------------------------------------
1 | {{ mensaje }}
2 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/app/auth/user/user.ts:
--------------------------------------------------------------------------------
1 | export interface User {
2 | id?: number;
3 | name?: string;
4 | email?: string;
5 | }
6 |
--------------------------------------------------------------------------------
/src/assets/img/home.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alura-es-cursos/1867-Angular-Formularios/master/src/assets/img/home.jpg
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/nuevo-usuario.ts:
--------------------------------------------------------------------------------
1 | export interface NuevoUsuario {
2 | userName: string;
3 | email: string;
4 | fullName: string;
5 | password: string;
6 | }
7 |
--------------------------------------------------------------------------------
/src/app/auth/auth.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 |
5 |
6 | @NgModule({
7 | declarations: [],
8 | imports: [
9 | CommonModule
10 | ]
11 | })
12 | export class AuthModule { }
13 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'catbook';
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/home/home.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-home',
5 | templateUrl: './home.component.html',
6 | styleUrls: ['./home.component.css'],
7 | })
8 | export class HomeComponent implements OnInit {
9 | constructor() {}
10 |
11 | ngOnInit(): void {}
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/minusculas.validator.ts:
--------------------------------------------------------------------------------
1 | import { AbstractControl } from '@angular/forms';
2 |
3 | export function minusculasValidator(control: AbstractControl) {
4 | const value = control.value as string;
5 | if (value !== value.toLowerCase()) {
6 | return { minuscula: true };
7 | } else {
8 | return null;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.ts]
12 | quote_type = single
13 |
14 | [*.md]
15 | max_line_length = off
16 | trim_trailing_whitespace = false
17 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Catbook
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/app/components/message/message.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { MessageComponent } from './message.component';
4 |
5 | @NgModule({
6 | declarations: [MessageComponent],
7 | imports: [CommonModule],
8 | exports: [MessageComponent],
9 | })
10 | export class MessageModule {}
11 |
--------------------------------------------------------------------------------
/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "outDir": "./out-tsc/app",
6 | "types": []
7 | },
8 | "files": [
9 | "src/main.ts",
10 | "src/polyfills.ts"
11 | ],
12 | "include": [
13 | "src/**/*.d.ts"
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/components/footer/footer.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-footer',
5 | templateUrl: './footer.component.html',
6 | styleUrls: ['./footer.component.css']
7 | })
8 | export class FooterComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit(): void {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/home/home.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |

9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/app/components/footer/footer.component.html:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/src/app/components/message/message.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-message',
5 | templateUrl: './message.component.html',
6 | styleUrls: ['./message.component.css'],
7 | })
8 | export class MessageComponent implements OnInit {
9 | @Input()
10 | mensaje = '';
11 | constructor() {}
12 |
13 | ngOnInit(): void {}
14 | }
15 |
--------------------------------------------------------------------------------
/src/app/components/footer/footer.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { FooterComponent } from './footer.component';
4 | import { RouterModule } from '@angular/router';
5 |
6 | @NgModule({
7 | declarations: [FooterComponent],
8 | imports: [CommonModule, RouterModule],
9 | exports: [FooterComponent],
10 | })
11 | export class FooterModule {}
12 |
--------------------------------------------------------------------------------
/src/app/components/header/header.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { HeaderComponent } from './header.component';
4 | import { RouterModule } from '@angular/router';
5 |
6 | @NgModule({
7 | declarations: [HeaderComponent],
8 | imports: [CommonModule, RouterModule],
9 | exports: [HeaderComponent],
10 | })
11 | export class HeaderModule {}
12 |
--------------------------------------------------------------------------------
/src/app/mascotas/lista-mascotas/lista-mascotas.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-lista-mascotas',
5 | templateUrl: './lista-mascotas.component.html',
6 | styleUrls: ['./lista-mascotas.component.css']
7 | })
8 | export class ListaMascotasComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit(): void {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "extends": "./tsconfig.json",
4 | "compilerOptions": {
5 | "outDir": "./out-tsc/spec",
6 | "types": [
7 | "jasmine"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts",
12 | "src/polyfills.ts"
13 | ],
14 | "include": [
15 | "src/**/*.spec.ts",
16 | "src/**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/src/app/auth/auth.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { AuthService } from './auth.service';
4 |
5 | describe('AuthService', () => {
6 | let service: AuthService;
7 |
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({});
10 | service = TestBed.inject(AuthService);
11 | });
12 |
13 | it('should be created', () => {
14 | expect(service).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/src/app/auth/token.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { TokenService } from './token.service';
4 |
5 | describe('TokenService', () => {
6 | let service: TokenService;
7 |
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({});
10 | service = TestBed.inject(TokenService);
11 | });
12 |
13 | it('should be created', () => {
14 | expect(service).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/src/app/auth/user/user.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { UserService } from './user.service';
4 |
5 | describe('UserService', () => {
6 | let service: UserService;
7 |
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({});
10 | service = TestBed.inject(UserService);
11 | });
12 |
13 | it('should be created', () => {
14 | expect(service).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/userNamePassword.validator.ts:
--------------------------------------------------------------------------------
1 | import { FormGroup } from '@angular/forms';
2 |
3 | export function userNamePasswordValidator(formGroup: FormGroup) {
4 | const userName = formGroup.get('userName')?.value ?? '';
5 | const password = formGroup.get('password')?.value ?? '';
6 |
7 | if (userName.trim() + password.trim()) {
8 | return userName !== password ? null : { inputsIguales: true };
9 | } else {
10 | return null;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/mascotas/mascotas-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 | import { ListaMascotasComponent } from './lista-mascotas/lista-mascotas.component';
4 |
5 | const routes: Routes = [
6 | {
7 | path: '',
8 | component: ListaMascotasComponent,
9 | },
10 | ];
11 |
12 | @NgModule({
13 | imports: [RouterModule.forChild(routes)],
14 | exports: [RouterModule],
15 | })
16 | export class MascotasRoutingModule {}
17 |
--------------------------------------------------------------------------------
/src/app/mascotas/mascotas.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { MascotasRoutingModule } from './mascotas-routing.module';
5 | import { ListaMascotasComponent } from './lista-mascotas/lista-mascotas.component';
6 |
7 |
8 | @NgModule({
9 | declarations: [
10 | ListaMascotasComponent
11 | ],
12 | imports: [
13 | CommonModule,
14 | MascotasRoutingModule
15 | ]
16 | })
17 | export class MascotasModule { }
18 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/nuevo-usuario.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { NuevoUsuarioService } from './nuevo-usuario.service';
4 |
5 | describe('NuevoUsuarioService', () => {
6 | let service: NuevoUsuarioService;
7 |
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({});
10 | service = TestBed.inject(NuevoUsuarioService);
11 | });
12 |
13 | it('should be created', () => {
14 | expect(service).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/src/app/auth/token.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 |
3 | const KEY = 'token';
4 |
5 | @Injectable({
6 | providedIn: 'root',
7 | })
8 | export class TokenService {
9 | obtenerToken() {
10 | return localStorage.getItem(KEY) ?? '';
11 | }
12 |
13 | guardarToken(token: string) {
14 | localStorage.setItem(KEY, token);
15 | }
16 |
17 | eliminarToken() {
18 | localStorage.removeItem(KEY);
19 | }
20 |
21 | existeToken() {
22 | return !!this.obtenerToken();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/usuario-existente.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 |
3 | import { UsuarioExistenteService } from './usuario-existente.service';
4 |
5 | describe('UsuarioExistenteService', () => {
6 | let service: UsuarioExistenteService;
7 |
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({});
10 | service = TestBed.inject(UsuarioExistenteService);
11 | });
12 |
13 | it('should be created', () => {
14 | expect(service).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/src/app/components/header/header.component.html:
--------------------------------------------------------------------------------
1 |
18 |
--------------------------------------------------------------------------------
/.browserslistrc:
--------------------------------------------------------------------------------
1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 |
5 | # For the full list of supported browsers by the Angular framework, please see:
6 | # https://angular.io/guide/browser-support
7 |
8 | # You can see what browsers were selected by your queries by running:
9 | # npx browserslist
10 |
11 | last 1 Chrome version
12 | last 1 Firefox version
13 | last 2 Edge major versions
14 | last 2 Safari major versions
15 | last 2 iOS major versions
16 | Firefox ESR
17 |
--------------------------------------------------------------------------------
/src/app/components/header/header.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { UserService } from '../../auth/user/user.service';
4 |
5 | @Component({
6 | selector: 'app-header',
7 | templateUrl: './header.component.html',
8 | styleUrls: ['./header.component.css'],
9 | })
10 | export class HeaderComponent implements OnInit {
11 | user$ = this.userService.returnUsuario();
12 |
13 | constructor(private userService: UserService, private router: Router) {}
14 |
15 | ngOnInit(): void {}
16 |
17 | logout() {
18 | this.userService.eliminarToken();
19 | this.router.navigate(['']);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/nuevo-usuario.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient } from '@angular/common/http';
3 | import { NuevoUsuario } from './nuevo-usuario';
4 | import { Observable } from 'rxjs';
5 |
6 | @Injectable({
7 | providedIn: 'root',
8 | })
9 | export class NuevoUsuarioService {
10 | constructor(private httpClient: HttpClient) {}
11 |
12 | url = 'http://localhost:3000/user';
13 |
14 | registrarUsuario(nuevoUsuario: NuevoUsuario) {
15 | return this.httpClient.post(`${this.url}/signup`, nuevoUsuario);
16 | }
17 |
18 | verificarUserName(userName: string): Observable {
19 | return this.httpClient.get(`${this.url}/exists/${userName}`);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 |
4 | const routes: Routes = [
5 | {
6 | path: '',
7 | pathMatch: 'full',
8 | redirectTo: 'home',
9 | },
10 | {
11 | path: 'home',
12 | loadChildren: () =>
13 | import('./home/home.module').then((module) => module.HomeModule),
14 | },
15 | {
16 | path: 'mascotas',
17 | loadChildren: () =>
18 | import('./mascotas/mascotas.module').then(
19 | (module) => module.MascotasModule
20 | ),
21 | },
22 | ];
23 |
24 | @NgModule({
25 | imports: [RouterModule.forRoot(routes)],
26 | exports: [RouterModule],
27 | })
28 | export class AppRoutingModule {}
29 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { HttpClientModule } from '@angular/common/http';
2 | import { NgModule } from '@angular/core';
3 | import { BrowserModule } from '@angular/platform-browser';
4 |
5 | import { AppRoutingModule } from './app-routing.module';
6 | import { AppComponent } from './app.component';
7 | import { HeaderModule } from './components/header/header.module';
8 | import { FooterModule } from './components/footer/footer.module';
9 |
10 | @NgModule({
11 | declarations: [AppComponent],
12 | imports: [
13 | BrowserModule,
14 | AppRoutingModule,
15 | HttpClientModule,
16 | HeaderModule,
17 | FooterModule,
18 | ],
19 | providers: [],
20 | bootstrap: [AppComponent],
21 | })
22 | export class AppModule {}
23 |
--------------------------------------------------------------------------------
/src/app/home/home.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { HomeComponent } from './home.component';
4 |
5 | describe('HomeComponent', () => {
6 | let component: HomeComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [ HomeComponent ]
12 | })
13 | .compileComponents();
14 | });
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(HomeComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/src/app/home/login/login.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { LoginComponent } from './login.component';
4 |
5 | describe('LoginComponent', () => {
6 | let component: LoginComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [ LoginComponent ]
12 | })
13 | .compileComponents();
14 | });
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(LoginComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/footer/footer.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { FooterComponent } from './footer.component';
4 |
5 | describe('FooterComponent', () => {
6 | let component: FooterComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [ FooterComponent ]
12 | })
13 | .compileComponents();
14 | });
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(FooterComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/header/header.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { HeaderComponent } from './header.component';
4 |
5 | describe('HeaderComponent', () => {
6 | let component: HeaderComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [ HeaderComponent ]
12 | })
13 | .compileComponents();
14 | });
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(HeaderComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/components/message/message.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { MessageComponent } from './message.component';
4 |
5 | describe('MessageComponent', () => {
6 | let component: MessageComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [ MessageComponent ]
12 | })
13 | .compileComponents();
14 | });
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(MessageComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/usuario-existente.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { AbstractControl } from '@angular/forms';
3 | import { map, switchMap, first } from 'rxjs';
4 | import { NuevoUsuarioService } from './nuevo-usuario.service';
5 |
6 | @Injectable({
7 | providedIn: 'root',
8 | })
9 | export class UsuarioExistenteService {
10 | constructor(private nuevoUsuarioService: NuevoUsuarioService) {}
11 |
12 | usuarioExistente() {
13 | return (control: AbstractControl) => {
14 | return control.valueChanges.pipe(
15 | switchMap((userName) =>
16 | this.nuevoUsuarioService.verificarUserName(userName)
17 | ),
18 | map((existe) => (existe ? { usuarioExistente: true } : null)),
19 | first()
20 | );
21 | };
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/home/home-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 | import { HomeComponent } from './home.component';
4 | import { LoginComponent } from './login/login.component';
5 | import { NuevoUsuarioComponent } from './nuevo-usuario/nuevo-usuario.component';
6 |
7 | const routes: Routes = [
8 | {
9 | path: '',
10 | component: HomeComponent,
11 | children: [
12 | {
13 | path: '',
14 | component: LoginComponent,
15 | },
16 | {
17 | path: 'nuevo-usuario',
18 | component: NuevoUsuarioComponent,
19 | },
20 | ],
21 | },
22 | ];
23 |
24 | @NgModule({
25 | imports: [RouterModule.forChild(routes)],
26 | exports: [RouterModule],
27 | })
28 | export class HomeRoutingModule {}
29 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/nuevo-usuario.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NuevoUsuarioComponent } from './nuevo-usuario.component';
4 |
5 | describe('NuevoUsuarioComponent', () => {
6 | let component: NuevoUsuarioComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [ NuevoUsuarioComponent ]
12 | })
13 | .compileComponents();
14 | });
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NuevoUsuarioComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 | # Only exists if Bazel was run
8 | /bazel-out
9 |
10 | # dependencies
11 | /node_modules
12 |
13 | # profiling files
14 | chrome-profiler-events*.json
15 |
16 | # IDEs and editors
17 | /.idea
18 | .project
19 | .classpath
20 | .c9/
21 | *.launch
22 | .settings/
23 | *.sublime-workspace
24 |
25 | # IDE - VSCode
26 | .vscode/*
27 | !.vscode/settings.json
28 | !.vscode/tasks.json
29 | !.vscode/launch.json
30 | !.vscode/extensions.json
31 | .history/*
32 |
33 | # misc
34 | /.angular/cache
35 | /.sass-cache
36 | /connect.lock
37 | /coverage
38 | /libpeerconnection.log
39 | npm-debug.log
40 | yarn-error.log
41 | testem.log
42 | /typings
43 |
44 | # System Files
45 | .DS_Store
46 | Thumbs.db
47 |
--------------------------------------------------------------------------------
/src/app/mascotas/lista-mascotas/lista-mascotas.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ListaMascotasComponent } from './lista-mascotas.component';
4 |
5 | describe('ListaMascotasComponent', () => {
6 | let component: ListaMascotasComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async () => {
10 | await TestBed.configureTestingModule({
11 | declarations: [ ListaMascotasComponent ]
12 | })
13 | .compileComponents();
14 | });
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ListaMascotasComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/home/home.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { HomeRoutingModule } from './home-routing.module';
5 | import { HomeComponent } from './home.component';
6 | import { LoginComponent } from './login/login.component';
7 | import { FormsModule, ReactiveFormsModule } from '@angular/forms';
8 | import { MessageModule } from '../components/message/message.module';
9 | import { NuevoUsuarioComponent } from './nuevo-usuario/nuevo-usuario.component';
10 |
11 | @NgModule({
12 | declarations: [HomeComponent, LoginComponent, NuevoUsuarioComponent],
13 | imports: [
14 | CommonModule,
15 | HomeRoutingModule,
16 | FormsModule,
17 | MessageModule,
18 | ReactiveFormsModule,
19 | ],
20 | exports: [HomeComponent],
21 | })
22 | export class HomeModule {}
23 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: {
11 | context(path: string, deep?: boolean, filter?: RegExp): {
12 | (id: string): T;
13 | keys(): string[];
14 | };
15 | };
16 |
17 | // First, initialize the Angular testing environment.
18 | getTestBed().initTestEnvironment(
19 | BrowserDynamicTestingModule,
20 | platformBrowserDynamicTesting(),
21 | );
22 |
23 | // Then we find all the tests.
24 | const context = require.context('./', true, /\.spec\.ts$/);
25 | // And load the modules.
26 | context.keys().map(context);
27 |
--------------------------------------------------------------------------------
/src/app/home/login/login.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { AuthService } from '../../auth/auth.service';
4 |
5 | @Component({
6 | selector: 'app-login',
7 | templateUrl: './login.component.html',
8 | styleUrls: ['./login.component.css'],
9 | })
10 | export class LoginComponent implements OnInit {
11 | userName = '';
12 | password = '';
13 |
14 | constructor(private authService: AuthService, private router: Router) {}
15 |
16 | ngOnInit(): void {}
17 |
18 | login() {
19 | console.log('enviar datos');
20 | console.log(this.userName, this.password);
21 | this.authService.autorizar(this.userName, this.password).subscribe({
22 | complete: () => this.router.navigate(['mascotas']),
23 | error: (err) => alert('Verifica tus datos'),
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/app/auth/auth.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Observable, tap } from 'rxjs';
3 | import { HttpClient, HttpResponse } from '@angular/common/http';
4 | import { UserService } from './user/user.service';
5 |
6 | @Injectable({
7 | providedIn: 'root',
8 | })
9 | export class AuthService {
10 | constructor(
11 | private httpClient: HttpClient,
12 | private userService: UserService
13 | ) {}
14 |
15 | autorizar(userName: string, password: string): Observable> {
16 | return this.httpClient
17 | .post(
18 | 'http://localhost:3000/user/login',
19 | {
20 | userName,
21 | password,
22 | },
23 | {
24 | observe: 'response',
25 | }
26 | )
27 | .pipe(
28 | tap((response) => {
29 | const token = response.headers.get('x-access-token') ?? '';
30 | this.userService.guardarToken(token);
31 | })
32 | );
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */
2 | {
3 | "compileOnSave": false,
4 | "compilerOptions": {
5 | "baseUrl": "./",
6 | "outDir": "./dist/out-tsc",
7 | "forceConsistentCasingInFileNames": true,
8 | "strict": true,
9 | "noImplicitOverride": true,
10 | "noPropertyAccessFromIndexSignature": true,
11 | "noImplicitReturns": true,
12 | "noFallthroughCasesInSwitch": true,
13 | "sourceMap": true,
14 | "declaration": false,
15 | "downlevelIteration": true,
16 | "experimentalDecorators": true,
17 | "moduleResolution": "node",
18 | "importHelpers": true,
19 | "target": "es2017",
20 | "module": "es2020",
21 | "lib": [
22 | "es2020",
23 | "dom"
24 | ]
25 | },
26 | "angularCompilerOptions": {
27 | "enableI18nLegacyMessageIdFormat": false,
28 | "strictInjectionParameters": true,
29 | "strictInputAccessModifiers": true,
30 | "strictTemplates": true
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Catbook
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.0.4.
4 |
5 | ## Development server
6 |
7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12 |
13 | ## Build
14 |
15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
28 |
--------------------------------------------------------------------------------
/src/app/auth/user/user.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { TokenService } from '../token.service';
3 | import jwt_decode from 'jwt-decode';
4 | import { User } from './user';
5 | import { BehaviorSubject } from 'rxjs';
6 |
7 | @Injectable({
8 | providedIn: 'root',
9 | })
10 | export class UserService {
11 | private usuarioSubject = new BehaviorSubject({});
12 |
13 | constructor(private tokenService: TokenService) {
14 | if (this.tokenService.existeToken()) {
15 | this.decodificarJWT();
16 | }
17 | }
18 |
19 | private decodificarJWT() {
20 | const token = this.tokenService.obtenerToken();
21 | const usuario = jwt_decode(token) as User;
22 | console.log('Decodificado ', usuario);
23 | this.usuarioSubject.next(usuario);
24 | }
25 |
26 | returnUsuario() {
27 | return this.usuarioSubject.asObservable();
28 | }
29 |
30 | guardarToken(token: string) {
31 | this.tokenService.guardarToken(token);
32 | this.decodificarJWT();
33 | }
34 |
35 | eliminarToken() {
36 | this.tokenService.eliminarToken();
37 | this.usuarioSubject.next({});
38 | }
39 |
40 | isLogin() {
41 | return this.tokenService.existeToken();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async () => {
7 | await TestBed.configureTestingModule({
8 | imports: [
9 | RouterTestingModule
10 | ],
11 | declarations: [
12 | AppComponent
13 | ],
14 | }).compileComponents();
15 | });
16 |
17 | it('should create the app', () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.componentInstance;
20 | expect(app).toBeTruthy();
21 | });
22 |
23 | it(`should have as title 'catbook'`, () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | const app = fixture.componentInstance;
26 | expect(app.title).toEqual('catbook');
27 | });
28 |
29 | it('should render title', () => {
30 | const fixture = TestBed.createComponent(AppComponent);
31 | fixture.detectChanges();
32 | const compiled = fixture.nativeElement as HTMLElement;
33 | expect(compiled.querySelector('.content span')?.textContent).toContain('catbook app is running!');
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/src/app/home/login/login.component.html:
--------------------------------------------------------------------------------
1 | Login
2 |
3 |
40 |
41 | ¿No tienes una cuenta? Registrate
42 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "catbook",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "watch": "ng build --watch --configuration development",
9 | "test": "ng test"
10 | },
11 | "private": true,
12 | "dependencies": {
13 | "@angular/animations": "~13.0.0",
14 | "@angular/common": "~13.0.0",
15 | "@angular/compiler": "~13.0.0",
16 | "@angular/core": "~13.0.0",
17 | "@angular/forms": "~13.0.0",
18 | "@angular/platform-browser": "~13.0.0",
19 | "@angular/platform-browser-dynamic": "~13.0.0",
20 | "@angular/router": "~13.0.0",
21 | "bootstrap": "^5.1.3",
22 | "font-awesome": "^4.7.0",
23 | "jwt-decode": "^3.1.2",
24 | "rxjs": "~7.4.0",
25 | "tslib": "^2.3.0",
26 | "zone.js": "~0.11.4"
27 | },
28 | "devDependencies": {
29 | "@angular-devkit/build-angular": "~13.0.4",
30 | "@angular/cli": "~13.0.4",
31 | "@angular/compiler-cli": "~13.0.0",
32 | "@types/jasmine": "~3.10.0",
33 | "@types/node": "^12.11.1",
34 | "jasmine-core": "~3.10.0",
35 | "karma": "~6.3.0",
36 | "karma-chrome-launcher": "~3.1.0",
37 | "karma-coverage": "~2.0.3",
38 | "karma-jasmine": "~4.0.0",
39 | "karma-jasmine-html-reporter": "~1.7.0",
40 | "typescript": "~4.4.3"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | jasmine: {
17 | // you can add configuration options for Jasmine here
18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19 | // for example, you can disable the random execution with `random: false`
20 | // or set a specific seed with `seed: 4321`
21 | },
22 | clearContext: false // leave Jasmine Spec Runner output visible in browser
23 | },
24 | jasmineHtmlReporter: {
25 | suppressAll: true // removes the duplicated traces
26 | },
27 | coverageReporter: {
28 | dir: require('path').join(__dirname, './coverage/catbook'),
29 | subdir: '.',
30 | reporters: [
31 | { type: 'html' },
32 | { type: 'text-summary' }
33 | ]
34 | },
35 | reporters: ['progress', 'kjhtml'],
36 | port: 9876,
37 | colors: true,
38 | logLevel: config.LOG_INFO,
39 | autoWatch: true,
40 | browsers: ['Chrome'],
41 | singleRun: false,
42 | restartOnFileChange: true
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/nuevo-usuario.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms';
3 | import { NuevoUsuarioService } from './nuevo-usuario.service';
4 | import { NuevoUsuario } from './nuevo-usuario';
5 | import { minusculasValidator } from './minusculas.validator';
6 | import { UsuarioExistenteService } from './usuario-existente.service';
7 | import { userNamePasswordValidator } from './userNamePassword.validator';
8 | import { Router } from '@angular/router';
9 |
10 | @Component({
11 | selector: 'app-nuevo-usuario',
12 | templateUrl: './nuevo-usuario.component.html',
13 | styleUrls: ['./nuevo-usuario.component.css'],
14 | })
15 | export class NuevoUsuarioComponent implements OnInit {
16 | nuevoUsuarioForm!: FormGroup;
17 | constructor(
18 | private formBuilder: FormBuilder,
19 | private nuevoUsuarioService: NuevoUsuarioService,
20 | private usuarioExistente: UsuarioExistenteService,
21 | private router: Router
22 | ) {}
23 |
24 | ngOnInit(): void {
25 | this.nuevoUsuarioForm = this.formBuilder.group(
26 | {
27 | email: ['', [Validators.required, Validators.email]],
28 | fullName: ['', [Validators.required, Validators.minLength(4)]],
29 | userName: [
30 | '',
31 | [minusculasValidator],
32 | [this.usuarioExistente.usuarioExistente()],
33 | ],
34 | password: [''],
35 | },
36 | {
37 | validators: [userNamePasswordValidator],
38 | }
39 | );
40 | }
41 |
42 | registrar() {
43 | if (this.nuevoUsuarioForm.valid) {
44 | const nuevousuario = this.nuevoUsuarioForm.getRawValue() as NuevoUsuario;
45 | this.nuevoUsuarioService.registrarUsuario(nuevousuario).subscribe({
46 | complete: () => this.router.navigate(['']),
47 | error: () => alert('No fue posible hacer el registro'),
48 | });
49 | } else {
50 | alert('verifica el formulario');
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/app/home/nuevo-usuario/nuevo-usuario.component.html:
--------------------------------------------------------------------------------
1 | Registrate y muestra al mundo tu gato
2 |
3 |
71 |
72 | ¿Ya tienes una cuenta? Accede
73 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes recent versions of Safari, Chrome (including
12 | * Opera), Edge on the desktop, and iOS and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /**
22 | * By default, zone.js will patch all possible macroTask and DomEvents
23 | * user can disable parts of macroTask/DomEvents patch by setting following flags
24 | * because those flags need to be set before `zone.js` being loaded, and webpack
25 | * will put import in the top of bundle, so user need to create a separate file
26 | * in this directory (for example: zone-flags.ts), and put the following flags
27 | * into that file, and then add the following code before importing zone.js.
28 | * import './zone-flags';
29 | *
30 | * The flags allowed in zone-flags.ts are listed here.
31 | *
32 | * The following flags will work for all browsers.
33 | *
34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
36 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
37 | *
38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
40 | *
41 | * (window as any).__Zone_enable_cross_context_check = true;
42 | *
43 | */
44 |
45 | /***************************************************************************************************
46 | * Zone JS is required by default for Angular itself.
47 | */
48 | import 'zone.js'; // Included with Angular CLI.
49 |
50 |
51 | /***************************************************************************************************
52 | * APPLICATION IMPORTS
53 | */
54 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "catbook": {
7 | "projectType": "application",
8 | "schematics": {
9 | "@schematics/angular:application": {
10 | "strict": true
11 | }
12 | },
13 | "root": "",
14 | "sourceRoot": "src",
15 | "prefix": "app",
16 | "architect": {
17 | "build": {
18 | "builder": "@angular-devkit/build-angular:browser",
19 | "options": {
20 | "outputPath": "dist/catbook",
21 | "index": "src/index.html",
22 | "main": "src/main.ts",
23 | "polyfills": "src/polyfills.ts",
24 | "tsConfig": "tsconfig.app.json",
25 | "assets": ["src/favicon.ico", "src/assets"],
26 | "styles": [
27 | "src/styles.css",
28 | "./node_modules/bootstrap/dist/css/bootstrap.min.css",
29 | "./node_modules/font-awesome/css/font-awesome.min.css"
30 | ],
31 | "scripts": []
32 | },
33 | "configurations": {
34 | "production": {
35 | "budgets": [
36 | {
37 | "type": "initial",
38 | "maximumWarning": "500kb",
39 | "maximumError": "1mb"
40 | },
41 | {
42 | "type": "anyComponentStyle",
43 | "maximumWarning": "2kb",
44 | "maximumError": "4kb"
45 | }
46 | ],
47 | "fileReplacements": [
48 | {
49 | "replace": "src/environments/environment.ts",
50 | "with": "src/environments/environment.prod.ts"
51 | }
52 | ],
53 | "outputHashing": "all"
54 | },
55 | "development": {
56 | "buildOptimizer": false,
57 | "optimization": false,
58 | "vendorChunk": true,
59 | "extractLicenses": false,
60 | "sourceMap": true,
61 | "namedChunks": true
62 | }
63 | },
64 | "defaultConfiguration": "production"
65 | },
66 | "serve": {
67 | "builder": "@angular-devkit/build-angular:dev-server",
68 | "configurations": {
69 | "production": {
70 | "browserTarget": "catbook:build:production"
71 | },
72 | "development": {
73 | "browserTarget": "catbook:build:development"
74 | }
75 | },
76 | "defaultConfiguration": "development"
77 | },
78 | "extract-i18n": {
79 | "builder": "@angular-devkit/build-angular:extract-i18n",
80 | "options": {
81 | "browserTarget": "catbook:build"
82 | }
83 | },
84 | "test": {
85 | "builder": "@angular-devkit/build-angular:karma",
86 | "options": {
87 | "main": "src/test.ts",
88 | "polyfills": "src/polyfills.ts",
89 | "tsConfig": "tsconfig.spec.json",
90 | "karmaConfig": "karma.conf.js",
91 | "assets": ["src/favicon.ico", "src/assets"],
92 | "styles": ["src/styles.css"],
93 | "scripts": []
94 | }
95 | }
96 | }
97 | }
98 | },
99 | "defaultProject": "catbook"
100 | }
101 |
--------------------------------------------------------------------------------