Skip to content

Commit

Permalink
add flow card to add an image to the gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
WeeJeWel committed Oct 8, 2024
1 parent 4f5af3c commit a3c5cbf
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .homeycompose/flow/actions/create-image.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"title": {
"en": "Add an Image to the Gallery"
},
"titleFormatted": {
"en": "Add [[droptoken]] as [[name]] to the Gallery"
},
"hint": {
"en": "This card adds an Image in your gGallery."
},
"droptoken": [
"image"
],
"args": [
{
"name": "name",
"type": "text",
"placeholder": {
"en": "Name"
}
}
]
}
12 changes: 12 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ module.exports = class extends Homey.App {
});
}));
}

this.homey.flow
.getActionCard('create-image')
.registerRunListener(async ({ droptoken, name }) => {
const imageStream = await droptoken.getStream();

await this.createImage({
name: name ?? imageStream.filename,
type: imageStream.contentType,
data: imageStream,
});
});
}

async initImage({ id }) {
Expand Down
28 changes: 28 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,34 @@
"path": "/image/:id"
}
},
"flow": {
"actions": [
{
"title": {
"en": "Add an Image to the Gallery"
},
"titleFormatted": {
"en": "Add [[droptoken]] as [[name]] to the Gallery"
},
"hint": {
"en": "This card adds an Image in your gGallery."
},
"droptoken": [
"image"
],
"args": [
{
"name": "name",
"type": "text",
"placeholder": {
"en": "Name"
}
}
],
"id": "create-image"
}
]
},
"widgets": {
"slideshow": {
"name": {
Expand Down

0 comments on commit a3c5cbf

Please sign in to comment.