Skip to content

Commit 97c72d5

Browse files
Babali42Baptiste LYET
and
Baptiste LYET
authored
Suppression des composants par page (#15)
* Suppression des composants par page * Correction linter --------- Co-authored-by: Baptiste LYET <[email protected]>
1 parent ee54157 commit 97c72d5

21 files changed

+35
-187
lines changed

src/app.route.ts

-17
This file was deleted.

src/app/app.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ <h2>Sous-genre</h2>
2525
</div>
2626
</div>
2727
<div class="flex content">
28-
<router-outlet></router-outlet>
28+
<sequencer [fileNameBehaviourSubject]="fileNameBehaviourSubject"></sequencer>
2929
</div>
3030
</div>

src/app/app.component.ts

+10-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
33
import {Subgenre} from './models/subgenre';
44
import {Genre} from './models/genre';
55
import {Router} from '@angular/router';
6+
import {BehaviorSubject} from 'rxjs';
67

78
@Component({
89
selector: 'app-root',
@@ -32,9 +33,10 @@ export class AppComponent implements OnInit {
3233
new Subgenre('Psytrance', '/psytrance'),
3334
])
3435
];
35-
36+
fileNameBehaviourSubject: BehaviorSubject<string>;
3637

3738
constructor(private responsive: BreakpointObserver, private router: Router) {
39+
this.fileNameBehaviourSubject = new BehaviorSubject<string>("metal");
3840
}
3941

4042
ngOnInit(): void {
@@ -44,26 +46,21 @@ export class AppComponent implements OnInit {
4446
.subscribe(result => {
4547
this.isMobileDisplay = !result.matches;
4648
});
47-
this.navigate();
4849
}
4950

5051
selectGenre(i: number) {
5152
this.selectedGenreIndex = i;
5253
this.selectedSubGenreIndex = 0;
53-
this.navigate();
54-
}
55-
56-
private navigate() {
57-
this.router.navigate([this.musicGenres[this.selectedGenreIndex].subGenres[this.selectedSubGenreIndex].link]).then(
58-
() => {
59-
},
60-
() => {
61-
},
62-
);
54+
this.updateFileName();
6355
}
6456

6557
selectSubGenre(i: number) {
6658
this.selectedSubGenreIndex = i;
67-
this.navigate();
59+
this.updateFileName();
60+
}
61+
62+
private updateFileName() {
63+
const fileName = this.musicGenres[this.selectedGenreIndex].subGenres[this.selectedSubGenreIndex].link;
64+
this.fileNameBehaviourSubject.next(fileName);
6865
}
6966
}

src/app/app.module.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,22 @@ import {NgModule} from '@angular/core';
22
import {BrowserModule} from '@angular/platform-browser';
33
import {AppRoutingModule} from './app-routing.module';
44
import {AppComponent} from './app.component';
5-
import {TechnoComponent} from './pages/techno/techno.component';
6-
import {MetalComponent} from './pages/metal/metal.component';
75
import {provideRouter} from '@angular/router';
8-
import {routes} from '../app.route';
9-
import {SequencerComponent} from "./components/sequencer/sequencer.component";
10-
import {HttpClientModule} from "@angular/common/http";
11-
import { TrackComponent } from './components/sequencer/track/track.component';
12-
import { RockComponent } from './pages/rock/rock.component';
13-
import { RockVariationComponent } from './pages/rock-variation/rock-variation.component';
14-
import { HalfTimeGrooveComponent } from './pages/half-time-groove/half-time-groove.component';
15-
import { DrumNBassComponent } from './pages/drum-n-bass/drum-n-bass.component';
16-
import { GarageComponent } from './pages/garage/garage.component';
17-
import { PsytranceComponent } from './pages/psytrance/psytrance.component';
6+
import {SequencerComponent} from './components/sequencer/sequencer.component';
7+
import {HttpClientModule} from '@angular/common/http';
8+
import {TrackComponent} from './components/sequencer/track/track.component';
189

1910
@NgModule({
2011
declarations: [
2112
AppComponent,
22-
TechnoComponent,
23-
MetalComponent,
2413
SequencerComponent,
2514
TrackComponent,
26-
RockComponent,
27-
RockVariationComponent,
28-
HalfTimeGrooveComponent,
29-
DrumNBassComponent,
30-
GarageComponent,
31-
PsytranceComponent
3215
],
3316
imports: [
3417
BrowserModule,
3518
AppRoutingModule,
3619
HttpClientModule
3720
],
38-
providers: [provideRouter(routes)],
3921
bootstrap: [AppComponent]
4022
})
4123
export class AppModule {

src/app/components/sequencer/sequencer.component.ts

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {Component, Input, OnInit} from '@angular/core';
2-
import {DataService} from "../../services/data.service";
3-
import {Convert, JsonBeat} from "../../models/primary/jsonBeat";
4-
import {SoundService} from "../../services/sound.service";
5-
import {Beat} from "../../models/beat";
2+
import {DataService} from '../../services/data.service';
3+
import {Convert, JsonBeat} from '../../models/primary/jsonBeat';
4+
import {SoundService} from '../../services/sound.service';
5+
import {Beat} from '../../models/beat';
6+
import {BehaviorSubject} from 'rxjs';
67

78
@Component({
89
selector: 'sequencer',
@@ -11,27 +12,32 @@ import {Beat} from "../../models/beat";
1112
})
1213
export class SequencerComponent implements OnInit {
1314

14-
@Input() fileName: string = "";
15-
beat: Beat = new Beat("", 120, []);
15+
@Input() fileNameBehaviourSubject: BehaviorSubject<string>
16+
beat: Beat = new Beat('', 120, []);
1617

1718
constructor(private dataService: DataService, public soundService: SoundService) {
19+
this.fileNameBehaviourSubject = new BehaviorSubject<string>("metal");
1820
}
1921

2022
ngOnInit(): void {
21-
this.dataService.getData(this.fileName).subscribe((result: JsonBeat) => {
22-
this.beat = Convert.toBeat(result);
23-
if(this.soundService.isPlaying)
24-
this.soundService.pause();
25-
this.soundService.reset();
26-
this.soundService.setBpm(this.beat.bpm);
27-
this.soundService.setTracks(this.beat.tracks);
23+
this.fileNameBehaviourSubject.subscribe(fileName => {
24+
this.dataService.getData(fileName).subscribe((result: JsonBeat) => {
25+
this.beat = Convert.toBeat(result);
26+
if (this.soundService.isPlaying)
27+
this.soundService.pause();
28+
this.soundService.reset();
29+
this.soundService.setBpm(this.beat.bpm);
30+
this.soundService.setTracks(this.beat.tracks);
31+
});
2832
});
2933
}
3034

3135
toggleIsPlaying(): void {
3236
this.soundService.playPause().then(
33-
() => {},
34-
() => {}
37+
() => {
38+
},
39+
() => {
40+
}
3541
);
3642
}
3743
}

src/app/pages/drum-n-bass/drum-n-bass.component.html

-1
This file was deleted.

src/app/pages/drum-n-bass/drum-n-bass.component.ts

-14
This file was deleted.

src/app/pages/garage/garage.component.html

-1
This file was deleted.

src/app/pages/garage/garage.component.ts

-14
This file was deleted.

src/app/pages/half-time-groove/half-time-groove.component.html

-1
This file was deleted.

src/app/pages/half-time-groove/half-time-groove.component.ts

-14
This file was deleted.

src/app/pages/metal/metal.component.html

-1
This file was deleted.

src/app/pages/metal/metal.component.ts

-14
This file was deleted.

src/app/pages/psytrance/psytrance.component.html

-1
This file was deleted.

src/app/pages/psytrance/psytrance.component.ts

-14
This file was deleted.

src/app/pages/rock-variation/rock-variation.component.html

-1
This file was deleted.

src/app/pages/rock-variation/rock-variation.component.ts

-14
This file was deleted.

src/app/pages/rock/rock.component.html

-1
This file was deleted.

src/app/pages/rock/rock.component.ts

-14
This file was deleted.

src/app/pages/techno/techno.component.html

-1
This file was deleted.

src/app/pages/techno/techno.component.ts

-14
This file was deleted.

0 commit comments

Comments
 (0)