mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-07-16 17:04:07 +01:00
Made selfServe standalone page
This commit is contained in:
parent
90fb7e7d8f
commit
c97eb6018b
@ -45,7 +45,6 @@ import { readMongoDBCollectionThroughRP } from "../../../Common/dataAccess/readM
|
|||||||
import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress";
|
import { getIndexTransformationProgress } from "../../../Common/dataAccess/getIndexTransformationProgress";
|
||||||
import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../../../Common/ErrorHandlingUtils";
|
||||||
import { isEmpty } from "underscore";
|
import { isEmpty } from "underscore";
|
||||||
import { SelfServeComponent } from "./SettingsSubComponents/SelfServe/SelfServeComponent";
|
|
||||||
|
|
||||||
interface SettingsV2TabInfo {
|
interface SettingsV2TabInfo {
|
||||||
tab: SettingsV2TabTypes;
|
tab: SettingsV2TabTypes;
|
||||||
@ -901,11 +900,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
|
|
||||||
const tabs: SettingsV2TabInfo[] = [];
|
const tabs: SettingsV2TabInfo[] = [];
|
||||||
|
|
||||||
tabs.push({
|
|
||||||
tab: SettingsV2TabTypes.SelfServe,
|
|
||||||
content: <SelfServeComponent />
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!hasDatabaseSharedThroughput(this.collection) && this.collection.offer()) {
|
if (!hasDatabaseSharedThroughput(this.collection) && this.collection.offer()) {
|
||||||
tabs.push({
|
tabs.push({
|
||||||
tab: SettingsV2TabTypes.ScaleTab,
|
tab: SettingsV2TabTypes.ScaleTab,
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { Descriptor, InputType, SmartUiComponent } from "../../../SmartUi/SmartUiComponent";
|
|
||||||
import { SqlX } from "./SqlX";
|
|
||||||
|
|
||||||
export class SelfServeComponent extends React.Component {
|
|
||||||
private onSubmit = async (currentValues: Map<string, InputType>): Promise<void> => {
|
|
||||||
console.log(currentValues.get("instanceCount"), currentValues.get("instanceSize"));
|
|
||||||
};
|
|
||||||
|
|
||||||
private selfServeData: Descriptor = {
|
|
||||||
onSubmit: this.onSubmit,
|
|
||||||
root: {
|
|
||||||
id: "root",
|
|
||||||
info: {
|
|
||||||
message: "Start at $24/mo per database",
|
|
||||||
link: {
|
|
||||||
href: "https://aka.ms/azure-cosmos-db-pricing",
|
|
||||||
text: "More Details"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
id: "instanceCount",
|
|
||||||
input: {
|
|
||||||
label: "Instance Count",
|
|
||||||
dataFieldName: "instanceCount",
|
|
||||||
type: "number",
|
|
||||||
min: 1,
|
|
||||||
max: 5,
|
|
||||||
step: 1,
|
|
||||||
defaultValue: 1,
|
|
||||||
inputType: "slider",
|
|
||||||
onChange: (currentState: Map<string, InputType>, newValue: InputType): Map<string, InputType> => {
|
|
||||||
currentState.set("instanceCount", newValue);
|
|
||||||
if ((newValue as number) === 1) {
|
|
||||||
currentState.set("instanceSize", "1Core4Gb");
|
|
||||||
}
|
|
||||||
return currentState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "instanceSize",
|
|
||||||
input: {
|
|
||||||
label: "Instance Size",
|
|
||||||
dataFieldName: "instanceSize",
|
|
||||||
type: "object",
|
|
||||||
choices: [
|
|
||||||
{ label: "1Core4Gb", key: "1Core4Gb", value: "1Core4Gb" },
|
|
||||||
{ label: "2Core8Gb", key: "2Core8Gb", value: "2Core8Gb" },
|
|
||||||
{ label: "4Core16Gb", key: "4Core16Gb", value: "4Core16Gb" }
|
|
||||||
],
|
|
||||||
defaultKey: "1Core4Gb",
|
|
||||||
onChange: (currentState: Map<string, InputType>, newValue: InputType): Map<string, InputType> => {
|
|
||||||
currentState.set("instanceSize", newValue);
|
|
||||||
return currentState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public render(): JSX.Element {
|
|
||||||
//return <SmartUiComponent descriptor={this.selfServeData} />
|
|
||||||
return <SmartUiComponent descriptor={SqlX.toSmartUiDescriptor()} />;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Info, InputType } from "../../../SmartUi/SmartUiComponent";
|
import { Info, InputType } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
import { addPropertyToMap, toSmartUiDescriptor } from "./SelfServeUtils";
|
import { addPropertyToMap, toSmartUiDescriptor } from "./SelfServeUtils";
|
||||||
|
|
||||||
export const SmartUi = (): ClassDecorator => {
|
export const SmartUi = (): ClassDecorator => {
|
@ -1,4 +1,4 @@
|
|||||||
import { ChoiceItem, Info, InputType } from "../../../SmartUi/SmartUiComponent";
|
import { ChoiceItem, Info, InputType } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
import { addPropertyToMap } from "./SelfServeUtils";
|
import { addPropertyToMap } from "./SelfServeUtils";
|
||||||
|
|
||||||
const addToMap = (descriptorName: string, descriptorValue: any): PropertyDecorator => {
|
const addToMap = (descriptorName: string, descriptorValue: any): PropertyDecorator => {
|
3
src/SelfServe/SelfServe.less
Normal file
3
src/SelfServe/SelfServe.less
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.selfServeComponentContainer {
|
||||||
|
margin: 10;
|
||||||
|
}
|
21
src/SelfServe/SelfServe.tsx
Normal file
21
src/SelfServe/SelfServe.tsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import "bootstrap/dist/css/bootstrap.css";
|
||||||
|
import { initializeIcons } from "office-ui-fabric-react/lib/Icons";
|
||||||
|
import React from "react";
|
||||||
|
import * as ReactDOM from "react-dom";
|
||||||
|
import { initializeConfiguration } from "../ConfigContext";
|
||||||
|
import { SmartUiComponent } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
|
import { SqlX } from "./SqlX/SqlX";
|
||||||
|
|
||||||
|
const render = async () => {
|
||||||
|
initializeIcons();
|
||||||
|
await initializeConfiguration();
|
||||||
|
|
||||||
|
const element = (
|
||||||
|
<SmartUiComponent descriptor={SqlX.toSmartUiDescriptor()} />
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDOM.render(element, document.getElementById("selfServeContent"));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Entry point
|
||||||
|
window.addEventListener("load", render);
|
@ -11,7 +11,7 @@ import {
|
|||||||
BooleanInput,
|
BooleanInput,
|
||||||
ChoiceInput,
|
ChoiceInput,
|
||||||
InputType
|
InputType
|
||||||
} from "../../../SmartUi/SmartUiComponent";
|
} from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
|
|
||||||
export class SelfServeBase {
|
export class SelfServeBase {
|
||||||
public static toSmartUiDescriptor(): Descriptor {
|
public static toSmartUiDescriptor(): Descriptor {
|
@ -14,11 +14,9 @@ import {
|
|||||||
Placeholder,
|
Placeholder,
|
||||||
DefaultNumberValue,
|
DefaultNumberValue,
|
||||||
DefaultBooleanValue,
|
DefaultBooleanValue,
|
||||||
DefaultStringValue,
|
|
||||||
CustomElement
|
CustomElement
|
||||||
} from "./PropertyDescriptors";
|
} from "../PropertyDescriptors";
|
||||||
import { SmartUi, ClassInfo, OnSubmit } from "./ClassDescriptors";
|
import { SmartUi, ClassInfo, OnSubmit } from "../ClassDescriptors";
|
||||||
import { ChoiceItem } from "../../../SmartUi/SmartUiComponent";
|
|
||||||
import {
|
import {
|
||||||
getPromise,
|
getPromise,
|
||||||
instanceSizeInfo,
|
instanceSizeInfo,
|
||||||
@ -29,7 +27,8 @@ import {
|
|||||||
Sizes,
|
Sizes,
|
||||||
sqlXInfo
|
sqlXInfo
|
||||||
} from "./SqlXApis";
|
} from "./SqlXApis";
|
||||||
import { SelfServeBase } from "./SelfServeUtils";
|
import { SelfServeBase } from "../SelfServeUtils";
|
||||||
|
import { ChoiceItem } from "../../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
|
|
||||||
@SmartUi()
|
@SmartUi()
|
||||||
@ClassInfo(getPromise(sqlXInfo))
|
@ClassInfo(getPromise(sqlXInfo))
|
||||||
@ -42,7 +41,6 @@ export class SqlX extends SelfServeBase {
|
|||||||
@PropertyInfo(getPromise(instanceSizeInfo))
|
@PropertyInfo(getPromise(instanceSizeInfo))
|
||||||
@Label(getPromise("Instance Size"))
|
@Label(getPromise("Instance Size"))
|
||||||
@Choices(getPromise(instanceSizeOptions))
|
@Choices(getPromise(instanceSizeOptions))
|
||||||
//@Choices(instanceSizeOptions)
|
|
||||||
@DefaultKey(getPromise(Sizes.OneCore4Gb))
|
@DefaultKey(getPromise(Sizes.OneCore4Gb))
|
||||||
static instanceSize: ChoiceItem;
|
static instanceSize: ChoiceItem;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import { Text } from "office-ui-fabric-react";
|
import { Text } from "office-ui-fabric-react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { ChoiceItem, Info, InputType } from "../../../SmartUi/SmartUiComponent";
|
import { ChoiceItem, Info, InputType } from "../../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
|
|
||||||
export enum Sizes {
|
export enum Sizes {
|
||||||
OneCore4Gb = "OneCore4Gb",
|
OneCore4Gb = "OneCore4Gb",
|
||||||
@ -61,5 +61,5 @@ export const getPromise = <T extends number | string | boolean | ChoiceItem[] |
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const renderTextInput = async (): Promise<JSX.Element> => {
|
export const renderTextInput = async (): Promise<JSX.Element> => {
|
||||||
return <Text>SqlX is a new feature of Cosmos DB</Text>;
|
return <Text>SqlX is a new feature of Cosmos DB.</Text>;
|
||||||
};
|
};
|
12
src/SelfServe/selfServe.html
Normal file
12
src/SelfServe/selfServe.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0" />
|
||||||
|
<link rel="shortcut icon" href="images/CosmosDB_rgb_ui_lighttheme.ico" type="image/x-icon" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="selfServeComponentContainer" id="selfServeContent"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -165,6 +165,11 @@ module.exports = function(env = {}, argv = {}) {
|
|||||||
template: "src/connectToGitHub.html",
|
template: "src/connectToGitHub.html",
|
||||||
chunks: ["connectToGitHub"]
|
chunks: ["connectToGitHub"]
|
||||||
}),
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
filename: "selfServe.html",
|
||||||
|
template: "src/SelfServe/selfServe.html",
|
||||||
|
chunks: ["selfServe"]
|
||||||
|
}),
|
||||||
new MonacoWebpackPlugin(),
|
new MonacoWebpackPlugin(),
|
||||||
new CopyWebpackPlugin({
|
new CopyWebpackPlugin({
|
||||||
patterns: [{ from: "DataExplorer.nuspec" }, { from: "web.config" }, { from: "quickstart/*.zip" }]
|
patterns: [{ from: "DataExplorer.nuspec" }, { from: "web.config" }, { from: "quickstart/*.zip" }]
|
||||||
@ -188,7 +193,8 @@ module.exports = function(env = {}, argv = {}) {
|
|||||||
terminal: "./src/Terminal/index.ts",
|
terminal: "./src/Terminal/index.ts",
|
||||||
notebookViewer: "./src/NotebookViewer/NotebookViewer.tsx",
|
notebookViewer: "./src/NotebookViewer/NotebookViewer.tsx",
|
||||||
galleryViewer: "./src/GalleryViewer/GalleryViewer.tsx",
|
galleryViewer: "./src/GalleryViewer/GalleryViewer.tsx",
|
||||||
connectToGitHub: "./src/GitHub/GitHubConnector.ts"
|
connectToGitHub: "./src/GitHub/GitHubConnector.ts",
|
||||||
|
selfServe: "./src/SelfServe/SelfServe.tsx"
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
util: true,
|
util: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user