forked from shaba/openuds
Configuration can now be saved
This commit is contained in:
parent
a50e1ecca8
commit
1e74a82a40
@ -34,7 +34,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from uds.core.util.Config import Config as cfgConfig
|
||||
|
||||
from uds.REST import Handler
|
||||
from uds.REST import Handler, AccessDenied
|
||||
|
||||
import logging
|
||||
|
||||
@ -59,4 +59,9 @@ class Config(Handler):
|
||||
logger.debug('Configuration: {0}'.format(res))
|
||||
return res
|
||||
|
||||
def put(self):
|
||||
for section, secDict in self._params.iteritems():
|
||||
for key, vals in secDict.iteritems():
|
||||
cfgConfig.update( section, key, vals['value'] )
|
||||
return 'done'
|
||||
|
@ -22,6 +22,27 @@ gui.configuration.link = function() {
|
||||
$('#'+fld).val($('#'+fld).attr('data-val'));
|
||||
});
|
||||
|
||||
$('#form_config .button-save').on('click', function(event){
|
||||
var cfg = {};
|
||||
$('#form_config .form-control').each(function(i, element){
|
||||
var $element = $(element);
|
||||
if( $element.attr('data-val') != $element.val()) {
|
||||
var section = $element.attr('data-section');
|
||||
var key = $element.attr('data-key');
|
||||
if( cfg[section] === undefined ) {
|
||||
cfg[section] = {};
|
||||
}
|
||||
cfg[section][key] = { value: $element.val() };
|
||||
}
|
||||
});
|
||||
gui.doLog(cfg);
|
||||
if( !$.isEmptyObject(cfg) ) {
|
||||
api.configuration.save(cfg, function(){
|
||||
gui.showDashboard();
|
||||
gui.notify(gettext('Configuration saved'), 'success');
|
||||
}, gui.failRequestModalFnc);
|
||||
}
|
||||
});
|
||||
}, gui.failRequestModalFnc);
|
||||
});
|
||||
};
|
@ -231,7 +231,7 @@
|
||||
$.blockUI.defaults.baseZ = 2000;
|
||||
|
||||
$.fn.dataTableExt.oSort['uds-date-pre'] = function( s ) {
|
||||
return parseInt(s.split('"')[1]);
|
||||
return parseInt(s.split('"')[1], 10);
|
||||
};
|
||||
// Sort for "date" columns (our "dates" are in fact postfix dates rendered as dates with locale format
|
||||
$.fn.dataTableExt.oSort['uds-date-asc'] = function(x,y) {
|
||||
@ -248,6 +248,10 @@
|
||||
gui.dashboard.link();
|
||||
};
|
||||
|
||||
gui.showDashboard = function() {
|
||||
gui.dashboard.link();
|
||||
};
|
||||
|
||||
// Generic "methods" for editing, creating, etc...
|
||||
|
||||
gui.methods = {};
|
||||
|
@ -55,7 +55,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-lg-6 col-lg-offset-1">
|
||||
<button type="button" class="btn btn-success pull-right">{% endverbatim %}{% trans 'Save' %}{% verbatim %}</button>
|
||||
<button type="button" class="btn btn-success pull-right button-save">{% endverbatim %}{% trans 'Save' %}{% verbatim %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user