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

Compare commits

..

No commits in common. "ccd99a70086983b681866498d53c51dc86cce15e" and "e3d8f64c5c078fe9afd8c6535bdefc7404aaad49" have entirely different histories.

3 changed files with 71 additions and 147 deletions

View File

@ -114,7 +114,7 @@ class Channels():
self.fhdhr.device.channels.set_channel_status("id", channel_id, updatedict) self.fhdhr.device.channels.set_channel_status("id", channel_id, updatedict)
elif method == "modify": elif method == "modify":
channels_list = json.loads(request.form.get('channels', [])) channels_list = eval(request.form.get('channels', []))
for channel in channels_list: for channel in channels_list:
updatedict = {} updatedict = {}
for key in list(channel.keys()): for key in list(channel.keys()):

View File

@ -1,85 +1,18 @@
from browser import document, bind # alert, window from browser import document, bind # alert, window
import json
def chan_edit_data(items, channel_id): @bind("#enable_button", "click")
def enable_all(event):
chanlist = []
chandict = {}
for element in items:
if element.name == "id":
if len(chandict.keys()) >= 2 and "id" in list(chandict.keys()):
chanlist.append(chandict)
chandict = {"id": element.value}
if element.type == "checkbox":
if element.name in ["enabled"]:
save_val = element.checked
else:
save_val = int(element.checked)
else:
save_val = element.value
if element.name != "id":
cur_value = element.placeholder
if element.type == "checkbox":
if element.name in ["enabled"]:
cur_value = element.placeholder
else:
cur_value = int(element.placeholder)
if str(save_val) != str(cur_value):
chandict[element.name] = save_val
if channel_id != "all":
chanlist == [x for x in chanlist if x["id"] == channel_id]
return chanlist
def chan_edit_postform(chanlist):
postForm = document.createElement('form')
postForm.method = "POST"
postForm.action = "/api/channels?method=modify&redirect=/channels_editor"
postForm.setRequestHeader = "('Content-Type', 'application/json')"
postData = document.createElement('input')
postData.type = 'hidden'
postData.name = "channels"
postData.value = json.dumps(chanlist)
postForm.appendChild(postData)
document.body.appendChild(postForm)
return postForm
@bind("#Chan_Edit_Reset", "submit")
def chan_edit_reset(evt):
chanlist = chan_edit_data(
document.select(".reset"),
str(evt.currentTarget.children[0].id).replace("reset_", ""))
postForm = chan_edit_postform(chanlist)
postForm.submit()
evt.preventDefault()
@bind("#Chan_Edit_Modify", "submit")
def chan_edit_modify(evt):
chanlist = chan_edit_data(
document.select(".channels"),
str(evt.currentTarget.children[0].id).replace("update_", ""))
postForm = chan_edit_postform(chanlist)
postForm.submit()
evt.preventDefault()
@bind("#Chan_Edit_Enable_Toggle", "click")
def chan_edit_enable(event):
enable_bool = bool(int(document["enable_button"].value))
for element in document.get(selector='input[type="checkbox"]'): for element in document.get(selector='input[type="checkbox"]'):
if element.name == "enabled": if element.name.endswith("enabled"):
element.checked = enable_bool if document["enable_button"].value == "0":
element.value = enable_bool element.checked = False
element.value = False
else:
element.checked = True
element.value = True
if not enable_bool: if document["enable_button"].value == "0":
document["enable_button"].value = "1" document["enable_button"].value = "1"
document["enable_button"].text = "Enable All" document["enable_button"].text = "Enable All"
else: else:
@ -87,17 +20,41 @@ def chan_edit_enable(event):
document["enable_button"].text = "Disable All" document["enable_button"].text = "Disable All"
@bind("#Chan_Edit_Favorite_Toggle", "click") @bind("#chanSubmit", "submit")
def chan_edit_favorite(event): def submit_fixup(evt):
enable_bool = bool(int(document["favorite_button"].value))
for element in document.get(selector='input[type="checkbox"]'): for element in document.get(selector='input[type="checkbox"]'):
if element.name == "favorite": if element.name.endswith("enabled"):
element.checked = enable_bool if element.checked is False:
element.value = int(enable_bool) element.checked = True
element.value = False
if element.name.endswith("favorite"):
if element.checked is False:
element.checked = True
element.value = 0
if not enable_bool: items = document.select(".channels")
document["favorite_button"].value = "1" chanlist = []
document["favorite_button"].text = "Favorite All" chandict = {}
else:
document["favorite_button"].value = "0" for element in items:
document["favorite_button"].text = "Unfavorite All" if element.name == "id":
if len(chandict.keys()):
chanlist.append(chandict)
chandict = {}
chandict[element.name] = element.value
element.clear()
postForm = document.createElement('form')
postData = document.createElement('input')
postForm.method = "POST"
postForm.action = "/api/channels?method=modify&redirect=/channels_editor"
postForm.setRequestHeader = "('Content-Type', 'application/json')"
postData.name = "channels"
postData.value = chanlist
postForm.appendChild(postData)
document.body.appendChild(postForm)
postForm.submit()
evt.preventDefault()

View File

@ -4,34 +4,14 @@
<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 class="container"> <div style="text-align: center;">
<table class="table-medium center"> <form id="chanSubmit" method="post">
<tbody> <button type="Submit" id="modify_button" value="0">Modify All</button>
<tr> <button type="button" id="enable_button" value="0">Disable All</button>
<td> </form>
<form id="Chan_Edit_Enable_Toggle" method="post">
<button type="button" id="enable_button" value="0">Disable All</button>
</form>
</td>
<td>
<form id="Chan_Edit_Favorite_Toggle" method="post">
<button type="button" id="favorite_button" value="0">Unfavorite All</button>
</form>
</td>
<td>
<form id="Chan_Edit_Modify" method="post">
<button type="Submit" id="modify_all">Modify All</button>
</form>
<form id="Chan_Edit_Reset" method="post">
<button type="Submit" id="reset_all">Reset All</button>
</form>
</td>
</tr>
</tbody>
</table>
</div> </div>
<div class="container"> <div class="container">
<table class="table-scroll center text-edit-cols"> <table class="table-scroll center text-edit-cols">
<thead> <thead>
@ -47,48 +27,35 @@
</thead> </thead>
<tbody class="body-half-screen"> <tbody class="body-half-screen">
{% for chan_dict in channelslist %} {% for chan_dict in channelslist %}
<tr> <tr>
<input type="hidden" name="id" class="channels" value="{{ chan_dict["id"] }}"> <td><input type="hidden" name="id" class="channels" value={{ chan_dict["id"] }}>
<input type="hidden" class="reset" name="id" value="{{ chan_dict["id"] }}"> <input type="text" class="channels" name="name" value="{{ chan_dict["name"] }}">
</td>
<td><input type="text" class="channels" name="name" value="{{ chan_dict["name"] }}" placeholder="{{ chan_dict["name"] }}"></td> <td><input type="text" class="channels" name="callsign" value="{{ chan_dict["callsign"] }}"></td>
<input type="hidden" class="reset" name="name" value="{{ chan_dict["origin_name"] }}" placeholder="{{ chan_dict["name"] }}"> <td><input type="text" class="channels" name="number" value="{{ chan_dict["number"] }}"></td>
<td><input type="text" class="channels" name="thumbnail" value="{{ chan_dict["thumbnail"] }}"></td>
<td><input type="text" class="channels" name="callsign" value="{{ chan_dict["callsign"] }}" placeholder="{{ chan_dict["callsign"] }}"></td>
<input type="hidden" class="reset" name="callsign" value="{{ chan_dict["origin_callsign"] }}" placeholder="{{ chan_dict["callsign"] }}">
<td><input type="text" class="channels" name="number" value="{{ chan_dict["number"] }}" placeholder="{{ chan_dict["number"] }}"></td>
<input type="hidden" class="reset" name="number" value="{{ chan_dict["origin_number"] }}" placeholder="{{ chan_dict["number"] }}">
<td><input type="text" class="channels" name="thumbnail" value="{{ chan_dict["thumbnail"] }}" placeholder="{{ chan_dict["thumbnail"] }}"></td>
<input type="hidden" class="reset" name="thumbnail" value="{{ chan_dict["origin_thumbnail"] }}" placeholder="{{ chan_dict["thumbnail"] }}">
{% if chan_dict["enabled"] %} {% if chan_dict["enabled"] %}
<td><input type="checkbox" class="channels" name="enabled" value=True checked placeholder="{{ chan_dict["enabled"] }}"></td> <td><input type="checkbox" class="channels" name="enabled" value=True checked></td>
{% else %} {% else %}
<td><input type="checkbox" class="channels" name="enabled" value=True placeholder="{{ chan_dict["enabled"] }}"></td> <td><input type="checkbox" class="channels" name="enabled" value=True ></td>
{% endif %} {% endif %}
<input type="hidden" class="reset" name="enabled" value=True placeholder="{{ chan_dict["enabled"] }}">
{% if chan_dict["favorite"] %} {% if chan_dict["favorite"] %}
<td><input type="checkbox" class="channels" name="favorite" value=1 checked placeholder="{{ chan_dict["favorite"] }}"></td> <td><input type="checkbox" class="channels" name="favorite" value=1 checked></td>
{% else %} {% else %}
<td><input type="checkbox" class="channels" name="favorite" value=1 placeholder="{{ chan_dict["favorite"] }}"></td> <td><input type="checkbox" class="channels" name="favorite" value=1 ></td>
{% endif %} {% endif %}
<input type="hidden" class="reset" name="favorite" value="0" placeholder="{{ chan_dict["favorite"] }}">
<td> <td>
<form id="Chan_Edit_Modify" method="post"> <form method="post" action="/api/channels?method=update&redirect=/channels_editor">
<button type="Submit" id="modify_{{ chan_dict["id"] }}">Modify</button> <input type="hidden" class="reset" name="id" value="{{ chan_dict["id"] }}">
</form> <input type="hidden" class="reset" name="name" value="{{ chan_dict["origin_name"] }}">
<input type="hidden" class="reset" name="callsign" value="{{ chan_dict["origin_callsign"] }}">
<form id="Chan_Edit_Reset" method="post"> <input type="hidden" class="reset" name="number" value="{{ chan_dict["origin_number"] }}">
<button type="Submit" id="reset_{{ chan_dict["id"] }}">Reset</button> <input type="hidden" class="reset" name="thumbnail" value="{{ chan_dict["origin_thumbnail"] }}">
<input type="hidden" class="reset" name="enabled" value=True>
<input type="submit" value="Reset">
</form> </form>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>