Skip to content

Commit

Permalink
Merge branch 'main' into abakar
Browse files Browse the repository at this point in the history
  • Loading branch information
qippa committed May 5, 2022
2 parents 7fcd091 + de18a61 commit 0e92c26
Show file tree
Hide file tree
Showing 13 changed files with 15,954 additions and 5 deletions.
15,802 changes: 15,802 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.2.9",
"@angular/cli": "~12.2.9",
"@angular/cli": "^12.2.17",
"@angular/compiler-cli": "~12.2.0",
"@types/jasmine": "~3.8.0",
"@types/node": "^12.11.1",
Expand Down
9 changes: 8 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CapsuleComponent } from './component/capsule/capsule.component';
import { ListCapsuleComponent } from './component/list-capsule/list-capsule.component';

const routes: Routes = [];
const routes: Routes = [
{ path: '', pathMatch: 'full', component: ListCapsuleComponent },
{ path: 'capsules', component: ListCapsuleComponent},
{ path: 'capsule/:id', component: CapsuleComponent},
{ path: '**', redirectTo: ''}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
8 changes: 7 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LaunchDetailComponent } from './components/launch-detail/alunch-detail.component';
import { LunchProgramsComponent } from './components/launch-programs/launch-programs.component';
import { ListCapsuleComponent } from './components/list-capsule/list-capsule.component';
import { CapsuleComponent } from './components/capsule/capsule.component';

@NgModule({
declarations: [
AppComponent,
LaunchDetailComponent,LunchProgramsComponent
LaunchDetailComponent,
LunchProgramsComponent,
ListCapsuleComponent,
CapsuleComponent
],
imports: [
AppRoutingModule,
BrowserModule,
AppRoutingModule,
HttpClientModule
Expand Down
Empty file.
1 change: 1 addition & 0 deletions src/app/components/capsule/capsule.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p *ngIf="capsule">capsule: {{capsule.capsule_serial}}</p>
25 changes: 25 additions & 0 deletions src/app/components/capsule/capsule.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CapsuleComponent } from './capsule.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
30 changes: 30 additions & 0 deletions src/app/components/capsule/capsule.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { CapsulesService } from 'src/app/services/capsules.service';

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

constructor(
private capsuleService: CapsulesService,
private route: ActivatedRoute
) { }

ngOnInit(): void {
const id = this.route.snapshot.paramMap.get('id');

if(id != null) {
this.capsuleService.getOneCapsule(id).toPromise().then(capsule => {
this.capsule = capsule;
})
} else {
console.log("error: capsule serial null")
}
}

}
4 changes: 4 additions & 0 deletions src/app/components/list-capsule/list-capsule.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tbody tr:hover {
cursor: pointer;
background-color: rgb(184, 181, 167);
}
19 changes: 19 additions & 0 deletions src/app/components/list-capsule/list-capsule.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1>Liste des Capsules</h1>

<table class="table">
<thead>
<tr>
<th>id</th>
<th>Launch Date</th>
<th>status</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let capsule of listCapsules" (click)="redirectToCapsule(capsule.capsule_serial)">
<td>{{ capsule.capsule_serial }}</td>
<td>{{ capsule.original_launch | date: 'dd LLL y H\'h\'mm' }}</td>
<td>{{ capsule.status }}</td>
</tr>
</tbody>
</table>

25 changes: 25 additions & 0 deletions src/app/components/list-capsule/list-capsule.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ListCapsuleComponent } from './list-capsule.component';

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

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

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

it('should create', () => {
expect(component).toBeTruthy();
});
});
29 changes: 29 additions & 0 deletions src/app/components/list-capsule/list-capsule.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { CapsulesService } from 'src/app/services/capsules.service';

@Component({
selector: 'app-list-capsule',
templateUrl: './list-capsule.component.html',
styleUrls: ['./list-capsule.component.css']
})
export class ListCapsuleComponent implements OnInit {
listCapsules: any;

constructor(
private capsulesService: CapsulesService,
private router: Router
) { }

ngOnInit(): void {
this.capsulesService.getCapsules().subscribe(capsules => {
this.listCapsules = capsules;
console.log(capsules);
})
}

redirectToCapsule(id: String): void {
this.router.navigate(["capsule/" + id]);
}

}
5 changes: 3 additions & 2 deletions src/app/services/capsules.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export class CapsulesService {
constructor(private http: HttpClient) { }

public getCapsules():Observable<any> {
return this.http.get<any>(CAPSULES_API, httpOptions);
const test = this.http.get<any>(CAPSULES_API, httpOptions);
return test;
}

public getOneCapsule(capsule_serial:number):Observable<any> {
public getOneCapsule(capsule_serial:String):Observable<any> {
return this.http.get<any>(CAPSULES_API+'/'+capsule_serial, httpOptions);
}

Expand Down

0 comments on commit 0e92c26

Please sign in to comment.