mirror of
https://github.com/nasa/openmct.git
synced 2025-06-27 11:32:13 +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);
|
return () => this._instanceEventEmitter.off(event, callback);
|
||||||
}
|
}
|
||||||
$destroy() {
|
$destroy() {
|
||||||
|
console.log('mutable destroy');
|
||||||
while (this._observers.length > 0) {
|
while (this._observers.length > 0) {
|
||||||
const observer = this._observers.pop();
|
const observer = this._observers.pop();
|
||||||
observer();
|
observer();
|
||||||
|
@ -416,6 +416,7 @@ ObjectAPI.prototype._toMutable = function (object) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
mutableObject.$on('$_destroy', () => {
|
mutableObject.$on('$_destroy', () => {
|
||||||
|
console.log('unobserve', object);
|
||||||
unobserve();
|
unobserve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ export default class CouchObjectProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get(identifier, abortSignal) {
|
get(identifier, abortSignal) {
|
||||||
|
console.log('couch get', identifier, abortSignal);
|
||||||
this.batchIds.push(identifier.key);
|
this.batchIds.push(identifier.key);
|
||||||
|
|
||||||
if (this.bulkPromise === undefined) {
|
if (this.bulkPromise === undefined) {
|
||||||
@ -166,14 +167,15 @@ export default class CouchObjectProvider {
|
|||||||
|
|
||||||
if (batchIds.length === 1) {
|
if (batchIds.length === 1) {
|
||||||
let objectKey = batchIds[0];
|
let objectKey = batchIds[0];
|
||||||
|
console.log('one req', objectKey);
|
||||||
//If there's only one request, just do a regular get
|
//If there's only one request, just do a regular get
|
||||||
return this.request(objectKey, "GET", undefined, abortSignal)
|
return this.request(objectKey, "GET", undefined, abortSignal)
|
||||||
.then(this.returnAsMap(objectKey));
|
.then(this.returnAsMap(objectKey));
|
||||||
} else {
|
} 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
|
* @private
|
||||||
*/
|
*/
|
||||||
bulkGet(ids, signal) {
|
bulkGet(ids) {
|
||||||
ids = this.removeDuplicates(ids);
|
ids = this.removeDuplicates(ids);
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
'keys': ids
|
'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) {
|
if (response && response.rows !== undefined) {
|
||||||
return response.rows.reduce((map, row) => {
|
return response.rows.reduce((map, row) => {
|
||||||
if (row.doc !== undefined) {
|
if (row.doc !== undefined) {
|
||||||
@ -227,7 +229,7 @@ export default class CouchObjectProvider {
|
|||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
});
|
}).catch(console.warn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -308,6 +310,7 @@ export default class CouchObjectProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
observe(identifier, callback) {
|
observe(identifier, callback) {
|
||||||
|
console.log('observe', identifier, 'observers', this.observers);
|
||||||
const keyString = this.openmct.objects.makeKeyString(identifier);
|
const keyString = this.openmct.objects.makeKeyString(identifier);
|
||||||
this.observers[keyString] = this.observers[keyString] || [];
|
this.observers[keyString] = this.observers[keyString] || [];
|
||||||
this.observers[keyString].push(callback);
|
this.observers[keyString].push(callback);
|
||||||
@ -317,6 +320,7 @@ export default class CouchObjectProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
console.log('stop observing', this, this.observers, this.observers[keyString]);
|
||||||
this.observers[keyString] = this.observers[keyString].filter(observer => observer !== callback);
|
this.observers[keyString] = this.observers[keyString].filter(observer => observer !== callback);
|
||||||
if (this.observers[keyString].length === 0) {
|
if (this.observers[keyString].length === 0) {
|
||||||
delete this.observers[keyString];
|
delete this.observers[keyString];
|
||||||
@ -382,11 +386,11 @@ export default class CouchObjectProvider {
|
|||||||
"Content-Type": 'application/json'
|
"Content-Type": 'application/json'
|
||||||
},
|
},
|
||||||
body
|
body
|
||||||
});
|
}).catch(console.warn);
|
||||||
|
|
||||||
let reader;
|
let reader;
|
||||||
|
|
||||||
if (response.body === undefined) {
|
if (!response || (response && response.body === undefined)) {
|
||||||
error = true;
|
error = true;
|
||||||
} else {
|
} else {
|
||||||
reader = response.body.getReader();
|
reader = response.body.getReader();
|
||||||
|
@ -293,6 +293,7 @@ export default {
|
|||||||
},
|
},
|
||||||
closeTreeItemByPath(path) {
|
closeTreeItemByPath(path) {
|
||||||
// if actively loading, abort
|
// if actively loading, abort
|
||||||
|
console.log('close tree item', path, 'is loading', this.isItemLoading(path));
|
||||||
if (this.isItemLoading(path)) {
|
if (this.isItemLoading(path)) {
|
||||||
this.abortItemLoad(path);
|
this.abortItemLoad(path);
|
||||||
}
|
}
|
||||||
@ -328,6 +329,7 @@ export default {
|
|||||||
delete this.treeItemLoading[path];
|
delete this.treeItemLoading[path];
|
||||||
},
|
},
|
||||||
abortItemLoad(path) {
|
abortItemLoad(path) {
|
||||||
|
console.log('abort', path);
|
||||||
if (this.treeItemLoading[path]) {
|
if (this.treeItemLoading[path]) {
|
||||||
this.treeItemLoading[path].abort();
|
this.treeItemLoading[path].abort();
|
||||||
this.endItemLoad(path);
|
this.endItemLoad(path);
|
||||||
@ -543,9 +545,11 @@ export default {
|
|||||||
this.abortSearchController = new AbortController();
|
this.abortSearchController = new AbortController();
|
||||||
const abortSignal = this.abortSearchController.signal;
|
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
|
.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 => {
|
Promise.all(promises).catch(reason => {
|
||||||
// search aborted
|
// search aborted
|
||||||
@ -561,7 +565,7 @@ export default {
|
|||||||
let resultPromises = [];
|
let resultPromises = [];
|
||||||
|
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
if (!abortSignal.aborted) {
|
if (!abortSignal || !abortSignal.aborted) {
|
||||||
resultPromises.push(this.openmct.objects.getOriginalPath(result.identifier).then((objectPath) => {
|
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
|
// removing the item itself, as the path we pass to buildTreeItem is a parent path
|
||||||
objectPath.shift();
|
objectPath.shift();
|
||||||
|
@ -5,6 +5,7 @@ define([
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
return function install(openmct) {
|
return function install(openmct) {
|
||||||
|
console.log('brwose install');
|
||||||
let navigateCall = 0;
|
let navigateCall = 0;
|
||||||
let browseObject;
|
let browseObject;
|
||||||
let unobserve = undefined;
|
let unobserve = undefined;
|
||||||
@ -28,6 +29,8 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('browse: on params changed function')
|
||||||
|
|
||||||
if (changed.view && browseObject) {
|
if (changed.view && browseObject) {
|
||||||
let provider = openmct
|
let provider = openmct
|
||||||
.objectViews
|
.objectViews
|
||||||
@ -37,24 +40,25 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
function viewObject(object, viewProvider) {
|
function viewObject(object, viewProvider) {
|
||||||
if (mutable) {
|
console.log('browse: view object');
|
||||||
openmct.objects.destroyMutable(mutable);
|
// if (mutable) {
|
||||||
mutable = undefined;
|
// openmct.objects.destroyMutable(mutable);
|
||||||
}
|
// mutable = undefined;
|
||||||
|
// }
|
||||||
|
|
||||||
if (openmct.objects.supportsMutation(object.identifier)) {
|
// if (openmct.objects.supportsMutation(object.identifier)) {
|
||||||
mutable = openmct.objects._toMutable(object);
|
// mutable = openmct.objects._toMutable(object);
|
||||||
}
|
// }
|
||||||
|
|
||||||
currentObjectPath = openmct.router.path;
|
currentObjectPath = openmct.router.path;
|
||||||
|
|
||||||
if (mutable !== undefined) {
|
// if (mutable !== undefined) {
|
||||||
openmct.layout.$refs.browseObject.show(mutable, viewProvider.key, true, currentObjectPath);
|
// openmct.layout.$refs.browseObject.show(mutable, viewProvider.key, true, currentObjectPath);
|
||||||
openmct.layout.$refs.browseBar.domainObject = mutable;
|
// openmct.layout.$refs.browseBar.domainObject = mutable;
|
||||||
} else {
|
// } else {
|
||||||
openmct.layout.$refs.browseObject.show(object, viewProvider.key, true, currentObjectPath);
|
openmct.layout.$refs.browseObject.show(object, viewProvider.key, true, currentObjectPath);
|
||||||
openmct.layout.$refs.browseBar.domainObject = object;
|
openmct.layout.$refs.browseBar.domainObject = object;
|
||||||
}
|
// }
|
||||||
|
|
||||||
openmct.layout.$refs.browseBar.viewKey = viewProvider.key;
|
openmct.layout.$refs.browseBar.viewKey = viewProvider.key;
|
||||||
}
|
}
|
||||||
@ -150,6 +154,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearMutationListeners() {
|
function clearMutationListeners() {
|
||||||
|
console.log('celarMutationListeners');
|
||||||
if (openmct.router.path !== undefined) {
|
if (openmct.router.path !== undefined) {
|
||||||
openmct.router.path.forEach((pathObject) => {
|
openmct.router.path.forEach((pathObject) => {
|
||||||
if (pathObject.isMutable) {
|
if (pathObject.isMutable) {
|
||||||
|
Reference in New Issue
Block a user