mirror of
https://github.com/nasa/openmct.git
synced 2024-12-27 16:38:51 +00:00
Update OperatorStatusIndicator install to hide if an observer
This commit is contained in:
parent
6c087a1d1e
commit
97ae44b5af
@ -126,6 +126,7 @@ class UserAPI extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
setActiveRole(role) {
|
setActiveRole(role) {
|
||||||
SessionPersistance.setActiveRole(role);
|
SessionPersistance.setActiveRole(role);
|
||||||
|
this.emit('roleChanged', role);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,7 +72,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
allRoles: [],
|
|
||||||
role: '--',
|
role: '--',
|
||||||
pollQuestionUpdated: '--',
|
pollQuestionUpdated: '--',
|
||||||
currentPollQuestion: DEFAULT_POLL_QUESTION,
|
currentPollQuestion: DEFAULT_POLL_QUESTION,
|
||||||
@ -87,11 +86,15 @@ export default {
|
|||||||
left: `${this.positionX}px`,
|
left: `${this.positionX}px`,
|
||||||
top: `${this.positionY}px`
|
top: `${this.positionY}px`
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
canProvideStatusForRole() {
|
||||||
|
return this.openmct.user.canProvideStatusForRole(this.role);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.openmct.user.status.off('statusChange', this.setStatus);
|
this.openmct.user.status.off('statusChange', this.setStatus);
|
||||||
this.openmct.user.status.off('pollQuestionChange', this.setPollQuestion);
|
this.openmct.user.status.off('pollQuestionChange', this.setPollQuestion);
|
||||||
|
this.openmct.user.off('roleChanged', this.fetchMyStatus);
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.unsubscribe = [];
|
this.unsubscribe = [];
|
||||||
@ -101,6 +104,7 @@ export default {
|
|||||||
await this.fetchMyStatus();
|
await this.fetchMyStatus();
|
||||||
this.subscribeToMyStatus();
|
this.subscribeToMyStatus();
|
||||||
this.subscribeToPollQuestion();
|
this.subscribeToPollQuestion();
|
||||||
|
this.subscribeToRoleChange();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
@ -124,8 +128,16 @@ export default {
|
|||||||
},
|
},
|
||||||
async fetchMyStatus() {
|
async fetchMyStatus() {
|
||||||
const activeRole = await this.openmct.user.getActiveRole();
|
const activeRole = await this.openmct.user.getActiveRole();
|
||||||
const status = await this.openmct.user.status.getStatusForRole(activeRole);
|
this.role = activeRole;
|
||||||
|
// hide indicator for observer
|
||||||
|
if (!this.openmct.user.canProvideStatusForRole()) {
|
||||||
|
this.indicator.text('');
|
||||||
|
this.indicator.statusClass('hidden');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const status = await this.openmct.user.status.getStatusForRole(activeRole);
|
||||||
if (status !== undefined) {
|
if (status !== undefined) {
|
||||||
this.setStatus({status});
|
this.setStatus({status});
|
||||||
}
|
}
|
||||||
@ -136,7 +148,11 @@ export default {
|
|||||||
subscribeToPollQuestion() {
|
subscribeToPollQuestion() {
|
||||||
this.openmct.user.status.on('pollQuestionChange', this.setPollQuestion);
|
this.openmct.user.status.on('pollQuestionChange', this.setPollQuestion);
|
||||||
},
|
},
|
||||||
|
subscribeToRoleChange() {
|
||||||
|
this.openmct.user.on('roleChanged', this.fetchMyStatus);
|
||||||
|
},
|
||||||
setStatus({status}) {
|
setStatus({status}) {
|
||||||
|
console.log('set Status firiging?')
|
||||||
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);
|
||||||
|
@ -30,14 +30,8 @@ export default function operatorStatusPlugin(configuration) {
|
|||||||
return function install(openmct) {
|
return function install(openmct) {
|
||||||
|
|
||||||
if (openmct.user.hasProvider()) {
|
if (openmct.user.hasProvider()) {
|
||||||
const activeRole = openmct.user.getActiveRole();
|
const operatorStatusIndicator = new OperatorStatusIndicator(openmct, configuration);
|
||||||
openmct.user.status.canProvideStatusForRole(activeRole).then(canProvideStatus => {
|
operatorStatusIndicator.install();
|
||||||
if (canProvideStatus) {
|
|
||||||
const operatorStatusIndicator = new OperatorStatusIndicator(openmct, configuration);
|
|
||||||
|
|
||||||
operatorStatusIndicator.install();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
openmct.user.status.canSetPollQuestion().then(canSetPollQuestion => {
|
openmct.user.status.canSetPollQuestion().then(canSetPollQuestion => {
|
||||||
if (canSetPollQuestion) {
|
if (canSetPollQuestion) {
|
||||||
|
Loading…
Reference in New Issue
Block a user