mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-28 20:27:21 +00:00
Compare commits
14 Commits
updates-st
...
logbook-ne
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44a52075ec | ||
|
|
c9c3be71cc | ||
|
|
f1b965dcc5 | ||
|
|
a08a23a93d | ||
|
|
2040a49458 | ||
|
|
df94f4f907 | ||
|
|
96d375cb84 | ||
|
|
7a9c2f56c5 | ||
|
|
5ec7193e5c | ||
|
|
d89e4337f2 | ||
|
|
2e192d5021 | ||
|
|
7db28c0156 | ||
|
|
f09c842981 | ||
|
|
6c73ae5bf7 |
@@ -50,6 +50,21 @@ export class HaButtonMenu extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
protected firstUpdated(changedProps): void {
|
||||
super.firstUpdated(changedProps);
|
||||
|
||||
if (document.dir === "rtl") {
|
||||
this.updateComplete.then(() => {
|
||||
this.querySelectorAll("mwc-list-item").forEach((item) => {
|
||||
const style = document.createElement("style");
|
||||
style.innerHTML =
|
||||
"span.material-icons:first-of-type { margin-left: var(--mdc-list-item-graphic-margin, 32px) !important; margin-right: 0px !important;}";
|
||||
item!.shadowRoot!.appendChild(style);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _handleClick(): void {
|
||||
if (this.disabled) {
|
||||
return;
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
import { Fab } from "@material/mwc-fab";
|
||||
import { FabBase } from "@material/mwc-fab/mwc-fab-base";
|
||||
import { styles } from "@material/mwc-fab/mwc-fab.css";
|
||||
import { customElement } from "lit/decorators";
|
||||
import { css } from "lit";
|
||||
|
||||
@customElement("ha-fab")
|
||||
export class HaFab extends Fab {
|
||||
export class HaFab extends FabBase {
|
||||
protected firstUpdated(changedProperties) {
|
||||
super.firstUpdated(changedProperties);
|
||||
this.style.setProperty("--mdc-theme-secondary", "var(--primary-color)");
|
||||
}
|
||||
|
||||
static override styles = Fab.styles.concat([
|
||||
static override styles = [
|
||||
styles,
|
||||
css`
|
||||
:host-context([style*="direction: rtl;"])
|
||||
.mdc-fab--extended
|
||||
.mdc-fab__icon {
|
||||
margin-left: 12px !important;
|
||||
margin-right: calc(12px - 20px) !important;
|
||||
:host .mdc-fab--extended .mdc-fab__icon {
|
||||
margin-inline-start: -8px;
|
||||
margin-inline-end: 12px;
|
||||
direction: var(--direction);
|
||||
}
|
||||
`,
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
@@ -46,7 +46,6 @@ export const getLogbookDataForContext = async (
|
||||
startDate,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
contextId
|
||||
)
|
||||
);
|
||||
@@ -56,20 +55,13 @@ export const getLogbookData = async (
|
||||
hass: HomeAssistant,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
entityId?: string,
|
||||
entity_matches_only?: boolean
|
||||
entityId?: string
|
||||
): Promise<LogbookEntry[]> => {
|
||||
const localize = await hass.loadBackendTranslation("device_class");
|
||||
return addLogbookMessage(
|
||||
hass,
|
||||
localize,
|
||||
await getLogbookDataCache(
|
||||
hass,
|
||||
startDate,
|
||||
endDate,
|
||||
entityId,
|
||||
entity_matches_only
|
||||
)
|
||||
await getLogbookDataCache(hass, startDate, endDate, entityId)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -97,8 +89,7 @@ export const getLogbookDataCache = async (
|
||||
hass: HomeAssistant,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
entityId?: string,
|
||||
entity_matches_only?: boolean
|
||||
entityId?: string
|
||||
) => {
|
||||
const ALL_ENTITIES = "*";
|
||||
|
||||
@@ -125,8 +116,7 @@ export const getLogbookDataCache = async (
|
||||
hass,
|
||||
startDate,
|
||||
endDate,
|
||||
entityId !== ALL_ENTITIES ? entityId : undefined,
|
||||
entity_matches_only
|
||||
entityId !== ALL_ENTITIES ? entityId : undefined
|
||||
).then((entries) => entries.reverse());
|
||||
return DATA_CACHE[cacheKey][entityId];
|
||||
};
|
||||
@@ -136,7 +126,6 @@ const getLogbookDataFromServer = async (
|
||||
startDate: string,
|
||||
endDate?: string,
|
||||
entityId?: string,
|
||||
entitymatchesOnly?: boolean,
|
||||
contextId?: string
|
||||
) => {
|
||||
const params = new URLSearchParams();
|
||||
@@ -147,9 +136,6 @@ const getLogbookDataFromServer = async (
|
||||
if (entityId) {
|
||||
params.append("entity", entityId);
|
||||
}
|
||||
if (entitymatchesOnly) {
|
||||
params.append("entity_matches_only", "");
|
||||
}
|
||||
if (contextId) {
|
||||
params.append("context_id", contextId);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import "@material/mwc-button";
|
||||
import { mdiContentCopy } from "@mdi/js";
|
||||
import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||
import "../../../../components/ha-card";
|
||||
import { copyToClipboard } from "../../../../common/util/copy-clipboard";
|
||||
import "../../../../components/ha-alert";
|
||||
import "../../../../components/ha-card";
|
||||
import "../../../../components/ha-switch";
|
||||
// eslint-disable-next-line
|
||||
import type { HaSwitch } from "../../../../components/ha-switch";
|
||||
@@ -13,6 +15,7 @@ import {
|
||||
disconnectCloudRemote,
|
||||
} from "../../../../data/cloud";
|
||||
import type { HomeAssistant } from "../../../../types";
|
||||
import { showToast } from "../../../../util/toast";
|
||||
import { showCloudCertificateDialog } from "../dialog-cloud-certificate/show-dialog-cloud-certificate";
|
||||
|
||||
@customElement("cloud-remote-pref")
|
||||
@@ -48,6 +51,11 @@ export class CloudRemotePref extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
const urlParts = remote_domain!.split(".");
|
||||
const hiddenURL = `https://${urlParts[0].substring(0, 5)}***.${
|
||||
urlParts[1]
|
||||
}.${urlParts[2]}.${urlParts[3]}`;
|
||||
|
||||
return html`
|
||||
<ha-card
|
||||
outlined
|
||||
@@ -85,8 +93,13 @@ export class CloudRemotePref extends LitElement {
|
||||
class="break-word"
|
||||
rel="noreferrer"
|
||||
>
|
||||
https://${remote_domain}</a
|
||||
${hiddenURL}</a
|
||||
>.
|
||||
<ha-svg-icon
|
||||
.url=${`https://${remote_domain}`}
|
||||
.path=${mdiContentCopy}
|
||||
@click=${this._copyURL}
|
||||
></ha-svg-icon>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<a
|
||||
@@ -133,6 +146,14 @@ export class CloudRemotePref extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async _copyURL(ev): Promise<void> {
|
||||
const url = ev.currentTarget.url;
|
||||
await copyToClipboard(url);
|
||||
showToast(this, {
|
||||
message: this.hass.localize("ui.common.copied_clipboard"),
|
||||
});
|
||||
}
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return css`
|
||||
.preparing {
|
||||
@@ -154,9 +175,6 @@ export class CloudRemotePref extends LitElement {
|
||||
font-weight: bold;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.warning ha-svg-icon {
|
||||
color: var(--warning-color);
|
||||
}
|
||||
.break-word {
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
@@ -178,6 +196,11 @@ export class CloudRemotePref extends LitElement {
|
||||
.spacer {
|
||||
flex-grow: 1;
|
||||
}
|
||||
ha-svg-icon {
|
||||
--mdc-icon-size: 18px;
|
||||
color: var(--secondary-text-color);
|
||||
cursor: pointer;
|
||||
}
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import { customElement, property, query, state } from "lit/decorators";
|
||||
import { classMap } from "lit/directives/class-map";
|
||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||
import { dynamicElement } from "../../../common/dom/dynamic-element-directive";
|
||||
import "../../../components/ha-dialog";
|
||||
import "../../../components/ha-circular-progress";
|
||||
import "../../../components/ha-dialog";
|
||||
import { getConfigFlowHandlers } from "../../../data/config_flow";
|
||||
import { createCounter } from "../../../data/counter";
|
||||
import { createInputBoolean } from "../../../data/input_boolean";
|
||||
@@ -16,10 +16,12 @@ import { createInputDateTime } from "../../../data/input_datetime";
|
||||
import { createInputNumber } from "../../../data/input_number";
|
||||
import { createInputSelect } from "../../../data/input_select";
|
||||
import { createInputText } from "../../../data/input_text";
|
||||
import { domainToName } from "../../../data/integration";
|
||||
import { createTimer } from "../../../data/timer";
|
||||
import { showConfigFlowDialog } from "../../../dialogs/config-flow/show-dialog-config-flow";
|
||||
import { haStyleDialog } from "../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { brandsUrl } from "../../../util/brands-url";
|
||||
import { Helper } from "./const";
|
||||
import "./forms/ha-counter-form";
|
||||
import "./forms/ha-input_boolean-form";
|
||||
@@ -29,9 +31,7 @@ import "./forms/ha-input_number-form";
|
||||
import "./forms/ha-input_select-form";
|
||||
import "./forms/ha-input_text-form";
|
||||
import "./forms/ha-timer-form";
|
||||
import { domainToName } from "../../../data/integration";
|
||||
import type { ShowDialogHelperDetailParams } from "./show-dialog-helper-detail";
|
||||
import { brandsUrl } from "../../../util/brands-url";
|
||||
|
||||
const HELPERS = {
|
||||
input_boolean: createInputBoolean,
|
||||
@@ -187,13 +187,13 @@ export class DialogHelperDetail extends LitElement {
|
||||
escapeKeyAction
|
||||
.heading=${this._domain
|
||||
? this.hass.localize(
|
||||
"ui.panel.config.helpers.dialog.add_platform",
|
||||
"ui.panel.config.helpers.dialog.create_platform",
|
||||
"platform",
|
||||
this.hass.localize(
|
||||
`ui.panel.config.helpers.types.${this._domain}`
|
||||
) || this._domain
|
||||
)
|
||||
: this.hass.localize("ui.panel.config.helpers.dialog.add_helper")}
|
||||
: this.hass.localize("ui.panel.config.helpers.dialog.create_helper")}
|
||||
>
|
||||
${content}
|
||||
</ha-dialog>
|
||||
|
||||
@@ -218,7 +218,7 @@ export class HaConfigHelpers extends SubscribeMixin(LitElement) {
|
||||
<ha-fab
|
||||
slot="fab"
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.helpers.picker.add_helper"
|
||||
"ui.panel.config.helpers.picker.create_helper"
|
||||
)}
|
||||
extended
|
||||
@click=${this._createHelpler}
|
||||
|
||||
@@ -235,8 +235,8 @@ class ErrorLogCard extends LitElement {
|
||||
color: var(--warning-color);
|
||||
}
|
||||
|
||||
:host-context([style*="direction: rtl;"]) mwc-button {
|
||||
direction: rtl;
|
||||
mwc-button {
|
||||
direction: var(--direction);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -217,13 +217,20 @@ class HaLogbook extends LitElement {
|
||||
.datetime=${item.when}
|
||||
capitalize
|
||||
></ha-relative-time>
|
||||
${item.domain === "automation" &&
|
||||
${["script", "automation"].includes(item.domain!) &&
|
||||
item.context_id! in this.traceContexts
|
||||
? html`
|
||||
-
|
||||
<a
|
||||
href=${`/config/automation/trace/${
|
||||
this.traceContexts[item.context_id!].item_id
|
||||
href=${`/config/${
|
||||
this.traceContexts[item.context_id!].domain
|
||||
}/trace/${
|
||||
this.traceContexts[item.context_id!].domain ===
|
||||
"script"
|
||||
? `script.${
|
||||
this.traceContexts[item.context_id!].item_id
|
||||
}`
|
||||
: this.traceContexts[item.context_id!].item_id
|
||||
}?run_id=${
|
||||
this.traceContexts[item.context_id!].run_id
|
||||
}`}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { atLeastVersion } from "../common/config/version";
|
||||
import { computeLocalize, LocalizeFunc } from "../common/translations/localize";
|
||||
import { computeRTL } from "../common/util/compute_rtl";
|
||||
import { computeRTLDirection } from "../common/util/compute_rtl";
|
||||
import { debounce } from "../common/util/debounce";
|
||||
import {
|
||||
getHassTranslations,
|
||||
@@ -180,12 +180,19 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
|
||||
|
||||
private _applyTranslations(hass: HomeAssistant) {
|
||||
document.querySelector("html")!.setAttribute("lang", hass.language);
|
||||
this.style.direction = computeRTL(hass) ? "rtl" : "ltr";
|
||||
this._applyDirection(hass);
|
||||
this._loadCoreTranslations(hass.language);
|
||||
this.__loadedFragmetTranslations = new Set();
|
||||
this._loadFragmentTranslations(hass.language, hass.panelUrl);
|
||||
}
|
||||
|
||||
private _applyDirection(hass: HomeAssistant) {
|
||||
const direction = computeRTLDirection(hass);
|
||||
this.style.direction = direction;
|
||||
document.dir = direction;
|
||||
this.style.setProperty("--direction", direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load translations from the backend
|
||||
* @param language language to fetch
|
||||
|
||||
@@ -1479,13 +1479,13 @@
|
||||
"type": "Type",
|
||||
"editable": "Editable"
|
||||
},
|
||||
"add_helper": "Add helper",
|
||||
"create_helper": "Create helper",
|
||||
"no_helpers": "Looks like you don't have any helpers yet!"
|
||||
},
|
||||
"dialog": {
|
||||
"create": "Create",
|
||||
"add_helper": "Add helper",
|
||||
"add_platform": "Add {platform}"
|
||||
"create_helper": "Create helper",
|
||||
"create_platform": "Create {platform}"
|
||||
}
|
||||
},
|
||||
"core": {
|
||||
|
||||
Reference in New Issue
Block a user