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:
		| @@ -277,40 +277,74 @@ 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 | ||||||
| 	retainkeys = {k:keys[k] for k in keys if k not in ["since","to","in"]} |  | ||||||
| 	keystr = "?" + urllib.parse.urlencode(retainkeys) |  | ||||||
| 	html = "<div>" |  | ||||||
| 	if keys.get("since") == "today" or keys.get("in") == "today": |  | ||||||
| 		html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>" |  | ||||||
| 	else: |  | ||||||
| 		html += "<a href='" + keystr + "&since=today'><span class='stat_selector'>Today</span></a>" |  | ||||||
| 	html += " | " |  | ||||||
|  |  | ||||||
| 	if keys.get("since") == "sunday": |  | ||||||
| 		html += "<span class='stat_selector' style='opacity:0.5;'>This Week</span>" |  | ||||||
| 	else: |  | ||||||
| 		html += "<a href='" + keystr + "&since=sunday'><span class='stat_selector'>This Week</span></a>" |  | ||||||
| 	html += " | " |  | ||||||
|  |  | ||||||
| 	if keys.get("since") == "month" or keys.get("in") == "month": | 	html = "" | ||||||
| 		html += "<span class='stat_selector' style='opacity:0.5;'>This Month</span>" |  | ||||||
| 	else: |  | ||||||
| 		html += "<a href='" + keystr + "&since=month'><span class='stat_selector'>This Month</span></a>" |  | ||||||
| 	html += " | " |  | ||||||
|  |  | ||||||
| 	if keys.get("since") == "year" or keys.get("in") == "year": | 	if time: | ||||||
| 		html += "<span class='stat_selector' style='opacity:0.5;'>This Year</span>" |  | ||||||
| 	else: |  | ||||||
| 		html += "<a href='" + keystr + "&since=year'><span class='stat_selector'>This Year</span></a>" |  | ||||||
| 	html += " | " |  | ||||||
|  |  | ||||||
| 	if keys.get("since") is None and keys.get("in") is None: | 		retainkeys = {k:keys[k] for k in keys if k not in ["since","to","in"]} | ||||||
| 		html += "<span class='stat_selector' style='opacity:0.5;'>All Time</span>" | 		keystr = "?" + urllib.parse.urlencode(retainkeys) | ||||||
| 	else: |  | ||||||
| 		html += "<a href='" + keystr + "'><span class='stat_selector'>All Time</span></a>" |  | ||||||
|  |  | ||||||
| 	html += "</div>" |  | ||||||
|  | 		html += "<div>" | ||||||
|  | 		if keys.get("since") == "today" or keys.get("in") == "today": | ||||||
|  | 			html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>" | ||||||
|  | 		else: | ||||||
|  | 			html += "<a href='" + keystr + "&since=today'><span class='stat_selector'>Today</span></a>" | ||||||
|  | 		html += " | " | ||||||
|  |  | ||||||
|  | 		if keys.get("since") == "sunday": | ||||||
|  | 			html += "<span class='stat_selector' style='opacity:0.5;'>This Week</span>" | ||||||
|  | 		else: | ||||||
|  | 			html += "<a href='" + keystr + "&since=sunday'><span class='stat_selector'>This Week</span></a>" | ||||||
|  | 		html += " | " | ||||||
|  |  | ||||||
|  | 		if keys.get("since") == "month" or keys.get("in") == "month": | ||||||
|  | 			html += "<span class='stat_selector' style='opacity:0.5;'>This Month</span>" | ||||||
|  | 		else: | ||||||
|  | 			html += "<a href='" + keystr + "&since=month'><span class='stat_selector'>This Month</span></a>" | ||||||
|  | 		html += " | " | ||||||
|  |  | ||||||
|  | 		if keys.get("since") == "year" or keys.get("in") == "year": | ||||||
|  | 			html += "<span class='stat_selector' style='opacity:0.5;'>This Year</span>" | ||||||
|  | 		else: | ||||||
|  | 			html += "<a href='" + keystr + "&since=year'><span class='stat_selector'>This Year</span></a>" | ||||||
|  | 		html += " | " | ||||||
|  |  | ||||||
|  | 		if keys.get("since") is None and keys.get("in") is None: | ||||||
|  | 			html += "<span class='stat_selector' style='opacity:0.5;'>All Time</span>" | ||||||
|  | 		else: | ||||||
|  | 			html += "<a href='" + keystr + "'><span class='stat_selector'>All Time</span></a>" | ||||||
|  |  | ||||||
|  | 		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 | ||||||
|   | |||||||
| @@ -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> | ||||||
|   | |||||||
| @@ -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) | ||||||
|   | |||||||
| @@ -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) | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Krateng
					Krateng