|
@@ -51,7 +51,7 @@ class labkeyBrowserWidget(ScriptedLoadableModuleWidget):
|
|
|
|
|
|
connectionFormLayout = qt.QFormLayout(connectionCollapsibleButton)
|
|
connectionFormLayout = qt.QFormLayout(connectionCollapsibleButton)
|
|
|
|
|
|
- self.configDir=os.path.join(getHomeDir(),".labkey")
|
|
|
|
|
|
+ self.configDir=os.path.join(os.path.expanduser('~'),".labkey")
|
|
|
|
|
|
self.serverURL=qt.QLineEdit("https://merlin.fmf.uni-lj.si")
|
|
self.serverURL=qt.QLineEdit("https://merlin.fmf.uni-lj.si")
|
|
self.serverURL.textChanged.connect(self.updateServerURL)
|
|
self.serverURL.textChanged.connect(self.updateServerURL)
|
|
@@ -59,7 +59,7 @@ class labkeyBrowserWidget(ScriptedLoadableModuleWidget):
|
|
#copy initial setting
|
|
#copy initial setting
|
|
self.updateServerURL(self.serverURL.text);
|
|
self.updateServerURL(self.serverURL.text);
|
|
|
|
|
|
- self.startDir=os.path.join(getHomeDir(),"temp/crt")
|
|
|
|
|
|
+ self.startDir=os.path.join(os.path.expanduser('~'),"temp/crt")
|
|
|
|
|
|
self.userCertButton=qt.QPushButton("Load")
|
|
self.userCertButton=qt.QPushButton("Load")
|
|
self.userCertButton.toolTip="Load user certificate (crt)"
|
|
self.userCertButton.toolTip="Load user certificate (crt)"
|
|
@@ -83,8 +83,13 @@ class labkeyBrowserWidget(ScriptedLoadableModuleWidget):
|
|
self.loadConfigButton=qt.QPushButton("Load configuration")
|
|
self.loadConfigButton=qt.QPushButton("Load configuration")
|
|
self.loadConfigButton.toolTip="Load configuration"
|
|
self.loadConfigButton.toolTip="Load configuration"
|
|
self.loadConfigButton.connect('clicked(bool)',self.onLoadConfigButtonClicked)
|
|
self.loadConfigButton.connect('clicked(bool)',self.onLoadConfigButtonClicked)
|
|
- connectionFormLayout.addRow("Connection:",self.loadConfigButton)
|
|
|
|
|
|
+ connectionFormLayout.addRow("Configuration:",self.loadConfigButton)
|
|
|
|
|
|
|
|
+ self.saveConfigButton=qt.QPushButton("Save configuration")
|
|
|
|
+ self.saveConfigButton.toolTip="Save configuration"
|
|
|
|
+ self.saveConfigButton.clicked.connect(self.onSaveConfigButtonClicked)
|
|
|
|
+ connectionFormLayout.addRow("Configuration:",self.saveConfigButton)
|
|
|
|
+
|
|
self.initButton=qt.QPushButton("Init")
|
|
self.initButton=qt.QPushButton("Init")
|
|
self.initButton.toolTip="Initialize connection to the server"
|
|
self.initButton.toolTip="Initialize connection to the server"
|
|
self.initButton.connect('clicked(bool)',self.onInitButtonClicked)
|
|
self.initButton.connect('clicked(bool)',self.onInitButtonClicked)
|
|
@@ -99,6 +104,9 @@ class labkeyBrowserWidget(ScriptedLoadableModuleWidget):
|
|
self.authPass.textChanged.connect(self.updateAuthPass)
|
|
self.authPass.textChanged.connect(self.updateAuthPass)
|
|
connectionFormLayout.addRow("Labkey password: ", self.authPass)
|
|
connectionFormLayout.addRow("Labkey password: ", self.authPass)
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
fileDialogCollapsibleButton = ctk.ctkCollapsibleButton()
|
|
fileDialogCollapsibleButton = ctk.ctkCollapsibleButton()
|
|
fileDialogCollapsibleButton.text = "Remote files"
|
|
fileDialogCollapsibleButton.text = "Remote files"
|
|
self.layout.addWidget(fileDialogCollapsibleButton)
|
|
self.layout.addWidget(fileDialogCollapsibleButton)
|
|
@@ -240,12 +248,57 @@ class labkeyBrowserWidget(ScriptedLoadableModuleWidget):
|
|
def onLoadConfigButtonClicked(self):
|
|
def onLoadConfigButtonClicked(self):
|
|
filename=qt.QFileDialog.getOpenFileName(None,'Open configuration file (JSON)',
|
|
filename=qt.QFileDialog.getOpenFileName(None,'Open configuration file (JSON)',
|
|
self.configDir, '*.json')
|
|
self.configDir, '*.json')
|
|
- self.network.parseConfig(filename)
|
|
|
|
- self.serverURL.setText(self.network.hostname)
|
|
|
|
- self.authName.setText(self.network.auth_name)
|
|
|
|
- self.authPass.setText(self.network.auth_pass)
|
|
|
|
|
|
+ self.network.parseConfig(filename,self)
|
|
|
|
+ #self.serverURL.setText(self.network.hostname)
|
|
|
|
+ #self.authName.setText(self.network.auth_name)
|
|
|
|
+ #self.authPass.setText(self.network.auth_pass)
|
|
|
|
|
|
self.loadConfigButton.setText(os.path.basename(filename))
|
|
self.loadConfigButton.setText(os.path.basename(filename))
|
|
|
|
+
|
|
|
|
+ def onSaveConfigButtonClicked(self):
|
|
|
|
+ connectionConfig={}
|
|
|
|
+
|
|
|
|
+ #setup SSL
|
|
|
|
+ if self.privateKeyButton.text=="Load" or\
|
|
|
|
+ self.userCertButton.text=="Load" or\
|
|
|
|
+ self.caCertButton.text=="Load":
|
|
|
|
+ #no ssl
|
|
|
|
+ pass
|
|
|
|
+ else:
|
|
|
|
+ sslSetup={}
|
|
|
|
+ sslSetup['user']=self.userCertButton.text
|
|
|
|
+ sslSetup['key']=self.privateKeyButton.text
|
|
|
|
+ sslSetup['ca']=self.caCertButton.text
|
|
|
|
+ sslSetup['keyPwd']=self.pwd
|
|
|
|
+ connectionConfig['SSL']=sslSetup
|
|
|
|
+ connectionConfig["host"]=self.serverURL.text
|
|
|
|
+ connectionConfig["context"]="labkey"
|
|
|
|
+ labkeySetup={}
|
|
|
|
+ labkeySetup['user']=self.authName.text
|
|
|
|
+ labkeySetup['password']=self.authPass.text
|
|
|
|
+ connectionConfig['labkey']=labkeySetup
|
|
|
|
+
|
|
|
|
+ orthancSetup={}
|
|
|
|
+ if self.serverURL.text.find('merlin')>-1:
|
|
|
|
+ orthancSetup['server']='https://orthanc.fmf.uni-lj.si'
|
|
|
|
+ if self.serverURL.text.find('onko-nix')>-1:
|
|
|
|
+ orthancSetup['server']='http://onko-nix.onko-i.si:8042'
|
|
|
|
+ orthancSetup['user']='ask'
|
|
|
|
+ orthancSetup['password']='askPassword'
|
|
|
|
+ connectionConfig['orthanc']=orthancSetup
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ fhome=os.path.expanduser('~')
|
|
|
|
+ labkeyDir=os.path.join(fhome,".labkey")
|
|
|
|
+ if not os.path.isdir(labkeyDir):
|
|
|
|
+ os.mkdir(labkeyDir)
|
|
|
|
+ fconfig=os.path.join(labkeyDir,'network.json')
|
|
|
|
+
|
|
|
|
+ with open(fconfig,'w') as f:
|
|
|
|
+ json.dump(connectionConfig,f,indent=3)
|
|
|
|
+
|
|
|
|
+ print("Done")
|
|
|
|
+
|
|
|
|
|
|
def onInitButtonClicked(self):
|
|
def onInitButtonClicked(self):
|
|
if self.serverURL.text.find("https")==0:
|
|
if self.serverURL.text.find("https")==0:
|
|
@@ -260,6 +313,10 @@ class labkeyBrowserWidget(ScriptedLoadableModuleWidget):
|
|
|
|
|
|
|
|
|
|
self.network.initRemote()
|
|
self.network.initRemote()
|
|
|
|
+ if self.network.getCSRF()==None:
|
|
|
|
+ self.initButton.setStyleSheet("background-color: red")
|
|
|
|
+ else:
|
|
|
|
+ self.initButton.setStyleSheet("background-color: green")
|
|
|
|
|
|
def updateAuthName(self,txt):
|
|
def updateAuthName(self,txt):
|
|
self.network.auth_name=txt
|
|
self.network.auth_name=txt
|