-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvitationsTableCard.yaml
More file actions
137 lines (137 loc) · 10.4 KB
/
InvitationsTableCard.yaml
File metadata and controls
137 lines (137 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
type: custom:html-template-card
title: ""
ignore_line_breaks: true
grid_options:
columns: 31
rows: auto
content: |
<div>
<style>
@media (max-width: 600px) {
.table-responsive { border: 0; }
.table-responsive thead { display: none; }
.table-responsive tr {
display: block;
margin-bottom: 20px;
border: 1px solid var(--divider-color, #333);
border-radius: 8px;
overflow: hidden;
background: var(--card-background-color, #1c1c1c);
}
.table-responsive td {
display: block;
text-align: left !important;
padding: 12px 16px !important;
border-bottom: 1px solid var(--divider-color, #333);
position: relative;
padding-left: 50% !important;
}
.table-responsive td:last-child {
border-bottom: 0;
}
.table-responsive td::before {
content: attr(data-label);
position: absolute;
left: 16px;
top: 16px;
font-weight: 500;
color: var(--primary-text-color, #fff);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.status-text { display: inline-block !important; }
.status-dot { display: none !important; }
}
@media (min-width: 601px) {
.status-text { display: inline-block !important; }
.status-dot { display: none !important; }
.status-header { text-align: left !important; }
.status-cell { text-align: left !important; }
}
</style>
<table class="table-responsive" style="width: 100%; border-collapse: collapse; font-family: 'Roboto', sans-serif; font-size: 14px; background: var(--card-background-color, #1c1c1c); border-radius: 8px; overflow: hidden; border: 1px solid var(--divider-color, #333); table-layout: fixed;">
<thead>
<tr>
<th style="padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--divider-color, #333); background: var(--primary-background-color, #111); color: var(--primary-text-color, #fff); font-weight: 500; font-size: 13px; width: 80px;">Invite Code</th>
<th style="padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--divider-color, #333); background: var(--primary-background-color, #111); color: var(--primary-text-color, #fff); font-weight: 500; font-size: 13px; width: 200px;">Sent to</th>
<th style="padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--divider-color, #333); background: var(--primary-background-color, #111); color: var(--primary-text-color, #fff); font-weight: 500; font-size: 13px; width: 200px;">Used By</th>
<th class="status-header" style="padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--divider-color, #333); background: var(--primary-background-color, #111); color: var(--primary-text-color, #fff); font-weight: 500; font-size: 13px; width: 60px;">Status</th>
<th style="padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--divider-color, #333); background: var(--primary-background-color, #111); color: var(--primary-text-color, #fff); font-weight: 500; font-size: 13px; width: 60px;">Created</th>
<th style="padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--divider-color, #333); background: var(--primary-background-color, #111); color: var(--primary-text-color, #fff); font-weight: 500; font-size: 13px; width: 60px;">Used</th>
</tr>
</thead>
<tbody>
{% set invites_raw = state_attr('sensor.wizarr_invitations', 'invitations') %}
{% if invites_raw %}
{# Check if it's an array or single object #}
{% if invites_raw is iterable and invites_raw is not string and invites_raw is not mapping %}
{# It's an array - loop through each invite #}
{% for invite in invites_raw %}
<tr style="border-bottom: 1px solid var(--divider-color, #333);">
<td data-label="Invite Code" style="padding: 12px 16px; text-align: left; color: var(--primary-text-color, #fff); word-wrap: break-word; overflow: hidden;">
<span style="font-family: 'Roboto Mono', monospace; background: var(--secondary-background-color, #2c2c2c); color: var(--accent-color, #03dac6); padding: 4px 8px; border-radius: 4px; font-size: 12px; display: inline-block; border: 1px solid var(--divider-color, #333); word-break: break-all;">{{ invite.code | default('N/A') }}</span>
</td>
<td data-label="Sent to" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); word-wrap: break-word; overflow: hidden; font-style: {% if not invite.notes %}italic{% else %}normal{% endif %};">
{{ invite.notes | default('No notes') }}
</td>
<td data-label="Used By" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); word-wrap: break-word; overflow: hidden; text-overflow: ellipsis;">{{ invite.used_by | default('Not used') }}</td>
<td data-label="Status" class="status-cell" style="padding: 12px 16px; text-align: left;">
<span class="status-text" style="background: {% if invite.status == 'used' %}var(--success-color, #4caf50){% else %}var(--warning-color, #ff9800){% endif %}; color: white; padding: 4px 12px; border-radius: 16px; font-size: 11px; font-weight: 500; display: inline-block; text-transform: uppercase; letter-spacing: 0.5px;">{{ invite.status | default('pending') }}</span>
<span class="status-dot" style="width: 12px; height: 12px; border-radius: 50%; background: {% if invite.status == 'used' %}var(--success-color, #4caf50){% else %}var(--warning-color, #ff9800){% endif %}; display: none;" title="{{ invite.status | default('pending') }}"></span>
</td>
<td data-label="Created" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); font-size: 13px; word-wrap: break-word;">
{% if invite.created %}
{{ relative_time(strptime(invite.created, '%Y-%m-%dT%H:%M:%S.%f')) }}
{% else %}
<span style="color: var(--disabled-text-color, #666);">Never</span>
{% endif %}
</td>
<td data-label="Used" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); font-size: 13px; word-wrap: break-word;">
{% if invite.used_at and invite.used_at != 'null' and invite.used_at != None %}
{{ relative_time(strptime(invite.used_at, '%Y-%m-%dT%H:%M:%S.%f')) }}
{% else %}
<span style="color: var(--disabled-text-color, #666);">Never</span>
{% endif %}
</td>
</tr>
{% endfor %}
{% else %}
{# It's a single object - treat as one invite #}
{% set invite = invites_raw %}
<tr style="border-bottom: 1px solid var(--divider-color, #333);">
<td data-label="Invite Code" style="padding: 12px 16px; text-align: left; color: var(--primary-text-color, #fff); word-wrap: break-word; overflow: hidden;">
<span style="font-family: 'Roboto Mono', monospace; background: var(--secondary-background-color, #2c2c2c); color: var(--accent-color, #03dac6); padding: 4px 8px; border-radius: 4px; font-size: 12px; display: inline-block; border: 1px solid var(--divider-color, #333); word-break: break-all;">{{ invite.code | default('N/A') }}</span>
</td>
<td data-label="Sent to" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); word-wrap: break-word; overflow: hidden; font-style: {% if not invite.notes %}italic{% else %}normal{% endif %};">
{{ invite.notes | default('No notes') }}
</td>
<td data-label="Used By" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); word-wrap: break-word; overflow: hidden; text-overflow: ellipsis;">{{ invite.used_by | default('Not used') }}</td>
<td data-label="Status" class="status-cell" style="padding: 12px 16px; text-align: left;">
<span class="status-text" style="background: {% if invite.status == 'used' %}var(--success-color, #4caf50){% else %}var(--warning-color, #ff9800){% endif %}; color: white; padding: 4px 12px; border-radius: 16px; font-size: 11px; font-weight: 500; display: inline-block; text-transform: uppercase; letter-spacing: 0.5px;">{{ invite.status | default('pending') }}</span>
<span class="status-dot" style="width: 12px; height: 12px; border-radius: 50%; background: {% if invite.status == 'used' %}var(--success-color, #4caf50){% else %}var(--warning-color, #ff9800){% endif %}; display: none;" title="{{ invite.status | default('pending') }}"></span>
</td>
<td data-label="Created" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); font-size: 13px; word-wrap: break-word;">
{% if invite.created %}
{{ relative_time(strptime(invite.created, '%Y-%m-%dT%H:%M:%S.%f')) }}
{% else %}
<span style="color: var(--disabled-text-color, #666);">Never</span>
{% endif %}
</td>
<td data-label="Used" style="padding: 12px 16px; text-align: left; color: var(--secondary-text-color, #ccc); font-size: 13px; word-wrap: break-word;">
{% if invite.used_at and invite.used_at != 'null' and invite.used_at != None %}
{{ relative_time(strptime(invite.used_at, '%Y-%m-%dT%H:%M:%S.%f')) }}
{% else %}
<span style="color: var(--disabled-text-color, #666);">Never</span>
{% endif %}
</td>
</tr>
{% endif %}
{% else %}
<tr>
<td colspan="6" style="padding: 20px; text-align: center; color: var(--secondary-text-color, #ccc); font-style: italic;">No invites available</td>
</tr>
{% endif %}
</tbody>
</table>
</div>