Skip to content

Commit

Permalink
add navigate and url actions to base remote element
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerwyn committed Dec 13, 2023
1 parent bca847a commit e020abe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/android-tv-card.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/classes/base-remote-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class BaseRemoteElement extends LitElement {
switch (action.action) {
case 'navigate':
case 'url':
this.navigate(action);
break;
case 'assist':
case 'none':
break;
Expand Down Expand Up @@ -111,6 +113,20 @@ export class BaseRemoteElement extends LitElement {
this.hass.callService(domain, service, data);
}

navigate(action: IAction) {
let url: string;
if (action.action == 'navigate') {
url = `${window.location.origin}/${action.url_path}`;
} else {
url = action.navigation_path!;
}
if (action.navigation_replace == true) {
window.location.replace(url);
} else {
window.location.assign(url);
}
}

handleConfirmation(action: IAction): boolean {
if ('confirmation' in action) {
let confirmation = action.confirmation;
Expand Down

0 comments on commit e020abe

Please sign in to comment.