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