diff --git a/jupyterhub_custom_config.yaml b/jupyterhub_custom_config.yaml index 1841b8386e613c925f0e8ba3ac25f5073d3fc1ab..946a5321c1f65e1d7e84200e85f7ad3947311957 100644 --- a/jupyterhub_custom_config.yaml +++ b/jupyterhub_custom_config.yaml @@ -182,6 +182,7 @@ authStateKeys: - incidentCheck - binderRepos - share + - mapSystems selfapihandler: allowedAuthStateKeys: - access_token @@ -366,11 +367,15 @@ services: show: true type: dropdown options: + values: + - A + - B + - C values_func: get_hpc_system invalidFeedback: "Please choose a System." label: type: text - value: "System--:" + value: "System" onChangeUpdate: - account - key: account @@ -392,7 +397,7 @@ services: invalidFeedback: "Please choose a Project." label: type: text - value: "Project" + value: "ProjectABC" onChangeUpdate: - partition - key: partition diff --git a/static/js/custom.js b/static/js/custom.js index 6bf44cbe952e7553f746eb96cc4a919166f47257..95c220052902c9ef95fcf37528475fa0cc1ac92a 100644 --- a/static/js/custom.js +++ b/static/js/custom.js @@ -9,6 +9,22 @@ define(["jquery"], function ( function get_hpc_system(software_key, tab_key, input_key, values) { const systems = ["JUWELS", "JURECA", "JEDI", "JUSUF", "DEEP", "JSC-Cloud"]; + const entitlements = getEntitlements(); + const mapSystems = getMapSystems(); + console.log(mapSystems); + const resPattern = /^urn:(.+?(?=:res:)):res:(?<systempartition>[^:]+):[^:]+:act:[^:]+:[^:]+$/; + const systemPartitions = []; + entitlements.forEach(entitlement => { + const match = entitlement.match(resPattern); + if (match) { + const lowersystempartition = match.groups.systempartition.toLowerCase(); + const system = mapSystems?.[lowersystempartition]; + if ( system && !systemPartitions.includes(system) ) { + systemPartitions.push(system); + } + } + }); + console.log(systemPartitions); return systems; } return functions; diff --git a/templates/home.html b/templates/home.html index dde057e4a62346b6522265dc406c821c3123e7a3..b37808aad30948a90276261446a31cfa4650eaef 100644 --- a/templates/home.html +++ b/templates/home.html @@ -143,6 +143,14 @@ function getHostname() { return {{hostname | tojson}} || {}; } +function getEntitlements() { + return {{auth_state.get("entitlements", []) | tojson}} || []; +} + +function getMapSystems() { + return {{custom_config.get("mapSystems", {}) | tojson }}; +} + function getDropdownOptions() { return {{auth_state.get("options_form", {}).get("dropdown_list", {}) | tojson}}; } @@ -340,7 +348,9 @@ require(["jquery", "jhapi", "home/utils", "home/dropdown-options", "home/lab-con select.append(`<option value="{{versionName}}">{{versionOptions.get("name", versionName)}}</option>`); {%- endfor %} select.val(defaultOptionValue); - select.trigger("change"); + setTimeout(() => { + select.trigger("change"); + }, 50); {# dropdowns.updateServices("{{ software_key }}", "{{ software }}-{{ new }}"); #}