@@ -497,7 +497,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
497497 attr :current , :integer , required: true , doc: "The current value of the usage."
498498 attr :limit , :integer , required: true , doc: "The max value of usage."
499499
500- attr :dom_sub_id , :string ,
500+ attr :dom_id , :string ,
501501 required: true ,
502502 doc: "An unique identifier for the usage that will be concatenated to `dom_id`."
503503
@@ -513,7 +513,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
513513 < div class = "card " >
514514 < div class = "card-body card-usage " >
515515 <%= for usage <- @ usage do %>
516- < . title_bar_component dom_id = { "#{ @ dom_id } -#{ usage . dom_sub_id } " } percent = { usage . percent } csp_nonces = { @ csp_nonces } >
516+ < . title_bar_component dom_id = { "#{ @ dom_id } -#{ usage . dom_id } " } percent = { usage . percent } csp_nonces = { @ csp_nonces } >
517517 < div >
518518 <%= usage . title %>
519519 < . hint text = { usage [ :hint ] } :if = { usage [ :hint ] } />
@@ -574,7 +574,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
574574 doc: """
575575 A list of `Map` with the following keys:
576576 * `:data` - A list of tuples with 4 elements with the following data: `{usage_name, usage_percent, color, hint}`
577- * `:dom_sub_id ` - Required. Usage identifier.
577+ * `:dom_id ` - Required. Usage identifier.
578578 * `:title`- Bar title.
579579 """
580580
@@ -585,6 +585,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
585585
586586 attr :total_legend , :string , required: true , doc: "The legent of the total usage."
587587 attr :total_usage , :string , required: true , doc: "The value of the total usage."
588+ attr :dom_id , :string , default: nil , doc: "id attribute for the HTML the main tag."
588589
589590 attr :csp_nonces , :any ,
590591 required: true ,
@@ -606,12 +607,12 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
606607 < div class = "card " >
607608 < . card_title title = { @ inner_title } hint = { @ inner_hint } />
608609 < div class = "card-body " >
609- < div phx-hook = "PhxColorBarHighlight " id = " cpu -color-bars ">
610+ < div phx-hook = "PhxColorBarHighlight " id = { " #{ @ dom_id } -color-bars"} >
610611 < div :for = { usage <- @ usages } class = "flex-grow-1 mb-3 " >
611612 < div class = "progress color-bar-progress flex-grow-1 mb-3 " >
612613 < span :if = { usage [ :title ] } class = "color-bar-progress-title " > <%= usage [ :title ] %> </ span >
613614 <%= for { { name , value , color , _desc } , index } <- Enum . with_index ( usage . data ) do %>
614- < style nonce = { @ csp_nonces . style } > #<%= "cpu -#{ usage . dom_sub_id } -progress-#{ index } " %> { width :< % = value % > % } </ style >
615+ < style nonce = { @ csp_nonces . style } > #<%= "#{ @ dom_id } -#{ usage . dom_id } -progress-#{ index } " %> { width :< % = value % > % } </ style >
615616 < div
616617 title = { "#{ name } - #{ Phoenix.LiveDashboard.Helpers . format_percent ( value ) } " }
617618 class = { "progress-bar color-bar-progress-bar bg-gradient-#{ color } " }
@@ -621,7 +622,7 @@ defmodule Phoenix.LiveDashboard.PageBuilder do
621622 aria-valuemax = "100 "
622623 data-name = { name }
623624 data-empty = { empty? ( value ) }
624- id = { "cpu -#{ usage . dom_sub_id } -progress-#{ index } " } >
625+ id = { "#{ @ dom_id } -#{ usage . dom_id } -progress-#{ index } " } >
625626 </ div >
626627 <% end %>
627628 </ div >
0 commit comments