1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 08:56:57 -05:00

Implement API and Interface Enablement for ALL channels

This commit is contained in:
deathbybandaid 2020-12-04 15:25:55 -05:00
parent 7ffd33ae51
commit f8cee0867e
4 changed files with 16 additions and 11 deletions

View File

@ -4,9 +4,13 @@
<h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor</h4> <h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor</h4>
<div style="text-align: center;">
<button onclick="OpenLink('/api/channels?method=enable&channel=all&redirect=%2Fchannels_editor')">Enable All</a></button>
<button onclick="OpenLink('/api/channels?method=disable&channel=all&redirect=%2Fchannels_editor')">Disable All</a></button>
</div>
<table class="center" style="width:100%"> <table class="center" style="width:100%">
<tr> <tr>
<th>Play</th>
<th>Channel Name</th> <th>Channel Name</th>
<th>Channel CallSign</th> <th>Channel CallSign</th>
<th>Channel Number</th> <th>Channel Number</th>
@ -18,12 +22,6 @@
</tr> </tr>
{% for chan_dict in channelslist %} {% for chan_dict in channelslist %}
<tr>
<td>
{% if chan_dict["enabled"] %}
<a href="{{ chan_dict["play_url"] }}">Play</a>
{% endif %}
</td>
<form method="post" action="/api/channels?method=update&redirect=%2Fchannels_editor"> <form method="post" action="/api/channels?method=update&redirect=%2Fchannels_editor">
<input type="hidden" name="id" value={{ chan_dict["id"] }}> <input type="hidden" name="id" value={{ chan_dict["id"] }}>

View File

@ -33,6 +33,10 @@ class Channels():
def set_channel_status(self, keyfind, valfind, updatedict): def set_channel_status(self, keyfind, valfind, updatedict):
self.get_channel_obj(keyfind, valfind).set_status(updatedict) self.get_channel_obj(keyfind, valfind).set_status(updatedict)
def set_channel_enablement_all(self, enablement):
for fhdhr_id in list(self.list.keys()):
self.list[fhdhr_id].set_enablement(enablement)
def set_channel_enablement(self, keyfind, valfind, enablement): def set_channel_enablement(self, keyfind, valfind, enablement):
self.get_channel_obj(keyfind, valfind).set_enablement(enablement) self.get_channel_obj(keyfind, valfind).set_enablement(enablement)

View File

@ -115,7 +115,7 @@ class Channel():
self.dict["favorite"] = 1 self.dict["favorite"] = 1
elif enablement == "+": elif enablement == "+":
self.dict["favorite"] = 0 self.dict["favorite"] = 0
self.fhdhr.db.set_channel_value(self.dict["fhdhr_id"], "info", self.dict) self.fhdhr.db.set_channel_value(self.dict["id"], "info", self.dict)
def set_enablement(self, enablement): def set_enablement(self, enablement):
if enablement == "disable": if enablement == "disable":
@ -127,7 +127,7 @@ class Channel():
self.dict["enabled"] = False self.dict["enabled"] = False
else: else:
self.dict["enabled"] = True self.dict["enabled"] = True
self.fhdhr.db.set_channel_value(self.dict["fhdhr_id"], "info", self.dict) self.fhdhr.db.set_channel_value(self.dict["id"], "info", self.dict)
def __getattr__(self, name): def __getattr__(self, name):
''' will only get called for undefined attributes ''' ''' will only get called for undefined attributes '''

View File

@ -66,11 +66,14 @@ class Channels():
elif method in ["enable", "disable"]: elif method in ["enable", "disable"]:
channel = request.args.get('channel', default=None, type=str) channel = request.args.get('channel', default=None, type=str)
if not channel or str(channel) not in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]: if channel == "all":
self.fhdhr.device.channels.set_channel_enablement_all(method)
elif not channel or str(channel) not in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]:
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method)) return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method))
else: else:
return "%s Falied" % method return "%s Falied" % method
else:
self.fhdhr.device.channels.set_channel_enablement("number", channel, method) self.fhdhr.device.channels.set_channel_enablement("number", channel, method)
elif method == "update": elif method == "update":