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/cloud-filesystem/util.ts
Views: 687
import { capitalize } from "@cocalc/util/misc";1import { markup } from "@cocalc/util/compute/cloud/google-cloud/compute-cost";23export function editModalStyle(cloudFilesystem) {4return {5borderWidth: "0.5px 10px",6borderStyle: "solid",7padding: "10px 15px",8borderRadius: "5px",9borderColor: cloudFilesystem.color ?? "#666",10};11}1213// Price returned from this includes markup14export function getDataStoragePriceRange({15priceData,16bucket_location,17bucket_storage_class,18}): { min: number | null; max: number | null } {19if (priceData == null) {20return { min: null, max: null };21}22if (bucket_storage_class.startsWith("autoclass")) {23const min = getDataStoragePrice({24priceData,25bucket_location,26bucket_storage_class: bucket_storage_class.split("-")[1],27});28const max = getDataStoragePrice({29priceData,30bucket_location,31bucket_storage_class: "standard",32});33return { min, max };34} else {35const price = getDataStoragePrice({36priceData,37bucket_location,38bucket_storage_class,39});40return { min: price, max: price };41}42}4344// Price returned from this includes markup45export function getDataStoragePrice({46priceData,47bucket_location,48bucket_storage_class,49}): number | null {50if (priceData == null) {51return null;52}53let cost;54if (!bucket_location.includes("-")) {55cost =56priceData.storage?.atRest?.multiRegions?.[bucket_location]?.[57capitalize(bucket_storage_class)58];59} else {60cost =61priceData.storage?.atRest?.regions?.[bucket_location]?.[62capitalize(bucket_storage_class)63];64}65return markup({66cost,67priceData,68});69}7071const alpha = "abcdefghijklmnopqrstuvwxyz".split("");72export function getCity({ region, priceData }) {73if (priceData?.zones == null) {74return "";75}76for (const x of alpha) {77const z = priceData.zones[`${region}-${x}`];78if (z != null) {79return z.location.split(",")[1].trim();80}81}82return "";83}848586