+- Create Web HTML / JS generators [pyOpenRPA.Orchestrator.Web.Basic]

+- - def JSEscapeForHTMLInline(inJSStr): # Escape JS to the safe JS for the inline JS in HTML tags ATTENTION! Use it only if want to paste JS into HTML tag - not in <script>
+- - def HTMLLinkURL(inURLStr, inTitleStr=None, inColorStr=None): # Generate HTML code of the simple URL link by the URL
+- - def HTMLLinkJSOnClick(inJSOnClickStr, inTitleStr, inColorStr=None): # Generate HTML code of the simple URL link by the JS when onclick
dev-linux
Ivan Maslov 4 years ago
parent a0e85bb795
commit 026a152dfc

@ -0,0 +1,34 @@
# !ATTENTION - Current Control panel works only from pyOpenRPA v1.2.0!
from pyOpenRPA import Orchestrator
def CPRender(inGSettings):
lJSCheckVersion="""
lT = 9;
lY="123";
console.log(lT+1);
if (lT==9) {
alert(123)
}
"""
lResultDict={
"HeaderLeftText":"CP_TEST",
"HeaderRightText":"NAME",
"DataStorageKey":"", #Use key for set current dict in mGlobal.DataStorage["DataStorageKey"] on client side
"SubheaderText":"",
"BodyKeyValueList":[
{"Key": "HTMLLinkURL", "Value": Orchestrator.Web.Basic.HTMLLinkURL(inURLStr="test",inColorStr="orange")},
{"Key": "HTMLLinkJSOnClick", "Value": Orchestrator.Web.Basic.HTMLLinkJSOnClick(inJSOnClickStr=lJSCheckVersion, inTitleStr="!Click me!",inColorStr="green")},
],
"FooterText":"",
"FooterButtonX2List":[],
"FooterButtonX1List":[],
"GlobalStorage": "" # UNCOMMENT FOR DEBUG PURPOSE TO WATCH inGSettings on client side
}
return lResultDict
# Check in control panel, that process is runnning
#Orchestrator settings
def SettingsUpdate(inGSettings):
inGSettings["ControlPanelDict"]["RobotList"].append({"RenderFunction": CPRender, "KeyStr": "TEST"})
return inGSettings

@ -1,14 +1,23 @@
import psutil, datetime, logging, os, json
# !ATTENTION - Current Control panel works only from pyOpenRPA v1.2.0! # !ATTENTION - Current Control panel works only from pyOpenRPA v1.2.0!
from pyOpenRPA import Orchestrator
def ControlPanelRenderDict(inGSettings): def ControlPanelRenderDict(inGSettings):
# Example of the JS code in Python code
lJSCheckVersion = f"""
if (!('VersionStr' in mGlobal)) {{
window.location.reload(true);
}} else {{
if (mGlobal.VersionStr != "{inGSettings["VersionStr"]}") {{
window.location.reload(true);
}} else {{
$('div.orchestrator-version').html(mGlobal['VersionStr']);
}}
}}
"""
lResultDict={ lResultDict={
"HeaderLeftText":"Version check", "HeaderLeftText":"Version check",
"HeaderRightText":"Orchestrator", "HeaderRightText":"Orchestrator",
"DataStorageKey":"", #Use key for set current dict in mGlobal.DataStorage["DataStorageKey"] on client side "DataStorageKey":"", #Use key for set current dict in mGlobal.DataStorage["DataStorageKey"] on client side
"SubheaderText":"<script>if (!('VersionStr' in mGlobal)) {window.location.reload(true);} else { if (mGlobal.VersionStr != '"+inGSettings["VersionStr"]+"') { window.location.reload(true);} else { $('div.orchestrator-version').html(mGlobal['VersionStr']);}}</script>", "SubheaderText":f"<script>{lJSCheckVersion}</script>",
"BodyKeyValueList":[ "BodyKeyValueList":[
{"Key": "Client", "Value": '<div class="orchestrator-version" style="display:inline;"></div>'}, {"Key": "Client", "Value": '<div class="orchestrator-version" style="display:inline;"></div>'},
{"Key": "Server", "Value": inGSettings["VersionStr"]}, {"Key": "Server", "Value": inGSettings["VersionStr"]},

@ -39,6 +39,9 @@ if __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orc
from ControlPanel import CP_VersionCheck from ControlPanel import CP_VersionCheck
CP_VersionCheck.SettingsUpdate(inGSettings=gSettings) CP_VersionCheck.SettingsUpdate(inGSettings=gSettings)
from ControlPanel import CP_Test
CP_Test.SettingsUpdate(inGSettings=gSettings)
# Call the orchestrator def # Call the orchestrator def
Orchestrator.Orchestrator(inGSettings=gSettings) Orchestrator.Orchestrator(inGSettings=gSettings)

@ -0,0 +1,26 @@
# Escape JS to the safe JS for the inline JS in HTML tags ATTENTION! Use it only if want to paste JS into HTML tag - not in <script>
# USAGE: JSEscapeForHTMLInline(inJSStr="lTest=\"Hello World\"; alert(\"lTest\")")
def JSEscapeForHTMLInline(inJSStr):
lResult = inJSStr.replace("\"","&quot;")
return lResult
# Generate HTML code of the simple URL link by the URL
# USAGE: Orchestrator.Web.Basic.HTMLLinkURL(inURLStr="test",inColorStr="orange")
# USAGE: Basic.HTMLLinkURL(inURLStr="test",inColorStr="orange")
def HTMLLinkURL(inURLStr, inTitleStr=None, inColorStr=None):
lCSSStyleStr = ""
if not inTitleStr: inTitleStr = inURLStr
if inColorStr: lCSSStyleStr=f"style=\"color:{inColorStr}\""
lResult=f"<a {lCSSStyleStr} href=\"{inURLStr}\">{inTitleStr}</a>"
return lResult
# Generate HTML code of the simple URL link by the JS when onclick
# USAGE: Orchestrator.Web.Basic.HTMLLinkJSOnClick(inJSOnClickStr="",inColorStr="orange")
# USAGE: Basic.HTMLLinkJSOnClick(inJSOnClickStr="test",inColorStr="orange")
def HTMLLinkJSOnClick(inJSOnClickStr, inTitleStr, inColorStr=None):
lCSSStyleStr = ""
if inColorStr: lCSSStyleStr=f"style=\"color:{inColorStr}\""
inJSOnClickStr= JSEscapeForHTMLInline(inJSStr=inJSOnClickStr) # Escape some symbols for the inline JS
lResult=f"<a {lCSSStyleStr} onclick=\"{inJSOnClickStr}\">{inTitleStr}</a>"
return lResult

@ -1,7 +1,8 @@
r""" r"""
The OpenRPA package (from UnicodeLabs) The pyOpenRPA package (from UnicodeLabs)
""" """
from .Web import Basic
__all__ = [] __all__ = []
__author__ = 'Ivan Maslov <ivan.maslov@unicodelabs.ru>' __author__ = 'Ivan Maslov <ivan.maslov@unicodelabs.ru>'

@ -29,6 +29,11 @@
- Add new Orchestrator defs: - Add new Orchestrator defs:
- - def OrchestratorAccessUserUpdate(inGSettings, inADLoginStr, inADStr="", inADIsDefaultBool=True, inURLList=[], inCPAllowKeyList=[]): - Update user access - - def OrchestratorAccessUserUpdate(inGSettings, inADLoginStr, inADStr="", inADIsDefaultBool=True, inURLList=[], inCPAllowKeyList=[]): - Update user access
- - def OrchestratorAccessSuperTokenAdd(inGSettings, inSuperTokenStr): # Add supertoken for the all access (it is need for the robot communication without human) - - def OrchestratorAccessSuperTokenAdd(inGSettings, inSuperTokenStr): # Add supertoken for the all access (it is need for the robot communication without human)
- Create Web HTML / JS generators [pyOpenRPA.Orchestrator.Web.Basic]
- - def JSEscapeForHTMLInline(inJSStr): # Escape JS to the safe JS for the inline JS in HTML tags ATTENTION! Use it only if want to paste JS into HTML tag - not in <script>
- - def HTMLLinkURL(inURLStr, inTitleStr=None, inColorStr=None): # Generate HTML code of the simple URL link by the URL
- - def HTMLLinkJSOnClick(inJSOnClickStr, inTitleStr, inColorStr=None): # Generate HTML code of the simple URL link by the JS when onclick
[1.1.0] [1.1.0]
After 2 month test prefinal with new improovements (+RobotRDPActive in Orchestrator + Easy ControlPanelTemplate) After 2 month test prefinal with new improovements (+RobotRDPActive in Orchestrator + Easy ControlPanelTemplate)
Beta before 1.1.0 (new way of OpenRPA with improvements. Sorry, but no backward compatibility)/ Backward compatibility will start from 1.0.1 Beta before 1.1.0 (new way of OpenRPA with improvements. Sorry, but no backward compatibility)/ Backward compatibility will start from 1.0.1

Loading…
Cancel
Save