Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/compute/config.ts
Views: 687
import { redux } from "@cocalc/frontend/app-framework";1import { CLOUDS_BY_NAME, Cloud } from "@cocalc/util/db-schema/compute-servers";23// Returns true if in admin compute_servers_enabled is true *and* at least4// one cloud is also enabled, since otherwise compute servers are not in any5// way useful. Returns false, if compute servers are not enabled or no cloud6// enabled. Returns null if we don't know yet, since e.g., page is just loading7// and/or backend server is slow to initialize the customize store.8export function computeServersEnabled(): true | false | null {9const customize = redux.getStore("customize");10if (customize == null || customize.get("time") == null) {11// definitely NOT loaded yet.12return null;13}14if (!customize.get("compute_servers_enabled")) {15return false;16}17for (const cloud in CLOUDS_BY_NAME) {18if (customize.get(`compute_servers_${cloud}_enabled`)) {19return true;20}21}22return false;23}2425export function cloudFilesystemsEnabled(): true | false | null {26const customize = redux.getStore("customize");27if (customize == null || customize.get("time") == null) {28// definitely NOT loaded yet.29return null;30}31// requires also google cloud and compute servers in general:32return (33!!customize.get("compute_servers_enabled") &&34!!customize.get("compute_servers_google-cloud_enabled") &&35!!customize.get("cloud_filesystems_enabled")36);37}3839export function availableClouds(): Cloud[] {40const v: Cloud[] = [];41const customize = redux.getStore("customize");42if (customize == null) {43return v;44}45for (const cloud in CLOUDS_BY_NAME) {46if (customize.get(`compute_servers_${cloud}_enabled`)) {47v.push(CLOUDS_BY_NAME[cloud].name);48}49}50return v;51}525354