Skip to content

Commit

Permalink
Suppression des composants par page (#15)
Browse files Browse the repository at this point in the history
* Suppression des composants par page

* Correction linter

---------

Co-authored-by: Baptiste LYET <[email protected]>
  • Loading branch information
Babali42 and Baptiste LYET authored Mar 2, 2024
1 parent ee54157 commit 97c72d5
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 187 deletions.
17 changes: 0 additions & 17 deletions src/app.route.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ <h2>Sous-genre</h2>
</div>
</div>
<div class="flex content">
<router-outlet></router-outlet>
<sequencer [fileNameBehaviourSubject]="fileNameBehaviourSubject"></sequencer>
</div>
</div>
23 changes: 10 additions & 13 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
import {Subgenre} from './models/subgenre';
import {Genre} from './models/genre';
import {Router} from '@angular/router';
import {BehaviorSubject} from 'rxjs';

@Component({
selector: 'app-root',
Expand Down Expand Up @@ -32,9 +33,10 @@ export class AppComponent implements OnInit {
new Subgenre('Psytrance', '/psytrance'),
])
];

fileNameBehaviourSubject: BehaviorSubject<string>;

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

ngOnInit(): void {
Expand All @@ -44,26 +46,21 @@ export class AppComponent implements OnInit {
.subscribe(result => {
this.isMobileDisplay = !result.matches;
});
this.navigate();
}

selectGenre(i: number) {
this.selectedGenreIndex = i;
this.selectedSubGenreIndex = 0;
this.navigate();
}

private navigate() {
this.router.navigate([this.musicGenres[this.selectedGenreIndex].subGenres[this.selectedSubGenreIndex].link]).then(
() => {
},
() => {
},
);
this.updateFileName();
}

selectSubGenre(i: number) {
this.selectedSubGenreIndex = i;
this.navigate();
this.updateFileName();
}

private updateFileName() {
const fileName = this.musicGenres[this.selectedGenreIndex].subGenres[this.selectedSubGenreIndex].link;
this.fileNameBehaviourSubject.next(fileName);
}
}
24 changes: 3 additions & 21 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,22 @@ import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {TechnoComponent} from './pages/techno/techno.component';
import {MetalComponent} from './pages/metal/metal.component';
import {provideRouter} from '@angular/router';
import {routes} from '../app.route';
import {SequencerComponent} from "./components/sequencer/sequencer.component";
import {HttpClientModule} from "@angular/common/http";
import { TrackComponent } from './components/sequencer/track/track.component';
import { RockComponent } from './pages/rock/rock.component';
import { RockVariationComponent } from './pages/rock-variation/rock-variation.component';
import { HalfTimeGrooveComponent } from './pages/half-time-groove/half-time-groove.component';
import { DrumNBassComponent } from './pages/drum-n-bass/drum-n-bass.component';
import { GarageComponent } from './pages/garage/garage.component';
import { PsytranceComponent } from './pages/psytrance/psytrance.component';
import {SequencerComponent} from './components/sequencer/sequencer.component';
import {HttpClientModule} from '@angular/common/http';
import {TrackComponent} from './components/sequencer/track/track.component';

@NgModule({
declarations: [
AppComponent,
TechnoComponent,
MetalComponent,
SequencerComponent,
TrackComponent,
RockComponent,
RockVariationComponent,
HalfTimeGrooveComponent,
DrumNBassComponent,
GarageComponent,
PsytranceComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule
],
providers: [provideRouter(routes)],
bootstrap: [AppComponent]
})
export class AppModule {
Expand Down
36 changes: 21 additions & 15 deletions src/app/components/sequencer/sequencer.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {Component, Input, OnInit} from '@angular/core';
import {DataService} from "../../services/data.service";
import {Convert, JsonBeat} from "../../models/primary/jsonBeat";
import {SoundService} from "../../services/sound.service";
import {Beat} from "../../models/beat";
import {DataService} from '../../services/data.service';
import {Convert, JsonBeat} from '../../models/primary/jsonBeat';
import {SoundService} from '../../services/sound.service';
import {Beat} from '../../models/beat';
import {BehaviorSubject} from 'rxjs';

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

@Input() fileName: string = "";
beat: Beat = new Beat("", 120, []);
@Input() fileNameBehaviourSubject: BehaviorSubject<string>
beat: Beat = new Beat('', 120, []);

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

ngOnInit(): void {
this.dataService.getData(this.fileName).subscribe((result: JsonBeat) => {
this.beat = Convert.toBeat(result);
if(this.soundService.isPlaying)
this.soundService.pause();
this.soundService.reset();
this.soundService.setBpm(this.beat.bpm);
this.soundService.setTracks(this.beat.tracks);
this.fileNameBehaviourSubject.subscribe(fileName => {
this.dataService.getData(fileName).subscribe((result: JsonBeat) => {
this.beat = Convert.toBeat(result);
if (this.soundService.isPlaying)
this.soundService.pause();
this.soundService.reset();
this.soundService.setBpm(this.beat.bpm);
this.soundService.setTracks(this.beat.tracks);
});
});
}

toggleIsPlaying(): void {
this.soundService.playPause().then(
() => {},
() => {}
() => {
},
() => {
}
);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/app/pages/drum-n-bass/drum-n-bass.component.html

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/drum-n-bass/drum-n-bass.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/pages/garage/garage.component.html

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/garage/garage.component.ts

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/half-time-groove/half-time-groove.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/pages/metal/metal.component.html

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/metal/metal.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/pages/psytrance/psytrance.component.html

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/psytrance/psytrance.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/pages/rock-variation/rock-variation.component.html

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/rock-variation/rock-variation.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/pages/rock/rock.component.html

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/rock/rock.component.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/pages/techno/techno.component.html

This file was deleted.

14 changes: 0 additions & 14 deletions src/app/pages/techno/techno.component.ts

This file was deleted.

0 comments on commit 97c72d5

Please sign in to comment.