Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/pangoRing' into feat/PangoR…
Browse files Browse the repository at this point in the history
…ing/Algos
  • Loading branch information
peacepilou committed Apr 15, 2020
2 parents 9b878e2 + ff77da5 commit 85e424f
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<btd-stepper></btd-stepper>
<btd-stepper [activeIndex]="currentAlgoIndex" ></btd-stepper>
<h1>{{battle}}</h1>
<h2>Instructions</h2>
<btd-instructions [myID]="currentAlgo"></btd-instructions>
<h2>Ta solution</h2>
<btd-input-and-solution [myID]="currentAlgo"></btd-input-and-solution>


<btd-output-and-validation [myID]="currentAlgo"></btd-output-and-validation>



<a routerLink="/pango-ring/{{algoList[currentAlgoIndex+1]?.id}}"> Suivant </a>
13 changes: 10 additions & 3 deletions src/app/pages/components/pango-ring/pango-ring.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { AlgoList } from '../../classes/algo-list';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { BattlesService } from '../../services/battles/battles.service';

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

constructor(private route: ActivatedRoute) { }
constructor(private route: ActivatedRoute, public battles: BattlesService) { }

ngOnInit(): void {
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,');
Expand All @@ -24,8 +27,12 @@ export class PangoRingComponent implements OnInit {
this.algoList.push(algo1, algo2, algo3, algo4, algo5);
this.route.paramMap.subscribe((params: ParamMap) => {
// tslint:disable-next-line: radix
this.currentAlgo = this.algoList.find((algo) => (algo.id === parseInt(params.get('id'))));
this.currentAlgoIndex = this.algoList.findIndex((algo) => (algo.id === parseInt(params.get('id'))));
this.currentAlgo = this.algoList[this.currentAlgoIndex];
});

this.battle = this.battles.getBattle();
}


}
2 changes: 1 addition & 1 deletion src/app/pages/components/stepper/stepper.component.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p-steps [model]="items" [(activeIndex)]="activeIndex" [readonly]="false"></p-steps>
<p-steps [model]="steps" [activeIndex]="activeIndex" ></p-steps>
3 changes: 0 additions & 3 deletions src/app/pages/components/stepper/stepper.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ body .ui-steps .ui-steps-item.ui-state-highlight .ui-steps-number {
.ui-steps .ui-steps-item {
width: 20%;
};
body .ui-steps .ui-steps-item .ui-menuitem-link .ui-steps-number {
margin-bottom: 30px;
};
body .ui-steps .ui-steps-item .ui-menuitem-link:focus {
box-shadow: none;
};
Expand Down
62 changes: 19 additions & 43 deletions src/app/pages/components/stepper/stepper.component.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,26 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import {MenuItem, MessageService} from 'primeng/api';
import { Component, OnInit, ViewEncapsulation, Input } from '@angular/core';
import { MenuItem } from 'primeng/api';

@Component({
selector: 'btd-stepper',
templateUrl: './stepper.component.html',
styleUrls: ['./stepper.component.scss'],
encapsulation: ViewEncapsulation.None,
providers: [MessageService],
selector: 'btd-stepper',
templateUrl: './stepper.component.html',
styleUrls: ['./stepper.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class StepperComponent implements OnInit {
@Input() activeIndex = 1;

items: MenuItem[];
activeIndex = 1;
constructor(private messageService: MessageService) {}
steps: MenuItem[];
constructor() { }

ngOnInit() {
this.items = [{
command: (event: any) => {
this.activeIndex = 0;
this.messageService.add({severity: 'info', summary: 'Algo 1', detail: event.item.label});
}
},
{
command: (event: any) => {
this.activeIndex = 1;
this.messageService.add({severity: 'info', summary: 'Algo 2', detail: event.item.label});
}
},
{
command: (event: any) => {
this.activeIndex = 2;
this.messageService.add({severity: 'info', summary: 'Algo 3', detail: event.item.label});
}
},
{
command: (event: any) => {
this.activeIndex = 3;
this.messageService.add({severity: 'info', summary: 'Algo 4', detail: event.item.label});
}
},
{
command: (event: any) => {
this.activeIndex = 4;
this.messageService.add({severity: 'info', summary: 'Algo 5', detail: event.item.label});
}
}
];
}
ngOnInit() {

this.steps = [
{label: 'Algo 1'},
{label: 'Algo 2'},
{label: 'Algo 3'},
{label: 'Algo 4'},
{label: 'Algo 5'},
];
}
}
16 changes: 16 additions & 0 deletions src/app/pages/services/battles/battles.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { BattlesService } from './battles.service';

describe('BattlesService', () => {
let service: BattlesService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(BattlesService);
});

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

@Injectable({
providedIn: 'root'
})
export class BattlesService {

battle = 'Spider battle';

constructor() { }

getBattle(){
return this.battle;
}
}

0 comments on commit 85e424f

Please sign in to comment.