Skip to content
Snippets Groups Projects
Select Git revision
  • 172333286a4cb5cc5cc983d21ef8cd36b16483c3
  • jupyterhub-share-base-production default protected
  • maintenance-files protected
  • jupyterhub-share-base-dev1
  • 21-frontend-user-workshop-website-collection
  • jupyterhub-share-base-staging
  • jupyterhub-share-base-dev2
  • jupyterhub-login-frontend
  • tmp
  • tmp2
  • tmp3
  • jupyterhub-dev2-enum
  • 4-runtime-limitation-if-reservation-is-selected
  • 4-runtime-limitation-if-reservation-is-selected-2
  • archived-jupyterhub-files-production
  • archived-jupyterhub-jupyterjsc-production
  • archived-maintenance-files-production
  • archived-maintenance-files-staging
  • archive/master
  • archive/css_rework
20 results

dropdown-options.js

Blame
  • dropdown-options.js 20.95 KiB
    define(["jquery", "home/utils"], function (
      $,
      utils
    ) {
      "use strict";
    
      var updateServices = function (id, value) {
        const dropdownOptions = getDropdownOptions();
        const serviceInfo = getServiceInfo();
    
        let select = $(`select#${id}-version-select`);
        const currentVal = select.val();
        resetInputElement(select);
        for (const service of Object.keys(dropdownOptions).sort().reverse()) {
          var serviceName = (serviceInfo.JupyterLab.options[service] || {}).name || service;
          select.append(`<option value="${service}">${serviceName}</option>`);
        }
        if (!value) value = serviceInfo.JupyterLab.defaultOption;
        updateLabConfigSelect(select, value, currentVal);
      }
    
      var updateSystems = function (id, service, value) {
        const dropdownOptions = getDropdownOptions();
        const systemInfo = getSystemInfo();
    
        let select = $(`select#${id}-system-select`);
        const currentVal = select.val();
        resetInputElement(select);
    
        const systemsAllowed = dropdownOptions[service] || {};
        for (const system of Object.keys(systemInfo).sort((a, b) => (systemInfo[a]["weight"] || 99) < (systemInfo[b]["weight"] || 99) ? -1 : 1)) {
          if (system in systemsAllowed) select.append(`<option value="${system}">${system}</option>`);
        }
        updateLabConfigSelect(select, value, currentVal);
      }
    
      var updateFlavors = function (id, service, system, value) {
        const systemInfo = getSystemInfo();
        const backendInfo = getBackendServiceInfo();
    
        let select = $(`select#${id}-flavor-select`);
        const currentVal = select.val();
    
        resetInputElement(select);
        if ($(`#${id}-na-info`).html().includes("flavor")) {
          $(`#${id}-na-btn`).hide();
          $(`#${id}-na-info`).empty().hide();
          if (!window.spawnActive[id])
            $(`#${id}-start-btn`).removeClass("disabled").show();
        }
    
        let systemFlavors = window.flavorInfo[system];
        if (!systemFlavors) {
          // Check if system should have flavor info but doesn't first
          let backend = (systemInfo[system] || {}).backendService;
          if (backend && (backendInfo[backend].flavorsRequired || backendInfo[backend].userflavors)) {
            // If so, we still want to create the flavor info to show the error message
            utils.createFlavorInfo(id, system);
            utils.setLabAsNA(id, "due to flavor");
            $(`#${id}-flavor-select-div, #${id}-flavor-legend-div, #${id}-flavor-info-div`).show();
          }
          else {
            // Otherwise, we can just skip showing the flavor info entirely
            $(`#${id}-flavor-select-div, #${id}-flavor-legend-div, #${id}-flavor-info-div`).hide();
          }
          updateLabConfigSelect(select, value, currentVal);
          return;
        };
    
        // Sort systemFlavors by flavor weights