diff --git a/src/api/user/StatusAPI.js b/src/api/user/StatusAPI.js index ecbefeef6f..9102a43a55 100644 --- a/src/api/user/StatusAPI.js +++ b/src/api/user/StatusAPI.js @@ -100,6 +100,52 @@ export default class StatusAPI extends EventEmitter { } } + /** + * Can the currently logged in user set the mission status. + * @returns {Promise} 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} 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} + */ + 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>} 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} 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