mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-22 12:15:19 +00:00
Q removal: the easy parts
This commit is contained in:
parent
94ff6b3e81
commit
6adfea03ab
@ -7,7 +7,6 @@ import {
|
|||||||
Resource
|
Resource
|
||||||
} from "@azure/cosmos";
|
} from "@azure/cosmos";
|
||||||
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
import { RequestOptions } from "@azure/cosmos/dist-esm";
|
||||||
import Q from "q";
|
|
||||||
import { configContext, Platform } from "../ConfigContext";
|
import { configContext, Platform } from "../ConfigContext";
|
||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||||
@ -39,18 +38,17 @@ export function getCommonQueryOptions(options: FeedOptions): any {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function queryDocuments(
|
export async function queryDocuments(
|
||||||
databaseId: string,
|
databaseId: string,
|
||||||
containerId: string,
|
containerId: string,
|
||||||
query: string,
|
query: string,
|
||||||
options: any
|
options: any
|
||||||
): Q.Promise<QueryIterator<ItemDefinition & Resource>> {
|
): Promise<QueryIterator<ItemDefinition & Resource>> {
|
||||||
options = getCommonQueryOptions(options);
|
options = getCommonQueryOptions(options);
|
||||||
const documentsIterator = client()
|
return client()
|
||||||
.database(databaseId)
|
.database(databaseId)
|
||||||
.container(containerId)
|
.container(containerId)
|
||||||
.items.query(query, options);
|
.items.query(query, options);
|
||||||
return Q(documentsIterator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPartitionKeyHeaderForConflict(conflictId: ConflictId): Object {
|
export function getPartitionKeyHeaderForConflict(conflictId: ConflictId): Object {
|
||||||
@ -76,17 +74,15 @@ export function updateDocument(
|
|||||||
collection: ViewModels.CollectionBase,
|
collection: ViewModels.CollectionBase,
|
||||||
documentId: DocumentId,
|
documentId: DocumentId,
|
||||||
newDocument: any
|
newDocument: any
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
const partitionKey = documentId.partitionKeyValue;
|
const partitionKey = documentId.partitionKeyValue;
|
||||||
|
|
||||||
return Q(
|
return client()
|
||||||
client()
|
|
||||||
.database(collection.databaseId)
|
.database(collection.databaseId)
|
||||||
.container(collection.id())
|
.container(collection.id())
|
||||||
.item(documentId.id(), partitionKey)
|
.item(documentId.id(), partitionKey)
|
||||||
.replace(newDocument)
|
.replace(newDocument)
|
||||||
.then(response => response.resource)
|
.then(response => response.resource);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function executeStoredProcedure(
|
export function executeStoredProcedure(
|
||||||
@ -94,105 +90,89 @@ export function executeStoredProcedure(
|
|||||||
storedProcedure: StoredProcedure,
|
storedProcedure: StoredProcedure,
|
||||||
partitionKeyValue: any,
|
partitionKeyValue: any,
|
||||||
params: any[]
|
params: any[]
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
// TODO remove this deferred. Kept it because of timeout code at bottom of function
|
return Promise.race([
|
||||||
const deferred = Q.defer<any>();
|
|
||||||
|
|
||||||
client()
|
client()
|
||||||
.database(collection.databaseId)
|
.database(collection.databaseId)
|
||||||
.container(collection.id())
|
.container(collection.id())
|
||||||
.scripts.storedProcedure(storedProcedure.id())
|
.scripts.storedProcedure(storedProcedure.id())
|
||||||
.execute(partitionKeyValue, params, { enableScriptLogging: true })
|
.execute(partitionKeyValue, params, { enableScriptLogging: true })
|
||||||
.then(response =>
|
.then(response => ({
|
||||||
deferred.resolve({
|
|
||||||
result: response.resource,
|
result: response.resource,
|
||||||
scriptLogs: response.headers[Constants.HttpHeaders.scriptLogResults]
|
scriptLogs: response.headers[Constants.HttpHeaders.scriptLogResults]
|
||||||
})
|
})),
|
||||||
|
new Promise((_, reject) =>
|
||||||
|
setTimeout(
|
||||||
|
() => reject(`Request timed out while executing stored procedure ${storedProcedure.id()}`),
|
||||||
|
Constants.ClientDefaults.requestTimeoutMs
|
||||||
)
|
)
|
||||||
.catch(error => deferred.reject(error));
|
)
|
||||||
|
]);
|
||||||
return deferred.promise.timeout(
|
|
||||||
Constants.ClientDefaults.requestTimeoutMs,
|
|
||||||
`Request timed out while executing stored procedure ${storedProcedure.id()}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createDocument(collection: ViewModels.CollectionBase, newDocument: any): Q.Promise<any> {
|
export function createDocument(collection: ViewModels.CollectionBase, newDocument: any): Promise<any> {
|
||||||
return Q(
|
return client()
|
||||||
client()
|
|
||||||
.database(collection.databaseId)
|
.database(collection.databaseId)
|
||||||
.container(collection.id())
|
.container(collection.id())
|
||||||
.items.create(newDocument)
|
.items.create(newDocument)
|
||||||
.then(response => response.resource)
|
.then(response => response.resource);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
export function readDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Promise<any> {
|
||||||
const partitionKey = documentId.partitionKeyValue;
|
const partitionKey = documentId.partitionKeyValue;
|
||||||
|
|
||||||
return Q(
|
return client()
|
||||||
client()
|
|
||||||
.database(collection.databaseId)
|
.database(collection.databaseId)
|
||||||
.container(collection.id())
|
.container(collection.id())
|
||||||
.item(documentId.id(), partitionKey)
|
.item(documentId.id(), partitionKey)
|
||||||
.read()
|
.read()
|
||||||
.then(response => response.resource)
|
.then(response => response.resource);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
export function deleteDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Promise<any> {
|
||||||
const partitionKey = documentId.partitionKeyValue;
|
const partitionKey = documentId.partitionKeyValue;
|
||||||
|
|
||||||
return Q(
|
return client()
|
||||||
client()
|
|
||||||
.database(collection.databaseId)
|
.database(collection.databaseId)
|
||||||
.container(collection.id())
|
.container(collection.id())
|
||||||
.item(documentId.id(), partitionKey)
|
.item(documentId.id(), partitionKey)
|
||||||
.delete()
|
.delete();
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteConflict(
|
export function deleteConflict(
|
||||||
collection: ViewModels.CollectionBase,
|
collection: ViewModels.CollectionBase,
|
||||||
conflictId: ConflictId,
|
conflictId: ConflictId,
|
||||||
options: any = {}
|
options: any = {}
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
options.partitionKey = options.partitionKey || getPartitionKeyHeaderForConflict(conflictId);
|
options.partitionKey = options.partitionKey || getPartitionKeyHeaderForConflict(conflictId);
|
||||||
|
|
||||||
return Q(
|
return client()
|
||||||
client()
|
|
||||||
.database(collection.databaseId)
|
.database(collection.databaseId)
|
||||||
.container(collection.id())
|
.container(collection.id())
|
||||||
.conflict(conflictId.id())
|
.conflict(conflictId.id())
|
||||||
.delete(options)
|
.delete(options);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshCachedOffers(): Q.Promise<void> {
|
export async function refreshCachedOffers(): Promise<void> {
|
||||||
if (configContext.platform === Platform.Portal) {
|
if (configContext.platform === Platform.Portal) {
|
||||||
return sendCachedDataMessage(MessageTypes.RefreshOffers, []);
|
sendCachedDataMessage(MessageTypes.RefreshOffers, []);
|
||||||
} else {
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshCachedResources(options?: any): Q.Promise<void> {
|
export async function refreshCachedResources(options?: any): Promise<void> {
|
||||||
if (configContext.platform === Platform.Portal) {
|
if (configContext.platform === Platform.Portal) {
|
||||||
return sendCachedDataMessage(MessageTypes.RefreshResources, []);
|
sendCachedDataMessage(MessageTypes.RefreshResources, []);
|
||||||
} else {
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function queryConflicts(
|
export async function queryConflicts(
|
||||||
databaseId: string,
|
databaseId: string,
|
||||||
containerId: string,
|
containerId: string,
|
||||||
query: string,
|
query: string,
|
||||||
options: any
|
options: any
|
||||||
): Q.Promise<QueryIterator<ConflictDefinition & Resource>> {
|
): Promise<QueryIterator<ConflictDefinition & Resource>> {
|
||||||
const documentsIterator = client()
|
return client()
|
||||||
.database(databaseId)
|
.database(databaseId)
|
||||||
.container(containerId)
|
.container(containerId)
|
||||||
.conflicts.query(query, options);
|
.conflicts.query(query, options);
|
||||||
return Q(documentsIterator);
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { ConflictDefinition, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
import { ConflictDefinition, ItemDefinition, QueryIterator, Resource } from "@azure/cosmos";
|
||||||
import Q from "q";
|
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
import ConflictId from "../Explorer/Tree/ConflictId";
|
import ConflictId from "../Explorer/Tree/ConflictId";
|
||||||
import DocumentId from "../Explorer/Tree/DocumentId";
|
import DocumentId from "../Explorer/Tree/DocumentId";
|
||||||
@ -16,7 +15,7 @@ export function queryDocuments(
|
|||||||
containerId: string,
|
containerId: string,
|
||||||
query: string,
|
query: string,
|
||||||
options: any
|
options: any
|
||||||
): Q.Promise<QueryIterator<ItemDefinition & Resource>> {
|
): Promise<QueryIterator<ItemDefinition & Resource>> {
|
||||||
return DataAccessUtilityBase.queryDocuments(databaseId, containerId, query, options);
|
return DataAccessUtilityBase.queryDocuments(databaseId, containerId, query, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ export function queryConflicts(
|
|||||||
containerId: string,
|
containerId: string,
|
||||||
query: string,
|
query: string,
|
||||||
options: any
|
options: any
|
||||||
): Q.Promise<QueryIterator<ConflictDefinition & Resource>> {
|
): Promise<QueryIterator<ConflictDefinition & Resource>> {
|
||||||
return DataAccessUtilityBase.queryConflicts(databaseId, containerId, query, options);
|
return DataAccessUtilityBase.queryConflicts(databaseId, containerId, query, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,17 +42,15 @@ export function executeStoredProcedure(
|
|||||||
storedProcedure: StoredProcedure,
|
storedProcedure: StoredProcedure,
|
||||||
partitionKeyValue: any,
|
partitionKeyValue: any,
|
||||||
params: any[]
|
params: any[]
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
var deferred = Q.defer<any>();
|
|
||||||
|
|
||||||
const clearMessage = logConsoleProgress(`Executing stored procedure ${storedProcedure.id()}`);
|
const clearMessage = logConsoleProgress(`Executing stored procedure ${storedProcedure.id()}`);
|
||||||
DataAccessUtilityBase.executeStoredProcedure(collection, storedProcedure, partitionKeyValue, params)
|
return DataAccessUtilityBase.executeStoredProcedure(collection, storedProcedure, partitionKeyValue, params)
|
||||||
.then(
|
.then(
|
||||||
(response: any) => {
|
(response: any) => {
|
||||||
deferred.resolve(response);
|
|
||||||
logConsoleInfo(
|
logConsoleInfo(
|
||||||
`Finished executing stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`
|
`Finished executing stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`
|
||||||
);
|
);
|
||||||
|
return response;
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
handleError(
|
handleError(
|
||||||
@ -61,14 +58,10 @@ export function executeStoredProcedure(
|
|||||||
`Failed to execute stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`,
|
`Failed to execute stored procedure ${storedProcedure.id()} for container ${storedProcedure.collection.id()}`,
|
||||||
"ExecuteStoredProcedure"
|
"ExecuteStoredProcedure"
|
||||||
);
|
);
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(clearMessage);
|
||||||
clearMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function queryDocumentsPage(
|
export function queryDocumentsPage(
|
||||||
@ -76,150 +69,114 @@ export function queryDocumentsPage(
|
|||||||
documentsIterator: MinimalQueryIterator,
|
documentsIterator: MinimalQueryIterator,
|
||||||
firstItemIndex: number,
|
firstItemIndex: number,
|
||||||
options: any
|
options: any
|
||||||
): Q.Promise<ViewModels.QueryResults> {
|
): Promise<ViewModels.QueryResults> {
|
||||||
var deferred = Q.defer<ViewModels.QueryResults>();
|
|
||||||
const entityName = getEntityName();
|
const entityName = getEntityName();
|
||||||
const clearMessage = logConsoleProgress(`Querying ${entityName} for container ${resourceName}`);
|
const clearMessage = logConsoleProgress(`Querying ${entityName} for container ${resourceName}`);
|
||||||
Q(nextPage(documentsIterator, firstItemIndex))
|
return nextPage(documentsIterator, firstItemIndex)
|
||||||
.then(
|
.then(
|
||||||
(result: ViewModels.QueryResults) => {
|
(result: ViewModels.QueryResults) => {
|
||||||
const itemCount = (result.documents && result.documents.length) || 0;
|
const itemCount = (result.documents && result.documents.length) || 0;
|
||||||
logConsoleInfo(`Successfully fetched ${itemCount} ${entityName} for container ${resourceName}`);
|
logConsoleInfo(`Successfully fetched ${itemCount} ${entityName} for container ${resourceName}`);
|
||||||
deferred.resolve(result);
|
return result;
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
handleError(error, `Failed to query ${entityName} for container ${resourceName}`, "QueryDocumentsPage");
|
handleError(error, `Failed to query ${entityName} for container ${resourceName}`, "QueryDocumentsPage");
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(clearMessage);
|
||||||
clearMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
export function readDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Promise<any> {
|
||||||
var deferred = Q.defer<any>();
|
|
||||||
const entityName = getEntityName();
|
const entityName = getEntityName();
|
||||||
const clearMessage = logConsoleProgress(`Reading ${entityName} ${documentId.id()}`);
|
const clearMessage = logConsoleProgress(`Reading ${entityName} ${documentId.id()}`);
|
||||||
DataAccessUtilityBase.readDocument(collection, documentId)
|
return DataAccessUtilityBase.readDocument(collection, documentId)
|
||||||
.then(
|
.catch((error: any) => {
|
||||||
(document: any) => {
|
|
||||||
deferred.resolve(document);
|
|
||||||
},
|
|
||||||
(error: any) => {
|
|
||||||
handleError(error, `Failed to read ${entityName} ${documentId.id()}`, "ReadDocument");
|
handleError(error, `Failed to read ${entityName} ${documentId.id()}`, "ReadDocument");
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
})
|
||||||
)
|
.finally(clearMessage);
|
||||||
.finally(() => {
|
|
||||||
clearMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateDocument(
|
export function updateDocument(
|
||||||
collection: ViewModels.CollectionBase,
|
collection: ViewModels.CollectionBase,
|
||||||
documentId: DocumentId,
|
documentId: DocumentId,
|
||||||
newDocument: any
|
newDocument: any
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
var deferred = Q.defer<any>();
|
|
||||||
const entityName = getEntityName();
|
const entityName = getEntityName();
|
||||||
const clearMessage = logConsoleProgress(`Updating ${entityName} ${documentId.id()}`);
|
const clearMessage = logConsoleProgress(`Updating ${entityName} ${documentId.id()}`);
|
||||||
DataAccessUtilityBase.updateDocument(collection, documentId, newDocument)
|
return DataAccessUtilityBase.updateDocument(collection, documentId, newDocument)
|
||||||
.then(
|
.then(
|
||||||
(updatedDocument: any) => {
|
(updatedDocument: any) => {
|
||||||
logConsoleInfo(`Successfully updated ${entityName} ${documentId.id()}`);
|
logConsoleInfo(`Successfully updated ${entityName} ${documentId.id()}`);
|
||||||
deferred.resolve(updatedDocument);
|
return updatedDocument;
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
handleError(error, `Failed to update ${entityName} ${documentId.id()}`, "UpdateDocument");
|
handleError(error, `Failed to update ${entityName} ${documentId.id()}`, "UpdateDocument");
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(clearMessage);
|
||||||
clearMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createDocument(collection: ViewModels.CollectionBase, newDocument: any): Q.Promise<any> {
|
export function createDocument(collection: ViewModels.CollectionBase, newDocument: any): Promise<any> {
|
||||||
var deferred = Q.defer<any>();
|
|
||||||
const entityName = getEntityName();
|
const entityName = getEntityName();
|
||||||
const clearMessage = logConsoleProgress(`Creating new ${entityName} for container ${collection.id()}`);
|
const clearMessage = logConsoleProgress(`Creating new ${entityName} for container ${collection.id()}`);
|
||||||
DataAccessUtilityBase.createDocument(collection, newDocument)
|
return DataAccessUtilityBase.createDocument(collection, newDocument)
|
||||||
.then(
|
.then(
|
||||||
(savedDocument: any) => {
|
(savedDocument: any) => {
|
||||||
logConsoleInfo(`Successfully created new ${entityName} for container ${collection.id()}`);
|
logConsoleInfo(`Successfully created new ${entityName} for container ${collection.id()}`);
|
||||||
deferred.resolve(savedDocument);
|
return savedDocument;
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
handleError(error, `Error while creating new ${entityName} for container ${collection.id()}`, "CreateDocument");
|
handleError(error, `Error while creating new ${entityName} for container ${collection.id()}`, "CreateDocument");
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(clearMessage);
|
||||||
clearMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Q.Promise<any> {
|
export function deleteDocument(collection: ViewModels.CollectionBase, documentId: DocumentId): Promise<any> {
|
||||||
var deferred = Q.defer<any>();
|
|
||||||
const entityName = getEntityName();
|
const entityName = getEntityName();
|
||||||
const clearMessage = logConsoleProgress(`Deleting ${entityName} ${documentId.id()}`);
|
const clearMessage = logConsoleProgress(`Deleting ${entityName} ${documentId.id()}`);
|
||||||
DataAccessUtilityBase.deleteDocument(collection, documentId)
|
return DataAccessUtilityBase.deleteDocument(collection, documentId)
|
||||||
.then(
|
.then(
|
||||||
(response: any) => {
|
(response: any) => {
|
||||||
logConsoleInfo(`Successfully deleted ${entityName} ${documentId.id()}`);
|
logConsoleInfo(`Successfully deleted ${entityName} ${documentId.id()}`);
|
||||||
deferred.resolve(response);
|
return response;
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
handleError(error, `Error while deleting ${entityName} ${documentId.id()}`, "DeleteDocument");
|
handleError(error, `Error while deleting ${entityName} ${documentId.id()}`, "DeleteDocument");
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(clearMessage);
|
||||||
clearMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteConflict(
|
export function deleteConflict(
|
||||||
collection: ViewModels.CollectionBase,
|
collection: ViewModels.CollectionBase,
|
||||||
conflictId: ConflictId,
|
conflictId: ConflictId,
|
||||||
options?: any
|
options?: any
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
var deferred = Q.defer<any>();
|
|
||||||
|
|
||||||
const clearMessage = logConsoleProgress(`Deleting conflict ${conflictId.id()}`);
|
const clearMessage = logConsoleProgress(`Deleting conflict ${conflictId.id()}`);
|
||||||
DataAccessUtilityBase.deleteConflict(collection, conflictId, options)
|
return DataAccessUtilityBase.deleteConflict(collection, conflictId, options)
|
||||||
.then(
|
.then(
|
||||||
(response: any) => {
|
(response: any) => {
|
||||||
logConsoleInfo(`Successfully deleted conflict ${conflictId.id()}`);
|
logConsoleInfo(`Successfully deleted conflict ${conflictId.id()}`);
|
||||||
deferred.resolve(response);
|
return response;
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
handleError(error, `Error while deleting conflict ${conflictId.id()}`, "DeleteConflict");
|
handleError(error, `Error while deleting conflict ${conflictId.id()}`, "DeleteConflict");
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(clearMessage);
|
||||||
clearMessage();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshCachedResources(options: any = {}): Q.Promise<void> {
|
export function refreshCachedResources(options: any = {}): Promise<void> {
|
||||||
return DataAccessUtilityBase.refreshCachedResources(options);
|
return DataAccessUtilityBase.refreshCachedResources(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshCachedOffers(): Q.Promise<void> {
|
export function refreshCachedOffers(): Promise<void> {
|
||||||
return DataAccessUtilityBase.refreshCachedOffers();
|
return DataAccessUtilityBase.refreshCachedOffers();
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ export class QueriesClient {
|
|||||||
return queryDocuments(SavedQueries.DatabaseName, SavedQueries.CollectionName, this.fetchQueriesQuery(), options)
|
return queryDocuments(SavedQueries.DatabaseName, SavedQueries.CollectionName, this.fetchQueriesQuery(), options)
|
||||||
.then(
|
.then(
|
||||||
(queryIterator: QueryIterator<ItemDefinition & Resource>) => {
|
(queryIterator: QueryIterator<ItemDefinition & Resource>) => {
|
||||||
const fetchQueries = (firstItemIndex: number): Q.Promise<ViewModels.QueryResults> =>
|
const fetchQueries = (firstItemIndex: number): Promise<ViewModels.QueryResults> =>
|
||||||
queryDocumentsPage(queriesCollection.id(), queryIterator, firstItemIndex, options);
|
queryDocumentsPage(queriesCollection.id(), queryIterator, firstItemIndex, options);
|
||||||
return QueryUtils.queryAllPages(fetchQueries).then(
|
return QueryUtils.queryAllPages(fetchQueries).then(
|
||||||
(results: ViewModels.QueryResults) => {
|
(results: ViewModels.QueryResults) => {
|
||||||
|
@ -5,7 +5,6 @@ import {
|
|||||||
TriggerDefinition,
|
TriggerDefinition,
|
||||||
UserDefinedFunctionDefinition
|
UserDefinedFunctionDefinition
|
||||||
} from "@azure/cosmos";
|
} from "@azure/cosmos";
|
||||||
import Q from "q";
|
|
||||||
import { CommandButtonComponentProps } from "../Explorer/Controls/CommandButton/CommandButtonComponent";
|
import { CommandButtonComponentProps } from "../Explorer/Controls/CommandButton/CommandButtonComponent";
|
||||||
import Explorer from "../Explorer/Explorer";
|
import Explorer from "../Explorer/Explorer";
|
||||||
import { ConsoleData } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
import { ConsoleData } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
@ -107,7 +106,7 @@ export interface CollectionBase extends TreeNode {
|
|||||||
|
|
||||||
onDocumentDBDocumentsClick(): void;
|
onDocumentDBDocumentsClick(): void;
|
||||||
onNewQueryClick(source: any, event: MouseEvent, queryText?: string): void;
|
onNewQueryClick(source: any, event: MouseEvent, queryText?: string): void;
|
||||||
expandCollection(): Q.Promise<any>;
|
expandCollection(): Promise<any>;
|
||||||
collapseCollection(): void;
|
collapseCollection(): void;
|
||||||
getDatabase(): Database;
|
getDatabase(): Database;
|
||||||
}
|
}
|
||||||
@ -172,7 +171,7 @@ export interface Collection extends CollectionBase {
|
|||||||
|
|
||||||
onDragOver(source: Collection, event: { originalEvent: DragEvent }): void;
|
onDragOver(source: Collection, event: { originalEvent: DragEvent }): void;
|
||||||
onDrop(source: Collection, event: { originalEvent: DragEvent }): void;
|
onDrop(source: Collection, event: { originalEvent: DragEvent }): void;
|
||||||
uploadFiles(fileList: FileList): Q.Promise<UploadDetails>;
|
uploadFiles(fileList: FileList): Promise<UploadDetails>;
|
||||||
|
|
||||||
getLabel(): string;
|
getLabel(): string;
|
||||||
}
|
}
|
||||||
@ -290,7 +289,7 @@ export interface DocumentsTabOptions extends TabOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface SettingsTabV2Options extends TabOptions {
|
export interface SettingsTabV2Options extends TabOptions {
|
||||||
getPendingNotification: Q.Promise<DataModels.Notification>;
|
getPendingNotification: Promise<DataModels.Notification>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConflictsTabOptions extends TabOptions {
|
export interface ConflictsTabOptions extends TabOptions {
|
||||||
|
@ -57,7 +57,7 @@ class EditorViewModel extends JsonEditorViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getErrorMarkers(input: string): Q.Promise<monaco.editor.IMarkerData[]> {
|
protected async getErrorMarkers(input: string): Promise<monaco.editor.IMarkerData[]> {
|
||||||
return ErrorMarkProvider.getErrorMark(input);
|
return ErrorMarkProvider.getErrorMark(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import Q from "q";
|
|
||||||
import * as monaco from "monaco-editor";
|
import * as monaco from "monaco-editor";
|
||||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { WaitsForTemplateViewModel } from "../../WaitsForTemplateViewModel";
|
import { WaitsForTemplateViewModel } from "../../WaitsForTemplateViewModel";
|
||||||
@ -107,8 +106,8 @@ export class JsonEditorViewModel extends WaitsForTemplateViewModel {
|
|||||||
protected registerCompletionItemProvider() {}
|
protected registerCompletionItemProvider() {}
|
||||||
|
|
||||||
// Interface. Will be implemented in children editor view model such as EditorViewModel.
|
// Interface. Will be implemented in children editor view model such as EditorViewModel.
|
||||||
protected getErrorMarkers(input: string): Q.Promise<monaco.editor.IMarkerData[]> {
|
protected getErrorMarkers(input: string): Promise<monaco.editor.IMarkerData[]> {
|
||||||
return Q.Promise(() => {});
|
return new Promise(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getEditorLanguage(): string {
|
protected getEditorLanguage(): string {
|
||||||
|
@ -31,7 +31,6 @@ jest.mock("../../../Common/dataAccess/updateCollection", () => ({
|
|||||||
}));
|
}));
|
||||||
import { updateOffer } from "../../../Common/dataAccess/updateOffer";
|
import { updateOffer } from "../../../Common/dataAccess/updateOffer";
|
||||||
import { MongoDBCollectionResource } from "../../../Utils/arm/generatedClients/2020-04-01/types";
|
import { MongoDBCollectionResource } from "../../../Utils/arm/generatedClients/2020-04-01/types";
|
||||||
import Q from "q";
|
|
||||||
jest.mock("../../../Common/dataAccess/updateOffer", () => ({
|
jest.mock("../../../Common/dataAccess/updateOffer", () => ({
|
||||||
updateOffer: jest.fn().mockReturnValue({} as DataModels.Offer)
|
updateOffer: jest.fn().mockReturnValue({} as DataModels.Offer)
|
||||||
}));
|
}));
|
||||||
@ -47,9 +46,7 @@ describe("SettingsComponent", () => {
|
|||||||
hashLocation: "settings",
|
hashLocation: "settings",
|
||||||
isActive: ko.observable(false),
|
isActive: ko.observable(false),
|
||||||
onUpdateTabsButtons: undefined,
|
onUpdateTabsButtons: undefined,
|
||||||
getPendingNotification: Q.Promise<DataModels.Notification>(() => {
|
getPendingNotification: Promise.resolve(undefined)
|
||||||
return;
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ jest.mock("../Graph/GraphExplorerComponent/GremlinClient");
|
|||||||
jest.mock("../../Common/dataAccess/createCollection");
|
jest.mock("../../Common/dataAccess/createCollection");
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import Q from "q";
|
|
||||||
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
||||||
import { createDocument } from "../../Common/DocumentClientUtilityBase";
|
import { createDocument } from "../../Common/DocumentClientUtilityBase";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
@ -21,7 +20,7 @@ describe("ContainerSampleGenerator", () => {
|
|||||||
explorerStub.canExceedMaximumValue = ko.computed<boolean>(() => false);
|
explorerStub.canExceedMaximumValue = ko.computed<boolean>(() => false);
|
||||||
explorerStub.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
|
explorerStub.hasAutoPilotV2FeatureFlag = ko.computed<boolean>(() => true);
|
||||||
explorerStub.findDatabaseWithId = () => database;
|
explorerStub.findDatabaseWithId = () => database;
|
||||||
explorerStub.refreshAllDatabases = () => Q.resolve();
|
explorerStub.refreshAllDatabases = () => Promise.resolve();
|
||||||
return explorerStub;
|
return explorerStub;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ export class ContainerSampleGenerator {
|
|||||||
if (!collection) {
|
if (!collection) {
|
||||||
throw new Error("No container to populate");
|
throw new Error("No container to populate");
|
||||||
}
|
}
|
||||||
const promises: Q.Promise<any>[] = [];
|
const promises: Promise<any>[] = [];
|
||||||
|
|
||||||
if (this.container.isPreferredApiGraph()) {
|
if (this.container.isPreferredApiGraph()) {
|
||||||
// For Gremlin, all queries are executed sequentially, because some queries might be dependent on other queries
|
// For Gremlin, all queries are executed sequentially, because some queries might be dependent on other queries
|
||||||
|
@ -217,7 +217,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
public shouldShowShareDialogContents: ko.Observable<boolean>;
|
public shouldShowShareDialogContents: ko.Observable<boolean>;
|
||||||
public shareAccessData: ko.Observable<AdHocAccessData>;
|
public shareAccessData: ko.Observable<AdHocAccessData>;
|
||||||
public renewExplorerShareAccess: (explorer: Explorer, token: string) => Q.Promise<void>;
|
public renewExplorerShareAccess: (explorer: Explorer, token: string) => Promise<void>;
|
||||||
public renewTokenError: ko.Observable<string>;
|
public renewTokenError: ko.Observable<string>;
|
||||||
public tokenForRenewal: ko.Observable<string>;
|
public tokenForRenewal: ko.Observable<string>;
|
||||||
public shareAccessToggleState: ko.Observable<ShareAccessToggleState>;
|
public shareAccessToggleState: ko.Observable<ShareAccessToggleState>;
|
||||||
@ -1120,7 +1120,7 @@ export default class Explorer {
|
|||||||
"Initiating connection to account"
|
"Initiating connection to account"
|
||||||
);
|
);
|
||||||
this.renewExplorerShareAccess(this, this.tokenForRenewal())
|
this.renewExplorerShareAccess(this, this.tokenForRenewal())
|
||||||
.fail((error: any) => {
|
.catch((error: any) => {
|
||||||
const stringifiedError: string = error.message;
|
const stringifiedError: string = error.message;
|
||||||
this.renewTokenError("Invalid connection string specified");
|
this.renewTokenError("Invalid connection string specified");
|
||||||
NotificationConsoleUtils.logConsoleMessage(
|
NotificationConsoleUtils.logConsoleMessage(
|
||||||
@ -1157,33 +1157,27 @@ export default class Explorer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public renewShareAccess(token: string): Q.Promise<void> {
|
public async renewShareAccess(token: string): Promise<void> {
|
||||||
if (!this.renewExplorerShareAccess) {
|
if (!this.renewExplorerShareAccess) {
|
||||||
return Q.reject("Not implemented");
|
throw "Not implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
const deferred: Q.Deferred<void> = Q.defer<void>();
|
|
||||||
const id: string = NotificationConsoleUtils.logConsoleMessage(
|
const id: string = NotificationConsoleUtils.logConsoleMessage(
|
||||||
ConsoleDataType.InProgress,
|
ConsoleDataType.InProgress,
|
||||||
"Initiating connection to account"
|
"Initiating connection to account"
|
||||||
);
|
);
|
||||||
this.renewExplorerShareAccess(this, token)
|
return this.renewExplorerShareAccess(this, token)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => {
|
||||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Info, "Connection successful");
|
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Info, "Connection successful");
|
||||||
this.renewAdHocAccessPane && this.renewAdHocAccessPane.close();
|
this.renewAdHocAccessPane && this.renewAdHocAccessPane.close();
|
||||||
deferred.resolve();
|
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, `Failed to connect: ${error.message}`);
|
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, `Failed to connect: ${error.message}`);
|
||||||
deferred.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => {
|
.finally(() => NotificationConsoleUtils.clearInProgressMessageWithId(id));
|
||||||
NotificationConsoleUtils.clearInProgressMessageWithId(id);
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public displayGuestAccessTokenRenewalPrompt(): void {
|
public displayGuestAccessTokenRenewalPrompt(): void {
|
||||||
@ -1378,24 +1372,19 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshDatabaseForResourceToken(): Q.Promise<any> {
|
public async refreshDatabaseForResourceToken(): Promise<any> {
|
||||||
const databaseId = this.resourceTokenDatabaseId();
|
const databaseId = this.resourceTokenDatabaseId();
|
||||||
const collectionId = this.resourceTokenCollectionId();
|
const collectionId = this.resourceTokenCollectionId();
|
||||||
if (!databaseId || !collectionId) {
|
if (!databaseId || !collectionId) {
|
||||||
return Q.reject();
|
throw new Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
const deferred: Q.Deferred<void> = Q.defer();
|
const collection = await readCollection(databaseId, collectionId);
|
||||||
readCollection(databaseId, collectionId).then((collection: DataModels.Collection) => {
|
|
||||||
this.resourceTokenCollection(new ResourceTokenCollection(this, databaseId, collection));
|
this.resourceTokenCollection(new ResourceTokenCollection(this, databaseId, collection));
|
||||||
this.selectedNode(this.resourceTokenCollection());
|
this.selectedNode(this.resourceTokenCollection());
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshAllDatabases(isInitialLoad?: boolean): Q.Promise<any> {
|
public refreshAllDatabases(isInitialLoad?: boolean): Promise<any> {
|
||||||
this.isRefreshingExplorer(true);
|
this.isRefreshingExplorer(true);
|
||||||
const startKey: number = TelemetryProcessor.traceStart(Action.LoadDatabases, {
|
const startKey: number = TelemetryProcessor.traceStart(Action.LoadDatabases, {
|
||||||
databaseAccountName: this.databaseAccount() && this.databaseAccount().name,
|
databaseAccountName: this.databaseAccount() && this.databaseAccount().name,
|
||||||
@ -1412,9 +1401,9 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Refactor
|
// TODO: Refactor
|
||||||
const deferred: Q.Deferred<any> = Q.defer();
|
|
||||||
this._setLoadingStatusText("Fetching databases...");
|
this._setLoadingStatusText("Fetching databases...");
|
||||||
readDatabases().then(
|
return readDatabases()
|
||||||
|
.then(
|
||||||
(databases: DataModels.Database[]) => {
|
(databases: DataModels.Database[]) => {
|
||||||
this._setLoadingStatusText("Successfully fetched databases.");
|
this._setLoadingStatusText("Successfully fetched databases.");
|
||||||
TelemetryProcessor.traceSuccess(
|
TelemetryProcessor.traceSuccess(
|
||||||
@ -1434,13 +1423,10 @@ export default class Explorer {
|
|||||||
this._setLoadingStatusText("Fetching containers...");
|
this._setLoadingStatusText("Fetching containers...");
|
||||||
this.refreshAndExpandNewDatabases(deltaDatabases.toAdd)
|
this.refreshAndExpandNewDatabases(deltaDatabases.toAdd)
|
||||||
.then(
|
.then(
|
||||||
() => {
|
() => this._setLoadingStatusText("Successfully fetched containers."),
|
||||||
this._setLoadingStatusText("Successfully fetched containers.");
|
|
||||||
deferred.resolve();
|
|
||||||
},
|
|
||||||
reason => {
|
reason => {
|
||||||
this._setLoadingStatusText("Failed to fetch containers.");
|
this._setLoadingStatusText("Failed to fetch containers.");
|
||||||
deferred.reject(reason);
|
throw reason;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.finally(() => this.isRefreshingExplorer(false));
|
.finally(() => this.isRefreshingExplorer(false));
|
||||||
@ -1448,7 +1434,6 @@ export default class Explorer {
|
|||||||
error => {
|
error => {
|
||||||
this._setLoadingStatusText("Failed to fetch databases.");
|
this._setLoadingStatusText("Failed to fetch databases.");
|
||||||
this.isRefreshingExplorer(false);
|
this.isRefreshingExplorer(false);
|
||||||
deferred.reject(error);
|
|
||||||
TelemetryProcessor.traceFailure(
|
TelemetryProcessor.traceFailure(
|
||||||
Action.LoadDatabases,
|
Action.LoadDatabases,
|
||||||
{
|
{
|
||||||
@ -1463,10 +1448,10 @@ export default class Explorer {
|
|||||||
ConsoleDataType.Error,
|
ConsoleDataType.Error,
|
||||||
`Error while refreshing databases: ${error.message}`
|
`Error while refreshing databases: ${error.message}`
|
||||||
);
|
);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
.then(
|
||||||
return deferred.promise.then(
|
|
||||||
() => {
|
() => {
|
||||||
if (resourceTreeStartKey != null) {
|
if (resourceTreeStartKey != null) {
|
||||||
TelemetryProcessor.traceSuccess(
|
TelemetryProcessor.traceSuccess(
|
||||||
@ -1794,7 +1779,7 @@ export default class Explorer {
|
|||||||
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
inputs.extensionEndpoint = configContext.PROXY_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initPromise: Q.Promise<void> = inputs ? this.initDataExplorerWithFrameInputs(inputs) : Q();
|
const initPromise: Promise<void> = inputs ? this.initDataExplorerWithFrameInputs(inputs) : Promise.resolve();
|
||||||
|
|
||||||
initPromise.then(() => {
|
initPromise.then(() => {
|
||||||
const openAction: ActionContracts.DataExplorerAction = message.openAction;
|
const openAction: ActionContracts.DataExplorerAction = message.openAction;
|
||||||
@ -1888,7 +1873,7 @@ export default class Explorer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDataExplorerWithFrameInputs(inputs: ViewModels.DataExplorerInputsFrame): Q.Promise<void> {
|
public async initDataExplorerWithFrameInputs(inputs: ViewModels.DataExplorerInputsFrame): Promise<void> {
|
||||||
if (inputs != null) {
|
if (inputs != null) {
|
||||||
const authorizationToken = inputs.authorizationToken || "";
|
const authorizationToken = inputs.authorizationToken || "";
|
||||||
const masterKey = inputs.masterKey || "";
|
const masterKey = inputs.masterKey || "";
|
||||||
@ -1938,7 +1923,6 @@ export default class Explorer {
|
|||||||
|
|
||||||
this.isAccountReady(true);
|
this.isAccountReady(true);
|
||||||
}
|
}
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setFeatureFlagsFromFlights(flights: readonly string[]): void {
|
public setFeatureFlagsFromFlights(flights: readonly string[]): void {
|
||||||
@ -2056,7 +2040,7 @@ export default class Explorer {
|
|||||||
// we reload collections for all databases so the resource tree reflects any collection-level changes
|
// we reload collections for all databases so the resource tree reflects any collection-level changes
|
||||||
// i.e addition of stored procedures, etc.
|
// i.e addition of stored procedures, etc.
|
||||||
const deferred: Q.Deferred<void> = Q.defer<void>();
|
const deferred: Q.Deferred<void> = Q.defer<void>();
|
||||||
let loadCollectionPromises: Q.Promise<void>[] = [];
|
let loadCollectionPromises: Promise<void>[] = [];
|
||||||
|
|
||||||
// If the user has a lot of databases, only load expanded databases.
|
// If the user has a lot of databases, only load expanded databases.
|
||||||
const databasesToLoad =
|
const databasesToLoad =
|
||||||
@ -2440,7 +2424,7 @@ export default class Explorer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public renameNotebook(notebookFile: NotebookContentItem): Q.Promise<NotebookContentItem> {
|
public async renameNotebook(notebookFile: NotebookContentItem): Promise<NotebookContentItem> {
|
||||||
if (!this.isNotebookEnabled() || !this.notebookManager?.notebookContentClient) {
|
if (!this.isNotebookEnabled() || !this.notebookManager?.notebookContentClient) {
|
||||||
const error = "Attempt to rename notebook, but notebook is not enabled";
|
const error = "Attempt to rename notebook, but notebook is not enabled";
|
||||||
Logger.logError(error, "Explorer/renameNotebook");
|
Logger.logError(error, "Explorer/renameNotebook");
|
||||||
@ -2457,12 +2441,11 @@ export default class Explorer {
|
|||||||
);
|
);
|
||||||
if (openedNotebookTabs.length > 0) {
|
if (openedNotebookTabs.length > 0) {
|
||||||
this.showOkModalDialog("Unable to rename file", "This file is being edited. Please close the tab and try again.");
|
this.showOkModalDialog("Unable to rename file", "This file is being edited. Please close the tab and try again.");
|
||||||
return Q.reject();
|
throw new Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
const originalPath = notebookFile.path;
|
const originalPath = notebookFile.path;
|
||||||
const result = this.stringInputPane
|
const newNotebookFile = await this.stringInputPane.openWithOptions<NotebookContentItem>({
|
||||||
.openWithOptions<NotebookContentItem>({
|
|
||||||
errorMessage: "Could not rename notebook",
|
errorMessage: "Could not rename notebook",
|
||||||
inProgressMessage: "Renaming notebook to",
|
inProgressMessage: "Renaming notebook to",
|
||||||
successMessage: "Renamed notebook to",
|
successMessage: "Renamed notebook to",
|
||||||
@ -2471,8 +2454,7 @@ export default class Explorer {
|
|||||||
submitButtonLabel: "Rename",
|
submitButtonLabel: "Rename",
|
||||||
defaultInput: FileSystemUtil.stripExtension(notebookFile.name, "ipynb"),
|
defaultInput: FileSystemUtil.stripExtension(notebookFile.name, "ipynb"),
|
||||||
onSubmit: (input: string) => this.notebookManager?.notebookContentClient.renameNotebook(notebookFile, input)
|
onSubmit: (input: string) => this.notebookManager?.notebookContentClient.renameNotebook(notebookFile, input)
|
||||||
})
|
});
|
||||||
.then(newNotebookFile => {
|
|
||||||
const notebookTabs = this.tabsManager.getTabs(
|
const notebookTabs = this.tabsManager.getTabs(
|
||||||
ViewModels.CollectionTabKind.NotebookV2,
|
ViewModels.CollectionTabKind.NotebookV2,
|
||||||
(tab: NotebookV2Tab) => tab.notebookPath && FileSystemUtil.isPathEqual(tab.notebookPath(), originalPath)
|
(tab: NotebookV2Tab) => tab.notebookPath && FileSystemUtil.isPathEqual(tab.notebookPath(), originalPath)
|
||||||
@ -2483,13 +2465,11 @@ export default class Explorer {
|
|||||||
(tab as NotebookV2Tab).notebookPath(newNotebookFile.path);
|
(tab as NotebookV2Tab).notebookPath(newNotebookFile.path);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.resourceTree.triggerRender();
|
||||||
return newNotebookFile;
|
return newNotebookFile;
|
||||||
});
|
|
||||||
result.then(() => this.resourceTree.triggerRender());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCreateDirectory(parent: NotebookContentItem): Q.Promise<NotebookContentItem> {
|
public async onCreateDirectory(parent: NotebookContentItem): Promise<NotebookContentItem> {
|
||||||
if (!this.isNotebookEnabled() || !this.notebookManager?.notebookContentClient) {
|
if (!this.isNotebookEnabled() || !this.notebookManager?.notebookContentClient) {
|
||||||
const error = "Attempt to create notebook directory, but notebook is not enabled";
|
const error = "Attempt to create notebook directory, but notebook is not enabled";
|
||||||
Logger.logError(error, "Explorer/onCreateDirectory");
|
Logger.logError(error, "Explorer/onCreateDirectory");
|
||||||
@ -2497,7 +2477,7 @@ export default class Explorer {
|
|||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = this.stringInputPane.openWithOptions<NotebookContentItem>({
|
const result = await this.stringInputPane.openWithOptions<NotebookContentItem>({
|
||||||
errorMessage: "Could not create directory ",
|
errorMessage: "Could not create directory ",
|
||||||
inProgressMessage: "Creating directory ",
|
inProgressMessage: "Creating directory ",
|
||||||
successMessage: "Created directory ",
|
successMessage: "Created directory ",
|
||||||
@ -2507,7 +2487,7 @@ export default class Explorer {
|
|||||||
defaultInput: "",
|
defaultInput: "",
|
||||||
onSubmit: (input: string) => this.notebookManager?.notebookContentClient.createDirectory(parent, input)
|
onSubmit: (input: string) => this.notebookManager?.notebookContentClient.createDirectory(parent, input)
|
||||||
});
|
});
|
||||||
result.then(() => this.resourceTree.triggerRender());
|
this.resourceTree.triggerRender();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,8 +378,7 @@ export class D3ForceGraph implements GraphRenderer {
|
|||||||
* @param targetPosition
|
* @param targetPosition
|
||||||
* @return promise with shift offset
|
* @return promise with shift offset
|
||||||
*/
|
*/
|
||||||
private shiftGraph(targetPosition: Point2D): Q.Promise<Point2D> {
|
private async shiftGraph(targetPosition: Point2D): Promise<Point2D> {
|
||||||
const deferred: Q.Deferred<Point2D> = Q.defer<Point2D>();
|
|
||||||
const offset = { x: this.width / 2 - targetPosition.x, y: this.height / 2 - targetPosition.y };
|
const offset = { x: this.width / 2 - targetPosition.x, y: this.height / 2 - targetPosition.y };
|
||||||
this.viewCenter = targetPosition;
|
this.viewCenter = targetPosition;
|
||||||
|
|
||||||
@ -391,18 +390,15 @@ export class D3ForceGraph implements GraphRenderer {
|
|||||||
.translate(-targetPosition.x, -targetPosition.y);
|
.translate(-targetPosition.x, -targetPosition.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.zoomBackground
|
const transition = this.zoomBackground
|
||||||
.transition()
|
.transition()
|
||||||
.duration(D3ForceGraph.TRANSITION_STEP1_MS)
|
.duration(D3ForceGraph.TRANSITION_STEP1_MS)
|
||||||
.call(this.zoom.transform, transform)
|
.call(this.zoom.transform, transform);
|
||||||
.on("end", () => {
|
|
||||||
deferred.resolve(offset);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
deferred.resolve(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deferred.promise;
|
await new Promise(resolve => transition.on("end", resolve));
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onGraphDataUpdate(graph: GraphData<D3Node, D3Link>) {
|
private onGraphDataUpdate(graph: GraphData<D3Node, D3Link>) {
|
||||||
@ -435,7 +431,7 @@ export class D3ForceGraph implements GraphRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private animateRemoveExitSelections(): Q.Promise<void> {
|
private animateRemoveExitSelections(): Promise<void> {
|
||||||
const deferred1 = Q.defer<void>();
|
const deferred1 = Q.defer<void>();
|
||||||
const deferred2 = Q.defer<void>();
|
const deferred2 = Q.defer<void>();
|
||||||
const linkExitSelection = this.linkSelection.exit();
|
const linkExitSelection = this.linkSelection.exit();
|
||||||
@ -508,7 +504,7 @@ export class D3ForceGraph implements GraphRenderer {
|
|||||||
deferred2.resolve();
|
deferred2.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q.allSettled([deferred1.promise, deferred2.promise]).then(undefined);
|
return Promise.all([deferred1.promise, deferred2.promise]).then(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { mount, ReactWrapper } from "enzyme";
|
import { mount, ReactWrapper } from "enzyme";
|
||||||
import * as Q from "q";
|
|
||||||
import { NodePropertiesComponent, NodePropertiesComponentProps, Mode } from "./NodePropertiesComponent";
|
import { NodePropertiesComponent, NodePropertiesComponentProps, Mode } from "./NodePropertiesComponent";
|
||||||
import { GraphHighlightedNodeData, EditedProperties, EditedEdges, PossibleVertex } from "./GraphExplorer";
|
import { GraphHighlightedNodeData, EditedProperties, EditedEdges, PossibleVertex } from "./GraphExplorer";
|
||||||
|
|
||||||
@ -41,11 +40,11 @@ describe("Property pane", () => {
|
|||||||
node: highlightedNode,
|
node: highlightedNode,
|
||||||
getPkIdFromNodeData: (v: GraphHighlightedNodeData): string => null,
|
getPkIdFromNodeData: (v: GraphHighlightedNodeData): string => null,
|
||||||
collectionPartitionKeyProperty: null,
|
collectionPartitionKeyProperty: null,
|
||||||
updateVertexProperties: (editedProperties: EditedProperties): Q.Promise<void> => Q.resolve(),
|
updateVertexProperties: (editedProperties: EditedProperties): Promise<void> => Promise.resolve(),
|
||||||
selectNode: (id: string): void => {},
|
selectNode: (id: string): void => {},
|
||||||
updatePossibleVertices: (): Q.Promise<PossibleVertex[]> => Q.resolve(null),
|
updatePossibleVertices: async (): Promise<PossibleVertex[]> => null,
|
||||||
possibleEdgeLabels: null,
|
possibleEdgeLabels: null,
|
||||||
editGraphEdges: (editedEdges: EditedEdges): Q.Promise<any> => Q.resolve(),
|
editGraphEdges: async (editedEdges: EditedEdges): Promise<any> => undefined,
|
||||||
deleteHighlightedNode: (): void => {},
|
deleteHighlightedNode: (): void => {},
|
||||||
onModeChanged: (newMode: Mode): void => {},
|
onModeChanged: (newMode: Mode): void => {},
|
||||||
viewMode: Mode.READONLY_PROP
|
viewMode: Mode.READONLY_PROP
|
||||||
|
@ -36,11 +36,11 @@ export interface NodePropertiesComponentProps {
|
|||||||
node: GraphHighlightedNodeData;
|
node: GraphHighlightedNodeData;
|
||||||
getPkIdFromNodeData: (v: GraphHighlightedNodeData) => string;
|
getPkIdFromNodeData: (v: GraphHighlightedNodeData) => string;
|
||||||
collectionPartitionKeyProperty: string;
|
collectionPartitionKeyProperty: string;
|
||||||
updateVertexProperties: (editedProperties: EditedProperties) => Q.Promise<void>;
|
updateVertexProperties: (editedProperties: EditedProperties) => Promise<void>;
|
||||||
selectNode: (id: string) => void;
|
selectNode: (id: string) => void;
|
||||||
updatePossibleVertices: () => Q.Promise<PossibleVertex[]>;
|
updatePossibleVertices: () => Promise<PossibleVertex[]>;
|
||||||
possibleEdgeLabels: Item[];
|
possibleEdgeLabels: Item[];
|
||||||
editGraphEdges: (editedEdges: EditedEdges) => Q.Promise<any>;
|
editGraphEdges: (editedEdges: EditedEdges) => Promise<any>;
|
||||||
deleteHighlightedNode: () => void;
|
deleteHighlightedNode: () => void;
|
||||||
onModeChanged: (newMode: Mode) => void;
|
onModeChanged: (newMode: Mode) => void;
|
||||||
viewMode: Mode; // If viewMode is specified in parent, keep state in sync with it
|
viewMode: Mode; // If viewMode is specified in parent, keep state in sync with it
|
||||||
|
@ -350,7 +350,7 @@ export default class CassandraAddCollectionPane extends ContextualPaneBase {
|
|||||||
}
|
}
|
||||||
this.isExecuting(true);
|
this.isExecuting(true);
|
||||||
const autoPilotCommand = `cosmosdb_autoscale_max_throughput`;
|
const autoPilotCommand = `cosmosdb_autoscale_max_throughput`;
|
||||||
let createTableAndKeyspacePromise: Q.Promise<any>;
|
let createTableAndKeyspacePromise: Promise<any>;
|
||||||
const toCreateKeyspace: boolean = this.keyspaceCreateNew();
|
const toCreateKeyspace: boolean = this.keyspaceCreateNew();
|
||||||
const useAutoPilotForKeyspace: boolean =
|
const useAutoPilotForKeyspace: boolean =
|
||||||
(!this.hasAutoPilotV2FeatureFlag() && this.isSharedAutoPilotSelected() && !!this.sharedAutoPilotThroughput()) ||
|
(!this.hasAutoPilotV2FeatureFlag() && this.isSharedAutoPilotSelected() && !!this.sharedAutoPilotThroughput()) ||
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
jest.mock("../../Common/dataAccess/deleteCollection");
|
jest.mock("../../Common/dataAccess/deleteCollection");
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
import Q from "q";
|
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
@ -58,7 +57,7 @@ describe("Delete Collection Confirmation Pane", () => {
|
|||||||
it("should return true if last collection and database does not have shared throughput else false", () => {
|
it("should return true if last collection and database does not have shared throughput else false", () => {
|
||||||
let fakeExplorer = new Explorer();
|
let fakeExplorer = new Explorer();
|
||||||
fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false);
|
fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false);
|
||||||
fakeExplorer.refreshAllDatabases = () => Q.resolve();
|
fakeExplorer.refreshAllDatabases = () => Promise.resolve();
|
||||||
|
|
||||||
let pane = new DeleteCollectionConfirmationPane({
|
let pane = new DeleteCollectionConfirmationPane({
|
||||||
id: "deletecollectionconfirmationpane",
|
id: "deletecollectionconfirmationpane",
|
||||||
@ -119,7 +118,7 @@ describe("Delete Collection Confirmation Pane", () => {
|
|||||||
fakeExplorer.selectedNode = ko.observable<TreeNode>();
|
fakeExplorer.selectedNode = ko.observable<TreeNode>();
|
||||||
fakeExplorer.isLastCollection = () => true;
|
fakeExplorer.isLastCollection = () => true;
|
||||||
fakeExplorer.isSelectedDatabaseShared = () => false;
|
fakeExplorer.isSelectedDatabaseShared = () => false;
|
||||||
fakeExplorer.refreshAllDatabases = () => Q.resolve();
|
fakeExplorer.refreshAllDatabases = () => Promise.resolve();
|
||||||
|
|
||||||
let pane = new DeleteCollectionConfirmationPane({
|
let pane = new DeleteCollectionConfirmationPane({
|
||||||
id: "deletecollectionconfirmationpane",
|
id: "deletecollectionconfirmationpane",
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
jest.mock("../../Common/dataAccess/deleteDatabase");
|
jest.mock("../../Common/dataAccess/deleteDatabase");
|
||||||
jest.mock("../../Shared/Telemetry/TelemetryProcessor");
|
jest.mock("../../Shared/Telemetry/TelemetryProcessor");
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
@ -91,7 +90,7 @@ describe("Delete Database Confirmation Pane", () => {
|
|||||||
collections: ko.observableArray<ViewModels.Collection>()
|
collections: ko.observableArray<ViewModels.Collection>()
|
||||||
} as ViewModels.Database;
|
} as ViewModels.Database;
|
||||||
};
|
};
|
||||||
fakeExplorer.refreshAllDatabases = () => Q.resolve();
|
fakeExplorer.refreshAllDatabases = () => Promise.resolve();
|
||||||
fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false);
|
fakeExplorer.isNotificationConsoleExpanded = ko.observable<boolean>(false);
|
||||||
fakeExplorer.selectedDatabaseId = ko.computed<string>(() => selectedDatabaseId);
|
fakeExplorer.selectedDatabaseId = ko.computed<string>(() => selectedDatabaseId);
|
||||||
fakeExplorer.isSelectedDatabaseShared = () => false;
|
fakeExplorer.isSelectedDatabaseShared = () => false;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
@ -31,7 +30,7 @@ export default class DeleteDatabaseConfirmationPane extends ContextualPaneBase {
|
|||||||
this.resetData();
|
this.resetData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public submit(): Q.Promise<any> {
|
public async submit(): Promise<any> {
|
||||||
if (!this._isValid()) {
|
if (!this._isValid()) {
|
||||||
const selectedDatabase: ViewModels.Database = this.container.findSelectedDatabase();
|
const selectedDatabase: ViewModels.Database = this.container.findSelectedDatabase();
|
||||||
this.formErrors("Input database name does not match the selected database");
|
this.formErrors("Input database name does not match the selected database");
|
||||||
@ -39,7 +38,7 @@ export default class DeleteDatabaseConfirmationPane extends ContextualPaneBase {
|
|||||||
ConsoleDataType.Error,
|
ConsoleDataType.Error,
|
||||||
`Error while deleting collection ${selectedDatabase && selectedDatabase.id()}: ${this.formErrors()}`
|
`Error while deleting collection ${selectedDatabase && selectedDatabase.id()}: ${this.formErrors()}`
|
||||||
);
|
);
|
||||||
return Q.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.formErrors("");
|
this.formErrors("");
|
||||||
@ -53,7 +52,7 @@ export default class DeleteDatabaseConfirmationPane extends ContextualPaneBase {
|
|||||||
paneTitle: this.title()
|
paneTitle: this.title()
|
||||||
});
|
});
|
||||||
// TODO: Should not be a Q promise anymore, but the Cassandra code requires it
|
// TODO: Should not be a Q promise anymore, but the Cassandra code requires it
|
||||||
let promise: Q.Promise<any>;
|
let promise: Promise<any>;
|
||||||
if (this.container.isPreferredApiCassandra()) {
|
if (this.container.isPreferredApiCassandra()) {
|
||||||
promise = (<CassandraAPIDataClient>this.container.tableDataClient).deleteTableOrKeyspace(
|
promise = (<CassandraAPIDataClient>this.container.tableDataClient).deleteTableOrKeyspace(
|
||||||
this.container.databaseAccount().properties.cassandraEndpoint,
|
this.container.databaseAccount().properties.cassandraEndpoint,
|
||||||
@ -62,7 +61,7 @@ export default class DeleteDatabaseConfirmationPane extends ContextualPaneBase {
|
|||||||
this.container
|
this.container
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
promise = Q(deleteDatabase(selectedDatabase.id()));
|
promise = deleteDatabase(selectedDatabase.id());
|
||||||
}
|
}
|
||||||
return promise.then(
|
return promise.then(
|
||||||
() => {
|
() => {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as Q from "q";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||||
@ -97,33 +96,30 @@ export class LoadQueryPane extends ContextualPaneBase {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
public loadQueryFromFile(file: File): Q.Promise<void> {
|
public async loadQueryFromFile(file: File): Promise<void> {
|
||||||
const selectedCollection: ViewModels.Collection = this.container && this.container.findSelectedCollection();
|
const selectedCollection: ViewModels.Collection = this.container && this.container.findSelectedCollection();
|
||||||
if (!selectedCollection) {
|
if (!selectedCollection) {
|
||||||
// should never get into this state
|
// should never get into this state
|
||||||
Logger.logError("No collection was selected", "LoadQueryPane.loadQueryFromFile");
|
Logger.logError("No collection was selected", "LoadQueryPane.loadQueryFromFile");
|
||||||
return Q.reject("No collection was selected");
|
throw new Error("No collection was selected");
|
||||||
} else if (this.container.isPreferredApiMongoDB()) {
|
} else if (this.container.isPreferredApiMongoDB()) {
|
||||||
selectedCollection.onNewMongoQueryClick(selectedCollection, null);
|
selectedCollection.onNewMongoQueryClick(selectedCollection, null);
|
||||||
} else {
|
} else {
|
||||||
selectedCollection.onNewQueryClick(selectedCollection, null);
|
selectedCollection.onNewQueryClick(selectedCollection, null);
|
||||||
}
|
}
|
||||||
const deferred: Q.Deferred<void> = Q.defer<void>();
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (evt: any): void => {
|
reader.onload = (evt: any): void => {
|
||||||
const fileData: string = evt.target.result;
|
const fileData: string = evt.target.result;
|
||||||
const queryTab = this.container.tabsManager.activeTab() as QueryTab;
|
const queryTab = this.container.tabsManager.activeTab() as QueryTab;
|
||||||
queryTab.initialEditorContent(fileData);
|
queryTab.initialEditorContent(fileData);
|
||||||
queryTab.sqlQueryEditorContent(fileData);
|
queryTab.sqlQueryEditorContent(fileData);
|
||||||
deferred.resolve();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
reader.onerror = (evt: ProgressEvent): void => {
|
reader.onerror = (evt: ProgressEvent): void => {
|
||||||
deferred.reject((evt as any).error.message);
|
throw new Error((evt as any).error.message);
|
||||||
};
|
};
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateSelectedFilesTitle(fileList: FileList) {
|
private updateSelectedFilesTitle(fileList: FileList) {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import _ from "underscore";
|
import _ from "underscore";
|
||||||
import Q from "q";
|
|
||||||
|
|
||||||
import * as Entities from "../Entities";
|
import * as Entities from "../Entities";
|
||||||
import * as QueryBuilderConstants from "../Constants";
|
import * as QueryBuilderConstants from "../Constants";
|
||||||
@ -84,11 +83,11 @@ export function filterColumns(table: DataTables.DataTable, settings: boolean[]):
|
|||||||
* Reorder columns based on current order.
|
* Reorder columns based on current order.
|
||||||
* If no current order is specified, reorder the columns based on intial order.
|
* If no current order is specified, reorder the columns based on intial order.
|
||||||
*/
|
*/
|
||||||
export function reorderColumns(
|
export async function reorderColumns(
|
||||||
table: DataTables.DataTable,
|
table: DataTables.DataTable,
|
||||||
targetOrder: number[],
|
targetOrder: number[],
|
||||||
currentOrder?: number[]
|
currentOrder?: number[]
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
var columnsCount: number = targetOrder.length;
|
var columnsCount: number = targetOrder.length;
|
||||||
var isCurrentOrderPassedIn: boolean = !!currentOrder;
|
var isCurrentOrderPassedIn: boolean = !!currentOrder;
|
||||||
if (!isCurrentOrderPassedIn) {
|
if (!isCurrentOrderPassedIn) {
|
||||||
@ -107,13 +106,9 @@ export function reorderColumns(
|
|||||||
var transformationOrder: number[] = isCurrentOrderPassedIn
|
var transformationOrder: number[] = isCurrentOrderPassedIn
|
||||||
? calculateTransformationOrder(currentOrder, targetOrder)
|
? calculateTransformationOrder(currentOrder, targetOrder)
|
||||||
: targetOrder;
|
: targetOrder;
|
||||||
try {
|
|
||||||
$.fn.dataTable.ColReorder(table).fnOrder(transformationOrder);
|
$.fn.dataTable.ColReorder(table).fnOrder(transformationOrder);
|
||||||
} catch (err) {
|
|
||||||
return Q.reject(err);
|
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
return Q.resolve(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resetColumns(table: DataTables.DataTable): void {
|
export function resetColumns(table: DataTables.DataTable): void {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import _ from "underscore";
|
import _ from "underscore";
|
||||||
import Q from "q";
|
|
||||||
import * as DataTableUtilities from "./DataTableUtilities";
|
import * as DataTableUtilities from "./DataTableUtilities";
|
||||||
import * as DataTableOperations from "./DataTableOperations";
|
import * as DataTableOperations from "./DataTableOperations";
|
||||||
import TableEntityListViewModel from "./TableEntityListViewModel";
|
import TableEntityListViewModel from "./TableEntityListViewModel";
|
||||||
@ -49,7 +48,7 @@ export default class TableCommands {
|
|||||||
/**
|
/**
|
||||||
* Edit entity
|
* Edit entity
|
||||||
*/
|
*/
|
||||||
public editEntityCommand(viewModel: TableEntityListViewModel): Q.Promise<any> {
|
public editEntityCommand(viewModel: TableEntityListViewModel): Promise<any> {
|
||||||
if (!viewModel) {
|
if (!viewModel) {
|
||||||
return null; // Error
|
return null; // Error
|
||||||
}
|
}
|
||||||
@ -68,7 +67,7 @@ export default class TableCommands {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteEntitiesCommand(viewModel: TableEntityListViewModel): Q.Promise<any> {
|
public deleteEntitiesCommand(viewModel: TableEntityListViewModel): Promise<any> {
|
||||||
if (!viewModel) {
|
if (!viewModel) {
|
||||||
return null; // Error
|
return null; // Error
|
||||||
}
|
}
|
||||||
@ -92,7 +91,7 @@ export default class TableCommands {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public customizeColumnsCommand(viewModel: TableEntityListViewModel): Q.Promise<any> {
|
public customizeColumnsCommand(viewModel: TableEntityListViewModel): Promise<any> {
|
||||||
var table: DataTables.DataTable = viewModel.table;
|
var table: DataTables.DataTable = viewModel.table;
|
||||||
var displayedColumnNames: string[] = DataTableOperations.getDataTableHeaders(table);
|
var displayedColumnNames: string[] = DataTableOperations.getDataTableHeaders(table);
|
||||||
var columnsCount: number = displayedColumnNames.length;
|
var columnsCount: number = displayedColumnNames.length;
|
||||||
@ -120,7 +119,7 @@ export default class TableCommands {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public reorderColumnsBasedOnSelectedEntities(viewModel: TableEntityListViewModel): Q.Promise<boolean> {
|
public reorderColumnsBasedOnSelectedEntities(viewModel: TableEntityListViewModel): Promise<boolean> {
|
||||||
var selected = viewModel.selected();
|
var selected = viewModel.selected();
|
||||||
if (!selected || !selected.length) {
|
if (!selected || !selected.length) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import Q from "q";
|
|
||||||
import * as Entities from "./Entities";
|
import * as Entities from "./Entities";
|
||||||
import { CassandraTableKey } from "./TableDataClient";
|
import { CassandraTableKey } from "./TableDataClient";
|
||||||
import * as Constants from "./Constants";
|
import * as Constants from "./Constants";
|
||||||
@ -19,8 +18,8 @@ export function guid() {
|
|||||||
/**
|
/**
|
||||||
* Returns a promise that resolves in the specified number of milliseconds.
|
* Returns a promise that resolves in the specified number of milliseconds.
|
||||||
*/
|
*/
|
||||||
export function delay(milliseconds: number): Q.Promise<any> {
|
export function delay(milliseconds: number): Promise<any> {
|
||||||
return Q.delay(milliseconds);
|
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
@ -225,7 +224,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshDocumentsGrid(): Q.Promise<any> {
|
public refreshDocumentsGrid(): Promise<any> {
|
||||||
// clear documents grid
|
// clear documents grid
|
||||||
this.conflictIds([]);
|
this.conflictIds([]);
|
||||||
return this.createIterator()
|
return this.createIterator()
|
||||||
@ -256,19 +255,17 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onConflictIdClick(clickedDocumentId: ConflictId): Q.Promise<any> {
|
public async onConflictIdClick(clickedDocumentId: ConflictId): Promise<any> {
|
||||||
if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) {
|
if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) {
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onAcceptChangesClick = (): Q.Promise<any> => {
|
public onAcceptChangesClick = async (): Promise<any> => {
|
||||||
if (this.isEditorDirty() && !this._isIgnoreDirtyEditor()) {
|
if (this.isEditorDirty() && !this._isIgnoreDirtyEditor()) {
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
@ -286,7 +283,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
conflictResourceId: selectedConflict.resourceId
|
conflictResourceId: selectedConflict.resourceId
|
||||||
});
|
});
|
||||||
|
|
||||||
let operationPromise: Q.Promise<any> = Q();
|
let operationPromise: Promise<any>;
|
||||||
if (selectedConflict.operationType === Constants.ConflictOperationType.Replace) {
|
if (selectedConflict.operationType === Constants.ConflictOperationType.Replace) {
|
||||||
const documentContent = JSON.parse(this.selectedConflictContent());
|
const documentContent = JSON.parse(this.selectedConflictContent());
|
||||||
|
|
||||||
@ -358,7 +355,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
.finally(() => this.isExecuting(false));
|
.finally(() => this.isExecuting(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
public onDeleteClick = (): Q.Promise<any> => {
|
public onDeleteClick = (): Promise<any> => {
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
this.isExecuting(true);
|
this.isExecuting(true);
|
||||||
|
|
||||||
@ -418,40 +415,34 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
.finally(() => this.isExecuting(false));
|
.finally(() => this.isExecuting(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
public onDiscardClick = (): Q.Promise<any> => {
|
public onDiscardClick = async (): Promise<any> => {
|
||||||
this.selectedConflictContent(this.selectedConflictContent.getEditableOriginalValue());
|
this.selectedConflictContent(this.selectedConflictContent.getEditableOriginalValue());
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onValidDocumentEdit(): Q.Promise<any> {
|
public async onValidDocumentEdit(): Promise<any> {
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onInvalidDocumentEdit(): Q.Promise<any> {
|
public async onInvalidDocumentEdit(): Promise<any> {
|
||||||
if (
|
if (
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits ||
|
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentNoEdits ||
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
|
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
|
||||||
) {
|
) {
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid);
|
||||||
return Q();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
public onTabClick(): Promise<any> {
|
||||||
}
|
|
||||||
|
|
||||||
public onTabClick(): Q.Promise<any> {
|
|
||||||
return super.onTabClick().then(() => {
|
return super.onTabClick().then(() => {
|
||||||
this.collection && this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Conflicts);
|
this.collection && this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Conflicts);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onActivate(): Q.Promise<any> {
|
public onActivate(): Promise<any> {
|
||||||
return super.onActivate().then(() => {
|
return super.onActivate().then(() => {
|
||||||
if (this._documentsIterator) {
|
if (this._documentsIterator) {
|
||||||
return Q.resolve(this._documentsIterator);
|
return this._documentsIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.createIterator().then(
|
return this.createIterator().then(
|
||||||
@ -481,7 +472,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onRefreshClick(): Q.Promise<any> {
|
public onRefreshClick(): Promise<any> {
|
||||||
return this.refreshDocumentsGrid().then(() => {
|
return this.refreshDocumentsGrid().then(() => {
|
||||||
this.selectedConflictContent("");
|
this.selectedConflictContent("");
|
||||||
this.selectedConflictId(null);
|
this.selectedConflictId(null);
|
||||||
@ -489,7 +480,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public createIterator(): Q.Promise<QueryIterator<ConflictDefinition & Resource>> {
|
public createIterator(): Promise<QueryIterator<ConflictDefinition & Resource>> {
|
||||||
// TODO: Conflict Feed does not allow filtering atm
|
// TODO: Conflict Feed does not allow filtering atm
|
||||||
const query: string = undefined;
|
const query: string = undefined;
|
||||||
let options: any = {};
|
let options: any = {};
|
||||||
@ -497,7 +488,7 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
return queryConflicts(this.collection.databaseId, this.collection.id(), query, options);
|
return queryConflicts(this.collection.databaseId, this.collection.id(), query, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadNextPage(): Q.Promise<any> {
|
public loadNextPage(): Promise<any> {
|
||||||
this.isExecuting(true);
|
this.isExecuting(true);
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
return this._loadNextPageInternal()
|
return this._loadNextPageInternal()
|
||||||
@ -564,8 +555,8 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected _loadNextPageInternal(): Q.Promise<DataModels.ConflictId[]> {
|
protected _loadNextPageInternal(): Promise<DataModels.ConflictId[]> {
|
||||||
return Q(this._documentsIterator.fetchNext().then(response => response.resources));
|
return this._documentsIterator.fetchNext().then(response => response.resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _onEditorContentChange(newContent: string) {
|
protected _onEditorContentChange(newContent: string) {
|
||||||
@ -577,22 +568,20 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDocumentEditorForCreate(documentId: ConflictId, documentToInsert: any): Q.Promise<any> {
|
public async initDocumentEditorForCreate(documentId: ConflictId, documentToInsert: any): Promise<any> {
|
||||||
if (documentId) {
|
if (documentId) {
|
||||||
let parsedConflictContent: any = JSON.parse(documentToInsert);
|
let parsedConflictContent: any = JSON.parse(documentToInsert);
|
||||||
const renderedConflictContent: string = this.renderObjectForEditor(parsedConflictContent, null, 4);
|
const renderedConflictContent: string = this.renderObjectForEditor(parsedConflictContent, null, 4);
|
||||||
this.selectedConflictContent.setBaseline(renderedConflictContent);
|
this.selectedConflictContent.setBaseline(renderedConflictContent);
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDocumentEditorForReplace(
|
public async initDocumentEditorForReplace(
|
||||||
documentId: ConflictId,
|
documentId: ConflictId,
|
||||||
conflictContent: any,
|
conflictContent: any,
|
||||||
currentContent: any
|
currentContent: any
|
||||||
): Q.Promise<any> {
|
): Promise<any> {
|
||||||
if (documentId) {
|
if (documentId) {
|
||||||
currentContent = ConflictsTab.removeSystemProperties(currentContent);
|
currentContent = ConflictsTab.removeSystemProperties(currentContent);
|
||||||
const renderedCurrentContent: string = this.renderObjectForEditor(currentContent, null, 4);
|
const renderedCurrentContent: string = this.renderObjectForEditor(currentContent, null, 4);
|
||||||
@ -605,11 +594,9 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
this.selectedConflictContent.setBaseline(renderedConflictContent);
|
this.selectedConflictContent.setBaseline(renderedConflictContent);
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDocumentEditorForDelete(documentId: ConflictId, documentToDelete: any): Q.Promise<any> {
|
public async initDocumentEditorForDelete(documentId: ConflictId, documentToDelete: any): Promise<any> {
|
||||||
if (documentId) {
|
if (documentId) {
|
||||||
let parsedDocumentToDelete: any = JSON.parse(documentToDelete);
|
let parsedDocumentToDelete: any = JSON.parse(documentToDelete);
|
||||||
parsedDocumentToDelete = ConflictsTab.removeSystemProperties(parsedDocumentToDelete);
|
parsedDocumentToDelete = ConflictsTab.removeSystemProperties(parsedDocumentToDelete);
|
||||||
@ -617,15 +604,12 @@ export default class ConflictsTab extends TabsBase {
|
|||||||
this.selectedConflictContent.setBaseline(renderedDocumentToDelete);
|
this.selectedConflictContent.setBaseline(renderedDocumentToDelete);
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDocumentEditorForNoOp(documentId: ConflictId): Q.Promise<any> {
|
public async initDocumentEditorForNoOp(documentId: ConflictId): Promise<any> {
|
||||||
this.selectedConflictContent(null);
|
this.selectedConflictContent(null);
|
||||||
this.selectedConflictCurrent(null);
|
this.selectedConflictCurrent(null);
|
||||||
this.editorState(ViewModels.DocumentExplorerState.noDocumentSelected);
|
this.editorState(ViewModels.DocumentExplorerState.noDocumentSelected);
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getTabsButtons(): CommandButtonComponentProps[] {
|
protected getTabsButtons(): CommandButtonComponentProps[] {
|
||||||
|
@ -8,7 +8,6 @@ import * as SharedConstants from "../../Shared/Constants";
|
|||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import DiscardIcon from "../../../images/discard.svg";
|
import DiscardIcon from "../../../images/discard.svg";
|
||||||
import editable from "../../Common/EditableUtility";
|
import editable from "../../Common/EditableUtility";
|
||||||
import Q from "q";
|
|
||||||
import SaveIcon from "../../../images/save-cosmos.svg";
|
import SaveIcon from "../../../images/save-cosmos.svg";
|
||||||
import TabsBase from "./TabsBase";
|
import TabsBase from "./TabsBase";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
@ -544,7 +543,7 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public onRevertClick = (): Q.Promise<any> => {
|
public onRevertClick = async (): Promise<any> => {
|
||||||
this.throughput.setBaseline(this.throughput.getEditableOriginalValue());
|
this.throughput.setBaseline(this.throughput.getEditableOriginalValue());
|
||||||
this.isAutoPilotSelected.setBaseline(this.isAutoPilotSelected.getEditableOriginalValue());
|
this.isAutoPilotSelected.setBaseline(this.isAutoPilotSelected.getEditableOriginalValue());
|
||||||
if (!this.hasAutoPilotV2FeatureFlag()) {
|
if (!this.hasAutoPilotV2FeatureFlag()) {
|
||||||
@ -552,11 +551,9 @@ export default class DatabaseSettingsTab extends TabsBase implements ViewModels.
|
|||||||
} else {
|
} else {
|
||||||
this.selectedAutoPilotTier.setBaseline(this.selectedAutoPilotTier.getEditableOriginalValue());
|
this.selectedAutoPilotTier.setBaseline(this.selectedAutoPilotTier.getEditableOriginalValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onActivate(): Q.Promise<any> {
|
public onActivate(): Promise<any> {
|
||||||
return super.onActivate().then(async () => {
|
return super.onActivate().then(async () => {
|
||||||
this.database.selectedSubnodeKind(ViewModels.CollectionTabKind.DatabaseSettings);
|
this.database.selectedSubnodeKind(ViewModels.CollectionTabKind.DatabaseSettings);
|
||||||
await this.database.loadOffer();
|
await this.database.loadOffer();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
@ -340,24 +339,21 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public onShowFilterClick(): Q.Promise<any> {
|
public async onShowFilterClick(): Promise<any> {
|
||||||
this.isFilterCreated(true);
|
this.isFilterCreated(true);
|
||||||
this.isFilterExpanded(true);
|
this.isFilterExpanded(true);
|
||||||
|
|
||||||
$(".filterDocExpanded").addClass("active");
|
$(".filterDocExpanded").addClass("active");
|
||||||
$("#content").addClass("active");
|
$("#content").addClass("active");
|
||||||
$(".querydropdown").focus();
|
$(".querydropdown").focus();
|
||||||
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onHideFilterClick(): Q.Promise<any> {
|
public async onHideFilterClick(): Promise<any> {
|
||||||
this.isFilterExpanded(false);
|
this.isFilterExpanded(false);
|
||||||
|
|
||||||
$(".filterDocExpanded").removeClass("active");
|
$(".filterDocExpanded").removeClass("active");
|
||||||
$("#content").removeClass("active");
|
$("#content").removeClass("active");
|
||||||
$(".queryButton").focus();
|
$(".queryButton").focus();
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCloseButtonKeyDown = (source: any, event: KeyboardEvent): boolean => {
|
public onCloseButtonKeyDown = (source: any, event: KeyboardEvent): boolean => {
|
||||||
@ -369,7 +365,7 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onApplyFilterClick(): Q.Promise<any> {
|
public onApplyFilterClick(): Promise<any> {
|
||||||
// clear documents grid
|
// clear documents grid
|
||||||
this.documentIds([]);
|
this.documentIds([]);
|
||||||
return this.createIterator()
|
return this.createIterator()
|
||||||
@ -398,7 +394,7 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public refreshDocumentsGrid(): Q.Promise<any> {
|
public refreshDocumentsGrid(): Promise<any> {
|
||||||
return this.onApplyFilterClick();
|
return this.onApplyFilterClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,19 +407,17 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onDocumentIdClick(clickedDocumentId: DocumentId): Q.Promise<any> {
|
public async onDocumentIdClick(clickedDocumentId: DocumentId): Promise<any> {
|
||||||
if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) {
|
if (this.editorState() !== ViewModels.DocumentExplorerState.noDocumentSelected) {
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onNewDocumentClick = (): Q.Promise<any> => {
|
public onNewDocumentClick = async (): Promise<any> => {
|
||||||
if (this.isEditorDirty() && !this._isIgnoreDirtyEditor()) {
|
if (this.isEditorDirty() && !this._isIgnoreDirtyEditor()) {
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
this.selectedDocumentId(null);
|
this.selectedDocumentId(null);
|
||||||
|
|
||||||
@ -431,11 +425,9 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
this.initialDocumentContent(defaultDocument);
|
this.initialDocumentContent(defaultDocument);
|
||||||
this.selectedDocumentContent.setBaseline(defaultDocument);
|
this.selectedDocumentContent.setBaseline(defaultDocument);
|
||||||
this.editorState(ViewModels.DocumentExplorerState.newDocumentValid);
|
this.editorState(ViewModels.DocumentExplorerState.newDocumentValid);
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onSaveNewDocumentClick = (): Q.Promise<any> => {
|
public onSaveNewDocumentClick = (): Promise<any> => {
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
const startKey: number = TelemetryProcessor.traceStart(Action.CreateDocument, {
|
const startKey: number = TelemetryProcessor.traceStart(Action.CreateDocument, {
|
||||||
databaseAccountName: this.collection && this.collection.container.databaseAccount().name,
|
databaseAccountName: this.collection && this.collection.container.databaseAccount().name,
|
||||||
@ -493,15 +485,13 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
.finally(() => this.isExecuting(false));
|
.finally(() => this.isExecuting(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
public onRevertNewDocumentClick = (): Q.Promise<any> => {
|
public onRevertNewDocumentClick = async (): Promise<any> => {
|
||||||
this.initialDocumentContent("");
|
this.initialDocumentContent("");
|
||||||
this.selectedDocumentContent("");
|
this.selectedDocumentContent("");
|
||||||
this.editorState(ViewModels.DocumentExplorerState.noDocumentSelected);
|
this.editorState(ViewModels.DocumentExplorerState.noDocumentSelected);
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onSaveExisitingDocumentClick = (): Q.Promise<any> => {
|
public onSaveExisitingDocumentClick = (): Promise<any> => {
|
||||||
const selectedDocumentId = this.selectedDocumentId();
|
const selectedDocumentId = this.selectedDocumentId();
|
||||||
const documentContent = JSON.parse(this.selectedDocumentContent());
|
const documentContent = JSON.parse(this.selectedDocumentContent());
|
||||||
|
|
||||||
@ -560,15 +550,13 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
.finally(() => this.isExecuting(false));
|
.finally(() => this.isExecuting(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
public onRevertExisitingDocumentClick = (): Q.Promise<any> => {
|
public onRevertExisitingDocumentClick = async (): Promise<any> => {
|
||||||
this.selectedDocumentContent.setBaseline(this.initialDocumentContent());
|
this.selectedDocumentContent.setBaseline(this.initialDocumentContent());
|
||||||
this.initialDocumentContent.valueHasMutated();
|
this.initialDocumentContent.valueHasMutated();
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onDeleteExisitingDocumentClick = (): Q.Promise<any> => {
|
public onDeleteExisitingDocumentClick = async (): Promise<any> => {
|
||||||
const selectedDocumentId = this.selectedDocumentId();
|
const selectedDocumentId = this.selectedDocumentId();
|
||||||
const msg = !this.isPreferredApiMongoDB
|
const msg = !this.isPreferredApiMongoDB
|
||||||
? "Are you sure you want to delete the selected item ?"
|
? "Are you sure you want to delete the selected item ?"
|
||||||
@ -577,30 +565,27 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
if (window.confirm(msg)) {
|
if (window.confirm(msg)) {
|
||||||
return this._deleteDocument(selectedDocumentId);
|
return this._deleteDocument(selectedDocumentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onValidDocumentEdit(): Q.Promise<any> {
|
public async onValidDocumentEdit(): Promise<any> {
|
||||||
if (
|
if (
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.newDocumentInvalid ||
|
this.editorState() === ViewModels.DocumentExplorerState.newDocumentInvalid ||
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.newDocumentValid
|
this.editorState() === ViewModels.DocumentExplorerState.newDocumentValid
|
||||||
) {
|
) {
|
||||||
this.editorState(ViewModels.DocumentExplorerState.newDocumentValid);
|
this.editorState(ViewModels.DocumentExplorerState.newDocumentValid);
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid);
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onInvalidDocumentEdit(): Q.Promise<any> {
|
public async onInvalidDocumentEdit(): Promise<any> {
|
||||||
if (
|
if (
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.newDocumentInvalid ||
|
this.editorState() === ViewModels.DocumentExplorerState.newDocumentInvalid ||
|
||||||
this.editorState() === ViewModels.DocumentExplorerState.newDocumentValid
|
this.editorState() === ViewModels.DocumentExplorerState.newDocumentValid
|
||||||
) {
|
) {
|
||||||
this.editorState(ViewModels.DocumentExplorerState.newDocumentInvalid);
|
this.editorState(ViewModels.DocumentExplorerState.newDocumentInvalid);
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -608,22 +593,20 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
|
this.editorState() === ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid
|
||||||
) {
|
) {
|
||||||
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid);
|
this.editorState(ViewModels.DocumentExplorerState.exisitingDocumentDirtyInvalid);
|
||||||
return Q();
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
public onTabClick(): Promise<any> {
|
||||||
}
|
|
||||||
|
|
||||||
public onTabClick(): Q.Promise<any> {
|
|
||||||
return super.onTabClick().then(() => {
|
return super.onTabClick().then(() => {
|
||||||
this.collection && this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Documents);
|
this.collection && this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Documents);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onActivate(): Q.Promise<any> {
|
public onActivate(): Promise<any> {
|
||||||
return super.onActivate().then(() => {
|
return super.onActivate().then(() => {
|
||||||
if (this._documentsIterator) {
|
if (this._documentsIterator) {
|
||||||
return Q.resolve(this._documentsIterator);
|
return this._documentsIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.createIterator().then(
|
return this.createIterator().then(
|
||||||
@ -653,7 +636,7 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onRefreshClick(): Q.Promise<any> {
|
public onRefreshClick(): Promise<any> {
|
||||||
return this.refreshDocumentsGrid().then(() => {
|
return this.refreshDocumentsGrid().then(() => {
|
||||||
this.selectedDocumentContent("");
|
this.selectedDocumentContent("");
|
||||||
this.selectedDocumentId(null);
|
this.selectedDocumentId(null);
|
||||||
@ -665,11 +648,11 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
return window.confirm(msg);
|
return window.confirm(msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
protected __deleteDocument(documentId: DocumentId): Q.Promise<any> {
|
protected __deleteDocument(documentId: DocumentId): Promise<any> {
|
||||||
return deleteDocument(this.collection, documentId);
|
return deleteDocument(this.collection, documentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _deleteDocument(selectedDocumentId: DocumentId): Q.Promise<any> {
|
private _deleteDocument(selectedDocumentId: DocumentId): Promise<any> {
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
const startKey: number = TelemetryProcessor.traceStart(Action.DeleteDocument, {
|
const startKey: number = TelemetryProcessor.traceStart(Action.DeleteDocument, {
|
||||||
databaseAccountName: this.collection && this.collection.container.databaseAccount().name,
|
databaseAccountName: this.collection && this.collection.container.databaseAccount().name,
|
||||||
@ -714,7 +697,7 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
.finally(() => this.isExecuting(false));
|
.finally(() => this.isExecuting(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public createIterator(): Q.Promise<QueryIterator<ItemDefinition & Resource>> {
|
public createIterator(): Promise<QueryIterator<ItemDefinition & Resource>> {
|
||||||
let filters = this.lastFilterContents();
|
let filters = this.lastFilterContents();
|
||||||
const filter: string = this.filterContent().trim();
|
const filter: string = this.filterContent().trim();
|
||||||
const query: string = this.buildQuery(filter);
|
const query: string = this.buildQuery(filter);
|
||||||
@ -728,14 +711,14 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
return queryDocuments(this.collection.databaseId, this.collection.id(), query, options);
|
return queryDocuments(this.collection.databaseId, this.collection.id(), query, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public selectDocument(documentId: DocumentId): Q.Promise<any> {
|
public selectDocument(documentId: DocumentId): Promise<any> {
|
||||||
this.selectedDocumentId(documentId);
|
this.selectedDocumentId(documentId);
|
||||||
return readDocument(this.collection, documentId).then((content: any) => {
|
return readDocument(this.collection, documentId).then((content: any) => {
|
||||||
this.initDocumentEditor(documentId, content);
|
this.initDocumentEditor(documentId, content);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadNextPage(): Q.Promise<any> {
|
public loadNextPage(): Promise<any> {
|
||||||
this.isExecuting(true);
|
this.isExecuting(true);
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
return this._loadNextPageInternal()
|
return this._loadNextPageInternal()
|
||||||
@ -809,8 +792,8 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected _loadNextPageInternal(): Q.Promise<DataModels.DocumentId[]> {
|
protected _loadNextPageInternal(): Promise<DataModels.DocumentId[]> {
|
||||||
return Q(this._documentsIterator.fetchNext().then(response => response.resources));
|
return this._documentsIterator.fetchNext().then(response => response.resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _onEditorContentChange(newContent: string) {
|
protected _onEditorContentChange(newContent: string) {
|
||||||
@ -822,7 +805,7 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public initDocumentEditor(documentId: DocumentId, documentContent: any): Q.Promise<any> {
|
public async initDocumentEditor(documentId: DocumentId, documentContent: any): Promise<any> {
|
||||||
if (documentId) {
|
if (documentId) {
|
||||||
const content: string = this.renderObjectForEditor(documentContent, null, 4);
|
const content: string = this.renderObjectForEditor(documentContent, null, 4);
|
||||||
this.selectedDocumentContent.setBaseline(content);
|
this.selectedDocumentContent.setBaseline(content);
|
||||||
@ -832,8 +815,6 @@ export default class DocumentsTab extends TabsBase {
|
|||||||
: ViewModels.DocumentExplorerState.newDocumentValid;
|
: ViewModels.DocumentExplorerState.newDocumentValid;
|
||||||
this.editorState(newState);
|
this.editorState(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public buildQuery(filter: string): string {
|
public buildQuery(filter: string): string {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as Q from "q";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import TabsBase from "./TabsBase";
|
import TabsBase from "./TabsBase";
|
||||||
import { GraphExplorerAdapter } from "../Graph/GraphExplorerComponent/GraphExplorerAdapter";
|
import { GraphExplorerAdapter } from "../Graph/GraphExplorerComponent/GraphExplorerAdapter";
|
||||||
@ -114,7 +113,7 @@ export default class GraphTab extends TabsBase {
|
|||||||
: `${account.name}.graphs.azure.com:443/`;
|
: `${account.name}.graphs.azure.com:443/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public onTabClick(): Q.Promise<any> {
|
public onTabClick(): Promise<any> {
|
||||||
return super.onTabClick().then(() => {
|
return super.onTabClick().then(() => {
|
||||||
this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Graph);
|
this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Graph);
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import Q from "q";
|
|
||||||
import MongoUtility from "../../Common/MongoUtility";
|
import MongoUtility from "../../Common/MongoUtility";
|
||||||
import QueryTab from "./QueryTab";
|
import QueryTab from "./QueryTab";
|
||||||
import * as HeadersUtility from "../../Common/HeadersUtility";
|
import * as HeadersUtility from "../../Common/HeadersUtility";
|
||||||
@ -20,10 +19,10 @@ export default class MongoQueryTab extends QueryTab {
|
|||||||
return MongoUtility.tojson(value, null, false);
|
return MongoUtility.tojson(value, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _initIterator(): Q.Promise<MinimalQueryIterator> {
|
protected async _initIterator(): Promise<MinimalQueryIterator> {
|
||||||
let options: any = {};
|
let options: any = {};
|
||||||
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
|
options.enableCrossPartitionQuery = HeadersUtility.shouldEnableCrossPartitionKey();
|
||||||
this._iterator = queryIterator(this.collection.databaseId, this.collection, this.sqlStatementToExecute());
|
this._iterator = queryIterator(this.collection.databaseId, this.collection, this.sqlStatementToExecute());
|
||||||
return Q(this._iterator);
|
return this._iterator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import * as ko from "knockout";
|
|||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import AuthHeadersUtil from "../../Platform/Hosted/Authorization";
|
import AuthHeadersUtil from "../../Platform/Hosted/Authorization";
|
||||||
import { isInvalidParentFrameOrigin } from "../../Utils/MessageValidation";
|
import { isInvalidParentFrameOrigin } from "../../Utils/MessageValidation";
|
||||||
import Q from "q";
|
|
||||||
import TabsBase from "./TabsBase";
|
import TabsBase from "./TabsBase";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
@ -53,7 +52,7 @@ export default class MongoShellTab extends TabsBase {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public onTabClick(): Q.Promise<any> {
|
public onTabClick(): Promise<any> {
|
||||||
return super.onTabClick().then(() => {
|
return super.onTabClick().then(() => {
|
||||||
this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Documents);
|
this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Documents);
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import * as Q from "q";
|
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
@ -84,7 +83,7 @@ export default class NotebookTabV2 extends TabsBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onCloseTabButtonClick(): Q.Promise<any> {
|
public async onCloseTabButtonClick(): Promise<any> {
|
||||||
const cleanup = () => {
|
const cleanup = () => {
|
||||||
this.notebookComponentAdapter.notebookShutdown();
|
this.notebookComponentAdapter.notebookShutdown();
|
||||||
this.isActive(false);
|
this.isActive(false);
|
||||||
@ -100,11 +99,11 @@ export default class NotebookTabV2 extends TabsBase {
|
|||||||
"Cancel",
|
"Cancel",
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
return Q.resolve(null);
|
|
||||||
} else {
|
} else {
|
||||||
cleanup();
|
cleanup();
|
||||||
return Q.resolve(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async reconfigureServiceEndpoints() {
|
public async reconfigureServiceEndpoints() {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
@ -163,13 +162,13 @@ export default class QueryTab extends TabsBase implements ViewModels.WaitsForTem
|
|||||||
this._buildCommandBarOptions();
|
this._buildCommandBarOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onTabClick(): Q.Promise<any> {
|
public onTabClick(): Promise<any> {
|
||||||
return super.onTabClick().then(() => {
|
return super.onTabClick().then(() => {
|
||||||
this.collection && this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Query);
|
this.collection && this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Query);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onExecuteQueryClick = (): Q.Promise<any> => {
|
public onExecuteQueryClick = (): Promise<any> => {
|
||||||
const sqlStatement: string = this.selectedContent() || this.sqlQueryEditorContent();
|
const sqlStatement: string = this.selectedContent() || this.sqlQueryEditorContent();
|
||||||
this.sqlStatementToExecute(sqlStatement);
|
this.sqlStatementToExecute(sqlStatement);
|
||||||
this.allResultsMetadata([]);
|
this.allResultsMetadata([]);
|
||||||
@ -191,7 +190,7 @@ export default class QueryTab extends TabsBase implements ViewModels.WaitsForTem
|
|||||||
this.collection && this.collection.container && this.collection.container.browseQueriesPane.open();
|
this.collection && this.collection.container && this.collection.container.browseQueriesPane.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
public onFetchNextPageClick(): Q.Promise<any> {
|
public onFetchNextPageClick(): Promise<any> {
|
||||||
const allResultsMetadata = (this.allResultsMetadata && this.allResultsMetadata()) || [];
|
const allResultsMetadata = (this.allResultsMetadata && this.allResultsMetadata()) || [];
|
||||||
const metadata: ViewModels.QueryResultsMetadata = allResultsMetadata[allResultsMetadata.length - 1];
|
const metadata: ViewModels.QueryResultsMetadata = allResultsMetadata[allResultsMetadata.length - 1];
|
||||||
const firstResultIndex: number = (metadata && Number(metadata.firstItemIndex)) || 1;
|
const firstResultIndex: number = (metadata && Number(metadata.firstItemIndex)) || 1;
|
||||||
@ -265,7 +264,7 @@ export default class QueryTab extends TabsBase implements ViewModels.WaitsForTem
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _executeQueryDocumentsPage(firstItemIndex: number): Q.Promise<any> {
|
private _executeQueryDocumentsPage(firstItemIndex: number): Promise<any> {
|
||||||
this.errors([]);
|
this.errors([]);
|
||||||
this.roundTrips(undefined);
|
this.roundTrips(undefined);
|
||||||
if (this._iterator == null) {
|
if (this._iterator == null) {
|
||||||
@ -277,7 +276,7 @@ export default class QueryTab extends TabsBase implements ViewModels.WaitsForTem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Position and enable spinner when request is in progress
|
// TODO: Position and enable spinner when request is in progress
|
||||||
private _queryDocumentsPage(firstItemIndex: number): Q.Promise<any> {
|
private _queryDocumentsPage(firstItemIndex: number): Promise<any> {
|
||||||
this.isExecutionError(false);
|
this.isExecutionError(false);
|
||||||
this._resetAggregateQueryMetrics();
|
this._resetAggregateQueryMetrics();
|
||||||
const startKey: number = TelemetryProcessor.traceStart(Action.ExecuteQuery, {
|
const startKey: number = TelemetryProcessor.traceStart(Action.ExecuteQuery, {
|
||||||
@ -485,16 +484,14 @@ export default class QueryTab extends TabsBase implements ViewModels.WaitsForTem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _initIterator(): Q.Promise<MinimalQueryIterator> {
|
protected _initIterator(): Promise<MinimalQueryIterator> {
|
||||||
const options: any = QueryTab.getIteratorOptions(this.collection);
|
const options: any = QueryTab.getIteratorOptions(this.collection);
|
||||||
if (this._resourceTokenPartitionKey) {
|
if (this._resourceTokenPartitionKey) {
|
||||||
options.partitionKey = this._resourceTokenPartitionKey;
|
options.partitionKey = this._resourceTokenPartitionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q(
|
return queryDocuments(this.collection.databaseId, this.collection.id(), this.sqlStatementToExecute(), options).then(
|
||||||
queryDocuments(this.collection.databaseId, this.collection.id(), this.sqlStatementToExecute(), options).then(
|
|
||||||
iterator => (this._iterator = iterator)
|
iterator => (this._iterator = iterator)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import TabsBase from "./TabsBase";
|
import TabsBase from "./TabsBase";
|
||||||
import TableEntityListViewModel from "../Tables/DataTable/TableEntityListViewModel";
|
import TableEntityListViewModel from "../Tables/DataTable/TableEntityListViewModel";
|
||||||
@ -130,38 +129,38 @@ export default class QueryTablesTab extends TabsBase {
|
|||||||
this.buildCommandBarOptions();
|
this.buildCommandBarOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onExecuteQueryClick = (): Q.Promise<any> => {
|
public onExecuteQueryClick = (): Promise<any> => {
|
||||||
this.queryViewModel().runQuery();
|
this.queryViewModel().runQuery();
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onQueryBuilderClick = (): Q.Promise<any> => {
|
public onQueryBuilderClick = (): Promise<any> => {
|
||||||
this.queryViewModel().selectHelper();
|
this.queryViewModel().selectHelper();
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onQueryTextClick = (): Q.Promise<any> => {
|
public onQueryTextClick = (): Promise<any> => {
|
||||||
this.queryViewModel().selectEditor();
|
this.queryViewModel().selectEditor();
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onAddEntityClick = (): Q.Promise<any> => {
|
public onAddEntityClick = (): Promise<any> => {
|
||||||
this.container.addTableEntityPane.tableViewModel = this.tableEntityListViewModel();
|
this.container.addTableEntityPane.tableViewModel = this.tableEntityListViewModel();
|
||||||
this.container.addTableEntityPane.open();
|
this.container.addTableEntityPane.open();
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onEditEntityClick = (): Q.Promise<any> => {
|
public onEditEntityClick = (): Promise<any> => {
|
||||||
this.tableCommands.editEntityCommand(this.tableEntityListViewModel());
|
this.tableCommands.editEntityCommand(this.tableEntityListViewModel());
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onDeleteEntityClick = (): Q.Promise<any> => {
|
public onDeleteEntityClick = (): Promise<any> => {
|
||||||
this.tableCommands.deleteEntitiesCommand(this.tableEntityListViewModel());
|
this.tableCommands.deleteEntitiesCommand(this.tableEntityListViewModel());
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
public onActivate(): Q.Promise<any> {
|
public onActivate(): Promise<any> {
|
||||||
return super.onActivate().then(() => {
|
return super.onActivate().then(() => {
|
||||||
const columns =
|
const columns =
|
||||||
!!this.tableEntityListViewModel() &&
|
!!this.tableEntityListViewModel() &&
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as monaco from "monaco-editor";
|
import * as monaco from "monaco-editor";
|
||||||
import Q from "q";
|
|
||||||
import DiscardIcon from "../../../images/discard.svg";
|
import DiscardIcon from "../../../images/discard.svg";
|
||||||
import SaveIcon from "../../../images/save-cosmos.svg";
|
import SaveIcon from "../../../images/save-cosmos.svg";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
@ -186,7 +185,7 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
|
|||||||
this._setBaselines();
|
this._setBaselines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onTabClick(): Q.Promise<any> {
|
public onTabClick(): Promise<any> {
|
||||||
return super.onTabClick().then(() => {
|
return super.onTabClick().then(() => {
|
||||||
if (this.isNew()) {
|
if (this.isNew()) {
|
||||||
this.collection.selectedSubnodeKind(this.tabKind);
|
this.collection.selectedSubnodeKind(this.tabKind);
|
||||||
@ -197,13 +196,11 @@ export default abstract class ScriptTabBase extends TabsBase implements ViewMode
|
|||||||
public abstract onSaveClick: () => Promise<any>;
|
public abstract onSaveClick: () => Promise<any>;
|
||||||
public abstract onUpdateClick: () => Promise<any>;
|
public abstract onUpdateClick: () => Promise<any>;
|
||||||
|
|
||||||
public onDiscard = (): Q.Promise<any> => {
|
public onDiscard = async (): Promise<any> => {
|
||||||
this.setBaselines();
|
this.setBaselines();
|
||||||
const original = this.editorContent.getEditableOriginalValue();
|
const original = this.editorContent.getEditableOriginalValue();
|
||||||
const editorModel = this.editor() && this.editor().getModel();
|
const editorModel = this.editor() && this.editor().getModel();
|
||||||
editorModel && editorModel.setValue(original);
|
editorModel && editorModel.setValue(original);
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onSaveOrUpdateClick(): Promise<any> {
|
public onSaveOrUpdateClick(): Promise<any> {
|
||||||
|
@ -9,7 +9,6 @@ import * as SharedConstants from "../../Shared/Constants";
|
|||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import DiscardIcon from "../../../images/discard.svg";
|
import DiscardIcon from "../../../images/discard.svg";
|
||||||
import editable from "../../Common/EditableUtility";
|
import editable from "../../Common/EditableUtility";
|
||||||
import Q from "q";
|
|
||||||
import SaveIcon from "../../../images/save-cosmos.svg";
|
import SaveIcon from "../../../images/save-cosmos.svg";
|
||||||
import TabsBase from "./TabsBase";
|
import TabsBase from "./TabsBase";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
@ -1231,7 +1230,7 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
|
|||||||
this.isExecuting(false);
|
this.isExecuting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
public onRevertClick = (): Q.Promise<any> => {
|
public onRevertClick = async (): Promise<any> => {
|
||||||
TelemetryProcessor.trace(Action.DiscardSettings, ActionModifiers.Mark, {
|
TelemetryProcessor.trace(Action.DiscardSettings, ActionModifiers.Mark, {
|
||||||
message: "Settings Discarded"
|
message: "Settings Discarded"
|
||||||
});
|
});
|
||||||
@ -1274,21 +1273,17 @@ export default class SettingsTab extends TabsBase implements ViewModels.WaitsFor
|
|||||||
this.selectedAutoPilotTier(originalAutoPilotTier);
|
this.selectedAutoPilotTier(originalAutoPilotTier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onValidIndexingPolicyEdit(): Q.Promise<any> {
|
public async onValidIndexingPolicyEdit(): Promise<any> {
|
||||||
this.indexingPolicyContent.editableIsValid(true);
|
this.indexingPolicyContent.editableIsValid(true);
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onInvalidIndexingPolicyEdit(): Q.Promise<any> {
|
public async onInvalidIndexingPolicyEdit(): Promise<any> {
|
||||||
this.indexingPolicyContent.editableIsValid(false);
|
this.indexingPolicyContent.editableIsValid(false);
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onActivate(): Q.Promise<any> {
|
public onActivate(): Promise<any> {
|
||||||
return super.onActivate().then(async () => {
|
return super.onActivate().then(async () => {
|
||||||
this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Settings);
|
this.collection.selectedSubnodeKind(ViewModels.CollectionTabKind.Settings);
|
||||||
const database: ViewModels.Database = this.collection.getDatabase();
|
const database: ViewModels.Database = this.collection.getDatabase();
|
||||||
|
@ -41,7 +41,7 @@ export default class SettingsTabV2 extends TabsBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onActivate(): Q.Promise<unknown> {
|
public onActivate(): Promise<unknown> {
|
||||||
this.isExecuting(true);
|
this.isExecuting(true);
|
||||||
this.currentCollection.loadOffer().then(
|
this.currentCollection.loadOffer().then(
|
||||||
() => {
|
() => {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Resource, StoredProcedureDefinition } from "@azure/cosmos";
|
import { Resource, StoredProcedureDefinition } from "@azure/cosmos";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as _ from "underscore";
|
import * as _ from "underscore";
|
||||||
import ExecuteQueryIcon from "../../../images/ExecuteQuery.svg";
|
import ExecuteQueryIcon from "../../../images/ExecuteQuery.svg";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
@ -61,13 +60,11 @@ export default class StoredProcedureTab extends ScriptTabBase {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
public onDiscard = (): Q.Promise<any> => {
|
public onDiscard = async (): Promise<any> => {
|
||||||
this.setBaselines();
|
this.setBaselines();
|
||||||
const original = this.editorContent.getEditableOriginalValue();
|
const original = this.editorContent.getEditableOriginalValue();
|
||||||
this.originalSprocBody(original);
|
this.originalSprocBody(original);
|
||||||
this.originalSprocBody.valueHasMutated(); // trigger a re-render of the editor
|
this.originalSprocBody.valueHasMutated(); // trigger a re-render of the editor
|
||||||
|
|
||||||
return Q();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public onUpdateClick = (): Promise<any> => {
|
public onUpdateClick = (): Promise<any> => {
|
||||||
@ -284,8 +281,7 @@ export default class StoredProcedureTab extends ScriptTabBase {
|
|||||||
.finally(() => this.isExecuting(false));
|
.finally(() => this.isExecuting(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public onDelete(): Q.Promise<any> {
|
public async onDelete(): Promise<any> {
|
||||||
// TODO
|
// TODO
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import Q from "q";
|
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
@ -93,9 +92,8 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public onTabClick(): Q.Promise<any> {
|
public async onTabClick(): Promise<any> {
|
||||||
this.getContainer().tabsManager.activateTab(this);
|
this.getContainer().tabsManager.activateTab(this);
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updateSelectedNode(): void {
|
protected updateSelectedNode(): void {
|
||||||
@ -127,7 +125,7 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
|||||||
return this.onSpaceOrEnterKeyPress(event, () => this.onCloseTabButtonClick());
|
return this.onSpaceOrEnterKeyPress(event, () => this.onCloseTabButtonClick());
|
||||||
};
|
};
|
||||||
|
|
||||||
public onActivate(): Q.Promise<any> {
|
public async onActivate(): Promise<any> {
|
||||||
this.updateSelectedNode();
|
this.updateSelectedNode();
|
||||||
if (!!this.collection) {
|
if (!!this.collection) {
|
||||||
this.collection.selectedSubnodeKind(this.tabKind);
|
this.collection.selectedSubnodeKind(this.tabKind);
|
||||||
@ -149,7 +147,6 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
|||||||
tabTitle: this.tabTitle(),
|
tabTitle: this.tabTitle(),
|
||||||
tabId: this.tabId
|
tabId: this.tabId
|
||||||
});
|
});
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onErrorDetailsClick = (src: any, event: MouseEvent): boolean => {
|
public onErrorDetailsClick = (src: any, event: MouseEvent): boolean => {
|
||||||
@ -172,9 +169,8 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
public refresh(): Q.Promise<any> {
|
public async refresh(): Promise<any> {
|
||||||
location.reload();
|
location.reload();
|
||||||
return Q();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getContainer(): Explorer {
|
protected getContainer(): Explorer {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import Q from "q";
|
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as Constants from "../../Common/Constants";
|
import * as Constants from "../../Common/Constants";
|
||||||
import DocumentId from "./DocumentId";
|
import DocumentId from "./DocumentId";
|
||||||
@ -59,13 +58,13 @@ export default class ConflictId {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadConflict(): Q.Promise<any> {
|
public async loadConflict(): Promise<any> {
|
||||||
const conflictsTab = this.container;
|
const conflictsTab = this.container;
|
||||||
this.container.selectedConflictId(this);
|
this.container.selectedConflictId(this);
|
||||||
|
|
||||||
if (this.operationType === Constants.ConflictOperationType.Create) {
|
if (this.operationType === Constants.ConflictOperationType.Create) {
|
||||||
this.container.initDocumentEditorForCreate(this, this.content);
|
this.container.initDocumentEditorForCreate(this, this.content);
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.loadingConflictData(true);
|
this.container.loadingConflictData(true);
|
||||||
@ -88,10 +87,10 @@ export default class ConflictId {
|
|||||||
this.operationType === Constants.ConflictOperationType.Delete
|
this.operationType === Constants.ConflictOperationType.Delete
|
||||||
) {
|
) {
|
||||||
this.container.initDocumentEditorForNoOp(this);
|
this.container.initDocumentEditorForNoOp(this);
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Q.reject(reason);
|
throw reason;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ export default class DocumentId {
|
|||||||
return JSON.stringify(partitionKeyValue);
|
return JSON.stringify(partitionKeyValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadDocument(): Q.Promise<any> {
|
public loadDocument(): Promise<any> {
|
||||||
return this.container.selectDocument(this);
|
return this.container.selectDocument(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import * as ViewModels from "../../Contracts/ViewModels";
|
|||||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||||
import DocumentId from "./DocumentId";
|
import DocumentId from "./DocumentId";
|
||||||
import DocumentsTab from "../Tabs/DocumentsTab";
|
import DocumentsTab from "../Tabs/DocumentsTab";
|
||||||
import Q from "q";
|
|
||||||
import QueryTab from "../Tabs/QueryTab";
|
import QueryTab from "../Tabs/QueryTab";
|
||||||
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
@ -41,9 +40,9 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
|||||||
this.isCollectionExpanded = ko.observable<boolean>(true);
|
this.isCollectionExpanded = ko.observable<boolean>(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public expandCollection(): Q.Promise<void> {
|
public async expandCollection(): Promise<void> {
|
||||||
if (this.isCollectionExpanded()) {
|
if (this.isCollectionExpanded()) {
|
||||||
return Q();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isCollectionExpanded(true);
|
this.isCollectionExpanded(true);
|
||||||
@ -55,8 +54,6 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
|||||||
defaultExperience: this.container.defaultExperience(),
|
defaultExperience: this.container.defaultExperience(),
|
||||||
dataExplorerArea: Constants.Areas.ResourceTree
|
dataExplorerArea: Constants.Areas.ResourceTree
|
||||||
});
|
});
|
||||||
|
|
||||||
return Q.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public collapseCollection() {
|
public collapseCollection() {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import Q from "q";
|
|
||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
|
|
||||||
@ -60,13 +59,12 @@ export class QueryUtils {
|
|||||||
|
|
||||||
public static queryPagesUntilContentPresent(
|
public static queryPagesUntilContentPresent(
|
||||||
firstItemIndex: number,
|
firstItemIndex: number,
|
||||||
queryItems: (itemIndex: number) => Q.Promise<ViewModels.QueryResults>
|
queryItems: (itemIndex: number) => Promise<ViewModels.QueryResults>
|
||||||
): Q.Promise<ViewModels.QueryResults> {
|
): Promise<ViewModels.QueryResults> {
|
||||||
let roundTrips: number = 0;
|
let roundTrips: number = 0;
|
||||||
let netRequestCharge: number = 0;
|
let netRequestCharge: number = 0;
|
||||||
const doRequest = (itemIndex: number): Q.Promise<ViewModels.QueryResults> =>
|
const doRequest = async (itemIndex: number): Promise<ViewModels.QueryResults> =>
|
||||||
queryItems(itemIndex).then(
|
queryItems(itemIndex).then((results: ViewModels.QueryResults) => {
|
||||||
(results: ViewModels.QueryResults) => {
|
|
||||||
roundTrips = roundTrips + 1;
|
roundTrips = roundTrips + 1;
|
||||||
results.roundTrips = roundTrips;
|
results.roundTrips = roundTrips;
|
||||||
results.requestCharge = Number(results.requestCharge) + netRequestCharge;
|
results.requestCharge = Number(results.requestCharge) + netRequestCharge;
|
||||||
@ -80,19 +78,15 @@ export class QueryUtils {
|
|||||||
if (resultsMetadata.itemCount === 0 && resultsMetadata.hasMoreResults) {
|
if (resultsMetadata.itemCount === 0 && resultsMetadata.hasMoreResults) {
|
||||||
return doRequest(resultsMetadata.lastItemIndex);
|
return doRequest(resultsMetadata.lastItemIndex);
|
||||||
}
|
}
|
||||||
return Q.resolve(results);
|
return results;
|
||||||
},
|
});
|
||||||
(error: any) => {
|
|
||||||
return Q.reject(error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return doRequest(firstItemIndex);
|
return doRequest(firstItemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static queryAllPages(
|
public static queryAllPages(
|
||||||
queryItems: (itemIndex: number) => Q.Promise<ViewModels.QueryResults>
|
queryItems: (itemIndex: number) => Promise<ViewModels.QueryResults>
|
||||||
): Q.Promise<ViewModels.QueryResults> {
|
): Promise<ViewModels.QueryResults> {
|
||||||
const queryResults: ViewModels.QueryResults = {
|
const queryResults: ViewModels.QueryResults = {
|
||||||
documents: [],
|
documents: [],
|
||||||
activityId: undefined,
|
activityId: undefined,
|
||||||
@ -103,9 +97,8 @@ export class QueryUtils {
|
|||||||
requestCharge: 0,
|
requestCharge: 0,
|
||||||
roundTrips: 0
|
roundTrips: 0
|
||||||
};
|
};
|
||||||
const doRequest = (itemIndex: number): Q.Promise<ViewModels.QueryResults> =>
|
const doRequest = async (itemIndex: number): Promise<ViewModels.QueryResults> =>
|
||||||
queryItems(itemIndex).then(
|
queryItems(itemIndex).then((results: ViewModels.QueryResults) => {
|
||||||
(results: ViewModels.QueryResults) => {
|
|
||||||
const { requestCharge, hasMoreResults, itemCount, lastItemIndex, documents } = results;
|
const { requestCharge, hasMoreResults, itemCount, lastItemIndex, documents } = results;
|
||||||
queryResults.roundTrips = queryResults.roundTrips + 1;
|
queryResults.roundTrips = queryResults.roundTrips + 1;
|
||||||
queryResults.requestCharge = Number(queryResults.requestCharge) + Number(requestCharge);
|
queryResults.requestCharge = Number(queryResults.requestCharge) + Number(requestCharge);
|
||||||
@ -116,12 +109,8 @@ export class QueryUtils {
|
|||||||
if (queryResults.hasMoreResults) {
|
if (queryResults.hasMoreResults) {
|
||||||
return doRequest(queryResults.lastItemIndex + 1);
|
return doRequest(queryResults.lastItemIndex + 1);
|
||||||
}
|
}
|
||||||
return Q.resolve(queryResults);
|
return queryResults;
|
||||||
},
|
});
|
||||||
(error: any) => {
|
|
||||||
return Q.reject(error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return doRequest(0);
|
return doRequest(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user