mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 10:51:30 +00:00
Compare commits
10 Commits
eslint/fix
...
users/srna
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c7f4d1ddf | ||
|
|
78e5c88e3c | ||
|
|
c0bd74ce1b | ||
|
|
c04ba728ef | ||
|
|
127b16cfc8 | ||
|
|
0f281c7a64 | ||
|
|
659d5a6677 | ||
|
|
5f66f113af | ||
|
|
b1c238f43a | ||
|
|
445d2650a2 |
@@ -3,7 +3,7 @@ import {
|
|||||||
Resource,
|
Resource,
|
||||||
StoredProcedureDefinition,
|
StoredProcedureDefinition,
|
||||||
TriggerDefinition,
|
TriggerDefinition,
|
||||||
UserDefinedFunctionDefinition,
|
UserDefinedFunctionDefinition
|
||||||
} from "@azure/cosmos";
|
} from "@azure/cosmos";
|
||||||
import Explorer from "../Explorer/Explorer";
|
import Explorer from "../Explorer/Explorer";
|
||||||
import { ConsoleData } from "../Explorer/Menus/NotificationConsole/ConsoleData";
|
import { ConsoleData } from "../Explorer/Menus/NotificationConsole/ConsoleData";
|
||||||
@@ -370,6 +370,7 @@ export enum TerminalKind {
|
|||||||
Default = 0,
|
Default = 0,
|
||||||
Mongo = 1,
|
Mongo = 1,
|
||||||
Cassandra = 2,
|
Cassandra = 2,
|
||||||
|
PostgreSQL = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DataExplorerInputsFrame {
|
export interface DataExplorerInputsFrame {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import _ from "underscore";
|
|||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
|
||||||
import * as Constants from "../Common/Constants";
|
import * as Constants from "../Common/Constants";
|
||||||
|
import { HttpHeaders } from "../Common/Constants";
|
||||||
import { readCollection } from "../Common/dataAccess/readCollection";
|
import { readCollection } from "../Common/dataAccess/readCollection";
|
||||||
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
||||||
import { isPublicInternetAccessAllowed } from "../Common/DatabaseAccountUtility";
|
import { isPublicInternetAccessAllowed } from "../Common/DatabaseAccountUtility";
|
||||||
@@ -24,12 +25,6 @@ import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
|||||||
import { userContext } from "../UserContext";
|
import { userContext } from "../UserContext";
|
||||||
import { getCollectionName, getDatabaseName, getUploadName } from "../Utils/APITypeUtils";
|
import { getCollectionName, getDatabaseName, getUploadName } from "../Utils/APITypeUtils";
|
||||||
import { update } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
import { update } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
|
||||||
import {
|
|
||||||
get as getWorkspace,
|
|
||||||
listByDatabaseAccount,
|
|
||||||
listConnectionInfo,
|
|
||||||
start,
|
|
||||||
} from "../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces";
|
|
||||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||||
import { stringToBlob } from "../Utils/BlobUtils";
|
import { stringToBlob } from "../Utils/BlobUtils";
|
||||||
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
|
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
|
||||||
@@ -69,6 +64,8 @@ import StoredProcedure from "./Tree/StoredProcedure";
|
|||||||
import { useDatabases } from "./useDatabases";
|
import { useDatabases } from "./useDatabases";
|
||||||
import { useSelectedNode } from "./useSelectedNode";
|
import { useSelectedNode } from "./useSelectedNode";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
var tmp = ComponentRegisterer;
|
var tmp = ComponentRegisterer;
|
||||||
@@ -458,16 +455,35 @@ export default class Explorer {
|
|||||||
this._isInitializingNotebooks = true;
|
this._isInitializingNotebooks = true;
|
||||||
|
|
||||||
await this.ensureNotebookWorkspaceRunning();
|
await this.ensureNotebookWorkspaceRunning();
|
||||||
|
/*
|
||||||
const connectionInfo = await listConnectionInfo(
|
const connectionInfo = await listConnectionInfo(
|
||||||
userContext.subscriptionId,
|
userContext.subscriptionId,
|
||||||
userContext.resourceGroup,
|
userContext.resourceGroup,
|
||||||
databaseAccount.name,
|
databaseAccount.name,
|
||||||
"default"
|
"default"
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
const provisionData = {
|
||||||
|
cosmosEndpoint: userContext.databaseAccount.properties.documentEndpoint,
|
||||||
|
resourceId: userContext.databaseAccount.id,
|
||||||
|
dbAccountName: userContext.databaseAccount.name,
|
||||||
|
aadToken: userContext.authorizationToken,
|
||||||
|
resourceGroup: userContext.resourceGroup,
|
||||||
|
subscriptionId: userContext.subscriptionId
|
||||||
|
}
|
||||||
|
const response = await window.fetch("http://localhost:443/api/containerpooling/provision", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
[HttpHeaders.contentType]: "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(provisionData)
|
||||||
|
})
|
||||||
|
var notebookServerInfo = await response.json();
|
||||||
|
|
||||||
this.notebookServerInfo({
|
this.notebookServerInfo({
|
||||||
notebookServerEndpoint: userContext.features.notebookServerUrl || connectionInfo.notebookServerEndpoint,
|
notebookServerEndpoint: userContext.features.notebookServerUrl || notebookServerInfo.notebookServerUrl,
|
||||||
authToken: userContext.features.notebookServerToken || connectionInfo.authToken,
|
authToken: userContext.features.notebookServerToken || notebookServerInfo.notebookServerToken,
|
||||||
});
|
});
|
||||||
this.notebookServerInfo.valueHasMutated();
|
this.notebookServerInfo.valueHasMutated();
|
||||||
this.refreshNotebookList();
|
this.refreshNotebookList();
|
||||||
@@ -501,6 +517,7 @@ export default class Explorer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
const { value: workspaces } = await listByDatabaseAccount(
|
const { value: workspaces } = await listByDatabaseAccount(
|
||||||
userContext.subscriptionId,
|
userContext.subscriptionId,
|
||||||
@@ -512,6 +529,8 @@ export default class Explorer {
|
|||||||
Logger.logError(getErrorMessage(error), "Explorer/_containsDefaultNotebookWorkspace");
|
Logger.logError(getErrorMessage(error), "Explorer/_containsDefaultNotebookWorkspace");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private async ensureNotebookWorkspaceRunning() {
|
private async ensureNotebookWorkspaceRunning() {
|
||||||
@@ -519,6 +538,7 @@ export default class Explorer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
let clearMessage;
|
let clearMessage;
|
||||||
try {
|
try {
|
||||||
const notebookWorkspace = await getWorkspace(
|
const notebookWorkspace = await getWorkspace(
|
||||||
@@ -541,6 +561,7 @@ export default class Explorer {
|
|||||||
} finally {
|
} finally {
|
||||||
clearMessage && clearMessage();
|
clearMessage && clearMessage();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private _resetNotebookWorkspace = async () => {
|
private _resetNotebookWorkspace = async () => {
|
||||||
@@ -1131,6 +1152,10 @@ export default class Explorer {
|
|||||||
title = "Cassandra Shell";
|
title = "Cassandra Shell";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ViewModels.TerminalKind.PostgreSQL:
|
||||||
|
title = "PostgreSQL Shell";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error("Terminal kind: ${kind} not supported");
|
throw new Error("Terminal kind: ${kind} not supported");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,18 +74,17 @@ export function createStaticCommandBarButtons(
|
|||||||
buttons.push(createOpenTerminalButton(container));
|
buttons.push(createOpenTerminalButton(container));
|
||||||
|
|
||||||
buttons.push(createNotebookWorkspaceResetButton(container));
|
buttons.push(createNotebookWorkspaceResetButton(container));
|
||||||
if (
|
|
||||||
(userContext.apiType === "Mongo" &&
|
|
||||||
container.isShellEnabled() &&
|
|
||||||
selectedNodeState.isDatabaseNodeOrNoneSelected()) ||
|
|
||||||
userContext.apiType === "Cassandra"
|
|
||||||
) {
|
|
||||||
buttons.push(createDivider());
|
buttons.push(createDivider());
|
||||||
if (userContext.apiType === "Cassandra") {
|
buttons.push(createOpenPostgreSQLTerminalButton(container));
|
||||||
buttons.push(createOpenCassandraTerminalButton(container));
|
|
||||||
} else {
|
if (userContext.apiType === "Mongo" &&
|
||||||
|
container.isShellEnabled() &&
|
||||||
|
selectedNodeState.isDatabaseNodeOrNoneSelected()){
|
||||||
buttons.push(createOpenMongoTerminalButton(container));
|
buttons.push(createOpenMongoTerminalButton(container));
|
||||||
}
|
}
|
||||||
|
if (userContext.apiType === "Cassandra") {
|
||||||
|
buttons.push(createOpenCassandraTerminalButton(container));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isRunningOnNationalCloud()) {
|
if (!isRunningOnNationalCloud()) {
|
||||||
@@ -468,6 +467,19 @@ function createOpenTerminalButton(container: Explorer): CommandButtonComponentPr
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createOpenPostgreSQLTerminalButton(container: Explorer): CommandButtonComponentProps {
|
||||||
|
const label = "Open PostgreSQL Shell";
|
||||||
|
return {
|
||||||
|
iconSrc: HostedTerminalIcon,
|
||||||
|
iconAlt: label,
|
||||||
|
onCommandClick: () => container.openNotebookTerminal(ViewModels.TerminalKind.PostgreSQL),
|
||||||
|
commandButtonLabel: label,
|
||||||
|
hasPopup: false,
|
||||||
|
disabled: false,
|
||||||
|
ariaLabel: label,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function createOpenMongoTerminalButton(container: Explorer): CommandButtonComponentProps {
|
function createOpenMongoTerminalButton(container: Explorer): CommandButtonComponentProps {
|
||||||
const label = "Open Mongo Shell";
|
const label = "Open Mongo Shell";
|
||||||
const tooltip =
|
const tooltip =
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
KernelRef,
|
KernelRef,
|
||||||
RemoteKernelProps,
|
RemoteKernelProps,
|
||||||
selectors,
|
selectors,
|
||||||
ServerConfig as JupyterServerConfig,
|
ServerConfig as JupyterServerConfig
|
||||||
} from "@nteract/core";
|
} from "@nteract/core";
|
||||||
import { Channels, childOf, createMessage, JupyterMessage, message, ofMessageType } from "@nteract/messaging";
|
import { Channels, childOf, createMessage, JupyterMessage, message, ofMessageType } from "@nteract/messaging";
|
||||||
import { RecordOf } from "immutable";
|
import { RecordOf } from "immutable";
|
||||||
@@ -29,7 +29,7 @@ import {
|
|||||||
switchMap,
|
switchMap,
|
||||||
take,
|
take,
|
||||||
tap,
|
tap,
|
||||||
timeout,
|
timeout
|
||||||
} from "rxjs/operators";
|
} from "rxjs/operators";
|
||||||
import { webSocket } from "rxjs/webSocket";
|
import { webSocket } from "rxjs/webSocket";
|
||||||
import * as Constants from "../../../Common/Constants";
|
import * as Constants from "../../../Common/Constants";
|
||||||
@@ -107,7 +107,7 @@ const formWebSocketURL = (serverConfig: NotebookServiceConfig, kernelId: string,
|
|||||||
const q = params.toString();
|
const q = params.toString();
|
||||||
const suffix = q !== "" ? `?${q}` : "";
|
const suffix = q !== "" ? `?${q}` : "";
|
||||||
|
|
||||||
const url = (serverConfig.endpoint || "") + `api/kernels/${kernelId}/channels${suffix}`;
|
const url = (serverConfig.endpoint.slice(0, -1) || "") + `api/kernels/${kernelId}/channels${suffix}`;
|
||||||
|
|
||||||
return url.replace(/^http(s)?/, "ws$1");
|
return url.replace(/^http(s)?/, "ws$1");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { getErrorMessage } from "../../Common/ErrorHandlingUtils";
|
|||||||
import * as Logger from "../../Common/Logger";
|
import * as Logger from "../../Common/Logger";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { createOrUpdate, destroy } from "../../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces";
|
|
||||||
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
|
|
||||||
export class NotebookContainerClient {
|
export class NotebookContainerClient {
|
||||||
@@ -54,7 +53,7 @@ export class NotebookContainerClient {
|
|||||||
|
|
||||||
const { notebookServerEndpoint, authToken } = this.getNotebookServerConfig();
|
const { notebookServerEndpoint, authToken } = this.getNotebookServerConfig();
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${notebookServerEndpoint}/api/metrics/memory`, {
|
const response = await fetch(`${notebookServerEndpoint}api/metrics/memory`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: authToken,
|
Authorization: authToken,
|
||||||
@@ -135,6 +134,7 @@ export class NotebookContainerClient {
|
|||||||
if (!databaseAccount?.id) {
|
if (!databaseAccount?.id) {
|
||||||
throw new Error("DataExplorer not initialized");
|
throw new Error("DataExplorer not initialized");
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
await destroy(userContext.subscriptionId, userContext.resourceGroup, userContext.databaseAccount.name, "default");
|
await destroy(userContext.subscriptionId, userContext.resourceGroup, userContext.databaseAccount.name, "default");
|
||||||
await createOrUpdate(
|
await createOrUpdate(
|
||||||
@@ -147,5 +147,6 @@ export class NotebookContainerClient {
|
|||||||
Logger.logError(getErrorMessage(error), "NotebookContainerClient/recreateNotebookWorkspaceAsync");
|
Logger.logError(getErrorMessage(error), "NotebookContainerClient/recreateNotebookWorkspaceAsync");
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export class NotebookContentClient {
|
|||||||
private notebookServerInfo: ko.Observable<DataModels.NotebookWorkspaceConnectionInfo>,
|
private notebookServerInfo: ko.Observable<DataModels.NotebookWorkspaceConnectionInfo>,
|
||||||
public notebookBasePath: ko.Observable<string>,
|
public notebookBasePath: ko.Observable<string>,
|
||||||
private contentProvider: IContentProvider
|
private contentProvider: IContentProvider
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This updates the item and points all the children's parent to this item
|
* This updates the item and points all the children's parent to this item
|
||||||
@@ -25,6 +25,9 @@ export class NotebookContentClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sleep = (milliseconds: number) => {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parent parent folder
|
* @param parent parent folder
|
||||||
@@ -35,6 +38,7 @@ export class NotebookContentClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const type = "notebook";
|
const type = "notebook";
|
||||||
|
|
||||||
return this.contentProvider
|
return this.contentProvider
|
||||||
.create<"notebook">(this.getServerConfig(), parent.path, { type })
|
.create<"notebook">(this.getServerConfig(), parent.path, { type })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import SaveIcon from "../../../images/save-cosmos.svg";
|
|||||||
import { useNotebookSnapshotStore } from "../../hooks/useNotebookSnapshotStore";
|
import { useNotebookSnapshotStore } from "../../hooks/useNotebookSnapshotStore";
|
||||||
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils";
|
|
||||||
import { logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
|
||||||
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
|
||||||
import * as CommandBarComponentButtonFactory from "../Menus/CommandBar/CommandBarComponentButtonFactory";
|
import * as CommandBarComponentButtonFactory from "../Menus/CommandBar/CommandBarComponentButtonFactory";
|
||||||
@@ -361,12 +360,14 @@ export default class NotebookTabV2 extends NotebookTabBase {
|
|||||||
private async configureServiceEndpoints(kernelName: string) {
|
private async configureServiceEndpoints(kernelName: string) {
|
||||||
const notebookConnectionInfo = this.container && this.container.notebookServerInfo();
|
const notebookConnectionInfo = this.container && this.container.notebookServerInfo();
|
||||||
const sparkClusterConnectionInfo = this.container && this.container.sparkClusterConnectionInfo();
|
const sparkClusterConnectionInfo = this.container && this.container.sparkClusterConnectionInfo();
|
||||||
|
/*
|
||||||
await NotebookConfigurationUtils.configureServiceEndpoints(
|
await NotebookConfigurationUtils.configureServiceEndpoints(
|
||||||
this.notebookPath(),
|
this.notebookPath(),
|
||||||
notebookConnectionInfo,
|
notebookConnectionInfo,
|
||||||
kernelName,
|
kernelName,
|
||||||
sparkClusterConnectionInfo
|
sparkClusterConnectionInfo
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private publishToGallery = async () => {
|
private publishToGallery = async () => {
|
||||||
|
|||||||
@@ -91,6 +91,10 @@ export default class TerminalTab extends TabsBase {
|
|||||||
endpointSuffix = "cassandra";
|
endpointSuffix = "cassandra";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ViewModels.TerminalKind.PostgreSQL:
|
||||||
|
endpointSuffix = "postgreSQL";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Terminal kind: ${options.kind} not supported`);
|
throw new Error(`Terminal kind: ${options.kind} not supported`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user