This commit is contained in:
parent
c48098d362
commit
c52497f7ed
8 changed files with 151 additions and 22 deletions
16
.vscode/tasks.json
vendored
16
.vscode/tasks.json
vendored
|
@ -16,11 +16,18 @@
|
|||
{
|
||||
"label": "dev",
|
||||
"dependsOn": [
|
||||
"dev extension",
|
||||
"dev directus",
|
||||
"dev extension"
|
||||
],
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "dev extension",
|
||||
"command": "npm run dev",
|
||||
"type": "shell",
|
||||
"hide": true,
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "dev directus",
|
||||
"command": "npx directus start",
|
||||
|
@ -31,12 +38,5 @@
|
|||
"hide": true,
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "dev extension",
|
||||
"command": "npm run dev",
|
||||
"type": "shell",
|
||||
"hide": true,
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
BIN
directus/data.db
BIN
directus/data.db
Binary file not shown.
15
package-lock.json
generated
15
package-lock.json
generated
|
@ -11,7 +11,8 @@
|
|||
"@directus/extensions": "^3.0.1",
|
||||
"@directus/extensions-sdk": "13.0.1",
|
||||
"@directus/types": "^13.0.0",
|
||||
"typescript": "^5.7.3",
|
||||
"@types/node": "^22.13.9",
|
||||
"typescript": "^5.8.2",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
}
|
||||
|
@ -1383,9 +1384,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.13.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.5.tgz",
|
||||
"integrity": "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg==",
|
||||
"version": "22.13.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.9.tgz",
|
||||
"integrity": "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
@ -4953,9 +4954,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.7.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
|
||||
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
|
||||
"version": "5.8.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
|
||||
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
|
|
19
package.json
19
package.json
|
@ -15,7 +15,15 @@
|
|||
{
|
||||
"type": "layout",
|
||||
"name": "tasks",
|
||||
"source": "src/tasks/index.js"
|
||||
"source": "src/tasks/index.ts"
|
||||
},
|
||||
{
|
||||
"type": "operation",
|
||||
"name": "windmill",
|
||||
"source": {
|
||||
"app": "src/windmill/app.ts",
|
||||
"api": "src/windmill/api.ts"
|
||||
}
|
||||
}
|
||||
],
|
||||
"host": "^10.10.0"
|
||||
|
@ -28,10 +36,11 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@directus/types": "^13.0.0",
|
||||
"@directus/extensions-sdk": "13.0.1",
|
||||
"@directus/extensions": "^3.0.1",
|
||||
"typescript": "^5.7.3",
|
||||
"@directus/extensions-sdk": "13.0.3",
|
||||
"@directus/extensions": "^3.0.3",
|
||||
"typescript": "^5.8.2",
|
||||
"vue": "^3.5.13",
|
||||
"vue-router": "^4.5.0"
|
||||
"vue-router": "^4.5.0",
|
||||
"@types/node": "^22.13.9"
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
@click="router.push(`${collection}/${item.id}`)">
|
||||
<VListItemIcon>
|
||||
<VIcon
|
||||
:name="fields.find(f => f.field == 'category')?.meta?.options?.choices?.find((c: any) => c.value == item.category)?.icon"
|
||||
:name="fields.find(f => f.field == 'category')?.meta?.options?.choices?.find((c: any) => c.value == item.category)?.icon ?? 'question_mark'"
|
||||
:color="item.priority == 'high' ? 'orange' : item.priority == 'normal' ? 'var(--theme--primary)' : 'grey'" />
|
||||
</VListItemIcon>
|
||||
<VListItemContent>
|
||||
|
@ -85,7 +85,7 @@ export default defineComponent({
|
|||
type: Array as PropType<Field[]>,
|
||||
required: true,
|
||||
},
|
||||
me: Object,
|
||||
me: String,
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
47
src/windmill/api.ts
Normal file
47
src/windmill/api.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { defineOperationApi } from '@directus/extensions-sdk';
|
||||
|
||||
type Options = {
|
||||
token: string
|
||||
instance: string
|
||||
flow: string
|
||||
}
|
||||
|
||||
type Data = {
|
||||
// create and update trigger
|
||||
event?: string
|
||||
collection?: string
|
||||
|
||||
// create trigger
|
||||
key: string
|
||||
|
||||
// update trigger
|
||||
keys?: string[]
|
||||
|
||||
// manual trigger
|
||||
body?: {
|
||||
collection: string
|
||||
keys: string[]
|
||||
}
|
||||
}
|
||||
|
||||
export default defineOperationApi<Options>({
|
||||
id: 'windmill',
|
||||
handler: async ({ token, instance, flow }, { data }) => {
|
||||
const last = data.$last as Data
|
||||
const body = JSON.stringify({
|
||||
event: last.event ?? "manual",
|
||||
instance: instance,
|
||||
collection: last.collection ?? last.body?.collection,
|
||||
keys: last.keys ?? last.body?.keys ?? [last.key]
|
||||
})
|
||||
|
||||
return await fetch(`https://windmill.swablab.de/api/r/${flow}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${token}`
|
||||
},
|
||||
body
|
||||
})
|
||||
},
|
||||
});
|
67
src/windmill/app.ts
Normal file
67
src/windmill/app.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
import { defineOperationApp } from "@directus/extensions-sdk";
|
||||
|
||||
export default defineOperationApp({
|
||||
id: "windmill",
|
||||
name: "swablab windmill",
|
||||
icon: "wind_power",
|
||||
description: "trigger a windmill action",
|
||||
overview: ({ instance, flow }) => [
|
||||
{
|
||||
label: "Instance",
|
||||
text: instance,
|
||||
},
|
||||
{
|
||||
label: "Flow",
|
||||
text: flow,
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
field: "token",
|
||||
name: "Token",
|
||||
type: "string",
|
||||
meta: {
|
||||
width: "full",
|
||||
interface: "input",
|
||||
required: true,
|
||||
note: "See Vaultwarden",
|
||||
options: {
|
||||
masked: true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: "instance",
|
||||
name: "Instance",
|
||||
type: "string",
|
||||
meta: {
|
||||
width: "full",
|
||||
interface: 'select-dropdown',
|
||||
required: true,
|
||||
options: {
|
||||
choices: [
|
||||
{
|
||||
text: 'Directus',
|
||||
value: 'directus',
|
||||
},
|
||||
{
|
||||
text: 'Management',
|
||||
value: 'management',
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "flow",
|
||||
name: "Flow",
|
||||
type: "string",
|
||||
meta: {
|
||||
width: "full",
|
||||
interface: "input",
|
||||
required: true,
|
||||
note: "https://windmill.swablab.de/api/r/..."
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
5
src/windmill/shims.d.ts
vendored
Normal file
5
src/windmill/shims.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
declare module '*.vue' {
|
||||
import { DefineComponent } from 'vue';
|
||||
const component: DefineComponent<{}, {}, any>;
|
||||
export default component;
|
||||
}
|
Loading…
Add table
Reference in a new issue