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/local port custom service #791

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/customservices.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ within Homer:

- [Custom Services](#custom-services)
- [Common options](#common-options)
- [GenericWithPort](#genericwithport)
- [PiHole](#pihole)
- [OpenWeatherMap](#openweathermap)
- [Medusa](#medusa)
Expand Down Expand Up @@ -51,6 +52,17 @@ If you experiencing any issue, please have a look to the [troubleshooting](troub
type: "<type>"
```

## GenericWithPort
Is shown as a generic service, but you can specify an additional port where the service is running, in case there is no DNS for the domain or reverse proxy for this service.
A link to access this service via port is added to which the browser is redirected based on the base url where the user accessed homer.
```yaml
- name: "My Service"
logo: "assets/tools/sample.png"
url: "http://my-service.domain"
port: <my-port>
type: "GenericWithPort"
```

## PiHole

Using the PiHole service you can display info about your local PiHole instance right on your Homer dashboard.
Expand Down Expand Up @@ -479,4 +491,4 @@ You need to set the type to HomeAssistant, provide an api key and enable cors on
separator: " " # optional, how to separate items
```
To create an API token on HomeAssistant, follow the [official documentation here](https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token).
To enable cors on HomeAssistant, edit your `configuration.yml` and add the IP of Homer to `https: cors_allowed_origins`
To enable cors on HomeAssistant, edit your `configuration.yml` and add the IP of Homer to `https: cors_allowed_origins`
85 changes: 85 additions & 0 deletions src/components/services/GenericWithPort.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<div class="is-multiline layout-vertical">
<div
class="card"
:style="`background-color:${item.background};`"
:class="item.class"
>
<a :href="item.url" :target="item.target" rel="noreferrer">
<div class="card-content">
<div :class="mediaClass">
<slot name="icon">
<div v-if="item.logo" class="media-left">
<figure class="image is-48x48">
<img :src="item.logo" :alt="`${item.name} logo`" />
</figure>
</div>
<div v-if="item.icon" class="media-left">
<figure class="image is-48x48">
<i style="font-size: 35px" :class="['fa-fw', item.icon]"></i>
</figure>
</div>
</slot>
<div class="media-content">
<slot name="content">
<p class="title is-4">{{ item.name }}</p>
<p class="subtitle is-6" v-if="item.subtitle">
{{ item.subtitle }}
</p>
</slot>
</div>
<slot name="indicator" class="indicator"></slot>
</div>
<div class="tag" :class="item.tagstyle" v-if="item.tag">
<strong class="tag-text">#{{ item.tag }}</strong>
</div>
</div>
</a>
<footer class="card-footer" v-if="item.port">
<a
href="/" :target="item.target"
@click="onClickPort"
@mouseover="onMouseoverPort"
rel="noreferrer"
class="card-footer-item"
>:{{ item.port }}</a>
</footer>
</div>
</div>
</template>

<script>
export default {
name: "GenericWithPort",
props: {
item: Object,
},
computed: {
mediaClass: function () {
return { media: true, "no-subtitle": !this.item.subtitle };
},
},
methods: {
onMouseoverPort: function(event){
event.target.port = this.item.port;
},
onClickPort: function(event){
event.target.port = this.item.port;
}
},
};
</script>

<style scoped lang="scss">
.media-left {
.image {
display: flex;
align-items: center;
}

img {
max-height: 100%;
object-fit: contain;
}
}
</style>