mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 10:51:30 +00:00
Compare commits
4 Commits
eslint/fix
...
fix_exlint
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e55e2b9fe3 | ||
|
|
0c1f6d2a80 | ||
|
|
55837db65b | ||
|
|
9f27cb95b9 |
@@ -42,8 +42,6 @@ src/Explorer/Controls/Editor/EditorComponent.ts
|
||||
src/Explorer/Controls/JsonEditor/JsonEditorComponent.ts
|
||||
src/Explorer/DataSamples/ContainerSampleGenerator.test.ts
|
||||
src/Explorer/DataSamples/ContainerSampleGenerator.ts
|
||||
src/Explorer/DataSamples/DataSamplesUtil.test.ts
|
||||
src/Explorer/DataSamples/DataSamplesUtil.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.test.ts
|
||||
@@ -54,8 +52,6 @@ src/Explorer/Graph/GraphExplorerComponent/GraphData.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts
|
||||
src/Explorer/Menus/ContextMenu.ts
|
||||
src/Explorer/MostRecentActivity/MostRecentActivity.ts
|
||||
src/Explorer/Notebook/NotebookClientV2.ts
|
||||
src/Explorer/Notebook/NotebookComponent/NotebookContentProvider.ts
|
||||
@@ -64,11 +60,8 @@ src/Explorer/Notebook/NotebookComponent/actions.ts
|
||||
src/Explorer/Notebook/NotebookComponent/epics.test.ts
|
||||
src/Explorer/Notebook/NotebookComponent/epics.ts
|
||||
src/Explorer/Notebook/NotebookComponent/loadTransform.ts
|
||||
src/Explorer/Notebook/NotebookComponent/reducers.ts
|
||||
src/Explorer/Notebook/NotebookComponent/store.ts
|
||||
src/Explorer/Notebook/NotebookComponent/types.ts
|
||||
src/Explorer/Notebook/NotebookContainerClient.ts
|
||||
src/Explorer/Notebook/NotebookContentClient.ts
|
||||
src/Explorer/Notebook/NotebookContentItem.ts
|
||||
src/Explorer/Notebook/NotebookUtil.ts
|
||||
src/Explorer/OpenActionsStubs.ts
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("DataSampleUtils", () => {
|
||||
const explorer = {} as Explorer;
|
||||
useDatabases.getState().addDatabases([database]);
|
||||
const dataSamplesUtil = new DataSamplesUtil(explorer);
|
||||
|
||||
//eslint-disable-next-line
|
||||
const fakeGenerator = sinon.createStubInstance<ContainerSampleGenerator>(ContainerSampleGenerator as any);
|
||||
fakeGenerator.getCollectionId.returns(sampleCollectionId);
|
||||
fakeGenerator.getDatabaseId.returns(sampleDatabaseId);
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface GremlinSimpleClientParameters {
|
||||
|
||||
export interface Result {
|
||||
requestId: string; // Can be null
|
||||
//eslint-disable-next-line
|
||||
data: any;
|
||||
requestCharge: number; // RU cost
|
||||
}
|
||||
@@ -30,6 +31,7 @@ export interface GremlinRequestMessage {
|
||||
args:
|
||||
| {
|
||||
gremlin: string;
|
||||
//eslint-disable-next-line
|
||||
bindings: {};
|
||||
language: string;
|
||||
}
|
||||
@@ -54,6 +56,7 @@ export interface GremlinResponseMessage {
|
||||
message: string;
|
||||
};
|
||||
result: {
|
||||
//eslint-disable-next-line
|
||||
data: any;
|
||||
};
|
||||
}
|
||||
@@ -74,7 +77,7 @@ export class GremlinSimpleClient {
|
||||
this.requestsToSend = {};
|
||||
}
|
||||
|
||||
public connect() {
|
||||
public connect(): void {
|
||||
if (this.ws) {
|
||||
if (this.ws.readyState === WebSocket.CONNECTING) {
|
||||
// Wait until it connects to execute all requests
|
||||
@@ -106,9 +109,10 @@ export class GremlinSimpleClient {
|
||||
return new WebSocket(endpoint);
|
||||
}
|
||||
|
||||
public close() {
|
||||
public close(): void {
|
||||
if (this.ws && this.ws.readyState !== WebSocket.CLOSING && this.ws.readyState !== WebSocket.CLOSED) {
|
||||
const msg = `Disconnecting from ${this.params.endpoint} as ${this.params.user}`;
|
||||
//eslint-disable-next-line
|
||||
console.log(msg);
|
||||
if (this.params.infoCallback) {
|
||||
this.params.infoCallback(msg);
|
||||
@@ -143,7 +147,7 @@ export class GremlinSimpleClient {
|
||||
}
|
||||
}
|
||||
|
||||
public onMessage(msg: MessageEvent) {
|
||||
public onMessage(msg: MessageEvent): void {
|
||||
if (!msg) {
|
||||
if (this.params.failureCallback) {
|
||||
this.params.failureCallback(null, "onMessage called with no message");
|
||||
@@ -194,8 +198,10 @@ export class GremlinSimpleClient {
|
||||
}
|
||||
break;
|
||||
case 407: // Request authentication
|
||||
const challengeResponse = this.buildChallengeResponse(this.pendingRequests[requestId]);
|
||||
this.sendGremlinMessage(challengeResponse);
|
||||
{
|
||||
const challengeResponse = this.buildChallengeResponse(this.pendingRequests[requestId]);
|
||||
this.sendGremlinMessage(challengeResponse);
|
||||
}
|
||||
break;
|
||||
case 401: // Unauthorized
|
||||
delete this.pendingRequests[requestId];
|
||||
@@ -267,7 +273,7 @@ export class GremlinSimpleClient {
|
||||
}
|
||||
|
||||
public buildChallengeResponse(request: GremlinRequestMessage): GremlinRequestMessage {
|
||||
var args = {
|
||||
const args = {
|
||||
SASL: GremlinSimpleClient.utf8ToB64("\0" + this.params.user + "\0" + this.params.password),
|
||||
};
|
||||
return {
|
||||
@@ -278,9 +284,9 @@ export class GremlinSimpleClient {
|
||||
};
|
||||
}
|
||||
|
||||
public static utf8ToB64(utf8Str: string) {
|
||||
public static utf8ToB64(utf8Str: string): string {
|
||||
return btoa(
|
||||
encodeURIComponent(utf8Str).replace(/%([0-9A-F]{2})/g, function (match, p1) {
|
||||
encodeURIComponent(utf8Str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
||||
return String.fromCharCode(parseInt(p1, 16));
|
||||
})
|
||||
);
|
||||
@@ -291,12 +297,13 @@ export class GremlinSimpleClient {
|
||||
* mimeLength + mimeType + serialized message
|
||||
* @param requestMessage
|
||||
*/
|
||||
//eslint-disable-next-line
|
||||
public static buildGremlinMessage(requestMessage: {}): Uint8Array {
|
||||
const mimeType = "application/json";
|
||||
let serializedMessage = mimeType + JSON.stringify(requestMessage);
|
||||
const serializedMessage = mimeType + JSON.stringify(requestMessage);
|
||||
const encodedMessage = new TextEncoder().encode(serializedMessage);
|
||||
|
||||
let binaryMessage = new Uint8Array(1 + encodedMessage.length);
|
||||
const binaryMessage = new Uint8Array(1 + encodedMessage.length);
|
||||
binaryMessage[0] = mimeType.length;
|
||||
|
||||
for (let i = 0; i < encodedMessage.length; i++) {
|
||||
@@ -305,19 +312,19 @@ export class GremlinSimpleClient {
|
||||
return binaryMessage;
|
||||
}
|
||||
|
||||
private onOpen(event: any) {
|
||||
private onOpen() {
|
||||
this.executeRequestsToSend();
|
||||
}
|
||||
|
||||
private executeRequestsToSend() {
|
||||
for (let requestId in this.requestsToSend) {
|
||||
for (const requestId in this.requestsToSend) {
|
||||
const request = this.requestsToSend[requestId];
|
||||
this.sendGremlinMessage(request);
|
||||
this.pendingRequests[request.requestId] = request;
|
||||
delete this.requestsToSend[request.requestId];
|
||||
}
|
||||
}
|
||||
|
||||
//eslint-disable-next-line
|
||||
private onError(err: any) {
|
||||
if (this.params.failureCallback) {
|
||||
this.params.failureCallback(null, err);
|
||||
@@ -339,9 +346,9 @@ export class GremlinSimpleClient {
|
||||
* RFC4122 version 4 compliant UUID
|
||||
*/
|
||||
private static uuidv4() {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
||||
const r = (Math.random() * 16) | 0,
|
||||
v = c === "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -307,18 +307,11 @@ function createOpenSynapseLinkDialogButton(container: Explorer): CommandButtonCo
|
||||
|
||||
function createNewDatabase(container: Explorer): CommandButtonComponentProps {
|
||||
const label = "New " + getDatabaseName();
|
||||
const newDatabaseButton = document.activeElement as HTMLElement;
|
||||
|
||||
return {
|
||||
iconSrc: AddDatabaseIcon,
|
||||
iconAlt: label,
|
||||
onCommandClick: () =>
|
||||
useSidePanel
|
||||
.getState()
|
||||
.openSidePanel(
|
||||
"New " + getDatabaseName(),
|
||||
<AddDatabasePanel explorer={container} buttonElement={newDatabaseButton} />
|
||||
),
|
||||
useSidePanel.getState().openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={container} />),
|
||||
commandButtonLabel: label,
|
||||
ariaLabel: label,
|
||||
hasPopup: true,
|
||||
|
||||
@@ -50,6 +50,7 @@ export const coreReducer = (state: CoreRecord, action: Action) => {
|
||||
.setIn(path.concat("language"), kernelspecs.language);
|
||||
}
|
||||
default:
|
||||
//eslint-disable-next-line
|
||||
return nteractReducers.core(state as any, action as any);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -228,11 +228,12 @@ export class NotebookContentClient {
|
||||
|
||||
public async readFileContent(filePath: string): Promise<string> {
|
||||
const xhr = await this.contentProvider.get(this.getServerConfig(), filePath, { content: 1 }).toPromise();
|
||||
//eslint-disable-next-line
|
||||
const content = (xhr.response as any).content;
|
||||
if (!content) {
|
||||
throw new Error("No content read");
|
||||
}
|
||||
|
||||
//eslint-disable-next-line
|
||||
const format = (xhr.response as any).format;
|
||||
switch (format) {
|
||||
case "text":
|
||||
|
||||
@@ -23,12 +23,10 @@ import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneFor
|
||||
|
||||
export interface AddDatabasePaneProps {
|
||||
explorer: Explorer;
|
||||
buttonElement?: HTMLElement;
|
||||
}
|
||||
|
||||
export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
|
||||
explorer: container,
|
||||
buttonElement,
|
||||
}: AddDatabasePaneProps) => {
|
||||
const closeSidePanel = useSidePanel((state) => state.closeSidePanel);
|
||||
let throughput: number;
|
||||
@@ -79,7 +77,6 @@ export const AddDatabasePanel: FunctionComponent<AddDatabasePaneProps> = ({
|
||||
dataExplorerArea: Constants.Areas.ContextualPane,
|
||||
};
|
||||
TelemetryProcessor.trace(Action.CreateDatabase, ActionModifiers.Open, addDatabasePaneOpenMessage);
|
||||
buttonElement.focus();
|
||||
}, []);
|
||||
|
||||
const onSubmit = () => {
|
||||
|
||||
@@ -307,23 +307,16 @@ export class SplashScreen extends React.Component<SplashScreenProps> {
|
||||
iconSrc: AddDatabaseIcon,
|
||||
title: "New " + getDatabaseName(),
|
||||
description: undefined,
|
||||
onClick: () => this.openAddDatabasePanel(),
|
||||
onClick: () =>
|
||||
useSidePanel
|
||||
.getState()
|
||||
.openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={this.container} />),
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private openAddDatabasePanel() {
|
||||
const newDatabaseButton = document.activeElement as HTMLElement;
|
||||
useSidePanel
|
||||
.getState()
|
||||
.openSidePanel(
|
||||
"New " + getDatabaseName(),
|
||||
<AddDatabasePanel explorer={this.container} buttonElement={newDatabaseButton} />
|
||||
);
|
||||
}
|
||||
|
||||
private decorateOpenCollectionActivity({ databaseId, collectionId }: MostRecentActivity.OpenCollectionItem) {
|
||||
return {
|
||||
iconSrc: NotebookIcon,
|
||||
|
||||
@@ -202,14 +202,21 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
|
||||
let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`;
|
||||
let isPropertyUpdated = false;
|
||||
let isFirstPropertyToUpdate = true;
|
||||
for (let property in newEntity) {
|
||||
if (
|
||||
!originalDocument[property] ||
|
||||
newEntity[property]._.toString() !== originalDocument[property]._.toString()
|
||||
) {
|
||||
updateQuery += this.isStringType(newEntity[property].$)
|
||||
? ` SET ${property} = '${newEntity[property]._}',`
|
||||
: ` SET ${property} = ${newEntity[property]._},`;
|
||||
let propertyQuerySegment = this.isStringType(newEntity[property].$)
|
||||
? `${property} = '${newEntity[property]._}',`
|
||||
: `${property} = ${newEntity[property]._},`;
|
||||
// Only add the "SET" keyword once
|
||||
if (isFirstPropertyToUpdate) {
|
||||
propertyQuerySegment = " SET " + propertyQuerySegment;
|
||||
isFirstPropertyToUpdate = false;
|
||||
}
|
||||
updateQuery += propertyQuerySegment;
|
||||
isPropertyUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user