Browse Source
IoT Hub: shorter package list in the default converter update dialog (#16652 )
* IoT Hub: the default converter update dialog shows the first three packages that use the converter, the rest on request
* IoT Hub: the rest of the packages slide open in the default converter update dialog
* IoT Hub: the converter update dialog hides at least two packages, says "and N more", and its toggle reads as a link
* IoT Hub: the converter update dialog's class comment stays on the class
* IoT Hub: converter update dialog cleanup (self-start class, trim comments)
---------
Co-authored-by: Vladyslav_Prykhodko <vprykhodko@thingsboard.io>
pull/16662/head
Shvaika Dmytro
3 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
69 additions and
4 deletions
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-converter-update-dialog.component.html
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-converter-update-dialog.component.scss
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-converter-update-dialog.component.ts
ui-ngx/src/assets/locale/locale.constant-en_US.json
@ -11,11 +11,33 @@
< div class = "tb-converter-update-name" > {{ data.update.converter.name }}< / div >
@if (data.usedBy.length) {
< span class = "tb-progress-alert-msg tb-progress-alert-msg-warning" > {{ 'iot-hub.device-update-shared' | translate }}< / span >
< ul class = "tb-converter-update-packages" >
@for (name of data.usedBy; track $index) {
< li > {{ name }}< / li >
< div >
< ul class = "tb-converter-update-packages" >
@for (name of usedByShown; track $index) {
< li > {{ name }}< / li >
}
< / ul >
@if (usedByHidden.length) {
< div id = "tb-converter-update-more" class = "tb-converter-update-more" [ class . expanded ] = " usedByExpanded "
[attr.aria-hidden]="!usedByExpanded">
< ul class = "tb-converter-update-packages" >
@for (name of usedByHidden; track $index) {
< li > {{ name }}< / li >
}
< / ul >
< / div >
}
< / ul >
< / div >
@if (usedByHidden.length) {
< button type = "button" class = "tb-converter-update-toggle self-start" aria-controls = "tb-converter-update-more"
[attr.aria-expanded]="usedByExpanded" (click)="usedByExpanded = !usedByExpanded">
@if (usedByExpanded) {
{{ 'iot-hub.device-update-shared-less' | translate }}
} @else {
{{ 'iot-hub.device-update-shared-more' | translate:{ count: usedByHidden.length } }}
}
< / button >
}
}
@if (data.modified) {
< span class = "tb-progress-alert-msg tb-progress-alert-msg-warning" >
@ -43,6 +43,38 @@
color : rgba ( 0 , 0 , 0 , 0 .54 ) ;
}
/ / Material expansion-panel timing
. tb-converter-update-more {
display : grid ;
grid-template-rows : 0 fr ;
transition : grid - template-rows 225 ms cubic-bezier ( 0 .4 , 0 , 0 .2 , 1 ) ;
> ul {
overflow : hidden ;
min-height : 0 ;
}
& . expanded {
grid-template-rows : 1 fr ;
}
@media ( prefers-reduced-motion : reduce ) {
transition : none ;
}
}
. tb-converter-update-toggle {
padding : 0 ;
border : none ;
background : none ;
font-size : 12 px ;
font-weight : 500 ;
line-height : 16 px ;
color : var ( -- tb-primary-500 ) ;
cursor : pointer ;
& : hover ,
& : focus-visible {
text-decoration : underline ;
}
}
. tb-converter-update-link {
color : #305680 ;
text-decoration : underline ;
@ -21,6 +21,8 @@ export interface IotHubConverterUpdateDialogData {
usedBy : string [ ] ;
}
const USED_BY_SHOWN = 3 ;
/ * *
* Brings an installed device package 's default converter to ThingsBoard' s default converter now , without a new version of
* the package . Closes with true once it is updated .
@ -34,6 +36,9 @@ export interface IotHubConverterUpdateDialogData {
export class TbIotHubConverterUpdateDialogComponent extends DialogComponent < TbIotHubConverterUpdateDialogComponent , boolean > {
readonly modifiedHint = splitTextWithLink ( this . translate . instant ( 'iot-hub.device-update-modified' ) ) ;
readonly usedByShown : string [ ] ;
readonly usedByHidden : string [ ] ;
usedByExpanded = false ;
updating = false ;
errorMessage : string | null = null ;
@ -46,6 +51,10 @@ export class TbIotHubConverterUpdateDialogComponent extends DialogComponent<TbIo
private translate : TranslateService
) {
super ( store , router , dialogRef ) ;
// Collapse only when at least 2 packages would be hidden
const shownCount = data . usedBy . length > USED_BY_SHOWN + 1 ? USED_BY_SHOWN : data.usedBy.length ;
this . usedByShown = data . usedBy . slice ( 0 , shownCount ) ;
this . usedByHidden = data . usedBy . slice ( shownCount ) ;
}
downloadCurrent ( ) : void {
@ -6594,6 +6594,8 @@
"device-update-no-changes" : "No changes" ,
"device-update-new" : "New" ,
"device-update-shared" : "Used by other packages. The update affects them." ,
"device-update-shared-more" : "and {{count}} more" ,
"device-update-shared-less" : "Show less" ,
"device-update-new-default-converter" : "ThingsBoard has a new version of the default converter used by this package." ,
"device-update-modified" : "Has local changes. You can download the current version <a>here</a>." ,
"device-install-unexpected-error" : "Something went wrong. Try again." ,