mirror of
https://github.com/nasa/openmct.git
synced 2025-03-18 10:05:22 +00:00
Suppressed time conductor for realtime
This commit is contained in:
parent
b3981e6158
commit
88f46d0e42
@ -22,22 +22,16 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[
|
||||
"zepto"
|
||||
],
|
||||
function ($) {
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function DemoConductorRepresenter(
|
||||
$q,
|
||||
views,
|
||||
scope,
|
||||
element
|
||||
) {
|
||||
/**
|
||||
* A policy that will test whether a given object OR all of its
|
||||
* support historical telemetry
|
||||
*/
|
||||
function ConductorPolicy($q) {
|
||||
this.$q = $q;
|
||||
this.scope = scope;
|
||||
this.element = element;
|
||||
this.views = views;
|
||||
}
|
||||
|
||||
function fastPromise(value) {
|
||||
@ -55,47 +49,33 @@ define(
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether the given object OR all of its descendants have the
|
||||
* conductor enabled
|
||||
* @param object
|
||||
* @returns {*}
|
||||
* @param {DomainObject} candidate
|
||||
* @returns {Promise} a promise resolved with true if the object
|
||||
* supports historical telemetry
|
||||
*/
|
||||
DemoConductorRepresenter.prototype.showConductor = function (object) {
|
||||
ConductorPolicy.prototype.allow = function (candidate) {
|
||||
var self = this;
|
||||
|
||||
//Does the object itself allow the time conductor?
|
||||
if (object.getModel().showConductor) {
|
||||
return fastPromise(object.getModel().showConductor);
|
||||
if (candidate.hasCapability('telemetry') && candidate.getCapability('telemetry').getMetadata().historical) {
|
||||
return fastPromise(true);
|
||||
} else {
|
||||
//If not, do all of its constituents allow time conductor?
|
||||
if (object.hasCapability('composition')) {
|
||||
return object.useCapability('composition').then(function (composition) {
|
||||
return self.$q.all(composition.map(self.showConductor.bind(self))).then(and);
|
||||
if (candidate.hasCapability('composition')) {
|
||||
return candidate.useCapability('composition').then(function (composition) {
|
||||
if (composition.length === 0 ) {
|
||||
return fastPromise(false);
|
||||
} else {
|
||||
return self.$q.all(composition.map(self.allow.bind(self))).then(and);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//if no, hide time conductor
|
||||
return fastPromise(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param representation
|
||||
* @param representedObject
|
||||
*/
|
||||
DemoConductorRepresenter.prototype.represent = function (representation, representedObject) {
|
||||
if (this.views.indexOf(representation) !== -1) {
|
||||
this.showConductor(representedObject).then(function (show) {
|
||||
if (!show || representation.type === 'folder') {
|
||||
$('.l-time-controller').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
DemoConductorRepresenter.prototype.destroy = function destroy() {
|
||||
|
||||
};
|
||||
|
||||
return DemoConductorRepresenter;
|
||||
});
|
||||
return ConductorPolicy;
|
||||
}
|
||||
);
|
@ -27,15 +27,14 @@ define(
|
||||
"use strict";
|
||||
|
||||
function ConductorServiceDecorator(conductorService) {
|
||||
this.conductorService = conductorService;
|
||||
conductorService.getConductor().displayStart(Date.UTC(2012,8,7));
|
||||
|
||||
return {
|
||||
getConductor: function () {
|
||||
return conductorService.getConductor();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ConductorServiceDecorator.prototype.getConductor = function () {
|
||||
return this.conductorService.getConductor();
|
||||
};
|
||||
|
||||
return ConductorServiceDecorator;
|
||||
}
|
||||
);
|
72
demo/src/conductor/DemoConductorRepresenter.js
Normal file
72
demo/src/conductor/DemoConductorRepresenter.js
Normal file
@ -0,0 +1,72 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[
|
||||
"zepto",
|
||||
"./ConductorPolicy",
|
||||
"../../platform/features/conductor/src/ConductorRepresenter"
|
||||
],
|
||||
function ($, ConductorPolicy, ConductorRepresenter) {
|
||||
"use strict";
|
||||
|
||||
function DemoConductorRepresenter(
|
||||
$q,
|
||||
$compile,
|
||||
conductorService,
|
||||
views,
|
||||
throttle,
|
||||
scope,
|
||||
element
|
||||
) {
|
||||
this.scope = scope;
|
||||
this.element = element;
|
||||
this.views = views;
|
||||
this.conductorPolicy = new ConductorPolicy($q);
|
||||
|
||||
ConductorRepresenter.call(this,
|
||||
throttle,
|
||||
conductorService,
|
||||
$compile,
|
||||
views,
|
||||
scope,
|
||||
element);
|
||||
}
|
||||
|
||||
DemoConductorRepresenter.prototype = Object.create(ConductorRepresenter.prototype);
|
||||
|
||||
DemoConductorRepresenter.prototype.represent = function (representation, representedObject) {
|
||||
var self = this;
|
||||
if (this.views.indexOf(representation) !== -1) {
|
||||
this.conductorPolicy.allow(representedObject).then(function (show) {
|
||||
if (show && representation.type !== 'folder') {
|
||||
ConductorRepresenter.prototype.represent.call(self, representation, representedObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
DemoConductorRepresenter.prototype.destroy = function destroy() {};
|
||||
|
||||
return DemoConductorRepresenter;
|
||||
});
|
54
demo/src/conductor/DemoTelemetryDecorator.js
Normal file
54
demo/src/conductor/DemoTelemetryDecorator.js
Normal file
@ -0,0 +1,54 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define,Promise*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
function DemoTelemetryDecorator(telemetryService) {
|
||||
this.telemetryService = telemetryService;
|
||||
}
|
||||
|
||||
function processRequest(request ) {
|
||||
if (!request.historical) {
|
||||
['start', 'end', 'domain'].forEach(function (attribute){
|
||||
delete request[attribute];
|
||||
});
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
DemoTelemetryDecorator.prototype.requestTelemetry = function (requests) {
|
||||
return this.telemetryService
|
||||
.requestTelemetry(requests.map(processRequest));
|
||||
};
|
||||
|
||||
DemoTelemetryDecorator.prototype.subscribe = function (callback, requests) {
|
||||
return this.telemetryService
|
||||
.subscribe(callback, requests.map(processRequest));
|
||||
};
|
||||
|
||||
return DemoTelemetryDecorator;
|
||||
}
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user