Shouldve committed earlier, lots of changes, main page mostly works now

This commit is contained in:
Patrick Speiser
2012-09-29 12:01:15 +02:00
parent 5e0835bf62
commit 37641ea0ca
3 changed files with 91 additions and 11 deletions
+4
View File
@@ -876,6 +876,10 @@ div#artistheader h2 a {
min-width: 300px; min-width: 300px;
text-align: left; text-align: left;
} }
#artist_table th#albumart{
width:50px;
}
#artist_table th#status, #artist_table th#status,
#artist_table th#albumart, #artist_table th#albumart,
#artist_table th#lastupdated { #artist_table th#lastupdated {
+78 -8
View File
@@ -8,10 +8,10 @@
<thead> <thead>
<tr> <tr>
<th id="albumart"></th> <th id="albumart"></th>
<th id="ArtistSortName">Artist Name</th> <th id="name">Artist Name</th>
<th id="Status">Status</th> <th id="status">Status</th>
<th id="LatestAlbum">Latest Album</th> <th id="album">Latest Album</th>
<th id="HaveTracks">Have</th> <th id="have">Have</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -49,15 +49,79 @@
return '<div id="artistImg"><img class="albumArt" alt="" id="'+ data + '" src="/thumbs/artist/' + data + '"/></div>'; return '<div id="artistImg"><img class="albumArt" alt="" id="'+ data + '" src="/thumbs/artist/' + data + '"/></div>';
} }
}, },
{"aTargets":[1],"mDataProp":"ArtistSortName"}, {
"aTargets":[1],
"mDataProp":"ArtistSortName",
"mRender":function (data,type,full) {
return '<span title="' + full['ArtistID'] + '"></span><a href="artistPage?ArtistID=' + full['ArtistID'] + '">' + data + '</a>'
}
},
{"aTargets":[2],"mDataProp":"Status"}, {"aTargets":[2],"mDataProp":"Status"},
{"aTargets":[3],"mDataProp":"LatestAlbum"}, {
{"aTargets":[4],"mDataProp":"HaveTracks"}, "aTargets":[3],
"mDataProp":"LatestAlbum",
"mRender":function(data,type,full){
artist = full;
if (artist['ReleaseDate'] && artist['LatestAlbum'])
{
releasedate = artist['ReleaseDate'];
albumdisplay = '<i>' + artist['LatestAlbum'] + '</i> (' + artist['ReleaseDate'] + ')';
}
else if(artist['LatestAlbum'])
{
releasedate = '';
albumdisplay = '<i>' + artist['LatestAlbum'] + '</i>';
}
else
{
releasedate = '';
albumdisplay = '<i>None</i>';
}
if (artist['ReleaseInFuture'] === 'True')
{
grade = 'gradeA';
}
else
{
grade = 'gradeZ';
}
artist['Grade'] = grade;
return '<span title="' + releasedate + '"></span><a href="albumPage?AlbumID=' + full['AlbumID'] + '">' + albumdisplay + '</a>'
}
},
{
"aTargets":[4],
"mDataProp":"HaveTracks",
"mRender":function(data,type,full){
if(full['TotalTracks'] > 0)
{
percent = (full['HaveTracks']*100.0)/full['TotalTracks']
if(percent > 100){
percent = 100;
}
}
else
{
full['TotalTracks'] = '?';
percent = 0;
}
return '<span title="' + percent + '"></span><div class="progress-container"><div style="width:' + percent + '%"><div class="havetracks">' + full['HaveTracks'] + '/' + full['TotalTracks'] + '</div></div></div>';
}},
], ],
"oLanguage": { "oLanguage": {
"sSearch": ""}, "sSearch": "",
"sLengthMenu":"Show _MENU_ artists per page",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ artists",
"sInfoEmpty":"Showing 0 to 0 of 0 artists",
"sInfoFiltered":"(filtered from _MAX_ total artists)"
},
"bStateSave": true, "bStateSave": true,
"iDisplayLength": 50, "iDisplayLength": 50,
"sPaginationType": "full_numbers", "sPaginationType": "full_numbers",
@@ -65,6 +129,12 @@
"bServerSide": true, "bServerSide": true,
"sAjaxSource": 'getArtists.json', "sAjaxSource": 'getArtists.json',
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ){ "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ){
$('td', nRow).closest('tr').addClass(aData['Grade'])
nRow.children[0].id = 'albumart';
nRow.children[1].id = 'name';
nRow.children[2].id = 'status'
nRow.children[3].id = 'album'
nRow.children[4].id = 'have'
return nRow; return nRow;
}, },
"fnServerData": function ( sSource, aoData, fnCallback ) { "fnServerData": function ( sSource, aoData, fnCallback ) {
+9 -3
View File
@@ -26,7 +26,7 @@ import threading
import headphones import headphones
from headphones import logger, searcher, db, importer, mb, lastfm, librarysync from headphones import logger, searcher, db, importer, mb, lastfm, librarysync
from headphones.helpers import checked, radio from headphones.helpers import checked, radio,today
import lib.simplejson as simplejson import lib.simplejson as simplejson
import json import json
@@ -451,8 +451,8 @@ class WebInterface(object):
filtered = myDB.select('SELECT * from artists order by ArtistSortName COLLATE NOCASE') filtered = myDB.select('SELECT * from artists order by ArtistSortName COLLATE NOCASE')
totalcount = len(filtered) totalcount = len(filtered)
else: else:
filtered = myDB.select('SELECT * from artists order by ArtistSortName WHERE ArtistSortName LIKE %s OR LatestAlbum LIKE %s COLLATE NOCASE' % (sSearch,sSearch)) filtered = myDB.select('SELECT * from artists WHERE ArtistSortName LIKE "%' + sSearch + '%" OR LatestAlbum LIKE "%' + sSearch +'%" order by ArtistSortName COLLATE NOCASE')
totalcount = myDB.select('SELECT COUNT(*) from artists') totalcount = myDB.select('SELECT COUNT(*) from artists')[0][0]
sortcolumn = 0 sortcolumn = 0
if iSortCol_0 == '1': if iSortCol_0 == '1':
@@ -470,14 +470,20 @@ class WebInterface(object):
"HaveTracks":artist["HaveTracks"] if 'HaveTracks' in artist else 0, "HaveTracks":artist["HaveTracks"] if 'HaveTracks' in artist else 0,
"LatestAlbum":"", "LatestAlbum":"",
"ReleaseDate":"", "ReleaseDate":"",
"ReleaseInFuture":"False",
"AlbumID":"",
} }
if artist['ReleaseDate'] and artist['LatestAlbum']: if artist['ReleaseDate'] and artist['LatestAlbum']:
row['ReleaseDate'] = artist['ReleaseDate'] row['ReleaseDate'] = artist['ReleaseDate']
row['LatestAlbum'] = artist['LatestAlbum'] row['LatestAlbum'] = artist['LatestAlbum']
row['AlbumID'] = artist['AlbumID']
if artist['ReleaseDate'] > today():
row['ReleaseInFuture'] = "True"
elif artist['LatestAlbum']: elif artist['LatestAlbum']:
row['ReleaseDate'] = '' row['ReleaseDate'] = ''
row['LatestAlbum'] = artist['LatestAlbum'] row['LatestAlbum'] = artist['LatestAlbum']
row['AlbumID'] = artist['AlbumID']
rows.append(row) rows.append(row)