-
Notifications
You must be signed in to change notification settings - Fork 0
/
mqtt.go
119 lines (96 loc) · 2.79 KB
/
mqtt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package mqtt
import (
"github.com/547176052/mqtt/controller"
"github.com/547176052/mqtt/guard"
language2 "github.com/547176052/mqtt/modules/language"
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/config"
"github.com/GoAdminGroup/go-admin/modules/language"
"github.com/GoAdminGroup/go-admin/modules/service"
"github.com/GoAdminGroup/go-admin/modules/utils"
"github.com/GoAdminGroup/go-admin/plugins"
form2 "github.com/GoAdminGroup/go-admin/plugins/admin/modules/form"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table"
"github.com/GoAdminGroup/go-admin/template/types"
)
type Mqtt struct {
*plugins.Base
handler *controller.Handler
guard *guard.Guardian
// ...
}
func init() {
plugins.Add(&Mqtt{
Base: &plugins.Base{PlugName: "mqtt", URLPrefix: "mqtt"},
// ....
})
}
func NewMqtt( /*...*/ ) *Mqtt {
return &Mqtt{
Base: &plugins.Base{PlugName: "mqtt", URLPrefix: "mqtt"},
// ...
}
}
func (plug *Mqtt) IsInstalled() bool {
// ... implement it
return true
}
func (plug *Mqtt) GetIndexURL() string {
return config.Url("/mqtt/example?param=helloworld")
}
func (plug *Mqtt) InitPlugin(srv service.List) {
// DO NOT DELETE
plug.InitBase(srv, "mqtt")
plug.handler = controller.NewHandler( /*...*/ )
plug.guard = guard.New( /*...*/ )
plug.App = plug.initRouter(srv)
plug.handler.HTML = plug.HTML
plug.handler.HTMLMenu = plug.HTMLMenu
language.Lang[language.CN].Combine(language2.CN)
language.Lang[language.EN].Combine(language2.EN)
plug.SetInfo(info)
}
var info = plugins.Info{
Website: "",
Title: "Mqtt",
Description: "",
Version: "",
Author: "",
Url: "",
Cover: "",
Agreement: "",
Uuid: "",
Name: "",
ModulePath: "",
CreateDate: utils.ParseTime("2000-01-11"),
UpdateDate: utils.ParseTime("2000-01-11"),
}
func (plug *Mqtt) GetSettingPage() table.Generator {
return func(ctx *context.Context) (mqttConfiguration table.Table) {
cfg := table.DefaultConfigWithDriver(config.GetDatabases().GetDefault().Driver)
if !plug.IsInstalled() {
cfg = cfg.SetOnlyNewForm()
} else {
cfg = cfg.SetOnlyUpdateForm()
}
mqttConfiguration = table.NewDefaultTable(cfg)
formList := mqttConfiguration.GetForm().
AddXssJsFilter().
HideBackButton().
HideContinueNewCheckBox().
HideResetButton()
// formList.AddField(...)
formList.SetInsertFn(func(values form2.Values) error {
// TODO: finish the installation
return nil
})
formList.EnableAjaxData(types.AjaxData{
SuccessTitle: language2.Get("install success"),
ErrorTitle: language2.Get("install fail"),
SuccessJumpURL: "...",
}).SetFormNewTitle(language2.GetHTML("mqtt installation")).
SetTitle(language2.Get("mqtt installation")).
SetFormNewBtnWord(language2.GetHTML("install"))
return
}
}