diff --git a/src/app/admin/admin-routing.module.ts b/src/app/admin/admin-routing.module.ts new file mode 100644 index 0000000..d42ad78 --- /dev/null +++ b/src/app/admin/admin-routing.module.ts @@ -0,0 +1,34 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { AdminComponent } from './admin.component'; +import { HomeComponent } from './home.component'; +import { AjudaComponent } from './ajuda.component'; +import { EstadosListaComponent } from './estados/estados-lista.component'; +import { CidadesListaComponent } from './cidades/cidades-lista.component'; +import { CidadesFormComponent } from './cidades/cidades-form.component'; +import { EstadoCadastroComponent } from './estados/cadastro.component'; +import { Cidade } from './cidades/Cidade'; + +const rotas: Routes = [ + { + path: 'admin', component: AdminComponent, children: [ + { path: 'estados/cadastro', component: EstadoCadastroComponent }, + { path: 'cidades', component: CidadesListaComponent }, + { path: 'cidades/cadastro', component: CidadesFormComponent }, + { path: 'cidades/editar/:idCidade', component: CidadesFormComponent }, + { path: 'estados', component: EstadosListaComponent }, + { path: 'ajuda', component: AjudaComponent }, + { path: '', component: HomeComponent } + ] + }, +]; + +@NgModule({ + imports: [ + RouterModule.forChild(rotas) + ], + exports: [ + RouterModule + ] +}) +export class AdminRoutingModule { } \ No newline at end of file diff --git a/src/app/admin/admin.component.css b/src/app/admin/admin.component.css new file mode 100644 index 0000000..b69805c --- /dev/null +++ b/src/app/admin/admin.component.css @@ -0,0 +1,76 @@ +/* + * Base structure + */ + +/* Move down content because we have a fixed navbar that is 50px tall */ +body { + padding-top: 50px !important; +} + +.navbar { + margin-top: 0px !important; + margin-bottom: 0px !important; +} + +/* + * Typography + */ + +h1 { + margin-top: 0px; + margin-bottom: 20px; + padding-bottom: 9px; + border-bottom: 1px solid #eee; +} + +/* + * Sidebar + */ + +.sidebar { + position: fixed; + top: 36px; + bottom: 0; + left: 0; + z-index: 1000; + padding: 20px; + overflow-x: hidden; + overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ + border-right: 1px solid #eee; +} + +/* Sidebar navigation */ +.sidebar { + padding-left: 0; + padding-right: 0; +} + +.sidebar .nav { + margin-bottom: 20px; +} + +.sidebar .nav-item { + width: 100%; +} + +.sidebar .nav-item + .nav-item { + margin-left: 0; +} + +.sidebar .nav-link { + border-radius: 0; +} + +/* + * Dashboard + */ + + /* Placeholders */ +.placeholders { + padding-bottom: 3rem; +} + +.placeholder img { + padding-top: 1.5rem; + padding-bottom: 1.5rem; +} diff --git a/src/app/admin/admin.component.html b/src/app/admin/admin.component.html new file mode 100644 index 0000000..bb51776 --- /dev/null +++ b/src/app/admin/admin.component.html @@ -0,0 +1,37 @@ + + +
+
+ + +
+ +
+
+
\ No newline at end of file diff --git a/src/app/admin/admin.component.ts b/src/app/admin/admin.component.ts new file mode 100644 index 0000000..4903229 --- /dev/null +++ b/src/app/admin/admin.component.ts @@ -0,0 +1,13 @@ +import { Component, OnInit, ViewEncapsulation } from '@angular/core'; + +@Component({ + templateUrl: 'admin.component.html', + styleUrls: [ 'admin.component.css' ], + encapsulation: ViewEncapsulation.None +}) + +export class AdminComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} \ No newline at end of file diff --git a/src/app/admin/admin.module.ts b/src/app/admin/admin.module.ts new file mode 100644 index 0000000..309c7b1 --- /dev/null +++ b/src/app/admin/admin.module.ts @@ -0,0 +1,39 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { FormsModule } from '@angular/forms'; +import { HttpModule } from '@angular/http'; +import { RouterModule } from '@angular/router'; +import { AdminComponent } from './admin.component'; +import { HomeComponent } from './home.component'; +import { AdminRoutingModule } from './admin-routing.module'; +import { AjudaComponent } from './ajuda.component'; +import { EstadosListaComponent } from './estados/estados-lista.component'; +import { EstadosService } from './estados/estados.service'; +import { CidadesListaComponent } from './cidades/cidades-lista.component'; +import { CidadesFormComponent } from './cidades/cidades-form.component'; +import { CidadesService } from './cidades/cidades.service'; +import { Cidade } from './cidades/Cidade'; +import { EstadoCadastroComponent } from './estados/cadastro.component'; + +@NgModule({ + imports: [ + BrowserModule, + FormsModule, + HttpModule, + AdminRoutingModule + ], + declarations: [ + AdminComponent, + HomeComponent, + AjudaComponent, + EstadosListaComponent, + EstadoCadastroComponent, + CidadesListaComponent, + CidadesFormComponent + ], + providers: [ + EstadosService, + CidadesService + ], +}) +export class AdminModule { } \ No newline at end of file diff --git a/src/app/admin/ajuda.component.html b/src/app/admin/ajuda.component.html new file mode 100644 index 0000000..49367f9 --- /dev/null +++ b/src/app/admin/ajuda.component.html @@ -0,0 +1,2 @@ +

Ajuda

+

Página de ajuda do módulo de administração de conferências (eventos).

\ No newline at end of file diff --git a/src/app/admin/ajuda.component.ts b/src/app/admin/ajuda.component.ts new file mode 100644 index 0000000..65a561b --- /dev/null +++ b/src/app/admin/ajuda.component.ts @@ -0,0 +1,11 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: 'ajuda.component.html' +}) + +export class AjudaComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} \ No newline at end of file diff --git a/src/app/admin/cidades/Cidade.ts b/src/app/admin/cidades/Cidade.ts new file mode 100644 index 0000000..f39e6d5 --- /dev/null +++ b/src/app/admin/cidades/Cidade.ts @@ -0,0 +1,11 @@ +export class Cidade { + public id: number; + public nome: string; + public estadoId: number; + + constructor(id: number, nome: string, estadoId: number) { + this.id = id; + this.nome = nome; + this.estadoId = estadoId; + } +} \ No newline at end of file diff --git a/src/app/admin/cidades/cidades-edit.component.html b/src/app/admin/cidades/cidades-edit.component.html new file mode 100644 index 0000000..5440e3a --- /dev/null +++ b/src/app/admin/cidades/cidades-edit.component.html @@ -0,0 +1,26 @@ +

Cidades

+ +
+
+ + +
Você deve informar o nome da Cidade.
+
+ +
+ + + +
Você deve informar o id do estado.
+
+ + + +
\ No newline at end of file diff --git a/src/app/admin/cidades/cidades-edit.component.ts b/src/app/admin/cidades/cidades-edit.component.ts new file mode 100644 index 0000000..3e76e7b --- /dev/null +++ b/src/app/admin/cidades/cidades-edit.component.ts @@ -0,0 +1,41 @@ +import { Component, OnInit } from '@angular/core'; +import { CidadesService } from './cidades.service'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { Cidade } from './Cidade'; +@Component({ + templateUrl: 'cidades-edit.component.html' +}) +export class CidadesEditComponent implements OnInit { + cidade: Cidade = new Cidade(0, '', 0); + estados: any; + errorMessage = ""; + + constructor(private cidadesService: CidadesService, private activatedRoute: ActivatedRoute, private router: Router) { } + + ngOnInit() { + } + + preencherNova(): void { + this.cidade = new Cidade(0, '', 0); + } + + salvar() { + this.cidadesService.save(this.cidade.nome, this.cidade.estadoId) + .subscribe( + erro => console.log(erro)); + } + + onSubmit() : void { + this.salvar(); + this.preencherNova(); + this.router.navigate(['admin/cidades/']); + } + + pegaEstados(){ + this.cidadesService.estados().subscribe( + estados => this.estados = estados, + error => this.errorMessage = error); + + return this.estados; + } +} \ No newline at end of file diff --git a/src/app/admin/cidades/cidades-form.component.html b/src/app/admin/cidades/cidades-form.component.html new file mode 100644 index 0000000..2a53714 --- /dev/null +++ b/src/app/admin/cidades/cidades-form.component.html @@ -0,0 +1,59 @@ +

Cidades

+
+

Cadastro de Cidades

+
+ +
+

Edição de Cidades

+
+ + +
+
+ + + + + + + +
+
+ + +
Você deve informar o nome da Cidade.
+
+ +
+ + + +
Você deve informar o id do estado.
+
+ + + +
\ No newline at end of file diff --git a/src/app/admin/cidades/cidades-form.component.ts b/src/app/admin/cidades/cidades-form.component.ts new file mode 100644 index 0000000..52328a7 --- /dev/null +++ b/src/app/admin/cidades/cidades-form.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit } from '@angular/core'; +import { CidadesService } from './cidades.service'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { Cidade } from './Cidade'; +@Component({ + templateUrl: 'cidades-form.component.html' +}) +export class CidadesFormComponent implements OnInit { + cidade: Cidade = new Cidade(0, '', 0); + idCidade: number = null; + status: boolean; + estados: any; + errorMessage = ""; + msgErro: any = ''; + + constructor(private cidadesService: CidadesService, private activatedRoute: ActivatedRoute, private router: Router) { } + + ngOnInit() { + this.activatedRoute.params.subscribe((params: Params) => { + this.idCidade = params['id']; + this.activatedRoute.params.subscribe((params: Params) => { + this.idCidade = params['idCidade']; + this.cidadesService.getCidadeById(this.idCidade).subscribe( + cidade => this.cidade = cidade); + }); + }); + } + + preencherNova(): void { + this.cidade = new Cidade(0, '', 0); + } + + salvar() { + this.cidade.id = this.idCidade; + if(this.idCidade != null){ + this.cidadesService.update(this.cidade.id, this.cidade.nome, this.cidade.estadoId) + .subscribe( + cidade => this.status = true, + erro => this.msgErro = erro); + } + else{ + this.cidadesService.save(this.cidade.nome, this.cidade.estadoId) + .subscribe( + cidade => this.status = true, + erro => this.msgErro = erro); + } + } + + onSubmit() : void { + this.salvar(); + this.preencherNova(); + } + + pegaEstados(){ + this.cidadesService.estados().subscribe( + estados => this.estados = estados, + error => this.errorMessage = error); + + return this.estados; + } + + voltar(){ + this.router.navigate(['admin/cidades/']); + } +} \ No newline at end of file diff --git a/src/app/admin/cidades/cidades-lista.component.html b/src/app/admin/cidades/cidades-lista.component.html new file mode 100644 index 0000000..dd59885 --- /dev/null +++ b/src/app/admin/cidades/cidades-lista.component.html @@ -0,0 +1,65 @@ +
+
+

Cidades

+
+ +
+ + + + + + + + + + + + + + + + + +
IdCidadeidEstado
{{cidade.id}}{{cidade.nome}}{{cidade.estado.nome}} + + +
+ + + + + \ No newline at end of file diff --git a/src/app/admin/cidades/cidades-lista.component.ts b/src/app/admin/cidades/cidades-lista.component.ts new file mode 100644 index 0000000..dc1f945 --- /dev/null +++ b/src/app/admin/cidades/cidades-lista.component.ts @@ -0,0 +1,75 @@ +import { Component, OnInit } from '@angular/core'; +import { CidadesService } from './cidades.service'; +import { Router, ActivatedRoute, Params } from '@angular/router'; +import { Cidade } from './Cidade'; +@Component({ + templateUrl: 'cidades-lista.component.html' +}) +export class CidadesListaComponent implements OnInit { + cidades: any; + errorMessage = ""; + excluir: boolean = false; + selecionada: any = null; + numPaginas: any; + totalPaginas: any = []; + msgErro: String = ''; + + constructor(private cidadesService: CidadesService, private activatedRoute: ActivatedRoute, private router: Router) {} + + pegaTodas(){ + this.cidadesService.getAllByPage(1).subscribe( + cidades => this.cidades = cidades, + error => this.errorMessage = error); + } + + ngOnInit() { + this.pegaTodas(); + this.paginar(); + } + + clickExcluir(cidade: any): void{ + this.excluir = true; + this.selecionada = cidade; + } + + clickConfirma(): void{ + this.excluir = false; + this.excluirCidade(this.selecionada); + } + + clickCancela(): void{ + this.excluir = false; + this.selecionada = null; + } + + excluirCidade(cidade: any): void { + this.cidadesService.delete(cidade.id).subscribe( + () => { + this.pegaTodas(); + }, + error => this.errorMessage = error); + } + + editarCidade(cidade: Cidade){ + this.router.navigate(['admin/cidades/editar/'+cidade.id]); + } + + paginar(){ + this.cidadesService.all().subscribe( + cidades => { + this.numPaginas = cidades.length; + this.numPaginas = Math.ceil(this.numPaginas/5); + for(var i=0; i this.msgErro = erro, + ); + } + + escolherPagina(numeroPagina: number){ + this.cidadesService.getAllByPage(numeroPagina+1).subscribe( + cidades => this.cidades = cidades, + erro => this.msgErro = erro, + ); + } +} \ No newline at end of file diff --git a/src/app/admin/cidades/cidades.service.ts b/src/app/admin/cidades/cidades.service.ts new file mode 100644 index 0000000..6970bd2 --- /dev/null +++ b/src/app/admin/cidades/cidades.service.ts @@ -0,0 +1,63 @@ +import { Injectable } from '@angular/core'; +import { Cidade } from './Cidade'; +import { Http, RequestOptions, Headers } from '@angular/http'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; + +@Injectable() +export class CidadesService { + private headers = null; + private options = null; + + constructor(private http: Http) { + this.headers = new Headers({'Content-Type': 'application/json'}); + this.options = new RequestOptions({ headers: this.headers }); + } + + select(id: number){ + return this.http.get('http://localhost:3000/cidades?id'+id) + .map(response => response.json() as Cidade); + } + + save(nome: string, estado: number) { + const cidade = { nome: nome, estadoId: estado}; + return this.http.post('http://localhost:3000/cidades', JSON.stringify(cidade), this.options) + .map(response => response.json()) + .catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } + + all(): Observable { + return this.http.get('http://localhost:3000/cidades?_expand=estado') + .map(response => response.json() as Cidade[]); + } + + estados(): Observable { + return this.http.get('http://localhost:3000/estados') + .map(response => response.json() as any[]); + } + + delete(id: number):Observable{ + return this.http.delete('http://localhost:3000/cidades/'+id, this.options) + .map(response => response.json() ).catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } + + update(id: number, nome: string, estado: number) { + const cidade = { id: id, nome: nome, estadoId: estado}; + return this.http.put('http://localhost:3000/cidades/' + id, JSON.stringify(cidade), this.options) + .map(response => response.json()) + .catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } + + getAllByPage(numeroPagina: number): Observable { + return this.http.get('http://localhost:3000/cidades?_page='+numeroPagina+'&_limit=5&_expand=estado') + .map(response => response.json() as Cidade[]) + .catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } + + getCidadeById(idCidade: number): Observable { + return this.http.get('http://localhost:3000/cidades/'+idCidade) + .map(response => response.json()) + .catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } +} \ No newline at end of file diff --git a/src/app/admin/estados/cadastro.component.html b/src/app/admin/estados/cadastro.component.html new file mode 100644 index 0000000..a5dce57 --- /dev/null +++ b/src/app/admin/estados/cadastro.component.html @@ -0,0 +1,3 @@ +

Cadastro de estados

+ + \ No newline at end of file diff --git a/src/app/admin/estados/cadastro.component.ts b/src/app/admin/estados/cadastro.component.ts new file mode 100644 index 0000000..3922e8f --- /dev/null +++ b/src/app/admin/estados/cadastro.component.ts @@ -0,0 +1,19 @@ +import { Component, OnInit } from '@angular/core'; +import { EstadosService } from './estados.service'; + + +@Component({ + templateUrl: 'cadastro.component.html' +}) +export class EstadoCadastroComponent implements OnInit { + constructor(private estadosService: EstadosService) { } + + ngOnInit() { } + + salvar() { + this.estadosService.save("Pará", "PA") + .subscribe( + estado => console.log(estado), + erro => console.log(erro)); + } +} \ No newline at end of file diff --git a/src/app/admin/estados/estados-lista.component.html b/src/app/admin/estados/estados-lista.component.html new file mode 100644 index 0000000..b607d6e --- /dev/null +++ b/src/app/admin/estados/estados-lista.component.html @@ -0,0 +1,4 @@ +

Estados

+
+    {{estados | async | json}}
+
\ No newline at end of file diff --git a/src/app/admin/estados/estados-lista.component.ts b/src/app/admin/estados/estados-lista.component.ts new file mode 100644 index 0000000..3d5ef2c --- /dev/null +++ b/src/app/admin/estados/estados-lista.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; +import { EstadosService } from './estados.service'; + +@Component({ + templateUrl: 'estados-lista.component.html' +}) +export class EstadosListaComponent implements OnInit { + estados: any; + + constructor(private estadosService: EstadosService) { } + + ngOnInit() { + this.estados = this.estadosService.all(); + } +} \ No newline at end of file diff --git a/src/app/admin/estados/estados.service.ts b/src/app/admin/estados/estados.service.ts new file mode 100644 index 0000000..114f979 --- /dev/null +++ b/src/app/admin/estados/estados.service.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@angular/core'; +import { Http, RequestOptions, Headers } from '@angular/http'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; + +@Injectable() +export class EstadosService { + private headers = null; + private options = null; + + constructor(private http: Http) { + this.headers = new Headers({'Content-Type': 'application/json'}); + this.options = new RequestOptions({ headers: this.headers }); + } + + all(): Observable { + return this.http.get('http://localhost:3000/estados') + .map(response => response.json()); + } + + save(nome: string, uf: string) { + const estado = { nome: nome, uf: uf }; + return this.http.post('http://localhost:3000/estados', JSON.stringify(estado), this.options) + .map(response => response.json()) + .catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } + + update(id: number, nome: string, uf: string) { + const estado = { id: id, nome: nome, uf: uf }; + return this.http.put('http://localhost:3000/estados/' + id, JSON.stringify(estado), this.options) + .map(response => response.json()) + .catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } + + delete(id: number) { + return this.http.delete('http://localhost:3000/estados/' + id, this.options) + .map(response => response.json()) + .catch((error:any) => Observable.throw(error.json().error || 'Erro ao conectar ao servidor.')); + } + +} \ No newline at end of file diff --git a/src/app/admin/home.component.html b/src/app/admin/home.component.html new file mode 100644 index 0000000..0b6fb8c --- /dev/null +++ b/src/app/admin/home.component.html @@ -0,0 +1,2 @@ +

Dashboard home

+

Esta é a home da Dashboard

\ No newline at end of file diff --git a/src/app/admin/home.component.ts b/src/app/admin/home.component.ts new file mode 100644 index 0000000..b4815d2 --- /dev/null +++ b/src/app/admin/home.component.ts @@ -0,0 +1,11 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: 'home.component.html' +}) + +export class HomeComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts new file mode 100644 index 0000000..09d4e2d --- /dev/null +++ b/src/app/app-routing.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { AppComponent } from './app.component'; +import { PaginaNaoEncontradaComponent } from './pagina-nao-encontrada.component'; + +const rotas: Routes = [ + { path: '', redirectTo: '/public', pathMatch: 'full' }, + { path: '**', component: PaginaNaoEncontradaComponent } +]; + +@NgModule({ + imports: [ + RouterModule.forRoot(rotas) + ], + exports: [ + RouterModule + ] +}) +export class AppRoutingModule { } \ No newline at end of file diff --git a/src/app/app.component.html b/src/app/app.component.html index a4b6ce3..0680b43 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,3 +1 @@ -
- -
\ No newline at end of file + diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts new file mode 100644 index 0000000..c740bcd --- /dev/null +++ b/src/app/app.component.spec.ts @@ -0,0 +1,32 @@ +import { TestBed, async } from '@angular/core/testing'; + +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ + AppComponent + ], + }).compileComponents(); + })); + + it('should create the app', async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + })); + + it(`should have as title 'app works!'`, async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app.title).toEqual('app works!'); + })); + + it('should render title in a h1 tag', async(() => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector('h1').textContent).toContain('app works!'); + })); +}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 875f70b..77f9411 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,11 +1,10 @@ import { Component } from '@angular/core'; -import '../../public/css/style.css'; +import '../assets/css/style.css'; @Component({ selector: 'my-app', - templateUrl: './app.component.html', - styleUrls: ['./app.component.css'] + templateUrl: './app.component.html' }) export class AppComponent { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b10c986..e0a7727 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -2,19 +2,34 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; +import { RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; -import { EventoManagerComponent } from './evento-manager.component'; +import { CidadesService } from './cidades.service'; +import { EstadosService } from './estados.service'; +import { AppRoutingModule } from './app-routing.module'; +import { PublicModule } from './public/public.module'; +import { AdminModule } from './admin/admin.module'; +import { EventosModule } from './eventos/eventos.module'; +import { PaginaNaoEncontradaComponent } from './pagina-nao-encontrada.component'; @NgModule({ imports: [ BrowserModule, FormsModule, - HttpModule + HttpModule, + EventosModule, + AdminModule, + PublicModule, + AppRoutingModule ], declarations: [ AppComponent, - EventoManagerComponent + PaginaNaoEncontradaComponent + ], + providers: [ + CidadesService, + EstadosService ], bootstrap: [AppComponent] }) -export class AppModule { } +export class AppModule { } \ No newline at end of file diff --git a/src/app/cidades.service.ts b/src/app/cidades.service.ts index 5b776a0..3ef1b7d 100644 --- a/src/app/cidades.service.ts +++ b/src/app/cidades.service.ts @@ -9,7 +9,7 @@ export class CidadesService { } all(): Observable { - return this.http.get('../../public/dados/cidades.json') + return this.http.get('assets/dados/cidades.json') .map(response => response.json()); } diff --git a/src/app/estados.service.ts b/src/app/estados.service.ts index 1569d9e..1a0ed32 100644 --- a/src/app/estados.service.ts +++ b/src/app/estados.service.ts @@ -9,7 +9,7 @@ export class EstadosService { } all(): Observable { - return this.http.get('../../public/dados/estados.json') + return this.http.get('assets/dados/estados.json') .map(response => response.json()); } } diff --git a/src/app/eventos/Evento.ts b/src/app/eventos/Evento.ts new file mode 100644 index 0000000..3bb3a2b --- /dev/null +++ b/src/app/eventos/Evento.ts @@ -0,0 +1,17 @@ +export class Evento { + public id: number; + public nome: string; + public sigla: string; + public inicio: string; + public termino: string; + public url: string; + public cidade: string; + public estado: string; + public local: string; + + constructor(id: number, nome: string, sigla: string) { + this.id = id; + this.nome = nome; + this.sigla = sigla; + } +} diff --git a/src/app/eventos/evento-detalhes.component.html b/src/app/eventos/evento-detalhes.component.html new file mode 100644 index 0000000..9be5495 --- /dev/null +++ b/src/app/eventos/evento-detalhes.component.html @@ -0,0 +1,13 @@ +
+

{{evento.sigla}} - {{evento.nome}}

+

{{evento.inicio}} a {{evento.termino}}

+

{{evento.local}}, em {{evento.cidade}} - {{evento.estado}}

+

Para saber mais, visite + {{evento.url}}

+
+
+

Evento não encontrado!

+

O evento que você procura não pode ser encontrado. Veja a + lista dos eventos. +

+
\ No newline at end of file diff --git a/src/app/eventos/evento-detalhes.component.ts b/src/app/eventos/evento-detalhes.component.ts new file mode 100644 index 0000000..6087241 --- /dev/null +++ b/src/app/eventos/evento-detalhes.component.ts @@ -0,0 +1,27 @@ +import { Component, OnInit } from '@angular/core'; +import { Router, ActivatedRoute } from '@angular/router'; +import { Evento } from './Evento'; +import { EventosService } from './eventos.service'; +import 'rxjs/add/operator/switchMap'; + + +@Component({ + templateUrl: 'evento-detalhes.component.html' +}) + +export class EventoDetalhesComponent implements OnInit { + evento: Evento; + + constructor( + private eventosService: EventosService, + private route: ActivatedRoute) { } + + ngOnInit() { + this.route.params + .switchMap(params => { + let id: number = Number.parseInt(params['id']); + return this.eventosService.find(id); + }) + .subscribe(evento => this.evento = evento ); + } +} \ No newline at end of file diff --git a/src/app/eventos/eventos-home.component.html b/src/app/eventos/eventos-home.component.html new file mode 100644 index 0000000..90c6b64 --- /dev/null +++ b/src/app/eventos/eventos-home.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/eventos/eventos-home.component.ts b/src/app/eventos/eventos-home.component.ts new file mode 100644 index 0000000..f5c9f8d --- /dev/null +++ b/src/app/eventos/eventos-home.component.ts @@ -0,0 +1,11 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: 'eventos-home.component.html' +}) + +export class EventosHomeComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} \ No newline at end of file diff --git a/src/app/eventos/eventos-lista.component.html b/src/app/eventos/eventos-lista.component.html new file mode 100644 index 0000000..10065ba --- /dev/null +++ b/src/app/eventos/eventos-lista.component.html @@ -0,0 +1,22 @@ +

Eventos

+ + + + + + + + + + + + + + + + + +
SiglaNomeDataDetalhes
{{evento.sigla}}{{evento.nome}}{{evento.inicio}} a {{evento.termino}} + +
diff --git a/src/app/eventos/eventos-lista.component.ts b/src/app/eventos/eventos-lista.component.ts new file mode 100644 index 0000000..1f3254d --- /dev/null +++ b/src/app/eventos/eventos-lista.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import { Location } from '@angular/common'; +import { Router } from '@angular/router'; +import { EventosService } from './eventos.service'; +import { Evento } from './Evento'; + +@Component({ + templateUrl: 'eventos-lista.component.html' +}) + +export class EventosListaComponent implements OnInit { + eventos: Evento[]; + + constructor(private eventosService: EventosService, + private router: Router) { } + + ngOnInit() { + this.eventosService.all(). + subscribe(eventos => this.eventos = eventos); + } + + mostrarDetalhes(evento: Evento) { + this.router.navigate(['/eventos', evento.id]); + } +} \ No newline at end of file diff --git a/src/app/eventos/eventos-routing.module.ts b/src/app/eventos/eventos-routing.module.ts new file mode 100644 index 0000000..57ad1be --- /dev/null +++ b/src/app/eventos/eventos-routing.module.ts @@ -0,0 +1,27 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { EventosHomeComponent } from './eventos-home.component'; +import { EventosListaComponent } from './eventos-lista.component'; +import { EventoDetalhesComponent } from './evento-detalhes.component'; + +const rotas: Routes = [ + { + path: 'eventos', + component: EventosHomeComponent, + children: [ + { path: ':id', component: EventoDetalhesComponent }, + { path: '', component: EventosListaComponent }, + ] + }, + +]; + +@NgModule({ + imports: [ + RouterModule.forChild(rotas) + ], + exports: [ + RouterModule + ] +}) +export class EventosRoutingModule { } diff --git a/src/app/eventos/eventos.module.ts b/src/app/eventos/eventos.module.ts new file mode 100644 index 0000000..e9615e2 --- /dev/null +++ b/src/app/eventos/eventos.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { FormsModule } from '@angular/forms'; +import { HttpModule } from '@angular/http'; +import { RouterModule } from '@angular/router'; +import { EventosHomeComponent } from './eventos-home.component'; +import { EventosListaComponent } from './eventos-lista.component'; +import { EventoDetalhesComponent } from './evento-detalhes.component'; +import { EventosRoutingModule } from './eventos-routing.module'; +import { EventosService } from './eventos.service'; + +@NgModule({ + imports: [ + BrowserModule, + FormsModule, + HttpModule, + EventosRoutingModule + ], + declarations: [ + EventosHomeComponent, + EventoDetalhesComponent, + EventosListaComponent, + ], + providers: [ + EventosService + ] +}) +export class EventosModule { } diff --git a/src/app/eventos/eventos.service.ts b/src/app/eventos/eventos.service.ts new file mode 100644 index 0000000..2c8ef1e --- /dev/null +++ b/src/app/eventos/eventos.service.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@angular/core'; +import { Evento } from './Evento'; +import { Http } from '@angular/http'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/find'; + +@Injectable() +export class EventosService { + constructor(private http: Http) { + } + + all(): Observable { + return this.http.get('assets/dados/eventos.json') + .map(response => response.json() as Evento[]); + } + + find(id: number): Observable { + return this.all() + .map(eventos => eventos.find(evento => evento.id === id)); + } +} diff --git a/src/app/pagina-nao-encontrada.component.html b/src/app/pagina-nao-encontrada.component.html new file mode 100644 index 0000000..e184914 --- /dev/null +++ b/src/app/pagina-nao-encontrada.component.html @@ -0,0 +1,2 @@ +

Oops!

+

A página solicitada não foi encontrada.

\ No newline at end of file diff --git a/src/app/pagina-nao-encontrada.component.ts b/src/app/pagina-nao-encontrada.component.ts new file mode 100644 index 0000000..72a9a9e --- /dev/null +++ b/src/app/pagina-nao-encontrada.component.ts @@ -0,0 +1,11 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: 'pagina-nao-encontrada.component.html' +}) + +export class PaginaNaoEncontradaComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} \ No newline at end of file diff --git a/src/app/public/home.component.html b/src/app/public/home.component.html new file mode 100644 index 0000000..8ccecee --- /dev/null +++ b/src/app/public/home.component.html @@ -0,0 +1,7 @@ +
+
+

Eventos++!

+

Este é um sistema de gerenciamento e divulgação de informações sobre eventos.

+

Saiba mais »

+
+
\ No newline at end of file diff --git a/src/app/public/home.component.ts b/src/app/public/home.component.ts new file mode 100644 index 0000000..235818a --- /dev/null +++ b/src/app/public/home.component.ts @@ -0,0 +1,10 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: 'home.component.html' +}) +export class HomeComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} \ No newline at end of file diff --git a/src/app/public/public-routing.module.ts b/src/app/public/public-routing.module.ts new file mode 100644 index 0000000..e8ea587 --- /dev/null +++ b/src/app/public/public-routing.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { PublicComponent } from './public.component'; +import { HomeComponent } from './home.component'; +import { SobreComponent } from './sobre.component'; + +const rotas: Routes = [ + { + path: '', component: PublicComponent, children: [ + { path: 'sobre', component: SobreComponent }, + { path: '', component: HomeComponent } + ] + }, + +]; + +@NgModule({ + imports: [ + RouterModule.forChild(rotas) + ], + exports: [ + RouterModule + ] +}) +export class PublicRoutingModule { } \ No newline at end of file diff --git a/src/app/public/public.component.html b/src/app/public/public.component.html new file mode 100644 index 0000000..586bb19 --- /dev/null +++ b/src/app/public/public.component.html @@ -0,0 +1,25 @@ +
+ + + +
\ No newline at end of file diff --git a/src/app/public/public.component.ts b/src/app/public/public.component.ts new file mode 100644 index 0000000..5e6d290 --- /dev/null +++ b/src/app/public/public.component.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + templateUrl: './public.component.html' +}) +export class PublicComponent { + +} diff --git a/src/app/public/public.module.ts b/src/app/public/public.module.ts new file mode 100644 index 0000000..e785e0a --- /dev/null +++ b/src/app/public/public.module.ts @@ -0,0 +1,26 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { FormsModule } from '@angular/forms'; +import { HttpModule } from '@angular/http'; +import { RouterModule } from '@angular/router'; +import { PublicComponent } from './public.component'; +import { HomeComponent } from './home.component'; +import { SobreComponent } from './sobre.component'; +import { PublicRoutingModule } from './public-routing.module'; + +@NgModule({ + imports: [ + BrowserModule, + FormsModule, + HttpModule, + PublicRoutingModule + ], + declarations: [ + PublicComponent, + HomeComponent, + SobreComponent + ], + providers: [ + ], +}) +export class PublicModule { } \ No newline at end of file diff --git a/src/app/public/sobre.component.html b/src/app/public/sobre.component.html new file mode 100644 index 0000000..15cc00f --- /dev/null +++ b/src/app/public/sobre.component.html @@ -0,0 +1,7 @@ +

Eventos++

+ +

Eventos++ é um sistema open-source, desenvolvido com uma arquitetura modular + utilizando Angular.

+

O objetivo principal é o apoio ao desenvolvimento de habilidades de programação na turma + de Linguagem de Programação para Web dos cursos de computação do Centro Universitário + Luterano de Palmas

\ No newline at end of file diff --git a/src/app/public/sobre.component.ts b/src/app/public/sobre.component.ts new file mode 100644 index 0000000..88d4d75 --- /dev/null +++ b/src/app/public/sobre.component.ts @@ -0,0 +1,11 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: 'sobre.component.html' +}) + +export class SobreComponent implements OnInit { + constructor() { } + + ngOnInit() { } +} \ No newline at end of file diff --git a/src/assets/.gitkeep b/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/assets/css/style.css b/src/assets/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/src/assets/dados/cidades.json b/src/assets/dados/cidades.json new file mode 100644 index 0000000..3ab6e2f --- /dev/null +++ b/src/assets/dados/cidades.json @@ -0,0 +1,38 @@ +[ + { + "nome": "Palmas", + "uf": "TO" + }, + { + "nome": "Paraíso do Tocantins", + "uf": "TO" + }, + { + "nome": "Gurupi", + "uf": "TO" + }, + { + "nome": "Araguaína", + "uf": "TO" + }, + { + "nome": "Porto Nacional", + "uf": "TO" + }, + { + "nome": "Belo Horizonte", + "uf": "MG" + }, + { + "nome": "Goiânia", + "uf": "GO" + }, + { + "nome": "São Paulo", + "uf": "SP" + }, + { + "nome": "Rio de Janeiro", + "uf": "RJ" + } +] \ No newline at end of file diff --git a/src/assets/dados/estados.json b/src/assets/dados/estados.json new file mode 100644 index 0000000..9b61fa1 --- /dev/null +++ b/src/assets/dados/estados.json @@ -0,0 +1,22 @@ +[ + { + "uf": "TO", + "nome": "Tocantins" + }, + { + "uf": "GO", + "nome": "Goiás" + }, + { + "uf": "MG", + "nome": "Minas Gerais" + }, + { + "uf": "SP", + "nome": "São Paulo" + }, + { + "uf": "RJ", + "nome": "Rio de Janeiro" + } +] \ No newline at end of file diff --git a/src/assets/dados/eventos.json b/src/assets/dados/eventos.json new file mode 100644 index 0000000..a8888ec --- /dev/null +++ b/src/assets/dados/eventos.json @@ -0,0 +1,35 @@ +[ + { + "id": 1, + "nome": "XIX Congresso de Computação e Sistemas de Informação", + "sigla": "ENCOINFO", + "inicio": "2017-05-15", + "termino": "2017-05-18", + "local": "Centro Universitário Luterano de Palmas", + "cidade": "Palmas", + "estado": "TO", + "url": "http://ulbra-to.br/encoinfo" + }, + { + "id": 2, + "nome": "XIII Simpósio Brasileiro de Sistemas de Informação", + "sigla": "SBSI", + "inicio": "2017-06-05", + "termino": "2017-06-08", + "local": "Universidade Federal de Lavras", + "cidade": "Lavras", + "estado": "MG", + "url": "http://sbsi2017.dcc.ufla.br/" + }, + { + "id": 3, + "nome": "XXXVII Congresso da Sociedade Brasileira de Computação", + "sigla": "CSBC", + "inicio": "2017-07-02", + "termino": "2017-07-06", + "local": "Universidade Presbiteriana Mackenzie", + "cidade": "São Paulo", + "estado": "SP", + "url": "http://csbc2017.mackenzie.br/" + } +] \ No newline at end of file diff --git a/src/assets/images/angular.png b/src/assets/images/angular.png new file mode 100644 index 0000000..a1d9790 Binary files /dev/null and b/src/assets/images/angular.png differ diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..b7f639a --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,8 @@ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `.angular-cli.json`. + +export const environment = { + production: false +}; diff --git a/src/favicon.ico b/src/favicon.ico new file mode 100644 index 0000000..8081c7c Binary files /dev/null and b/src/favicon.ico differ diff --git a/src/index-jit.html b/src/index-jit.html new file mode 100644 index 0000000..d83bb5d --- /dev/null +++ b/src/index-jit.html @@ -0,0 +1,20 @@ + + + + + + Sistema Eventos + + + + + + + + + + + Aguarde, carregando... + + + \ No newline at end of file diff --git a/src/main-aot.ts b/src/main-aot.ts new file mode 100644 index 0000000..ba0ee66 --- /dev/null +++ b/src/main-aot.ts @@ -0,0 +1,4 @@ +import { platformBrowser } from '@angular/platform-browser'; +import { AppModuleNgFactory } from '../aot/src/app/app.module.ngfactory'; + +platformBrowser().bootstrapModuleFactory(AppModuleNgFactory); diff --git a/src/main-jit.ts b/src/main-jit.ts new file mode 100644 index 0000000..f43008b --- /dev/null +++ b/src/main-jit.ts @@ -0,0 +1,10 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { enableProdMode } from '@angular/core'; +import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/src/polyfills.ts b/src/polyfills.ts index da6be00..53bdaf1 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -1,11 +1,68 @@ -import 'core-js/es6'; +/** + * This file includes polyfills needed by Angular and is loaded before the app. + * You can add your own extra polyfills to this file. + * + * This file is divided into 2 sections: + * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. + * 2. Application imports. Files imported after ZoneJS that should be loaded before your main + * file. + * + * The current setup is for so-called "evergreen" browsers; the last versions of browsers that + * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), + * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. + * + * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html + */ + +/*************************************************************************************************** + * BROWSER POLYFILLS + */ + +/** IE9, IE10 and IE11 requires all of the following polyfills. **/ +// import 'core-js/es6/symbol'; +// import 'core-js/es6/object'; +// import 'core-js/es6/function'; +// import 'core-js/es6/parse-int'; +// import 'core-js/es6/parse-float'; +// import 'core-js/es6/number'; +// import 'core-js/es6/math'; +// import 'core-js/es6/string'; +// import 'core-js/es6/date'; +// import 'core-js/es6/array'; +// import 'core-js/es6/regexp'; +// import 'core-js/es6/map'; +// import 'core-js/es6/set'; + +/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +// import 'classlist.js'; // Run `npm install --save classlist.js`. + +/** IE10 and IE11 requires the following to support `@angular/animation`. */ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + +/** Evergreen browsers require these. **/ +import 'core-js/es6/reflect'; import 'core-js/es7/reflect'; -require('zone.js/dist/zone'); - -if (process.env.ENV === 'production') { - // Production -} else { - // Development and test - Error['stackTraceLimit'] = Infinity; - require('zone.js/dist/long-stack-trace-zone'); -} + + +/** ALL Firefox browsers require the following to support `@angular/animation`. **/ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + + +/*************************************************************************************************** + * Zone JS is required by Angular itself. + */ +import 'zone.js/dist/zone'; // Included with Angular CLI. + + + +/*************************************************************************************************** + * APPLICATION IMPORTS + */ + +/** + * Date, currency, decimal and percent pipes. + * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 + */ +// import 'intl'; // Run `npm install --save intl`. diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..a7e9944 --- /dev/null +++ b/src/styles.css @@ -0,0 +1,5 @@ +/* You can add global styles to this file, and also import other style files */ +.navbar { + margin-top: 30px; + margin-bottom: 30px; +} \ No newline at end of file diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 0000000..9bf7226 --- /dev/null +++ b/src/test.ts @@ -0,0 +1,32 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/long-stack-trace-zone'; +import 'zone.js/dist/proxy.js'; +import 'zone.js/dist/sync-test'; +import 'zone.js/dist/jasmine-patch'; +import 'zone.js/dist/async-test'; +import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. +declare var __karma__: any; +declare var require: any; + +// Prevent Karma from running prematurely. +__karma__.loaded = function () {}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json new file mode 100644 index 0000000..53d5570 --- /dev/null +++ b/src/tsconfig.app.json @@ -0,0 +1,14 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "module": "es2015", + "baseUrl": "", + "types": [] + }, + "exclude": [ + "test.ts", + "**/*.spec.ts", + "*-aot.ts" + ] +} diff --git a/src/tsconfig.spec.json b/src/tsconfig.spec.json new file mode 100644 index 0000000..510e3f1 --- /dev/null +++ b/src/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/spec", + "module": "commonjs", + "target": "es5", + "baseUrl": "", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/src/typings.d.ts b/src/typings.d.ts new file mode 100644 index 0000000..ef5c7bd --- /dev/null +++ b/src/typings.d.ts @@ -0,0 +1,5 @@ +/* SystemJS module definition */ +declare var module: NodeModule; +interface NodeModule { + id: string; +}