mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57:21 +00:00
Add clipboard button (#8411)
This commit is contained in:
parent
13ac14d449
commit
f42c0a0717
@ -1,5 +1,8 @@
|
||||
import "@material/mwc-button";
|
||||
import { mdiInformationOutline } from "@mdi/js";
|
||||
import {
|
||||
mdiInformationOutline,
|
||||
mdiClipboardTextMultipleOutline
|
||||
} from "@mdi/js";
|
||||
import "@polymer/paper-checkbox/paper-checkbox";
|
||||
import "@polymer/paper-input/paper-input";
|
||||
import { html } from "@polymer/polymer/lib/utils/html-tag";
|
||||
@ -15,6 +18,7 @@ import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import { EventsMixin } from "../../../mixins/events-mixin";
|
||||
import LocalizeMixin from "../../../mixins/localize-mixin";
|
||||
import "../../../styles/polymer-ha-style";
|
||||
import { copyToClipboard } from "../../../common/util/copy-clipboard";
|
||||
|
||||
const ERROR_SENTINEL = {};
|
||||
/*
|
||||
@ -205,6 +209,12 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
||||
title="[[localize('ui.panel.developer-tools.tabs.states.more_info')]]"
|
||||
path="[[informationOutlineIcon()]]"
|
||||
></ha-svg-icon>
|
||||
<ha-svg-icon
|
||||
on-click="copyEntity"
|
||||
alt="[[localize('ui.panel.developer-tools.tabs.states.copy_id')]]"
|
||||
title="[[localize('ui.panel.developer-tools.tabs.states.copy_id')]]"
|
||||
path="[[clipboardOutlineIcon()]]"
|
||||
></ha-svg-icon>
|
||||
<a href="#" on-click="entitySelected">[[entity.entity_id]]</a>
|
||||
</td>
|
||||
<td>
|
||||
@ -296,6 +306,11 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
||||
};
|
||||
}
|
||||
|
||||
copyEntity(ev) {
|
||||
ev.preventDefault();
|
||||
copyToClipboard(ev.model.entity.entity_id);
|
||||
}
|
||||
|
||||
entitySelected(ev) {
|
||||
const state = ev.model.entity;
|
||||
this._entityId = state.entity_id;
|
||||
@ -345,6 +360,10 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
||||
return mdiInformationOutline;
|
||||
}
|
||||
|
||||
clipboardOutlineIcon() {
|
||||
return mdiClipboardTextMultipleOutline;
|
||||
}
|
||||
|
||||
computeEntities(hass, _entityFilter, _stateFilter, _attributeFilter) {
|
||||
return Object.keys(hass.states)
|
||||
.map(function (key) {
|
||||
|
@ -3343,7 +3343,8 @@
|
||||
"more_info": "More Info",
|
||||
"alert_entity_field": "Entity is a mandatory field",
|
||||
"last_updated": "[%key:ui::dialogs::more_info_control::last_updated%]",
|
||||
"last_changed": "[%key:ui::dialogs::more_info_control::last_changed%]"
|
||||
"last_changed": "[%key:ui::dialogs::more_info_control::last_changed%]",
|
||||
"copy_id": "Copy ID to clipboard"
|
||||
},
|
||||
"templates": {
|
||||
"title": "Template",
|
||||
|
Loading…
x
Reference in New Issue
Block a user