Skip to content

Commit 85e424f

Browse files
committed
Merge remote-tracking branch 'origin/feat/pangoRing' into feat/PangoRing/Algos
2 parents 9b878e2 + ff77da5 commit 85e424f

7 files changed

+67
-51
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
<btd-stepper></btd-stepper>
1+
<btd-stepper [activeIndex]="currentAlgoIndex" ></btd-stepper>
2+
<h1>{{battle}}</h1>
23
<h2>Instructions</h2>
34
<btd-instructions [myID]="currentAlgo"></btd-instructions>
45
<h2>Ta solution</h2>
56
<btd-input-and-solution [myID]="currentAlgo"></btd-input-and-solution>
67

78

89
<btd-output-and-validation [myID]="currentAlgo"></btd-output-and-validation>
10+
11+
12+
13+
<a routerLink="/pango-ring/{{algoList[currentAlgoIndex+1]?.id}}"> Suivant </a>

src/app/pages/components/pango-ring/pango-ring.component.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { AlgoList } from '../../classes/algo-list';
33
import { ActivatedRoute, ParamMap } from '@angular/router';
4+
import { BattlesService } from '../../services/battles/battles.service';
45

56
@Component({
67
selector: 'btd-pango-ring',
@@ -10,9 +11,11 @@ import { ActivatedRoute, ParamMap } from '@angular/router';
1011
export class PangoRingComponent implements OnInit {
1112
// Ce tableau contiendra 5 objets. Chaque objet contiendra : un ID, instructions, input-solution, output-validation.
1213
algoList: AlgoList[] = [];
13-
public currentAlgo: any;
14+
battle: string;
15+
currentAlgo: any;
16+
currentAlgoIndex: number;
1417

15-
constructor(private route: ActivatedRoute) { }
18+
constructor(private route: ActivatedRoute, public battles: BattlesService) { }
1619

1720
ngOnInit(): void {
1821
const algo1 = new AlgoList (1, 'tu dois rentrer un algorithme simple', 'tu dois ranger ce tableau dans l\'ordre décroissant: [1, 2, 3]', '[3, 2,');
@@ -24,8 +27,12 @@ export class PangoRingComponent implements OnInit {
2427
this.algoList.push(algo1, algo2, algo3, algo4, algo5);
2528
this.route.paramMap.subscribe((params: ParamMap) => {
2629
// tslint:disable-next-line: radix
27-
this.currentAlgo = this.algoList.find((algo) => (algo.id === parseInt(params.get('id'))));
30+
this.currentAlgoIndex = this.algoList.findIndex((algo) => (algo.id === parseInt(params.get('id'))));
31+
this.currentAlgo = this.algoList[this.currentAlgoIndex];
2832
});
33+
34+
this.battle = this.battles.getBattle();
2935
}
3036

37+
3138
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<p-steps [model]="items" [(activeIndex)]="activeIndex" [readonly]="false"></p-steps>
1+
<p-steps [model]="steps" [activeIndex]="activeIndex" ></p-steps>

src/app/pages/components/stepper/stepper.component.scss

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ body .ui-steps .ui-steps-item.ui-state-highlight .ui-steps-number {
44
.ui-steps .ui-steps-item {
55
width: 20%;
66
};
7-
body .ui-steps .ui-steps-item .ui-menuitem-link .ui-steps-number {
8-
margin-bottom: 30px;
9-
};
107
body .ui-steps .ui-steps-item .ui-menuitem-link:focus {
118
box-shadow: none;
129
};
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,26 @@
1-
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2-
import {MenuItem, MessageService} from 'primeng/api';
1+
import { Component, OnInit, ViewEncapsulation, Input } from '@angular/core';
2+
import { MenuItem } from 'primeng/api';
33

44
@Component({
5-
selector: 'btd-stepper',
6-
templateUrl: './stepper.component.html',
7-
styleUrls: ['./stepper.component.scss'],
8-
encapsulation: ViewEncapsulation.None,
9-
providers: [MessageService],
5+
selector: 'btd-stepper',
6+
templateUrl: './stepper.component.html',
7+
styleUrls: ['./stepper.component.scss'],
8+
encapsulation: ViewEncapsulation.None
109
})
1110
export class StepperComponent implements OnInit {
11+
@Input() activeIndex = 1;
1212

13-
items: MenuItem[];
14-
activeIndex = 1;
15-
constructor(private messageService: MessageService) {}
13+
steps: MenuItem[];
14+
constructor() { }
1615

17-
ngOnInit() {
18-
this.items = [{
19-
command: (event: any) => {
20-
this.activeIndex = 0;
21-
this.messageService.add({severity: 'info', summary: 'Algo 1', detail: event.item.label});
22-
}
23-
},
24-
{
25-
command: (event: any) => {
26-
this.activeIndex = 1;
27-
this.messageService.add({severity: 'info', summary: 'Algo 2', detail: event.item.label});
28-
}
29-
},
30-
{
31-
command: (event: any) => {
32-
this.activeIndex = 2;
33-
this.messageService.add({severity: 'info', summary: 'Algo 3', detail: event.item.label});
34-
}
35-
},
36-
{
37-
command: (event: any) => {
38-
this.activeIndex = 3;
39-
this.messageService.add({severity: 'info', summary: 'Algo 4', detail: event.item.label});
40-
}
41-
},
42-
{
43-
command: (event: any) => {
44-
this.activeIndex = 4;
45-
this.messageService.add({severity: 'info', summary: 'Algo 5', detail: event.item.label});
46-
}
47-
}
48-
];
49-
}
16+
ngOnInit() {
17+
18+
this.steps = [
19+
{label: 'Algo 1'},
20+
{label: 'Algo 2'},
21+
{label: 'Algo 3'},
22+
{label: 'Algo 4'},
23+
{label: 'Algo 5'},
24+
];
25+
}
5026
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { BattlesService } from './battles.service';
4+
5+
describe('BattlesService', () => {
6+
let service: BattlesService;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({});
10+
service = TestBed.inject(BattlesService);
11+
});
12+
13+
it('should be created', () => {
14+
expect(service).toBeTruthy();
15+
});
16+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Injectable } from '@angular/core';
2+
3+
@Injectable({
4+
providedIn: 'root'
5+
})
6+
export class BattlesService {
7+
8+
battle = 'Spider battle';
9+
10+
constructor() { }
11+
12+
getBattle(){
13+
return this.battle;
14+
}
15+
}

0 commit comments

Comments
 (0)