<%inherit file="base.html" />
<%!
	from headphones import db
	import headphones
%>

<%def name="body()">
	<div id="nav-sub-container">
		<ul id="nav-sub">
			<li><a href="manage">Manage</a></li>
			<li><a href="manageAlbums">Albums</a></li>
			<li><a class="active" href="manageArtists">Artists</a></li>
			%if not headphones.ADD_ARTISTS:
			<li><a href="manageNew">New Artists</a></li>
			%endif
		</ul>
	</div>
	<form action="markArtists" method="get">
	<p class="indented">
		<select class="styled" name="action">
  			<option value="pause">Pause</option>
  			<option value="resume">Resume</option>
  			<option value="refresh">Refresh</option>
  			<option value="delete">Delete</option>
		</select>
		selected artists
		<input type="submit" value="Go">
	</p>
	<table class="display" id="artist_table">
		<thead>
			<tr>
				<th id="select"><input type="checkbox" onClick="toggle(this)" /></th>
				<th id="status">Status</th>
				<th id="name">Artist Name</th>
				<th id="album">Latest Album</th>
			</tr>
		</thead>
		<tbody>
		%for artist in artists:
			<%
				if artist['Status'] == 'Paused':
					grade = 'X'
				elif artist['Status'] == 'Loading':
					grade = 'C'
				else:
					grade = 'Z'
					
				if artist['ReleaseDate'] and artist['LatestAlbum']:
					releasedate = artist['ReleaseDate']
					albumdisplay = '<i>%s</i> (%s)' % (artist['LatestAlbum'], artist['ReleaseDate'])	
				elif artist['LatestAlbum']:
					releasedate = ''
					albumdisplay = '<i>%s</i>' % artist['LatestAlbum']
				else:
					releasedate = ''
					albumdisplay = '<i>None</i>'
			%>
			<tr class="grade${grade}">
				<td id="select"><input type="checkbox" name="${artist['ArtistID']}" class="checkbox" /></td>
				<td id="status">

				%if artist['Status'] == 'Paused':
					<span class="wsr Clock"></span>
				%elif artist['Status'] == 'Loading':
					<span class="wsr Loading loader"></span>
				%elif artist['Status'] == 'Active':
					<span class="wsr Approved"></span>
				%else: 
					<span class="wsr Alert"></span>
				%endif
				${artist['Status']}
				</td>	
				<td id="name"><span title="${artist['ArtistSortName']}"></span><a href="artistPage?ArtistID=${artist['ArtistID']}">${artist['ArtistName']}</a></td>
				<td id="album"><span title="${releasedate}"></span><a href="albumPage?AlbumID=${artist['AlbumID']}">${albumdisplay}</a></td>
			</tr>
		%endfor
		</tbody>
	</table>
	</form>
</%def>

<%def name="headIncludes()">
	
</%def>

<%def name="javascriptIncludes()">
	<script src="interfaces/brink/JS/libs/jquery.dataTables.min.js"></script>
	<script>
	$(document).ready(function()
	{
		$('#artist_table').dataTable(
			{
				"bDestroy": true,
				"aoColumns": [
					null,
					null,
					null,
					null,
				],
				"bStateSave": true,
				"bPaginate": false
			});
	});
	</script>
</%def>