Skip to content

Commit

Permalink
Merge pull request #657 from amansinghbais/job-manager/copyUtilityFor…
Browse files Browse the repository at this point in the history
…FailedJob

Implemented: button for copying failed job reason in the modal
  • Loading branch information
ravilodhi authored Dec 27, 2023
2 parents e395f30 + 1eb7f32 commit e4ff554
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions src/views/FailedJobReasonModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
</ion-button>
</ion-buttons>
<ion-title>{{ $t("Failed job reason") }}</ion-title>
<ion-buttons slot="end">
<ion-button @click="copyToClipboard(job.jobResult, 'Copied to clipboard')">
<ion-icon slot="icon-only" :icon="copyOutline" />
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
Expand All @@ -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",
Expand All @@ -51,7 +57,9 @@ export default defineComponent({
},
setup() {
return {
closeOutline
closeOutline,
copyOutline,
copyToClipboard
};
},
});
Expand Down

0 comments on commit e4ff554

Please sign in to comment.