Skip to content

Commit

Permalink
1.3.0:
Browse files Browse the repository at this point in the history
 - Added the file download interface
 - Added preview mode of the HTML
 - Change icons of operations & interfaces
  • Loading branch information
Attacler committed Feb 6, 2025
1 parent 4075a10 commit 75ece07
Show file tree
Hide file tree
Showing 17 changed files with 10,560 additions and 680 deletions.
2 changes: 1 addition & 1 deletion GenerateBarcode/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const types = [
export default defineOperationApp({
id: "ttabarcode",
name: "TTA generate barcode",
icon: "box",
icon: "barcode",
description: "Generate a barcode trough Text to anything!",
overview: ({ barcodeContent }) => [
{
Expand Down
2 changes: 1 addition & 1 deletion GeneratePDF/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineOperationApp } from "@directus/extensions-sdk";
export default defineOperationApp({
id: "ttapdf",
name: "TTA generate PDF",
icon: "box",
icon: "picture_as_pdf",
description: "Generate a PDF trough Text to anything!",
overview: ({ filename }) => [
{
Expand Down
3 changes: 3 additions & 0 deletions GeneratePDFFromTemplateInterface/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
node_modules
dist
24 changes: 24 additions & 0 deletions GeneratePDFFromTemplateInterface/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "directus-extension-PDFTemplateInterface",
"version": "1.0.0",
"keywords": [
"directus",
"directus-extension",
"directus-custom-interface"
],
"directus:extension": {
"type": "interface",
"path": "dist/index.js",
"source": "src/index.ts",
"host": "^9.22.1"
},
"scripts": {
"build": "directus-extension build",
"dev": "directus-extension build -w --no-minify"
},
"devDependencies": {
"@directus/extensions-sdk": "9.22.1",
"typescript": "^5.3.3",
"vue": "^3.3.11"
}
}
58 changes: 58 additions & 0 deletions GeneratePDFFromTemplateInterface/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { defineInterface } from "@directus/extensions-sdk";
import { computed } from "vue";
import InterfaceComponent from "./interface.vue";
import { useStores } from "@directus/extensions-sdk";

export default defineInterface({
id: "tta-download-interface",
name: "Download interface",
icon: "sim_card_download",
description: "Download files based on a flow. (Text to anything)",
hideLabel: true,
hideLoader: true,
component: InterfaceComponent,
options: () => {
const { useFlowsStore } = useStores();
const flowStore = useFlowsStore();

const flowOptions = computed(() =>
flowStore.flows
.filter(
(flow: any) =>
flow.trigger === "webhook" && flow.options.method == "POST"
)
.map((flow: any) => {
return { text: flow.name, value: flow.id };
})
);
return [
{
field: "label",
type: "string",
name: "$t:label",
meta: {
width: "full",
interface: "system-input-translated-string",
options: {
placeholder: "$t:label",
},
},
},
{
field: "flow",
name: "$t:operations.trigger.flow",
type: "string",
meta: {
width: "full",
interface: "select-dropdown",
options: {
choices: flowOptions,
iconRight: "bolt",
placeholder: "$t:a_flow_uuid",
},
},
},
];
},
types: ["string"],
});
31 changes: 31 additions & 0 deletions GeneratePDFFromTemplateInterface/src/interface.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<v-button @click="downloadFile" :loading="loading" :disabled="loading">{{
props.label
}}</v-button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useApi } from "@directus/extensions-sdk";
const api = useApi();
const props = defineProps<{
label: string;
flow: any;
primaryKey: any;
}>();
const loading = ref(false);
async function downloadFile() {
loading.value = true;
try {
const webhookOutput = await api.post("/flows/trigger/" + props.flow, {
id: props.primaryKey,
});
window.open("/assets/" + webhookOutput.data, "_blank");
} catch (e) {}
loading.value = false;
}
</script>
5 changes: 5 additions & 0 deletions GeneratePDFFromTemplateInterface/src/shims.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
28 changes: 28 additions & 0 deletions GeneratePDFFromTemplateInterface/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "ES2019",
"lib": ["ES2019", "DOM"],
"moduleResolution": "node",
"strict": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUncheckedIndexedAccess": true,
"noUnusedParameters": true,
"alwaysStrict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"resolveJsonModule": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"rootDir": "./src"
},
"include": ["./src/**/*.ts"]
}
2 changes: 1 addition & 1 deletion GeneratePDFGenerateFromTemplate/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineOperationApp } from "@directus/extensions-sdk";
export default defineOperationApp({
id: "ttapdftemplate",
name: "TTA generate PDF from template",
icon: "box",
icon: "picture_as_pdf",
description: "Generate a PDF based on a template trough Text to anything!",
overview: ({ filename }) => [
{
Expand Down
2 changes: 1 addition & 1 deletion GenerateQRCode/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineOperationApp } from "@directus/extensions-sdk";
export default defineOperationApp({
id: "ttaqrcode",
name: "TTA generate QRcode",
icon: "box",
icon: "qr_code",
description: "Generate a QRcode trough Text to anything!",
overview: ({ content }) => [
{
Expand Down
2 changes: 1 addition & 1 deletion PDFTemplateSelector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import InterfaceComponent from "./interface.vue";
export default defineInterface({
id: "TTA-pdf-template-selector",
name: "PDF template selector",
icon: "box",
icon: "picture_as_pdf",
description: "Selector for a PDF template for Text To Anything",
component: InterfaceComponent,
options: null,
Expand Down
Loading

0 comments on commit 75ece07

Please sign in to comment.