mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 02:41:39 +00:00
added inital open from data explorer
This commit is contained in:
@@ -15,6 +15,7 @@ import DocumentId from "../Explorer/Tree/DocumentId";
|
|||||||
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
|
import StoredProcedure from "../Explorer/Tree/StoredProcedure";
|
||||||
import Trigger from "../Explorer/Tree/Trigger";
|
import Trigger from "../Explorer/Tree/Trigger";
|
||||||
import UserDefinedFunction from "../Explorer/Tree/UserDefinedFunction";
|
import UserDefinedFunction from "../Explorer/Tree/UserDefinedFunction";
|
||||||
|
import { SelfServeTypes } from "../SelfServe/SelfServeUtils";
|
||||||
import { UploadDetails } from "../workers/upload/definitions";
|
import { UploadDetails } from "../workers/upload/definitions";
|
||||||
import * as DataModels from "./DataModels";
|
import * as DataModels from "./DataModels";
|
||||||
import { SubscriptionType } from "./SubscriptionType";
|
import { SubscriptionType } from "./SubscriptionType";
|
||||||
@@ -395,6 +396,7 @@ export interface DataExplorerInputsFrame {
|
|||||||
isAuthWithresourceToken?: boolean;
|
isAuthWithresourceToken?: boolean;
|
||||||
defaultCollectionThroughput?: CollectionCreationDefaults;
|
defaultCollectionThroughput?: CollectionCreationDefaults;
|
||||||
flights?: readonly string[];
|
flights?: readonly string[];
|
||||||
|
selfServeType?: SelfServeTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CollectionCreationDefaults {
|
export interface CollectionCreationDefaults {
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ import { stringToBlob } from "../Utils/BlobUtils";
|
|||||||
import { IChoiceGroupProps } from "office-ui-fabric-react";
|
import { IChoiceGroupProps } from "office-ui-fabric-react";
|
||||||
import { getErrorMessage, handleError, getErrorStack } from "../Common/ErrorHandlingUtils";
|
import { getErrorMessage, handleError, getErrorStack } from "../Common/ErrorHandlingUtils";
|
||||||
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
import { SubscriptionType } from "../Contracts/SubscriptionType";
|
||||||
|
import { SelfServeLoadingComponentAdapter } from "../SelfServe/SelfServeLoadingComponentAdapter";
|
||||||
|
import { SelfServeTypes } from "../SelfServe/SelfServeUtils";
|
||||||
|
import { SelfServeComponentAdapter } from "../SelfServe/SelfServeComponentAdapter";
|
||||||
|
|
||||||
BindingHandlersRegisterer.registerBindingHandlers();
|
BindingHandlersRegisterer.registerBindingHandlers();
|
||||||
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
|
||||||
@@ -132,6 +135,7 @@ export default class Explorer {
|
|||||||
public isEnableMongoCapabilityPresent: ko.Computed<boolean>;
|
public isEnableMongoCapabilityPresent: ko.Computed<boolean>;
|
||||||
public isServerlessEnabled: ko.Computed<boolean>;
|
public isServerlessEnabled: ko.Computed<boolean>;
|
||||||
public isAccountReady: ko.Observable<boolean>;
|
public isAccountReady: ko.Observable<boolean>;
|
||||||
|
public selfServeType: ko.Observable<SelfServeTypes>;
|
||||||
public canSaveQueries: ko.Computed<boolean>;
|
public canSaveQueries: ko.Computed<boolean>;
|
||||||
public features: ko.Observable<any>;
|
public features: ko.Observable<any>;
|
||||||
public serverId: ko.Observable<string>;
|
public serverId: ko.Observable<string>;
|
||||||
@@ -159,6 +163,7 @@ export default class Explorer {
|
|||||||
public selectedNode: ko.Observable<ViewModels.TreeNode>;
|
public selectedNode: ko.Observable<ViewModels.TreeNode>;
|
||||||
public isRefreshingExplorer: ko.Observable<boolean>;
|
public isRefreshingExplorer: ko.Observable<boolean>;
|
||||||
private resourceTree: ResourceTreeAdapter;
|
private resourceTree: ResourceTreeAdapter;
|
||||||
|
private selfServeComponentAdapter: SelfServeComponentAdapter
|
||||||
|
|
||||||
// Resource Token
|
// Resource Token
|
||||||
public resourceTokenDatabaseId: ko.Observable<string>;
|
public resourceTokenDatabaseId: ko.Observable<string>;
|
||||||
@@ -255,6 +260,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
// React adapters
|
// React adapters
|
||||||
private commandBarComponentAdapter: CommandBarComponentAdapter;
|
private commandBarComponentAdapter: CommandBarComponentAdapter;
|
||||||
|
private selfServeLoadingComponentAdapter : SelfServeLoadingComponentAdapter;
|
||||||
private splashScreenAdapter: SplashScreenComponentAdapter;
|
private splashScreenAdapter: SplashScreenComponentAdapter;
|
||||||
private notificationConsoleComponentAdapter: NotificationConsoleComponentAdapter;
|
private notificationConsoleComponentAdapter: NotificationConsoleComponentAdapter;
|
||||||
private dialogComponentAdapter: DialogComponentAdapter;
|
private dialogComponentAdapter: DialogComponentAdapter;
|
||||||
@@ -297,6 +303,7 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.isAccountReady = ko.observable<boolean>(false);
|
this.isAccountReady = ko.observable<boolean>(false);
|
||||||
|
this.selfServeType = ko.observable<SelfServeTypes>(undefined);
|
||||||
this._isInitializingNotebooks = false;
|
this._isInitializingNotebooks = false;
|
||||||
this._isInitializingSparkConnectionInfo = false;
|
this._isInitializingSparkConnectionInfo = false;
|
||||||
this.arcadiaToken = ko.observable<string>();
|
this.arcadiaToken = ko.observable<string>();
|
||||||
@@ -702,6 +709,7 @@ export default class Explorer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.uploadItemsPaneAdapter = new UploadItemsPaneAdapter(this);
|
this.uploadItemsPaneAdapter = new UploadItemsPaneAdapter(this);
|
||||||
|
this.selfServeComponentAdapter = new SelfServeComponentAdapter(this);
|
||||||
|
|
||||||
this.loadQueryPane = new LoadQueryPane({
|
this.loadQueryPane = new LoadQueryPane({
|
||||||
id: "loadquerypane",
|
id: "loadquerypane",
|
||||||
@@ -877,6 +885,7 @@ export default class Explorer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.commandBarComponentAdapter = new CommandBarComponentAdapter(this);
|
this.commandBarComponentAdapter = new CommandBarComponentAdapter(this);
|
||||||
|
this.selfServeLoadingComponentAdapter = new SelfServeLoadingComponentAdapter();
|
||||||
this.notificationConsoleComponentAdapter = new NotificationConsoleComponentAdapter(this);
|
this.notificationConsoleComponentAdapter = new NotificationConsoleComponentAdapter(this);
|
||||||
|
|
||||||
this._initSettings();
|
this._initSettings();
|
||||||
@@ -1854,6 +1863,12 @@ export default class Explorer {
|
|||||||
|
|
||||||
public initDataExplorerWithFrameInputs(inputs: ViewModels.DataExplorerInputsFrame): Q.Promise<void> {
|
public initDataExplorerWithFrameInputs(inputs: ViewModels.DataExplorerInputsFrame): Q.Promise<void> {
|
||||||
if (inputs != null) {
|
if (inputs != null) {
|
||||||
|
inputs.selfServeType
|
||||||
|
? this.selfServeType(inputs.selfServeType)
|
||||||
|
: this.selfServeType(SelfServeTypes.none);
|
||||||
|
this._setLoadingStatusText("Connecting...", "Welcome to Azure Cosmos DB")
|
||||||
|
this._setConnectingImage()
|
||||||
|
|
||||||
const authorizationToken = inputs.authorizationToken || "";
|
const authorizationToken = inputs.authorizationToken || "";
|
||||||
const masterKey = inputs.masterKey || "";
|
const masterKey = inputs.masterKey || "";
|
||||||
const databaseAccount = inputs.databaseAccount || null;
|
const databaseAccount = inputs.databaseAccount || null;
|
||||||
@@ -2985,6 +3000,11 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _setConnectingImage() {
|
||||||
|
const connectingImage = document.getElementById("explorerConnectingImage");
|
||||||
|
connectingImage.innerHTML="<img src=\"../images/HdeConnectCosmosDB.svg\" >";
|
||||||
|
}
|
||||||
|
|
||||||
private _openSetupNotebooksPaneForQuickstart(): void {
|
private _openSetupNotebooksPaneForQuickstart(): void {
|
||||||
const title = "Enable Notebooks (Preview)";
|
const title = "Enable Notebooks (Preview)";
|
||||||
const description =
|
const description =
|
||||||
|
|||||||
21
src/Main.tsx
21
src/Main.tsx
@@ -126,9 +126,11 @@ const App: React.FunctionComponent = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flexContainer">
|
<div className="flexContainer">
|
||||||
|
<div id="divSelfServe" data-bind="visible: selfServeType() && selfServeType() !== 'none', react: selfServeComponentAdapter">
|
||||||
|
</div>
|
||||||
<div id="divExplorer" className="flexContainer hideOverflows" style={{ display: "none" }}>
|
<div id="divExplorer" className="flexContainer hideOverflows" style={{ display: "none" }}>
|
||||||
{/* Main Command Bar - Start */}
|
{/* Main Command Bar - Start */}
|
||||||
<div data-bind="react: commandBarComponentAdapter" />
|
<div data-bind="visible: selfServeType() === 'none', react: commandBarComponentAdapter" />
|
||||||
{/* Main Command Bar - End */}
|
{/* Main Command Bar - End */}
|
||||||
{/* Share url flyout - Start */}
|
{/* Share url flyout - Start */}
|
||||||
<div
|
<div
|
||||||
@@ -196,7 +198,7 @@ const App: React.FunctionComponent = () => {
|
|||||||
</div>
|
</div>
|
||||||
{/* Share url flyout - End */}
|
{/* Share url flyout - End */}
|
||||||
{/* Collections Tree and Tabs - Begin */}
|
{/* Collections Tree and Tabs - Begin */}
|
||||||
<div className="resourceTreeAndTabs">
|
<div className="resourceTreeAndTabs" data-bind="visible: selfServeType() === 'none'">
|
||||||
{/* Collections Tree - Start */}
|
{/* Collections Tree - Start */}
|
||||||
<div id="resourcetree" data-test="resourceTreeId" className="resourceTree">
|
<div id="resourcetree" data-test="resourceTreeId" className="resourceTree">
|
||||||
<div className="collectionsTreeWithSplitter">
|
<div className="collectionsTreeWithSplitter">
|
||||||
@@ -303,7 +305,7 @@ const App: React.FunctionComponent = () => {
|
|||||||
data-bind="visible: !isRefreshingExplorer() && tabsManager.openedTabs().length === 0"
|
data-bind="visible: !isRefreshingExplorer() && tabsManager.openedTabs().length === 0"
|
||||||
>
|
>
|
||||||
<form className="connectExplorerFormContainer">
|
<form className="connectExplorerFormContainer">
|
||||||
<div className="connectExplorer" data-bind="react: splashScreenAdapter" />
|
<div className="connectExplorer" data-bind="visible: selfServeType() === 'none', react: splashScreenAdapter" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@@ -317,7 +319,7 @@ const App: React.FunctionComponent = () => {
|
|||||||
role="contentinfo"
|
role="contentinfo"
|
||||||
aria-label="Notification console"
|
aria-label="Notification console"
|
||||||
id="explorerNotificationConsole"
|
id="explorerNotificationConsole"
|
||||||
data-bind="react: notificationConsoleComponentAdapter"
|
data-bind="react: notificationConsoleComponentAdapter, visible: selfServeType() === 'none'"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/* Explorer Connection - Encryption Token / AAD - Start */}
|
{/* Explorer Connection - Encryption Token / AAD - Start */}
|
||||||
@@ -373,14 +375,13 @@ const App: React.FunctionComponent = () => {
|
|||||||
{/* Global loader - Start */}
|
{/* Global loader - Start */}
|
||||||
<div className="splashLoaderContainer" data-bind="visible: isRefreshingExplorer">
|
<div className="splashLoaderContainer" data-bind="visible: isRefreshingExplorer">
|
||||||
<div className="splashLoaderContentContainer">
|
<div className="splashLoaderContentContainer">
|
||||||
<p className="connectExplorerContent">
|
<div className="splashLoaderTitle" data-bind="visible: selfServeType() === undefined, react: selfServeLoadingComponentAdapter">
|
||||||
<img src={hdeConnectImage} alt="Azure Cosmos DB" />
|
</div>
|
||||||
|
<p className="connectExplorerContent" id="explorerConnectingImage" data-bind="visible: selfServeType() === 'none'">
|
||||||
</p>
|
</p>
|
||||||
<p className="splashLoaderTitle" id="explorerLoadingStatusTitle">
|
<p className="splashLoaderTitle" id="explorerLoadingStatusTitle" data-bind="visible: selfServeType() === 'none'">
|
||||||
Welcome to Azure Cosmos DB
|
|
||||||
</p>
|
</p>
|
||||||
<p className="splashLoaderText" id="explorerLoadingStatusText" role="alert">
|
<p className="splashLoaderText" id="explorerLoadingStatusText" role="alert" data-bind="visible: selfServeType() === 'none'">
|
||||||
Connecting...
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
50
src/SelfServe/SelfServeComponentAdapter.tsx
Normal file
50
src/SelfServe/SelfServeComponentAdapter.tsx
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* This adapter is responsible to render the React component
|
||||||
|
* If the component signals a change through the callback passed in the properties, it must render the React component when appropriate
|
||||||
|
* and update any knockout observables passed from the parent.
|
||||||
|
*/
|
||||||
|
import * as ko from "knockout";
|
||||||
|
import * as React from "react";
|
||||||
|
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
||||||
|
import Explorer from "../Explorer/Explorer";
|
||||||
|
import { Descriptor, SmartUiComponent } from "../Explorer/Controls/SmartUi/SmartUiComponent";
|
||||||
|
import { SelfServeTypes } from "./SelfServeUtils";
|
||||||
|
import { SqlX } from "./SqlX/SqlX";
|
||||||
|
|
||||||
|
export class SelfServeComponentAdapter implements ReactAdapter {
|
||||||
|
public parameters: ko.Observable<number>;
|
||||||
|
public container: Explorer;
|
||||||
|
|
||||||
|
constructor(container: Explorer) {
|
||||||
|
this.container = container;
|
||||||
|
this.parameters = ko.observable(Date.now());
|
||||||
|
this.container.selfServeType.subscribe(() => {this.triggerRender()})
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDescriptor = (selfServeType : SelfServeTypes) : Descriptor => {
|
||||||
|
switch (selfServeType) {
|
||||||
|
case SelfServeTypes.sqlx:
|
||||||
|
return SqlX.toSmartUiDescriptor()
|
||||||
|
default:
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public renderComponent(): JSX.Element {
|
||||||
|
const selfServeType = this.container.selfServeType()
|
||||||
|
console.log("type:" + selfServeType)
|
||||||
|
const smartUiDescriptor = this.getDescriptor(selfServeType)
|
||||||
|
|
||||||
|
|
||||||
|
const element = smartUiDescriptor ?
|
||||||
|
<SmartUiComponent descriptor={smartUiDescriptor} /> :
|
||||||
|
<h1>Invalid self serve type!</h1>
|
||||||
|
|
||||||
|
|
||||||
|
return element
|
||||||
|
}
|
||||||
|
|
||||||
|
private triggerRender() {
|
||||||
|
window.requestAnimationFrame(() => this.parameters(Date.now()));
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/SelfServe/SelfServeLoadingComponentAdapter.tsx
Normal file
25
src/SelfServe/SelfServeLoadingComponentAdapter.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* This adapter is responsible to render the React component
|
||||||
|
* If the component signals a change through the callback passed in the properties, it must render the React component when appropriate
|
||||||
|
* and update any knockout observables passed from the parent.
|
||||||
|
*/
|
||||||
|
import * as ko from "knockout";
|
||||||
|
import { Spinner, SpinnerSize } from "office-ui-fabric-react";
|
||||||
|
import * as React from "react";
|
||||||
|
import { ReactAdapter } from "../Bindings/ReactBindingHandler";
|
||||||
|
|
||||||
|
export class SelfServeLoadingComponentAdapter implements ReactAdapter {
|
||||||
|
public parameters: ko.Observable<number>;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.parameters = ko.observable(Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
public renderComponent(): JSX.Element {
|
||||||
|
return <Spinner size={SpinnerSize.large} />
|
||||||
|
}
|
||||||
|
|
||||||
|
private triggerRender() {
|
||||||
|
window.requestAnimationFrame(() => this.parameters(Date.now()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -197,6 +197,7 @@ const getInput = (value: CommonInputTypes): AnyInput => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export enum SelfServeTypes {
|
export enum SelfServeTypes {
|
||||||
|
none="none",
|
||||||
sqlx="sqlx"
|
sqlx="sqlx"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user