mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-08 03:57:31 +00:00
Compare commits
2 Commits
eslint/fix
...
eslint/fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f47952a77 | ||
|
|
fdfc1f69ed |
@@ -23,13 +23,8 @@ src/Common/QueriesClient.ts
|
|||||||
src/Common/Splitter.ts
|
src/Common/Splitter.ts
|
||||||
src/Config.ts
|
src/Config.ts
|
||||||
src/Contracts/ActionContracts.ts
|
src/Contracts/ActionContracts.ts
|
||||||
src/Contracts/DataModels.ts
|
|
||||||
src/Contracts/Diagnostics.ts
|
|
||||||
src/Contracts/ExplorerContracts.ts
|
|
||||||
src/Contracts/Versions.ts
|
src/Contracts/Versions.ts
|
||||||
src/Contracts/ViewModels.ts
|
src/Contracts/ViewModels.ts
|
||||||
src/Controls/Heatmap/Heatmap.test.ts
|
|
||||||
src/Controls/Heatmap/Heatmap.ts
|
|
||||||
src/Controls/Heatmap/HeatmapDatatypes.ts
|
src/Controls/Heatmap/HeatmapDatatypes.ts
|
||||||
src/Definitions/datatables.d.ts
|
src/Definitions/datatables.d.ts
|
||||||
src/Definitions/gif.d.ts
|
src/Definitions/gif.d.ts
|
||||||
@@ -121,6 +116,7 @@ src/Explorer/Tables/QueryBuilder/QueryBuilderViewModel.ts
|
|||||||
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
src/Explorer/Tables/QueryBuilder/QueryClauseViewModel.ts
|
||||||
src/Explorer/Tables/TableDataClient.ts
|
src/Explorer/Tables/TableDataClient.ts
|
||||||
src/Explorer/Tables/TableEntityProcessor.ts
|
src/Explorer/Tables/TableEntityProcessor.ts
|
||||||
|
src/Explorer/Tables/Utilities.ts
|
||||||
src/Explorer/Tabs/ConflictsTab.ts
|
src/Explorer/Tabs/ConflictsTab.ts
|
||||||
src/Explorer/Tabs/DatabaseSettingsTab.ts
|
src/Explorer/Tabs/DatabaseSettingsTab.ts
|
||||||
src/Explorer/Tabs/DocumentsTab.test.ts
|
src/Explorer/Tabs/DocumentsTab.test.ts
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { handleMessage, Heatmap, isDarkTheme } from "./Heatmap";
|
import { handleMessage, Heatmap, isDarkTheme } from "./Heatmap";
|
||||||
import { PortalTheme } from "./HeatmapDatatypes";
|
import { PortalTheme } from "./HeatmapDatatypes";
|
||||||
@@ -22,8 +23,8 @@ describe("The Heatmap Control", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let heatmap: Heatmap;
|
let heatmap: Heatmap;
|
||||||
let theme: PortalTheme = 1;
|
const theme: PortalTheme = 1;
|
||||||
const divElement: string = `<div id="${Heatmap.elementId}"></div>`;
|
const divElement = `<div id="${Heatmap.elementId}"></div>`;
|
||||||
|
|
||||||
describe("drawHeatmap rendering", () => {
|
describe("drawHeatmap rendering", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -100,7 +101,7 @@ describe("iframe rendering when there is no data", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show a no data message with a dark theme", () => {
|
it("should show a no data message with a dark theme", () => {
|
||||||
let data = {
|
const data = {
|
||||||
data: {
|
data: {
|
||||||
signature: "pcIframe",
|
signature: "pcIframe",
|
||||||
data: {
|
data: {
|
||||||
@@ -111,7 +112,7 @@ describe("iframe rendering when there is no data", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const divElement: string = `<div id="${Heatmap.elementId}"></div>`;
|
const divElement = `<div id="${Heatmap.elementId}"></div>`;
|
||||||
document.body.innerHTML = divElement;
|
document.body.innerHTML = divElement;
|
||||||
|
|
||||||
handleMessage(data as MessageEvent);
|
handleMessage(data as MessageEvent);
|
||||||
@@ -120,7 +121,7 @@ describe("iframe rendering when there is no data", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show a no data message with a white theme", () => {
|
it("should show a no data message with a white theme", () => {
|
||||||
let data = {
|
const data = {
|
||||||
data: {
|
data: {
|
||||||
signature: "pcIframe",
|
signature: "pcIframe",
|
||||||
data: {
|
data: {
|
||||||
@@ -131,7 +132,7 @@ describe("iframe rendering when there is no data", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const divElement: string = `<div id="${Heatmap.elementId}"></div>`;
|
const divElement = `<div id="${Heatmap.elementId}"></div>`;
|
||||||
document.body.innerHTML = divElement;
|
document.body.innerHTML = divElement;
|
||||||
|
|
||||||
handleMessage(data as MessageEvent);
|
handleMessage(data as MessageEvent);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export class Heatmap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getFontStyles(size: number = StyleConstants.MediumFontSize, color: string = "#838383"): FontSettings {
|
private _getFontStyles(size: number = StyleConstants.MediumFontSize, color = "#838383"): FontSettings {
|
||||||
return {
|
return {
|
||||||
family: StyleConstants.DataExplorerFont,
|
family: StyleConstants.DataExplorerFont,
|
||||||
size,
|
size,
|
||||||
@@ -78,9 +78,9 @@ export class Heatmap {
|
|||||||
// go thru all rows and create 2d matrix for heatmap...
|
// go thru all rows and create 2d matrix for heatmap...
|
||||||
for (let i = 0; i < rows.length; i++) {
|
for (let i = 0; i < rows.length; i++) {
|
||||||
output.yAxisPoints.push(rows[i]);
|
output.yAxisPoints.push(rows[i]);
|
||||||
let dataPoints: number[] = [];
|
const dataPoints: number[] = [];
|
||||||
for (let a = 0; a < output.xAxisPoints.length; a++) {
|
for (let a = 0; a < output.xAxisPoints.length; a++) {
|
||||||
let row: PartitionTimeStampToData = data[rows[i]];
|
const row: PartitionTimeStampToData = data[rows[i]];
|
||||||
dataPoints.push(row[output.xAxisPoints[a]]["Normalized Throughput"]);
|
dataPoints.push(row[output.xAxisPoints[a]]["Normalized Throughput"]);
|
||||||
}
|
}
|
||||||
output.dataPoints.push(dataPoints);
|
output.dataPoints.push(dataPoints);
|
||||||
@@ -193,8 +193,8 @@ export class Heatmap {
|
|||||||
this._getLayoutSettings(),
|
this._getLayoutSettings(),
|
||||||
this._getChartDisplaySettings()
|
this._getChartDisplaySettings()
|
||||||
);
|
);
|
||||||
let plotDiv: any = document.getElementById(Heatmap.elementId);
|
const plotDiv = document.getElementById(Heatmap.elementId) as HTMLFormElement;
|
||||||
plotDiv.on("plotly_click", (data: any) => {
|
plotDiv.on("plotly_click", (data: HTMLFormElement) => {
|
||||||
let timeSelected: string = data.points[0].x;
|
let timeSelected: string = data.points[0].x;
|
||||||
timeSelected = timeSelected.replace(" ", "T");
|
timeSelected = timeSelected.replace(" ", "T");
|
||||||
timeSelected = `${timeSelected}Z`;
|
timeSelected = `${timeSelected}Z`;
|
||||||
@@ -205,7 +205,7 @@ export class Heatmap {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let output = [];
|
const output = [];
|
||||||
for (let i = 0; i < this._chartData.dataPoints.length; i++) {
|
for (let i = 0; i < this._chartData.dataPoints.length; i++) {
|
||||||
output.push(this._chartData.dataPoints[i][xAxisIndex]);
|
output.push(this._chartData.dataPoints[i][xAxisIndex]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
/**
|
|
||||||
* [Todo] disable any type of file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
import * as Entities from "./Entities";
|
import * as Entities from "./Entities";
|
||||||
@@ -13,11 +8,11 @@ import * as Constants from "./Constants";
|
|||||||
* Generates a pseudo-random GUID.
|
* Generates a pseudo-random GUID.
|
||||||
*/
|
*/
|
||||||
export function guid() {
|
export function guid() {
|
||||||
const s4 = () => {
|
function s4() {
|
||||||
return Math.floor((1 + Math.random()) * 0x10000)
|
return Math.floor((1 + Math.random()) * 0x10000)
|
||||||
.toString(16)
|
.toString(16)
|
||||||
.substring(1);
|
.substring(1);
|
||||||
};
|
}
|
||||||
return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4();
|
return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +39,7 @@ export function ensureBetweenBounds(value: number, minimum: number, maximum: num
|
|||||||
* If supplied, the original error will be added as "details".
|
* If supplied, the original error will be added as "details".
|
||||||
*/
|
*/
|
||||||
export function getErrorMessage(error: any, simpleMessage?: string): string {
|
export function getErrorMessage(error: any, simpleMessage?: string): string {
|
||||||
let detailsMessage: string;
|
var detailsMessage: string;
|
||||||
if (typeof error === "string" || error instanceof String) {
|
if (typeof error === "string" || error instanceof String) {
|
||||||
detailsMessage = error.toString();
|
detailsMessage = error.toString();
|
||||||
} else {
|
} else {
|
||||||
@@ -64,7 +59,7 @@ export function getErrorMessage(error: any, simpleMessage?: string): string {
|
|||||||
* Get the environment's new line characters
|
* Get the environment's new line characters
|
||||||
*/
|
*/
|
||||||
export function getEnvironmentNewLine(): string {
|
export function getEnvironmentNewLine(): string {
|
||||||
const platform = navigator.platform.toUpperCase();
|
var platform = navigator.platform.toUpperCase();
|
||||||
|
|
||||||
if (platform.indexOf("WIN") >= 0) {
|
if (platform.indexOf("WIN") >= 0) {
|
||||||
return "\r\n";
|
return "\r\n";
|
||||||
@@ -78,7 +73,7 @@ export function getEnvironmentNewLine(): string {
|
|||||||
* Tests whether two arrays have same elements in the same sequence.
|
* Tests whether two arrays have same elements in the same sequence.
|
||||||
*/
|
*/
|
||||||
export function isEqual<T>(a: T[], b: T[]): boolean {
|
export function isEqual<T>(a: T[], b: T[]): boolean {
|
||||||
let isEqual = false;
|
var isEqual: boolean = false;
|
||||||
if (!!a && !!b && a.length === b.length) {
|
if (!!a && !!b && a.length === b.length) {
|
||||||
isEqual = _.every(a, (value: T, index: number) => value === b[index]);
|
isEqual = _.every(a, (value: T, index: number) => value === b[index]);
|
||||||
}
|
}
|
||||||
@@ -90,13 +85,12 @@ export function isEqual<T>(a: T[], b: T[]): boolean {
|
|||||||
*/
|
*/
|
||||||
export function jQuerySelectorEscape(value: string): string {
|
export function jQuerySelectorEscape(value: string): string {
|
||||||
value = value || "";
|
value = value || "";
|
||||||
// removed Unnecessary escape character: \/.eslintno-useless-escape
|
return value.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, "\\$&");
|
||||||
return value.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function copyTableQuery(query: Entities.ITableQuery): Entities.ITableQuery {
|
export function copyTableQuery(query: Entities.ITableQuery): Entities.ITableQuery {
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return undefined;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -110,7 +104,7 @@ export function copyTableQuery(query: Entities.ITableQuery): Entities.ITableQuer
|
|||||||
* Html encode
|
* Html encode
|
||||||
*/
|
*/
|
||||||
export function htmlEncode(value: string): string {
|
export function htmlEncode(value: string): string {
|
||||||
const _divElem: JQuery = $("<div/>");
|
var _divElem: JQuery = $("<div/>");
|
||||||
return _divElem.text(value).html();
|
return _divElem.text(value).html();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,22 +117,22 @@ export function onKey(
|
|||||||
event: any,
|
event: any,
|
||||||
eventKeyCode: number,
|
eventKeyCode: number,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
const source: unknown = event.target || event.srcElement,
|
var source: any = event.target || event.srcElement,
|
||||||
keyCode: number = event.keyCode,
|
keyCode: number = event.keyCode,
|
||||||
$sourceElement = $(source);
|
$sourceElement = $(source),
|
||||||
let handled = false;
|
handled: boolean = false;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$sourceElement.length &&
|
$sourceElement.length &&
|
||||||
keyCode === eventKeyCode &&
|
keyCode === eventKeyCode &&
|
||||||
$.isFunction(action) &&
|
$.isFunction(action) &&
|
||||||
(metaKey === undefined || metaKey === event.metaKey) &&
|
(metaKey === null || metaKey === event.metaKey) &&
|
||||||
(shiftKey === undefined || shiftKey === event.shiftKey) &&
|
(shiftKey === null || shiftKey === event.shiftKey) &&
|
||||||
(altKey === undefined || altKey === event.altKey)
|
(altKey === null || altKey === event.altKey)
|
||||||
) {
|
) {
|
||||||
action($sourceElement);
|
action($sourceElement);
|
||||||
handled = true;
|
handled = true;
|
||||||
@@ -153,9 +147,9 @@ export function onKey(
|
|||||||
export function onEnter(
|
export function onEnter(
|
||||||
event: any,
|
event: any,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
return onKey(event, Constants.keyCodes.Enter, action, metaKey, shiftKey, altKey);
|
return onKey(event, Constants.keyCodes.Enter, action, metaKey, shiftKey, altKey);
|
||||||
}
|
}
|
||||||
@@ -166,9 +160,9 @@ export function onEnter(
|
|||||||
export function onTab(
|
export function onTab(
|
||||||
event: any,
|
event: any,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
return onKey(event, Constants.keyCodes.Tab, action, metaKey, shiftKey, altKey);
|
return onKey(event, Constants.keyCodes.Tab, action, metaKey, shiftKey, altKey);
|
||||||
}
|
}
|
||||||
@@ -179,9 +173,9 @@ export function onTab(
|
|||||||
export function onEsc(
|
export function onEsc(
|
||||||
event: any,
|
event: any,
|
||||||
action: ($sourceElement: JQuery) => void,
|
action: ($sourceElement: JQuery) => void,
|
||||||
metaKey?: boolean,
|
metaKey: boolean = null,
|
||||||
shiftKey?: boolean,
|
shiftKey: boolean = null,
|
||||||
altKey?: boolean
|
altKey: boolean = null
|
||||||
): boolean {
|
): boolean {
|
||||||
return onKey(event, Constants.keyCodes.Esc, action, metaKey, shiftKey, altKey);
|
return onKey(event, Constants.keyCodes.Esc, action, metaKey, shiftKey, altKey);
|
||||||
}
|
}
|
||||||
@@ -206,21 +200,21 @@ export function isEnvironmentAltPressed(event: JQueryEventObject): boolean {
|
|||||||
* Returns whether the current platform is MacOS.
|
* Returns whether the current platform is MacOS.
|
||||||
*/
|
*/
|
||||||
export function isMac(): boolean {
|
export function isMac(): boolean {
|
||||||
const platform = navigator.platform.toUpperCase();
|
var platform = navigator.platform.toUpperCase();
|
||||||
return platform.indexOf("MAC") >= 0;
|
return platform.indexOf("MAC") >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MAX_SAFE_INTEGER and MIN_SAFE_INTEGER will be provided by ECMAScript 6's Number
|
// MAX_SAFE_INTEGER and MIN_SAFE_INTEGER will be provided by ECMAScript 6's Number
|
||||||
export const MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
export var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
||||||
export const MIN_SAFE_INTEGER = -MAX_SAFE_INTEGER;
|
export var MIN_SAFE_INTEGER = -MAX_SAFE_INTEGER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a value a safe integer.
|
* Tests whether a value a safe integer.
|
||||||
* A safe integer is an integer that can be exactly represented as an IEEE-754 double precision number (all integers from (2^53 - 1) to -(2^53 - 1))
|
* A safe integer is an integer that can be exactly represented as an IEEE-754 double precision number (all integers from (2^53 - 1) to -(2^53 - 1))
|
||||||
* Note: Function and constants will be provided by ECMAScript 6's Number.
|
* Note: Function and constants will be provided by ECMAScript 6's Number.
|
||||||
*/
|
*/
|
||||||
export function isSafeInteger(value: number | string): boolean {
|
export function isSafeInteger(value: any): boolean {
|
||||||
const n: number = typeof value !== "number" ? Number(value) : value;
|
var n: number = typeof value !== "number" ? Number(value) : value;
|
||||||
|
|
||||||
return Math.round(n) === n && MIN_SAFE_INTEGER <= n && n <= MAX_SAFE_INTEGER;
|
return Math.round(n) === n && MIN_SAFE_INTEGER <= n && n <= MAX_SAFE_INTEGER;
|
||||||
}
|
}
|
||||||
@@ -246,7 +240,7 @@ export function getInputTypeFromDisplayedName(displayedName: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function padLongWithZeros(value: string): string {
|
export function padLongWithZeros(value: string): string {
|
||||||
const s = "0000000000000000000" + value;
|
var s = "0000000000000000000" + value;
|
||||||
return s.substr(s.length - 20);
|
return s.substr(s.length - 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,13 +249,13 @@ export function padLongWithZeros(value: string): string {
|
|||||||
* Notice: Not every header will have a data type since some headers don't even exist in entities.
|
* Notice: Not every header will have a data type since some headers don't even exist in entities.
|
||||||
*/
|
*/
|
||||||
export function getDataTypesFromEntities(headers: string[], entities: Entities.ITableEntity[]): any {
|
export function getDataTypesFromEntities(headers: string[], entities: Entities.ITableEntity[]): any {
|
||||||
let currentHeaders: string[] = _.clone(headers);
|
var currentHeaders: string[] = _.clone(headers);
|
||||||
const dataTypes: any = {};
|
var dataTypes: any = {};
|
||||||
entities = entities || [];
|
entities = entities || [];
|
||||||
entities.forEach((entity: Entities.ITableEntity) => {
|
entities.forEach((entity: Entities.ITableEntity, index: number) => {
|
||||||
if (currentHeaders.length) {
|
if (currentHeaders.length) {
|
||||||
const keys: string[] = _.keys(entity);
|
var keys: string[] = _.keys(entity);
|
||||||
const headersToProcess: string[] = _.intersection(currentHeaders, keys);
|
var headersToProcess: string[] = _.intersection(currentHeaders, keys);
|
||||||
headersToProcess &&
|
headersToProcess &&
|
||||||
headersToProcess.forEach((propertyName: string) => {
|
headersToProcess.forEach((propertyName: string) => {
|
||||||
dataTypes[propertyName] = entity[propertyName].$ || Constants.TableType.String;
|
dataTypes[propertyName] = entity[propertyName].$ || Constants.TableType.String;
|
||||||
@@ -276,9 +270,9 @@ export function getDataTypesFromEntities(headers: string[], entities: Entities.I
|
|||||||
* Set a data type for each header. The data type is inferred from Cassandra Schema.
|
* Set a data type for each header. The data type is inferred from Cassandra Schema.
|
||||||
*/
|
*/
|
||||||
export function getDataTypesFromCassandraSchema(schema: CassandraTableKey[]): any {
|
export function getDataTypesFromCassandraSchema(schema: CassandraTableKey[]): any {
|
||||||
const dataTypes: any = {};
|
var dataTypes: any = {};
|
||||||
schema &&
|
schema &&
|
||||||
schema.forEach((schemaItem: CassandraTableKey) => {
|
schema.forEach((schemaItem: CassandraTableKey, index: number) => {
|
||||||
dataTypes[schemaItem.property] = schemaItem.type;
|
dataTypes[schemaItem.property] = schemaItem.type;
|
||||||
});
|
});
|
||||||
return dataTypes;
|
return dataTypes;
|
||||||
|
|||||||
Reference in New Issue
Block a user