mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
add extra javascript file for user interface functions
This commit is contained in:
parent
20369b892b
commit
e83c88b879
37
src/opnsense/www/js/opnsense_ui.js
Normal file
37
src/opnsense/www/js/opnsense_ui.js
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* User interface shared components, requires opnsense.js for supporting functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* save form to server
|
||||
* @param url endpoint url
|
||||
* @param formid parent id to grep input data from
|
||||
*/
|
||||
function saveFormToEndpoint(url,formid) {
|
||||
data = getFormData(formid);
|
||||
ajaxCall(url=url,sendData=data,callback=function(data,status){
|
||||
if ( status == "success") {
|
||||
// if there are validation issues, update our screen and show a dialog.
|
||||
if (data['validations'] != undefined) {
|
||||
// update field validation
|
||||
handleFormValidation(formid,data['validations']);
|
||||
BootstrapDialog.show({
|
||||
type:BootstrapDialog.TYPE_WARNING,
|
||||
title: 'Input validation',
|
||||
message: 'Please correct validation errors in form'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// error handling, show internal errors
|
||||
// Normally the form should only return validation issues, if other things go wrong throw an error.
|
||||
BootstrapDialog.show({
|
||||
type: BootstrapDialog.TYPE_ERROR,
|
||||
title: 'save',
|
||||
message: 'Unable to save data, an internal error occurred.<br> ' +
|
||||
'Response from server was: <br> <small>'+JSON.stringify(data)+'</small>'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user