Select Git revision
dropdown-options.js
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