mirror of
https://github.com/nasa/openmct.git
synced 2025-06-26 11:09:22 +00:00
Compare commits
16 Commits
code-cover
...
couch-navi
Author | SHA1 | Date | |
---|---|---|---|
23a9bce055 | |||
c9fda1af90 | |||
8e5d09a4d4 | |||
c44917bf13 | |||
72a560323f | |||
646e28ee6d | |||
b5b8e5aa1a | |||
80918fb397 | |||
e2c81923cb | |||
9d9ac00b99 | |||
d0643ad54d | |||
634ff87f45 | |||
a3b5f882bb | |||
f06ccd5564 | |||
7319b2977f | |||
75d65106d1 |
@ -115,6 +115,7 @@ class MutableDomainObject {
|
||||
return () => this._instanceEventEmitter.off(event, callback);
|
||||
}
|
||||
$destroy() {
|
||||
console.log('mutable destroy');
|
||||
while (this._observers.length > 0) {
|
||||
const observer = this._observers.pop();
|
||||
observer();
|
||||
|
@ -416,6 +416,7 @@ ObjectAPI.prototype._toMutable = function (object) {
|
||||
}
|
||||
});
|
||||
mutableObject.$on('$_destroy', () => {
|
||||
console.log('unobserve', object);
|
||||
unobserve();
|
||||
});
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ export default class CouchObjectProvider {
|
||||
}
|
||||
|
||||
get(identifier, abortSignal) {
|
||||
console.log('couch get', identifier, abortSignal);
|
||||
this.batchIds.push(identifier.key);
|
||||
|
||||
if (this.bulkPromise === undefined) {
|
||||
@ -166,14 +167,15 @@ export default class CouchObjectProvider {
|
||||
|
||||
if (batchIds.length === 1) {
|
||||
let objectKey = batchIds[0];
|
||||
|
||||
console.log('one req', objectKey);
|
||||
//If there's only one request, just do a regular get
|
||||
return this.request(objectKey, "GET", undefined, abortSignal)
|
||||
.then(this.returnAsMap(objectKey));
|
||||
} else {
|
||||
return this.bulkGet(batchIds, abortSignal);
|
||||
console.log('bulk get', batchIds);
|
||||
return this.bulkGet(batchIds);
|
||||
}
|
||||
});
|
||||
}).catch(console.warn);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,14 +210,14 @@ export default class CouchObjectProvider {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
bulkGet(ids, signal) {
|
||||
bulkGet(ids) {
|
||||
ids = this.removeDuplicates(ids);
|
||||
|
||||
const query = {
|
||||
'keys': ids
|
||||
};
|
||||
|
||||
return this.request(ALL_DOCS, 'POST', query, signal).then((response) => {
|
||||
return this.request(ALL_DOCS, 'POST', query).then((response) => {
|
||||
if (response && response.rows !== undefined) {
|
||||
return response.rows.reduce((map, row) => {
|
||||
if (row.doc !== undefined) {
|
||||
@ -227,7 +229,7 @@ export default class CouchObjectProvider {
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
});
|
||||
}).catch(console.warn);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,6 +310,7 @@ export default class CouchObjectProvider {
|
||||
}
|
||||
|
||||
observe(identifier, callback) {
|
||||
console.log('observe', identifier, 'observers', this.observers);
|
||||
const keyString = this.openmct.objects.makeKeyString(identifier);
|
||||
this.observers[keyString] = this.observers[keyString] || [];
|
||||
this.observers[keyString].push(callback);
|
||||
@ -317,6 +320,7 @@ export default class CouchObjectProvider {
|
||||
}
|
||||
|
||||
return () => {
|
||||
console.log('stop observing', this, this.observers, this.observers[keyString]);
|
||||
this.observers[keyString] = this.observers[keyString].filter(observer => observer !== callback);
|
||||
if (this.observers[keyString].length === 0) {
|
||||
delete this.observers[keyString];
|
||||
@ -382,11 +386,11 @@ export default class CouchObjectProvider {
|
||||
"Content-Type": 'application/json'
|
||||
},
|
||||
body
|
||||
});
|
||||
}).catch(console.warn);
|
||||
|
||||
let reader;
|
||||
|
||||
if (response.body === undefined) {
|
||||
if (!response || (response && response.body === undefined)) {
|
||||
error = true;
|
||||
} else {
|
||||
reader = response.body.getReader();
|
||||
|
@ -293,6 +293,7 @@ export default {
|
||||
},
|
||||
closeTreeItemByPath(path) {
|
||||
// if actively loading, abort
|
||||
console.log('close tree item', path, 'is loading', this.isItemLoading(path));
|
||||
if (this.isItemLoading(path)) {
|
||||
this.abortItemLoad(path);
|
||||
}
|
||||
@ -328,6 +329,7 @@ export default {
|
||||
delete this.treeItemLoading[path];
|
||||
},
|
||||
abortItemLoad(path) {
|
||||
console.log('abort', path);
|
||||
if (this.treeItemLoading[path]) {
|
||||
this.treeItemLoading[path].abort();
|
||||
this.endItemLoad(path);
|
||||
@ -543,9 +545,11 @@ export default {
|
||||
this.abortSearchController = new AbortController();
|
||||
const abortSignal = this.abortSearchController.signal;
|
||||
|
||||
const promises = this.openmct.objects.search(this.searchValue, abortSignal)
|
||||
// removed abortSignal until future updates support it
|
||||
const promises = this.openmct.objects.search(this.searchValue)
|
||||
.map(promise => promise
|
||||
.then(results => this.aggregateSearchResults(results, abortSignal)));
|
||||
// removed abortSignal until future updates support it
|
||||
.then(results => this.aggregateSearchResults(results)));
|
||||
|
||||
Promise.all(promises).catch(reason => {
|
||||
// search aborted
|
||||
@ -561,7 +565,7 @@ export default {
|
||||
let resultPromises = [];
|
||||
|
||||
for (const result of results) {
|
||||
if (!abortSignal.aborted) {
|
||||
if (!abortSignal || !abortSignal.aborted) {
|
||||
resultPromises.push(this.openmct.objects.getOriginalPath(result.identifier).then((objectPath) => {
|
||||
// removing the item itself, as the path we pass to buildTreeItem is a parent path
|
||||
objectPath.shift();
|
||||
|
@ -5,6 +5,7 @@ define([
|
||||
) {
|
||||
|
||||
return function install(openmct) {
|
||||
console.log('brwose install');
|
||||
let navigateCall = 0;
|
||||
let browseObject;
|
||||
let unobserve = undefined;
|
||||
@ -28,6 +29,8 @@ define([
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('browse: on params changed function')
|
||||
|
||||
if (changed.view && browseObject) {
|
||||
let provider = openmct
|
||||
.objectViews
|
||||
@ -37,24 +40,25 @@ define([
|
||||
}
|
||||
|
||||
function viewObject(object, viewProvider) {
|
||||
if (mutable) {
|
||||
openmct.objects.destroyMutable(mutable);
|
||||
mutable = undefined;
|
||||
}
|
||||
console.log('browse: view object');
|
||||
// if (mutable) {
|
||||
// openmct.objects.destroyMutable(mutable);
|
||||
// mutable = undefined;
|
||||
// }
|
||||
|
||||
if (openmct.objects.supportsMutation(object.identifier)) {
|
||||
mutable = openmct.objects._toMutable(object);
|
||||
}
|
||||
// if (openmct.objects.supportsMutation(object.identifier)) {
|
||||
// mutable = openmct.objects._toMutable(object);
|
||||
// }
|
||||
|
||||
currentObjectPath = openmct.router.path;
|
||||
|
||||
if (mutable !== undefined) {
|
||||
openmct.layout.$refs.browseObject.show(mutable, viewProvider.key, true, currentObjectPath);
|
||||
openmct.layout.$refs.browseBar.domainObject = mutable;
|
||||
} else {
|
||||
// if (mutable !== undefined) {
|
||||
// openmct.layout.$refs.browseObject.show(mutable, viewProvider.key, true, currentObjectPath);
|
||||
// openmct.layout.$refs.browseBar.domainObject = mutable;
|
||||
// } else {
|
||||
openmct.layout.$refs.browseObject.show(object, viewProvider.key, true, currentObjectPath);
|
||||
openmct.layout.$refs.browseBar.domainObject = object;
|
||||
}
|
||||
// }
|
||||
|
||||
openmct.layout.$refs.browseBar.viewKey = viewProvider.key;
|
||||
}
|
||||
@ -150,6 +154,7 @@ define([
|
||||
}
|
||||
|
||||
function clearMutationListeners() {
|
||||
console.log('celarMutationListeners');
|
||||
if (openmct.router.path !== undefined) {
|
||||
openmct.router.path.forEach((pathObject) => {
|
||||
if (pathObject.isMutable) {
|
||||
|
Reference in New Issue
Block a user