2019-12-08 16:59:58 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
2019-12-08 23:18:29 +08:00
|
|
|
"net/http"
|
|
|
|
|
2019-12-08 16:59:58 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
2020-12-19 22:14:36 +08:00
|
|
|
"github.com/naiba/nezha/model"
|
2022-01-09 11:54:14 +08:00
|
|
|
"github.com/naiba/nezha/service/singleton"
|
2019-12-08 16:59:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type memberPage struct {
|
|
|
|
r *gin.Engine
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mp *memberPage) serve() {
|
|
|
|
mr := mp.r.Group("")
|
2024-10-20 11:47:45 +08:00
|
|
|
// mr.Use(mygin.Authorize(mygin.AuthorizeOption{
|
|
|
|
// MemberOnly: true,
|
|
|
|
// IsPage: true,
|
|
|
|
// // Msg: singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "YouAreNotAuthorized"}),
|
|
|
|
// // Btn: singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "Login"}),
|
|
|
|
// Redirect: "/login",
|
|
|
|
// }))
|
2021-01-19 09:59:04 +08:00
|
|
|
mr.GET("/cron", mp.cron)
|
2020-12-19 22:14:36 +08:00
|
|
|
mr.GET("/notification", mp.notification)
|
2024-10-17 21:03:03 +08:00
|
|
|
mr.GET("/ddns", mp.ddns)
|
2024-07-14 19:41:50 +08:00
|
|
|
mr.GET("/nat", mp.nat)
|
2020-12-09 19:05:40 +08:00
|
|
|
mr.GET("/setting", mp.setting)
|
2019-12-08 23:18:29 +08:00
|
|
|
}
|
|
|
|
|
2021-01-19 09:59:04 +08:00
|
|
|
func (mp *memberPage) cron(c *gin.Context) {
|
|
|
|
var crons []model.Cron
|
2022-01-09 11:54:14 +08:00
|
|
|
singleton.DB.Find(&crons)
|
2024-10-20 11:47:45 +08:00
|
|
|
c.HTML(http.StatusOK, "dashboard-", gin.H{
|
2024-10-20 00:09:16 +08:00
|
|
|
// "Title": singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "ScheduledTasks"}),
|
2021-01-19 09:59:04 +08:00
|
|
|
"Crons": crons,
|
2024-10-20 11:47:45 +08:00
|
|
|
})
|
2021-01-19 09:59:04 +08:00
|
|
|
}
|
|
|
|
|
2020-12-19 22:14:36 +08:00
|
|
|
func (mp *memberPage) notification(c *gin.Context) {
|
|
|
|
var nf []model.Notification
|
2022-01-09 11:54:14 +08:00
|
|
|
singleton.DB.Find(&nf)
|
2020-12-19 23:11:16 +08:00
|
|
|
var ar []model.AlertRule
|
2022-01-09 11:54:14 +08:00
|
|
|
singleton.DB.Find(&ar)
|
2024-10-20 11:47:45 +08:00
|
|
|
c.HTML(http.StatusOK, "dashboard-", gin.H{
|
2024-10-20 00:09:16 +08:00
|
|
|
// "Title": singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "Notification"}),
|
2020-12-19 22:14:36 +08:00
|
|
|
"Notifications": nf,
|
2020-12-19 23:11:16 +08:00
|
|
|
"AlertRules": ar,
|
2024-10-20 11:47:45 +08:00
|
|
|
})
|
2020-12-19 22:14:36 +08:00
|
|
|
}
|
|
|
|
|
2024-10-17 21:03:03 +08:00
|
|
|
func (mp *memberPage) ddns(c *gin.Context) {
|
|
|
|
var data []model.DDNSProfile
|
|
|
|
singleton.DB.Find(&data)
|
2024-10-20 11:47:45 +08:00
|
|
|
c.HTML(http.StatusOK, "dashboard-", gin.H{
|
2024-10-20 00:09:16 +08:00
|
|
|
// "Title": singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "DDNS"}),
|
2024-10-22 00:04:17 +08:00
|
|
|
"DDNS": data,
|
|
|
|
//"ProviderMap": model.ProviderMap,
|
|
|
|
//"ProviderList": model.ProviderList,
|
2024-10-20 11:47:45 +08:00
|
|
|
})
|
2024-10-17 21:03:03 +08:00
|
|
|
}
|
|
|
|
|
2024-07-14 19:41:50 +08:00
|
|
|
func (mp *memberPage) nat(c *gin.Context) {
|
|
|
|
var data []model.NAT
|
|
|
|
singleton.DB.Find(&data)
|
2024-10-20 11:47:45 +08:00
|
|
|
c.HTML(http.StatusOK, "dashboard-", gin.H{
|
2024-10-20 00:09:16 +08:00
|
|
|
// "Title": singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "NAT"}),
|
|
|
|
"NAT": data,
|
2024-10-20 11:47:45 +08:00
|
|
|
})
|
2024-07-14 19:41:50 +08:00
|
|
|
}
|
|
|
|
|
2020-12-09 19:05:40 +08:00
|
|
|
func (mp *memberPage) setting(c *gin.Context) {
|
2024-10-20 11:47:45 +08:00
|
|
|
c.HTML(http.StatusOK, "dashboard-", gin.H{
|
2024-10-20 00:09:16 +08:00
|
|
|
// "Title": singleton.Localizer.MustLocalize(&i18n.LocalizeConfig{MessageID: "Settings"}),
|
2024-10-27 13:10:07 +08:00
|
|
|
//"Languages": model.Languages,
|
|
|
|
//"DashboardThemes": model.DashboardThemes,
|
2024-10-20 11:47:45 +08:00
|
|
|
})
|
2020-12-09 19:05:40 +08:00
|
|
|
}
|