From 4ca42c9c11614799d1e08ee8d14916376a6747fc Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 18 Apr 2014 00:59:35 -0700 Subject: [PATCH] Initial changes to stop artist page from refreshing when artist is loading --- data/interfaces/default/artist.html | 59 ++++++++++++++++++++--------- headphones/webserve.py | 6 +++ 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index 423fa014..beb3695d 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -42,14 +42,8 @@
-

- %if artist['Status'] == 'Loading': - - %endif +

${artist['ArtistName']} - %if artist['Status'] == 'Loading': -

(Album information for this artist is currently being loaded)

- %endif
@@ -156,9 +150,6 @@ <%def name="headIncludes()"> - %if artist['Status'] == 'Loading': - - %endif <%def name="javascriptIncludes()"> @@ -171,7 +162,6 @@ getInfo(elem,id,'artist'); } - <% if headphones.SONGKICK_FILTER_ENABLED: songkick_filter_enabled = "true" @@ -240,6 +230,41 @@ }); } + var loadingMessage = false; + var spinner_active = false; + var loadingtext_active = false; + + function checkArtistStatus() { + $.ajax({ + url: "getArtistStatus?ArtistID=${artist['ArtistID']}", + complete: function(result) { + if (result.responseText == "Loading"){ + refreshTable(); + if (loadingMessage == false){ + showMsg("Getting artist information",true); + loadingMessage = true; + } + if (spinner_active == false){ + $('#artistname').prepend('') + spinner_active = true; + } + if (loadingtext_active == false){ + $('#artistname').append('

(Album information for this artist is currently being loaded)

') + loadingtext_active = true; + } + } + else{ + $('#artistnamespinner').remove() + $('#loadingtext').remove() + $('#ajaxMsg').remove() + spinner_active = false + loadingtext_active = false + loadingMessage = false + } + } + }); + } + function initThisPage() { $('#menu_link_getextra').click(function() { $('#dialog').dialog(); @@ -248,10 +273,6 @@ $('#menu_link_modifyextra').click(function() { $('#dialog').dialog(); }); - - %if artist['Status'] == 'Loading': - showMsg("Getting artist information",true); - %endif $('#album_table').dataTable({ "bDestroy": true, "aoColumns": [ @@ -291,8 +312,12 @@ initThisPage(); getArtistBio(); if( ${songkick_enabled} ){ - getArtistsCalendar(); - } + getArtistsCalendar(); + } + checkArtistStatus(); + setInterval(function(){ + checkArtistStatus(); + }, 3000); }); diff --git a/headphones/webserve.py b/headphones/webserve.py index 39ddb88f..81b06f8a 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -854,6 +854,12 @@ class WebInterface(object): return json_albums getAlbumsByArtist_json.exposed=True + def getArtistStatus(self, ArtistID): + myDB = db.DBConnection() + artist = myDB.action('SELECT Status FROM artists WHERE ArtistID=?', [ArtistID]).fetchone() + return artist['Status'] + getArtistStatus.exposed=True + def clearhistory(self, type=None, date_added=None, title=None): myDB = db.DBConnection() if type: