Add time for Album + pipe to convert Ms
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row cardAdmin">
|
||||
<div class="col-lg-4 col-md-4">
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-yellow">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4">
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-green">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
@@ -46,7 +46,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4">
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-purple">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
@@ -64,6 +64,24 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3">
|
||||
<div class="panel panel-blue">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-xs-3">
|
||||
<span class="glyphicon glyphicon-time stats_icon"></span>
|
||||
</div>
|
||||
<div class="col-xs-9 text-right">
|
||||
<div>
|
||||
<h3 *ngIf="!album"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="album">{{album['Total Time'] | convertMs}}</h3>
|
||||
</div>
|
||||
<div><br>Album time</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped" (window:scroll)="onScroll($event)">
|
||||
@@ -78,7 +96,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let song of songs | sortBy : 'Artist':'Track Number'">
|
||||
<tr *ngFor="let song of songs | sortBy : 'Track Number'">
|
||||
<td>{{song['Track Number'] ? (("0" + song['Track Number']).slice(-2)) : "--"}}</td>
|
||||
<td [title]="song.Name">{{song.Name}}</td>
|
||||
<td [title]="song.Artist"><a [routerLink]="['/artist', song.Artist]">{{song.Artist}}</a></td>
|
||||
|
||||
@@ -19,7 +19,8 @@ import { ElsService } from './els.service';
|
||||
|
||||
import { AppRoutingModule } from './app-routing.module'
|
||||
|
||||
import { SortPipe } from './sortby.pipe'
|
||||
import { ConvertMsPipe } from './convertms.pipe'
|
||||
import { SortPipe } from './sortby.pipe'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -36,6 +37,7 @@ import { SortPipe } from './sortby.pipe'
|
||||
DashboardComponent,
|
||||
AlbumComponent,
|
||||
ArtistComponent,
|
||||
ConvertMsPipe,
|
||||
SortPipe
|
||||
],
|
||||
providers: [
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<h3 *ngIf="!artist"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="artist">{{artist.Rating}}/100</h3>
|
||||
</div>
|
||||
<div><br>Rating</div>
|
||||
<div>Rating</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -40,7 +40,7 @@
|
||||
<h3 *ngIf="!artist"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="artist">{{artist.Album?.length}}</h3>
|
||||
</div>
|
||||
<div><br>Albums</div>
|
||||
<div>Albums</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,7 +58,7 @@
|
||||
<h3 *ngIf="!artist"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="artist">{{artist['Track Count']}}</h3>
|
||||
</div>
|
||||
<div><br>Songs</div>
|
||||
<div>Songs</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -76,7 +76,8 @@
|
||||
<h3 *ngIf="!artist"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="artist">{{artist['Play Count']}} list.</h3>
|
||||
</div>
|
||||
<div><br>~{{artist['Play Count'] / artist['Track Count'] | number:'1.0-0'}} listening avg.</div>
|
||||
<div *ngIf="artist">~{{artist['Play Count'] / artist['Track Count'] | number:'1.0-0'}} listening avg.</div>
|
||||
<div *ngIf="!artist">Listening</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
</div>
|
||||
<div class="col-xs-9 text-right">
|
||||
<div>
|
||||
<h3 *ngIf="!totalTimeSt"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="totalTimeSt">{{totalTimeSt}}</h3>
|
||||
<h3 *ngIf="!totalTime"><span class="glyphicon glyphicon-refresh loading"></span></h3>
|
||||
<h3 *ngIf="totalTime">{{totalTime | convertMs}}</h3>
|
||||
</div>
|
||||
<div><br>Total time</div>
|
||||
</div>
|
||||
@@ -91,10 +91,10 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let song of mostPlayedSongs">
|
||||
<td [title]="song.Name"><b>{{song.Name}}</b></td>
|
||||
<td [title]="song.Artist"><a [routerLink]="['/artist', song.Artist]">{{song.Artist}}</a></td>
|
||||
<td [title]="song.Album"><a [routerLink]="['/album', song.Album]">{{song.Album}}</a></td>
|
||||
<td [title]="song['Play Count']">{{song['Play Count']}}</td>
|
||||
<td><b>{{song.Name}}</b></td>
|
||||
<td><a [routerLink]="['/artist', song.Artist]">{{song.Artist}}</a></td>
|
||||
<td><a [routerLink]="['/album', song.Album]">{{song.Album}}</a></td>
|
||||
<td>{{song['Play Count']}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Hero } from './hero'
|
||||
import { HeroService } from './hero.service'
|
||||
import { ElsService } from './els.service'
|
||||
import { Song } from './object/song';
|
||||
import { Bucket } from './object/bucket';
|
||||
|
||||
@Component({
|
||||
selector: 'my-dashboard',
|
||||
@@ -12,7 +13,6 @@ import { Song } from './object/song';
|
||||
})
|
||||
|
||||
export class DashboardComponent implements OnInit {
|
||||
totalTimeSt = "";
|
||||
totalTime: number = 0;
|
||||
totalSize: number = 0;
|
||||
totalSizeSt = "";
|
||||
@@ -28,7 +28,6 @@ export class DashboardComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
this.elsService.getTime().then(result => {
|
||||
this.totalTime = result;
|
||||
this.totalTimeSt = this.convertMsToTime(this.totalTime);
|
||||
});
|
||||
|
||||
this.elsService.getSize().then(result => {
|
||||
@@ -56,21 +55,6 @@ export class DashboardComponent implements OnInit {
|
||||
* UTILS FUNCTION - TODO MOVE
|
||||
*/
|
||||
|
||||
convertMsToTime(ms: number): string {
|
||||
let x = ms / 1000
|
||||
let seconds = Math.round(x % 60)
|
||||
x /= 60
|
||||
let minutes = Math.round(x % 60)
|
||||
x /= 60
|
||||
let hours = Math.round(x % 24)
|
||||
// TODO Enable/disable day
|
||||
x /= 24
|
||||
let days = Math.round(x);
|
||||
|
||||
return days + ":" + hours + ":" + minutes + "." + seconds;
|
||||
// return days + " days, " + hours + " hours, " + minutes + " minutes and " + seconds + " seconds";
|
||||
}
|
||||
|
||||
convertSizeToString(size: number) {
|
||||
let units = ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB'];
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export class ElsService {
|
||||
constructor(private http: Http) { }
|
||||
|
||||
getTime(): Promise<number> {
|
||||
return this.http.post(this.elsUrl + ElsService.ACTION_SEARCH, JSON.stringify({aggs:{sum_time:{sum:{field:"Total Time"}}},"size":0}), {headers: this.headers})
|
||||
return this.http.post(this.elsUrl + 'song/' + ElsService.ACTION_SEARCH, JSON.stringify({aggs:{sum_time:{sum:{field:"Total Time"}}},"size":0}), {headers: this.headers})
|
||||
.toPromise()
|
||||
.then(res => res.json().aggregations.sum_time.value as number)
|
||||
.catch(this.handleError);
|
||||
@@ -84,7 +84,7 @@ export class ElsService {
|
||||
"Play Count": {
|
||||
"order": "desc"
|
||||
} } ],
|
||||
"size": 10
|
||||
"size": 5
|
||||
}),
|
||||
{headers: this.headers})
|
||||
.map(res => {
|
||||
@@ -130,18 +130,18 @@ export class ElsService {
|
||||
return this.http
|
||||
.post(this.elsUrl + "song" + ElsService.ACTION_SEARCH,
|
||||
JSON.stringify(
|
||||
{
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"match_phrase" : { "Album Artist" : artistName }},
|
||||
{"match_phrase" : { "Artist" : artistName }}
|
||||
]
|
||||
}
|
||||
},
|
||||
"size": ElsService.DEFAULT_SIZE,
|
||||
"from": from
|
||||
}),
|
||||
{
|
||||
"query": {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"match_phrase" : { "Album Artist" : artistName }},
|
||||
{"match_phrase" : { "Artist" : artistName }}
|
||||
]
|
||||
}
|
||||
},
|
||||
"size": ElsService.DEFAULT_SIZE,
|
||||
"from": from
|
||||
}),
|
||||
{headers: this.headers})
|
||||
.map(res => {
|
||||
return res.json().hits.hits;
|
||||
|
||||
@@ -9,4 +9,5 @@ export class Album {
|
||||
"Persistent ID": string;
|
||||
"Album Rating Computed": boolean;
|
||||
"Play Count": number;
|
||||
"Total Time": number;
|
||||
}
|
||||
@@ -184,7 +184,8 @@ class ITunesParser:
|
||||
'Play Count': 0,
|
||||
'Rating': 0,
|
||||
'Genre': set(),
|
||||
'Artist': set()
|
||||
'Artist': set(),
|
||||
'Total Time': 0
|
||||
}
|
||||
|
||||
# Compute information
|
||||
@@ -193,9 +194,12 @@ class ITunesParser:
|
||||
rating = track['Rating'] if 'Rating' in track else 0
|
||||
rating = self.calc_rating(rating, self._albums[akey]['Rating'], self._albums[akey]['Track Count'])
|
||||
|
||||
total_time = track['Total Time'] if 'Total Time' in track else 0
|
||||
|
||||
self._albums[akey]['Track Count'] += 1
|
||||
self._albums[akey]['Rating'] = rating
|
||||
self._albums[akey]['Play Count'] += play_count
|
||||
self._albums[akey]['Total Time'] += total_time
|
||||
|
||||
if 'Genre' in track:
|
||||
# Split up the Genres
|
||||
|
||||
Reference in New Issue
Block a user