mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-06 18:07:11 +00:00
Not wroking code
This commit is contained in:
parent
76742455bf
commit
78c8df0904
33
package-lock.json
generated
33
package-lock.json
generated
@ -14042,17 +14042,6 @@
|
|||||||
"version": "1.12.0",
|
"version": "1.12.0",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
|
||||||
"version": "1.7.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
|
||||||
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"follow-redirects": "^1.15.6",
|
|
||||||
"form-data": "^4.0.0",
|
|
||||||
"proxy-from-env": "^1.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/babel-core": {
|
"node_modules/babel-core": {
|
||||||
"version": "7.0.0-bridge.0",
|
"version": "7.0.0-bridge.0",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -31155,12 +31144,6 @@
|
|||||||
"node": ">= 0.10"
|
"node": ">= 0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/proxy-from-env": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/prr": {
|
"node_modules/prr": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -46813,16 +46796,6 @@
|
|||||||
"aws4": {
|
"aws4": {
|
||||||
"version": "1.12.0"
|
"version": "1.12.0"
|
||||||
},
|
},
|
||||||
"axios": {
|
|
||||||
"version": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
|
||||||
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"follow-redirects": "^1.15.6",
|
|
||||||
"form-data": "^4.0.0",
|
|
||||||
"proxy-from-env": "^1.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"babel-core": {
|
"babel-core": {
|
||||||
"version": "7.0.0-bridge.0",
|
"version": "7.0.0-bridge.0",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -58547,12 +58520,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"proxy-from-env": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"prr": {
|
"prr": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as msal from "@azure/msal-browser";
|
import * as msal from "@azure/msal-browser";
|
||||||
import { Link } from "@fluentui/react/lib/Link";
|
import { Link } from "@fluentui/react/lib/Link";
|
||||||
|
import { Panel, Widget } from "@phosphor/widgets";
|
||||||
import { isPublicInternetAccessAllowed } from "Common/DatabaseAccountUtility";
|
import { isPublicInternetAccessAllowed } from "Common/DatabaseAccountUtility";
|
||||||
import { Environment, getEnvironment } from "Common/EnvironmentUtility";
|
import { Environment, getEnvironment } from "Common/EnvironmentUtility";
|
||||||
import { sendMessage } from "Common/MessageHandler";
|
import { sendMessage } from "Common/MessageHandler";
|
||||||
@ -17,18 +18,19 @@ import { useQueryCopilot } from "hooks/useQueryCopilot";
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import _ from "underscore";
|
import _ from "underscore";
|
||||||
|
import { Terminal as XTerminal } from 'xterm';
|
||||||
import shallow from "zustand/shallow";
|
import shallow from "zustand/shallow";
|
||||||
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 { Areas, ConnectionStatusType, HttpStatusCodes, Notebook, PoolIdType } from "../Common/Constants";
|
import { ConnectionStatusType, Notebook, PoolIdType } from "../Common/Constants";
|
||||||
import { getErrorMessage, getErrorStack, handleError } from "../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack, handleError } from "../Common/ErrorHandlingUtils";
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
import { QueriesClient } from "../Common/QueriesClient";
|
import { QueriesClient } from "../Common/QueriesClient";
|
||||||
import { readCollection, readSampleCollection } from "../Common/dataAccess/readCollection";
|
import { readCollection, readSampleCollection } from "../Common/dataAccess/readCollection";
|
||||||
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
import { readDatabases } from "../Common/dataAccess/readDatabases";
|
||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import { ContainerConnectionInfo, IPhoenixServiceInfo, IProvisionData, IResponse } from "../Contracts/DataModels";
|
import { IPhoenixServiceInfo, IResponse } from "../Contracts/DataModels";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
||||||
import { PhoenixClient } from "../Phoenix/PhoenixClient";
|
import { PhoenixClient } from "../Phoenix/PhoenixClient";
|
||||||
@ -377,87 +379,87 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async allocateContainer(poolId: PoolIdType, mode?: string): Promise<void> {
|
public async allocateContainer(poolId: PoolIdType, mode?: string): Promise<void> {
|
||||||
const shouldUseNotebookStates = poolId === PoolIdType.DefaultPoolId ? true : false;
|
// const shouldUseNotebookStates = poolId === PoolIdType.DefaultPoolId ? true : false;
|
||||||
const notebookServerInfo = shouldUseNotebookStates
|
// const notebookServerInfo = shouldUseNotebookStates
|
||||||
? useNotebook.getState().notebookServerInfo
|
// ? useNotebook.getState().notebookServerInfo
|
||||||
: useQueryCopilot.getState().notebookServerInfo;
|
// : useQueryCopilot.getState().notebookServerInfo;
|
||||||
|
|
||||||
const isAllocating = shouldUseNotebookStates
|
// const isAllocating = shouldUseNotebookStates
|
||||||
? useNotebook.getState().isAllocating
|
// ? useNotebook.getState().isAllocating
|
||||||
: useQueryCopilot.getState().isAllocatingContainer;
|
// : useQueryCopilot.getState().isAllocatingContainer;
|
||||||
if (
|
// if (
|
||||||
isAllocating === false &&
|
// isAllocating === false &&
|
||||||
(notebookServerInfo === undefined ||
|
// (notebookServerInfo === undefined ||
|
||||||
(notebookServerInfo && notebookServerInfo.notebookServerEndpoint === undefined))
|
// (notebookServerInfo && notebookServerInfo.notebookServerEndpoint === undefined))
|
||||||
) {
|
// ) {
|
||||||
const connectionStatus: ContainerConnectionInfo = {
|
// const connectionStatus: ContainerConnectionInfo = {
|
||||||
status: ConnectionStatusType.Connecting,
|
// status: ConnectionStatusType.Connecting,
|
||||||
};
|
// };
|
||||||
|
|
||||||
shouldUseNotebookStates && useNotebook.getState().setConnectionInfo(connectionStatus);
|
// shouldUseNotebookStates && useNotebook.getState().setConnectionInfo(connectionStatus);
|
||||||
|
|
||||||
let connectionInfo;
|
// let connectionInfo;
|
||||||
let provisionData: IProvisionData;
|
// let provisionData: IProvisionData;
|
||||||
try {
|
// try {
|
||||||
TelemetryProcessor.traceStart(Action.PhoenixConnection, {
|
// TelemetryProcessor.traceStart(Action.PhoenixConnection, {
|
||||||
dataExplorerArea: Areas.Notebook,
|
// dataExplorerArea: Areas.Notebook,
|
||||||
});
|
// });
|
||||||
if (shouldUseNotebookStates) {
|
// if (shouldUseNotebookStates) {
|
||||||
useNotebook.getState().setIsAllocating(true);
|
// useNotebook.getState().setIsAllocating(true);
|
||||||
provisionData = {
|
// provisionData = {
|
||||||
cosmosEndpoint: userContext?.databaseAccount?.properties?.documentEndpoint,
|
// cosmosEndpoint: userContext?.databaseAccount?.properties?.documentEndpoint,
|
||||||
poolId: undefined,
|
// poolId: undefined,
|
||||||
};
|
// };
|
||||||
} else {
|
// } else {
|
||||||
useQueryCopilot.getState().setIsAllocatingContainer(true);
|
// useQueryCopilot.getState().setIsAllocatingContainer(true);
|
||||||
provisionData = {
|
// provisionData = {
|
||||||
poolId: poolId,
|
// poolId: poolId,
|
||||||
databaseId: useTabs.getState().activeTab.collection.databaseId,
|
// databaseId: useTabs.getState().activeTab.collection.databaseId,
|
||||||
containerId: useTabs.getState().activeTab.collection.id(),
|
// containerId: useTabs.getState().activeTab.collection.id(),
|
||||||
mode: mode,
|
// mode: mode,
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
connectionInfo = await this.phoenixClient.allocateContainer(provisionData);
|
// // connectionInfo = await this.phoenixClient.allocateContainer(provisionData);
|
||||||
if (!connectionInfo?.data?.phoenixServiceUrl) {
|
// // if (!connectionInfo?.data?.phoenixServiceUrl) {
|
||||||
throw new Error(`PhoenixServiceUrl is invalid!`);
|
// // throw new Error(`PhoenixServiceUrl is invalid!`);
|
||||||
}
|
// // }
|
||||||
await this.setNotebookInfo(shouldUseNotebookStates, connectionInfo, connectionStatus);
|
// // await this.setNotebookInfo(shouldUseNotebookStates, connectionInfo, connectionStatus);
|
||||||
TelemetryProcessor.traceSuccess(Action.PhoenixConnection, {
|
// // TelemetryProcessor.traceSuccess(Action.PhoenixConnection, {
|
||||||
dataExplorerArea: Areas.Notebook,
|
// // dataExplorerArea: Areas.Notebook,
|
||||||
});
|
// // });
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
TelemetryProcessor.traceFailure(Action.PhoenixConnection, {
|
// TelemetryProcessor.traceFailure(Action.PhoenixConnection, {
|
||||||
dataExplorerArea: Areas.Notebook,
|
// dataExplorerArea: Areas.Notebook,
|
||||||
status: error.status,
|
// status: error.status,
|
||||||
error: getErrorMessage(error),
|
// error: getErrorMessage(error),
|
||||||
errorStack: getErrorStack(error),
|
// errorStack: getErrorStack(error),
|
||||||
});
|
// });
|
||||||
if (shouldUseNotebookStates) {
|
// if (shouldUseNotebookStates) {
|
||||||
connectionStatus.status = ConnectionStatusType.Failed;
|
// connectionStatus.status = ConnectionStatusType.Failed;
|
||||||
shouldUseNotebookStates
|
// shouldUseNotebookStates
|
||||||
? useNotebook.getState().resetContainerConnection(connectionStatus)
|
// ? useNotebook.getState().resetContainerConnection(connectionStatus)
|
||||||
: useQueryCopilot.getState().resetContainerConnection();
|
// : useQueryCopilot.getState().resetContainerConnection();
|
||||||
if (error?.status === HttpStatusCodes.Forbidden && error.message) {
|
// if (error?.status === HttpStatusCodes.Forbidden && error.message) {
|
||||||
useDialog.getState().showOkModalDialog("Connection Failed", `${error.message}`);
|
// useDialog.getState().showOkModalDialog("Connection Failed", `${error.message}`);
|
||||||
} else {
|
// } else {
|
||||||
useDialog
|
// useDialog
|
||||||
.getState()
|
// .getState()
|
||||||
.showOkModalDialog(
|
// .showOkModalDialog(
|
||||||
"Connection Failed",
|
// "Connection Failed",
|
||||||
"We are unable to connect to the temporary workspace. Please try again in a few minutes. If the error persists, file a support ticket.",
|
// "We are unable to connect to the temporary workspace. Please try again in a few minutes. If the error persists, file a support ticket.",
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
throw error;
|
// throw error;
|
||||||
} finally {
|
// } finally {
|
||||||
shouldUseNotebookStates
|
// shouldUseNotebookStates
|
||||||
? useNotebook.getState().setIsAllocating(false)
|
// ? useNotebook.getState().setIsAllocating(false)
|
||||||
: useQueryCopilot.getState().setIsAllocatingContainer(false);
|
// : useQueryCopilot.getState().setIsAllocatingContainer(false);
|
||||||
this.refreshCommandBarButtons();
|
// this.refreshCommandBarButtons();
|
||||||
this.refreshNotebookList();
|
// this.refreshNotebookList();
|
||||||
this._isInitializingNotebooks = false;
|
// this._isInitializingNotebooks = false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setNotebookInfo(
|
public async setNotebookInfo(
|
||||||
@ -907,19 +909,19 @@ export default class Explorer {
|
|||||||
|
|
||||||
public async openNotebookTerminal(kind: ViewModels.TerminalKind): Promise<void> {
|
public async openNotebookTerminal(kind: ViewModels.TerminalKind): Promise<void> {
|
||||||
if (useNotebook.getState().isPhoenixFeatures) {
|
if (useNotebook.getState().isPhoenixFeatures) {
|
||||||
await this.allocateContainer(PoolIdType.DefaultPoolId);
|
// //await this.allocateContainer(PoolIdType.DefaultPoolId);
|
||||||
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
// //const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
||||||
if (notebookServerInfo && notebookServerInfo.notebookServerEndpoint !== undefined) {
|
// // if (notebookServerInfo && notebookServerInfo.notebookServerEndpoint !== undefined) {
|
||||||
this.connectToNotebookTerminal(kind);
|
// this.connectToNotebookTerminal(kind);
|
||||||
} else {
|
// // } else {
|
||||||
useDialog
|
// // useDialog
|
||||||
.getState()
|
// // .getState()
|
||||||
.showOkModalDialog(
|
// // .showOkModalDialog(
|
||||||
"Failed to connect",
|
// // "Failed to connect",
|
||||||
"Failed to connect to temporary workspace. This could happen because of network issues. Please refresh the page and try again.",
|
// // "Failed to connect to temporary workspace. This could happen because of network issues. Please refresh the page and try again.",
|
||||||
);
|
// // );
|
||||||
}
|
// // }
|
||||||
} else {
|
// } else {
|
||||||
this.connectToNotebookTerminal(kind);
|
this.connectToNotebookTerminal(kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -972,6 +974,33 @@ export default class Explorer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useTabs.getState().activateNewTab(newTab);
|
useTabs.getState().activateNewTab(newTab);
|
||||||
|
|
||||||
|
const xterminal = new XTerminal();
|
||||||
|
|
||||||
|
// Ensure newTab.node is set to a valid HTMLDivElement
|
||||||
|
if (!newTab.node || !(newTab.node instanceof HTMLDivElement)) {
|
||||||
|
newTab.node = document.createElement('div'); // Create a div if not already set
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the container is an HTMLDivElement
|
||||||
|
const termContainer = newTab.node as unknown as HTMLDivElement;
|
||||||
|
termContainer.style.width = '100%';
|
||||||
|
termContainer.style.height = '100%';
|
||||||
|
|
||||||
|
// Append the container to the tab system if necessary
|
||||||
|
document.body.appendChild(termContainer); // Optional: Add it to the DOM if needed
|
||||||
|
|
||||||
|
// Attach xterm.js to the correct container
|
||||||
|
xterminal.open(termContainer);
|
||||||
|
|
||||||
|
const termWidget = new Widget();
|
||||||
|
termWidget.node.appendChild(termContainer);
|
||||||
|
|
||||||
|
const panel = new Panel();
|
||||||
|
panel.addWidget(termWidget);
|
||||||
|
|
||||||
|
// Write to the terminal
|
||||||
|
xterminal.write('I am new shell');
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openGallery(
|
public async openGallery(
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ import { IMessage, ITerminalConnection } from "@jupyterlab/services/lib/terminal
|
|||||||
import "@jupyterlab/terminal/style/index.css";
|
import "@jupyterlab/terminal/style/index.css";
|
||||||
import { MessageTypes } from "Contracts/ExplorerContracts";
|
import { MessageTypes } from "Contracts/ExplorerContracts";
|
||||||
import postRobot from "post-robot";
|
import postRobot from "post-robot";
|
||||||
|
import { Terminal as XTerminal } from 'xterm';
|
||||||
import { HttpHeaders } from "../Common/Constants";
|
import { HttpHeaders } from "../Common/Constants";
|
||||||
import { Action } from "../Shared/Telemetry/TelemetryConstants";
|
import { Action } from "../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
|
||||||
@ -11,7 +12,7 @@ import { JupyterLabAppFactory } from "./JupyterLabAppFactory";
|
|||||||
import { TerminalProps } from "./TerminalProps";
|
import { TerminalProps } from "./TerminalProps";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
let session: ITerminalConnection | undefined;
|
let session: ITerminalConnection | undefined | XTerminal;
|
||||||
|
|
||||||
const createServerSettings = (props: TerminalProps): ServerConnection.ISettings => {
|
const createServerSettings = (props: TerminalProps): ServerConnection.ISettings => {
|
||||||
let body: BodyInit | undefined;
|
let body: BodyInit | undefined;
|
||||||
@ -62,7 +63,37 @@ const initTerminal = async (props: TerminalProps): Promise<void> => {
|
|||||||
|
|
||||||
const serverSettings = createServerSettings(props);
|
const serverSettings = createServerSettings(props);
|
||||||
|
|
||||||
createTerminalApp(props, serverSettings);
|
//createTerminalApp(props, serverSettings);
|
||||||
|
|
||||||
|
|
||||||
|
const xterminal = new XTerminal();
|
||||||
|
|
||||||
|
// Ensure newTab.node is set to a valid HTMLDivElement
|
||||||
|
if (!newTab.node || !(newTab.node instanceof HTMLDivElement)) {
|
||||||
|
newTab.node = document.createElement('div'); // Create a div if not already set
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the container is an HTMLDivElement
|
||||||
|
const termContainer = newTab.node as unknown as HTMLDivElement;
|
||||||
|
termContainer.style.width = '100%';
|
||||||
|
termContainer.style.height = '100%';
|
||||||
|
|
||||||
|
// Append the container to the tab system if necessary
|
||||||
|
document.body.appendChild(termContainer); // Optional: Add it to the DOM if needed
|
||||||
|
|
||||||
|
// Attach xterm.js to the correct container
|
||||||
|
xterminal.open(termContainer);
|
||||||
|
|
||||||
|
const termWidget = new Widget();
|
||||||
|
termWidget.node.appendChild(termContainer);
|
||||||
|
|
||||||
|
const panel = new Panel();
|
||||||
|
panel.addWidget(termWidget);
|
||||||
|
|
||||||
|
// Write to the terminal
|
||||||
|
xterminal.write('I am new shell');
|
||||||
|
|
||||||
|
session = xterminal;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createTerminalApp = async (props: TerminalProps, serverSettings: ServerConnection.ISettings) => {
|
const createTerminalApp = async (props: TerminalProps, serverSettings: ServerConnection.ISettings) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user