mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 11:26:57 -05:00
Merge pull request #77 from deathbybandaid/dev
Implement API and Interface Enablement for ALL channels
This commit is contained in:
commit
e3646e7b9d
@ -4,9 +4,13 @@
|
||||
|
||||
<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%">
|
||||
<tr>
|
||||
<th>Play</th>
|
||||
<th>Channel Name</th>
|
||||
<th>Channel CallSign</th>
|
||||
<th>Channel Number</th>
|
||||
@ -18,12 +22,6 @@
|
||||
</tr>
|
||||
|
||||
{% 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">
|
||||
<input type="hidden" name="id" value={{ chan_dict["id"] }}>
|
||||
|
||||
@ -33,6 +33,10 @@ class Channels():
|
||||
def set_channel_status(self, keyfind, valfind, 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):
|
||||
self.get_channel_obj(keyfind, valfind).set_enablement(enablement)
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ class Channel():
|
||||
self.dict["favorite"] = 1
|
||||
elif enablement == "+":
|
||||
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):
|
||||
if enablement == "disable":
|
||||
@ -127,7 +127,7 @@ class Channel():
|
||||
self.dict["enabled"] = False
|
||||
else:
|
||||
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):
|
||||
''' will only get called for undefined attributes '''
|
||||
|
||||
@ -66,11 +66,14 @@ class Channels():
|
||||
|
||||
elif method in ["enable", "disable"]:
|
||||
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:
|
||||
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method))
|
||||
else:
|
||||
return "%s Falied" % method
|
||||
else:
|
||||
self.fhdhr.device.channels.set_channel_enablement("number", channel, method)
|
||||
|
||||
elif method == "update":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user