diff --git a/templates/index.html b/templates/index.html index 9bdf1fa70e9e1cb1192b8d4f9f7d965e48f8525b..2645ef99824e2deeea6f249ba4122dd68d5bba20 100644 --- a/templates/index.html +++ b/templates/index.html @@ -20,53 +20,69 @@ var rs=document.getElementById("routerselect"); var cs=document.getElementById("commandselect"); + + var commondict_${cp} = ' \ + + \ + + '; + + - document.getElementById("paramsect").innerHTML=' \ + document.getElementById("paramsect").innerHTML=' \ -
\ - \ +
\ + \ + + \ + - \ + \ - \ + \ - \ + \ -
\ +
\
'; + + + + + + + + document.getElementById("param${pidx}").selectedIndex=${paridx}; + + + document.getElementById("param${pidx}").selectedIndex=${paridx}; + + + + + + }
@@ -77,14 +93,14 @@ var rs=document.getElementById("routerselect"); if(rs.options[rs.selectedIndex].value==$ridx) { - document.getElementById("commandselect").innerHTML=' \ + document.getElementById("commandselect").innerHTML=' \ - \ + \ - \ + \ '; diff --git a/ulg.py b/ulg.py index 9bfb729f0a039986be24e10a810c2c125db06dc9..e2c776b8f07ab5cb03d7cce8cd2a07462b90e2ba 100755 --- a/ulg.py +++ b/ulg.py @@ -28,7 +28,7 @@ import re import fcntl import traceback import urllib -import md5 +import hashlib import time import random @@ -90,7 +90,7 @@ class Session(object): self.save() def __genSessionId__(self): - return md5.new(str(time.time())+str(random.randint(1,1000000))).hexdigest() + return hashlib.md5(str(time.time())+str(random.randint(1,1000000))).hexdigest() def save(self): try: @@ -462,6 +462,16 @@ class ULGCgi: else: return defaults.refresh_interval + def getCommonParams(self): + res = {} + for r in config.routers: + for c in r.listCommands(): + for ps in c.getParamSpecs(): + if(ps.getType() == 'commonselect'): + res[ps.getID()] = ps + + return res + def HTTPRedirect(self,url): return """ @@ -531,6 +541,7 @@ class ULGCgi: return template.generate(defaults=defaults, routers=config.routers, + commonparams=self.getCommonParams(), default_routerid=routerid, default_commandid=commandid, default_sessionid=sessionid, @@ -617,6 +628,7 @@ class ULGCgi: template = self.loader.load(defaults.index_template_file) return template.generate(defaults=defaults, routers=config.routers, + commonparams=self.getCommonParams(), default_routerid=session.getRouterId(), default_commandid=session.getCommandId(), default_params=session.getParameters(), @@ -639,6 +651,7 @@ class ULGCgi: return template.generate(defaults=defaults, routers=config.routers, + commonparams=self.getCommonParams(), default_routerid=0, default_commandid=0, default_sessionid=None, @@ -657,6 +670,7 @@ class ULGCgi: return template.generate(defaults=defaults, routers=config.routers, + commonparams=self.getCommonParams(), default_routerid=0, default_commandid=0, default_sessionid=None, diff --git a/ulgmodel.py b/ulgmodel.py index 9d8547fdac3d56c74cf8d029e75beb4f2e73e0ba..2553fac44a06de9be2612a64e376355dcf94f051 100644 --- a/ulgmodel.py +++ b/ulgmodel.py @@ -301,6 +301,20 @@ class SelectionParameter(TextParameter): else: raise Exception("Invalid input encountered: Check did not passed.") +class CommonSelectionParameter(SelectionParameter): + def __init__(self,oid,option_tuples=[],name=defaults.STRING_PARAMETER,default=None): + SelectionParameter.__init__(self,option_tuples,name,default) + self.setID(oid) + + def getType(self): + return 'commonselect' + + def setID(self,oid): + self.oid = oid + + def getID(self): + return self.oid + class TextCommand(object): def __init__(self,command,param_specs=[],name=None):