(front) Another way to get toSort boolean at Service

This commit is contained in:
2023-01-30 01:24:07 +01:00
parent 9f4ef952b3
commit 29350c36cd
4 changed files with 23 additions and 6 deletions

View File

@@ -2,7 +2,8 @@
<h1>{{albumName}}</h1>
<div *ngIf="toSort" class="alert alert-danger">
To sort filter applyed. Songs are filter on location.
To sort filter applyed. Songs are filter on location. <br/>
Album folder: {{album['Location']}}
</div>
<div class="alert alert-warning">

View File

@@ -6,6 +6,7 @@ import { map, catchError } from 'rxjs/operators';
import { Album } from './model/album';
import { ElsService } from './els.service';
import { ActivatedRoute } from '@angular/router';
@Injectable()
export class ElsAlbumService extends ElsService {
@@ -36,8 +37,10 @@ export class ElsAlbumService extends ElsService {
'size': 500
}
constructor(protected http: HttpClient) {
super(http);
constructor(
protected http: HttpClient,
protected route: ActivatedRoute) {
super(http, route);
}
getAlbums(query: any): Observable<Album[]> {

View File

@@ -1,5 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { ElsService } from './els.service';
@@ -12,8 +13,10 @@ import { Song } from './model/song';
})
export class ElsSortService extends ElsService {
constructor(protected http: HttpClient) {
super(http);
constructor(
protected http: HttpClient,
protected route: ActivatedRoute) {
super(http, route);
}
getTime(): Promise<number> {

View File

@@ -9,6 +9,7 @@ import { Album } from './model/album';
import { Artist } from './model/artist';
import { Bucket } from './model/bucket';
import { Suggested } from './model/suggested';
import { ActivatedRoute } from '@angular/router';
@Injectable()
export class ElsService {
@@ -25,7 +26,16 @@ export class ElsService {
protected headers = new HttpHeaders({'Content-Type': 'application/json'});
protected defaultLocation = "/F:/Musique" // TODO Use conf
constructor(protected http: HttpClient) { }
constructor(
protected http: HttpClient,
protected route: ActivatedRoute) { }
fetchToSortParam() {
const toSort = this.route.snapshot.queryParams['backend'] || 'defaultUrl';
console.log('fetchToSortParam return ' + toSort)
return toSort;
// ? Retrieve to sort on Service or on each component and add a parameter for each methods?
}
getTime(): Promise<number> {
return this.http