diff --git a/src/locales/en.json b/src/locales/en.json index 0edf9815..ca994ec1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -58,6 +58,7 @@ "Completed orders": "Completed orders", "Configuration missing": "Configuration missing", "Copied job details to clipboard": "Copied job details to clipboard", + "Copied to clipboard": "Copied to clipboard", "Copy details": "Copy details", "Custom": "Custom", "Custom frequency": "Custom frequency", diff --git a/src/utils/index.ts b/src/utils/index.ts index b93513bc..d59ce19f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,6 +4,7 @@ import Papa from 'papaparse' import { DateTime } from "luxon"; import logger from "@/logger"; import { translate } from "@/i18n"; +import { Plugins } from '@capacitor/core'; // TODO Use separate files for specific utilities @@ -330,7 +331,19 @@ const hasJobDataError = (job: any) => { return false; } +const copyToClipboard = async (value: string, text?: string) => { + const { Clipboard } = Plugins; + + await Clipboard.write({ + string: value, + }).then(() => { + text ? showToast(translate(text)) : showToast(translate("Copied", { value })); + }); +} + + export { + copyToClipboard, isCustomRunTime, getNowTimestamp, generateAllowedFrequencies, diff --git a/src/views/FailedJobReasonModal.vue b/src/views/FailedJobReasonModal.vue index 50cdded5..40b21785 100644 --- a/src/views/FailedJobReasonModal.vue +++ b/src/views/FailedJobReasonModal.vue @@ -7,6 +7,11 @@ {{ $t("Failed job reason") }} + + + + + @@ -29,7 +34,8 @@ import { modalController, } from '@ionic/vue'; import { defineComponent } from 'vue'; -import { closeOutline } from 'ionicons/icons'; +import { closeOutline, copyOutline } from 'ionicons/icons'; +import { copyToClipboard } from "@/utils"; export default defineComponent({ name: "FailedJobReasonModal", @@ -51,7 +57,9 @@ export default defineComponent({ }, setup() { return { - closeOutline + closeOutline, + copyOutline, + copyToClipboard }; }, });