errors
This commit is contained in:
parent
e508294e81
commit
7c1b4193cf
24
app/http/endpoints/api/whitelabelgeterrors.go
Normal file
24
app/http/endpoints/api/whitelabelgeterrors.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TicketsBot/GoPanel/database"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func WhitelabelGetErrors(ctx *gin.Context) {
|
||||||
|
userId := ctx.Keys["userid"].(uint64)
|
||||||
|
|
||||||
|
errors, err := database.Client.WhitelabelErrors.GetRecent(userId, 10)
|
||||||
|
if err != nil {
|
||||||
|
ctx.JSON(500, gin.H{
|
||||||
|
"success": false,
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.JSON(200, gin.H{
|
||||||
|
"success": true,
|
||||||
|
"errors": errors,
|
||||||
|
})
|
||||||
|
}
|
@ -114,6 +114,7 @@ func StartServer() {
|
|||||||
userGroup.GET("/guilds", api.GetGuilds)
|
userGroup.GET("/guilds", api.GetGuilds)
|
||||||
|
|
||||||
userGroup.GET("/whitelabel", api.WhitelabelGet)
|
userGroup.GET("/whitelabel", api.WhitelabelGet)
|
||||||
|
userGroup.GET("/whitelabel/errors", api.WhitelabelGetErrors)
|
||||||
|
|
||||||
userGroup.Group("/").Use(createLimiter(10, time.Minute)).POST("/whitelabel", api.WhitelabelPost)
|
userGroup.Group("/").Use(createLimiter(10, time.Minute)).POST("/whitelabel", api.WhitelabelPost)
|
||||||
userGroup.Group("/").Use(createLimiter(1, time.Second * 5)).POST("/whitelabel/status", api.WhitelabelStatusPost)
|
userGroup.Group("/").Use(createLimiter(1, time.Second * 5)).POST("/whitelabel/status", api.WhitelabelStatusPost)
|
||||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/TicketsBot/archiverclient v0.0.0-20200425115930-0ca198cc8306
|
github.com/TicketsBot/archiverclient v0.0.0-20200425115930-0ca198cc8306
|
||||||
github.com/TicketsBot/common v0.0.0-20200529141045-7426ad13f1a4
|
github.com/TicketsBot/common v0.0.0-20200529141045-7426ad13f1a4
|
||||||
github.com/TicketsBot/database v0.0.0-20200612175645-63696c6f8675
|
github.com/TicketsBot/database v0.0.0-20200612180221-a26ff96874ea
|
||||||
github.com/apex/log v1.1.2
|
github.com/apex/log v1.1.2
|
||||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||||
|
@ -151,7 +151,7 @@
|
|||||||
showToast('Success', 'Updated status successfully')
|
showToast('Success', 'Updated status successfully')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadDetails() {
|
async function loadStatus() {
|
||||||
const res = await axios.get('/user/whitelabel');
|
const res = await axios.get('/user/whitelabel');
|
||||||
if (res.status !== 200 || !res.data.success) {
|
if (res.status !== 200 || !res.data.success) {
|
||||||
showToast('Error', res.data.error);
|
showToast('Error', res.data.error);
|
||||||
@ -160,6 +160,16 @@
|
|||||||
|
|
||||||
// set status
|
// set status
|
||||||
document.getElementById('status').value = res.data.status;
|
document.getElementById('status').value = res.data.status;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadStatus();
|
||||||
|
|
||||||
|
async function loadErrors() {
|
||||||
|
const res = await axios.get('/user/whitelabel/errors');
|
||||||
|
if (res.status !== 200 || !res.data.success) {
|
||||||
|
showToast('Error', res.data.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// append errors
|
// append errors
|
||||||
for (error of res.data.errors) {
|
for (error of res.data.errors) {
|
||||||
@ -169,6 +179,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadDetails();
|
loadErrors();
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
Loading…
x
Reference in New Issue
Block a user