Skip to content

Commit f4cd1af

Browse files
Enabled hide and show username/password based on auth_type.
1 parent 59360e6 commit f4cd1af

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

sparkmagic/sparkmagic/controllerwidget/addendpointwidget.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def __init__(self, spark_controller, ipywidget_factory, ipython_display, endpoin
4444
description='Add endpoint'
4545
)
4646

47+
self.auth_type.on_trait_change(self.update_endpoint)
48+
4749
self.children = [self.ipywidget_factory.get_html(value="<br/>", width=widget_width),
4850
self.address_widget, self.auth_type, self.user_widget, self.password_widget,
4951
self.ipywidget_factory.get_html(value="<br/>", width=widget_width), self.submit_widget]
@@ -59,3 +61,12 @@ def run(self):
5961
# We need to call the refresh method because drop down in Tab 2 for endpoints wouldn't refresh with the new
6062
# value otherwise.
6163
self.refresh_method()
64+
65+
def update_endpoint(self):
66+
if self.auth_type.value == constants.NO_AUTH or self.auth_type.value == constants.AUTH_KERBEROS:
67+
self.user_widget.layout.display = 'none'
68+
self.password_widget.layout.display = 'none'
69+
else:
70+
self.user_widget.layout.display = 'flex'
71+
self.password_widget.layout.display = 'flex'
72+

sparkmagic/sparkmagic/magics/remotesparkmagics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def manage_spark(self, line, local_ns=None):
5454
@argument("-u", "--url", type=str, default=None, help="URL for Livy endpoint")
5555
@argument("-a", "--user", type=str, default="", help="Username for HTTP access to Livy endpoint")
5656
@argument("-p", "--password", type=str, default="", help="Password for HTTP access to Livy endpoint")
57-
@argument("-t", "--auth", type=str, default=conf.default_livy_endpoint_auth_type(),
58-
help="Auth type for HTTP access to Livy endpoint. [Kerberos, None, Basic Auth]")
57+
@argument("-t", "--auth", type=str, help="Auth type for HTTP access to Livy endpoint. [Kerberos, None, Basic Auth]")
5958
@argument("-l", "--language", type=str, default=None,
6059
help="Language for Livy session; one of {}".format(', '.join([LANG_PYTHON, LANG_SCALA, LANG_R])))
6160
@argument("command", type=str, default=[""], nargs="*", help="Commands to execute.")

0 commit comments

Comments
 (0)