mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 17:30:46 +00:00
Resolve ESlint Errors (#932)
This commit is contained in:
@@ -1,22 +1,17 @@
|
||||
import * as Constants from "../Common/Constants";
|
||||
import { LocalStorageUtility, StorageKey } from "./StorageUtility";
|
||||
|
||||
export class ExplorerSettings {
|
||||
public static createDefaultSettings() {
|
||||
LocalStorageUtility.setEntryNumber(StorageKey.ActualItemPerPage, Constants.Queries.itemsPerPage);
|
||||
LocalStorageUtility.setEntryNumber(StorageKey.CustomItemPerPage, Constants.Queries.itemsPerPage);
|
||||
LocalStorageUtility.setEntryString(StorageKey.IsCrossPartitionQueryEnabled, "true");
|
||||
LocalStorageUtility.setEntryNumber(
|
||||
StorageKey.MaxDegreeOfParellism,
|
||||
Constants.Queries.DefaultMaxDegreeOfParallelism
|
||||
);
|
||||
}
|
||||
export const createDefaultSettings = () => {
|
||||
LocalStorageUtility.setEntryNumber(StorageKey.ActualItemPerPage, Constants.Queries.itemsPerPage);
|
||||
LocalStorageUtility.setEntryNumber(StorageKey.CustomItemPerPage, Constants.Queries.itemsPerPage);
|
||||
LocalStorageUtility.setEntryString(StorageKey.IsCrossPartitionQueryEnabled, "true");
|
||||
LocalStorageUtility.setEntryNumber(StorageKey.MaxDegreeOfParellism, Constants.Queries.DefaultMaxDegreeOfParallelism);
|
||||
};
|
||||
|
||||
public static hasSettingsDefined(): boolean {
|
||||
return (
|
||||
LocalStorageUtility.hasItem(StorageKey.ActualItemPerPage) &&
|
||||
LocalStorageUtility.hasItem(StorageKey.IsCrossPartitionQueryEnabled) &&
|
||||
LocalStorageUtility.hasItem(StorageKey.MaxDegreeOfParellism)
|
||||
);
|
||||
}
|
||||
}
|
||||
export const hasSettingsDefined = (): boolean => {
|
||||
return (
|
||||
LocalStorageUtility.hasItem(StorageKey.ActualItemPerPage) &&
|
||||
LocalStorageUtility.hasItem(StorageKey.IsCrossPartitionQueryEnabled) &&
|
||||
LocalStorageUtility.hasItem(StorageKey.MaxDegreeOfParellism)
|
||||
);
|
||||
};
|
||||
|
||||
22
src/Shared/LocalStorageUtility.ts
Normal file
22
src/Shared/LocalStorageUtility.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { StorageKey } from "./StorageUtility";
|
||||
import * as StringUtility from "./StringUtility";
|
||||
|
||||
export const hasItem = (key: StorageKey): boolean => !!localStorage.getItem(StorageKey[key]);
|
||||
|
||||
export const getEntryString = (key: StorageKey): string | null => localStorage.getItem(StorageKey[key]);
|
||||
|
||||
export const getEntryNumber = (key: StorageKey): number =>
|
||||
StringUtility.toNumber(localStorage.getItem(StorageKey[key]));
|
||||
|
||||
export const getEntryBoolean = (key: StorageKey): boolean =>
|
||||
StringUtility.toBoolean(localStorage.getItem(StorageKey[key]));
|
||||
|
||||
export const setEntryString = (key: StorageKey, value: string): void => localStorage.setItem(StorageKey[key], value);
|
||||
|
||||
export const removeEntry = (key: StorageKey): void => localStorage.removeItem(StorageKey[key]);
|
||||
|
||||
export const setEntryNumber = (key: StorageKey, value: number): void =>
|
||||
localStorage.setItem(StorageKey[key], value.toString());
|
||||
|
||||
export const setEntryBoolean = (key: StorageKey, value: boolean): void =>
|
||||
localStorage.setItem(StorageKey[key], value.toString());
|
||||
@@ -2,26 +2,26 @@ import * as Constants from "./Constants";
|
||||
|
||||
export function computeRUUsagePrice(serverId: string, requestUnits: number): string {
|
||||
if (serverId === "mooncake") {
|
||||
let ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerRU;
|
||||
const ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerRU;
|
||||
return calculateEstimateNumber(ruCharge) + " " + Constants.OfferPricing.HourlyPricing.mooncake.Currency;
|
||||
}
|
||||
|
||||
let ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerRU;
|
||||
const ruCharge = requestUnits * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerRU;
|
||||
return calculateEstimateNumber(ruCharge) + " " + Constants.OfferPricing.HourlyPricing.default.Currency;
|
||||
}
|
||||
|
||||
export function computeStorageUsagePrice(serverId: string, storageUsedRoundUpToGB: number): string {
|
||||
if (serverId === "mooncake") {
|
||||
let storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerGB;
|
||||
const storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.mooncake.Standard.PricePerGB;
|
||||
return calculateEstimateNumber(storageCharge) + " " + Constants.OfferPricing.HourlyPricing.mooncake.Currency;
|
||||
}
|
||||
|
||||
let storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerGB;
|
||||
const storageCharge = storageUsedRoundUpToGB * Constants.OfferPricing.HourlyPricing.default.Standard.PricePerGB;
|
||||
return calculateEstimateNumber(storageCharge) + " " + Constants.OfferPricing.HourlyPricing.default.Currency;
|
||||
}
|
||||
|
||||
export function computeDisplayUsageString(usageInKB: number): string {
|
||||
let usageInMB = usageInKB / 1024,
|
||||
const usageInMB = usageInKB / 1024,
|
||||
usageInGB = usageInMB / 1024,
|
||||
displayUsageString =
|
||||
usageInGB > 0.1
|
||||
@@ -33,7 +33,7 @@ export function computeDisplayUsageString(usageInKB: number): string {
|
||||
}
|
||||
|
||||
export function usageInGB(usageInKB: number): number {
|
||||
let usageInMB = usageInKB / 1024,
|
||||
const usageInMB = usageInKB / 1024,
|
||||
usageInGB = usageInMB / 1024;
|
||||
return Math.ceil(usageInGB);
|
||||
}
|
||||
|
||||
20
src/Shared/SessionStorageUtility.ts
Normal file
20
src/Shared/SessionStorageUtility.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { StorageKey } from "./StorageUtility";
|
||||
import * as StringUtility from "./StringUtility";
|
||||
|
||||
export const hasItem = (key: StorageKey): boolean => !!sessionStorage.getItem(StorageKey[key]);
|
||||
|
||||
export const getEntryString = (key: StorageKey): string | null => sessionStorage.getItem(StorageKey[key]);
|
||||
|
||||
export const getEntryNumber = (key: StorageKey): number =>
|
||||
StringUtility.toNumber(sessionStorage.getItem(StorageKey[key]));
|
||||
|
||||
export const getEntry = (key: string): string | null => sessionStorage.getItem(key);
|
||||
|
||||
export const removeEntry = (key: StorageKey): void => sessionStorage.removeItem(StorageKey[key]);
|
||||
|
||||
export const setEntryString = (key: StorageKey, value: string): void => sessionStorage.setItem(StorageKey[key], value);
|
||||
|
||||
export const setEntry = (key: string, value: string): void => sessionStorage.setItem(key, value);
|
||||
|
||||
export const setEntryNumber = (key: StorageKey, value: number): void =>
|
||||
sessionStorage.setItem(StorageKey[key], value.toString());
|
||||
@@ -1,73 +1,7 @@
|
||||
import * as StringUtility from "./StringUtility";
|
||||
|
||||
export class LocalStorageUtility {
|
||||
public static hasItem(key: StorageKey): boolean {
|
||||
return !!localStorage.getItem(StorageKey[key]);
|
||||
}
|
||||
|
||||
public static getEntryString(key: StorageKey): string | null {
|
||||
return localStorage.getItem(StorageKey[key]);
|
||||
}
|
||||
|
||||
public static getEntryNumber(key: StorageKey): number {
|
||||
return StringUtility.toNumber(localStorage.getItem(StorageKey[key]));
|
||||
}
|
||||
|
||||
public static getEntryBoolean(key: StorageKey): boolean {
|
||||
return StringUtility.toBoolean(localStorage.getItem(StorageKey[key]));
|
||||
}
|
||||
|
||||
public static setEntryString(key: StorageKey, value: string): void {
|
||||
localStorage.setItem(StorageKey[key], value);
|
||||
}
|
||||
|
||||
public static removeEntry(key: StorageKey): void {
|
||||
return localStorage.removeItem(StorageKey[key]);
|
||||
}
|
||||
|
||||
public static setEntryNumber(key: StorageKey, value: number): void {
|
||||
localStorage.setItem(StorageKey[key], value.toString());
|
||||
}
|
||||
|
||||
public static setEntryBoolean(key: StorageKey, value: boolean): void {
|
||||
localStorage.setItem(StorageKey[key], value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
export class SessionStorageUtility {
|
||||
public static hasItem(key: StorageKey): boolean {
|
||||
return !!sessionStorage.getItem(StorageKey[key]);
|
||||
}
|
||||
|
||||
public static getEntryString(key: StorageKey): string | null {
|
||||
return sessionStorage.getItem(StorageKey[key]);
|
||||
}
|
||||
|
||||
public static getEntryNumber(key: StorageKey): number {
|
||||
return StringUtility.toNumber(sessionStorage.getItem(StorageKey[key]));
|
||||
}
|
||||
|
||||
public static getEntry(key: string): string | null {
|
||||
return sessionStorage.getItem(key);
|
||||
}
|
||||
|
||||
public static removeEntry(key: StorageKey): void {
|
||||
return sessionStorage.removeItem(StorageKey[key]);
|
||||
}
|
||||
|
||||
public static setEntryString(key: StorageKey, value: string): void {
|
||||
sessionStorage.setItem(StorageKey[key], value);
|
||||
}
|
||||
|
||||
public static setEntry(key: string, value: string): void {
|
||||
sessionStorage.setItem(key, value);
|
||||
}
|
||||
|
||||
public static setEntryNumber(key: StorageKey, value: number): void {
|
||||
sessionStorage.setItem(StorageKey[key], value.toString());
|
||||
}
|
||||
}
|
||||
import * as LocalStorageUtility from "./LocalStorageUtility";
|
||||
import * as SessionStorageUtility from "./SessionStorageUtility";
|
||||
|
||||
export { LocalStorageUtility, SessionStorageUtility };
|
||||
export enum StorageKey {
|
||||
ActualItemPerPage,
|
||||
CustomItemPerPage,
|
||||
|
||||
Reference in New Issue
Block a user