mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 00:41:31 +00:00
Remove deprecated calls to logConsoleMessage (#608)
Co-authored-by: Steve Faulkner <southpolesteve@gmail.com>
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
import * as ko from "knockout";
|
||||
import Q from "q";
|
||||
import { schemeCategory10 } from "d3-scale-chromatic";
|
||||
import { selectAll, select } from "d3-selection";
|
||||
import { zoom, zoomIdentity } from "d3-zoom";
|
||||
import { scaleOrdinal } from "d3-scale";
|
||||
import { forceSimulation, forceLink, forceCollide, forceManyBody } from "d3-force";
|
||||
import { interpolateNumber, interpolate } from "d3-interpolate";
|
||||
import { BaseType } from "d3";
|
||||
import { map as d3Map } from "d3-collection";
|
||||
import { drag, D3DragEvent } from "d3-drag";
|
||||
|
||||
import { D3DragEvent, drag } from "d3-drag";
|
||||
import { forceCollide, forceLink, forceManyBody, forceSimulation } from "d3-force";
|
||||
import { interpolate, interpolateNumber } from "d3-interpolate";
|
||||
import { scaleOrdinal } from "d3-scale";
|
||||
import { schemeCategory10 } from "d3-scale-chromatic";
|
||||
import { select, selectAll } from "d3-selection";
|
||||
import { zoom, zoomIdentity } from "d3-zoom";
|
||||
import * as ko from "knockout";
|
||||
import Q from "q";
|
||||
import _ from "underscore";
|
||||
import { NeighborType } from "../../../Contracts/ViewModels";
|
||||
import { GraphData, D3Node, D3Link } from "./GraphData";
|
||||
import { HashMap } from "../../../Common/HashMap";
|
||||
import { BaseType } from "d3";
|
||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils";
|
||||
import { GraphConfig } from "../../Tabs/GraphTab";
|
||||
import { GraphExplorer } from "./GraphExplorer";
|
||||
import * as Constants from "../../../Common/Constants";
|
||||
import { HashMap } from "../../../Common/HashMap";
|
||||
import { NeighborType } from "../../../Contracts/ViewModels";
|
||||
import { logConsoleError } from "../../../Utils/NotificationConsoleUtils";
|
||||
import { GraphConfig } from "../../Tabs/GraphTab";
|
||||
import { D3Link, D3Node, GraphData } from "./GraphData";
|
||||
import { GraphExplorer } from "./GraphExplorer";
|
||||
|
||||
export interface D3GraphIconMap {
|
||||
[key: string]: { data: string; format: string };
|
||||
@@ -1005,7 +1003,7 @@ export class D3ForceGraph implements GraphRenderer {
|
||||
*/
|
||||
private loadNeighbors(v: D3Node, pageAction: PAGE_ACTION) {
|
||||
if (!this.graphDataWrapper.hasVertexId(v.id)) {
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, `Clicked node not in graph data. id: ${v.id}`);
|
||||
logConsoleError(`Clicked node not in graph data. id: ${v.id}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
import { FeedOptions, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||
import * as Q from "q";
|
||||
import * as React from "react";
|
||||
import * as LeftPane from "./LeftPaneComponent";
|
||||
import { MiddlePaneComponent } from "./MiddlePaneComponent";
|
||||
import * as InputTypeaheadComponent from "../../Controls/InputTypeahead/InputTypeaheadComponent";
|
||||
import * as NodeProperties from "./NodePropertiesComponent";
|
||||
import * as D3ForceGraph from "./D3ForceGraph";
|
||||
import { GraphVizComponentProps } from "./GraphVizComponent";
|
||||
import * as GraphData from "./GraphData";
|
||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils";
|
||||
import * as GraphUtil from "./GraphUtil";
|
||||
import * as DataModels from "../../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||
import * as GremlinClient from "./GremlinClient";
|
||||
import * as StorageUtility from "../../../Shared/StorageUtility";
|
||||
import { ArraysByKeyCache } from "./ArraysByKeyCache";
|
||||
import { EdgeInfoCache } from "./EdgeInfoCache";
|
||||
import * as TabComponent from "../../Controls/Tabs/TabComponent";
|
||||
import { LocalStorageUtility, StorageKey } from "../../../Shared/StorageUtility";
|
||||
import { QueryContainerComponent } from "./QueryContainerComponent";
|
||||
import { GraphConfig } from "../../Tabs/GraphTab";
|
||||
import { EditorReact } from "../../Controls/Editor/EditorReact";
|
||||
import LoadGraphIcon from "../../../../images/LoadGraph.png";
|
||||
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||
import * as Constants from "../../../Common/Constants";
|
||||
import { InputProperty } from "../../../Contracts/ViewModels";
|
||||
import { QueryIterator, ItemDefinition, Resource } from "@azure/cosmos";
|
||||
import LoadingIndicatorIcon from "../../../../images/LoadingIndicator_3Squares.gif";
|
||||
import * as Constants from "../../../Common/Constants";
|
||||
import { queryDocuments } from "../../../Common/dataAccess/queryDocuments";
|
||||
import { queryDocumentsPage } from "../../../Common/dataAccess/queryDocumentsPage";
|
||||
import { getErrorMessage } from "../../../Common/ErrorHandlingUtils";
|
||||
import { FeedOptions } from "@azure/cosmos";
|
||||
import * as DataModels from "../../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||
import { InputProperty } from "../../../Contracts/ViewModels";
|
||||
import * as StorageUtility from "../../../Shared/StorageUtility";
|
||||
import { LocalStorageUtility, StorageKey } from "../../../Shared/StorageUtility";
|
||||
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||
import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor";
|
||||
import { logConsoleError, logConsoleInfo, logConsoleProgress } from "../../../Utils/NotificationConsoleUtils";
|
||||
import { EditorReact } from "../../Controls/Editor/EditorReact";
|
||||
import * as InputTypeaheadComponent from "../../Controls/InputTypeahead/InputTypeaheadComponent";
|
||||
import * as TabComponent from "../../Controls/Tabs/TabComponent";
|
||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { GraphConfig } from "../../Tabs/GraphTab";
|
||||
import { ArraysByKeyCache } from "./ArraysByKeyCache";
|
||||
import * as D3ForceGraph from "./D3ForceGraph";
|
||||
import { EdgeInfoCache } from "./EdgeInfoCache";
|
||||
import * as GraphData from "./GraphData";
|
||||
import * as GraphUtil from "./GraphUtil";
|
||||
import { GraphVizComponentProps } from "./GraphVizComponent";
|
||||
import * as GremlinClient from "./GremlinClient";
|
||||
import * as LeftPane from "./LeftPaneComponent";
|
||||
import { MiddlePaneComponent } from "./MiddlePaneComponent";
|
||||
import * as NodeProperties from "./NodePropertiesComponent";
|
||||
import { QueryContainerComponent } from "./QueryContainerComponent";
|
||||
|
||||
export interface GraphAccessor {
|
||||
applyFilter: () => void;
|
||||
@@ -697,13 +696,13 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
* @param cmd
|
||||
*/
|
||||
public submitToBackend(cmd: string): Q.Promise<GremlinClient.GremlinRequestResult> {
|
||||
const id = GraphExplorer.reportToConsole(ConsoleDataType.InProgress, `Executing: ${cmd}`);
|
||||
const clearConsoleProgress = GraphExplorer.reportToConsole(ConsoleDataType.InProgress, `Executing: ${cmd}`);
|
||||
this.setExecuteCounter(this.executeCounter + 1);
|
||||
|
||||
return this.gremlinClient.execute(cmd).then(
|
||||
(result: GremlinClient.GremlinRequestResult) => {
|
||||
this.setExecuteCounter(this.executeCounter - 1);
|
||||
GraphExplorer.clearConsoleProgress(id);
|
||||
clearConsoleProgress();
|
||||
if (result.isIncomplete) {
|
||||
const msg = `The query results are too large and only partial results are displayed for: ${cmd}`;
|
||||
GraphExplorer.reportToConsole(ConsoleDataType.Error, msg);
|
||||
@@ -718,7 +717,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
(err: string) => {
|
||||
this.setExecuteCounter(this.executeCounter - 1);
|
||||
GraphExplorer.reportToConsole(ConsoleDataType.Error, `Gremlin query failed: ${cmd}`, err);
|
||||
GraphExplorer.clearConsoleProgress(id);
|
||||
clearConsoleProgress();
|
||||
throw err;
|
||||
}
|
||||
);
|
||||
@@ -1083,13 +1082,26 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
* @param errorData additional errors
|
||||
* @return id
|
||||
*/
|
||||
public static reportToConsole(type: ConsoleDataType, msg: string, ...errorData: any[]): string {
|
||||
public static reportToConsole(type: ConsoleDataType.InProgress, msg: string, ...errorData: any[]): () => void;
|
||||
public static reportToConsole(type: ConsoleDataType.Info, msg: string, ...errorData: any[]): void;
|
||||
public static reportToConsole(type: ConsoleDataType.Error, msg: string, ...errorData: any[]): void;
|
||||
public static reportToConsole(type: ConsoleDataType, msg: string, ...errorData: any[]): void | (() => void) {
|
||||
let errorDataStr: string = "";
|
||||
if (errorData && errorData.length > 0) {
|
||||
console.error(msg, errorData);
|
||||
errorDataStr = ": " + JSON.stringify(errorData);
|
||||
}
|
||||
return NotificationConsoleUtils.logConsoleMessage(type, `${msg}${errorDataStr}`);
|
||||
|
||||
const consoleMessage = `${msg}${errorDataStr}`;
|
||||
|
||||
switch (type) {
|
||||
case ConsoleDataType.Error:
|
||||
return logConsoleError(consoleMessage);
|
||||
case ConsoleDataType.Info:
|
||||
return logConsoleInfo(consoleMessage);
|
||||
case ConsoleDataType.InProgress:
|
||||
return logConsoleProgress(consoleMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private setNodePropertiesViewMode(viewMode: NodeProperties.Mode) {
|
||||
@@ -1368,7 +1380,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
let { id } = d;
|
||||
if (typeof id !== "string") {
|
||||
const error = `Vertex id is not a string: ${JSON.stringify(id)}.`;
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, error);
|
||||
logConsoleError(error);
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
@@ -1380,7 +1392,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
pk = pk[0]["_value"];
|
||||
} else {
|
||||
const error = `Vertex pk is not a string nor a non-empty array: ${JSON.stringify(pk)}.`;
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, error);
|
||||
logConsoleError(error);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
@@ -1767,7 +1779,10 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
const queryInfoStr = `${this.currentDocDBQueryInfo.query} (${this.currentDocDBQueryInfo.index + 1}-${
|
||||
this.currentDocDBQueryInfo.index + GraphExplorer.ROOT_LIST_PAGE_SIZE
|
||||
})`;
|
||||
const id = GraphExplorer.reportToConsole(ConsoleDataType.InProgress, `Executing: ${queryInfoStr}`);
|
||||
const clearConsoleProgress = GraphExplorer.reportToConsole(
|
||||
ConsoleDataType.InProgress,
|
||||
`Executing: ${queryInfoStr}`
|
||||
);
|
||||
|
||||
try {
|
||||
const results: ViewModels.QueryResults = await queryDocumentsPage(
|
||||
@@ -1776,7 +1791,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
this.currentDocDBQueryInfo.index
|
||||
);
|
||||
|
||||
GraphExplorer.clearConsoleProgress(id);
|
||||
clearConsoleProgress();
|
||||
this.currentDocDBQueryInfo.index = results.lastItemIndex + 1;
|
||||
this.setState({ hasMoreRoots: results.hasMoreResults });
|
||||
RU = results.requestCharge.toString();
|
||||
@@ -1793,7 +1808,7 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
|
||||
return { requestCharge: RU };
|
||||
} catch (error) {
|
||||
GraphExplorer.clearConsoleProgress(id);
|
||||
clearConsoleProgress();
|
||||
const errorMsg = `Failed to query: ${this.currentDocDBQueryInfo.query}. Reason:${getErrorMessage(error)}`;
|
||||
GraphExplorer.reportToConsole(ConsoleDataType.Error, errorMsg);
|
||||
this.setState({
|
||||
@@ -2003,8 +2018,4 @@ export class GraphExplorer extends React.Component<GraphExplorerProps, GraphExpl
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
private static clearConsoleProgress(id: string) {
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
*/
|
||||
|
||||
import * as Q from "q";
|
||||
import { GremlinSimpleClient, Result } from "./GremlinSimpleClient";
|
||||
import * as NotificationConsoleUtils from "../../../Utils/NotificationConsoleUtils";
|
||||
import { ConsoleDataType } from "../../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { HashMap } from "../../../Common/HashMap";
|
||||
import { getErrorMessage, handleError } from "../../../Common/ErrorHandlingUtils";
|
||||
import { HashMap } from "../../../Common/HashMap";
|
||||
import { logConsoleInfo } from "../../../Utils/NotificationConsoleUtils";
|
||||
import { GremlinSimpleClient, Result } from "./GremlinSimpleClient";
|
||||
|
||||
export interface GremlinClientParameters {
|
||||
endpoint: string;
|
||||
@@ -77,9 +76,7 @@ export class GremlinClient {
|
||||
this.abortPendingRequest(requestId, errorMessage, result.requestCharge);
|
||||
}
|
||||
},
|
||||
infoCallback: (msg: string) => {
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Info, msg);
|
||||
},
|
||||
infoCallback: logConsoleInfo,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user