Improve JSON value rendering

This commit is contained in:
lideming 2021-02-24 12:50:54 +08:00
parent f4c8887454
commit 6809ca5f6a
3 changed files with 9 additions and 9 deletions

View file

@ -7,6 +7,12 @@ mixin nav_item(name, displayName, href)
li(class=((navigate && navigate.active === name) ? 'active' : ''))
a(href=href) #{displayName}
mixin json_value(value)
- if ((!!value ) && (value.constructor == Object || value.constructor == Array))
code(style='white-space: pre;')= JSON.stringify(value, null, 2)
- else
code= value
doctype html
html(lang='en')
head

View file

@ -14,10 +14,7 @@ block net_content
.col-sm-2
a(href=('/controller/network/' + member.nwid + '/member/' + member.address + '/' + key)) #{key}:
.col-sm-10
- if ((!!value ) && (value.constructor == Object || value.constructor == Array))
code #{JSON.stringify(value)}
- else
code #{value}
+json_value(value)
a.btn.btn-default(href=('/controller/network/' + member.nwid + "#members") name='networks' role='button' style='margin-top: 10px;')
| Members

View file

@ -123,13 +123,10 @@ block net_content
h3#detail Detail for network
each value, key in network
.row
.row(style='margin: 5px 0;')
.col-sm-2
a(href= network.nwid + '/' + key) #{key}:
.col-sm-10
- if ((!!value ) && (value.constructor == Object || value.constructor == Array))
code #{JSON.stringify(value)}
- else
code #{value}
+json_value(value)
a.btn.btn-default(href='/controller/networks' name='networks' role='button' style='margin-top: 10px;') Networks