Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smartvisu: Improve web interface #826

Merged
merged 6 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion smartvisu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

class SmartVisu(SmartPlugin):

PLUGIN_VERSION="1.8.13"
PLUGIN_VERSION="1.8.14"
ALLOW_MULTIINSTANCE = True

visu_definition = None
Expand Down Expand Up @@ -184,6 +184,7 @@ def parse_item(self, item):
item.expand_relativepathes('sv_widget2', "'", "'")
item.expand_relativepathes('sv_nav_aside', "'", "'")
item.expand_relativepathes('sv_nav_aside2', "'", "'")
self.add_item(item)


def parse_logic(self, logic):
Expand Down
8 changes: 2 additions & 6 deletions smartvisu/locale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@ plugin_translations:
# Translations for the plugin specially for the web interface
'Websocket Protokoll': {'de': '=', 'en': 'Websocket protocol'}
'Standard Zugriff': {'de': '=', 'en': 'Default Access'}
'Standard Zugriff (acl)': {'de': '=', 'en': 'Default Access (acl)'}
'Definitions-Abfrage': {'de': '=', 'en': 'Query definitions'}
'Erlaubt': {'de': '=', 'en': 'Allowed'}
'Verboten': {'de': '=', 'en': 'Forbidden'}
'Anzahl Clients': {'de': '=', 'en': 'Number of clients'}

'Visu Client': {'de': '=', 'en': '='}
'IP': {'de': '=', 'en': '='}
'Port': {'de': '=', 'en': '='}
'Protokoll': {'de': '=', 'en': 'Protocol'}
'Port (ws / wss)': {'de': '=', 'en': '='}
'Client Software': {'de': '=', 'en': '='}
'Browser': {'de': '=', 'en': '='}

'Keine aktiven Clients': {'de': '=', 'en': 'No active clients'}

'Visu Zugriff': {'de': '=', 'en': 'Visu Access'}
'aktiv': {'de': '=', 'en': 'enabled'}
'nicht aktiv': {'de': '=', 'en': 'disabled'}
'erlaubt': {'de': '=', 'en': 'enabled'}
'nicht erlaubt': {'de': '=', 'en': 'disabled'}

5 changes: 2 additions & 3 deletions smartvisu/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ plugin:
de: 'smartVISU Unterstützung: Autogenerierung von Seiten; Widget Handling'
en: 'Support for smartVISU: Automatic generation of pages; widget handling'
maintainer: msinn
tester: wvhn
tester: wvhn, onkelandy
state: ready
#keywords: iot xyz
#documentation: ''
support: https://knx-user-forum.de/forum/supportforen/smarthome-py/1586800-support-thread-für-das-smartvisu-plugin

version: 1.8.13 # Plugin version
version: 1.8.14 # Plugin version
sh_minversion: 1.9.3.5 # minimum shNG version to use this plugin
# sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest)
py_minversion: 3.6 # minimum Python version to use for this plugin
Expand Down Expand Up @@ -233,4 +233,3 @@ plugin_functions:
description:
de: "Falls angegeben, werden nur Clients (Browser) die auf dem Host mit der angegebenen IP Adresse laufen angewiesen die Seite zu wechseln. "
en: "If specified, only clients (browsers) running on the host with the specified ip address are instructed to change the page."

44 changes: 22 additions & 22 deletions smartvisu/webif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ def index(self, reload=None):
plgitems.append(item)

plglogics = []
for logic in self.logics.return_logics():
plglogics.append(self.logics.get_logic_info(logic))

if self.logics:
for logic in self.logics.return_logics():
plglogics.append(self.logics.get_logic_info(logic))
pagelength = self.plugin.get_parameter_value('webif_pagelength')
tmpl = self.tplenv.get_template('index.html')
return tmpl.render(p=self.plugin,
webif_pagelength=self.plugin.get_parameter_value('webif_pagelength'),
webif_pagelength=pagelength,
items=sorted(plgitems, key=lambda k: str.lower(k['_path'])),
logics=sorted(plglogics, key=lambda k: str.lower(k['name'])),
clients=clients_sorted, client_count=len(clients_sorted))
Expand All @@ -137,23 +138,18 @@ def get_data_html(self, dataSet=None):
:return: dict with the data needed to update the web page.
"""
if dataSet is None:
result_array = []

# callect data for 'items' tab
item_list = []
# for item in self.plugin.get_item_list():
# item_config = self.plugin.get_item_config(item)
# value_dict = {}
# value_dict['path'] = item.id()
# value_dict['type'] = item.type()
# value_dict['not_discovered'] = (item_config['bus'] == '')
# value_dict['sensor_addr'] = item_config['sensor_addr']
# value_dict['deviceclass'] = item_config['deviceclass']
# value_dict['value'] = item()
# value_dict['value_unit'] = item_config['unit']
# value_dict['last_update'] = item.property.last_update.strftime('%d.%m.%Y %H:%M:%S')
# value_dict['last_change'] = item.property.last_change.strftime('%d.%m.%Y %H:%M:%S')
# item_list.append(value_dict)
item_dict = {}
for item in self.plugin.get_item_list():
item_config = self.plugin.get_item_config(item)
value_dict = {}
value_dict['type'] = item.property.type
if ('visu_acl' in item.conf):
value_dict['acl'] = item.conf.get('visu_acl')
value_dict['value'] = item.property.value
value_dict['last_update'] = item.property.last_update.strftime('%d.%m.%Y %H:%M:%S')
value_dict['last_change'] = item.property.last_change.strftime('%d.%m.%Y %H:%M:%S')
item_dict[item.property.path] = value_dict

# callect data for 'clients' tab
client_list = []
Expand All @@ -174,8 +170,13 @@ def get_data_html(self, dataSet=None):
value_dict['browserversion'] = clientinfo.get('browserversion', '')
client_list.append(value_dict)

result = {'items': item_list, 'clients': client_list}
plglogics = []
if self.logics:
for logic in self.logics.return_logics():
plglogics.append(self.logics.get_logic_info(logic))

result = {'items': item_dict, 'clients': client_list, 'logics': plglogics}
self.logger.error(result)
# send result to wen interface
try:
data = json.dumps(result)
Expand All @@ -187,4 +188,3 @@ def get_data_html(self, dataSet=None):
self.logger.error(f"get_data_html exception: {e}")

return {}

Loading