1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added filter selection to pulse view

This commit is contained in:
Krateng 2019-04-01 18:43:08 +02:00
parent 6c646f5aac
commit 3cf37aff90
5 changed files with 71 additions and 33 deletions

View File

@ -277,11 +277,19 @@ def module_trackcharts_tiles(**kwargs):
def module_filterselection(**keys): def module_filterselection(keys,time=True,delimit=False):
# all other keys that will not be changed by clicking another filter # all other keys that will not be changed by clicking another filter
html = ""
if time:
retainkeys = {k:keys[k] for k in keys if k not in ["since","to","in"]} retainkeys = {k:keys[k] for k in keys if k not in ["since","to","in"]}
keystr = "?" + urllib.parse.urlencode(retainkeys) keystr = "?" + urllib.parse.urlencode(retainkeys)
html = "<div>"
html += "<div>"
if keys.get("since") == "today" or keys.get("in") == "today": if keys.get("since") == "today" or keys.get("in") == "today":
html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>" html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>"
else: else:
@ -313,4 +321,30 @@ def module_filterselection(**keys):
html += "</div>" html += "</div>"
if delimit:
retainkeys = {k:keys[k] for k in keys if k not in ["step","stepn","trail"]}
keystr = "?" + urllib.parse.urlencode(retainkeys)
html += "<div>"
if keys.get("step") == "day":
html += "<span class='stat_selector' style='opacity:0.5;'>Daily</span>"
else:
html += "<a href='" + keystr + "&step=day'><span class='stat_selector'>Daily</span></a>"
html += " | "
if keys.get("step") == "month":
html += "<span class='stat_selector' style='opacity:0.5;'>Monthly</span>"
else:
html += "<a href='" + keystr + "&step=month'><span class='stat_selector'>Monthly</span></a>"
html += " | "
if keys.get("step") == "year":
html += "<span class='stat_selector' style='opacity:0.5;'>Yearly</span>"
else:
html += "<a href='" + keystr + "&step=year'><span class='stat_selector'>Yearly</span></a>"
html += " | "
html += "</div>"
return html return html

View File

@ -16,6 +16,8 @@
<h1>KEY_PULSEDETAILS Pulse</h1><br/> <h1>KEY_PULSEDETAILS Pulse</h1><br/>
<span>KEY_LIMITS</span> <span>KEY_LIMITS</span>
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>--> <!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
<br/><br/>
KEY_FILTERSELECTOR
</td> </td>
</tr> </tr>

View File

@ -5,7 +5,7 @@ import database
def instructions(keys): def instructions(keys):
from utilities import getArtistImage, getTrackImage from utilities import getArtistImage, getTrackImage
from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink, keysToUrl, KeySplit from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink, keysToUrl, KeySplit
from htmlmodules import module_pulse from htmlmodules import module_pulse, module_filterselection
from malojatime import range_desc, delimit_desc from malojatime import range_desc, delimit_desc
filterkeys, timekeys, delimitkeys, _ = KeySplit(keys) filterkeys, timekeys, delimitkeys, _ = KeySplit(keys)
@ -32,6 +32,8 @@ def instructions(keys):
delimitstring = delimit_desc(**delimitkeys) delimitstring = delimit_desc(**delimitkeys)
html_filterselector = module_filterselection(keys,delimit=True)
# get image # get image
if filterkeys.get("track") is not None: if filterkeys.get("track") is not None:
@ -47,6 +49,6 @@ def instructions(keys):
html_pulse = module_pulse(**filterkeys,**timekeys,**delimitkeys) html_pulse = module_pulse(**filterkeys,**timekeys,**delimitkeys)
replace = {"KEY_PULSE_TABLE":html_pulse,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring,"KEY_PULSEDETAILS":delimitstring} replace = {"KEY_PULSE_TABLE":html_pulse,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring,"KEY_PULSEDETAILS":delimitstring,"KEY_FILTERSELECTOR":html_filterselector}
return (replace,pushresources) return (replace,pushresources)

View File

@ -12,7 +12,7 @@ def instructions(keys):
limitstring = range_desc(**timekeys) limitstring = range_desc(**timekeys)
html_filterselector = module_filterselection(**keys) html_filterselector = module_filterselection(keys)

View File

@ -12,7 +12,7 @@ def instructions(keys):
limitstring = "" limitstring = ""
html_filterselector = module_filterselection(**keys) html_filterselector = module_filterselection(keys)
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys) html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)