mirror of
https://github.com/nasa/openmct.git
synced 2025-01-14 08:49:58 +00:00
Added success notification and cleanup
This commit is contained in:
parent
c0e7804ccd
commit
ec7f954411
@ -58,8 +58,7 @@ const STATUSES = [{
|
|||||||
* @implements {StatusUserProvider}
|
* @implements {StatusUserProvider}
|
||||||
*/
|
*/
|
||||||
export default class ExampleUserProvider extends EventEmitter {
|
export default class ExampleUserProvider extends EventEmitter {
|
||||||
constructor(openmct, {defaultStatusRole, statusRoles} = {
|
constructor(openmct, {statusRoles} = {
|
||||||
defaultStatusRole: undefined,
|
|
||||||
statusRoles: []
|
statusRoles: []
|
||||||
}) {
|
}) {
|
||||||
super();
|
super();
|
||||||
@ -73,9 +72,7 @@ export default class ExampleUserProvider extends EventEmitter {
|
|||||||
status: STATUSES[0]
|
status: STATUSES[0]
|
||||||
}));
|
}));
|
||||||
this.pollQuestion = undefined;
|
this.pollQuestion = undefined;
|
||||||
// this.defaultStatusRole = defaultStatusRole;
|
|
||||||
this.statusRoles = statusRoles;
|
this.statusRoles = statusRoles;
|
||||||
this.selectedStatusRole = defaultStatusRole;
|
|
||||||
|
|
||||||
this.ExampleUser = createExampleUser(this.openmct.user.User);
|
this.ExampleUser = createExampleUser(this.openmct.user.User);
|
||||||
this.loginPromise = undefined;
|
this.loginPromise = undefined;
|
||||||
@ -123,9 +120,10 @@ export default class ExampleUserProvider extends EventEmitter {
|
|||||||
return this.user.getRoles();
|
return this.user.getRoles();
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatusRoleForCurrentUser() {
|
getStatusRoleForCurrentUser(role) {
|
||||||
|
const matchedRole = this.statusRoleValues.find(x => x.role === role);
|
||||||
|
|
||||||
return Promise.resolve(this.selectedStatusRole);
|
return Promise.resolve(matchedRole?.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllStatusRoles() {
|
getAllStatusRoles() {
|
||||||
|
@ -230,7 +230,9 @@ export default class StatusAPI extends EventEmitter {
|
|||||||
const provider = this.#userAPI.getProvider();
|
const provider = this.#userAPI.getProvider();
|
||||||
|
|
||||||
if (provider.getStatusRoleForCurrentUser) {
|
if (provider.getStatusRoleForCurrentUser) {
|
||||||
return provider.getStatusRoleForCurrentUser();
|
const activeRole = this.#userAPI.getActiveRole();
|
||||||
|
|
||||||
|
return provider.getStatusRoleForCurrentUser(activeRole);
|
||||||
} else {
|
} else {
|
||||||
this.#userAPI.error("User provider cannot provide role status for this user");
|
this.#userAPI.error("User provider cannot provide role status for this user");
|
||||||
}
|
}
|
||||||
@ -244,7 +246,7 @@ export default class StatusAPI extends EventEmitter {
|
|||||||
const provider = this.#userAPI.getProvider();
|
const provider = this.#userAPI.getProvider();
|
||||||
|
|
||||||
if (provider.getStatusRoleForCurrentUser) {
|
if (provider.getStatusRoleForCurrentUser) {
|
||||||
const activeStatusRole = await this.#userAPI.getProvider().getStatusRoleForCurrentUser();
|
const activeStatusRole = await this.#userAPI.getActiveRole()
|
||||||
const canProvideStatus = await this.canProvideStatusForRole(activeStatusRole);
|
const canProvideStatus = await this.canProvideStatusForRole(activeStatusRole);
|
||||||
|
|
||||||
return canProvideStatus;
|
return canProvideStatus;
|
||||||
|
@ -137,7 +137,7 @@ export default {
|
|||||||
subscribeToPollQuestion() {
|
subscribeToPollQuestion() {
|
||||||
this.openmct.user.status.on('pollQuestionChange', this.setPollQuestion);
|
this.openmct.user.status.on('pollQuestionChange', this.setPollQuestion);
|
||||||
},
|
},
|
||||||
setStatus({role, status}) {
|
setStatus({status}) {
|
||||||
status = this.applyStyling(status);
|
status = this.applyStyling(status);
|
||||||
this.selectedStatus = status.key;
|
this.selectedStatus = status.key;
|
||||||
this.indicator.iconClass(status.iconClassPoll);
|
this.indicator.iconClass(status.iconClassPoll);
|
||||||
|
@ -59,16 +59,14 @@ export default {
|
|||||||
this.role = this.openmct.user.getActiveRole();
|
this.role = this.openmct.user.getActiveRole();
|
||||||
this.loggedIn = this.openmct.user.isLoggedIn();
|
this.loggedIn = this.openmct.user.isLoggedIn();
|
||||||
},
|
},
|
||||||
async fetchOrPromptForRole() {
|
fetchOrPromptForRole() {
|
||||||
const UserAPI = this.openmct.user;
|
const UserAPI = this.openmct.user;
|
||||||
const activeRole = UserAPI.getActiveRole();
|
const activeRole = UserAPI.getActiveRole();
|
||||||
this.selectedRole = activeRole;
|
this.role = activeRole;
|
||||||
if (!activeRole) {
|
if (!activeRole) {
|
||||||
this.promptForRoleSelection();
|
this.promptForRoleSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.role = await this.openmct.user.status.getStatusRoleForCurrentUser();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
promptForRoleSelection() {
|
promptForRoleSelection() {
|
||||||
const allRoles = this.openmct.user.getPossibleRoles();
|
const allRoles = this.openmct.user.getPossibleRoles();
|
||||||
@ -82,9 +80,9 @@ export default {
|
|||||||
iconClass: 'info',
|
iconClass: 'info',
|
||||||
title: 'Select Role',
|
title: 'Select Role',
|
||||||
message: 'Please select your role for operator status.',
|
message: 'Please select your role for operator status.',
|
||||||
currentSelection: this.selectedRole,
|
currentSelection: this.role,
|
||||||
onChange: (event) => {
|
onChange: (event) => {
|
||||||
this.selectedRole = event.target.value;
|
this.role = event.target.value;
|
||||||
},
|
},
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
@ -92,8 +90,8 @@ export default {
|
|||||||
emphasis: true,
|
emphasis: true,
|
||||||
callback: () => {
|
callback: () => {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
//TODO: introduce a notification of success
|
this.updateRole(this.role);
|
||||||
this.updateRole(this.selectedRole);
|
this.openmct.notifications.info(`Successfully set new role to ${this.role}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user