mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 07:46:37 +00:00
Sort media sources (#6960)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
5480e54185
commit
c1afed7f98
@ -10,10 +10,12 @@ import {
|
|||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
|
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||||
|
import { compare } from "../../common/string/compare";
|
||||||
import { createCloseHeading } from "../../components/ha-dialog";
|
import { createCloseHeading } from "../../components/ha-dialog";
|
||||||
import { BROWSER_SOURCE } from "../../data/media-player";
|
import { BROWSER_SOURCE } from "../../data/media-player";
|
||||||
import type { HomeAssistant } from "../../types";
|
|
||||||
import { haStyleDialog } from "../../resources/styles";
|
import { haStyleDialog } from "../../resources/styles";
|
||||||
|
import type { HomeAssistant } from "../../types";
|
||||||
import type { SelectMediaPlayerDialogParams } from "./show-select-media-source-dialog";
|
import type { SelectMediaPlayerDialogParams } from "./show-select-media-source-dialog";
|
||||||
|
|
||||||
@customElement("hui-dialog-select-media-player")
|
@customElement("hui-dialog-select-media-player")
|
||||||
@ -55,13 +57,15 @@ export class HuiDialogSelectMediaPlayer extends LitElement {
|
|||||||
"ui.components.media-browser.web-browser"
|
"ui.components.media-browser.web-browser"
|
||||||
)}</paper-item
|
)}</paper-item
|
||||||
>
|
>
|
||||||
${this._params.mediaSources.map(
|
${this._params.mediaSources
|
||||||
(source) => html`
|
.sort((a, b) => compare(computeStateName(a), computeStateName(b)))
|
||||||
<paper-item .itemName=${source.entity_id}
|
.map(
|
||||||
>${source.attributes.friendly_name}</paper-item
|
(source) => html`
|
||||||
>
|
<paper-item .itemName=${source.entity_id}
|
||||||
`
|
>${computeStateName(source)}</paper-item
|
||||||
)}
|
>
|
||||||
|
`
|
||||||
|
)}
|
||||||
</paper-listbox>
|
</paper-listbox>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user