feat: support mission statuses

This commit is contained in:
Mazzella, Jesse D. (ARC-TI)[KBR Wyle Services, LLC] 2024-01-24 13:35:48 -08:00
parent 0d1a6f97c2
commit ebc67ebbc9

View File

@ -100,6 +100,52 @@ export default class StatusAPI extends EventEmitter {
}
}
/**
* Can the currently logged in user set the mission status.
* @returns {Promise<Boolean>} true if the currently logged in user can set the mission status, false otherwise.
*/
canSetMissionStatus() {
const provider = this.#userAPI.getProvider();
if (provider.canSetMissionStatus) {
return provider.canSetMissionStatus();
} else {
return Promise.resolve(false);
}
}
/**
* Fetch the list of possible mission status options
* @returns {Promise<MissionStatusOption[]>} the current mission status
*/
async getPossibleMissionStatusOptions() {
const provider = this.#userAPI.getProvider();
if (provider.getPossibleMissionStatusOptions) {
const possibleOptions = await provider.getPossibleMissionStatusOptions();
return possibleOptions;
} else {
this.#userAPI.error('User provider does not support mission status options');
}
}
/**
* Fetch the list of possible mission status roles
* @returns {Promise<MissionStatusRole[]>}
*/
async getPossibleMissionStatusRoles() {
const provider = this.#userAPI.getProvider();
if (provider.getPossibleMissionStatusRoles) {
const possibleRoles = await provider.getPossibleMissionStatusRoles();
return possibleRoles;
} else {
this.#userAPI.error('User provider does not support mission status roles');
}
}
/**
* @returns {Promise<Array<Status>>} the complete list of possible states that an operator can reply to a poll question with.
*/
@ -166,6 +212,21 @@ export default class StatusAPI extends EventEmitter {
}
}
/**
* @param {MissionStatusRole} role
* @param {MissionStatusOption} status
* @returns {Promise<Boolean>} true if operation was successful, otherwise false.
*/
setStatusForMissionRole(role, status) {
const provider = this.#userAPI.getProvider();
if (provider.setStatusForMissionRole) {
return provider.setStatusForMissionRole(role, status);
} else {
this.#userAPI.error('User provider does not support setting mission role status');
}
}
/**
* Resets the status of the provided role back to its default status.
* @param {import("./UserAPI").Role} role The role to set the status for.
@ -276,6 +337,19 @@ export default class StatusAPI extends EventEmitter {
* @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
*/
/**
* @typedef {Object} MissionStatusRole
* @property {String} key A unique identifier for this role
* @property {String} label A human readable label for this role
*/
/**
* The Status type
* @typedef {Object} Status