openmct/example/exampleUser/ExampleUserProvider.js

279 lines
6.8 KiB
JavaScript
Raw Permalink Normal View History

/*****************************************************************************
* Open MCT, Copyright (c) 2014-2024, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
import { EventEmitter } from 'eventemitter3';
2022-05-25 21:09:08 +00:00
import { v4 as uuid } from 'uuid';
import createExampleUser from './exampleUserCreator.js';
const STATUSES = [
{
key: 'NO_STATUS',
label: 'Not set',
iconClass: 'icon-question-mark',
iconClassPoll: 'icon-status-poll-question-mark'
},
{
key: 'GO',
label: 'Go',
iconClass: 'icon-check',
iconClassPoll: 'icon-status-poll-question-mark',
statusClass: 's-status-ok',
statusBgColor: '#33cc33',
statusFgColor: '#000'
},
{
key: 'MAYBE',
label: 'Maybe',
iconClass: 'icon-alert-triangle',
iconClassPoll: 'icon-status-poll-question-mark',
statusClass: 's-status-warning',
statusBgColor: '#ffb66c',
statusFgColor: '#000'
},
{
key: 'NO_GO',
label: 'No go',
iconClass: 'icon-circle-slash',
iconClassPoll: 'icon-status-poll-question-mark',
statusClass: 's-status-error',
statusBgColor: '#9900cc',
statusFgColor: '#fff'
}
];
const MISSION_STATUSES = [
{
key: 0,
label: 'NO GO'
},
{
key: 1,
label: 'GO'
}
];
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
/**
* @implements {StatusUserProvider}
*/
export default class ExampleUserProvider extends EventEmitter {
#actionToStatusMap;
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
constructor(
openmct,
{ statusRoles } = {
statusRoles: []
}
) {
super();
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
this.openmct = openmct;
this.#actionToStatusMap = {
Imagery: MISSION_STATUSES[0],
Commanding: MISSION_STATUSES[0],
Driving: MISSION_STATUSES[0]
};
this.user = undefined;
this.loggedIn = false;
this.autoLoginUser = undefined;
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
this.statusRoleValues = statusRoles.map((role) => ({
role: role,
status: STATUSES[0]
}));
this.pollQuestion = undefined;
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
this.statusRoles = statusRoles;
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
this.ExampleUser = createExampleUser(this.openmct.user.User);
this.loginPromise = undefined;
}
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
isLoggedIn() {
return this.loggedIn;
}
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
autoLogin(username) {
this.autoLoginUser = username;
}
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
getCurrentUser() {
if (!this.loginPromise) {
this.loginPromise = this._login().then(() => this.user);
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
}
return this.loginPromise;
}
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
canProvideStatusForRole(role) {
return this.statusRoles.includes(role);
}
canSetPollQuestion() {
return Promise.resolve(true);
}
feat: Mission Status for Situational Awareness (#7418) * refactor: `UserIndicator` use vue component directly * style(WIP): filler styles for user-indicator * feat(WIP): working on mission status indicators * feat: support mission statuses * feat(WIP): can display mission statuses now * feat(WIP): add composables and dynamically calculate popup position * feat(WIP): dismissible popup, use moar compositionAPI * Closes #7420 - Styling and markup for mission status control panel. - Tweaks and additions to some common style elements. * feat: set/unset mission status for role * refactor: rename some functions * feat: more renaming, get mission role statuses working * refactor: more method renaming * fix: remove dupe method * feat: hook up event listeners * refactor: convert to CompositionAPI and listen to events * fix: add that back in, woops * test: fix some existing tests * lint: words for the word god * refactor: rename * fix: setting mission statuses * style: fix go styling * style: add mission status button * refactor: rename `MissionRole` -> `MissionAction` * test: fix most existing tests * test: remove integration tests already covered by e2e - These tests are going to be wonky since they depend on the View. Any unit tests depending on Vue / the View will become increasingly volatile over time as we migrate more of the app into the main Vue app. Since these LOC are already covered by e2e, I'm going to remove them. We will need to move towards a more component / Vue-friendly testing framework to stabilize all of this. * docs: add documentation * refactor: rename * fix: a comma * refactor: a word * fix: emit parameter format * fix: correct emit for `missionStatusActionChange` --------- Co-authored-by: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Co-authored-by: John Hill <john.c.hill@nasa.gov>
2024-02-02 22:50:16 +00:00
canSetMissionStatus() {
return Promise.resolve(true);
feat: Mission Status for Situational Awareness (#7418) * refactor: `UserIndicator` use vue component directly * style(WIP): filler styles for user-indicator * feat(WIP): working on mission status indicators * feat: support mission statuses * feat(WIP): can display mission statuses now * feat(WIP): add composables and dynamically calculate popup position * feat(WIP): dismissible popup, use moar compositionAPI * Closes #7420 - Styling and markup for mission status control panel. - Tweaks and additions to some common style elements. * feat: set/unset mission status for role * refactor: rename some functions * feat: more renaming, get mission role statuses working * refactor: more method renaming * fix: remove dupe method * feat: hook up event listeners * refactor: convert to CompositionAPI and listen to events * fix: add that back in, woops * test: fix some existing tests * lint: words for the word god * refactor: rename * fix: setting mission statuses * style: fix go styling * style: add mission status button * refactor: rename `MissionRole` -> `MissionAction` * test: fix most existing tests * test: remove integration tests already covered by e2e - These tests are going to be wonky since they depend on the View. Any unit tests depending on Vue / the View will become increasingly volatile over time as we migrate more of the app into the main Vue app. Since these LOC are already covered by e2e, I'm going to remove them. We will need to move towards a more component / Vue-friendly testing framework to stabilize all of this. * docs: add documentation * refactor: rename * fix: a comma * refactor: a word * fix: emit parameter format * fix: correct emit for `missionStatusActionChange` --------- Co-authored-by: Charles Hacskaylo <charles.f.hacskaylo@nasa.gov> Co-authored-by: John Hill <john.c.hill@nasa.gov>
2024-02-02 22:50:16 +00:00
}
hasRole(roleId) {
if (!this.loggedIn) {
Promise.resolve(undefined);
}
return Promise.resolve(this.user.getRoles().includes(roleId));
}
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
getPossibleRoles() {
return this.user.getRoles();
}
getPossibleMissionActions() {
return Promise.resolve(Object.keys(this.#actionToStatusMap));
}
getPossibleMissionActionStatuses() {
return Promise.resolve(MISSION_STATUSES);
}
getStatusForMissionAction(action) {
return Promise.resolve(this.#actionToStatusMap[action]);
}
setStatusForMissionAction(action, status) {
this.#actionToStatusMap[action] = status;
this.emit('missionStatusChange', {
action,
status
});
return true;
}
getAllStatusRoles() {
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
return Promise.resolve(this.statusRoles);
}
getStatusForRole(role) {
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
const statusForRole = this.statusRoleValues.find((statusRole) => statusRole.role === role);
return Promise.resolve(statusForRole?.status);
}
async getDefaultStatusForRole(role) {
const allRoles = await this.getPossibleStatuses();
return allRoles?.[0];
}
setStatusForRole(role, status) {
status.timestamp = Date.now();
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
const matchingIndex = this.statusRoleValues.findIndex((statusRole) => statusRole.role === role);
this.statusRoleValues[matchingIndex].status = status;
this.emit('statusChange', {
role,
status
});
return true;
}
// eslint-disable-next-line require-await
async getPollQuestion() {
if (this.pollQuestion) {
return this.pollQuestion;
} else {
return undefined;
}
}
setPollQuestion(pollQuestion) {
if (!pollQuestion) {
// If the poll question is undefined, set it to a blank string.
// This behavior better reflects how other telemetry systems
// deal with undefined poll questions.
pollQuestion = '';
}
this.pollQuestion = {
question: pollQuestion,
timestamp: Date.now()
};
this.emit('pollQuestionChange', this.pollQuestion);
return true;
}
getPossibleStatuses() {
return Promise.resolve(STATUSES);
}
_login() {
const id = uuid();
// for testing purposes, this will skip the form, this wouldn't be used in
// a normal authentication process
if (this.autoLoginUser) {
Role selection for operator status roles (#6706) * Add additional test roles to example user * Add session storage and role to user indicator * Update example user provider * Added selection dialog to overlays and implemented for operator status * Display role in user indicator * Updates to broadcast channel lifecycle * Update comment * Comment width * UserAPI role updates and UserIndicator improvement * Moved prompt to UserIndicator * Reconnect channel on error and UserIndicator updates * Updates to status api canPRovideStatusForRole * Cleanup * Store status roles in an array instead of a singular value * Added success notification and cleanup * Lint * Removed unused role param from status api call * Remove default status role from example user plugin * Removed status.getStatusRoleForCurrentUser * Cleanup * Cleanup * Moved roleChannel to private field * Separated input value from active role value * More flight like status role names and parameter names * Update statusRole parameter name * Update default selection for roles if input is not chosen * Update OperatorStatusIndicator install to hide if an observer * console.log * Return null instead of undefined * Remove unneccesary filter on allRoles * refactor: format with prettier * Undid merge error * Merge conflict extra line * Copyright statement * RoleChannelProvider to RoleChannel * Throw error on no provider * Change RoleChannel to ActiveRoleSynchronizer and update method calls to match * iconClass to alert * Add role selection step to beforeEach * example-role to flight * Dismiss overlay from exampleUser plugin which affected menu api positioning --------- Co-authored-by: Scott Bell <scott@traclabs.com>
2023-07-14 19:10:58 +00:00
this.user = new this.ExampleUser(id, this.autoLoginUser, ['flight', 'driver', 'observer']);
this.loggedIn = true;
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
return Promise.resolve();
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
}
const formStructure = {
title: 'Login',
sections: [
{
rows: [
{
key: 'username',
control: 'textfield',
name: 'Username',
pattern: '\\S+',
required: true,
cssClass: 'l-input-lg',
value: ''
}
]
}
],
buttons: {
submit: {
label: 'Login'
}
}
};
return this.openmct.forms.showForm(formStructure).then(
(info) => {
this.user = new this.ExampleUser(id, info.username, ['example-role']);
this.loggedIn = true;
},
() => {
// user canceled, setting a default username
this.user = new this.ExampleUser(id, 'Pat', ['example-role']);
this.loggedIn = true;
}
);
}
}
Operator status (#5179) * Added click event to simple indicator * Moved operator status plugin to Open * Implementing user role status API * Support adding indicators asynchronously * Adding user status API * Updated example user provider * Update icon with status * Adding admin indicator * Apply config options * Set status class on indicator. Clear all statuses * Show poll question in op stat indicator * Implementing status summary * Get statuses from providers. Reset statuses when poll question set * Styling for operator status - New icon glyph - IMPORTANT: OVERRIDE ANY MERGE CONFLICTS USING THIS COMMIT! - Fixed erroneous font glyph mapping; - Added default color for indicator icon; - Changed user indicator to display response when set to other than "NO_STATUS". - Standardized icon display. * Cherrypick symbols font updates from restricted-notebook branch. This is the most full and complete version of the symbols font - OVERRIDE ANY MERGE CONFLICTS WITH THIS COMMIT! * Fix positioning of popups * Also fix positioning of status indicator * Get roles by status instead of users * Refactor how status summary is determined to simplify API * Re-fetch status summary on status change * Implemented status reset * Move status into separate API * Refactor user status to its own sub-API * Create RAF utility class * Error handling * Add copyright notices * Fix test issues * Added jsdocs * Additional tests for raf utility function * Move status style configuration into Open * Move styling from the API into the view * Added some docs * Added some unit tests and fixed a bug found in the process. Tests work\! Co-authored-by: Andrew Henry <akhenry@gmail.com>
2022-06-02 20:46:13 +00:00
/**
* @typedef {import('@/api/user/StatusUserProvider').default} StatusUserProvider
*/