diff --git a/.homeycompose/flow/actions/create-image.json b/.homeycompose/flow/actions/create-image.json new file mode 100644 index 0000000..3ef0a27 --- /dev/null +++ b/.homeycompose/flow/actions/create-image.json @@ -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" + } + } + ] +} \ No newline at end of file diff --git a/app.js b/app.js index 056bef7..764dbd0 100644 --- a/app.js +++ b/app.js @@ -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 }) { diff --git a/app.json b/app.json index cacc423..5cb68ed 100644 --- a/app.json +++ b/app.json @@ -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": {