-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added the file download interface - Added preview mode of the HTML - Change icons of operations & interfaces
- Loading branch information
Showing
17 changed files
with
10,560 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.