Display read-only settings for information purpose
This commit is contained in:
parent
6ef91a92e5
commit
a1c6eadbe5
3 changed files with 25 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"path"
|
||||
"time"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
"srs.epita.fr/fic-server/settings"
|
||||
|
||||
|
@ -13,12 +14,24 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
router.GET("/api/settings-ro.json", apiHandler(getROSettings))
|
||||
router.GET("/api/settings.json", apiHandler(getSettings))
|
||||
router.PUT("/api/settings.json", apiHandler(saveSettings))
|
||||
|
||||
router.POST("/api/reset", apiHandler(reset))
|
||||
}
|
||||
|
||||
func getROSettings(_ httprouter.Params, body []byte) (interface{}, error) {
|
||||
syncMtd := "Disabled"
|
||||
if sync.GlobalImporter != nil {
|
||||
syncMtd = sync.GlobalImporter.Kind()
|
||||
}
|
||||
|
||||
return map[string]interface{}{
|
||||
"sync": syncMtd,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getSettings(_ httprouter.Params, body []byte) (interface{}, error) {
|
||||
if settings.ExistsSettings(path.Join(settings.SettingsDir, settings.SettingsFile)) {
|
||||
return settings.ReadSettings(path.Join(settings.SettingsDir, settings.SettingsFile))
|
||||
|
|
Reference in a new issue