File ClientApp/src/app/app.module.ts changed (mode: 100644) (index c3cfbf9..fc7d73c) |
... |
... |
import { CounterComponent } from './counter/counter.component'; |
15 |
15 |
import { FetchDataComponent } from './fetch-data/fetch-data.component';
|
import { FetchDataComponent } from './fetch-data/fetch-data.component';
|
16 |
16 |
import { VehiculeFormComponent } from './vehicule-form/vehicule-form.component';
|
import { VehiculeFormComponent } from './vehicule-form/vehicule-form.component';
|
17 |
17 |
import { AppErrorHandler } from './app.error-handler';
|
import { AppErrorHandler } from './app.error-handler';
|
|
18 |
|
import { VehicleListComponent } from './vehicle-list/vehicle-list.component';
|
18 |
19 |
|
|
19 |
20 |
@NgModule({
|
@NgModule({
|
20 |
21 |
declarations: [
|
declarations: [
|
|
... |
... |
import { AppErrorHandler } from './app.error-handler'; |
23 |
24 |
HomeComponent,
|
HomeComponent,
|
24 |
25 |
CounterComponent,
|
CounterComponent,
|
25 |
26 |
FetchDataComponent,
|
FetchDataComponent,
|
26 |
|
VehiculeFormComponent
|
|
|
27 |
|
VehiculeFormComponent,
|
|
28 |
|
VehicleListComponent
|
27 |
29 |
],
|
],
|
28 |
30 |
imports: [
|
imports: [
|
29 |
31 |
BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
|
BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
|
|
... |
... |
import { AppErrorHandler } from './app.error-handler'; |
32 |
34 |
FormsModule,
|
FormsModule,
|
33 |
35 |
ToastaModule.forRoot(),
|
ToastaModule.forRoot(),
|
34 |
36 |
RouterModule.forRoot([
|
RouterModule.forRoot([
|
35 |
|
{ path: '', component: HomeComponent, pathMatch: 'full' },
|
|
|
37 |
|
{ path: '', redirectTo: 'vehicles', pathMatch: 'full' },
|
36 |
38 |
{ path: 'counter', component: CounterComponent },
|
{ path: 'counter', component: CounterComponent },
|
37 |
39 |
{ path: 'fetch-data', component: FetchDataComponent },
|
{ path: 'fetch-data', component: FetchDataComponent },
|
38 |
40 |
{ path: 'vehicles/new', component: VehiculeFormComponent },
|
{ path: 'vehicles/new', component: VehiculeFormComponent },
|
39 |
41 |
{ path: 'vehicles/:id', component: VehiculeFormComponent },
|
{ path: 'vehicles/:id', component: VehiculeFormComponent },
|
|
42 |
|
{ path: 'vehicles', component: VehicleListComponent },
|
40 |
43 |
])
|
])
|
41 |
44 |
],
|
],
|
42 |
45 |
providers: [
|
providers: [
|
File ClientApp/src/app/services/vehicle.service.ts changed (mode: 100644) (index eeeb9eb..a563e6c) |
... |
... |
import { SaveVehicle } from '../models/vehicle'; |
5 |
5 |
|
|
6 |
6 |
@Injectable() |
@Injectable() |
7 |
7 |
export class VehicleService { |
export class VehicleService { |
8 |
|
|
|
9 |
8 |
constructor(private http: Http) { } |
constructor(private http: Http) { } |
10 |
9 |
|
|
11 |
10 |
getMakes(){ |
getMakes(){ |
|
... |
... |
export class VehicleService { |
37 |
36 |
return this.http.delete('api/vehicles/' + id) |
return this.http.delete('api/vehicles/' + id) |
38 |
37 |
.pipe(map((res: any) => res.json())); |
.pipe(map((res: any) => res.json())); |
39 |
38 |
} |
} |
|
39 |
|
|
|
40 |
|
getVehicles() { |
|
41 |
|
return this.http.get('/api/vehicles') |
|
42 |
|
.pipe(map((res: any) => res.json)); |
|
43 |
|
} |
40 |
44 |
} |
} |
File ClientApp/src/app/vehicle-list/vehicle-list.component.spec.ts copied from file ClientApp/src/app/vehicule-form/vehicule-form.component.spec.ts (similarity 53%) (mode: 100644) (index 8357f33..74a1ee7) |
1 |
1 |
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
2 |
2 |
|
|
3 |
|
import { VehiculeFormComponent } from './vehicule-form.component'; |
|
|
3 |
|
import { VehicleListComponent } from './vehicle-list.component'; |
4 |
4 |
|
|
5 |
|
describe('VehiculeFormComponent', () => { |
|
6 |
|
let component: VehiculeFormComponent; |
|
7 |
|
let fixture: ComponentFixture<VehiculeFormComponent>; |
|
|
5 |
|
describe('VehicleListComponent', () => { |
|
6 |
|
let component: VehicleListComponent; |
|
7 |
|
let fixture: ComponentFixture<VehicleListComponent>; |
8 |
8 |
|
|
9 |
9 |
beforeEach(async(() => { |
beforeEach(async(() => { |
10 |
10 |
TestBed.configureTestingModule({ |
TestBed.configureTestingModule({ |
11 |
|
declarations: [ VehiculeFormComponent ] |
|
|
11 |
|
declarations: [ VehicleListComponent ] |
12 |
12 |
}) |
}) |
13 |
13 |
.compileComponents(); |
.compileComponents(); |
14 |
14 |
})); |
})); |
15 |
15 |
|
|
16 |
16 |
beforeEach(() => { |
beforeEach(() => { |
17 |
|
fixture = TestBed.createComponent(VehiculeFormComponent); |
|
|
17 |
|
fixture = TestBed.createComponent(VehicleListComponent); |
18 |
18 |
component = fixture.componentInstance; |
component = fixture.componentInstance; |
19 |
19 |
fixture.detectChanges(); |
fixture.detectChanges(); |
20 |
20 |
}); |
}); |
File ClientApp/src/app/vehicle-list/vehicle-list.component.ts added (mode: 100644) (index 0000000..6a83f06) |
|
1 |
|
import { Component, OnInit } from '@angular/core'; |
|
2 |
|
import { VehicleService } from '../services/vehicle.service'; |
|
3 |
|
import { Vehicle } from '../models/vehicle'; |
|
4 |
|
|
|
5 |
|
@Component({ |
|
6 |
|
selector: 'app-vehicle-list', |
|
7 |
|
templateUrl: './vehicle-list.component.html', |
|
8 |
|
styleUrls: ['./vehicle-list.component.css'] |
|
9 |
|
}) |
|
10 |
|
export class VehicleListComponent implements OnInit { |
|
11 |
|
vehicles: Vehicle[]; |
|
12 |
|
|
|
13 |
|
constructor(private vehicleService: VehicleService,) { } |
|
14 |
|
|
|
15 |
|
ngOnInit() { |
|
16 |
|
this.vehicleService.getVehicles() |
|
17 |
|
.subscribe(vehicles => this.vehicles = vehicles); |
|
18 |
|
} |
|
19 |
|
|
|
20 |
|
} |