diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 5650737965..f9bbeb31fc 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -25,11 +25,11 @@ setup_hifi_project(${TARGET_NAME} TRUE) # remove and then copy the files for the webserver add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E remove_directory - $/resources) + $/resources/web) add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory - "${PROJECT_SOURCE_DIR}/resources" - $/resources) + "${PROJECT_SOURCE_DIR}/resources/web" + $/resources/web) # link the shared hifi library include(${MACRO_DIR}/LinkHifiLibrary.cmake) diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index 639ec1a6fa..2df5687df6 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -1,8 +1,12 @@ var Settings = {}; $(document).ready(function(){ - Handlebars.registerHelper('setKey', function(value){ - this.key = value; + Handlebars.registerHelper('setGroup', function(value){ + this.group = value; + }); + + Handlebars.registerHelper('settingsValue', function(values, key, group){ + return values[group][key]; }); var source = $('#template').html(); @@ -12,11 +16,13 @@ $(document).ready(function(){ }); function reloadSettings() { - $.getJSON('describe.json', function(data){ + $.getJSON('/settings.json', function(data){ $('#settings').html(Settings.template(data)); }); } +var SETTINGS_ERROR_MESSAGE = "There was a problem saving domain settings. Please try again!"; + $('#settings').on('click', 'button', function(e){ // grab a JSON representation of the form via form2js var formJSON = form2js('settings-form', ".", false, null, true); @@ -26,17 +32,26 @@ $('#settings').on('click', 'button', function(e){ data: JSON.stringify(formJSON), contentType: 'application/json', type: 'POST' - }).done(function(){ + }).done(function(data){ + if (data.status == "success") { + showAlertMessage("Domain settings saved.", true); + } else { + showAlertMessage(SETTINGS_ERROR_MESSAGE, false); + } + reloadSettings(); }).fail(function(){ - var alertBox = $('.alert'); - alertBox.attr('class', 'alert'); - alertBox.addClass('alert-danger'); - alertBox.html("There was a problem saving domain settings. Please try again!"); - alertBox.fadeIn(); - + showAlertMessage(SETTINGS_ERROR_MESSAGE, false); reloadSettings(); }); return false; }); + +function showAlertMessage(message, isSuccess) { + var alertBox = $('.alert'); + alertBox.attr('class', 'alert'); + alertBox.addClass(isSuccess ? 'alert-success' : 'alert-danger'); + alertBox.html(message); + alertBox.fadeIn(); +} \ No newline at end of file diff --git a/domain-server/resources/web/settings/index.shtml b/domain-server/resources/web/settings/index.shtml index 7d8a50f5b7..f17b6758b4 100644 --- a/domain-server/resources/web/settings/index.shtml +++ b/domain-server/resources/web/settings/index.shtml @@ -5,8 +5,8 @@