whitelabel error log

This commit is contained in:
Dot-Rar 2020-06-12 18:11:35 +01:00
parent b2f4968c64
commit 799ef8719b
4 changed files with 109 additions and 66 deletions

View File

@ -35,10 +35,21 @@ func WhitelabelGet(ctx *gin.Context) {
return
}
// Get errors
errors, err := database.Client.WhitelabelErrors.GetRecent(bot.BotId, 10)
if err != nil {
ctx.JSON(500, gin.H{
"success": false,
"error": err.Error(),
})
return
}
ctx.JSON(200, gin.H{
"success": true,
"id": strconv.FormatUint(bot.BotId, 10),
"status": status,
"errors": errors,
})
}
}

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20200425115930-0ca198cc8306
github.com/TicketsBot/common v0.0.0-20200529141045-7426ad13f1a4
github.com/TicketsBot/database v0.0.0-20200606205929-6851b2444a67
github.com/TicketsBot/database v0.0.0-20200612170437-4f91fa8bf2f1
github.com/apex/log v1.1.2
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible

View File

@ -15,6 +15,10 @@ body {
color: white;
}
::-webkit-scrollbar {
display: none;
}
.sidebar {
background-size: cover;
overflow-x: hidden !important;

View File

@ -46,8 +46,9 @@
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h4 class="card-title">Custom Status</h4>
@ -58,7 +59,8 @@
<div class="col-md-12">
<div class="form-group">
<label>Status</label>
<input name="status" type="text" class="form-control" placeholder="DM for help | t!help" id="status">
<input name="status" type="text" class="form-control" placeholder="DM for help | t!help"
id="status">
</div>
</div>
</div>
@ -77,6 +79,25 @@
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h4 class="card-title">Error Logs</h4>
</div>
<div class="card-body" id="card">
<table class="table">
<thead>
<tr>
<th scope="col">Error</th>
</tr>
</thead>
<tbody id="error_body">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@ -130,17 +151,24 @@
showToast('Success', 'Updated status successfully')
}
async function loadStatus() {
async function loadDetails() {
const res = await axios.get('/user/whitelabel');
if (res.status !== 200 || !res.data.success) {
showToast('Error', res.data.error);
return;
}
// set status
document.getElementById('status').value = res.data.status;
// append errors
for (error of res.data.errors) {
const tr = document.createElement('tr');
appendTd(tr, error);
document.getElementById('error_body').appendChild(tr);
}
}
loadStatus();
loadDetails();
</script>
</div>
{{end}}