mirror of
https://github.com/nasa/openmct.git
synced 2025-01-15 01:10:51 +00:00
[Inspector] Separate primary and contextual locations
The object inspector now finds both the contextual location of the link and the primary location of the original, if the selected object is a link. #73.
This commit is contained in:
parent
454b96c3c9
commit
70324a2198
@ -108,7 +108,7 @@
|
|||||||
{
|
{
|
||||||
"key": "ObjectInspectorController",
|
"key": "ObjectInspectorController",
|
||||||
"implementation": "controllers/ObjectInspectorController.js",
|
"implementation": "controllers/ObjectInspectorController.js",
|
||||||
"depends": [ "$scope" ]
|
"depends": [ "$scope", "objectService" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"directives": [
|
"directives": [
|
||||||
|
@ -29,10 +29,21 @@
|
|||||||
<em>{{ data.name }}</em>
|
<em>{{ data.name }}</em>
|
||||||
{{ data.value }}
|
{{ data.value }}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li ng-if="contextutalParents.length > 0">
|
||||||
<em>Location </em>
|
<em>Contextual Location </em>
|
||||||
<span class="inspector-location"
|
<span class="inspector-location"
|
||||||
ng-repeat="parent in parents">
|
ng-repeat="parent in contextutalParents">
|
||||||
|
<mct-representation key="'label'"
|
||||||
|
mct-object="parent"
|
||||||
|
ng-model="ngModel"
|
||||||
|
ng-click="ngModel.selectedObject = parent">
|
||||||
|
</mct-representation>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li ng-if="primaryParents.length > 0">
|
||||||
|
<em>Primary Location </em>
|
||||||
|
<span class="inspector-location"
|
||||||
|
ng-repeat="parent in primaryParents">
|
||||||
<mct-representation key="'label'"
|
<mct-representation key="'label'"
|
||||||
mct-object="parent"
|
mct-object="parent"
|
||||||
ng-model="ngModel"
|
ng-model="ngModel"
|
||||||
|
@ -35,11 +35,13 @@ define(
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ObjectInspectorController($scope) {
|
function ObjectInspectorController($scope, objectService) {
|
||||||
$scope.parents = [];
|
$scope.primaryParents = [];
|
||||||
|
$scope.contextutalParents = [];
|
||||||
|
//$scope.isLink = false;
|
||||||
|
|
||||||
// Gets an array of the parents/anscestors of the selected object
|
// Gets an array of the contextual parents/anscestors of the selected object
|
||||||
function getPath() {
|
function getContextualPath() {
|
||||||
var currentObj = $scope.ngModel.selectedObject,
|
var currentObj = $scope.ngModel.selectedObject,
|
||||||
currentParent,
|
currentParent,
|
||||||
parents = [];
|
parents = [];
|
||||||
@ -53,20 +55,53 @@ define(
|
|||||||
currentObj = currentParent;
|
currentObj = currentParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.parents = parents;
|
$scope.contextutalParents = parents;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets an array of the parents/anscestors of the selected object's
|
||||||
|
// primary location (locational of original non-link)
|
||||||
|
function getPrimaryPath(current) {
|
||||||
|
var location;
|
||||||
|
|
||||||
|
// If this the the initial call of this recursive function
|
||||||
|
if (!current) {
|
||||||
|
current = $scope.ngModel.selectedObject;
|
||||||
|
$scope.primaryParents = [current];
|
||||||
|
}
|
||||||
|
|
||||||
|
location = current.getModel().location;
|
||||||
|
|
||||||
|
if (location && location !== 'root') {
|
||||||
|
objectService.getObjects([location]).then(function (obj) {
|
||||||
|
var next = obj[location];
|
||||||
|
|
||||||
|
$scope.primaryParents.unshift(next);
|
||||||
|
getPrimaryPath(next);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the metadata for the selected object
|
// Gets the metadata for the selected object
|
||||||
function getMetadata() {
|
function getMetadata() {
|
||||||
$scope.metadata = $scope.ngModel.selectedObject &&
|
var sel = $scope.ngModel.selectedObject;
|
||||||
$scope.ngModel.selectedObject.hasCapability('metadata') &&
|
$scope.metadata = sel && sel.hasCapability('metadata') && sel.useCapability('metadata');
|
||||||
$scope.ngModel.selectedObject.useCapability('metadata');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set scope variables when the selected object changes
|
// Set scope variables when the selected object changes
|
||||||
$scope.$watch('ngModel.selectedObject', function () {
|
$scope.$watch('ngModel.selectedObject', function () {
|
||||||
|
var sel = $scope.ngModel.selectedObject;
|
||||||
|
$scope.isLink = sel && sel.hasCapability('location') && sel.getCapability('location').isLink();
|
||||||
|
|
||||||
|
if ($scope.isLink) {
|
||||||
|
getPrimaryPath();
|
||||||
|
getContextualPath();
|
||||||
|
} else {
|
||||||
|
$scope.primaryParents = [];
|
||||||
|
getContextualPath();
|
||||||
|
}
|
||||||
|
|
||||||
getMetadata();
|
getMetadata();
|
||||||
getPath();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user