Skip to content

Commit

Permalink
demo meetup
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosrodriguesjunior committed Jul 30, 2017
1 parent 670c075 commit 32de137
Show file tree
Hide file tree
Showing 22 changed files with 272 additions and 16 deletions.
20 changes: 19 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import { MyGuardGuard } from './my-guard.guard';
import { HomeComponent } from './vendas/home/home.component';
import { Usuario2Component } from './usuario2/usuario2.component';
import { UsuarioComponent } from './usuario/usuario.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
children: []
canActivate: [MyGuardGuard],
children: [
{
path: 'usuario',
component: UsuarioComponent,
},
{
path: 'usuario2',
component: Usuario2Component
},
{
path: 'vendas',
component: HomeComponent
}
]
}
];

Expand Down
12 changes: 0 additions & 12 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,5 @@ <h1>
</h1>
<img width="300" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiDQoJIHZpZXdCb3g9IjAgMCAyNTAgMjUwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNTAgMjUwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDojREQwMDMxO30NCgkuc3Qxe2ZpbGw6I0MzMDAyRjt9DQoJLnN0MntmaWxsOiNGRkZGRkY7fQ0KPC9zdHlsZT4NCjxnPg0KCTxwb2x5Z29uIGNsYXNzPSJzdDAiIHBvaW50cz0iMTI1LDMwIDEyNSwzMCAxMjUsMzAgMzEuOSw2My4yIDQ2LjEsMTg2LjMgMTI1LDIzMCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAJIi8+DQoJPHBvbHlnb24gY2xhc3M9InN0MSIgcG9pbnRzPSIxMjUsMzAgMTI1LDUyLjIgMTI1LDUyLjEgMTI1LDE1My40IDEyNSwxNTMuNCAxMjUsMjMwIDEyNSwyMzAgMjAzLjksMTg2LjMgMjE4LjEsNjMuMiAxMjUsMzAgCSIvPg0KCTxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik0xMjUsNTIuMUw2Ni44LDE4Mi42aDBoMjEuN2gwbDExLjctMjkuMmg0OS40bDExLjcsMjkuMmgwaDIxLjdoMEwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMUwxMjUsNTIuMQ0KCQlMMTI1LDUyLjF6IE0xNDIsMTM1LjRIMTA4bDE3LTQwLjlMMTQyLDEzNS40eiIvPg0KPC9nPg0KPC9zdmc+DQo=">
</div>
<h2>Here are some links to help you start: </h2>
<ul>
<li>
<h2><a target="_blank" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
</li>
<li>
<h2><a target="_blank" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
</li>
<li>
<h2><a target="_blank" href="http://angularjs.blogspot.com/">Angular blog</a></h2>
</li>
</ul>

<router-outlet></router-outlet>
18 changes: 15 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { HttpUsuarioService } from './http-usuario.service';
import { MyGuardGuard } from './my-guard.guard';
import { VendasModule } from './vendas/vendas.module';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { UsuarioComponent } from './usuario/usuario.component';
import { Usuario2Component } from './usuario2/usuario2.component';

@NgModule({
declarations: [
AppComponent
AppComponent,
UsuarioComponent,
Usuario2Component
],
imports: [
BrowserModule,
AppRoutingModule
AppRoutingModule,
VendasModule,
HttpClientModule,
FormsModule
],
providers: [],
providers: [MyGuardGuard, HttpUsuarioService],
bootstrap: [AppComponent]
})
export class AppModule { }
10 changes: 10 additions & 0 deletions src/app/bla/bla-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class BlaRoutingModule { }
13 changes: 13 additions & 0 deletions src/app/bla/bla.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { BlaRoutingModule } from './bla-routing.module';

@NgModule({
imports: [
CommonModule,
BlaRoutingModule
],
declarations: []
})
export class BlaModule { }
15 changes: 15 additions & 0 deletions src/app/http-usuario.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';

import { HttpUsuarioService } from './http-usuario.service';

describe('HttpUsuarioService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [HttpUsuarioService]
});
});

it('should be created', inject([HttpUsuarioService], (service: HttpUsuarioService) => {
expect(service).toBeTruthy();
}));
});
14 changes: 14 additions & 0 deletions src/app/http-usuario.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

@Injectable()
export class HttpUsuarioService {

constructor(private http: HttpClient) {
}

obterUsuarios() {
return this.http.get('https://demo-gama.herokuapp.com/user');
}

}
15 changes: 15 additions & 0 deletions src/app/my-guard.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TestBed, async, inject } from '@angular/core/testing';

import { MyGuardGuard } from './my-guard.guard';

describe('MyGuardGuard', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [MyGuardGuard]
});
});

it('should ...', inject([MyGuardGuard], (guard: MyGuardGuard) => {
expect(guard).toBeTruthy();
}));
});
12 changes: 12 additions & 0 deletions src/app/my-guard.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class MyGuardGuard implements CanActivate {
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
return true;
}
}
Empty file.
8 changes: 8 additions & 0 deletions src/app/usuario/usuario.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Teste Async 2
<div *ngIf="usuarios | async as u">
<p *ngFor=" let usuario of u" >
Meu documento é {{usuario.documento}}
</p>
<input type="text" [value]="name" (input)="name=$event.target.value" (click)="name='will'">
{{name}}
</div>
25 changes: 25 additions & 0 deletions src/app/usuario/usuario.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { UsuarioComponent } from './usuario.component';

describe('UsuarioComponent', () => {
let component: UsuarioComponent;
let fixture: ComponentFixture<UsuarioComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UsuarioComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(UsuarioComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
26 changes: 26 additions & 0 deletions src/app/usuario/usuario.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { HttpUsuarioService } from './../http-usuario.service';
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import 'rxjs/add/operator/toPromise';

@Component({
selector: 'app-usuario',
templateUrl: './usuario.component.html',
styleUrls: ['./usuario.component.css']
})
export class UsuarioComponent implements OnInit {

usuarios = this.httpUsuario.obterUsuarios();
name = 'Carlao';

constructor(private httpUsuario: HttpUsuarioService) {
}

meuMetodo(event) {
console.log(event);
}

ngOnInit() {
}

}
Empty file.
3 changes: 3 additions & 0 deletions src/app/usuario2/usuario2.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
usuario2 works!
</p>
25 changes: 25 additions & 0 deletions src/app/usuario2/usuario2.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { Usuario2Component } from './usuario2.component';

describe('Usuario2Component', () => {
let component: Usuario2Component;
let fixture: ComponentFixture<Usuario2Component>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Usuario2Component ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(Usuario2Component);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/usuario2/usuario2.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-usuario2',
templateUrl: './usuario2.component.html',
styleUrls: ['./usuario2.component.css']
})
export class Usuario2Component implements OnInit {

constructor() { }

ngOnInit() {
}

}
Empty file.
3 changes: 3 additions & 0 deletions src/app/vendas/home/home.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
home works!
</p>
25 changes: 25 additions & 0 deletions src/app/vendas/home/home.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { HomeComponent } from './home.component';

describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/vendas/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
14 changes: 14 additions & 0 deletions src/app/vendas/vendas.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HomeComponent } from './home/home.component';

@NgModule({
imports: [
CommonModule
],
exports: [
HomeComponent
],
declarations: [HomeComponent]
})
export class VendasModule { }

0 comments on commit 32de137

Please sign in to comment.