Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE_REQUEST] Widget for displaying locally stored images #487

Closed
RK62 opened this issue Feb 13, 2022 · 5 comments
Closed

[FEATURE_REQUEST] Widget for displaying locally stored images #487

RK62 opened this issue Feb 13, 2022 · 5 comments
Labels
🦄 Feature Request [ISSUE] Suggestion for new feature, update or change 👩‍💻 Good First Issue [ISSUE] Great task for newcomers to work on

Comments

@RK62
Copy link

RK62 commented Feb 13, 2022

Is your feature request related to a problem? If so, please describe.

I would like to include images on my dashboard.
This can be rendered Grafana graphics or just pictures from my last vacation.

Describe the solution you'd like

The widget should display an image from the local /app/public/item-icons directory. Maybe it would be better to provide a separate directory for this. It would be great to be able to select a single image or play random images from a directory.

Thanks a lot for DASHY! I use it every day and find it really cool.

Priority

Low (Nice-to-have)

Is this something you would be keen to implement

No response

@RK62 RK62 added the 🦄 Feature Request [ISSUE] Suggestion for new feature, update or change label Feb 13, 2022
@Lissy93
Copy link
Owner

Lissy93 commented Feb 13, 2022

Heya @RK62,
So you can actually already do this, using one of the dynamic widget options to make your own widget.
For example, using the HTML Embedded Widget, your config would be:

- type: embed
  options:
    html: '<img src="https://dashy.lan/item-icons/my-image.png" />'

Hope that helps :)

@Lissy93
Copy link
Owner

Lissy93 commented Feb 13, 2022

We could add a dedicated widget just for displaying images, it would be really easy to do by extending from the WidgetMixin.

For example, in a new file, src\components\Widgets\ImageWidget.vue:

<template>
<div class="image-widget">
  <img :src="imagePath" class="embedded-image" />
</div>
</template>

<script>
import WidgetMixin from '@/mixins/WidgetMixin';
export default {
  mixins: [WidgetMixin],
  computed: {
    imagePath() {
      if (!this.options.imagePath) this.error('You must specify an imagePath');
      return this.options.imagePath;
    },
  },
};
</script>

<style scoped lang="scss">
.image-widget {
  img.embedded-image {
    max-width: 100%;
    margin: 0.2rem auto;
  }
}
</style>

Then just import that file in WidgetBase.vue, and maybe add it into the docs. More details on doing so is available here.

You can then use the widget like normal, e.g:

- type: image
  options:
    imagePath: https://i.ibb.co/yhbt6CY/dashy.png

@Lissy93 Lissy93 added the 👩‍💻 Good First Issue [ISSUE] Great task for newcomers to work on label Feb 13, 2022
@liss-bot
Copy link
Collaborator

This issue has been marked as a good first issue for first-time contributors to implement! This is a great way to support the project, while also improving your skills, you'll also be credited as a contributor once your PR is merged. If you're new to web development, here are a collection of resources to help you get started. You can also find step-by-step tutorials for common tasks within Dashy, on the Dev Guides page. If you need any support at all, feel free to reach out via GitHub Discussions.


I am a bot, and this is an automated message 🤖

@Lissy93
Copy link
Owner

Lissy93 commented Feb 14, 2022

I've implemented this in #488, Let me know how you get on with that


Example

- name: Image Example
  icon: far fa-image
  widgets:
  - type: image
    options:
      imagePath: https://picsum.photos/400

image

See the Docs for full usage instructions.

@RK62
Copy link
Author

RK62 commented Feb 15, 2022

Thanks a lot, this works great!
In docker-compose I mount the directory
- ${SSDPROD}/dashy/media:/app/public/media
and then can use

      - type: image
        options:
           imagePath: /media/bobcat1.png

in Dashy to show it.
The given links on https://github.com/Lissy93/dashy/blob/master/docs/widgets.md#image are very helpful!

🚀 A self-hosted startpage for your server. Easy to use visual editor, status checking, widgets, themes and tons more! - dashy/widgets.md at master · Lissy93/dashy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦄 Feature Request [ISSUE] Suggestion for new feature, update or change 👩‍💻 Good First Issue [ISSUE] Great task for newcomers to work on
Projects
None yet
Development

No branches or pull requests

3 participants