Fix eslint issues for NotebookContentLient and other files
This commit is contained in:
parent
55837db65b
commit
0c1f6d2a80
|
@ -54,8 +54,8 @@ src/Explorer/Graph/GraphExplorerComponent/GraphData.ts
|
||||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts
|
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts
|
||||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts
|
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts
|
||||||
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.test.ts
|
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.test.ts
|
||||||
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts
|
# src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts
|
||||||
src/Explorer/Menus/ContextMenu.ts
|
# src/Explorer/Menus/ContextMenu.ts
|
||||||
src/Explorer/MostRecentActivity/MostRecentActivity.ts
|
src/Explorer/MostRecentActivity/MostRecentActivity.ts
|
||||||
src/Explorer/Notebook/NotebookClientV2.ts
|
src/Explorer/Notebook/NotebookClientV2.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/NotebookContentProvider.ts
|
src/Explorer/Notebook/NotebookComponent/NotebookContentProvider.ts
|
||||||
|
@ -64,11 +64,11 @@ src/Explorer/Notebook/NotebookComponent/actions.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/epics.test.ts
|
src/Explorer/Notebook/NotebookComponent/epics.test.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/epics.ts
|
src/Explorer/Notebook/NotebookComponent/epics.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/loadTransform.ts
|
src/Explorer/Notebook/NotebookComponent/loadTransform.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/reducers.ts
|
# src/Explorer/Notebook/NotebookComponent/reducers.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/store.ts
|
src/Explorer/Notebook/NotebookComponent/store.ts
|
||||||
src/Explorer/Notebook/NotebookComponent/types.ts
|
# src/Explorer/Notebook/NotebookComponent/types.ts
|
||||||
src/Explorer/Notebook/NotebookContainerClient.ts
|
src/Explorer/Notebook/NotebookContainerClient.ts
|
||||||
src/Explorer/Notebook/NotebookContentClient.ts
|
# src/Explorer/Notebook/NotebookContentClient.ts
|
||||||
src/Explorer/Notebook/NotebookContentItem.ts
|
src/Explorer/Notebook/NotebookContentItem.ts
|
||||||
src/Explorer/Notebook/NotebookUtil.ts
|
src/Explorer/Notebook/NotebookUtil.ts
|
||||||
src/Explorer/OpenActionsStubs.ts
|
src/Explorer/OpenActionsStubs.ts
|
||||||
|
|
|
@ -18,6 +18,7 @@ export interface GremlinSimpleClientParameters {
|
||||||
|
|
||||||
export interface Result {
|
export interface Result {
|
||||||
requestId: string; // Can be null
|
requestId: string; // Can be null
|
||||||
|
//eslint-disable-next-line
|
||||||
data: any;
|
data: any;
|
||||||
requestCharge: number; // RU cost
|
requestCharge: number; // RU cost
|
||||||
}
|
}
|
||||||
|
@ -30,6 +31,7 @@ export interface GremlinRequestMessage {
|
||||||
args:
|
args:
|
||||||
| {
|
| {
|
||||||
gremlin: string;
|
gremlin: string;
|
||||||
|
//eslint-disable-next-line
|
||||||
bindings: {};
|
bindings: {};
|
||||||
language: string;
|
language: string;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +56,7 @@ export interface GremlinResponseMessage {
|
||||||
message: string;
|
message: string;
|
||||||
};
|
};
|
||||||
result: {
|
result: {
|
||||||
|
//eslint-disable-next-line
|
||||||
data: any;
|
data: any;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -74,7 +77,7 @@ export class GremlinSimpleClient {
|
||||||
this.requestsToSend = {};
|
this.requestsToSend = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public connect() {
|
public connect(): void {
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
if (this.ws.readyState === WebSocket.CONNECTING) {
|
if (this.ws.readyState === WebSocket.CONNECTING) {
|
||||||
// Wait until it connects to execute all requests
|
// Wait until it connects to execute all requests
|
||||||
|
@ -106,9 +109,10 @@ export class GremlinSimpleClient {
|
||||||
return new WebSocket(endpoint);
|
return new WebSocket(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public close() {
|
public close(): void {
|
||||||
if (this.ws && this.ws.readyState !== WebSocket.CLOSING && this.ws.readyState !== WebSocket.CLOSED) {
|
if (this.ws && this.ws.readyState !== WebSocket.CLOSING && this.ws.readyState !== WebSocket.CLOSED) {
|
||||||
const msg = `Disconnecting from ${this.params.endpoint} as ${this.params.user}`;
|
const msg = `Disconnecting from ${this.params.endpoint} as ${this.params.user}`;
|
||||||
|
//eslint-disable-next-line
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
if (this.params.infoCallback) {
|
if (this.params.infoCallback) {
|
||||||
this.params.infoCallback(msg);
|
this.params.infoCallback(msg);
|
||||||
|
@ -143,7 +147,7 @@ export class GremlinSimpleClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onMessage(msg: MessageEvent) {
|
public onMessage(msg: MessageEvent): void {
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
if (this.params.failureCallback) {
|
if (this.params.failureCallback) {
|
||||||
this.params.failureCallback(null, "onMessage called with no message");
|
this.params.failureCallback(null, "onMessage called with no message");
|
||||||
|
@ -194,8 +198,10 @@ export class GremlinSimpleClient {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 407: // Request authentication
|
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;
|
break;
|
||||||
case 401: // Unauthorized
|
case 401: // Unauthorized
|
||||||
delete this.pendingRequests[requestId];
|
delete this.pendingRequests[requestId];
|
||||||
|
@ -267,7 +273,7 @@ export class GremlinSimpleClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public buildChallengeResponse(request: GremlinRequestMessage): GremlinRequestMessage {
|
public buildChallengeResponse(request: GremlinRequestMessage): GremlinRequestMessage {
|
||||||
var args = {
|
const args = {
|
||||||
SASL: GremlinSimpleClient.utf8ToB64("\0" + this.params.user + "\0" + this.params.password),
|
SASL: GremlinSimpleClient.utf8ToB64("\0" + this.params.user + "\0" + this.params.password),
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
|
@ -278,9 +284,9 @@ export class GremlinSimpleClient {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static utf8ToB64(utf8Str: string) {
|
public static utf8ToB64(utf8Str: string): string {
|
||||||
return btoa(
|
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));
|
return String.fromCharCode(parseInt(p1, 16));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -291,12 +297,13 @@ export class GremlinSimpleClient {
|
||||||
* mimeLength + mimeType + serialized message
|
* mimeLength + mimeType + serialized message
|
||||||
* @param requestMessage
|
* @param requestMessage
|
||||||
*/
|
*/
|
||||||
|
//eslint-disable-next-line
|
||||||
public static buildGremlinMessage(requestMessage: {}): Uint8Array {
|
public static buildGremlinMessage(requestMessage: {}): Uint8Array {
|
||||||
const mimeType = "application/json";
|
const mimeType = "application/json";
|
||||||
let serializedMessage = mimeType + JSON.stringify(requestMessage);
|
const serializedMessage = mimeType + JSON.stringify(requestMessage);
|
||||||
const encodedMessage = new TextEncoder().encode(serializedMessage);
|
const encodedMessage = new TextEncoder().encode(serializedMessage);
|
||||||
|
|
||||||
let binaryMessage = new Uint8Array(1 + encodedMessage.length);
|
const binaryMessage = new Uint8Array(1 + encodedMessage.length);
|
||||||
binaryMessage[0] = mimeType.length;
|
binaryMessage[0] = mimeType.length;
|
||||||
|
|
||||||
for (let i = 0; i < encodedMessage.length; i++) {
|
for (let i = 0; i < encodedMessage.length; i++) {
|
||||||
|
@ -305,19 +312,19 @@ export class GremlinSimpleClient {
|
||||||
return binaryMessage;
|
return binaryMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onOpen(event: any) {
|
private onOpen() {
|
||||||
this.executeRequestsToSend();
|
this.executeRequestsToSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
private executeRequestsToSend() {
|
private executeRequestsToSend() {
|
||||||
for (let requestId in this.requestsToSend) {
|
for (const requestId in this.requestsToSend) {
|
||||||
const request = this.requestsToSend[requestId];
|
const request = this.requestsToSend[requestId];
|
||||||
this.sendGremlinMessage(request);
|
this.sendGremlinMessage(request);
|
||||||
this.pendingRequests[request.requestId] = request;
|
this.pendingRequests[request.requestId] = request;
|
||||||
delete this.requestsToSend[request.requestId];
|
delete this.requestsToSend[request.requestId];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//eslint-disable-next-line
|
||||||
private onError(err: any) {
|
private onError(err: any) {
|
||||||
if (this.params.failureCallback) {
|
if (this.params.failureCallback) {
|
||||||
this.params.failureCallback(null, err);
|
this.params.failureCallback(null, err);
|
||||||
|
@ -339,9 +346,9 @@ export class GremlinSimpleClient {
|
||||||
* RFC4122 version 4 compliant UUID
|
* RFC4122 version 4 compliant UUID
|
||||||
*/
|
*/
|
||||||
private static uuidv4() {
|
private static uuidv4() {
|
||||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
||||||
var r = (Math.random() * 16) | 0,
|
const r = (Math.random() * 16) | 0,
|
||||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
v = c === "x" ? r : (r & 0x3) | 0x8;
|
||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ export const coreReducer = (state: CoreRecord, action: Action) => {
|
||||||
.setIn(path.concat("language"), kernelspecs.language);
|
.setIn(path.concat("language"), kernelspecs.language);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
//eslint-disable-next-line
|
||||||
return nteractReducers.core(state as any, action as any);
|
return nteractReducers.core(state as any, action as any);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -228,11 +228,12 @@ export class NotebookContentClient {
|
||||||
|
|
||||||
public async readFileContent(filePath: string): Promise<string> {
|
public async readFileContent(filePath: string): Promise<string> {
|
||||||
const xhr = await this.contentProvider.get(this.getServerConfig(), filePath, { content: 1 }).toPromise();
|
const xhr = await this.contentProvider.get(this.getServerConfig(), filePath, { content: 1 }).toPromise();
|
||||||
|
//eslint-disable-next-line
|
||||||
const content = (xhr.response as any).content;
|
const content = (xhr.response as any).content;
|
||||||
if (!content) {
|
if (!content) {
|
||||||
throw new Error("No content read");
|
throw new Error("No content read");
|
||||||
}
|
}
|
||||||
|
//eslint-disable-next-line
|
||||||
const format = (xhr.response as any).format;
|
const format = (xhr.response as any).format;
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case "text":
|
case "text":
|
||||||
|
|
Loading…
Reference in New Issue