diff --git a/packages/dashboard/util.go b/packages/dashboard/util.go index e0ee78e52e..2f7378a4f4 100644 --- a/packages/dashboard/util.go +++ b/packages/dashboard/util.go @@ -6,6 +6,15 @@ import ( "time" ) +const maxLength = 150 + +func Trim(s string) string { + if len(s) > maxLength { + return s[0:maxLength] + "..." + } + return s +} + func FormatTimestamp(ts interface{}) string { t, ok := ts.(time.Time) if !ok { diff --git a/tools/wwallet/dashboard/base.go b/tools/wwallet/dashboard/base.go index 0290b2f4a5..8bd27fe137 100644 --- a/tools/wwallet/dashboard/base.go +++ b/tools/wwallet/dashboard/base.go @@ -28,6 +28,7 @@ type NavPage struct { func MakeTemplate(parts ...string) *template.Template { t := template.New("").Funcs(template.FuncMap{ "formatTimestamp": dashboard.FormatTimestamp, + "trim": dashboard.Trim, "exploreAddressUrl": dashboard.ExploreAddressUrl( dashboard.ExploreAddressUrlFromGoshimmerUri(config.GoshimmerApi()), ), @@ -90,7 +91,7 @@ const TplSCInfo = ` Smart contract details

SC address: {{template "address" .Status.SCAddress}}

Program hash: {{.Status.ProgramHash}}

-

Description of the instance: {{.Status.Description}}

+

Description of the instance: {{trim .Status.Description}}

Owner address: {{template "address" .Status.OwnerAddress}}

Minimum node reward (fee): {{.Status.MinimumReward}}

Color: {{.Config.BootupData.Color}}

diff --git a/tools/wwallet/sc/dwf/dwfdashboard/dwfdashboard.go b/tools/wwallet/sc/dwf/dwfdashboard/dwfdashboard.go index 63a1e10302..1b1c745ec3 100644 --- a/tools/wwallet/sc/dwf/dwfdashboard/dwfdashboard.go +++ b/tools/wwallet/sc/dwf/dwfdashboard/dwfdashboard.go @@ -68,7 +68,7 @@ const tplDwf = `

Log (latest first)

{{range $i, $di := .Status.LastRecordsDesc}}
- {{$di.Seq}}: {{$di.Feedback}} + {{$di.Seq}}: {{trim $di.Feedback}}

Sender: {{template "address" $di.Sender}}

Amount: {{$di.Amount}} IOTAs

When: {{formatTimestamp $di.When}}

diff --git a/tools/wwallet/sc/fa/fadashboard/fadashboard.go b/tools/wwallet/sc/fa/fadashboard/fadashboard.go index 943c6f68fe..0f20df0d01 100644 --- a/tools/wwallet/sc/fa/fadashboard/fadashboard.go +++ b/tools/wwallet/sc/fa/fadashboard/fadashboard.go @@ -63,7 +63,7 @@ const tplFairAuction = `
{{range $color, $auction := .Status.Auctions}}
- {{$auction.Description}} + {{trim $auction.Description}}

For sale: {{$auction.NumTokens}} tokens of color {{$color}}

Owner: {{template "address" $auction.AuctionOwner}}

Started at: {{formatTimestamp $auction.WhenStarted}}

diff --git a/tools/wwallet/sc/tr/trdashboard/trdashboard.go b/tools/wwallet/sc/tr/trdashboard/trdashboard.go index 81a0f6a470..32cdc71531 100644 --- a/tools/wwallet/sc/tr/trdashboard/trdashboard.go +++ b/tools/wwallet/sc/tr/trdashboard/trdashboard.go @@ -99,7 +99,7 @@ const tplTokenRegistry = `
{{range $color, $tm := .Status.Registry}}
- {{$tm.Description}} + {{trim $tm.Description}}

Color: {{$color}}

{{template "tmdetails" $tm}}
@@ -114,7 +114,7 @@ const tplTokenRegistry = ` {{if .Color}} {{if .QueryResult}} -

{{.QueryResult.Description}}

+

{{trim .QueryResult.Description}}

Color: {{.Color}}

{{template "tmdetails" .QueryResult}} {{else}}