Display read-only settings for information purpose
This commit is contained in:
parent
6ef91a92e5
commit
a1c6eadbe5
@ -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))
|
||||
|
@ -68,6 +68,9 @@ angular.module("FICApp")
|
||||
'update': {method: 'PUT'},
|
||||
})
|
||||
})
|
||||
.factory("ROSettings", function($resource) {
|
||||
return $resource("/api/settings-ro.json")
|
||||
})
|
||||
.factory("Settings", function($resource) {
|
||||
return $resource("/api/settings.json", null, {
|
||||
'update': {method: 'PUT'},
|
||||
@ -328,8 +331,9 @@ angular.module("FICApp")
|
||||
$interval(updBox, 750);
|
||||
})
|
||||
|
||||
.controller("SettingsController", function($scope, $rootScope, Settings, $location, $http) {
|
||||
.controller("SettingsController", function($scope, $rootScope, Settings, ROSettings, $location, $http) {
|
||||
$scope.config = Settings.get();
|
||||
$scope.configro = ROSettings.get();
|
||||
$scope.duration = 240;
|
||||
|
||||
$scope.saveSettings = function(msg) {
|
||||
|
@ -112,6 +112,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">Synchronisation</label>
|
||||
<div class="col-sm-10">{{ configro.sync }}</div>
|
||||
</div>
|
||||
|
||||
<div class="text-right">
|
||||
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-save" aria-hidden="true"></span> Propager ces paramètres</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user