| <template> |
| <PluginComponent :infoPayload="infoPayload" v-model="open" :cancelBtnTxt="neverClose ? '' : 'Ok'" actionBtnTxt="" |
| @onClosed="onClosed" :variant="variantToUse" @onUserArgChanged="onUserArgChanged" |
| @onMolCountsChanged="onMolCountsChanged"> |
| |
| <MessageList :messages="simpleMsgs"></MessageList> |
| </PluginComponent> |
| </template> |
| |
| <script lang="ts"> |
| |
| |
| import { Options } from "vue-class-component"; |
| import Popup from "@/UI/MessageAlerts/Popups/Popup.vue"; |
| import { IContributorCredit, ISoftwareCredit } from "../PluginInterfaces"; |
| import { |
| ISimpleMsg, |
| PopupVariant, |
| } from "@/UI/MessageAlerts/Popups/InterfacesAndEnums"; |
| import PluginComponent from "../Parents/PluginComponent/PluginComponent.vue"; |
| import { PluginParentClass } from "../Parents/PluginParentClass/PluginParentClass"; |
| import { UserArg } from "@/UI/Forms/FormFull/FormFullInterfaces"; |
| import { ITest } from "@/Testing/TestInterfaces"; |
| import { pluginsApi } from "@/Api/Plugins"; |
| import MessageList from "@/UI/MessageAlerts/MessageList.vue"; |
| import { Tag } from "./ActivityFocus/ActivityFocusUtils"; |
| import { toTitleCase } from "@/Core/Utils/StringUtils"; |
| |
| |
| |
| |
| @Options({ |
| components: { |
| Popup, |
| PluginComponent, |
| MessageList |
| }, |
| }) |
| export default class SimpleMsgPlugin extends PluginParentClass { |
| // @Prop({ required: true }) title!: string; |
| { required: true }) message!: string; |
| |
| menuPath = null; |
| softwareCredits: ISoftwareCredit[] = []; |
| contributorCredits: IContributorCredit[] = [ |
| { |
| // name: "Jacob D. Durrant", |
| // url: "http://durrantlab.com/", |
| // }, |
| ]; |
| pluginId = "simplemsg"; |
| intro = null; |
| details = "This is a system plugin for displaying simple messages to the user."; |
| tags = [Tag.All]; |
| |
| |
| simpleMsgs: ISimpleMsg[] = []; |
| |
| title = "Messages"; |
| |
| |
| |
| neverClose = false; |
| showInQueue = false; |
| |
| userArgDefaults: UserArg[] = []; |
| |
| logJob = false; |
| logAnalytics = false; |
| |
| |
| |
| |
| {PopupVariant} The variant to use for the popup. |
| */ |
| get variantToUse(): PopupVariant { |
| // No messages. |
| if (this.simpleMsgs.length === 0) return PopupVariant.Primary; |
| |
| // Variant not defined. |
| if (this.simpleMsgs[0].variant === undefined) |
| return PopupVariant.Primary; |
| |
| // Only one message, so just use that associated variant. |
| if (this.simpleMsgs.length == 1) return this.simpleMsgs[0].variant; |
| |
| // Get all the variants in this.simpleMsgs. Is there only one unique |
| // variant? Then use that one. |
| const variants = this.simpleMsgs.map((x) => x.variant); |
| const uniqueVariants = Array.from(new Set(variants)); |
| if (uniqueVariants.length === 1 && uniqueVariants[0] !== undefined) { |
| return uniqueVariants[0]; |
| } |
| |
| |
| return PopupVariant.Primary; |
| } |
| |
| |
| |
| |
| |
| {ISimpleMsg} [payload] Information about the message to display. |
| * @returns {Promise<void>} Promise that resolves when the plugin is |
| * finished starting. |
| */ |
| async onPluginStart(payload: ISimpleMsg): Promise<void> { |
| if (payload.message === "") { |
| // Sometimes this plugin gets called with an empty message. TODO: |
| // Not sure why. Good to investigate. Happens, for example, when you |
| // try to load PDB ID 9999. |
| return; |
| } |
| |
| |
| payload.datetime = new Date().toLocaleString(); |
| |
| |
| this.simpleMsgs.unshift(payload); |
| |
| |
| |
| const titles = this.simpleMsgs.map((x) => toTitleCase(x.title)); |
| const uniqueTitles = Array.from(new Set(titles)); |
| this.title = uniqueTitles.length === 1 ? uniqueTitles[0] : "Messages"; |
| |
| this.neverClose = |
| payload.neverClose === undefined ? false : payload.neverClose; |
| |
| |
| |
| this.open = payload.open !== undefined ? payload.open : true; |
| } |
| |
| |
| |
| |
| onClosed() { |
| this.submitJobs(); |
| } |
| |
| |
| |
| |
| |
| {Promise<void>} A promise that resolves when the job is done. |
| */ |
| runJobInBrowser(): Promise<void> { |
| for (const simpleMsg of this.simpleMsgs) { |
| if (simpleMsg.callBack) { |
| simpleMsg.callBack(); |
| } |
| } |
| this.simpleMsgs = []; |
| return Promise.resolve(); |
| } |
| |
| |
| |
| |
| |
| |
| {ITest[]} The selenium test commands. |
| */ |
| async getTests(): Promise<ITest[]> { |
| // Not going to test closing, etc. (Too much work.) But at least opens |
| // to see if an error occurs. |
| |
| pluginsApi.runPlugin(this.pluginId, { |
| title: "Test Title", |
| message: "Test message", |
| open: true, // open |
| } as ISimpleMsg); |
| |
| return []; |
| } |
| } |
| </script> |
| |
| |
| <style scoped lang="scss"></style> |
| |