From 40ad4038ff4e3875a5a7ac8bd5b92fae10ca5f09 Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Wed, 25 Oct 2023 18:15:57 +0200 Subject: [PATCH] blockly plugin: load language in blockly based on shng language --- blockly/webif/__init__.py | 5 ++++- blockly/webif/static/js/logics_blockly_code.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/blockly/webif/__init__.py b/blockly/webif/__init__.py index 6755d8874..d48bfe62d 100755 --- a/blockly/webif/__init__.py +++ b/blockly/webif/__init__.py @@ -113,6 +113,7 @@ def index_html(self, cmd='', filename='', logicname='', v=0): self.logic_filename = filename self.logicname = logicname self.logger.info("index_html: self.logicname = '{}', self.logic_filename = '{}'".format(self.logicname, self.logic_filename)) + language = self._sh.get_defaultlanguage() tmpl = self.tplenv.get_template('blockly.html') return tmpl.render(smarthome=self._sh, @@ -120,6 +121,7 @@ def index_html(self, cmd='', filename='', logicname='', v=0): dyn_sh_toolbox=self._DynToolbox(self._sh), cmd=self.cmd, logicname=logicname, + lang=language, timestamp=str(time.time())) @@ -148,7 +150,7 @@ def edit_html(self, cmd='', filename='', logicname='', v=0): self.logic_filename = filename self.logicname = logicname self.logger.info("edit_html: self.logicname = '{}', self.logic_filename = '{}'".format(self.logicname, self.logic_filename)) - + language = self._sh.get_defaultlanguage() tmpl = self.tplenv.get_template('blockly.html') return tmpl.render(smarthome=self._sh, @@ -156,6 +158,7 @@ def edit_html(self, cmd='', filename='', logicname='', v=0): dyn_sh_toolbox=self._DynToolbox(self._sh), cmd=self.cmd, logicname=logicname, + lang=language, timestamp=str(time.time())) diff --git a/blockly/webif/static/js/logics_blockly_code.js b/blockly/webif/static/js/logics_blockly_code.js index 0950d63bc..8490e26e0 100755 --- a/blockly/webif/static/js/logics_blockly_code.js +++ b/blockly/webif/static/js/logics_blockly_code.js @@ -1,3 +1,4 @@ + /** * Create a namespace for the application. */ @@ -74,7 +75,6 @@ Code.saveBlocks = function() { if (topblock.data == "sh_logic_main") { logicname = Code.workspace.getTopBlocks()[0].getFieldValue('LOGIC_NAME') }; - //Code.workspace; var pycode = Blockly.Python.workspaceToCode(Code.workspace); var xmldom = Blockly.Xml.workspaceToDom(Code.workspace); var xmltxt = Blockly.utils.xml.domToText(xmldom);