mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 09:20:16 +00:00
Update prettier to latest. Remove tslint (#1641)
* Rev up prettier * Reformat * Remove deprecated tslint * Remove call to tslint and update package-lock.json
This commit is contained in:
@@ -29,7 +29,7 @@ function bindDataTable(element: any, valueAccessor: any, allBindings: any, viewM
|
||||
var operationManager = new DataTableOperationManager(
|
||||
$dataTable,
|
||||
tableEntityListViewModel,
|
||||
queryTablesTab.tableCommands
|
||||
queryTablesTab.tableCommands,
|
||||
);
|
||||
|
||||
tableEntityListViewModelMap[queryTablesTab.tabId] = {
|
||||
@@ -53,7 +53,7 @@ function onTableColumnChange(enablePrompt: boolean = true, queryTablesTab: Query
|
||||
tableEntityListViewModel,
|
||||
queryTablesTab,
|
||||
true,
|
||||
columnsFilter
|
||||
columnsFilter,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ function createDataTable(
|
||||
tableEntityListViewModel: TableEntityListViewModel,
|
||||
queryTablesTab: QueryTablesTab,
|
||||
destroy: boolean = false,
|
||||
columnsFilter: boolean[] = null
|
||||
columnsFilter: boolean[] = null,
|
||||
): void {
|
||||
var $dataTable = tableEntityListViewModelMap[queryTablesTab.tabId].$dataTable;
|
||||
if (destroy) {
|
||||
@@ -142,7 +142,7 @@ function createDataTable(
|
||||
.forEach((table) => {
|
||||
table.setAttribute(
|
||||
"summary",
|
||||
`Header for sorting results for container ${tableEntityListViewModel.queryTablesTab.collection.id()}`
|
||||
`Header for sorting results for container ${tableEntityListViewModel.queryTablesTab.collection.id()}`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -177,7 +177,7 @@ function getServerData(sSource: any, aoData: any, fnCallback: any, oSettings: an
|
||||
sSource,
|
||||
aoData,
|
||||
fnCallback,
|
||||
oSettings
|
||||
oSettings,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -275,8 +275,9 @@ function updateTableScrollableRegionWidth(): void {
|
||||
}
|
||||
|
||||
var bodyWidth = $(window).width();
|
||||
var dataTablesScrollBodyPosLeft = $(tabElement).find(Constants.htmlSelectors.dataTableScrollBodySelector).offset()
|
||||
.left;
|
||||
var dataTablesScrollBodyPosLeft = $(tabElement)
|
||||
.find(Constants.htmlSelectors.dataTableScrollBodySelector)
|
||||
.offset().left;
|
||||
var scrollWidth = bodyWidth - dataTablesScrollBodyPosLeft;
|
||||
|
||||
// jquery datatables automatically sets width:100% to both the header and the body when we use it's column autoWidth feature.
|
||||
@@ -308,7 +309,7 @@ function initializeEventHandlers(): void {
|
||||
},
|
||||
/* metaKey */ null,
|
||||
/* shiftKey */ true,
|
||||
/* altKey */ null
|
||||
/* altKey */ null,
|
||||
);
|
||||
|
||||
// Also reset color if [shift-] tabbing away from button while holding down 'enter'
|
||||
|
||||
@@ -55,7 +55,7 @@ export default class DataTableOperationManager {
|
||||
// Simply select the first item in this case.
|
||||
var lastSelectedItemIndex = lastSelectedItem
|
||||
? this._tableEntityListViewModel.getItemIndexFromCurrentPage(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(lastSelectedItem.RowKey._)
|
||||
this._tableEntityListViewModel.getTableEntityKeys(lastSelectedItem.RowKey._),
|
||||
)
|
||||
: -1;
|
||||
var nextIndex: number = isUpArrowKey ? lastSelectedItemIndex - 1 : lastSelectedItemIndex + 1;
|
||||
@@ -152,7 +152,7 @@ export default class DataTableOperationManager {
|
||||
private updateLastSelectedItem($elem: JQuery, isShiftSelect: boolean) {
|
||||
var entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
var entity = this._tableEntityListViewModel.getItemFromCurrentPage(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey)
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey),
|
||||
);
|
||||
|
||||
this._tableEntityListViewModel.lastSelectedItem = entity;
|
||||
@@ -175,7 +175,7 @@ export default class DataTableOperationManager {
|
||||
this._tableEntityListViewModel.clearSelection();
|
||||
ko.utils.arrayPushAll<Entities.ITableEntity>(
|
||||
this._tableEntityListViewModel.selected,
|
||||
this._tableEntityListViewModel.getAllItemsInCurrentPage()
|
||||
this._tableEntityListViewModel.getAllItemsInCurrentPage(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ export default class DataTableOperationManager {
|
||||
|
||||
if (
|
||||
!this._tableEntityListViewModel.isItemSelected(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey)
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey),
|
||||
)
|
||||
) {
|
||||
// Adding item not previously in selection
|
||||
@@ -211,10 +211,10 @@ export default class DataTableOperationManager {
|
||||
if (anchorItem) {
|
||||
var entityIdentity: Entities.ITableEntityIdentity = this.getEntityIdentity($elem);
|
||||
var elementIndex = this._tableEntityListViewModel.getItemIndexFromAllPages(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey)
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey),
|
||||
);
|
||||
var anchorIndex = this._tableEntityListViewModel.getItemIndexFromAllPages(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(anchorItem.RowKey._)
|
||||
this._tableEntityListViewModel.getTableEntityKeys(anchorItem.RowKey._),
|
||||
);
|
||||
|
||||
var startIndex = Math.min(elementIndex, anchorIndex);
|
||||
@@ -223,7 +223,7 @@ export default class DataTableOperationManager {
|
||||
this._tableEntityListViewModel.clearSelection();
|
||||
ko.utils.arrayPushAll<Entities.ITableEntity>(
|
||||
this._tableEntityListViewModel.selected,
|
||||
this._tableEntityListViewModel.getItemsFromAllPagesWithinRange(startIndex, endIndex + 1)
|
||||
this._tableEntityListViewModel.getItemsFromAllPagesWithinRange(startIndex, endIndex + 1),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -233,7 +233,7 @@ export default class DataTableOperationManager {
|
||||
|
||||
if (
|
||||
!this._tableEntityListViewModel.isItemSelected(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey)
|
||||
this._tableEntityListViewModel.getTableEntityKeys(entityIdentity.RowKey),
|
||||
)
|
||||
) {
|
||||
if (this._tableEntityListViewModel.selected().length) {
|
||||
@@ -245,7 +245,7 @@ export default class DataTableOperationManager {
|
||||
|
||||
private addToSelection(rowKey: string) {
|
||||
var selectedEntity: Entities.ITableEntity = this._tableEntityListViewModel.getItemFromCurrentPage(
|
||||
this._tableEntityListViewModel.getTableEntityKeys(rowKey)
|
||||
this._tableEntityListViewModel.getTableEntityKeys(rowKey),
|
||||
);
|
||||
|
||||
if (selectedEntity != null) {
|
||||
|
||||
@@ -86,7 +86,7 @@ export function filterColumns(table: DataTables.DataTable, settings: boolean[]):
|
||||
export function reorderColumns(
|
||||
table: DataTables.DataTable,
|
||||
targetOrder: number[],
|
||||
currentOrder?: number[]
|
||||
currentOrder?: number[],
|
||||
//eslint-disable-next-line
|
||||
): Q.Promise<any> {
|
||||
const columnsCount: number = targetOrder.length;
|
||||
|
||||
@@ -59,7 +59,7 @@ export function removeCssClass($sourceElement: JQuery, cssClassName: string): vo
|
||||
*/
|
||||
export function getPropertyIntersectionFromTableEntities(
|
||||
entities: Entities.ITableEntity[],
|
||||
isCassandraApi: boolean
|
||||
isCassandraApi: boolean,
|
||||
): string[] {
|
||||
const headerUnion: string[] = [];
|
||||
entities &&
|
||||
|
||||
@@ -157,7 +157,7 @@ abstract class DataTableViewModel {
|
||||
item1: Entities.ITableEntity,
|
||||
item2: Entities.ITableEntity,
|
||||
sortOrder: any,
|
||||
oSettings: any
|
||||
oSettings: any,
|
||||
): number;
|
||||
protected abstract isCacheValid(validator: any): boolean;
|
||||
|
||||
@@ -176,7 +176,7 @@ abstract class DataTableViewModel {
|
||||
startIndex: number,
|
||||
pageSize: number,
|
||||
oSettings: any,
|
||||
postRenderTasks: (startIndex: number, pageSize: number) => Promise<void> = null
|
||||
postRenderTasks: (startIndex: number, pageSize: number) => Promise<void> = null,
|
||||
) {
|
||||
this.updatePaginationControls(oSettings);
|
||||
|
||||
@@ -208,7 +208,7 @@ abstract class DataTableViewModel {
|
||||
dataExplorerArea: CommonConstants.Areas.Tab,
|
||||
tabTitle: this.queryTablesTab.tabTitle(),
|
||||
},
|
||||
this.queryTablesTab.onLoadStartKey
|
||||
this.queryTablesTab.onLoadStartKey,
|
||||
);
|
||||
this.queryTablesTab.onLoadStartKey = null;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ export default class TableCommands {
|
||||
});
|
||||
},
|
||||
"Cancel",
|
||||
undefined
|
||||
undefined,
|
||||
);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -47,7 +47,7 @@ function _parse(err: any): ErrorDataModel[] {
|
||||
} else {
|
||||
const innerErrors: any[] = _getInnerErrors(err.message);
|
||||
normalizedErrors = innerErrors.map((innerError) =>
|
||||
typeof innerError === "string" ? { message: innerError } : innerError
|
||||
typeof innerError === "string" ? { message: innerError } : innerError,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,8 +120,8 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
this.id = `tableEntityListViewModel${this.queryTablesTab.tabId}`;
|
||||
this.cqlQuery = ko.observable<string>(
|
||||
`SELECT * FROM ${getQuotedCqlIdentifier(this.queryTablesTab.collection.databaseId)}.${getQuotedCqlIdentifier(
|
||||
this.queryTablesTab.collection.id()
|
||||
)}`
|
||||
this.queryTablesTab.collection.id(),
|
||||
)}`,
|
||||
);
|
||||
this.oDataQuery = ko.observable<string>();
|
||||
this.sqlQuery = ko.observable<string>("SELECT * FROM c");
|
||||
@@ -216,7 +216,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
draw,
|
||||
fnCallback,
|
||||
oSettings,
|
||||
columnSortOrder
|
||||
columnSortOrder,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
var insertIndex: number = Utilities.ensureBetweenBounds(
|
||||
index < 0 ? this.cache.length : index,
|
||||
0,
|
||||
this.cache.length
|
||||
this.cache.length,
|
||||
);
|
||||
|
||||
this.cache.data.splice(insertIndex, 0, entity);
|
||||
@@ -260,7 +260,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
}
|
||||
var oldEntityIndex: number = _.findIndex(
|
||||
this.cache.data,
|
||||
(data: Entities.ITableEntity) => data.RowKey._ === entity.RowKey._
|
||||
(data: Entities.ITableEntity) => data.RowKey._ === entity.RowKey._,
|
||||
);
|
||||
|
||||
this.cache.data.splice(oldEntityIndex, 1, entity);
|
||||
@@ -284,7 +284,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
entities.forEach((entity: Entities.ITableEntity) => {
|
||||
var cachedIndex: number = _.findIndex(
|
||||
this.cache.data,
|
||||
(e: Entities.ITableEntity) => e.RowKey._ === entity.RowKey._
|
||||
(e: Entities.ITableEntity) => e.RowKey._ === entity.RowKey._,
|
||||
);
|
||||
if (cachedIndex >= 0) {
|
||||
this.cache.data.splice(cachedIndex, 1);
|
||||
@@ -307,7 +307,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
item1: Entities.ITableEntity,
|
||||
item2: Entities.ITableEntity,
|
||||
sortOrder: any[],
|
||||
oSettings: any
|
||||
oSettings: any,
|
||||
): number {
|
||||
var sort: any;
|
||||
var itemA: any;
|
||||
@@ -400,7 +400,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
draw: number,
|
||||
renderCallBack: Function,
|
||||
oSettings: any,
|
||||
columnSortOrder: any
|
||||
columnSortOrder: any,
|
||||
): void {
|
||||
this.queryErrorMessage(null);
|
||||
if (this.cache.serverCallInProgress) {
|
||||
@@ -419,13 +419,13 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
.then((headers: CassandraTableKey[]) => {
|
||||
this.updateHeaders(
|
||||
headers.map((header) => header.property),
|
||||
true
|
||||
true,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
var selectedHeadersUnion: string[] = DataTableUtilities.getPropertyIntersectionFromTableEntities(
|
||||
entities,
|
||||
userContext.apiType === "Cassandra"
|
||||
userContext.apiType === "Cassandra",
|
||||
);
|
||||
var newHeaders: string[] = _.difference(selectedHeadersUnion, this.headers);
|
||||
if (newHeaders.length > 0) {
|
||||
@@ -466,7 +466,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
tabTitle: this.queryTablesTab.tabTitle(),
|
||||
error: error,
|
||||
},
|
||||
this.queryTablesTab.onLoadStartKey
|
||||
this.queryTablesTab.onLoadStartKey,
|
||||
);
|
||||
this.queryTablesTab.onLoadStartKey = null;
|
||||
}
|
||||
@@ -488,7 +488,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
private prefetchData(
|
||||
tableQuery: Entities.ITableQuery,
|
||||
downloadSize: number,
|
||||
currentRetry: number = 0
|
||||
currentRetry: number = 0,
|
||||
): Q.Promise<any> {
|
||||
if (!this.cache.serverCallInProgress) {
|
||||
this.cache.serverCallInProgress = true;
|
||||
@@ -508,7 +508,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
ContinuationToken: this._documentIterator.hasMoreResults(),
|
||||
};
|
||||
return Q.resolve(finalEntities);
|
||||
}
|
||||
},
|
||||
);
|
||||
} else if (this.continuationToken && userContext.apiType === "Cassandra") {
|
||||
promise = Q(
|
||||
@@ -516,8 +516,8 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
this.queryTablesTab.collection,
|
||||
this.cqlQuery(),
|
||||
true,
|
||||
this.continuationToken
|
||||
)
|
||||
this.continuationToken,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
let query = this.sqlQuery();
|
||||
@@ -525,7 +525,7 @@ export default class TableEntityListViewModel extends DataTableViewModel {
|
||||
query = this.cqlQuery();
|
||||
}
|
||||
promise = Q(
|
||||
this.queryTablesTab.container.tableDataClient.queryDocuments(this.queryTablesTab.collection, query, true)
|
||||
this.queryTablesTab.container.tableDataClient.queryDocuments(this.queryTablesTab.collection, query, true),
|
||||
);
|
||||
}
|
||||
return promise
|
||||
|
||||
@@ -36,7 +36,7 @@ export enum TimeUnit {
|
||||
export function addRangeTimestamp(
|
||||
timestamp: ITimestampQuery,
|
||||
queryBuilderViewModel: QueryBuilderViewModel,
|
||||
queryClauseViewModel: QueryClauseViewModel
|
||||
queryClauseViewModel: QueryClauseViewModel,
|
||||
): void {
|
||||
queryBuilderViewModel.addCustomRange(timestamp, queryClauseViewModel);
|
||||
}
|
||||
@@ -294,7 +294,7 @@ function _getLocalIsoDateString(date: Date): string {
|
||||
function _getLocalIsoDateStringFromParts(
|
||||
fullYear: number,
|
||||
month: number /* 0..11 */,
|
||||
date: number /* 1..31 */
|
||||
date: number /* 1..31 */,
|
||||
): string {
|
||||
month = month + 1;
|
||||
return (
|
||||
|
||||
@@ -119,7 +119,7 @@ export default class QueryBuilderViewModel {
|
||||
"",
|
||||
"",
|
||||
//null,
|
||||
true
|
||||
true,
|
||||
);
|
||||
const example2 = new QueryClauseViewModel(
|
||||
this,
|
||||
@@ -133,7 +133,7 @@ export default class QueryBuilderViewModel {
|
||||
"",
|
||||
"",
|
||||
//null,
|
||||
true
|
||||
true,
|
||||
);
|
||||
this.addClauseImpl(example1, 0);
|
||||
this.addClauseImpl(example2, 1);
|
||||
@@ -156,8 +156,8 @@ export default class QueryBuilderViewModel {
|
||||
clause.type(),
|
||||
clause.operator(),
|
||||
clause.value(),
|
||||
this.generateRightParentheses(clause)
|
||||
)
|
||||
this.generateRightParentheses(clause),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ export default class QueryBuilderViewModel {
|
||||
clause.type(),
|
||||
clause.operator(),
|
||||
value,
|
||||
this.generateRightParentheses(clause)
|
||||
)
|
||||
this.generateRightParentheses(clause),
|
||||
),
|
||||
);
|
||||
first = false;
|
||||
}
|
||||
@@ -275,8 +275,8 @@ export default class QueryBuilderViewModel {
|
||||
clause.type(),
|
||||
clause.operator(),
|
||||
value,
|
||||
this.generateRightParentheses(clause)
|
||||
)
|
||||
this.generateRightParentheses(clause),
|
||||
),
|
||||
);
|
||||
first = false;
|
||||
}
|
||||
@@ -354,31 +354,31 @@ export default class QueryBuilderViewModel {
|
||||
type: string,
|
||||
operator: string,
|
||||
value: string,
|
||||
rightParentheses: string
|
||||
rightParentheses: string,
|
||||
): string => {
|
||||
switch (type) {
|
||||
case Constants.TableType.DateTime:
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}${propertyName} ${this.operatorConverter(
|
||||
operator
|
||||
operator,
|
||||
)} ${value}${rightParentheses}`;
|
||||
case Constants.TableType.String:
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}${propertyName} ${this.operatorConverter(
|
||||
operator
|
||||
operator,
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
)} \'${value}\'${rightParentheses}`;
|
||||
case Constants.TableType.Guid:
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}${propertyName} ${this.operatorConverter(
|
||||
operator
|
||||
operator,
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
)} guid\'${value}\'${rightParentheses}`;
|
||||
case Constants.TableType.Binary:
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}${propertyName} ${this.operatorConverter(
|
||||
operator
|
||||
operator,
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
)} binary\'${value}\'${rightParentheses}`;
|
||||
default:
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}${propertyName} ${this.operatorConverter(
|
||||
operator
|
||||
operator,
|
||||
)} ${value}${rightParentheses}`;
|
||||
}
|
||||
};
|
||||
@@ -390,7 +390,7 @@ export default class QueryBuilderViewModel {
|
||||
type: string,
|
||||
operator: string,
|
||||
value: string,
|
||||
rightParentheses: string
|
||||
rightParentheses: string,
|
||||
): string => {
|
||||
if (propertyName === Constants.EntityKeyNames.PartitionKey) {
|
||||
propertyName = TableEntityProcessor.keyProperties.PartitionKey;
|
||||
@@ -403,20 +403,20 @@ export default class QueryBuilderViewModel {
|
||||
} else if (propertyName === Constants.EntityKeyNames.Timestamp) {
|
||||
propertyName = TableEntityProcessor.keyProperties.Timestamp;
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}c.${propertyName} ${operator} ${DateTimeUtilities.convertJSDateToUnix(
|
||||
value
|
||||
value,
|
||||
)}${rightParentheses}`;
|
||||
}
|
||||
switch (type) {
|
||||
case Constants.TableType.DateTime:
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}c.${propertyName}["$v"] ${operator} \'${DateTimeUtilities.convertJSDateToTicksWithPadding(
|
||||
value
|
||||
value,
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
)}\'${rightParentheses}`;
|
||||
case Constants.TableType.Int64:
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
return ` ${clauseRule.toLowerCase()} ${leftParentheses}c.${propertyName}["$v"] ${operator} \'${Utilities.padLongWithZeros(
|
||||
value
|
||||
value,
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
)}\'${rightParentheses}`;
|
||||
case Constants.TableType.String:
|
||||
@@ -436,7 +436,7 @@ export default class QueryBuilderViewModel {
|
||||
type: string,
|
||||
operator: string,
|
||||
value: string,
|
||||
rightParentheses: string
|
||||
rightParentheses: string,
|
||||
): string => {
|
||||
if (
|
||||
type === Constants.CassandraType.Text ||
|
||||
@@ -490,7 +490,7 @@ export default class QueryBuilderViewModel {
|
||||
"",
|
||||
"",
|
||||
//null,
|
||||
true
|
||||
true,
|
||||
);
|
||||
this.addClauseImpl(newClause, index);
|
||||
if (index === this.clauseArray().length - 1) {
|
||||
@@ -663,7 +663,7 @@ export default class QueryBuilderViewModel {
|
||||
timestamp.endTime,
|
||||
"range",
|
||||
//null,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
newClause.isLocal = ko.observable(timestamp.timeZone === "local");
|
||||
|
||||
@@ -46,7 +46,7 @@ export default class QueryClauseViewModel {
|
||||
timestampType: string,
|
||||
//customLastTimestamp: CustomTimestampHelper.ILastQuery,
|
||||
isLocal: boolean,
|
||||
id?: string
|
||||
id?: string,
|
||||
) {
|
||||
this._queryBuilderViewModel = queryBuilderViewModel;
|
||||
this.checkedForGrouping = ko.observable<boolean>(false);
|
||||
@@ -72,7 +72,7 @@ export default class QueryClauseViewModel {
|
||||
const isPreferredApiCassandra = userContext.apiType === "Cassandra";
|
||||
const cassandraKeys = isPreferredApiCassandra
|
||||
? this._queryBuilderViewModel.tableEntityListViewModel.queryTablesTab.collection.cassandraKeys.partitionKeys.map(
|
||||
(key) => key.property
|
||||
(key) => key.property,
|
||||
)
|
||||
: [];
|
||||
return (
|
||||
@@ -85,7 +85,7 @@ export default class QueryClauseViewModel {
|
||||
this.field() !== "Timestamp" &&
|
||||
this.field() !== "PartitionKey" &&
|
||||
this.field() !== "RowKey" &&
|
||||
userContext.apiType !== "Cassandra"
|
||||
userContext.apiType !== "Cassandra",
|
||||
);
|
||||
|
||||
this.and_or.subscribe(() => {
|
||||
@@ -172,8 +172,8 @@ export default class QueryClauseViewModel {
|
||||
} else {
|
||||
this.resetFromTimestamp();
|
||||
if (userContext.apiType === "Cassandra") {
|
||||
const cassandraSchema = this._queryBuilderViewModel.tableEntityListViewModel.queryTablesTab.collection
|
||||
.cassandraSchema;
|
||||
const cassandraSchema =
|
||||
this._queryBuilderViewModel.tableEntityListViewModel.queryTablesTab.collection.cassandraSchema;
|
||||
for (let i = 0, len = cassandraSchema.length; i < len; i++) {
|
||||
if (cassandraSchema[i].property === this.field()) {
|
||||
this.type(cassandraSchema[i].type);
|
||||
|
||||
@@ -62,7 +62,7 @@ export default class QueryViewModel {
|
||||
() =>
|
||||
this.queryText() !== this.unchangedSaveText() ||
|
||||
this.selectText() !== this.unchangedSaveSelect() ||
|
||||
this.topValue() !== this.unchangedSaveTop()
|
||||
this.topValue() !== this.unchangedSaveTop(),
|
||||
);
|
||||
|
||||
this.queryBuilderViewModel().clauseArray.subscribe(() => {
|
||||
@@ -191,8 +191,8 @@ export default class QueryViewModel {
|
||||
this._tableEntityListViewModel.sqlQuery("SELECT * FROM c");
|
||||
this._tableEntityListViewModel.cqlQuery(
|
||||
`SELECT * FROM ${getQuotedCqlIdentifier(this.queryTablesTab.collection.databaseId)}.${getQuotedCqlIdentifier(
|
||||
this.queryTablesTab.collection.id()
|
||||
)}`
|
||||
this.queryTablesTab.collection.id(),
|
||||
)}`,
|
||||
);
|
||||
return this._tableEntityListViewModel.reloadTable(false);
|
||||
};
|
||||
|
||||
@@ -35,37 +35,37 @@ export abstract class TableDataClient {
|
||||
|
||||
public abstract createDocument(
|
||||
collection: ViewModels.Collection,
|
||||
entity: Entities.ITableEntity
|
||||
entity: Entities.ITableEntity,
|
||||
): Q.Promise<Entities.ITableEntity>;
|
||||
|
||||
public abstract updateDocument(
|
||||
collection: ViewModels.Collection,
|
||||
originalDocument: any,
|
||||
newEntity: Entities.ITableEntity
|
||||
newEntity: Entities.ITableEntity,
|
||||
): Promise<Entities.ITableEntity>;
|
||||
|
||||
public abstract queryDocuments(
|
||||
collection: ViewModels.Collection,
|
||||
query: string,
|
||||
shouldNotify?: boolean,
|
||||
paginationToken?: string
|
||||
paginationToken?: string,
|
||||
): Promise<Entities.IListTableEntitiesResult>;
|
||||
|
||||
public abstract deleteDocuments(
|
||||
collection: ViewModels.Collection,
|
||||
entitiesToDelete: Entities.ITableEntity[]
|
||||
entitiesToDelete: Entities.ITableEntity[],
|
||||
): Promise<any>;
|
||||
}
|
||||
|
||||
export class TablesAPIDataClient extends TableDataClient {
|
||||
public createDocument(
|
||||
collection: ViewModels.Collection,
|
||||
entity: Entities.ITableEntity
|
||||
entity: Entities.ITableEntity,
|
||||
): Q.Promise<Entities.ITableEntity> {
|
||||
const deferred = Q.defer<Entities.ITableEntity>();
|
||||
createDocument(
|
||||
collection,
|
||||
TableEntityProcessor.convertEntityToNewDocument(<Entities.ITableEntityForTablesAPI>entity)
|
||||
TableEntityProcessor.convertEntityToNewDocument(<Entities.ITableEntityForTablesAPI>entity),
|
||||
).then(
|
||||
(newDocument: any) => {
|
||||
const newEntity = TableEntityProcessor.convertDocumentsToEntities([newDocument])[0];
|
||||
@@ -73,7 +73,7 @@ export class TablesAPIDataClient extends TableDataClient {
|
||||
},
|
||||
(reason) => {
|
||||
deferred.reject(reason);
|
||||
}
|
||||
},
|
||||
);
|
||||
return deferred.promise;
|
||||
}
|
||||
@@ -81,13 +81,13 @@ export class TablesAPIDataClient extends TableDataClient {
|
||||
public async updateDocument(
|
||||
collection: ViewModels.Collection,
|
||||
originalDocument: any,
|
||||
entity: Entities.ITableEntity
|
||||
entity: Entities.ITableEntity,
|
||||
): Promise<Entities.ITableEntity> {
|
||||
try {
|
||||
const newDocument = await updateDocument(
|
||||
collection,
|
||||
originalDocument,
|
||||
TableEntityProcessor.convertEntityToNewDocument(<Entities.ITableEntityForTablesAPI>entity)
|
||||
TableEntityProcessor.convertEntityToNewDocument(<Entities.ITableEntityForTablesAPI>entity),
|
||||
);
|
||||
return TableEntityProcessor.convertDocumentsToEntities([newDocument])[0];
|
||||
} catch (error) {
|
||||
@@ -98,7 +98,7 @@ export class TablesAPIDataClient extends TableDataClient {
|
||||
|
||||
public async queryDocuments(
|
||||
collection: ViewModels.Collection,
|
||||
query: string
|
||||
query: string,
|
||||
): Promise<Entities.IListTableEntitiesResult> {
|
||||
try {
|
||||
const options = {
|
||||
@@ -122,18 +122,18 @@ export class TablesAPIDataClient extends TableDataClient {
|
||||
|
||||
public async deleteDocuments(
|
||||
collection: ViewModels.Collection,
|
||||
entitiesToDelete: Entities.ITableEntity[]
|
||||
entitiesToDelete: Entities.ITableEntity[],
|
||||
): Promise<any> {
|
||||
const documentsToDelete: any[] = TableEntityProcessor.convertEntitiesToDocuments(
|
||||
<Entities.ITableEntityForTablesAPI[]>entitiesToDelete,
|
||||
collection
|
||||
collection,
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
documentsToDelete?.map(async (document) => {
|
||||
document.id = ko.observable<string>(document.id);
|
||||
await deleteDocument(collection, document);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ export class TablesAPIDataClient extends TableDataClient {
|
||||
export class CassandraAPIDataClient extends TableDataClient {
|
||||
public createDocument(
|
||||
collection: ViewModels.Collection,
|
||||
entity: Entities.ITableEntity
|
||||
entity: Entities.ITableEntity,
|
||||
): Q.Promise<Entities.ITableEntity> {
|
||||
const clearInProgressMessage = logConsoleProgress(`Adding new row to table ${collection.id()}`);
|
||||
let properties = "(";
|
||||
@@ -173,7 +173,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
(error) => {
|
||||
handleError(error, "AddRowCassandra", `Error while adding new row to table ${collection.id()}`);
|
||||
deferred.reject(error);
|
||||
}
|
||||
},
|
||||
)
|
||||
.finally(clearInProgressMessage);
|
||||
return deferred.promise;
|
||||
@@ -182,14 +182,14 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
public async updateDocument(
|
||||
collection: ViewModels.Collection,
|
||||
originalDocument: any,
|
||||
newEntity: Entities.ITableEntity
|
||||
newEntity: Entities.ITableEntity,
|
||||
): Promise<Entities.ITableEntity> {
|
||||
const clearMessage = NotificationConsoleUtils.logConsoleProgress(`Updating row ${originalDocument.RowKey._}`);
|
||||
|
||||
try {
|
||||
let whereSegment = " WHERE";
|
||||
let keys: CassandraTableKey[] = collection.cassandraKeys.partitionKeys.concat(
|
||||
collection.cassandraKeys.clusteringKeys
|
||||
collection.cassandraKeys.clusteringKeys,
|
||||
);
|
||||
for (let keyIndex in keys) {
|
||||
const key = keys[keyIndex].property;
|
||||
@@ -257,7 +257,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
collection: ViewModels.Collection,
|
||||
query: string,
|
||||
shouldNotify?: boolean,
|
||||
paginationToken?: string
|
||||
paginationToken?: string,
|
||||
): Promise<Entities.IListTableEntitiesResult> {
|
||||
const clearMessage =
|
||||
shouldNotify && NotificationConsoleUtils.logConsoleProgress(`Querying rows for table ${collection.id()}`);
|
||||
@@ -283,7 +283,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
});
|
||||
shouldNotify &&
|
||||
NotificationConsoleUtils.logConsoleInfo(
|
||||
`Successfully fetched ${data.result.length} rows for table ${collection.id()}`
|
||||
`Successfully fetched ${data.result.length} rows for table ${collection.id()}`,
|
||||
);
|
||||
return {
|
||||
Results: data.result,
|
||||
@@ -300,7 +300,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
|
||||
public async deleteDocuments(
|
||||
collection: ViewModels.Collection,
|
||||
entitiesToDelete: Entities.ITableEntity[]
|
||||
entitiesToDelete: Entities.ITableEntity[],
|
||||
): Promise<any> {
|
||||
const query = `DELETE FROM ${collection.databaseId}.${collection.id()} WHERE `;
|
||||
const partitionKeyProperty = this.getCassandraPartitionKeyProperty(collection);
|
||||
@@ -324,7 +324,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
} finally {
|
||||
clearMessage();
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
cassandraEndpoint: string,
|
||||
resourceId: string,
|
||||
explorer: Explorer,
|
||||
createKeyspaceQuery: string
|
||||
createKeyspaceQuery: string,
|
||||
): Q.Promise<any> {
|
||||
if (!createKeyspaceQuery) {
|
||||
return Q.reject("No query specified");
|
||||
@@ -350,10 +350,10 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
handleError(
|
||||
error,
|
||||
"CreateKeyspaceCassandra",
|
||||
`Error while creating a keyspace with query ${createKeyspaceQuery}`
|
||||
`Error while creating a keyspace with query ${createKeyspaceQuery}`,
|
||||
);
|
||||
deferred.reject(error);
|
||||
}
|
||||
},
|
||||
)
|
||||
.finally(clearInProgressMessage);
|
||||
|
||||
@@ -365,7 +365,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
resourceId: string,
|
||||
explorer: Explorer,
|
||||
createTableQuery: string,
|
||||
createKeyspaceQuery?: string
|
||||
createKeyspaceQuery?: string,
|
||||
): Q.Promise<any> {
|
||||
let createKeyspacePromise: Q.Promise<any>;
|
||||
if (createKeyspaceQuery) {
|
||||
@@ -387,13 +387,13 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
(error) => {
|
||||
handleError(error, "CreateTableCassandra", `Error while creating a table with query ${createTableQuery}`);
|
||||
deferred.reject(error);
|
||||
}
|
||||
},
|
||||
)
|
||||
.finally(clearInProgressMessage);
|
||||
},
|
||||
(reason) => {
|
||||
deferred.reject(reason);
|
||||
}
|
||||
},
|
||||
);
|
||||
return deferred.promise;
|
||||
}
|
||||
@@ -432,7 +432,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
(error: any) => {
|
||||
handleError(error, "FetchKeysCassandra", `Error fetching keys for table ${collection.id()}`);
|
||||
deferred.reject(error);
|
||||
}
|
||||
},
|
||||
)
|
||||
.done(clearInProgressMessage);
|
||||
return deferred.promise;
|
||||
@@ -472,7 +472,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
(error: any) => {
|
||||
handleError(error, "FetchSchemaCassandra", `Error fetching schema for table ${collection.id()}`);
|
||||
deferred.reject(error);
|
||||
}
|
||||
},
|
||||
)
|
||||
.done(clearInProgressMessage);
|
||||
return deferred.promise;
|
||||
@@ -501,7 +501,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
},
|
||||
(reason) => {
|
||||
deferred.reject(reason);
|
||||
}
|
||||
},
|
||||
);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export function convertDocumentsToEntities(documents: any[]): Entities.ITableEnt
|
||||
// Do not use this to create a document to send to the server, only for delete and for giving rid/self/collection to the utility methods.
|
||||
export function convertEntitiesToDocuments(
|
||||
entities: Entities.ITableEntityForTablesAPI[],
|
||||
collection: ViewModels.Collection
|
||||
collection: ViewModels.Collection,
|
||||
): any[] {
|
||||
let results: any[] = [];
|
||||
entities &&
|
||||
|
||||
@@ -119,7 +119,7 @@ export function onKey(
|
||||
action: ($sourceElement: JQuery) => void,
|
||||
metaKey: boolean = null,
|
||||
shiftKey: boolean = null,
|
||||
altKey: boolean = null
|
||||
altKey: boolean = null,
|
||||
): boolean {
|
||||
var source: any = event.target || event.srcElement,
|
||||
keyCode: number = event.keyCode,
|
||||
@@ -149,7 +149,7 @@ export function onEnter(
|
||||
action: ($sourceElement: JQuery) => void,
|
||||
metaKey: boolean = null,
|
||||
shiftKey: boolean = null,
|
||||
altKey: boolean = null
|
||||
altKey: boolean = null,
|
||||
): boolean {
|
||||
return onKey(event, Constants.keyCodes.Enter, action, metaKey, shiftKey, altKey);
|
||||
}
|
||||
@@ -162,7 +162,7 @@ export function onTab(
|
||||
action: ($sourceElement: JQuery) => void,
|
||||
metaKey: boolean = null,
|
||||
shiftKey: boolean = null,
|
||||
altKey: boolean = null
|
||||
altKey: boolean = null,
|
||||
): boolean {
|
||||
return onKey(event, Constants.keyCodes.Tab, action, metaKey, shiftKey, altKey);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ export function onEsc(
|
||||
action: ($sourceElement: JQuery) => void,
|
||||
metaKey: boolean = null,
|
||||
shiftKey: boolean = null,
|
||||
altKey: boolean = null
|
||||
altKey: boolean = null,
|
||||
): boolean {
|
||||
return onKey(event, Constants.keyCodes.Esc, action, metaKey, shiftKey, altKey);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user