From f8cee0867e872ec366c7fba8c7238c27b8e82a47 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 4 Dec 2020 15:25:55 -0500 Subject: [PATCH] Implement API and Interface Enablement for ALL channels --- data/www/templates/channels_editor.html | 12 +++++------- fHDHR/device/channels/__init__.py | 4 ++++ fHDHR/device/channels/channel.py | 4 ++-- fHDHR/http/api/channels.py | 7 +++++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/data/www/templates/channels_editor.html b/data/www/templates/channels_editor.html index 3309394..0f89269 100644 --- a/data/www/templates/channels_editor.html +++ b/data/www/templates/channels_editor.html @@ -4,9 +4,13 @@

{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Channels Editor

+
+ + +
+ - @@ -18,12 +22,6 @@ {% for chan_dict in channelslist %} - - diff --git a/fHDHR/device/channels/__init__.py b/fHDHR/device/channels/__init__.py index 261a420..119da2f 100644 --- a/fHDHR/device/channels/__init__.py +++ b/fHDHR/device/channels/__init__.py @@ -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) diff --git a/fHDHR/device/channels/channel.py b/fHDHR/device/channels/channel.py index dfa8378..4a1ad68 100644 --- a/fHDHR/device/channels/channel.py +++ b/fHDHR/device/channels/channel.py @@ -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 ''' diff --git a/fHDHR/http/api/channels.py b/fHDHR/http/api/channels.py index 855bd1f..f2c5175 100644 --- a/fHDHR/http/api/channels.py +++ b/fHDHR/http/api/channels.py @@ -66,12 +66,15 @@ 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 - self.fhdhr.device.channels.set_channel_enablement("number", channel, method) + else: + self.fhdhr.device.channels.set_channel_enablement("number", channel, method) elif method == "update": channel_id = request.form.get('id', None)
Play Channel Name Channel CallSign Channel Number
- {% if chan_dict["enabled"] %} - Play - {% endif %} -