Compare commits

...

14 Commits

Author SHA1 Message Date
Zack
44a52075ec Remove entity_matches_only 2022-05-11 10:20:28 -05:00
Yosi Levy
c9c3be71cc Merge pull request #12620 from yosilevy/RTL-no-host-context
Replace host-context with css properties - after session with Bram
2022-05-11 16:30:21 +03:00
Bram Kragten
f1b965dcc5 Update ha-fab.ts 2022-05-11 15:19:03 +02:00
Bram Kragten
a08a23a93d Use FabBase 2022-05-11 14:25:43 +02:00
Bram Kragten
2040a49458 Update var name 2022-05-11 14:21:02 +02:00
Bram Kragten
df94f4f907 Merge branch 'dev' into RTL-no-host-context 2022-05-11 14:18:26 +02:00
Bram Kragten
96d375cb84 Use / 2022-05-11 14:16:44 +02:00
Yosi Levy
7a9c2f56c5 Rtl menu fix (#12561)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2022-05-11 11:01:45 +02:00
J. Nick Koston
5ec7193e5c Show script traces in logbook (#12643) 2022-05-10 23:32:09 +02:00
Zack Barett
d89e4337f2 Hide Cloud URL - Add Copy Icon (#12655)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2022-05-10 19:37:31 +00:00
Zack Barett
2e192d5021 Update Translations to create helper (#12656) 2022-05-10 21:25:03 +02:00
Yosi Levy
7db28c0156 Update following review 2022-05-10 19:31:23 +03:00
Yosi Levy
f09c842981 Update src/state/translations-mixin.ts
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
2022-05-10 18:25:28 +03:00
Yosi Levy
6c73ae5bf7 Replace host-context with css properties 2022-05-07 06:39:39 +03:00
10 changed files with 87 additions and 48 deletions

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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);
}

View File

@@ -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;
}
`;
}
}

View File

@@ -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>

View File

@@ -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}

View File

@@ -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);
}
`;
}

View File

@@ -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
}`}

View File

@@ -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

View File

@@ -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": {