mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-21 01:41:31 +00:00
initial changes for CP
This commit is contained in:
@@ -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";
|
||||||
@@ -25,12 +26,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";
|
||||||
@@ -71,6 +66,8 @@ import { ResourceTreeAdapterForResourceToken } from "./Tree/ResourceTreeAdapterF
|
|||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import { useDatabases } from "./useDatabases";
|
import { useDatabases } from "./useDatabases";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
@@ -511,16 +508,32 @@ 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 = {
|
||||||
|
cosmosKey: userContext.masterKey,
|
||||||
|
cosmosEndpoint: userContext.databaseAccount.properties.documentEndpoint,
|
||||||
|
resourceId: userContext.databaseAccount.id,
|
||||||
|
dbAcountName: userContext.databaseAccount.name
|
||||||
|
}
|
||||||
|
const response = await window.fetch("http://localhost:443/api/containerpooling/provision", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
[HttpHeaders.contentType]: "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(provisionData)
|
||||||
|
})
|
||||||
|
|
||||||
this.notebookServerInfo({
|
this.notebookServerInfo({
|
||||||
notebookServerEndpoint: userContext.features.notebookServerUrl || connectionInfo.notebookServerEndpoint,
|
notebookServerEndpoint: userContext.features.notebookServerUrl || `http://localhost:443/api/containerpooling/resid${userContext.databaseAccount.id}/forward/`,
|
||||||
authToken: userContext.features.notebookServerToken || connectionInfo.authToken,
|
authToken: userContext.features.notebookServerToken || "token",
|
||||||
});
|
});
|
||||||
this.notebookServerInfo.valueHasMutated();
|
this.notebookServerInfo.valueHasMutated();
|
||||||
this.refreshNotebookList();
|
this.refreshNotebookList();
|
||||||
@@ -554,6 +567,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,
|
||||||
@@ -565,6 +579,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() {
|
||||||
@@ -572,6 +588,7 @@ export default class Explorer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
let clearMessage;
|
let clearMessage;
|
||||||
try {
|
try {
|
||||||
const notebookWorkspace = await getWorkspace(
|
const notebookWorkspace = await getWorkspace(
|
||||||
@@ -594,6 +611,7 @@ export default class Explorer {
|
|||||||
} finally {
|
} finally {
|
||||||
clearMessage && clearMessage();
|
clearMessage && clearMessage();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private _resetNotebookWorkspace = async () => {
|
private _resetNotebookWorkspace = async () => {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,15 @@ export class NotebookContentClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const type = "notebook";
|
const type = "notebook";
|
||||||
|
const item = NotebookUtil.createNotebookContentItem("Sample.ipynb", "notebooks/Sample.ipynb", "notebook");
|
||||||
|
if (parent.children) {
|
||||||
|
item.parent = parent;
|
||||||
|
parent.children.push(item);
|
||||||
|
}
|
||||||
|
return this.sleep(1000).then(() => item);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
return this.contentProvider
|
return this.contentProvider
|
||||||
.create<"notebook">(this.getServerConfig(), parent.path, { type })
|
.create<"notebook">(this.getServerConfig(), parent.path, { type })
|
||||||
.toPromise()
|
.toPromise()
|
||||||
@@ -57,6 +69,7 @@ export class NotebookContentClient {
|
|||||||
|
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteContentItem(item: NotebookContentItem): Promise<void> {
|
public deleteContentItem(item: NotebookContentItem): Promise<void> {
|
||||||
@@ -242,9 +255,7 @@ export class NotebookContentClient {
|
|||||||
|
|
||||||
private fetchNotebookFiles(path: string): Promise<NotebookContentItem[]> {
|
private fetchNotebookFiles(path: string): Promise<NotebookContentItem[]> {
|
||||||
return this.contentProvider
|
return this.contentProvider
|
||||||
.get(this.getServerConfig(), path, {
|
.get(this.getServerConfig(), path + "/directory", {})
|
||||||
type: "directory",
|
|
||||||
})
|
|
||||||
.toPromise()
|
.toPromise()
|
||||||
.then((xhr) => {
|
.then((xhr) => {
|
||||||
if (xhr.status !== 200) {
|
if (xhr.status !== 200) {
|
||||||
|
|||||||
@@ -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 () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user