From a986696ffb36a98473243fe5ac3b15ccba5e38a1 Mon Sep 17 00:00:00 2001 From: Stephen M Moraco Date: Sat, 26 Sep 2020 15:51:27 -0600 Subject: [PATCH] add new show_title:false support --- README.md | 21 +++++++++++---------- info.md | 21 +++++++++++---------- src/const.ts | 2 +- src/rpi-monitor-card.ts | 28 ++++++++++++++++++++++++++-- src/types.ts | 1 + 5 files changed, 50 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 0225038..f43fd2c 100644 --- a/README.md +++ b/README.md @@ -42,16 +42,17 @@ If you don't use HACS please change the url accordingly. ## Configuration -| Name | Type | Default | Description | -| ------------- | ------ | ------------------ | ----------------------------------------------------------------------- | -| type | string | **Required** | `custom:rpi-monitor-card` | -| entity | string | **Required** | Entity State | -| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) | -| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') | -| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) | -| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) | -| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | -| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | +| Name | Type | Default | Description | +| ------------- | ------- | ------------------ | ----------------------------------------------------------------------- | +| type | string | **Required** | `custom:rpi-monitor-card` | +| entity | string | **Required** | Entity State | +| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) | +| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') | +| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) | +| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) | +| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | +| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | +| show_title | boolean | true | Show / hide the Title for this card. (Default is show - 'true') | ### Threashold Monitoring diff --git a/info.md b/info.md index 4481a03..380030e 100644 --- a/info.md +++ b/info.md @@ -34,16 +34,17 @@ If you don't use HACS please change the url accordingly. ## Configuration -| Name | Type | Default | Description | -| ------------- | ------ | ------------------ | ----------------------------------------------------------------------- | -| type | string | **Required** | `custom:rpi-monitor-card` | -| entity | string | **Required** | Entity State | -| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) | -| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') | -| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) | -| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) | -| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | -| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | +| Name | Type | Default | Description | +| ------------- | ------- | ------------------ | ----------------------------------------------------------------------- | +| type | string | **Required** | `custom:rpi-monitor-card` | +| entity | string | **Required** | Entity State | +| name | string | none | Overrides default title of the card. (Default: RPi Monitor {FQDN}) | +| name_prefix | string | 'RPi monitor' | Overrides default name prefix(Default: 'RPi Monitor') | +| card_style | string | 'glance' or 'full' | Card layout desired for this RPi. (Default is full) | +| temp_scale | string | 'C' or 'F' | Show Temperature in Celsius (C) or Fahrenheit (F). (Default is C) | +| fs_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | +| temp_severity | object | none | A list of severity values. See [Severity Coloring](#severity-coloring). | +| show_title | boolean | true | Show / hide the Title for this card. (Default is show - 'true') | ### Threashold Monitoring diff --git a/src/const.ts b/src/const.ts index f1dbe71..8697736 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1,4 +1,4 @@ -export const CARD_VERSION = '1.2.4'; +export const CARD_VERSION = '1.2.5'; /* * EXAMPLE attributes diff --git a/src/rpi-monitor-card.ts b/src/rpi-monitor-card.ts index c562ace..f3f9040 100644 --- a/src/rpi-monitor-card.ts +++ b/src/rpi-monitor-card.ts @@ -363,9 +363,19 @@ export class RPiMonitorCard extends LitElement { const rpi_fqdn = this._getAttributeValueForKey(Constants.RPI_FQDN_KEY); let cardName = 'RPi monitor ' + rpi_fqdn; + cardName = this._config.name_prefix != undefined ? this._config.name_prefix + ' ' + rpi_fqdn : cardName; cardName = this._config.name != undefined ? this._config.name : cardName; + const showCardName = this._config.show_title != undefined ? this._config.show_title : true; + if (showCardName == false) { + cardName = ''; + } + + const last_heard_full_class = showCardName == false ? 'last-heard-full-notitle' : 'last-heard-full'; + + const last_heard_class = showCardName == false ? 'last-heard-notitle' : 'last-heard'; + const card_timestamp_value = this._getRelativeTimeSinceUpdate(); if (this._useFullCard()) { @@ -385,7 +395,7 @@ export class RPiMonitorCard extends LitElement { >
${fullRows} -
${card_timestamp_value}
+
${card_timestamp_value}
`; @@ -406,7 +416,7 @@ export class RPiMonitorCard extends LitElement { >
${glanceRows} -
${card_timestamp_value}
+
${card_timestamp_value}
`; @@ -1142,6 +1152,20 @@ export class RPiMonitorCard extends LitElement { font-size: 12px; color: var(--primary-text-color); } + .last-heard-full-notitle { + position: absolute; + top: 3px; + right: 30px; + font-size: 12px; + color: var(--primary-text-color); + } + .last-heard-notitle { + position: absolute; + bottom: 5px; + right: 90px; + font-size: 12px; + color: var(--primary-text-color); + } `; } } diff --git a/src/types.ts b/src/types.ts index 8114880..b4a5171 100644 --- a/src/types.ts +++ b/src/types.ts @@ -20,6 +20,7 @@ export interface RPiMonitorCardConfig extends LovelaceCardConfig { temp_severity?: any; temp_scale?: string; name_prefix?: string; + show_title?: boolean; show_warning?: boolean; show_error?: boolean;