Bug fixes for saving music folder/scan options without initiating a scan

This commit is contained in:
rembo10
2012-10-20 20:01:13 -03:00
parent f09b0425c6
commit 4f1f05e12b
2 changed files with 14 additions and 21 deletions

View File

@@ -58,12 +58,12 @@
%endif
</div>
<div class="row checkbox">
<input type="checkbox" name="autoadd" value="1" ${checked(headphones.ADD_ARTISTS)}><label>Automatically add new artists</label>
<input type="checkbox" name="autoadd" id="autoadd" value="1" ${checked(headphones.ADD_ARTISTS)}><label>Automatically add new artists</label>
</div>
</fieldset>
<input type="button" value="Save Changes" onclick="doAjaxCall('musicSave',$(this),'tabs',true);return false;" data-success="Changes have been saved">
<input type="button" value="Save Changes + Scan" onclick="doAjaxCall('musicScan',$(this),'tabs',true);return false;" data-success="Changes saved. Library will be scanned">
<input type="button" value="Save Changes and Scan" onclick="addScanAction();doAjaxCall('musicScan',$(this),'tabs',true);return false;" data-success="Changes saved. Library will be scanned">
<input type="button" value="Save Changes without Scanning Library" onclick="doAjaxCall('musicScan',$(this),'tabs',true);return false;" data-success="Changes Saved Successfully">
</form>
</div>
@@ -139,6 +139,10 @@
</%def>
<%def name="javascriptIncludes()">
<script>
function addScanAction() {
$('#autoadd').append('<input type="hidden" name="scan" value=1 />');
};
function initThisPage() {
$('#manage_albums').click(function() {
$('#dialog').dialog();

View File

@@ -352,13 +352,11 @@ class WebInterface(object):
headphones.LASTFM_USERNAME = username
headphones.config_write()
threading.Thread(target=lastfm.getArtists).start()
time.sleep(10)
raise cherrypy.HTTPRedirect("home")
importLastFM.exposed = True
def importLastFMTag(self, tag, limit):
threading.Thread(target=lastfm.getTagTopArtists, args=(tag, limit)).start()
time.sleep(10)
raise cherrypy.HTTPRedirect("home")
importLastFMTag.exposed = True
@@ -370,23 +368,15 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect("home")
importItunes.exposed = True
def musicSave(self, path, redirect=None, autoadd=0):
def musicScan(self, path, scan=0, redirect=None, autoadd=0):
headphones.ADD_ARTISTS = autoadd
headphones.MUSIC_DIR = path
headphones.config_write()
if redirect:
raise cherrypy.HTTPRedirect(redirect)
musicSave.exposed = True
def musicScan(self, path, redirect=None, autoadd=0):
headphones.ADD_ARTISTS = autoadd
headphones.MUSIC_DIR = path
headphones.config_write()
try:
threading.Thread(target=librarysync.libraryScan).start()
except Exception, e:
logger.error('Unable to complete the scan: %s' % e)
time.sleep(10)
headphones.config_write()
if scan:
try:
threading.Thread(target=librarysync.libraryScan).start()
except Exception, e:
logger.error('Unable to complete the scan: %s' % e)
if redirect:
raise cherrypy.HTTPRedirect(redirect)
else:
@@ -421,7 +411,6 @@ class WebInterface(object):
myDB = db.DBConnection()
history = myDB.select('''SELECT * from snatched order by DateAdded DESC''')
return serve_template(templatename="history.html", title="History", history=history)
return page
history.exposed = True
def logs(self):