Improve lock system + syle

Try to add a loadAll button without success...
This commit is contained in:
2017-05-07 17:48:05 +02:00
parent 11348abb81
commit 29841820e6
3 changed files with 16 additions and 11 deletions

View File

@@ -98,11 +98,11 @@
<tbody> <tbody>
<tr *ngFor="let song of songs | sortBy : 'Album':'Track Number'"> <tr *ngFor="let song of songs | sortBy : 'Album':'Track Number'">
<td>{{song['Track Number'] ? (("0" + song['Track Number']).slice(-2)) : "--"}}</td> <td>{{song['Track Number'] ? (("0" + song['Track Number']).slice(-2)) : "--"}}</td>
<td [title]="song.Name">{{song.Name}}</td> <td>{{song.Name}}</td>
<td [title]="song.Artist"><a [routerLink]="['/artist', song.Artist]">{{song.Artist}}</a></td> <td><a [routerLink]="['/artist', song.Artist]">{{song.Artist}}</a></td>
<td [title]="song.Album"><a [routerLink]="['/album', song.Album]">{{song.Album}}</a></td> <td><a [routerLink]="['/album', song.Album]">{{song.Album}}</a></td>
<td [title]="song.Album">{{song['Album Artist'] ? song['Album Artist'] : "-" }}</td> <td>{{song['Album Artist'] ? song['Album Artist'] : "-" }}</td>
<td [title]="song['Play Count']">{{song['Play Count']}}</td> <td>{{song['Play Count']}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -113,11 +113,11 @@
<!-- Go to Top Button--> <!-- Go to Top Button-->
<button type="button" class="btn btn-warning btn-top" [class.btn-top-is-visible]="atBottom" <button type="button" class="btn btn-warning btn-top" [class.btn-top-is-visible]="atBottom"
aria-label="Top" (click)="scrollTop()"> aria-label="Top" (click)="scrollTop()" title="Go back to Top!">
<span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span> <span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span>
</button> </button>
<button type="button" class="btn btn-primary btn-top btn-sort" [class.btn-top-is-visible]="sortable" <button type="button" class="btn btn-primary btn-top btn-sort" [class.btn-top-is-visible]="sortable"
aria-label="Top" (click)="sort()"> aria-label="Top" (click)="sort()" title="Sort by Album & Track Number">
<span class="glyphicon glyphicon-sort-by-attributes" aria-hidden="true"></span> <span class="glyphicon glyphicon-sort-by-attributes" aria-hidden="true"></span>
</button> </button>
</div> </div>

View File

@@ -29,7 +29,7 @@ export class ArtistComponent implements OnInit {
atBottom: boolean = false; atBottom: boolean = false;
sortable: boolean = false; sortable: boolean = false;
lockLoadData: boolean = true; lockLoadData: boolean = false;
ngOnInit(): void { ngOnInit(): void {
this.route.params this.route.params
@@ -42,6 +42,12 @@ export class ArtistComponent implements OnInit {
// TODO Duplicate code! // TODO Duplicate code!
loadSongs(): void { loadSongs(): void {
if (this.lockLoadData) {
console.debug("Loading data locked");
return;
}
this.lockLoadData = true;
this.elsService.getArtistSongs(this.artistName, this.songs.length).subscribe( this.elsService.getArtistSongs(this.artistName, this.songs.length).subscribe(
data => { data => {
this.moreDataAvailable = data.length == ElsService.DEFAULT_SIZE; this.moreDataAvailable = data.length == ElsService.DEFAULT_SIZE;
@@ -56,6 +62,7 @@ export class ArtistComponent implements OnInit {
this.songs.push(song); this.songs.push(song);
}); });
} }
console.debug("Unlock load data");
this.lockLoadData = false; this.lockLoadData = false;
} }
); );
@@ -73,9 +80,8 @@ export class ArtistComponent implements OnInit {
* @param event scroll event * @param event scroll event
*/ */
onScroll(event: any) { onScroll(event: any) {
if (this.moreDataAvailable && !this.lockLoadData && if (this.moreDataAvailable &&
(window.innerHeight + window.scrollY) >= document.body.offsetHeight) { (window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
this.lockLoadData = true;
this.loadSongs(); this.loadSongs();
} }

View File

@@ -173,7 +173,6 @@ export class ElsService {
.map((hits: Array<any>) => { .map((hits: Array<any>) => {
// Theorically, my script prevent to found two documents with this query. // Theorically, my script prevent to found two documents with this query.
// But Prevention is better than cure as Shakespeare said // But Prevention is better than cure as Shakespeare said
console.log(hits.length);
if (hits.length < 1) { if (hits.length < 1) {
console.info('No artist "' + artistName + '" found.'); console.info('No artist "' + artistName + '" found.');
return undefined; return undefined;