User trace report can contains messages
This commit is contained in:
parent
1348678be1
commit
49dd674f72
@ -154,16 +154,21 @@
|
||||
<TraceStatus status={trace.status} />
|
||||
</div>
|
||||
{#if trace.items}
|
||||
<ul class="list-group">
|
||||
<ul class="list-group mb-3">
|
||||
{#each trace.items as item}
|
||||
<li class="list-group-item fw-bold">
|
||||
<li class="list-group-item">
|
||||
<i
|
||||
class="me-1 bi"
|
||||
class:bi-check-lg={item.status == "success"}
|
||||
class:bi-x-lg={item.status == "failure"}
|
||||
class:bi-question-lg={item.status != "success" && item.status != "failure"}
|
||||
></i>
|
||||
{item.title}
|
||||
<strong>
|
||||
{item.title}
|
||||
</strong>
|
||||
{#if item.msg}
|
||||
{item.msg}
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
18
works.go
18
works.go
@ -375,8 +375,9 @@ func declareAPIAdminWorksRoutes(router *gin.RouterGroup) {
|
||||
}
|
||||
|
||||
type UserTraceItem struct {
|
||||
Title string `json:"title"`
|
||||
Status string `json:"status"`
|
||||
Title string `json:"title"`
|
||||
Status string `json:"status"`
|
||||
Message string `json:"msg,omitempty"`
|
||||
}
|
||||
|
||||
type UserTrace struct {
|
||||
@ -516,14 +517,19 @@ func declareAPIAuthWorksRoutes(router *gin.RouterGroup) {
|
||||
items := []UserTraceItem{}
|
||||
for _, line := range result {
|
||||
if strings.HasPrefix(line.Message, "report:") {
|
||||
tmp := strings.Split(strings.TrimSpace(line.Message), ":")
|
||||
if len(tmp) != 3 {
|
||||
tmp := strings.SplitN(strings.TrimSpace(line.Message), ":", 4)
|
||||
if len(tmp) < 3 {
|
||||
continue
|
||||
}
|
||||
items = append(items, UserTraceItem{
|
||||
|
||||
uti := UserTraceItem{
|
||||
Title: tmp[1],
|
||||
Status: tmp[2],
|
||||
})
|
||||
}
|
||||
if len(tmp) >= 4 {
|
||||
uti.Message = tmp[3]
|
||||
}
|
||||
items = append(items, uti)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user