mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
Inspector location (#2317)
* working original location - todo link location * remove link location for now * remove legacy getPath and implement new getOriginalPath API call * simplify getOriginalPath, and use path to calculate parent paths in location.vue
This commit is contained in:
committed by
Andrew Henry
parent
bcbf244fd2
commit
df53af7b4d
@ -226,7 +226,20 @@ define([
|
|||||||
(identifier.namespace === identifiers[0].namespace &&
|
(identifier.namespace === identifiers[0].namespace &&
|
||||||
identifier.key === identifiers[0].key);
|
identifier.key === identifiers[0].key);
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
ObjectAPI.prototype.getOriginalPath = function (identifier, path = []) {
|
||||||
|
return this.get(identifier).then((domainObject) => {
|
||||||
|
path.push(domainObject);
|
||||||
|
let location = domainObject.location;
|
||||||
|
|
||||||
|
if (location) {
|
||||||
|
return this.getOriginalPath(utils.parseKeyString(location), path);
|
||||||
|
} else {
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uniquely identifies a domain object.
|
* Uniquely identifies a domain object.
|
||||||
|
@ -2,24 +2,37 @@
|
|||||||
<div class="c-properties c-properties--location">
|
<div class="c-properties c-properties--location">
|
||||||
<div class="c-properties__header" title="The location of this linked object.">Location</div>
|
<div class="c-properties__header" title="The location of this linked object.">Location</div>
|
||||||
<ul class="c-properties__section">
|
<ul class="c-properties__section">
|
||||||
<li class="c-properties__row">
|
<li class="c-properties__row" v-if="originalPath.length">
|
||||||
<div class="c-properties__label">This Link</div>
|
|
||||||
<div class="c-properties__value">TODO</div>
|
|
||||||
</li>
|
|
||||||
<li class="c-properties__row">
|
|
||||||
<div class="c-properties__label">Original</div>
|
<div class="c-properties__label">Original</div>
|
||||||
<div class="c-properties__value">TODO</div>
|
<ul class="c-properties__value">
|
||||||
|
<li v-for="pathObject in orderedOriginalPath"
|
||||||
|
:key="pathObject.key">
|
||||||
|
<object-label
|
||||||
|
:domainObject="pathObject.domainObject"
|
||||||
|
:objectPath="pathObject.objectPath">
|
||||||
|
</object-label>
|
||||||
|
<span class="c-disclosure-triangle"></span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
import ObjectLabel from '../components/ObjectLabel.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['openmct'],
|
inject: ['openmct'],
|
||||||
|
components: {
|
||||||
|
ObjectLabel
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
domainObject: {}
|
domainObject: {},
|
||||||
|
originalPath: [],
|
||||||
|
keyString: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -30,12 +43,39 @@ export default {
|
|||||||
this.openmct.selection.off('change', this.updateSelection);
|
this.openmct.selection.off('change', this.updateSelection);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setOriginalPath(path) {
|
||||||
|
this.originalPath = path.slice(1,-1).map((domainObject, index, pathArray) => {
|
||||||
|
let key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
|
return {
|
||||||
|
domainObject,
|
||||||
|
key,
|
||||||
|
objectPath: pathArray.slice(index)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
updateSelection(selection) {
|
updateSelection(selection) {
|
||||||
if (selection.length === 0) {
|
if (selection.length === 0) {
|
||||||
this.domainObject = {};
|
this.domainObject = {};
|
||||||
|
this.originalLocation = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.domainObject = selection[0].context.item;
|
this.domainObject = selection[0].context.item;
|
||||||
|
|
||||||
|
let keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
|
||||||
|
|
||||||
|
if (this.keyString !== keyString) {
|
||||||
|
this.keyString = keyString;
|
||||||
|
this.originalPath = [];
|
||||||
|
|
||||||
|
this.openmct.objects.getOriginalPath(this.keyString)
|
||||||
|
.then(this.setOriginalPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
orderedOriginalPath() {
|
||||||
|
return this.originalPath.reverse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user