mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-28 21:32:05 +00:00
Compare commits
3 Commits
users/v-pr
...
upload_doc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1d62d34d1 | ||
|
|
cf0c51337f | ||
|
|
1d6c0bbd1e |
@@ -1,23 +1,23 @@
|
|||||||
import {
|
import {
|
||||||
actions,
|
|
||||||
AppState,
|
AppState,
|
||||||
castToSessionId,
|
|
||||||
ContentRef,
|
ContentRef,
|
||||||
createKernelRef,
|
|
||||||
JupyterHostRecordProps,
|
JupyterHostRecordProps,
|
||||||
|
ServerConfig as JupyterServerConfig,
|
||||||
KernelInfo,
|
KernelInfo,
|
||||||
KernelRef,
|
KernelRef,
|
||||||
RemoteKernelProps,
|
RemoteKernelProps,
|
||||||
|
actions,
|
||||||
|
castToSessionId,
|
||||||
|
createKernelRef,
|
||||||
selectors,
|
selectors,
|
||||||
ServerConfig as JupyterServerConfig,
|
|
||||||
} from "@nteract/core";
|
} from "@nteract/core";
|
||||||
import { Channels, childOf, createMessage, JupyterMessage, message, ofMessageType } from "@nteract/messaging";
|
import { Channels, childOf, createMessage, message, ofMessageType } from "@nteract/messaging";
|
||||||
import { defineConfigOption } from "@nteract/mythic-configuration";
|
import { defineConfigOption } from "@nteract/mythic-configuration";
|
||||||
import { RecordOf } from "immutable";
|
import { RecordOf } from "immutable";
|
||||||
import { Action, AnyAction } from "redux";
|
import { Action, AnyAction } from "redux";
|
||||||
import { ofType, StateObservable } from "redux-observable";
|
import { StateObservable, ofType } from "redux-observable";
|
||||||
import { kernels, sessions } from "rx-jupyter";
|
import { kernels, sessions } from "rx-jupyter";
|
||||||
import { concat, EMPTY, from, interval, merge, Observable, Observer, of, Subject, Subscriber, timer } from "rxjs";
|
import { EMPTY, Observable, Observer, Subject, Subscriber, concat, from, interval, merge, of, timer } from "rxjs";
|
||||||
import {
|
import {
|
||||||
catchError,
|
catchError,
|
||||||
concatMap,
|
concatMap,
|
||||||
@@ -35,17 +35,17 @@ import {
|
|||||||
import { webSocket } from "rxjs/webSocket";
|
import { webSocket } from "rxjs/webSocket";
|
||||||
import * as Constants from "../../../Common/Constants";
|
import * as Constants from "../../../Common/Constants";
|
||||||
import { Areas } from "../../../Common/Constants";
|
import { Areas } from "../../../Common/Constants";
|
||||||
import { useTabs } from "../../../hooks/useTabs";
|
import { ActionModifiers, Action as TelemetryAction } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
import { Action as TelemetryAction, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
|
||||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { logConsoleError, logConsoleInfo } from "../../../Utils/NotificationConsoleUtils";
|
import { logConsoleError, logConsoleInfo } from "../../../Utils/NotificationConsoleUtils";
|
||||||
|
import { useTabs } from "../../../hooks/useTabs";
|
||||||
import { useDialog } from "../../Controls/Dialog";
|
import { useDialog } from "../../Controls/Dialog";
|
||||||
import * as FileSystemUtil from "../FileSystemUtil";
|
import * as FileSystemUtil from "../FileSystemUtil";
|
||||||
import * as cdbActions from "../NotebookComponent/actions";
|
import * as cdbActions from "../NotebookComponent/actions";
|
||||||
import { NotebookContentProviderType, NotebookUtil } from "../NotebookUtil";
|
import { NotebookContentProviderType, NotebookUtil } from "../NotebookUtil";
|
||||||
import * as CdbActions from "./actions";
|
import * as CdbActions from "./actions";
|
||||||
import * as TextFile from "./contents/file/text-file";
|
import * as TextFile from "./contents/file/text-file";
|
||||||
import { CdbAppState } from "./types";
|
import { CdbAppState, JupyterMessage } from "./types";
|
||||||
|
|
||||||
interface NotebookServiceConfig extends JupyterServerConfig {
|
interface NotebookServiceConfig extends JupyterServerConfig {
|
||||||
userPuid?: string;
|
userPuid?: string;
|
||||||
@@ -106,10 +106,8 @@ const formWebSocketURL = (serverConfig: NotebookServiceConfig, kernelId: string,
|
|||||||
if (sessionId) {
|
if (sessionId) {
|
||||||
params.append("session_id", sessionId);
|
params.append("session_id", sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const q = params.toString();
|
const q = params.toString();
|
||||||
const suffix = q !== "" ? `?${q}` : "";
|
const suffix = q !== "" ? `?${q}` : "";
|
||||||
|
|
||||||
const url = (serverConfig.endpoint.slice(0, -1) || "") + `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");
|
||||||
@@ -241,10 +239,10 @@ const connect = (serverConfig: NotebookServiceConfig, kernelID: string, sessionI
|
|||||||
...message,
|
...message,
|
||||||
header: {
|
header: {
|
||||||
session: sessionID,
|
session: sessionID,
|
||||||
|
token: serverConfig.token,
|
||||||
...message.header,
|
...message.header,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
wsSubject.next(sessionizedMessage);
|
wsSubject.next(sessionizedMessage);
|
||||||
} else {
|
} else {
|
||||||
console.error("Message must be an object, the app sent", message);
|
console.error("Message must be an object, the app sent", message);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { CellId } from "@nteract/commutable";
|
import { CellId } from "@nteract/commutable";
|
||||||
import { AppState } from "@nteract/core";
|
import { AppState } from "@nteract/core";
|
||||||
|
import { MessageType } from "@nteract/messaging";
|
||||||
import * as Immutable from "immutable";
|
import * as Immutable from "immutable";
|
||||||
import { Notebook } from "../../../Common/Constants";
|
import { Notebook } from "../../../Common/Constants";
|
||||||
|
|
||||||
@@ -53,3 +54,26 @@ export const makeCdbRecord = Immutable.Record<CdbRecordProps>({
|
|||||||
pendingSnapshotRequest: undefined,
|
pendingSnapshotRequest: undefined,
|
||||||
notebookSnapshotError: undefined,
|
notebookSnapshotError: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export interface JupyterMessage<MT extends MessageType = MessageType, C = any> {
|
||||||
|
header: JupyterMessageHeader<MT>;
|
||||||
|
parent_header:
|
||||||
|
| JupyterMessageHeader<any>
|
||||||
|
| {
|
||||||
|
msg_id?: string;
|
||||||
|
};
|
||||||
|
metadata: object;
|
||||||
|
content: C;
|
||||||
|
channel: string;
|
||||||
|
buffers?: Uint8Array | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface JupyterMessageHeader<MT extends MessageType = MessageType> {
|
||||||
|
msg_id: string;
|
||||||
|
username: string;
|
||||||
|
date: string;
|
||||||
|
msg_type: MT;
|
||||||
|
version: string;
|
||||||
|
session: string;
|
||||||
|
token: string;
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,11 +13,8 @@ import {
|
|||||||
} from "@fluentui/react";
|
} from "@fluentui/react";
|
||||||
import { QueryCopilotSampleDatabaseId, StyleConstants } from "Common/Constants";
|
import { QueryCopilotSampleDatabaseId, StyleConstants } from "Common/Constants";
|
||||||
import { handleError } from "Common/ErrorHandlingUtils";
|
import { handleError } from "Common/ErrorHandlingUtils";
|
||||||
import { createCollection } from "Common/dataAccess/createCollection";
|
|
||||||
import * as DataModels from "Contracts/DataModels";
|
|
||||||
import { ContainerSampleGenerator } from "Explorer/DataSamples/ContainerSampleGenerator";
|
import { ContainerSampleGenerator } from "Explorer/DataSamples/ContainerSampleGenerator";
|
||||||
import Explorer from "Explorer/Explorer";
|
import Explorer from "Explorer/Explorer";
|
||||||
import { AllPropertiesIndexed } from "Explorer/Panes/AddCollectionPanel";
|
|
||||||
import { PromptCard } from "Explorer/QueryCopilot/PromptCard";
|
import { PromptCard } from "Explorer/QueryCopilot/PromptCard";
|
||||||
import { useDatabases } from "Explorer/useDatabases";
|
import { useDatabases } from "Explorer/useDatabases";
|
||||||
import { useCarousel } from "hooks/useCarousel";
|
import { useCarousel } from "hooks/useCarousel";
|
||||||
@@ -78,30 +75,27 @@ export const QueryCopilotCarousel: React.FC<QueryCopilotCarouselProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createSampleDatabase = async (): Promise<void> => {
|
const createSampleDatabase = async (): Promise<void> => {
|
||||||
const database = useDatabases.getState().findDatabaseWithId(QueryCopilotSampleDatabaseId);
|
// const database = useDatabases.getState().findDatabaseWithId(QueryCopilotSampleDatabaseId);
|
||||||
if (database) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsCreatingDatabase(true);
|
// setIsCreatingDatabase(true);
|
||||||
setSpinnerText("Setting up your database...");
|
// setSpinnerText("Setting up your database...");
|
||||||
const params: DataModels.CreateCollectionParams = {
|
// const params: DataModels.CreateCollectionParams = {
|
||||||
createNewDatabase: true,
|
// createNewDatabase: false,
|
||||||
collectionId: "SampleContainer",
|
// collectionId: "SampleContainer",
|
||||||
databaseId: QueryCopilotSampleDatabaseId,
|
// databaseId: QueryCopilotSampleDatabaseId,
|
||||||
databaseLevelThroughput: true,
|
// databaseLevelThroughput: true,
|
||||||
autoPilotMaxThroughput: 1000,
|
// autoPilotMaxThroughput: 1000,
|
||||||
offerThroughput: undefined,
|
// offerThroughput: undefined,
|
||||||
indexingPolicy: AllPropertiesIndexed,
|
// indexingPolicy: AllPropertiesIndexed,
|
||||||
partitionKey: {
|
// partitionKey: {
|
||||||
paths: ["/categoryId"],
|
// paths: ["/categoryId"],
|
||||||
kind: "Hash",
|
// kind: "Hash",
|
||||||
version: 2,
|
// version: 2,
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
await createCollection(params);
|
// await createCollection(params);
|
||||||
await explorer.refreshAllDatabases();
|
// await explorer.refreshAllDatabases();
|
||||||
const database = useDatabases.getState().findDatabaseWithId(QueryCopilotSampleDatabaseId);
|
const database = useDatabases.getState().findDatabaseWithId(QueryCopilotSampleDatabaseId);
|
||||||
await database.loadCollections();
|
await database.loadCollections();
|
||||||
const collection = database.findCollectionWithId("SampleContainer");
|
const collection = database.findCollectionWithId("SampleContainer");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { FeedOptions } from "@azure/cosmos";
|
import { FeedOptions, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||||
import {
|
import {
|
||||||
Callout,
|
Callout,
|
||||||
CommandBarButton,
|
CommandBarButton,
|
||||||
@@ -25,7 +25,8 @@ import {
|
|||||||
import { getErrorMessage, handleError } from "Common/ErrorHandlingUtils";
|
import { getErrorMessage, handleError } from "Common/ErrorHandlingUtils";
|
||||||
import { shouldEnableCrossPartitionKey } from "Common/HeadersUtility";
|
import { shouldEnableCrossPartitionKey } from "Common/HeadersUtility";
|
||||||
import { MinimalQueryIterator } from "Common/IteratorUtilities";
|
import { MinimalQueryIterator } from "Common/IteratorUtilities";
|
||||||
import { queryDocuments } from "Common/dataAccess/queryDocuments";
|
import { sampleDataClient } from "Common/SampleDataClient";
|
||||||
|
import { getCommonQueryOptions } from "Common/dataAccess/queryDocuments";
|
||||||
import { queryDocumentsPage } from "Common/dataAccess/queryDocumentsPage";
|
import { queryDocumentsPage } from "Common/dataAccess/queryDocumentsPage";
|
||||||
import { QueryResults } from "Contracts/ViewModels";
|
import { QueryResults } from "Contracts/ViewModels";
|
||||||
import { CommandButtonComponentProps } from "Explorer/Controls/CommandButton/CommandButtonComponent";
|
import { CommandButtonComponentProps } from "Explorer/Controls/CommandButton/CommandButtonComponent";
|
||||||
@@ -199,9 +200,17 @@ export const QueryCopilotTab: React.FC<QueryCopilotTabProps> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const querySampleDocuments = (query: string, options: FeedOptions): QueryIterator<ItemDefinition & Resource> => {
|
||||||
|
options = getCommonQueryOptions(options);
|
||||||
|
return sampleDataClient()
|
||||||
|
.database(QueryCopilotSampleDatabaseId)
|
||||||
|
.container(QueryCopilotSampleContainerId)
|
||||||
|
.items.query(query, options);
|
||||||
|
};
|
||||||
|
|
||||||
const onExecuteQueryClick = async (): Promise<void> => {
|
const onExecuteQueryClick = async (): Promise<void> => {
|
||||||
const queryToExecute = selectedQuery || query;
|
const queryToExecute = selectedQuery || query;
|
||||||
const queryIterator = queryDocuments(QueryCopilotSampleDatabaseId, QueryCopilotSampleContainerId, queryToExecute, {
|
const queryIterator = querySampleDocuments(queryToExecute, {
|
||||||
enableCrossPartitionQuery: shouldEnableCrossPartitionKey(),
|
enableCrossPartitionQuery: shouldEnableCrossPartitionKey(),
|
||||||
} as FeedOptions);
|
} as FeedOptions);
|
||||||
setQueryIterator(queryIterator);
|
setQueryIterator(queryIterator);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ initializeIcons();
|
|||||||
const App: React.FunctionComponent = () => {
|
const App: React.FunctionComponent = () => {
|
||||||
const [isLeftPaneExpanded, setIsLeftPaneExpanded] = useState<boolean>(true);
|
const [isLeftPaneExpanded, setIsLeftPaneExpanded] = useState<boolean>(true);
|
||||||
const isCarouselOpen = useCarousel((state) => state.shouldOpen);
|
const isCarouselOpen = useCarousel((state) => state.shouldOpen);
|
||||||
const isCopilotCarouselOpen = useCarousel((state) => state.showCopilotCarousel);
|
// const isCopilotCarouselOpen = useCarousel((state) => state.showCopilotCarousel);
|
||||||
const shouldShowModal = useQueryCopilot((state) => state.showFeedbackModal);
|
const shouldShowModal = useQueryCopilot((state) => state.showFeedbackModal);
|
||||||
|
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
@@ -127,7 +127,7 @@ const App: React.FunctionComponent = () => {
|
|||||||
{<QuickstartCarousel isOpen={isCarouselOpen} />}
|
{<QuickstartCarousel isOpen={isCarouselOpen} />}
|
||||||
{<SQLQuickstartTutorial />}
|
{<SQLQuickstartTutorial />}
|
||||||
{<MongoQuickstartTutorial />}
|
{<MongoQuickstartTutorial />}
|
||||||
{<QueryCopilotCarousel isOpen={isCopilotCarouselOpen} explorer={explorer} />}
|
{<QueryCopilotCarousel isOpen={true} explorer={explorer} />}
|
||||||
{shouldShowModal && <QueryCopilotFeedbackModal />}
|
{shouldShowModal && <QueryCopilotFeedbackModal />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ export class JupyterLabAppFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async createTerminalApp(serverSettings: ServerConnection.ISettings): Promise<ITerminalConnection | undefined> {
|
public async createTerminalApp(serverSettings: ServerConnection.ISettings): Promise<ITerminalConnection | undefined> {
|
||||||
|
//Need to add this after we remove passing token through url
|
||||||
|
//const configurationSettings: Partial<ServerConnection.ISettings> = serverSettings;
|
||||||
|
//(configurationSettings.appendToken as boolean) = false;
|
||||||
|
//serverSettings = ServerConnection.makeSettings(configurationSettings);
|
||||||
const manager = new TerminalManager({
|
const manager = new TerminalManager({
|
||||||
serverSettings: serverSettings,
|
serverSettings: serverSettings,
|
||||||
});
|
});
|
||||||
@@ -64,6 +68,11 @@ export class JupyterLabAppFactory {
|
|||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
let internalSend = session.send;
|
||||||
|
session.send = (message: IMessage) => {
|
||||||
|
message?.content?.push(serverSettings?.token);
|
||||||
|
internalSend.call(session, message);
|
||||||
|
};
|
||||||
const term = new Terminal(session, { theme: "dark", shutdownOnClose: true });
|
const term = new Terminal(session, { theme: "dark", shutdownOnClose: true });
|
||||||
|
|
||||||
if (!term) {
|
if (!term) {
|
||||||
|
|||||||
Reference in New Issue
Block a user