Skip to content

Commit be91a2d

Browse files
clase 05
1 parent 7b546c2 commit be91a2d

38 files changed

+702
-71
lines changed

ambulance/package-lock.json

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ambulance/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"@angular/platform-browser": "~11.0.5",
2525
"@angular/platform-browser-dynamic": "~11.0.5",
2626
"@angular/router": "~11.0.5",
27+
"lodash": "^4.17.20",
28+
"ngx-webcam": "^0.3.2",
2729
"rxjs": "~6.6.0",
2830
"tslib": "^2.0.0",
2931
"zone.js": "~0.10.2"
@@ -33,6 +35,7 @@
3335
"@angular/cli": "~11.0.5",
3436
"@angular/compiler-cli": "~11.0.5",
3537
"@types/jasmine": "~3.6.0",
38+
"@types/lodash": "^4.14.168",
3639
"@types/node": "^12.11.1",
3740
"codelyzer": "^6.0.0",
3841
"jasmine-core": "~3.6.0",

ambulance/src/app/app-routing.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
3+
import { PageLockScreenComponent } from './core/presentation/pages/page-lock-screen/page-lock-screen.component';
34
import { PageLoginComponent } from './core/presentation/pages/page-login/page-login.component';
45

56
const routes: Routes = [
67
{
78
path: 'auth',
8-
component: PageLoginComponent,
9+
children: [
10+
{ path: '', component: PageLoginComponent },
11+
{ path: 'lock', component: PageLockScreenComponent },
12+
],
913
},
1014
{
1115
path: 'dashboard',
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<mat-sidenav-container>
2-
<mat-sidenav opened="true" mode="side">
2+
<mat-sidenav opened="true" mode="side" *ngIf="!config.layout.menu.hidden">
33
<div class="logo" fxLayout fxLayoutGap="20px" fxLayoutAlign="start center">
44
<mat-icon svgIcon="logo"></mat-icon>
55
<h3>Sistema de historias</h3>
66
</div>
77
<amb-menu></amb-menu>
88
</mat-sidenav>
99
<mat-sidenav-content>
10-
<amb-header></amb-header>
10+
<amb-header *ngIf="!config.layout.header.hidden"></amb-header>
1111
<router-outlet></router-outlet>
1212
</mat-sidenav-content>
1313
</mat-sidenav-container>

ambulance/src/app/app.component.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { Component } from '@angular/core';
2+
import { ConfigService } from './config/config.service';
23

34
@Component({
45
selector: 'amb-root',
56
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.css']
7+
styleUrls: ['./app.component.css'],
78
})
89
export class AppComponent {
9-
title = 'ambulance';
10+
config: any;
11+
12+
constructor(private readonly configService: ConfigService) {}
13+
14+
ngOnInit() {
15+
this.configService.config.subscribe((config: any) => {
16+
this.config = config;
17+
});
18+
}
1019
}

ambulance/src/app/app.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import { CoreModule } from './core/core.module';
1010
import { IconService } from './shared/services/icon.service';
1111
import { HttpClientModule } from '@angular/common/http';
1212
import { SharedModule } from './shared/shared.module';
13+
import { MatPaginatorIntl } from '@angular/material/paginator';
14+
import { Paginator } from './shared/classes/paginator';
15+
import { ConfigModule } from './config/config.module';
16+
import { AMB_Config } from './config/info';
17+
1318
@NgModule({
1419
declarations: [AppComponent, LoginComponent, ItemComponent],
1520
imports: [
@@ -19,8 +24,9 @@ import { SharedModule } from './shared/shared.module';
1924
HttpClientModule,
2025
SharedModule,
2126
CoreModule,
27+
ConfigModule.forRoot(AMB_Config),
2228
],
23-
providers: [],
29+
providers: [{ provide: MatPaginatorIntl, useClass: Paginator }],
2430
bootstrap: [AppComponent],
2531
})
2632
export class AppModule {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ModuleWithProviders, NgModule } from '@angular/core';
2+
import { Config } from './layer.interface';
3+
import { AMB_CONFIG } from './token';
4+
5+
@NgModule()
6+
export class ConfigModule {
7+
static forRoot(config: Config): ModuleWithProviders<ConfigModule> {
8+
return {
9+
ngModule: ConfigModule,
10+
providers: [{ provide: AMB_CONFIG, useValue: config }],
11+
};
12+
}
13+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Inject, Injectable } from '@angular/core';
2+
import { BehaviorSubject } from 'rxjs';
3+
import { Config } from './layer.interface';
4+
import { AMB_CONFIG } from './token';
5+
import * as _ from 'lodash';
6+
7+
@Injectable({
8+
providedIn: 'root',
9+
})
10+
export class ConfigService {
11+
private configSubject: BehaviorSubject<Config>;
12+
13+
constructor(@Inject(AMB_CONFIG) config: Config) {
14+
this.configSubject = new BehaviorSubject<Config>(config);
15+
}
16+
17+
set config(value: any) {
18+
let config = this.configSubject.getValue();
19+
config = _.merge({}, config, value);
20+
21+
this.configSubject.next(config);
22+
}
23+
24+
get config(): any {
25+
return this.configSubject.asObservable();
26+
}
27+
}

ambulance/src/app/config/info.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Config } from './layer.interface';
2+
3+
export const AMB_Config: Config = {
4+
layout: {
5+
header: {
6+
hidden: true,
7+
},
8+
menu: {
9+
hidden: true,
10+
},
11+
},
12+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export interface Config {
2+
layout: {
3+
header: {
4+
hidden: boolean;
5+
};
6+
menu: {
7+
hidden: boolean;
8+
};
9+
};
10+
}

0 commit comments

Comments
 (0)