mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-23 03:34:16 +00:00
Added more Self Serve functionalities (#401)
* added recursion and inition decorators * working version * added todo comment and removed console.log * Added Recursive add * removed type requirement * proper resolution of promises * added custom element and base class * Made selfServe standalone page * Added custom renderer as async type * Added overall defaults * added inital open from data explorer * removed landingpage * added feature for self serve type * renamed sqlx->example and added invalid type * Added comments for Example * removed unnecessary changes * Resolved PR comments Added tests Moved onSubmt and initialize inside base class Moved testExplorer to separate folder made fields of SelfServe Class non static * fixed lint errors * fixed compilation errors * Removed reactbinding changes * renamed dropdown -> choice * Added SelfServeComponent * Addressed PR comments * added toggle, visibility, text display,commandbar * added sqlx example * added onRefrssh * formatting changes * rmoved radioswitch display * updated smartui tests * Added more tests * onSubmit -> onSave * Resolved PR comments
This commit is contained in:
committed by
GitHub
parent
b0b973b21a
commit
49bf8c60db
64
src/SelfServe/Example/SelfServeExample.rp.ts
Normal file
64
src/SelfServe/Example/SelfServeExample.rp.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { get } from "../../Utils/arm/generatedClients/2020-04-01/databaseAccounts";
|
||||
import { userContext } from "../../UserContext";
|
||||
import { SessionStorageUtility } from "../../Shared/StorageUtility";
|
||||
import { RefreshResult } from "../SelfServeTypes";
|
||||
export enum Regions {
|
||||
NorthCentralUS = "NorthCentralUS",
|
||||
WestUS = "WestUS",
|
||||
EastUS2 = "EastUS2",
|
||||
}
|
||||
|
||||
export interface InitializeResponse {
|
||||
regions: Regions;
|
||||
enableLogging: boolean;
|
||||
accountName: string;
|
||||
collectionThroughput: number;
|
||||
dbThroughput: number;
|
||||
}
|
||||
|
||||
export const getMaxThroughput = async (): Promise<number> => {
|
||||
return 10000;
|
||||
};
|
||||
|
||||
export const update = async (
|
||||
regions: Regions,
|
||||
enableLogging: boolean,
|
||||
accountName: string,
|
||||
collectionThroughput: number,
|
||||
dbThoughput: number
|
||||
): Promise<void> => {
|
||||
SessionStorageUtility.setEntry("regions", regions);
|
||||
SessionStorageUtility.setEntry("enableLogging", enableLogging?.toString());
|
||||
SessionStorageUtility.setEntry("accountName", accountName);
|
||||
SessionStorageUtility.setEntry("collectionThroughput", collectionThroughput?.toString());
|
||||
SessionStorageUtility.setEntry("dbThroughput", dbThoughput?.toString());
|
||||
};
|
||||
|
||||
export const initialize = async (): Promise<InitializeResponse> => {
|
||||
const regions = Regions[SessionStorageUtility.getEntry("regions") as keyof typeof Regions];
|
||||
const enableLogging = SessionStorageUtility.getEntry("enableLogging") === "true";
|
||||
const accountName = SessionStorageUtility.getEntry("accountName");
|
||||
let collectionThroughput = parseInt(SessionStorageUtility.getEntry("collectionThroughput"));
|
||||
collectionThroughput = isNaN(collectionThroughput) ? undefined : collectionThroughput;
|
||||
let dbThroughput = parseInt(SessionStorageUtility.getEntry("dbThroughput"));
|
||||
dbThroughput = isNaN(dbThroughput) ? undefined : dbThroughput;
|
||||
return {
|
||||
regions: regions,
|
||||
enableLogging: enableLogging,
|
||||
accountName: accountName,
|
||||
collectionThroughput: collectionThroughput,
|
||||
dbThroughput: dbThroughput,
|
||||
};
|
||||
};
|
||||
|
||||
export const onRefreshSelfServeExample = async (): Promise<RefreshResult> => {
|
||||
const subscriptionId = userContext.subscriptionId;
|
||||
const resourceGroup = userContext.resourceGroup;
|
||||
const databaseAccountName = userContext.databaseAccount.name;
|
||||
const databaseAccountGetResults = await get(subscriptionId, resourceGroup, databaseAccountName);
|
||||
const isUpdateInProgress = databaseAccountGetResults.properties.provisioningState !== "Succeeded";
|
||||
return {
|
||||
isUpdateInProgress: isUpdateInProgress,
|
||||
notificationMessage: "Self Serve Example successfully refreshing",
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user