1
1
import { html , CSSResultGroup , LitElement , TemplateResult , nothing } from "lit" ;
2
2
import { customElement , property , state } from "lit/decorators" ;
3
3
4
+ import { mdiPause , mdiAutorenew } from "@mdi/js" ;
4
5
import memoize from "memoize-one" ;
5
6
6
7
import "@ha/layouts/hass-loading-screen" ;
@@ -13,6 +14,7 @@ import type {
13
14
DataTableRowData ,
14
15
RowClickedEvent ,
15
16
} from "@ha/components/data-table/ha-data-table" ;
17
+ import "@ha/components/ha-icon-button" ;
16
18
import { haStyle } from "@ha/resources/styles" ;
17
19
import { HomeAssistant , Route } from "@ha/types" ;
18
20
import type { PageNavigation } from "@ha/layouts/hass-tabs-subpage" ;
@@ -47,6 +49,8 @@ export class KNXGroupMonitor extends LitElement {
47
49
48
50
@state ( ) private _dialogIndex : number | null = null ;
49
51
52
+ @state ( ) private _pause : boolean = false ;
53
+
50
54
public disconnectedCallback ( ) {
51
55
super . disconnectedCallback ( ) ;
52
56
if ( this . subscribed ) {
@@ -99,6 +103,7 @@ export class KNXGroupMonitor extends LitElement {
99
103
sortable : true ,
100
104
title : this . knx . localize ( "group_monitor_source" ) ,
101
105
flex : 2 ,
106
+ minWidth : "0" , // prevent horizontal scroll on very narrow screens
102
107
template : ( row ) =>
103
108
projectLoaded
104
109
? html `< div > ${ row . sourceAddress } </ div >
@@ -117,6 +122,7 @@ export class KNXGroupMonitor extends LitElement {
117
122
filterable : true ,
118
123
title : this . knx . localize ( "group_monitor_destination" ) ,
119
124
flex : 2 ,
125
+ minWidth : "0" , // prevent horizontal scroll on very narrow screens
120
126
template : ( row ) =>
121
127
projectLoaded
122
128
? html `< div > ${ row . destinationAddress } </ div >
@@ -155,12 +161,14 @@ export class KNXGroupMonitor extends LitElement {
155
161
title : this . knx . localize ( "group_monitor_value" ) ,
156
162
filterable : true ,
157
163
flex : 1 ,
164
+ minWidth : "0" , // prevent horizontal scroll on very narrow screens
158
165
} ,
159
166
} ) ,
160
167
) ;
161
168
162
169
protected telegram_callback ( telegram : TelegramDict ) : void {
163
170
this . telegrams . push ( telegram ) ;
171
+ if ( this . _pause ) return ;
164
172
const rows = [ ...this . rows ] ;
165
173
rows . push ( this . _telegramToRow ( telegram , rows . length ) ) ;
166
174
this . rows = rows ;
@@ -208,11 +216,31 @@ export class KNXGroupMonitor extends LitElement {
208
216
id="index"
209
217
.clickable=${ true }
210
218
@row-click=${ this . _rowClicked }
211
- > </ hass-tabs-subpage-data-table >
219
+ >
220
+ < ha-icon-button
221
+ slot ="toolbar-icon "
222
+ .label =${ this . _pause ? "Resume" : "Pause" }
223
+ .path =${ this . _pause ? mdiAutorenew : mdiPause }
224
+ @click=${ this . _togglePause }
225
+ > </ ha-icon-button >
226
+ </ hass-tabs-subpage-data-table >
212
227
${ this . _dialogIndex !== null ? this . _renderTelegramInfoDialog ( this . _dialogIndex ) : nothing }
213
228
` ;
214
229
}
215
230
231
+ private _togglePause ( ) : void {
232
+ this . _pause = ! this . _pause ;
233
+ if ( ! this . _pause ) {
234
+ const currentRowCount = this . rows . length ;
235
+ const pauseTelegrams = this . telegrams . slice ( currentRowCount ) ;
236
+ this . rows = this . rows . concat (
237
+ pauseTelegrams . map ( ( telegram , index ) =>
238
+ this . _telegramToRow ( telegram , currentRowCount + index ) ,
239
+ ) ,
240
+ ) ;
241
+ }
242
+ }
243
+
216
244
private _renderTelegramInfoDialog ( index : number ) : TemplateResult {
217
245
return html ` < knx-telegram-info-dialog
218
246
.hass =${ this . hass }
0 commit comments