diff --git a/jupyter-openbis-extension/static/connectionDialog.js b/jupyter-openbis-extension/static/connectionDialog.js index 177372e0264f6654aca73113ffdd85b8b66d7e35..3663a50b07f77948887efafbcdfe1edb25ae5e2d 100644 --- a/jupyter-openbis-extension/static/connectionDialog.js +++ b/jupyter-openbis-extension/static/connectionDialog.js @@ -7,34 +7,34 @@ define( ], function (dialog, $, state, connections) { - var currentDownloadPath = null + let currentDownloadPath = null; function show_available_connections(env, data, conn_table) { if (!currentDownloadPath) { currentDownloadPath = data.cwd } - var table = document.createElement("TABLE") + let table = document.createElement("TABLE"); table.className = 'table-bordered table-striped table-condensed' - var thead = table.createTHead() - var thead_row = thead.insertRow(0) - var titles = ['', 'Name', 'URL', 'Status', 'Username / Password'] + let thead = table.createTHead(); + let thead_row = thead.insertRow(0) + let titles = ['', 'Name', 'URL', 'Status', 'Username / Password'] for (title of titles) { thead_row.insertCell().textContent = title } tbody = table.createTBody() - var getConnectionByName = function(name) { - for (connection of data.connections) { - if(connection.name === name) { - return connection; - } - } - } - + let getConnectionByName = function (name) { + for (connection of data.connections) { + if (connection.name === name) { + return connection; + } + } + }; + for (connection of data.connections) { - var conn = document.createElement("INPUT") + let conn = document.createElement("INPUT") conn.type = "radio" conn.name = "connection_name" conn.value = connection.name @@ -46,28 +46,28 @@ define( state.connection.candidateDTO = getConnectionByName(state.connection.candidateName); } - var row = tbody.insertRow() + let row = tbody.insertRow() row.insertCell().appendChild(conn) - var nameCell = row.insertCell() + let nameCell = row.insertCell() nameCell.textContent = connection.name nameCell.onclick = function () { - var radio = this.parentElement.firstElementChild.firstElementChild + let radio = this.parentElement.firstElementChild.firstElementChild radio.checked = 1 state.connection.candidateName = radio.value state.connection.candidateDTO = getConnectionByName(state.connection.candidateName); } - var urlCell = row.insertCell() + let urlCell = row.insertCell() urlCell.textContent = connection.url urlCell.onclick = function () { - var radio = this.parentElement.firstElementChild.firstElementChild + let radio = this.parentElement.firstElementChild.firstElementChild radio.checked = 1 state.connection.candidateName = radio.value state.connection.candidateDTO = getConnectionByName(state.connection.candidateName); } - var status_cell = row.insertCell() + let status_cell = row.insertCell() - var status_badge = document.createElement("SPAN") + let status_badge = document.createElement("SPAN") status_badge.id = connection.name + "-badge" status_badge.textContent = connection.status if (connection.status === "connected") { @@ -77,14 +77,14 @@ define( } status_cell.appendChild(status_badge) - var username = document.createElement("INPUT") + let username = document.createElement("INPUT") username.type = "text" username.name = "username" username.autocomplete = "on" username.value = connection.username username.setAttribute("form", connection.name) - var password = document.createElement("INPUT") + let password = document.createElement("INPUT") password.type = "password" password.name = "password" password.autocomplete = "current-password" @@ -92,11 +92,11 @@ define( password.setAttribute("form", connection.name) // Username / Password form - var pwform = document.createElement("FORM") + let pwform = document.createElement("FORM") pwform.id = connection.name pwform.onsubmit = function (event) { - var form_data = new FormData(this) - var status_badge = document.getElementById(this.id + "-badge") + let form_data = new FormData(this) + let status_badge = document.getElementById(this.id + "-badge") connections.connect(env, this.id, form_data.get("username"), form_data.get("password") ) @@ -128,7 +128,7 @@ define( } - var connect_button = document.createElement("BUTTON") + let connect_button = document.createElement("BUTTON") connect_button.className = "btn btn-primary btn-xs" connect_button.textContent = "connect" @@ -136,11 +136,11 @@ define( pwform.appendChild(password) pwform.appendChild(connect_button) - var pwCell = row.insertCell() + let pwCell = row.insertCell() pwCell.appendChild(pwform) pwCell.onclick = function () { - var radio = this.parentElement.firstElementChild.firstElementChild + let radio = this.parentElement.firstElementChild.firstElementChild radio.checked = 1 state.connection.candidateName = radio.value state.connection.candidateDTO = getConnectionByName(state.connection.candidateName); @@ -148,12 +148,12 @@ define( } // add row for new connection - var row = tbody.insertRow() + let row = tbody.insertRow() - var conn_form = document.createElement("FORM") + let conn_form = document.createElement("FORM") conn_form.id = "new_connection" conn_form.onsubmit = function (event) { - var inputs = document.querySelectorAll("input[form=new_connection]") + let inputs = document.querySelectorAll("input[form=new_connection]") data = {} for (input of inputs) { @@ -176,7 +176,7 @@ define( }) return false } - var conn_name = document.createElement("INPUT") + let conn_name = document.createElement("INPUT") conn_name.type = "input" conn_name.name = "connection_name" conn_name.setAttribute("form", conn_form.id) @@ -184,7 +184,7 @@ define( row.insertCell().appendChild(conn_form) row.insertCell().appendChild(conn_name) - var conn_url = document.createElement("INPUT") + let conn_url = document.createElement("INPUT") conn_url.type = "input" conn_url.name = "url" conn_url.setAttribute("form", conn_form.id) @@ -192,21 +192,21 @@ define( row.insertCell().appendChild(conn_url) row.insertCell() - var username = document.createElement("INPUT") + let username = document.createElement("INPUT") username.autocomplete = "off" username.type = "text" username.name = "username" username.setAttribute("form", conn_form.id) username.placeholder = "username" - var password = document.createElement("INPUT") + let password = document.createElement("INPUT") password.type = "password" password.name = "password" password.autocomplete = "new-password" password.setAttribute("form", conn_form.id) - var create_btn = document.createElement("BUTTON") + let create_btn = document.createElement("BUTTON") create_btn.setAttribute("form", conn_form.id) create_btn.textContent = "create" - var uname_pw_cell = row.insertCell() + let uname_pw_cell = row.insertCell() uname_pw_cell.appendChild(username) uname_pw_cell.appendChild(password) uname_pw_cell.appendChild(create_btn) @@ -224,13 +224,12 @@ define( help_index: '', handler: function (env) { conn_table = document.createElement("DIV") - var dst_title = document.createElement("STRONG") + let dst_title = document.createElement("STRONG") dst_title.textContent = "DataSet type" - var dataset_types = document.createElement("SELECT") + let dataset_types = document.createElement("SELECT") dataset_types.id = "dataset_type" dataset_types.className = "form-control select-xs" - var input_fields = document.createElement("DIV") conn_table.id = "openbis_connections" connections.list(env) @@ -241,7 +240,7 @@ define( alert(data.status) }) - var uploadDialogBox = $('<div/>').append(conn_table) + let uploadDialogBox = $('<div/>').append(conn_table) function onOk() { state.connection.name = state.connection.candidateName