diff --git a/rrd/__init__.py b/rrd/__init__.py index 6d54f92dc..9bdff81eb 100755 --- a/rrd/__init__.py +++ b/rrd/__init__.py @@ -86,7 +86,6 @@ def __init__(self, sh): self.logger.error("{}: Unable to import Python package 'rrdtool'".format(self.get_fullname())) return - self.init_webinterface() return def run(self): @@ -359,114 +358,3 @@ def _create(self, rrd): self.logger.debug("Creating rrd ({0}) for {1}.".format(rrd['rrdb'], rrd['item'])) except Exception as e: self.logger.warning("Error creating rrd ({0}) for {1}: {2}".format(rrd['rrdb'], rrd['item'], e)) - - # ToDo: - # create a meaningful webinterface - - def init_webinterface(self): - """" - Initialize the web interface for this plugin - - This method is only needed if the plugin is implementing a web interface - """ - try: - self.mod_http = Modules.get_instance().get_module( - 'http') # try/except to handle running in a core version that does not support modules - except: - self.mod_http = None - if self.mod_http == None: - self.logger.error("Not initializing the web interface") - return False - - import sys - if not "SmartPluginWebIf" in list(sys.modules['lib.model.smartplugin'].__dict__): - self.logger.warning("Web interface needs SmartHomeNG v1.5 and up. Not initializing the web interface") - return False - - # set application configuration for cherrypy - webif_dir = self.path_join(self.get_plugin_dir(), 'webif') - config = { - '/': { - 'tools.staticdir.root': webif_dir, - }, - '/static': { - 'tools.staticdir.on': True, - 'tools.staticdir.dir': 'static' - } - } - - # Register the web interface as a cherrypy app - self.mod_http.register_webif(WebInterface(webif_dir, self), - self.get_shortname(), - config, - self.get_classname(), self.get_instance_name(), - description='') - - return True - - -# ------------------------------------------ -# Webinterface of the plugin -# ------------------------------------------ - -import cherrypy -from jinja2 import Environment, FileSystemLoader - - -class WebInterface(SmartPluginWebIf): - - def __init__(self, webif_dir, plugin): - """ - Initialization of instance of class WebInterface - - :param webif_dir: directory where the webinterface of the plugin resides - :param plugin: instance of the plugin - :type webif_dir: str - :type plugin: object - """ - self.logger = logging.getLogger(__name__) - self.webif_dir = webif_dir - self.plugin = plugin - self.tplenv = self.init_template_environment() - - self.items = Items.get_instance() - - @cherrypy.expose - def index(self, reload=None): - """ - Build index.html for cherrypy - - Render the template and return the html file to be delivered to the browser - - :return: contents of the template after beeing rendered - """ - tmpl = self.tplenv.get_template('index.html') - # add values to be passed to the Jinja2 template eg: tmpl.render(p=self.plugin, interface=interface, ...) - return tmpl.render(p=self.plugin, items=sorted(self.items.return_items(), key=lambda k: str.lower(k['_path']))) - - - @cherrypy.expose - def get_data_html(self, dataSet=None): - """ - Return data to update the webpage - - For the standard update mechanism of the web interface, the dataSet to return the data for is None - - :param dataSet: Dataset for which the data should be returned (standard: None) - :return: dict with the data needed to update the web page. - """ - if dataSet is None: - # get the new data - data = {} - - # data['item'] = {} - # for i in self.plugin.items: - # data['item'][i]['value'] = self.plugin.getitemvalue(i) - # - # return it as json the the web page - # try: - # return json.dumps(data) - # except Exception as e: - # self.logger.error("get_data_html exception: {}".format(e)) - return {} - diff --git a/rrd/webif/static/img/readme.txt b/rrd/webif/static/img/readme.txt deleted file mode 100755 index 1a7c55eef..000000000 --- a/rrd/webif/static/img/readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -This directory is for storing images that are used by the web interface. - -If you want to have your own logo on the top of the web interface, store it here and name it plugin_logo.. - -Extension can be png, svg or jpg - diff --git a/rrd/webif/templates/index.html b/rrd/webif/templates/index.html deleted file mode 100755 index d59434db8..000000000 --- a/rrd/webif/templates/index.html +++ /dev/null @@ -1,116 +0,0 @@ -{% extends "base_plugin.html" %} - -{% set logo_frame = false %} - - -{% set update_interval = 0 %} - - -{% block pluginscripts %} - -{% endblock pluginscripts %} - - -{% block headtable %} - - - - - - - - - - - -
{{ _('Datenpunktabstand') }}{{ p.step }} {{ _('Sekunden') }}{{ _('Verzeichnis') }}{{ p._rrd_dir }}
- -{% endblock headtable %} - - - -{% block buttons %} -{% if 1==2 %} -
- -
-{% endif %} -{% endblock %} - - -{% set tabcount = 1 %} - - -{% set item_count = p._rrds | count %} -{% if item_count==0 %} - {% set start_tab = 2 %} -{% endif %} - - - -{% set tab1title = "" ~ p.get_shortname() ~ " Items (" ~ item_count ~ ")" %} -{% block bodytab1 %} -
- {% for item in p._rrds %} -
{{ item }}
{{ p._rrds[item] }}
- - {% endfor %} -
-{% endblock bodytab1 %} - - - -{% set tab2title = "" ~ p.get_shortname() ~ " Geräte (" ~ device_count ~ ")" %} -{% block bodytab2 %} - -
- {{ _('Hier kommt der Inhalt des Webinterfaces hin.') }} -
-{% endblock bodytab2 %} - - - -{% block bodytab3 %} -{% endblock bodytab3 %} - - - -{% block bodytab4 %} -{% endblock bodytab4 %}