From b0967dfc3a188fb799f0c82fd42d41f3e7272a39 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 30 Jan 2018 16:38:32 -0800 Subject: [PATCH] move some more settings to content, leave places in domain settings --- domain-server/resources/describe-settings.json | 7 +++++-- domain-server/resources/web/js/base-settings.js | 8 ++++++-- domain-server/resources/web/js/domain-server.js | 7 +++++++ domain-server/resources/web/settings/js/settings.js | 11 +++++++++-- domain-server/src/DomainServerSettingsManager.cpp | 7 ++++++- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 705d110542..b9a4246895 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -55,8 +55,8 @@ ] }, { - "label": "Places / Paths", - "html_id": "places_paths", + "label": "Paths", + "html_id": "paths", "restart": false, "settings": [ { @@ -64,6 +64,7 @@ "label": "Paths", "help": "Clients can enter a path to reach an exact viewpoint in your domain.
Add rows to the table below to map a path to a viewpoint.
The index path ( / ) is where clients will enter if they do not enter an explicit path.", "type": "table", + "content_setting": true, "can_add_new_rows": true, "key": { "name": "path", @@ -1081,6 +1082,7 @@ "name": "attenuation_per_doubling_in_distance", "label": "Default Domain Attenuation", "help": "Factor between 0 and 1.0 (0: No attenuation, 1.0: extreme attenuation)", + "content_setting": true, "placeholder": "0.5", "default": "0.5", "advanced": false @@ -1313,6 +1315,7 @@ "name": "entityEditFilter", "label": "Filter Entity Edits", "help": "Check all entity edits against this filter function.", + "content_setting": true, "placeholder": "url whose content is like: function filter(properties) { return properties; }", "default": "", "advanced": true diff --git a/domain-server/resources/web/js/base-settings.js b/domain-server/resources/web/js/base-settings.js index 5e32463d61..aad342da63 100644 --- a/domain-server/resources/web/js/base-settings.js +++ b/domain-server/resources/web/js/base-settings.js @@ -94,9 +94,13 @@ var viewHelpers = { function reloadSettings(callback) { $.getJSON(Settings.endpoint, function(data){ - _.extend(data, viewHelpers) + _.extend(data, viewHelpers); - $('#panels').html(Settings.panelsTemplate(data)) + for (var spliceIndex in Settings.extraGroups) { + data.descriptions.splice(spliceIndex, 0, Settings.extraGroups[spliceIndex]); + } + + $('#panels').html(Settings.panelsTemplate(data)); Settings.data = data; Settings.initialValues = form2js('settings-form', ".", false, cleanupFormValues, true); diff --git a/domain-server/resources/web/js/domain-server.js b/domain-server/resources/web/js/domain-server.js index aa658bce3f..a7c8c3a4d1 100644 --- a/domain-server/resources/web/js/domain-server.js +++ b/domain-server/resources/web/js/domain-server.js @@ -79,6 +79,13 @@ $(document).ready(function(){ } $settingsDropdown.append(makeGroupDropdownElement(group, "/settings/")); + + // for domain settings, we add a dummy "Places" group that we fill + // via the API - add it to the dropdown menu in the right spot + if (index == 1) { + $settingsDropdown.append(""); + $settingsDropdown.append(makeGroupDropdownElement({ html_id: 'places', label: 'Places' }, "/settings/")); + } }); }); } diff --git a/domain-server/resources/web/settings/js/settings.js b/domain-server/resources/web/settings/js/settings.js index 9a31b766a6..d10d1304c3 100644 --- a/domain-server/resources/web/settings/js/settings.js +++ b/domain-server/resources/web/settings/js/settings.js @@ -14,6 +14,14 @@ $(document).ready(function(){ return b; })(window.location.search.substr(1).split('&')); + // define extra groups to add to description, with their splice index + Settings.extraGroups = { + 1: { + html_id: 'places', + label: 'Places' + } + } + Settings.afterReloadActions = function() { // append the domain selection modal appendDomainIDButtons(); @@ -657,8 +665,7 @@ $(document).ready(function(){ var placesTableGroup = viewHelpers.getFormGroup('', placesTableSetting, Settings.data.values); // append the places table in the right place - $('#places_paths .panel-body').prepend(placesTableGroup); - //$('#' + Settings.PLACES_TABLE_ID).append(""); + $('#places .panel-body').prepend(placesTableGroup); var spinner = createDomainSpinner(); $('#' + Settings.PLACES_TABLE_ID).after($(spinner)); diff --git a/domain-server/src/DomainServerSettingsManager.cpp b/domain-server/src/DomainServerSettingsManager.cpp index 52754babb3..f91c5af06f 100644 --- a/domain-server/src/DomainServerSettingsManager.cpp +++ b/domain-server/src/DomainServerSettingsManager.cpp @@ -123,7 +123,10 @@ void DomainServerSettingsManager::splitSettingsDescription() { QJsonObject settingsDropdownGroup; if (!groupHidden) { - settingsDropdownGroup[DESCRIPTION_NAME_KEY] = groupObject[DESCRIPTION_NAME_KEY]; + if (groupObject.contains(DESCRIPTION_NAME_KEY)) { + settingsDropdownGroup[DESCRIPTION_NAME_KEY] = groupObject[DESCRIPTION_NAME_KEY]; + } + settingsDropdownGroup[DESCRIPTION_GROUP_LABEL_KEY] = groupObject[DESCRIPTION_GROUP_LABEL_KEY]; static const QString DESCRIPTION_GROUP_HTML_ID_KEY = "html_id"; @@ -1383,7 +1386,9 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ foreach(const QJsonValue& groupValue, _descriptionArray) { // find groups with root values (they don't have a group name) QJsonObject groupObject = groupValue.toObject(); + if (!groupObject.contains(DESCRIPTION_NAME_KEY)) { + // this is a group with root values - check if our setting is in here matchingDescriptionObject = settingDescriptionFromGroup(groupObject, rootKey);