docs: Mission Status and more (#7521)

* chore: update tsconfig to target modern ES

* docs: update UserProvider

* docs: update UserAPI, make openmct private

* docs: update StatusAPI

* refactor: convert ViewRegistry to ES6 class

* docs: finish type imports for openmct api

* docs: minor doc improvements

* docs: add UserIndicator readme

* docs: add User API section to API docs

* docs: document Mission Status

* docs(JSDoc): primitive types should be lowercase, otherwise TitleCase
This commit is contained in:
Jesse Mazzella 2024-03-26 12:11:00 -07:00 committed by GitHub
parent 986da5782b
commit 6e264517f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
55 changed files with 372 additions and 266 deletions

10
API.md
View File

@ -1305,6 +1305,16 @@ View provider Example:
}
```
## User API
Open MCT provides a User API which can be used to define providers for user information. The API
can be used to manage user information and roles.
### Example
Open MCT provides an example [user](example/exampleUser/exampleUserCreator.js) and [user provider](example/exampleUser/ExampleUserProvider.js) which
can be used as a starting point for creating a custom user provider.
## Visibility-Based Rendering in View Providers
To enhance performance and resource efficiency in OpenMCT, a visibility-based rendering feature has been added. This feature is designed to defer the execution of rendering logic for views that are not currently visible. It ensures that views are only updated when they are in the viewport, similar to how modern browsers handle rendering of inactive tabs but optimized for the OpenMCT tabbed display. It also works when views are scrolled outside the viewport (e.g., in a Display Layout).

View File

@ -46,7 +46,7 @@ const TEST_RESULTS_DIR = './test-results';
* Scans for accessibility violations on a page and writes a report to disk if violations are found.
* Automatically asserts that no violations should be present.
*
* @typedef {object} GenerateReportOptions
* @typedef {Object} GenerateReportOptions
* @property {string} [reportName] - The name for the report file.
*
* @param {import('playwright').Page} page - The page object from Playwright.

View File

@ -40,7 +40,7 @@ import { v4 as uuid } from 'uuid';
* @see {@link https://github.com/microsoft/playwright/discussions/11690 Github Discussion}
* @private
* @param {import('@playwright/test').ConsoleMessage} msg
* @returns {String} formatted string with message type, text, url, and line and column numbers
* @returns {string} formatted string with message type, text, url, and line and column numbers
*/
function _consoleMessageToString(msg) {
const { url, lineNumber, columnNumber } = msg.location();

View File

@ -29,7 +29,7 @@ import { expect } from '../pluginFixtures.js';
* for each activity in the plan data per group, using the earliest activity's
* start time as the start bound and the current activity's end time as the end bound.
* @param {import('@playwright/test').Page} page the page
* @param {object} plan The raw plan json to assert against
* @param {Object} plan The raw plan json to assert against
* @param {string} objectUrl The URL of the object to assert against (plan or gantt chart)
*/
export async function assertPlanActivities(page, plan, objectUrl) {
@ -86,7 +86,7 @@ function activitiesWithinTimeBounds(start1, end1, start2, end2) {
* Asserts that the swim lanes / groups in the plan view matches the order of
* groups in the plan data.
* @param {import('@playwright/test').Page} page the page
* @param {object} plan The raw plan json to assert against
* @param {Object} plan The raw plan json to assert against
* @param {string} objectUrl The URL of the object to assert against (plan or gantt chart)
*/
export async function assertPlanOrderedSwimLanes(page, plan, objectUrl) {
@ -110,7 +110,7 @@ export async function assertPlanOrderedSwimLanes(page, plan, objectUrl) {
* Navigate to the plan view, switch to fixed time mode,
* and set the bounds to span all activities.
* @param {import('@playwright/test').Page} page
* @param {object} planJson
* @param {Object} planJson
* @param {string} planObjectUrl
*/
export async function setBoundsToSpanAllActivities(page, planJson, planObjectUrl) {
@ -125,7 +125,7 @@ export async function setBoundsToSpanAllActivities(page, planJson, planObjectUrl
}
/**
* @param {object} planJson
* @param {Object} planJson
* @returns {number}
*/
export function getEarliestStartTime(planJson) {
@ -135,7 +135,7 @@ export function getEarliestStartTime(planJson) {
/**
*
* @param {object} planJson
* @param {Object} planJson
* @returns {number}
*/
export function getLatestEndTime(planJson) {

View File

@ -27,8 +27,8 @@ import { expect } from '../pluginFixtures.js';
* Given a canvas and a set of points, tags the points on the canvas.
* @param {import('@playwright/test').Page} page
* @param {HTMLCanvasElement} canvas a telemetry item with a plot
* @param {Number} xEnd a telemetry item with a plot
* @param {Number} yEnd a telemetry item with a plot
* @param {number} xEnd a telemetry item with a plot
* @param {number} yEnd a telemetry item with a plot
* @returns {Promise}
*/
export async function createTags({ page, canvas, xEnd = 700, yEnd = 520 }) {

View File

@ -773,7 +773,7 @@ async function dragContrastSliderAndAssertFilterValues(page) {
* Gets the filter:brightness value of the current background-image and
* asserts against an expected value
* @param {import('@playwright/test').Page} page
* @param {String} expected The expected brightness value
* @param {string} expected The expected brightness value
*/
async function assertBackgroundImageBrightness(page, expected) {
const backgroundImage = page.locator('.c-imagery__main-image__background-image');
@ -938,7 +938,7 @@ async function buttonZoomOnImageAndAssert(page) {
* Gets the filter:contrast value of the current background-image and
* asserts against an expected value
* @param {import('@playwright/test').Page} page
* @param {String} expected The expected contrast value
* @param {string} expected The expected contrast value
*/
async function assertBackgroundImageContrast(page, expected) {
const backgroundImage = page.locator('.c-imagery__main-image__background-image');

View File

@ -30,23 +30,22 @@ if (document.currentScript) {
}
/**
* @typedef {object} BuildInfo
* @typedef {Object} BuildInfo
* @property {string} version
* @property {string} buildDate
* @property {string} revision
* @property {string} branch
*/
/**
* @typedef {object} OpenMCT
* @typedef {Object} OpenMCT
* @property {BuildInfo} buildInfo
* @property {*} selection
* @property {import('./src/selection/Selection').default} selection
* @property {import('./src/api/time/TimeAPI').default} time
* @property {import('./src/api/composition/CompositionAPI').default} composition
* @property {*} objectViews
* @property {*} inspectorViews
* @property {*} propertyEditors
* @property {*} toolbars
* @property {import('./src/ui/registries/ViewRegistry').default} objectViews
* @property {import('./src/ui/registries/InspectorViewRegistry').default} inspectorViews
* @property {import('./src/ui/registries/ViewRegistry').default} propertyEditors
* @property {import('./src/ui/registries/ToolbarRegistry').default} toolbars
* @property {import('./src/api/types/TypeRegistry').default} types
* @property {import('./src/api/objects/ObjectAPI').default} objects
* @property {import('./src/api/telemetry/TelemetryAPI').default} telemetry
@ -59,7 +58,7 @@ if (document.currentScript) {
* @property {import('./src/api/menu/MenuAPI').default} menus
* @property {import('./src/api/actions/ActionsAPI').default} actions
* @property {import('./src/api/status/StatusAPI').default} status
* @property {*} priority
* @property {import('./src/api/priority/PriorityAPI').default} priority
* @property {import('./src/ui/router/ApplicationRouter')} router
* @property {import('./src/api/faultmanagement/FaultManagementAPI').default} faults
* @property {import('./src/api/forms/FormsAPI').default} forms
@ -74,7 +73,6 @@ if (document.currentScript) {
* @property {OpenMCTPlugin[]} plugins
* @property {OpenMCTComponent[]} components
*/
import { MCT } from './src/MCT.js';
/** @type {OpenMCT} */

View File

@ -74,6 +74,7 @@ import Browse from './ui/router/Browse.js';
* or registering extensions before the application is started.
* @constructor
* @memberof module:openmct
* @extends EventEmitter
*/
export class MCT extends EventEmitter {
constructor() {

View File

@ -23,7 +23,7 @@
let brandingOptions = {};
/**
* @typedef {object} BrandingOptions
* @typedef {Object} BrandingOptions
* @property {string} smallLogoImage URL to the image to use as the applications logo.
* This logo will appear on every screen and when clicked will launch the about dialog.
* @property {string} aboutHtml Custom content for the about screen. When defined the

View File

@ -26,12 +26,12 @@ import { v4 as uuid } from 'uuid';
/**
* @readonly
* @enum {String} AnnotationType
* @property {String} NOTEBOOK The notebook annotation type
* @property {String} GEOSPATIAL The geospatial annotation type
* @property {String} PIXEL_SPATIAL The pixel-spatial annotation type
* @property {String} TEMPORAL The temporal annotation type
* @property {String} PLOT_SPATIAL The plot-spatial annotation type
* @enum {string} AnnotationType
* @property {string} NOTEBOOK The notebook annotation type
* @property {string} GEOSPATIAL The geospatial annotation type
* @property {string} PIXEL_SPATIAL The pixel-spatial annotation type
* @property {string} TEMPORAL The temporal annotation type
* @property {string} PLOT_SPATIAL The plot-spatial annotation type
*/
const ANNOTATION_TYPES = Object.freeze({
NOTEBOOK: 'NOTEBOOK',
@ -47,9 +47,9 @@ const ANNOTATION_LAST_CREATED = 'annotationLastCreated';
/**
* @typedef {Object} Tag
* @property {String} key a unique identifier for the tag
* @property {String} backgroundColor eg. "#cc0000"
* @property {String} foregroundColor eg. "#ffffff"
* @property {string} key a unique identifier for the tag
* @property {string} backgroundColor eg. "#cc0000"
* @property {string} foregroundColor eg. "#ffffff"
*/
/**
@ -112,11 +112,11 @@ export default class AnnotationAPI extends EventEmitter {
/**
* Creates an annotation on a given domain object (e.g., a plot) and a set of targets (e.g., telemetry objects)
* @typedef {Object} CreateAnnotationOptions
* @property {String} name a name for the new annotation (e.g., "Plot annnotation")
* @property {string} name a name for the new annotation (e.g., "Plot annnotation")
* @property {DomainObject} domainObject the domain object this annotation was created with
* @property {ANNOTATION_TYPES} annotationType the type of annotation to create (e.g., PLOT_SPATIAL)
* @property {Tag[]} tags tags to add to the annotation, e.g., SCIENCE for science related annotations
* @property {String} contentText Some text to add to the annotation, e.g. ("This annotation is about science")
* @property {string} contentText Some text to add to the annotation, e.g. ("This annotation is about science")
* @property {Array<Object>} targets The targets ID keystrings and their specific properties.
* For plots, this will be a bounding box, e.g.: {keyString: "d8385009-789d-457b-acc7-d50ba2fd55ea", maxY: 100, minY: 0, maxX: 100, minX: 0}
* For notebooks, this will be an entry ID, e.g.: {entryId: "entry-ecb158f5-d23c-45e1-a704-649b382622ba"}
@ -208,7 +208,7 @@ export default class AnnotationAPI extends EventEmitter {
/**
* @method defineTag
* @param {String} key a unique identifier for the tag
* @param {string} key a unique identifier for the tag
* @param {Tag} tagsDefinition the definition of the tag to add
*/
defineTag(tagKey, tagsDefinition) {
@ -217,7 +217,7 @@ export default class AnnotationAPI extends EventEmitter {
/**
* @method setNamespaceToSaveAnnotations
* @param {String} namespace the namespace to save new annotations to
* @param {string} namespace the namespace to save new annotations to
*/
setNamespaceToSaveAnnotations(namespace) {
this.namespaceToSaveAnnotations = namespace;
@ -226,7 +226,7 @@ export default class AnnotationAPI extends EventEmitter {
/**
* @method isAnnotation
* @param {DomainObject} domainObject the domainObject in question
* @returns {Boolean} Returns true if the domain object is an annotation
* @returns {boolean} Returns true if the domain object is an annotation
*/
isAnnotation(domainObject) {
return domainObject && domainObject.type === ANNOTATION_TYPE;
@ -442,7 +442,7 @@ export default class AnnotationAPI extends EventEmitter {
/**
* @method searchForTags
* @param {String} query A query to match against tags. E.g., "dr" will match the tags "drilling" and "driving"
* @param {string} query A query to match against tags. E.g., "dr" will match the tags "drilling" and "driving"
* @param {Object} [abortController] An optional abort method to stop the query
* @returns {Promise} returns a model of matching tags with their target domain objects attached
*/

View File

@ -33,7 +33,7 @@
*/
/**
* @typedef {object} ListenerMap
* @typedef {Object} ListenerMap
* @property {Array.<any>} add
* @property {Array.<any>} remove
* @property {Array.<any>} load
@ -271,7 +271,7 @@ export default class CompositionCollection {
/**
* Handle reorder from provider.
* @private
* @param {object} reorderMap
* @param {Object} reorderMap
*/
#onProviderReorder(reorderMap) {
this.#emit('reorder', reorderMap);

View File

@ -88,21 +88,21 @@ export default class FaultManagementAPI {
}
/**
* @typedef {object} TriggerValueInfo
* @typedef {Object} TriggerValueInfo
* @property {number} value
* @property {string} rangeCondition
* @property {string} monitoringResult
*/
/**
* @typedef {object} CurrentValueInfo
* @typedef {Object} CurrentValueInfo
* @property {number} value
* @property {string} rangeCondition
* @property {string} monitoringResult
*/
/**
* @typedef {object} Fault
* @typedef {Object} Fault
* @property {boolean} acknowledged
* @property {CurrentValueInfo} currentValueInfo
* @property {string} id
@ -117,7 +117,7 @@ export default class FaultManagementAPI {
*/
/**
* @typedef {object} FaultAPIResponse
* @typedef {Object} FaultAPIResponse
* @property {string} type
* @property {Fault} fault
*/

View File

@ -48,7 +48,7 @@ export default class FormsAPI {
* this formControlViewProvider is used inside form overlay to show/render a form row
*
* @public
* @param {String} controlName a form structure, array of section
* @param {string} controlName a form structure, array of section
* @param {ControlViewProvider} controlViewProvider
*/
addNewFormControl(controlName, controlViewProvider) {
@ -59,7 +59,7 @@ export default class FormsAPI {
* Get a ControlViewProvider for a given/stored form controlName
*
* @public
* @param {String} controlName a form structure, array of section
* @param {string} controlName a form structure, array of section
* @return {ControlViewProvider}
*/
getFormControl(controlName) {
@ -69,7 +69,7 @@ export default class FormsAPI {
/**
* Section definition for formStructure
* @typedef Section
* @property {object} name Name of the section to display on Form
* @property {Object} name Name of the section to display on Form
* @property {string} cssClass class name for styling section
* @property {array<Row>} rows collection of rows inside a section
*/

View File

@ -25,7 +25,7 @@ import Menu, { MENU_PLACEMENT } from './menu.js';
/**
* Popup Menu options
* @typedef {Object} MenuOptions
* @property {String} menuClass Class for popup menu
* @property {string} menuClass Class for popup menu
* @property {MENU_PLACEMENT} placement Placement for menu relative to click
* @property {Function} onDestroy callback function: invoked when menu is destroyed
*/
@ -33,10 +33,10 @@ import Menu, { MENU_PLACEMENT } from './menu.js';
/**
* Popup Menu Item/action
* @typedef {Object} Action
* @property {String} cssClass Class for menu item
* @property {Boolean} isDisabled adds disable class if true
* @property {String} name Menu item text
* @property {String} description Menu item description
* @property {string} cssClass Class for menu item
* @property {boolean} isDisabled adds disable class if true
* @property {string} name Menu item text
* @property {string} description Menu item description
* @property {Function} onItemClicked callback function: invoked when item is clicked
*/

View File

@ -34,7 +34,7 @@ import EventEmitter from 'eventemitter3';
import moment from 'moment';
/**
* @typedef {object} NotificationProperties
* @typedef {Object} NotificationProperties
* @property {function} dismiss Dismiss the notification
* @property {NotificationModel} model The Notification model
* @property {(progressPerc: number, progressText: string) => void} [progress] Update the progress of the notification
@ -45,14 +45,14 @@ import moment from 'moment';
*/
/**
* @typedef {object} NotificationLink
* @typedef {Object} NotificationLink
* @property {function} onClick The function to be called when the link is clicked
* @property {string} cssClass A CSS class name to style the link
* @property {string} text The text to be displayed for the link
*/
/**
* @typedef {object} NotificationOptions
* @typedef {Object} NotificationOptions
* @property {number} [autoDismissTimeout] Milliseconds to wait before automatically dismissing the notification
* @property {boolean} [minimized] Allows for a notification to be minimized into the indicator by default
* @property {NotificationLink} [link] A link for the notification
@ -66,7 +66,7 @@ import moment from 'moment';
* and then minimized to a banner notification if needed, or vice-versa.
*
* @see DialogModel
* @typedef {object} NotificationModel
* @typedef {Object} NotificationModel
* @property {string} message The message to be displayed by the notification
* @property {number | 'unknown'} [progress] The progress of some ongoing task. Should be a number between 0 and 100, or
* with the string literal 'unknown'.

View File

@ -391,7 +391,7 @@ class InMemorySearchProvider {
* Dispatch a search query to the worker and return a queryId.
*
* @private
* @returns {String} a unique query Id for the query.
* @returns {string} a unique query Id for the query.
*/
#dispatchSearchToWorker({ queryId, searchType, query, maxResults }) {
const message = {

View File

@ -34,7 +34,7 @@ import Transaction from './Transaction.js';
/**
* Uniquely identifies a domain object.
*
* @typedef {object} Identifier
* @typedef {Object} Identifier
* @property {string} namespace the namespace to/from which this domain
* object should be loaded/stored.
* @property {string} key a unique identifier for the domain object
@ -51,7 +51,7 @@ import Transaction from './Transaction.js';
* A few common properties are defined for domain objects. Beyond these,
* individual types of domain objects may add more as they see fit.
*
* @typedef {object} DomainObject
* @typedef {Object} DomainObject
* @property {Identifier} identifier a key/namespace pair which
* uniquely identifies this domain object
* @property {string} type the type of domain object
@ -572,8 +572,8 @@ export default class ObjectAPI {
/**
* Return path of telemetry objects in the object composition
* @param {object} identifier the identifier for the domain object to query for
* @param {object} [telemetryIdentifier] the specific identifier for the telemetry
* @param {Object} identifier the identifier for the domain object to query for
* @param {Object} [telemetryIdentifier] the specific identifier for the telemetry
* to look for in the composition, uses first object in composition otherwise
* @returns {Array} path of telemetry object in object composition
*/

View File

@ -107,7 +107,7 @@ class OverlayAPI {
* displaying messages that require the user's
* immediate attention.
* @param {model} options defines options for the dialog
* @returns {object} with an object with a dismiss function that can be called from the calling code
* @returns {Object} with an object with a dismiss function that can be called from the calling code
* to dismiss/destroy the dialog
*
* A description of the model options that may be passed to the
@ -134,7 +134,7 @@ class OverlayAPI {
* Displays a blocking (modal) progress dialog. This dialog can be used for
* displaying messages that require the user's attention, and show progress
* @param {model} options defines options for the dialog
* @returns {object} with an object with a dismiss function that can be called from the calling code
* @returns {Object} with an object with a dismiss function that can be called from the calling code
* to dismiss/destroy the dialog and an updateProgress function that takes progressPercentage(Number 0-100)
* and progressText (string)
*

View File

@ -156,7 +156,7 @@ class BatchingWebSocket extends EventTarget {
}
/**
* @param {Number} maxBatchSize the maximum length of a batch of messages. For example,
* @param {number} maxBatchSize the maximum length of a batch of messages. For example,
* the maximum number of telemetry values to batch before dropping them
* Note that this is a fail-safe that is only invoked if performance drops to the
* point where Open MCT cannot keep up with the amount of telemetry it is receiving.

View File

@ -38,19 +38,19 @@ import TelemetryValueFormatter from './TelemetryValueFormatter.js';
* Describes and bounds requests for telemetry data.
*
* @typedef TelemetryRequestOptions
* @property {String} [sort] the key of the property to sort by. This may
* @property {string} [sort] the key of the property to sort by. This may
* be prefixed with a "+" or a "-" sign to sort in ascending
* or descending order respectively. If no prefix is present,
* ascending order will be used.
* @property {Number} [start] the lower bound for values of the sorting property
* @property {Number} [end] the upper bound for values of the sorting property
* @property {String} [strategy] symbolic identifier for strategies
* @property {number} [start] the lower bound for values of the sorting property
* @property {number} [end] the upper bound for values of the sorting property
* @property {string} [strategy] symbolic identifier for strategies
* (such as `latest` or `minmax`) which may be recognized by providers;
* these will be tried in order until an appropriate provider
* is found
* @property {AbortController} [signal] an AbortController which can be used
* to cancel a telemetry request
* @property {String} [domain] the domain key of the request
* @property {string} [domain] the domain key of the request
* @property {TimeContext} [timeContext] the time context to use for this request
* @memberof module:openmct.TelemetryAPI~
*/
@ -59,7 +59,7 @@ import TelemetryValueFormatter from './TelemetryValueFormatter.js';
* Describes and bounds requests for telemetry data.
*
* @typedef TelemetrySubscriptionOptions
* @property {String} [strategy] symbolic identifier directing providers on how
* @property {string} [strategy] symbolic identifier directing providers on how
* to handle telemetry subscriptions. The default behavior is 'latest' which will
* always return a single telemetry value with each callback, and in the event
* of throttling will always prioritize the latest data, meaning intermediate
@ -936,7 +936,7 @@ export default class TelemetryAPI {
*/
/**
* @typedef {object} LimitsResponseObject
* @typedef {Object} LimitsResponseObject
* @memberof {module:openmct.TelemetryAPI~}
* @property {LimitDefinition} limitLevel the level name and it's limit definition
* @example {
@ -966,7 +966,7 @@ export default class TelemetryAPI {
* @typedef LimitDefinitionValue
* @memberof {module:openmct.TelemetryAPI~}
* @property {string} color color to represent this limit
* @property {Number} value the limit value
* @property {number} value the limit value
*/
/**
@ -1050,9 +1050,9 @@ export default class TelemetryAPI {
*/
/**
* @typedef {object} StalenessResponseObject
* @property {Boolean} isStale boolean representing the staleness state
* @property {Number} timestamp Unix timestamp in milliseconds
* @typedef {Object} StalenessResponseObject
* @property {boolean} isStale boolean representing the staleness state
* @property {number} timestamp Unix timestamp in milliseconds
*/
/**

View File

@ -55,7 +55,7 @@ export default function installWorker() {
/**
* Establish a new WebSocket connection to the given URL
* @param {String} url
* @param {string} url
*/
connect(url) {
this.#wsUrl = url;

View File

@ -62,7 +62,7 @@ class TimeAPI extends GlobalTimeContext {
* another time system might be "sols" for a Martian mission. TimeSystems do
* not address the issue of converting between time systems.
*
* @typedef {object} TimeSystem
* @typedef {Object} TimeSystem
* @property {string} key A unique identifier
* @property {string} name A human-readable descriptor
* @property {string} [cssClass] Specify a css class defining an icon for
@ -95,7 +95,7 @@ class TimeAPI extends GlobalTimeContext {
* Clocks provide a timing source that is used to
* automatically update the time bounds of the data displayed in Open MCT.
*
* @typedef {object} Clock
* @typedef {Object} Clock
* @memberof openmct.timeAPI
* @property {string} key A unique identifier
* @property {string} name A human-readable name. The name will be used to

View File

@ -122,7 +122,7 @@ class TimeContext extends EventEmitter {
* Clock offsets are used to calculate temporal bounds when the system is
* ticking on a clock source.
*
* @typedef {object} ValidationResult
* @typedef {Object} ValidationResult
* @property {boolean} valid Result of the validation - true or false.
* @property {string} message An error message if valid is false.
*/
@ -241,7 +241,7 @@ class TimeContext extends EventEmitter {
* Clock offsets are used to calculate temporal bounds when the system is
* ticking on a clock source.
*
* @typedef {object} ClockOffsets
* @typedef {Object} ClockOffsets
* @property {number} start A time span relative to the current value of the
* ticking clock, from which start bounds will be calculated. This value must
* be < 0. When a clock is active, bounds will be calculated automatically

View File

@ -24,12 +24,12 @@ import Tooltip from './ToolTip.js';
/**
* @readonly
* @enum {String} TooltipLocation
* @property {String} ABOVE The string for locating tooltips above an element
* @property {String} BELOW The string for locating tooltips below an element
* @property {String} RIGHT The pixel-spatial annotation type
* @property {String} LEFT The temporal annotation type
* @property {String} CENTER The plot-spatial annotation type
* @enum {string} TooltipLocation
* @property {string} ABOVE The string for locating tooltips above an element
* @property {string} BELOW The string for locating tooltips below an element
* @property {string} RIGHT The pixel-spatial annotation type
* @property {string} LEFT The temporal annotation type
* @property {string} CENTER The plot-spatial annotation type
*/
const TOOLTIP_LOCATIONS = Object.freeze({
ABOVE: 'above',

View File

@ -21,10 +21,23 @@
*****************************************************************************/
import EventEmitter from 'EventEmitter';
/**
* The StatusAPI is used to get and set various statuses linked to the current logged in user.
* This includes the ability to set the status of the current user as a response to a poll question,
* set the poll question itself, and the ability to set the status of mission actions.
*
* @augments EventEmitter
*/
export default class StatusAPI extends EventEmitter {
/** @type {UserAPI} */
#userAPI;
/** @type {OpenMCT} */
#openmct;
/**
* @param {UserAPI} userAPI
* @param {OpenMCT} openmct
*/
constructor(userAPI, openmct) {
super();
this.#userAPI = userAPI;
@ -64,7 +77,7 @@ export default class StatusAPI extends EventEmitter {
/**
* Set a poll question for operators to respond to. When presented with a status poll question, all operators will reply with their current status.
* @param {String} questionText - The text of the question
* @param {string} questionText - The text of the question
* @returns {Promise<Boolean>} true if operation was successful, otherwise false.
*/
async setPollQuestion(questionText) {
@ -316,7 +329,7 @@ export default class StatusAPI extends EventEmitter {
}
/**
* Private internal function that cannot be made #private because it needs to be registered as a callback to the user provider
* Listen to status events from the UserProvider
* @private
*/
listenToStatusEvents(provider) {
@ -328,6 +341,7 @@ export default class StatusAPI extends EventEmitter {
}
/**
* Emit a status change event
* @private
*/
onProviderStatusChange(newStatus) {
@ -335,6 +349,7 @@ export default class StatusAPI extends EventEmitter {
}
/**
* Emit a poll question change event
* @private
*/
onProviderPollQuestionChange(pollQuestion) {
@ -342,6 +357,7 @@ export default class StatusAPI extends EventEmitter {
}
/**
* Emit a mission action status change event
* @private
*/
onMissionActionStatusChange({ action, status }) {
@ -349,6 +365,14 @@ export default class StatusAPI extends EventEmitter {
}
}
/**
* @typedef {import('./UserAPI').default} UserAPI
*/
/**
* @typedef {import('../../../openmct').OpenMCT} OpenMCT
*/
/**
* @typedef {import('./UserProvider')} UserProvider
*/
@ -360,27 +384,29 @@ export default class StatusAPI extends EventEmitter {
/**
* The PollQuestion type
* @typedef {Object} PollQuestion
* @property {String} question - The question to be presented to users
* @property {Number} timestamp - The time that the poll question was set.
*/
/**
* The MissionStatus type
* @typedef {Object} MissionStatusOption
* @extends {Status}
* @property {String} color A color to be used when displaying the mission status
* @property {string} question - The question to be presented to users
* @property {number} timestamp - The time that the poll question was set.
*/
/**
* @typedef {Object} MissionAction
* @property {String} key A unique identifier for this action
* @property {String} label A human readable label for this action
* @property {string} key A unique identifier for this action
* @property {string} label A human readable label for this action
*/
/**
* The MissionStatusOption type, extends Status.
* @typedef {Object} MissionStatusOption
* @property {string} key - A unique identifier for this status.
* @property {string} label - A human-readable label for this status.
* @property {number} timestamp - The time that the status was set.
* @property {string} color - A color to be used when displaying the mission status.
*/
/**
* The Status type
* @typedef {Object} Status
* @property {String} key - A unique identifier for this status
* @property {String} label - A human readable label for this status
* @property {Number} timestamp - The time that the status was set.
* @property {string} key - A unique identifier for this status
* @property {string} label - A human readable label for this status
* @property {number} timestamp - The time that the status was set.
*/

View File

@ -20,6 +20,9 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
/**
* The example User class.
*/
export default class User {
constructor(id, name) {
this.id = id;

View File

@ -28,6 +28,8 @@ import StoragePersistance from './StoragePersistance.js';
import User from './User.js';
class UserAPI extends EventEmitter {
/** @type {OpenMCT} */
#openmct;
/**
* @param {OpenMCT} openmct
* @param {UserAPIConfiguration} config
@ -35,7 +37,7 @@ class UserAPI extends EventEmitter {
constructor(openmct, config) {
super();
this._openmct = openmct;
this.#openmct = openmct;
this._provider = undefined;
this.User = User;
@ -134,7 +136,7 @@ class UserAPI extends EventEmitter {
/**
* Will return if a role can provide a operator status response
* @memberof module:openmct.UserApi#
* @returns {Boolean}
* @returns {boolean}
*/
canProvideStatusForRole() {
if (!this.hasProvider()) {
@ -166,7 +168,7 @@ class UserAPI extends EventEmitter {
* 'hasRole' method
*
* @memberof module:openmct.UserAPI#
* @returns {Function|Boolean} user provider 'isLoggedIn' method
* @returns {Function|boolean} user provider 'isLoggedIn' method
* @param {string} roleId id of role to check for
* @throws Will throw an error if no user provider is set
*/
@ -201,20 +203,28 @@ class UserAPI extends EventEmitter {
}
export default UserAPI;
/**
* @typedef {String} Role
* @typedef {string} Role
*/
/**
* @typedef {Object} OpenMCT
* @typedef {import('../../../openmct.js').OpenMCT} OpenMCT
*/
/**
* @typedef {{statusStyles: Object.<string, StatusStyleDefinition>}} UserAPIConfiguration
*/
/**
* @typedef {Object} StatusStyleDefinition
* @property {String} iconClass The icon class to apply to the status indicator when this status is active "icon-circle-slash",
* @property {String} iconClassPoll The icon class to apply to the poll question indicator when this style is active eg. "icon-status-poll-question-mark"
* @property {String} statusClass The class to apply to the indicator when this status is active eg. "s-status-error"
* @property {String} statusBgColor The background color to apply in the status summary section of the poll question popup for this status eg."#9900cc"
* @property {String} statusFgColor The foreground color to apply in the status summary section of the poll question popup for this status eg. "#fff"
* @property {string} iconClass The icon class to apply to the status indicator when this status is active "icon-circle-slash",
* @property {string} iconClassPoll The icon class to apply to the poll question indicator when this style is active eg. "icon-status-poll-question-mark"
* @property {string} statusClass The class to apply to the indicator when this status is active eg. "s-status-error"
* @property {string} statusBgColor The background color to apply in the status summary section of the poll question popup for this status eg."#9900cc"
* @property {string} statusFgColor The foreground color to apply in the status summary section of the poll question popup for this status eg. "#fff"
*/
/**
* @typedef {Object} UserProvider
*/

View File

@ -19,18 +19,24 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/**
* A user provider is responsible for providing information about the currently
* logged in user. This includes information about the user's roles, and whether
* the user is currently logged in.
*/
export default class UserProvider {
/**
* @returns {Promise<User>} A promise that resolves with the currently logged in user
*/
getCurrentUser() {}
/**
* @returns {Boolean} true if a user is currently logged in, otherwise false
* @returns {boolean} true if a user is currently logged in, otherwise false
*/
isLoggedIn() {}
/**
* @param {String} role
* @returns {Promise<Boolean>} true if the current user has the given role
* @param {string} role
* @returns {Promise<boolean>} true if the current user has the given role
*/
hasRole(role) {}
}

View File

@ -43,7 +43,7 @@ class ImageExporter {
* Converts an HTML element into a PNG or JPG Blob.
* @private
* @param {node} element that will be converted to an image
* @param {object} options Image options.
* @param {Object} options Image options.
* @returns {promise}
*/
renderElement(element, { imageType, className, thumbnailSize }) {

View File

@ -23,7 +23,7 @@
import { ACTIVITY_STATES_KEY } from './createActivityStatesIdentifier.js';
/**
* @typedef {object} ActivityStatesInterceptorOptions
* @typedef {Object} ActivityStatesInterceptorOptions
* @property {import('../../api/objects/ObjectAPI').Identifier} identifier the {namespace, key} to use for the activity states object.
* @property {string} name The name of the activity states model.
* @property {number} priority the priority of the interceptor. By default, it is low.
@ -34,7 +34,7 @@ import { ACTIVITY_STATES_KEY } from './createActivityStatesIdentifier.js';
* This will only get invoked when an attempt is made to save the state for an activity and no activity states object exists in the store.
* @param {import('../../../openmct').OpenMCT} openmct
* @param {ActivityStatesInterceptorOptions} options
* @returns {object}
* @returns {Object}
*/
const ACTIVITY_STATES_TYPE = 'activity-states';

View File

@ -45,7 +45,7 @@ export default function AutoflowTabularController(domainObject, data, openmct) {
/**
* Set the "Last Updated" value to be displayed.
* @param {String} value the value to display
* @param {string} value the value to display
* @private
*/
AutoflowTabularController.prototype.trackLastUpdated = function (value) {

View File

@ -39,7 +39,7 @@
* with the mouse while the horizontal dimensions shrink in
* kind (and vertical properties remain unmodified.)
*
* @param {object} rawPosition the initial position/dimensions
* @param {Object} rawPosition the initial position/dimensions
* of the frame being interacted with
* @param {number[]} posFactor the position factor
* @param {number[]} dimFactor the dimensions factor

View File

@ -59,7 +59,7 @@ export default class ExportAsJSONAction {
// Public
/**
*
* @param {object} objectPath
* @param {Object} objectPath
* @returns {boolean}
*/
appliesTo(objectPath) {
@ -191,9 +191,9 @@ export default class ExportAsJSONAction {
/**
* @private
* @param {object} child
* @param {object} parent
* @returns {object}
* @param {Object} child
* @param {Object} parent
* @returns {Object}
*/
#rewriteLink(child, parent) {
const originalKeyString = this.#getKeystring(child);
@ -266,7 +266,7 @@ export default class ExportAsJSONAction {
/**
* @private
* @param {object} domainObject
* @param {Object} domainObject
* @returns {string} A string representation of the given identifier, including namespace and key
*/
#getKeystring(domainObject) {
@ -275,7 +275,7 @@ export default class ExportAsJSONAction {
/**
* @private
* @param {object} domainObject
* @param {Object} domainObject
* @returns {boolean}
*/
#isCreatableAndPersistable(domainObject) {
@ -287,8 +287,8 @@ export default class ExportAsJSONAction {
/**
* @private
* @param {object} child
* @param {object} parent
* @param {Object} child
* @param {Object} parent
* @returns {boolean}
*/
#isLinkedObject(child, parent) {
@ -376,14 +376,14 @@ export default class ExportAsJSONAction {
}
/**
* @private
* @param {object} completedTree
* @param {Object} completedTree
*/
saveAs(completedTree) {
this.JSONExportService.export(completedTree, { filename: this.root.name + '.json' });
}
/**
* @private
* @returns {object}
* @returns {Object}
*/
#wrapTree() {
return {

View File

@ -39,7 +39,7 @@ export default class ImportAsJSONAction {
// Public
/**
*
* @param {object} objectPath
* @param {Object} objectPath
* @returns {boolean}
*/
appliesTo(objectPath) {
@ -58,15 +58,15 @@ export default class ImportAsJSONAction {
}
/**
*
* @param {object} objectPath
* @param {Object} objectPath
*/
invoke(objectPath) {
this._showForm(objectPath[0]);
}
/**
*
* @param {object} object
* @param {object} changes
* @param {Object} object
* @param {Object} changes
*/
onSave(object, changes) {
@ -79,9 +79,9 @@ export default class ImportAsJSONAction {
/**
* @private
* @param {object} parent
* @param {object} tree
* @param {object} seen
* @param {Object} parent
* @param {Object} tree
* @param {Object} seen
* @param {Array} objectsToCreate tracks objects from import json that will need to be created
*/
_deepInstantiate(parent, tree, seen, objectsToCreate) {
@ -112,7 +112,7 @@ export default class ImportAsJSONAction {
/**
* @private
* @param {object} parent
* @param {Object} parent
* @returns [identifiers]
*/
_getObjectReferenceIds(parent) {
@ -146,9 +146,9 @@ export default class ImportAsJSONAction {
}
/**
* @private
* @param {object} tree
* @param {Object} tree
* @param {string} namespace
* @returns {object}
* @returns {Object}
*/
_generateNewIdentifiers(tree, newNamespace) {
// For each domain object in the file, generate new ID, replace in tree
@ -166,8 +166,8 @@ export default class ImportAsJSONAction {
}
/**
* @private
* @param {object} domainObject
* @param {object} objTree
* @param {Object} domainObject
* @param {Object} objTree
*/
async _importObjectTree(domainObject, objTree) {
const objectsToCreate = [];
@ -211,18 +211,18 @@ export default class ImportAsJSONAction {
}
/**
* @private
* @param {object} model
* @returns {object}
* @param {Object} model
* @returns {Object}
*/
_instantiate(model) {
return this.openmct.objects.save(model);
}
/**
* @private
* @param {object} oldId
* @param {object} newId
* @param {object} tree
* @returns {object}
* @param {Object} oldId
* @param {Object} newId
* @param {Object} tree
* @returns {Object}
*/
_rewriteId(oldId, newId, tree) {
let newIdKeyString = this.openmct.objects.makeKeyString(newId);
@ -256,7 +256,7 @@ export default class ImportAsJSONAction {
}
/**
* @private
* @param {object} domainObject
* @param {Object} domainObject
*/
_showForm(domainObject) {
const formStructure = {
@ -285,7 +285,7 @@ export default class ImportAsJSONAction {
}
/**
* @private
* @param {object} data
* @param {Object} data
* @returns {boolean}
*/
_validateJSON(data) {

View File

@ -30,7 +30,7 @@
* @memberof platform/persistence/couch
* @constructor
* @param {string} id the id under which to store this mode
* @param {object} model the model to store
* @param {Object} model the model to store
* @param {string} rev the revision to include (or undefined,
* if no revision should be noted for couch)
* @param {boolean} whether or not to mark this document as

View File

@ -30,11 +30,11 @@ import PlanViewProvider from './PlanViewProvider.js';
const ACTIVITY_STATES_DEFAULT_NAME = 'Activity States';
/**
* @typedef {object} PlanOptions
* @typedef {Object} PlanOptions
* @property {boolean} creatable true/false to allow creation of a plan via the Create menu.
* @property {string} name The name of the activity states model.
* @property {string} namespace the namespace to use for the activity states object.
* @property {Number} priority the priority of the interceptor. By default, it is low.
* @property {number} priority the priority of the interceptor. By default, it is low.
*/
/**

View File

@ -22,15 +22,15 @@
/**
* The SourceMap allows mapping specific implementations of plan domain objects to those expected by Open MCT.
* @typedef {object} SourceMapOption
* @typedef {Object} SourceMapOption
* @property {string} orderedGroups the property of the plan that lists groups/swim lanes specifying what order they will be displayed in Open MCT.
* @property {string} activities the property of the plan that has the list of activities to be displayed.
* @property {string} groupId the property of the activity that maps to the group/swim lane it should be displayed in.
* @property {string} start The start time property of the activity
* @property {string} end The end time property of the activity
* @property {string} id The unique id of the activity. This is required to allow setting activity states
* @property {object} displayProperties a list of key: value pairs that specifies which properties of the activity should be displayed when it is selected. Ex. {'location': 'Location', 'metadata.length_in_meters', 'Length (meters)'}
* @property {object} filterMetadata a list of strings that specifies which properties of the activity be included for filtering. Ex. {'description','properties.length_in_meters'}
* @property {Object} displayProperties a list of key: value pairs that specifies which properties of the activity should be displayed when it is selected. Ex. {'location': 'Location', 'metadata.length_in_meters', 'Length (meters)'}
* @property {Object} filterMetadata a list of strings that specifies which properties of the activity be included for filtering. Ex. {'description','properties.length_in_meters'}
*/
import _ from 'lodash';

View File

@ -22,8 +22,8 @@
import Model from './Model.js';
/**
* @template {object} T
* @template {object} O
* @template {Object} T
* @template {Object} O
* @extends {Model<T, O>}
*/
export default class Collection extends Model {

View File

@ -26,8 +26,8 @@ import _ from 'lodash';
import eventHelpers from '../lib/eventHelpers.js';
/**
* @template {object} T
* @template {object} O
* @template {Object} T
* @template {Object} O
*/
export default class Model extends EventEmitter {
/**
@ -144,15 +144,15 @@ export default class Model extends EventEmitter {
*/
/**
@template {object} T
@template {Object} T
@typedef {{
id?: string
} & T} ModelType
*/
/**
@template {object} T
@template {object} O
@template {Object} T
@template {Object} O
@typedef {{
model?: ModelType<T>
models?: T[]

View File

@ -422,7 +422,7 @@ export default class PlotSeries extends Model {
*
* @private
* @param {Object} newData a telemetry datum.
* @param {Boolean} [sorted] default false, if true will append
* @param {boolean} [sorted] default false, if true will append
* a point to the end without dupe checking.
*/
add(newData, sorted = false) {

View File

@ -302,7 +302,7 @@ export default class YAxisModel extends Model {
* For a given series collection, get the metadata of the current yKey for each series.
* Then return first available value of the given property from the metadata.
* @param {import('./SeriesCollection').default} series
* @param {String} property
* @param {string} property
*/
getMetadataValueByProperty(series, property) {
return series

View File

@ -315,9 +315,9 @@ export default {
},
/**
* @typedef {Object} PlotYTickData
* @property {Number} leftTickWidth the width of the ticks for all the y axes on the left of the plot.
* @property {Number} rightTickWidth the width of the ticks for all the y axes on the right of the plot.
* @property {Boolean} hasMultipleLeftAxes whether or not there is more than one left y axis.
* @property {number} leftTickWidth the width of the ticks for all the y axes on the left of the plot.
* @property {number} rightTickWidth the width of the ticks for all the y axes on the right of the plot.
* @property {boolean} hasMultipleLeftAxes whether or not there is more than one left y axis.
*/
onYTickWidthChange(data, plotId) {
if (!Object.prototype.hasOwnProperty.call(this.tickWidthMap, plotId)) {

View File

@ -464,7 +464,7 @@ ConditionEvaluator.prototype.getInputTypeById = function (dataType) {
/**
* Set the test data cache used by this rule evaluator
* @param {object} testCache A mock cache following the format of the real
* @param {Object} testCache A mock cache following the format of the real
* subscription cache
*/
ConditionEvaluator.prototype.setTestDataCache = function (testCache) {

View File

@ -241,7 +241,7 @@ ConditionManager.prototype.onCompositionAdd = function (obj) {
/**
* Invoked on a remove event in this Summary Widget's composition. Removes
* the object from the local composition, and untracks it
* @param {object} identifier The identifier of the object to be removed
* @param {Object} identifier The identifier of the object to be removed
* @private
*/
ConditionManager.prototype.onCompositionRemove = function (identifier) {

View File

@ -377,7 +377,7 @@ SummaryWidget.prototype.reorder = function (event) {
/**
* Apply a list of css properties to an element
* @param {element} elem The DOM element to which the rules will be applied
* @param {object} style an object representing the style
* @param {Object} style an object representing the style
*/
SummaryWidget.prototype.applyStyle = function (elem, style) {
Object.keys(style).forEach(function (propId) {

View File

@ -8,7 +8,7 @@ import ObjectSelect from './input/ObjectSelect.js';
/**
* An object representing a single mock telemetry value
* @param {object} itemConfig the configuration for this item, consisting of
* @param {Object} itemConfig the configuration for this item, consisting of
* object, key, and value fields
* @param {number} index the index of this TestDataItem object in the data
* model of its parent {TestDataManager} o be injected into callbacks

View File

@ -268,7 +268,7 @@ export default class TableRowCollection extends EventEmitter {
* collection.sort("timestamp.text");
*
*
* @param {object} sortOptions An object specifying a sort key, and direction.
* @param {Object} sortOptions An object specifying a sort key, and direction.
*/
sortBy(sortOptions) {
if (arguments.length > 0) {

View File

@ -0,0 +1,55 @@
# User Indicator
This plugin provides a user indicator for the top status bar that displays user information as
defined by a User Provider. A User Provider must be registered as a prerequisite for this plugin.
If the User Provider supports role-based access control, the user indicator will display the user's
current role and, if the user has multiple roles, allow the user to switch between them.
## Usage
To use this plugin, first register a custom User Provider with the `openmct` API, or install the example
User Provider plugin:
```javascript
openmct.install(openmct.plugins.example.ExampleUser());
```
Then, install the User Indicator plugin:
```javascript
openmct.install(openmct.plugins.UserIndicator());
```
## Configuration
The User Indicator plugin does not require any configuration itself.
## Mission Status
"Mission Status" is a feature that is used to indicate the current state of a mission with regards to
one or more "Mission Actions". A mission action defines a verb that may be, for example, a task
for a spacecraft (such as "Drive" or "Imagery"), a change in the state of a ground system, or any
other event that is relevant to the mission. Example states for a mission action might include
"Go" or "No Go", indicating whether a particular action is currently cleared for execution.
A user with the appropriate permissions may set the mission status by clicking on either the
User Indicator itself, or the "Mission Status" button next to the User Indicator. This will
open a dialog that allows the user to set the status of each mission action.
### Provider Configuration
In order to use the Mission Status feature, a registered User Provider must define the following
methods:
* `canSetMissionStatus`: A method that returns a boolean indicating whether the current user has
permission to set the mission status.
* `getPossibleMissionActions`: A method that returns an array of mission actions that the user
may set the status of. Each mission action should have a `key` and a `name` property.
* `getPossibleMissionActionStatuses`: A method that returns an array of `MissionStatusOption` objects,
which define the possible statuses for each mission action.
* `getStatusForMissionAction`: A method that returns the current status for a given mission action.
* `setStatusForMissionAction`: A method that sets the status for a given mission action.
The [Example User Provider](../../../example/exampleUser/ExampleUserProvider.js) provides an example
implementation of these methods.

View File

@ -63,8 +63,7 @@ export default class Selection extends EventEmitter {
* Selects the selectable object and emits the 'change' event.
*
* @param {Selectable|Selectable[]} selectable An object or array of objects with element and context properties
* @param {object} selectable an object with element and context properties
* @param {Boolean} isMultiSelectEvent flag indication shift key is pressed or not
* @param {boolean} isMultiSelectEvent flag indication shift key is pressed or not
* @private
*/
select(selectable, isMultiSelectEvent) {

View File

@ -140,7 +140,7 @@ export default {
* @param {import('../../api/objects/ObjectAPI').DomainObject[]} objectPath
*/
navigateToPath(objectPath) {
/** @type {String} */
/** @type {string} */
const path = `/browse/${this.openmct.objects.getRelativePath(objectPath)}`;
return path.replace('ROOT/', '');

View File

@ -36,7 +36,7 @@ export default class InspectorViewRegistry {
/**
*
* @param {object} selection the object to be viewed
* @param {Object} selection the object to be viewed
* @returns {module:openmct.InspectorViewRegistry[]} any providers
* which can provide views of this object
* @private for platform-internal use

View File

@ -33,7 +33,7 @@ export default function ToolbarRegistry() {
/**
* Gets toolbar controls from providers which can provide a toolbar for this selection.
*
* @param {object} selection the selection object
* @param {Object} selection the selection object
* @returns {Object[]} an array of objects defining controls for the toolbar
* @private for platform-internal use
*/
@ -112,6 +112,6 @@ ToolbarRegistry.prototype.addProvider = function (provider) {
*
* @method toolbar
* @memberof module:openmct.ToolbarProvider#
* @param {object} selection the selection object
* @param {Object} selection the selection object
* @returns {Object[]} an array of objects defining controls for the toolbar.
*/

View File

@ -30,97 +30,93 @@ const DEFAULT_VIEW_PRIORITY = 100;
* @interface ViewRegistry
* @memberof module:openmct
*/
export default function ViewRegistry() {
EventEmitter.apply(this);
this.providers = {};
}
ViewRegistry.prototype = Object.create(EventEmitter.prototype);
/**
* @private for platform-internal use
* @param {*} item the object to be viewed
* @param {array} objectPath - The current contextual object path of the view object
* eg current domainObject is located under MyItems which is under Root
* @returns {module:openmct.ViewProvider[]} any providers
* which can provide views of this object
*/
ViewRegistry.prototype.get = function (item, objectPath) {
if (objectPath === undefined) {
throw 'objectPath must be provided to get applicable views for an object';
export default class ViewRegistry extends EventEmitter {
constructor() {
super();
EventEmitter.apply(this);
this.providers = {};
}
/**
* @private for platform-internal use
* @param {*} item the object to be viewed
* @param {array} objectPath - The current contextual object path of the view object
* eg current domainObject is located under MyItems which is under Root
* @returns {module:openmct.ViewProvider[]} any providers
* which can provide views of this object
*/
get(item, objectPath) {
if (objectPath === undefined) {
throw 'objectPath must be provided to get applicable views for an object';
}
function byPriority(providerA, providerB) {
let priorityA = providerA.priority ? providerA.priority(item) : DEFAULT_VIEW_PRIORITY;
let priorityB = providerB.priority ? providerB.priority(item) : DEFAULT_VIEW_PRIORITY;
function byPriority(providerA, providerB) {
let priorityA = providerA.priority ? providerA.priority(item) : DEFAULT_VIEW_PRIORITY;
let priorityB = providerB.priority ? providerB.priority(item) : DEFAULT_VIEW_PRIORITY;
return priorityB - priorityA;
return priorityB - priorityA;
}
return this.getAllProviders()
.filter(function (provider) {
return provider.canView(item, objectPath);
})
.sort(byPriority);
}
return this.getAllProviders()
.filter(function (provider) {
return provider.canView(item, objectPath);
})
.sort(byPriority);
};
/**
* @private
*/
ViewRegistry.prototype.getAllProviders = function () {
return Object.values(this.providers);
};
/**
* Register a new type of view.
*
* @param {module:openmct.ViewProvider} provider the provider for this view
* @method addProvider
* @memberof module:openmct.ViewRegistry#
*/
ViewRegistry.prototype.addProvider = function (provider) {
const key = provider.key;
if (key === undefined) {
throw "View providers must have a unique 'key' property defined";
/**
* @private
*/
getAllProviders() {
return Object.values(this.providers);
}
/**
* Register a new type of view.
*
* @param {module:openmct.ViewProvider} provider the provider for this view
* @method addProvider
* @memberof module:openmct.ViewRegistry#
*/
addProvider(provider) {
const key = provider.key;
if (key === undefined) {
throw "View providers must have a unique 'key' property defined";
}
if (this.providers[key] !== undefined) {
console.warn("Provider already defined for key '%s'. Provider keys must be unique.", key);
}
if (this.providers[key] !== undefined) {
console.warn(`Provider already defined for key '${key}'. Provider keys must be unique.`);
}
const wrappedView = provider.view.bind(provider);
provider.view = (domainObject, objectPath) => {
const viewObject = wrappedView(domainObject, objectPath);
const wrappedShow = viewObject.show.bind(viewObject);
viewObject.key = key; // provide access to provider key on view object
viewObject.show = (element, isEditing, viewOptions) => {
viewObject.parentElement = element.parentElement;
wrappedShow(element, isEditing, viewOptions);
const wrappedView = provider.view.bind(provider);
provider.view = (domainObject, objectPath) => {
const viewObject = wrappedView(domainObject, objectPath);
const wrappedShow = viewObject.show.bind(viewObject);
viewObject.key = key; // provide access to provider key on view object
viewObject.show = (element, isEditing, viewOptions) => {
viewObject.parentElement = element.parentElement;
wrappedShow(element, isEditing, viewOptions);
};
return viewObject;
};
return viewObject;
};
this.providers[key] = provider;
};
/**
* @private
*/
ViewRegistry.prototype.getByProviderKey = function (key) {
return this.providers[key];
};
/**
* Used internally to support seamless usage of new views with old
* views.
* @private
*/
ViewRegistry.prototype.getByVPID = function (vpid) {
return this.providers.filter(function (p) {
return p.vpid === vpid;
})[0];
};
this.providers[key] = provider;
}
/**
* @private
*/
getByProviderKey(key) {
return this.providers[key];
}
/**
* Used internally to support seamless usage of new views with old
* views.
* @private
*/
getByVPID(vpid) {
return this.providers.filter(function (p) {
return p.vpid === vpid;
})[0];
}
}
/**
* A View is used to provide displayable content, and to react to
@ -248,7 +244,7 @@ ViewRegistry.prototype.getByVPID = function (vpid) {
* Provide a view of this object.
*
* When called by Open MCT, the following arguments will be passed to it:
* @param {object} domainObject - the domainObject that the view is provided for
* @param {Object} domainObject - the domainObject that the view is provided for
* @param {array} objectPath - The current contextual object path of the view object
* eg current domainObject is located under MyItems which is under Root
*

View File

@ -89,7 +89,7 @@ class ApplicationRouter extends EventEmitter {
* @property {URL} url current url location
* @property {string} path current url location pathname
* @property {string} getQueryString a function which returns url search query
* @property {object} params object representing url searchParams
* @property {Object} params object representing url searchParams
*/
/**
@ -113,7 +113,7 @@ class ApplicationRouter extends EventEmitter {
/**
* Get current location URL Object searchParams
*
* @returns {object} object representing current url searchParams
* @returns {Object} object representing current url searchParams
*/
getParams() {
return this.currentLocation.params;
@ -143,7 +143,7 @@ class ApplicationRouter extends EventEmitter {
*
* @param {Array<Object>} objectPath Object path of a given Domain Object
*
* @returns {Boolean}
* @returns {boolean}
*/
isNavigatedObject(objectPath) {
let targetObject = objectPath[0];
@ -329,8 +329,8 @@ class ApplicationRouter extends EventEmitter {
* @private
* Compare new and old params and on change emit event 'change:params'
*
* @param {object} newParams new params of url
* @param {object} oldParams old params of url
* @param {Object} newParams new params of url
* @param {Object} oldParams old params of url
* @returns {boolean} true if params changed, false otherwise
*/
doParamsChange(newParams, oldParams) {

View File

@ -13,10 +13,12 @@
"strict": true,
"esModuleInterop": true,
"noImplicitOverride": true,
"noImplicitAny": false,
"module": "esnext",
"moduleResolution": "node",
"outDir": "dist",
"skipLibCheck": true,
"target": "ES2015",
"paths": {
// matches the alias in webpack config, so that types for those imports are visible.
"@/*": ["src/*"]