mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 02:53:43 +02:00
Merge pull request #12295 from birarda/feat/content-split-from-settings
initial separation of DS into domain settings and content settings
This commit is contained in:
commit
c62f68264f
20 changed files with 2978 additions and 2403 deletions
|
@ -1,12 +1,6 @@
|
|||
{
|
||||
"version": 2.1,
|
||||
"settings": [
|
||||
{
|
||||
"name": "label",
|
||||
"label": "Label",
|
||||
"settings": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "metaverse",
|
||||
"label": "Metaverse / Networking",
|
||||
|
@ -15,7 +9,8 @@
|
|||
"name": "access_token",
|
||||
"label": "Access Token",
|
||||
"help": "This is your OAuth access token to connect this domain-server with your High Fidelity account. <br/>It can be generated by clicking the 'Connect Account' button above.<br/>You can also go to the <a href='https://metaverse.highfidelity.com/user/security' target='_blank'>My Security</a> page of your account and generate a token with the 'domains' scope and paste it here.",
|
||||
"advanced": true
|
||||
"advanced": true,
|
||||
"backup": false
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
|
@ -55,8 +50,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"label": "Places / Paths",
|
||||
"html_id": "places_paths",
|
||||
"label": "Paths",
|
||||
"html_id": "paths",
|
||||
"restart": false,
|
||||
"settings": [
|
||||
{
|
||||
|
@ -64,6 +59,7 @@
|
|||
"label": "Paths",
|
||||
"help": "Clients can enter a path to reach an exact viewpoint in your domain.<br/>Add rows to the table below to map a path to a viewpoint.<br/>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",
|
||||
|
@ -164,7 +160,8 @@
|
|||
{
|
||||
"name": "http_username",
|
||||
"label": "HTTP Username",
|
||||
"help": "Username used for basic HTTP authentication."
|
||||
"help": "Username used for basic HTTP authentication.",
|
||||
"backup": false
|
||||
},
|
||||
{
|
||||
"name": "http_password",
|
||||
|
@ -172,7 +169,8 @@
|
|||
"type": "password",
|
||||
"help": "Password used for basic HTTP authentication. Leave this alone if you do not want to change it.",
|
||||
"password_placeholder": "******",
|
||||
"value-hidden": true
|
||||
"value-hidden": true,
|
||||
"backup": false
|
||||
},
|
||||
{
|
||||
"name": "verify_http_password",
|
||||
|
@ -935,6 +933,7 @@
|
|||
"name": "persistent_scripts",
|
||||
"type": "table",
|
||||
"label": "Persistent Scripts",
|
||||
"content_setting": true,
|
||||
"help": "Add the URLs for scripts that you would like to ensure are always running in your domain.",
|
||||
"can_add_new_rows": true,
|
||||
"columns": [
|
||||
|
@ -955,99 +954,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "asset_server",
|
||||
"label": "Asset Server (ATP)",
|
||||
"assignment-types": [ 3 ],
|
||||
"settings": [
|
||||
{
|
||||
"name": "enabled",
|
||||
"type": "checkbox",
|
||||
"label": "Enabled",
|
||||
"help": "Assigns an asset-server in your domain to serve files to clients via the ATP protocol (over UDP)",
|
||||
"default": true,
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "assets_path",
|
||||
"type": "string",
|
||||
"label": "Assets Path",
|
||||
"help": "The path to the directory assets are stored in.<br/>If this path is relative, it will be relative to the application data directory.<br/>If you change this path you will need to manually copy any existing assets from the previous directory.",
|
||||
"default": "",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "assets_filesize_limit",
|
||||
"type": "int",
|
||||
"label": "File Size Limit",
|
||||
"help": "The file size limit of an asset that can be imported into the asset server in MBytes. 0 (default) means no limit on file size.",
|
||||
"default": 0,
|
||||
"advanced": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "entity_script_server",
|
||||
"label": "Entity Script Server (ESS)",
|
||||
"assignment-types": [ 5 ],
|
||||
"settings": [
|
||||
{
|
||||
"name": "entity_pps_per_script",
|
||||
"label": "Entity PPS per script",
|
||||
"help": "The number of packets per second (PPS) that can be sent to the entity server for each server entity script. This contributes to a total overall amount.<br/>Example: 1000 PPS with 5 entites gives a total PPS of 5000 that is shared among the entity scripts. A single could use 4000 PPS, leaving 1000 for the rest, for example.",
|
||||
"default": 900,
|
||||
"type": "int",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "max_total_entity_pps",
|
||||
"label": "Maximum Total Entity PPS",
|
||||
"help": "The maximum total packets per seconds (PPS) that can be sent to the entity server.<br/>Example: 5 scripts @ 1000 PPS per script = 5000 total PPS. A maximum total PPS of 4000 would cap this 5000 total PPS to 4000.",
|
||||
"default": 9000,
|
||||
"type": "int",
|
||||
"advanced": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "avatars",
|
||||
"label": "Avatars",
|
||||
"assignment-types": [ 1, 2 ],
|
||||
"settings": [
|
||||
{
|
||||
"name": "min_avatar_height",
|
||||
"type": "double",
|
||||
"label": "Minimum Avatar Height (meters)",
|
||||
"help": "Limits the height of avatars in your domain. Must be at least 0.009.",
|
||||
"placeholder": 0.4,
|
||||
"default": 0.4
|
||||
},
|
||||
{
|
||||
"name": "max_avatar_height",
|
||||
"type": "double",
|
||||
"label": "Maximum Avatar Height (meters)",
|
||||
"help": "Limits the scale of avatars in your domain. Cannot be greater than 1755.",
|
||||
"placeholder": 5.2,
|
||||
"default": 5.2
|
||||
},
|
||||
{
|
||||
"name": "avatar_whitelist",
|
||||
"label": "Avatars Allowed from:",
|
||||
"help": "Comma separated list of URLs (with optional paths) that avatar .fst files are allowed from. If someone attempts to use an avatar with a different domain, it will be rejected and the replacement avatar will be used. If left blank, any domain is allowed.",
|
||||
"placeholder": "",
|
||||
"default": "",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "replacement_avatar",
|
||||
"label": "Replacement Avatar for disallowed avatars",
|
||||
"help": "A URL for an avatar .fst to be used when someone tries to use an avatar that is not allowed. If left blank, the generic default avatar is used.",
|
||||
"placeholder": "",
|
||||
"default": "",
|
||||
"advanced": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "audio_threading",
|
||||
"label": "Audio Threading",
|
||||
|
@ -1080,6 +986,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
|
||||
|
@ -1105,6 +1012,7 @@
|
|||
"label": "Zones",
|
||||
"help": "In this table you can define a set of zones in which you can specify various audio properties.",
|
||||
"numbered": false,
|
||||
"content_setting": true,
|
||||
"can_add_new_rows": true,
|
||||
"key": {
|
||||
"name": "name",
|
||||
|
@ -1155,6 +1063,7 @@
|
|||
"type": "table",
|
||||
"label": "Attenuation Coefficients",
|
||||
"help": "In this table you can set custom attenuation coefficients between audio zones",
|
||||
"content_setting": true,
|
||||
"numbered": true,
|
||||
"can_order": true,
|
||||
"can_add_new_rows": true,
|
||||
|
@ -1185,6 +1094,7 @@
|
|||
"label": "Reverb Settings",
|
||||
"help": "In this table you can set reverb levels for audio zones. For a medium-sized (e.g., 100 square meter) meeting room, try a decay time of around 1.5 seconds and a wet/dry mix of 25%. For an airplane hangar or cathedral, try a decay time of 4 seconds and a wet/dry mix of 50%.",
|
||||
"numbered": true,
|
||||
"content_setting": true,
|
||||
"can_add_new_rows": true,
|
||||
"columns": [
|
||||
{
|
||||
|
@ -1266,9 +1176,82 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "avatars",
|
||||
"label": "Avatars",
|
||||
"assignment-types": [ 1, 2 ],
|
||||
"settings": [
|
||||
{
|
||||
"name": "min_avatar_height",
|
||||
"type": "double",
|
||||
"label": "Minimum Avatar Height (meters)",
|
||||
"help": "Limits the height of avatars in your domain. Must be at least 0.009.",
|
||||
"placeholder": 0.4,
|
||||
"default": 0.4
|
||||
},
|
||||
{
|
||||
"name": "max_avatar_height",
|
||||
"type": "double",
|
||||
"label": "Maximum Avatar Height (meters)",
|
||||
"help": "Limits the scale of avatars in your domain. Cannot be greater than 1755.",
|
||||
"placeholder": 5.2,
|
||||
"default": 5.2
|
||||
},
|
||||
{
|
||||
"name": "avatar_whitelist",
|
||||
"label": "Avatars Allowed from:",
|
||||
"help": "Comma separated list of URLs (with optional paths) that avatar .fst files are allowed from. If someone attempts to use an avatar with a different domain, it will be rejected and the replacement avatar will be used. If left blank, any domain is allowed.",
|
||||
"placeholder": "",
|
||||
"default": "",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "replacement_avatar",
|
||||
"label": "Replacement Avatar for disallowed avatars",
|
||||
"help": "A URL for an avatar .fst to be used when someone tries to use an avatar that is not allowed. If left blank, the generic default avatar is used.",
|
||||
"placeholder": "",
|
||||
"default": "",
|
||||
"advanced": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "avatar_mixer",
|
||||
"label": "Avatar Mixer",
|
||||
"assignment-types": [
|
||||
1
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"name": "max_node_send_bandwidth",
|
||||
"type": "double",
|
||||
"label": "Per-Node Bandwidth",
|
||||
"help": "Desired maximum send bandwidth (in Megabits per second) to each node",
|
||||
"placeholder": 5.0,
|
||||
"default": 5.0,
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "auto_threads",
|
||||
"label": "Automatically determine thread count",
|
||||
"type": "checkbox",
|
||||
"help": "Allow system to determine number of threads (recommended)",
|
||||
"default": false,
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "num_threads",
|
||||
"label": "Number of Threads",
|
||||
"help": "Threads to spin up for avatar mixing (if not automatically set)",
|
||||
"placeholder": "1",
|
||||
"default": "1",
|
||||
"advanced": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "entity_server_settings",
|
||||
"label": "Entity Server Settings",
|
||||
"label": "Entities",
|
||||
"assignment-types": [
|
||||
6
|
||||
],
|
||||
|
@ -1309,6 +1292,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
|
||||
|
@ -1503,35 +1487,55 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "avatar_mixer",
|
||||
"label": "Avatar Mixer",
|
||||
"assignment-types": [
|
||||
1
|
||||
],
|
||||
"name": "asset_server",
|
||||
"label": "Asset Server (ATP)",
|
||||
"assignment-types": [ 3 ],
|
||||
"settings": [
|
||||
{
|
||||
"name": "max_node_send_bandwidth",
|
||||
"type": "double",
|
||||
"label": "Per-Node Bandwidth",
|
||||
"help": "Desired maximum send bandwidth (in Megabits per second) to each node",
|
||||
"placeholder": 5.0,
|
||||
"default": 5.0,
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "auto_threads",
|
||||
"label": "Automatically determine thread count",
|
||||
"name": "enabled",
|
||||
"type": "checkbox",
|
||||
"help": "Allow system to determine number of threads (recommended)",
|
||||
"default": false,
|
||||
"label": "Enabled",
|
||||
"help": "Assigns an asset-server in your domain to serve files to clients via the ATP protocol (over UDP)",
|
||||
"default": true,
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "num_threads",
|
||||
"label": "Number of Threads",
|
||||
"help": "Threads to spin up for avatar mixing (if not automatically set)",
|
||||
"placeholder": "1",
|
||||
"default": "1",
|
||||
"name": "assets_path",
|
||||
"type": "string",
|
||||
"label": "Assets Path",
|
||||
"help": "The path to the directory assets are stored in.<br/>If this path is relative, it will be relative to the application data directory.<br/>If you change this path you will need to manually copy any existing assets from the previous directory.",
|
||||
"default": "",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "assets_filesize_limit",
|
||||
"type": "int",
|
||||
"label": "File Size Limit",
|
||||
"help": "The file size limit of an asset that can be imported into the asset server in MBytes. 0 (default) means no limit on file size.",
|
||||
"default": 0,
|
||||
"advanced": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "entity_script_server",
|
||||
"label": "Entity Script Server (ESS)",
|
||||
"assignment-types": [ 5 ],
|
||||
"settings": [
|
||||
{
|
||||
"name": "entity_pps_per_script",
|
||||
"label": "Entity PPS per script",
|
||||
"help": "The number of packets per second (PPS) that can be sent to the entity server for each server entity script. This contributes to a total overall amount.<br/>Example: 1000 PPS with 5 entites gives a total PPS of 5000 that is shared among the entity scripts. A single could use 4000 PPS, leaving 1000 for the rest, for example.",
|
||||
"default": 900,
|
||||
"type": "int",
|
||||
"advanced": true
|
||||
},
|
||||
{
|
||||
"name": "max_total_entity_pps",
|
||||
"label": "Maximum Total Entity PPS",
|
||||
"help": "The maximum total packets per seconds (PPS) that can be sent to the entity server.<br/>Example: 5 scripts @ 1000 PPS per script = 5000 total PPS. A maximum total PPS of 4000 would cap this 5000 total PPS to 4000.",
|
||||
"default": 9000,
|
||||
"type": "int",
|
||||
"advanced": true
|
||||
}
|
||||
]
|
||||
|
|
7
domain-server/resources/web/base-settings-scripts.html
Normal file
7
domain-server/resources/web/base-settings-scripts.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
<script src='/js/underscore-min.js'></script>
|
||||
<script src='/js/underscore-keypath.min.js'></script>
|
||||
<script src='/js/bootbox.min.js'></script>
|
||||
<script src='/js/form2js.min.js'></script>
|
||||
<script src='/js/bootstrap-switch.min.js'></script>
|
||||
<script src='/js/shared.js'></script>
|
||||
<script src='/js/base-settings.js'></script>
|
59
domain-server/resources/web/base-settings.html
Normal file
59
domain-server/resources/web/base-settings.html
Normal file
|
@ -0,0 +1,59 @@
|
|||
<div class="col-md-10 col-md-offset-1 col-xs-12">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-xs-12">
|
||||
<div id="cloud-domains-alert" class="alert alert-info alert-dismissible" role="alert" style="display: none;">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<span class="alert-link">
|
||||
<a href="https://highfidelity.com/user/cloud_domains" target="_blank" class="blue-link">Visit Cloud Hosted Domains</a> to manage all your cloud domains
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<form id="settings-form" role="form">
|
||||
<script id="panels-template" type="text/template">
|
||||
<% _.each(descriptions, function(group){ %>
|
||||
<% if (!group.hidden) { %>
|
||||
|
||||
<% var settings = _.partition(group.settings, function(value, index) { %>
|
||||
<% return !value.deprecated %>
|
||||
<% })[0] %>
|
||||
|
||||
<% var split_settings = _.partition(group.settings, function(value, index) { %>
|
||||
<% return !value.advanced %>
|
||||
<% }) %>
|
||||
|
||||
<% isGrouped = !!group.name %>
|
||||
<% panelID = isGrouped ? group.name : group.html_id %>
|
||||
|
||||
<div id="<%- panelID %>_group" class="anchor"></div>
|
||||
<div class="panel panel-default<%- (isGrouped) ? ' grouped' : '' %>"
|
||||
id="<%- panelID %>">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><%- group.label %></h3>
|
||||
<span class="badge"></span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<% _.each(split_settings[0], function(setting) { %>
|
||||
<% keypath = isGrouped ? group.name + "." + setting.name : setting.name %>
|
||||
<%= getFormGroup(keypath, setting, values, false) %>
|
||||
<% }); %>
|
||||
|
||||
<% if (split_settings[1].length > 0) { %>
|
||||
<button type="button" class="btn btn-default" data-toggle="collapse" data-target="#<%- panelID %>-advanced">Advanced Settings <span class="caret"></span></button>
|
||||
<div id="<%- panelID %>-advanced" class="collapse advanced-settings-section">
|
||||
<% _.each(split_settings[1], function(setting) { %>
|
||||
<% keypath = isGrouped ? group.name + "." + setting.name : setting.name %>
|
||||
<%= getFormGroup(keypath, setting, values, true) %>
|
||||
<% }); %>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<% }); %>
|
||||
</script>
|
||||
<div id="panels"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,45 +1,19 @@
|
|||
<!--#include virtual="header.html"-->
|
||||
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="alert" style="display:none;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var Settings = {
|
||||
content_settings: true,
|
||||
endpoint: "/content-settings.json",
|
||||
path: "/content/"
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Upload Entities File</h3>
|
||||
</div>
|
||||
<form id="upload-form" action="upload" enctype="multipart/form-data" method="post">
|
||||
<div class="panel-body">
|
||||
<p>
|
||||
Upload an entities file (e.g.: models.json.gz) to replace the content of this domain.<br>
|
||||
Note: <strong>Your domain's content will be replaced by the content you upload</strong>, but the backup files of your domain's content will not immediately be changed.
|
||||
</p>
|
||||
<p>If your domain has any content that you would like to re-use at a later date, save a manual backup of your models.json.gz file, which is usually stored at the following paths:</p>
|
||||
<label class="control-label">Windows</label>
|
||||
<pre>C:/Users/[username]/AppData/Roaming/High Fidelity/assignment-client/entities/models.json.gz</pre>
|
||||
<label class="control-label">OSX</label>
|
||||
<pre>/Users/[username]/Library/Application Support/High Fidelity/assignment-client/entities/models.json.gz</pre>
|
||||
<label class="control-label">Linux</label>
|
||||
<pre>/home/[username]/.local/share/High Fidelity/assignment-client/entities/models.json.gz</pre>
|
||||
<br>
|
||||
<input type="file" name="entities-file" class="form-control-file" accept=".json, .gz">
|
||||
<br>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<input type="submit" class="btn btn-info" value="Upload">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--#include virtual="base-settings.html"-->
|
||||
|
||||
<!--#include virtual="footer.html"-->
|
||||
<script src='js/content.js'></script>
|
||||
<script src='/js/sweetalert.min.js'></script>
|
||||
|
||||
<!--#include virtual="base-settings-scripts.html"-->
|
||||
|
||||
<script src="js/content.js"></script>
|
||||
|
||||
<!--#include virtual="page-end.html"-->
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
$(document).ready(function(){
|
||||
|
||||
function showSpinnerAlert(title) {
|
||||
swal({
|
||||
title: title,
|
||||
text: '<div class="spinner" style="color:black;"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div>',
|
||||
html: true,
|
||||
showConfirmButton: false,
|
||||
allowEscapeKey: false
|
||||
});
|
||||
}
|
||||
Settings.afterReloadActions = function() {};
|
||||
|
||||
var frm = $('#upload-form');
|
||||
frm.submit(function (ev) {
|
||||
|
|
|
@ -18,6 +18,14 @@ body {
|
|||
margin-top: 70px;
|
||||
}
|
||||
|
||||
/* unfortunate hack so that anchors go to the right place with fixed navbar */
|
||||
:target:before {
|
||||
content: " ";
|
||||
display: block;
|
||||
height: 70px;
|
||||
margin-top: -70px;
|
||||
}
|
||||
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
@ -118,11 +126,6 @@ span.port {
|
|||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#small-save-button {
|
||||
width: 100%;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
td.buttons {
|
||||
width: 30px;
|
||||
}
|
||||
|
@ -345,3 +348,89 @@ table .headers + .headers td {
|
|||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
ul.nav li.dropdown-on-hover:hover ul.dropdown-menu {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
ul.nav li.dropdown ul.dropdown-menu {
|
||||
padding: 0px 0px;
|
||||
}
|
||||
|
||||
ul.nav li.dropdown li a {
|
||||
padding-top: 7px;
|
||||
padding-bottom: 7px;
|
||||
}
|
||||
|
||||
ul.nav li.dropdown li a:hover {
|
||||
color: white;
|
||||
background-color: #337ab7;
|
||||
}
|
||||
|
||||
ul.nav li.dropdown ul.dropdown-menu .divider {
|
||||
margin: 0px 0;
|
||||
}
|
||||
|
||||
#visit-domain-link {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.navbar-btn {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
#save-settings-xs-button {
|
||||
float: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#button-bars {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#hamburger-badge {
|
||||
position: relative;
|
||||
top: -2px;
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
#restart-server {
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
#restart-server:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.badge {
|
||||
margin-left: 5px;
|
||||
background-color: #00B4EF !important;
|
||||
}
|
||||
|
||||
.panel-title {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#visit-hmd-icon {
|
||||
width: 25px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
.advanced-settings-section {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#restore-settings-button {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* fix for https://bugs.webkit.org/show_bug.cgi?id=39620 */
|
||||
.save-button-text {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
|
|
@ -17,30 +17,47 @@
|
|||
<div class="container-fluid">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapsed-navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span id="hamburger-badge" class="badge"></span>
|
||||
|
||||
<div id="button-bars">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<button id="save-settings-xs-button" class="save-button btn btn-success navbar-btn hidden-sm hidden-md hidden-lg" disabled="true"><span class="save-button-text">Save</span></button>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<div class="collapse navbar-collapse" id="collapsed-navbar">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="/">Nodes</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Assignments <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="/assignment">New Assignment</a></li>
|
||||
</ul>
|
||||
<li><a href="/assignment">Assignment</a></li>
|
||||
|
||||
<li class="dropdown dropdown-on-hover">
|
||||
<a href="/content/" class="hidden-xs">Content <span class="content-settings-badge badge"></span> <span class="caret"></span></a>
|
||||
<a href="#" class="dropdown-toggle hidden-sm hidden-md hidden-lg" data-toggle="dropdown">Content <span class="content-badge badge"></span> <span class="caret"></span></a>
|
||||
<ul id="content-settings-nav-dropdown" class="dropdown-menu" role="menu">
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown dropdown-on-hover">
|
||||
<a href="/settings/" class="hidden-xs">Settings <span class="domain-settings-badge badge"></span> <span class="caret"></span></a>
|
||||
<a href="#" class="dropdown-toggle hidden-sm hidden-md hidden-lg" data-toggle="dropdown">Settings <span class="domain-settings-badge badge"></span> <span class="caret"></span></a>
|
||||
<ul id="domain-settings-nav-dropdown" class="dropdown-menu" role="menu">
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="/content/">Content</a></li>
|
||||
<li><a href="/settings/">Settings</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-right navbar-nav">
|
||||
<li><a id="visit-domain-link" class="blue-link" target="_blank" style="display: none;">Visit domain in VR</a></li>
|
||||
<li><a href="#" id="restart-server"><span class="glyphicon glyphicon-refresh"></span> Restart</a></li>
|
||||
<a id="visit-domain-link" class="btn btn-default navbar-btn" role="button" target="_blank" style="display: none;">
|
||||
<img id="visit-hmd-icon" src="/images/hmd-w-eyes.svg" alt="Head-mounted display" />
|
||||
Visit in VR
|
||||
</a>
|
||||
<button id="save-settings-button" class="save-button btn btn-success navbar-btn hidden-xs" disabled="true"><span class="save-button-text">Save</span></button>
|
||||
<a href="#" id="restart-server" class="navbar-btn btn btn-link"><span class="glyphicon glyphicon-refresh"></span> Restart</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div><!-- /.container-fluid -->
|
||||
|
@ -50,7 +67,7 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">domain-server is restarting</h4>
|
||||
<h4 class="modal-title">Domain Server is restarting</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h5>This page will automatically refresh in <span id="refresh-time">3 seconds</span>.</h5>
|
||||
|
|
13
domain-server/resources/web/images/hmd-w-eyes.svg
Normal file
13
domain-server/resources/web/images/hmd-w-eyes.svg
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 456 244" style="enable-background:new 0 0 456 244;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#666666;}
|
||||
</style>
|
||||
<path class="st0" d="M352.8,3.4h-250C49.6,3.4,6.3,46.2,6.3,98.9v44.9c0,52.7,43.3,95.5,96.5,95.5h67.6c19.4,0,31.9-17.9,42.9-33.6
|
||||
c4.2-6.1,11.1-15.9,14.8-17.9c3.6,2.1,10.4,12.2,14.5,18.4c10.4,15.5,22.1,33.1,40.3,33.1h69.9c53.3,0,96.5-42.9,96.5-95.5V98.9
|
||||
C449.3,46.2,406,3.4,352.8,3.4z M129.6,157.6c-22.4,0-40.6-18.2-40.6-40.6s18.2-40.6,40.6-40.6c22.4,0,40.6,18.2,40.6,40.6
|
||||
S151.9,157.6,129.6,157.6z M328.4,157.6c-22.4,0-40.6-18.2-40.6-40.6s18.2-40.6,40.6-40.6c22.4,0,40.6,18.2,40.6,40.6
|
||||
S350.8,157.6,328.4,157.6z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 928 B |
1152
domain-server/resources/web/js/base-settings.js
Normal file
1152
domain-server/resources/web/js/base-settings.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -23,16 +23,22 @@ function showRestartModal() {
|
|||
}, 1000);
|
||||
}
|
||||
|
||||
function settingsGroupAnchor(base, html_id) {
|
||||
return base + "#" + html_id + "_group"
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var url = window.location;
|
||||
|
||||
// Will only work if string in href matches with location
|
||||
$('ul.nav a[href="'+ url +'"]').parent().addClass('active');
|
||||
|
||||
// Will also work for relative and absolute hrefs
|
||||
$('ul.nav a').filter(function() {
|
||||
return this.href == url;
|
||||
}).parent().addClass('active');
|
||||
$('body').on('click', '#restart-server', function(e) {
|
||||
}).parent().addClass('active');
|
||||
|
||||
$('body').on('click', '#restart-server', function(e) {
|
||||
swal( {
|
||||
title: "Are you sure?",
|
||||
text: "This will restart your domain server, causing your domain to be briefly offline.",
|
||||
|
@ -45,4 +51,47 @@ $(document).ready(function(){
|
|||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
var $contentDropdown = $('#content-settings-nav-dropdown');
|
||||
var $settingsDropdown = $('#domain-settings-nav-dropdown');
|
||||
|
||||
// for pages that have the settings dropdowns
|
||||
if ($contentDropdown.length && $settingsDropdown.length) {
|
||||
// make a JSON request to get the dropdown menus for content and settings
|
||||
// we don't error handle here because the top level menu is still clickable and usables if this fails
|
||||
$.getJSON('/settings-menu-groups.json', function(data){
|
||||
function makeGroupDropdownElement(group, base) {
|
||||
var html_id = group.html_id ? group.html_id : group.name;
|
||||
return "<li class='setting-group'><a href='" + settingsGroupAnchor(base, html_id) + "'>" + group.label + "<span class='badge'></span></a></li>";
|
||||
}
|
||||
|
||||
$.each(data.content_settings, function(index, group){
|
||||
if (index > 0) {
|
||||
$contentDropdown.append("<li role='separator' class='divider'></li>");
|
||||
}
|
||||
|
||||
$contentDropdown.append(makeGroupDropdownElement(group, "/content/"));
|
||||
});
|
||||
|
||||
$.each(data.domain_settings, function(index, group){
|
||||
if (index > 0) {
|
||||
$settingsDropdown.append("<li role='separator' class='divider'></li>");
|
||||
}
|
||||
|
||||
$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
|
||||
// which is after "Metaverse / Networking"
|
||||
if (group.name == "metaverse") {
|
||||
$settingsDropdown.append("<li role='separator' class='divider'></li>");
|
||||
$settingsDropdown.append(makeGroupDropdownElement({ html_id: 'places', label: 'Places' }, "/settings/"));
|
||||
}
|
||||
});
|
||||
|
||||
// append a link for the "Settings Backup" panel
|
||||
$settingsDropdown.append("<li role='separator' class='divider'></li>");
|
||||
$settingsDropdown.append(makeGroupDropdownElement({ html_id: 'settings_backup', label: 'Settings Backup'}, "/settings"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
var Settings = {
|
||||
showAdvanced: false,
|
||||
ADVANCED_CLASS: 'advanced-setting',
|
||||
if (typeof Settings === "undefined") {
|
||||
Settings = {};
|
||||
}
|
||||
|
||||
Object.assign(Settings, {
|
||||
DEPRECATED_CLASS: 'deprecated-setting',
|
||||
TRIGGER_CHANGE_CLASS: 'trigger-change',
|
||||
DATA_ROW_CLASS: 'value-row',
|
||||
|
@ -41,7 +43,7 @@ var Settings = {
|
|||
FORM_ID: 'settings-form',
|
||||
INVALID_ROW_CLASS: 'invalid-input',
|
||||
DATA_ROW_INDEX: 'data-row-index'
|
||||
};
|
||||
});
|
||||
|
||||
var URLs = {
|
||||
// STABLE METAVERSE_URL: https://metaverse.highfidelity.com
|
||||
|
@ -95,7 +97,13 @@ var DOMAIN_ID_TYPE_FULL = 2;
|
|||
var DOMAIN_ID_TYPE_UNKNOWN = 3;
|
||||
|
||||
function domainIDIsSet() {
|
||||
return Settings.data.values.metaverse.id.length > 0;
|
||||
if (typeof Settings.data.values.metaverse !== 'undefined' &&
|
||||
typeof Settings.data.values.metaverse.id !== 'undefined') {
|
||||
|
||||
return Settings.data.values.metaverse.id.length > 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentDomainIDType() {
|
||||
|
@ -156,11 +164,12 @@ function getDomainFromAPI(callback) {
|
|||
if (callback === undefined) {
|
||||
callback = function() {};
|
||||
}
|
||||
|
||||
var domainID = Settings.data.values.metaverse.id;
|
||||
if (domainID === null || domainID === undefined || domainID === '') {
|
||||
|
||||
if (!domainIDIsSet()) {
|
||||
callback({ status: 'fail' });
|
||||
return null;
|
||||
} else {
|
||||
var domainID = Settings.data.values.metaverse.id;
|
||||
}
|
||||
|
||||
pendingDomainRequest = $.ajax({
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,104 +1,29 @@
|
|||
<!--#include virtual="header.html"-->
|
||||
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert" style="display:none;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var Settings = {
|
||||
content_settings: false,
|
||||
endpoint: "/settings.json",
|
||||
path: "/settings/"
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3 col-sm-3" id="setup-sidebar-col">
|
||||
<div id="setup-sidebar" data-clampedwidth="#setup-sidebar-col">
|
||||
<script id="list-group-template" type="text/template">
|
||||
<% _.each(descriptions, function(group){ %>
|
||||
<% if (!group.hidden) { %>
|
||||
<% panelID = group.name ? group.name : group.html_id %>
|
||||
<li>
|
||||
<a href="#<%- panelID %>" class="list-group-item">
|
||||
<span class="badge"></span>
|
||||
<%- group.label %>
|
||||
</a>
|
||||
</li>
|
||||
<% } %>
|
||||
<% }); %>
|
||||
</script>
|
||||
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
</ul>
|
||||
|
||||
<button id="advanced-toggle-button" class="btn btn-info advanced-toggle">Show advanced</button>
|
||||
<button class="btn btn-success save-button" disabled>Save</button>
|
||||
<div id="manage-cloud-domains-link" style="display: none;">
|
||||
<a href="https://highfidelity.com/user/cloud_domains" target="_blank" class="blue-link">Manage Cloud Hosted Domains</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9 col-sm-9 col-xs-12">
|
||||
<div class="col-md-10 col-md-offset-1 col-xs-12">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<div id="cloud-domains-alert" class="alert alert-info alert-dismissible" role="alert" style="display: none;">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<span class="alert-link">
|
||||
<a href="https://highfidelity.com/user/cloud_domains" target="_blank" class="blue-link">Visit Cloud Hosted Domains</a> to manage all your cloud domains
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<form id="settings-form" role="form">
|
||||
|
||||
<script id="panels-template" type="text/template">
|
||||
<% _.each(descriptions, function(group){ %>
|
||||
<% if (!group.hidden) { %>
|
||||
<% var settings = _.partition(group.settings, function(value, index) { return !value.deprecated })[0] %>
|
||||
<% split_settings = _.partition(settings, function(value, index) { return !value.advanced }) %>
|
||||
<% isAdvanced = _.isEmpty(split_settings[0]) && !_.isEmpty(split_settings[1]) %>
|
||||
<% if (isAdvanced) { %>
|
||||
<% $("a[href=#" + group.name + "]").addClass('advanced-setting').hide() %>
|
||||
<% } %>
|
||||
|
||||
<% isGrouped = !!group.name %>
|
||||
<% panelID = isGrouped ? group.name : group.html_id %>
|
||||
|
||||
<div class="panel panel-default<%- (isAdvanced) ? ' advanced-setting' : '' %><%- (isGrouped) ? ' grouped' : '' %>"
|
||||
id="<%- panelID %>">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><%- group.label %></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<% _.each(split_settings[0], function(setting) { %>
|
||||
<% keypath = isGrouped ? group.name + "." + setting.name : setting.name %>
|
||||
<%= getFormGroup(keypath, setting, values, false) %>
|
||||
<% }); %>
|
||||
<% if (!_.isEmpty(split_settings[1])) { %>
|
||||
<% $("#advanced-toggle-button").show() %>
|
||||
<% _.each(split_settings[1], function(setting) { %>
|
||||
<% keypath = isGrouped ? group.name + "." + setting.name : setting.name %>
|
||||
<%= getFormGroup(keypath, setting, values, true) %>
|
||||
<% }); %>
|
||||
<% }%>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<% }); %>
|
||||
</script>
|
||||
<div id="panels"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 hidden-sm hidden-md hidden-lg">
|
||||
<button class="btn btn-success save-button" id="small-save-button">Save</button>
|
||||
</div>
|
||||
<div class="alert alert-info">Your domain content settings are now available in <a href='/content/'>Content</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--#include virtual="base-settings.html"-->
|
||||
|
||||
<!--#include virtual="footer.html"-->
|
||||
<script src='/js/underscore-min.js'></script>
|
||||
<script src='/js/underscore-keypath.min.js'></script>
|
||||
<script src='/js/bootbox.min.js'></script>
|
||||
|
||||
<script src='/js/sha256.js'></script>
|
||||
<script src='js/form2js.min.js'></script>
|
||||
<script src='js/bootstrap-switch.min.js'></script>
|
||||
<script src='/js/shared.js'></script>
|
||||
<script src='js/settings.js'></script>
|
||||
|
||||
<!--#include virtual="base-settings-scripts.html"-->
|
||||
|
||||
<script src="js/settings.js"></script>
|
||||
|
||||
<!--#include virtual="page-end.html"-->
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -501,7 +501,7 @@ void DomainServer::handleTempDomainSuccess(QNetworkReply& requestReply) {
|
|||
// store the new domain ID and auto network setting immediately
|
||||
QString newSettingsJSON = QString("{\"metaverse\": { \"id\": \"%1\", \"automatic_networking\": \"full\"}}").arg(id);
|
||||
auto settingsDocument = QJsonDocument::fromJson(newSettingsJSON.toUtf8());
|
||||
_settingsManager.recurseJSONObjectAndOverwriteSettings(settingsDocument.object());
|
||||
_settingsManager.recurseJSONObjectAndOverwriteSettings(settingsDocument.object(), DomainSettings);
|
||||
|
||||
// store the new ID and auto networking setting on disk
|
||||
_settingsManager.persistToFile();
|
||||
|
|
|
@ -39,8 +39,11 @@ const QString SETTINGS_DESCRIPTION_RELATIVE_PATH = "/resources/describe-settings
|
|||
const QString DESCRIPTION_SETTINGS_KEY = "settings";
|
||||
const QString SETTING_DEFAULT_KEY = "default";
|
||||
const QString DESCRIPTION_NAME_KEY = "name";
|
||||
const QString DESCRIPTION_GROUP_LABEL_KEY = "label";
|
||||
const QString DESCRIPTION_BACKUP_FLAG_KEY = "backup";
|
||||
const QString SETTING_DESCRIPTION_TYPE_KEY = "type";
|
||||
const QString DESCRIPTION_COLUMNS_KEY = "columns";
|
||||
const QString CONTENT_SETTING_FLAG_KEY = "content_setting";
|
||||
|
||||
const QString SETTINGS_VIEWPOINT_KEY = "viewpoint";
|
||||
|
||||
|
@ -63,6 +66,8 @@ DomainServerSettingsManager::DomainServerSettingsManager() {
|
|||
|
||||
if (descriptionObject.contains(DESCRIPTION_SETTINGS_KEY)) {
|
||||
_descriptionArray = descriptionDocument.object()[DESCRIPTION_SETTINGS_KEY].toArray();
|
||||
splitSettingsDescription();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -78,11 +83,99 @@ DomainServerSettingsManager::DomainServerSettingsManager() {
|
|||
Q_ARG(int, MISSING_SETTINGS_DESC_ERROR_CODE));
|
||||
}
|
||||
|
||||
void DomainServerSettingsManager::splitSettingsDescription() {
|
||||
// construct separate description arrays for domain settings and content settings
|
||||
// since they are displayed on different pages
|
||||
|
||||
// along the way we also construct one object that holds the groups separated by domain settings
|
||||
// and content settings, so that the DS can setup dropdown menus below "Content" and "Settings"
|
||||
// headers to jump directly to a settings group on the page of either
|
||||
QJsonArray domainSettingsMenuGroups;
|
||||
QJsonArray contentSettingsMenuGroups;
|
||||
|
||||
foreach(const QJsonValue& group, _descriptionArray) {
|
||||
QJsonObject groupObject = group.toObject();
|
||||
|
||||
static const QString HIDDEN_GROUP_KEY = "hidden";
|
||||
bool groupHidden = groupObject.contains(HIDDEN_GROUP_KEY) && groupObject[HIDDEN_GROUP_KEY].toBool();
|
||||
|
||||
QJsonArray domainSettingArray;
|
||||
QJsonArray contentSettingArray;
|
||||
|
||||
foreach(const QJsonValue& settingDescription, groupObject[DESCRIPTION_SETTINGS_KEY].toArray()) {
|
||||
QJsonObject settingDescriptionObject = settingDescription.toObject();
|
||||
|
||||
bool isContentSetting = settingDescriptionObject.contains(CONTENT_SETTING_FLAG_KEY)
|
||||
&& settingDescriptionObject[CONTENT_SETTING_FLAG_KEY].toBool();
|
||||
|
||||
if (isContentSetting) {
|
||||
// push the setting description to the pending content setting array
|
||||
contentSettingArray.push_back(settingDescriptionObject);
|
||||
} else {
|
||||
// push the setting description to the pending domain setting array
|
||||
domainSettingArray.push_back(settingDescriptionObject);
|
||||
}
|
||||
}
|
||||
|
||||
if (!domainSettingArray.isEmpty() || !contentSettingArray.isEmpty()) {
|
||||
|
||||
// we know for sure we'll have something to add to our settings menu groups
|
||||
// so setup that object for the group now, as long as the group isn't hidden alltogether
|
||||
QJsonObject settingsDropdownGroup;
|
||||
|
||||
if (!groupHidden) {
|
||||
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";
|
||||
if (groupObject.contains(DESCRIPTION_GROUP_HTML_ID_KEY)) {
|
||||
settingsDropdownGroup[DESCRIPTION_GROUP_HTML_ID_KEY] = groupObject[DESCRIPTION_GROUP_HTML_ID_KEY];
|
||||
}
|
||||
}
|
||||
|
||||
if (!domainSettingArray.isEmpty()) {
|
||||
// we have some domain settings from this group, add the group with the filtered settings
|
||||
QJsonObject filteredGroupObject = groupObject;
|
||||
filteredGroupObject[DESCRIPTION_SETTINGS_KEY] = domainSettingArray;
|
||||
_domainSettingsDescription.push_back(filteredGroupObject);
|
||||
|
||||
// if the group isn't hidden, add its information to the domain settings menu groups
|
||||
if (!groupHidden) {
|
||||
domainSettingsMenuGroups.push_back(settingsDropdownGroup);
|
||||
}
|
||||
}
|
||||
|
||||
if (!contentSettingArray.isEmpty()) {
|
||||
// we have some content settings from this group, add the group with the filtered settings
|
||||
QJsonObject filteredGroupObject = groupObject;
|
||||
filteredGroupObject[DESCRIPTION_SETTINGS_KEY] = contentSettingArray;
|
||||
_contentSettingsDescription.push_back(filteredGroupObject);
|
||||
|
||||
// if the group isn't hidden, add its information to the content settings menu groups
|
||||
if (!groupHidden) {
|
||||
contentSettingsMenuGroups.push_back(settingsDropdownGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// populate the settings menu groups with what we've collected
|
||||
|
||||
static const QString SPLIT_MENU_GROUPS_DOMAIN_SETTINGS_KEY = "domain_settings";
|
||||
static const QString SPLIT_MENU_GROUPS_CONTENT_SETTINGS_KEY = "content_settings";
|
||||
|
||||
_settingsMenuGroups[SPLIT_MENU_GROUPS_DOMAIN_SETTINGS_KEY] = domainSettingsMenuGroups;
|
||||
_settingsMenuGroups[SPLIT_MENU_GROUPS_CONTENT_SETTINGS_KEY] = contentSettingsMenuGroups;
|
||||
}
|
||||
|
||||
void DomainServerSettingsManager::processSettingsRequestPacket(QSharedPointer<ReceivedMessage> message) {
|
||||
Assignment::Type type;
|
||||
message->readPrimitive(&type);
|
||||
|
||||
QJsonObject responseObject = responseObjectForType(QString::number(type));
|
||||
QJsonObject responseObject = settingsResponseObjectForType(QString::number(type));
|
||||
auto json = QJsonDocument(responseObject).toJson();
|
||||
|
||||
auto packetList = NLPacketList::create(PacketType::DomainSettings, QByteArray(), true, true);
|
||||
|
@ -314,14 +407,14 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
|
|||
|
||||
QVariant* avatarMinScale = _configMap.valueForKeyPath(AVATAR_MIN_SCALE_KEYPATH);
|
||||
if (avatarMinScale) {
|
||||
float scale = avatarMinScale->toFloat();
|
||||
_configMap.valueForKeyPath(AVATAR_MIN_HEIGHT_KEYPATH, scale * DEFAULT_AVATAR_HEIGHT);
|
||||
auto newMinScaleVariant = _configMap.valueForKeyPath(AVATAR_MIN_HEIGHT_KEYPATH, true);
|
||||
*newMinScaleVariant = avatarMinScale->toFloat() * DEFAULT_AVATAR_HEIGHT;
|
||||
}
|
||||
|
||||
QVariant* avatarMaxScale = _configMap.valueForKeyPath(AVATAR_MAX_SCALE_KEYPATH);
|
||||
if (avatarMaxScale) {
|
||||
float scale = avatarMaxScale->toFloat();
|
||||
_configMap.valueForKeyPath(AVATAR_MAX_HEIGHT_KEYPATH, scale * DEFAULT_AVATAR_HEIGHT);
|
||||
auto newMaxScaleVariant = _configMap.valueForKeyPath(AVATAR_MAX_HEIGHT_KEYPATH, true);
|
||||
*newMaxScaleVariant = avatarMaxScale->toFloat() * DEFAULT_AVATAR_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,48 +1079,246 @@ QVariant DomainServerSettingsManager::valueOrDefaultValueForKeyPath(const QStrin
|
|||
}
|
||||
|
||||
bool DomainServerSettingsManager::handleAuthenticatedHTTPRequest(HTTPConnection *connection, const QUrl &url) {
|
||||
if (connection->requestOperation() == QNetworkAccessManager::PostOperation && url.path() == SETTINGS_PATH_JSON) {
|
||||
// this is a POST operation to change one or more settings
|
||||
QJsonDocument postedDocument = QJsonDocument::fromJson(connection->requestContent());
|
||||
QJsonObject postedObject = postedDocument.object();
|
||||
if (connection->requestOperation() == QNetworkAccessManager::PostOperation) {
|
||||
static const QString SETTINGS_RESTORE_PATH = "/settings/restore";
|
||||
|
||||
// we recurse one level deep below each group for the appropriate setting
|
||||
bool restartRequired = recurseJSONObjectAndOverwriteSettings(postedObject);
|
||||
if (url.path() == SETTINGS_PATH_JSON || url.path() == CONTENT_SETTINGS_PATH_JSON) {
|
||||
// this is a POST operation to change one or more settings
|
||||
QJsonDocument postedDocument = QJsonDocument::fromJson(connection->requestContent());
|
||||
QJsonObject postedObject = postedDocument.object();
|
||||
|
||||
// store whatever the current _settingsMap is to file
|
||||
persistToFile();
|
||||
SettingsType endpointType = url.path() == SETTINGS_PATH_JSON ? DomainSettings : ContentSettings;
|
||||
|
||||
// return success to the caller
|
||||
QString jsonSuccess = "{\"status\": \"success\"}";
|
||||
connection->respond(HTTPConnection::StatusCode200, jsonSuccess.toUtf8(), "application/json");
|
||||
// we recurse one level deep below each group for the appropriate setting
|
||||
bool restartRequired = recurseJSONObjectAndOverwriteSettings(postedObject, endpointType);
|
||||
|
||||
// defer a restart to the domain-server, this gives our HTTPConnection enough time to respond
|
||||
if (restartRequired) {
|
||||
const int DOMAIN_SERVER_RESTART_TIMER_MSECS = 1000;
|
||||
QTimer::singleShot(DOMAIN_SERVER_RESTART_TIMER_MSECS, qApp, SLOT(restart()));
|
||||
} else {
|
||||
unpackPermissions();
|
||||
apiRefreshGroupInformation();
|
||||
emit updateNodePermissions();
|
||||
emit settingsUpdated();
|
||||
// store whatever the current _settingsMap is to file
|
||||
persistToFile();
|
||||
|
||||
// return success to the caller
|
||||
QString jsonSuccess = "{\"status\": \"success\"}";
|
||||
connection->respond(HTTPConnection::StatusCode200, jsonSuccess.toUtf8(), "application/json");
|
||||
|
||||
// defer a restart to the domain-server, this gives our HTTPConnection enough time to respond
|
||||
if (restartRequired) {
|
||||
const int DOMAIN_SERVER_RESTART_TIMER_MSECS = 1000;
|
||||
QTimer::singleShot(DOMAIN_SERVER_RESTART_TIMER_MSECS, qApp, SLOT(restart()));
|
||||
} else {
|
||||
unpackPermissions();
|
||||
apiRefreshGroupInformation();
|
||||
emit updateNodePermissions();
|
||||
emit settingsUpdated();
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (url.path() == SETTINGS_RESTORE_PATH) {
|
||||
// this is an JSON settings file restore, ask the HTTPConnection to parse the data
|
||||
QList<FormData> formData = connection->parseFormData();
|
||||
|
||||
bool wasRestoreSuccessful = false;
|
||||
|
||||
if (formData.size() > 0 && formData[0].second.size() > 0) {
|
||||
// take the posted file and convert it to a QJsonObject
|
||||
auto postedDocument = QJsonDocument::fromJson(formData[0].second);
|
||||
if (postedDocument.isObject()) {
|
||||
wasRestoreSuccessful = restoreSettingsFromObject(postedDocument.object(), DomainSettings);
|
||||
}
|
||||
}
|
||||
|
||||
if (wasRestoreSuccessful) {
|
||||
// respond with a 200 for success
|
||||
QString jsonSuccess = "{\"status\": \"success\"}";
|
||||
connection->respond(HTTPConnection::StatusCode200, jsonSuccess.toUtf8(), "application/json");
|
||||
|
||||
// defer a restart to the domain-server, this gives our HTTPConnection enough time to respond
|
||||
const int DOMAIN_SERVER_RESTART_TIMER_MSECS = 1000;
|
||||
QTimer::singleShot(DOMAIN_SERVER_RESTART_TIMER_MSECS, qApp, SLOT(restart()));
|
||||
} else {
|
||||
// respond with a 400 for failure
|
||||
connection->respond(HTTPConnection::StatusCode400);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
|
||||
static const QString SETTINGS_MENU_GROUPS_PATH = "/settings-menu-groups.json";
|
||||
static const QString SETTINGS_BACKUP_PATH = "/settings/backup.json";
|
||||
|
||||
return true;
|
||||
} else if (connection->requestOperation() == QNetworkAccessManager::GetOperation && url.path() == SETTINGS_PATH_JSON) {
|
||||
// setup a JSON Object with descriptions and non-omitted settings
|
||||
const QString SETTINGS_RESPONSE_DESCRIPTION_KEY = "descriptions";
|
||||
const QString SETTINGS_RESPONSE_VALUE_KEY = "values";
|
||||
if (url.path() == SETTINGS_PATH_JSON || url.path() == CONTENT_SETTINGS_PATH_JSON) {
|
||||
|
||||
QJsonObject rootObject;
|
||||
rootObject[SETTINGS_RESPONSE_DESCRIPTION_KEY] = _descriptionArray;
|
||||
rootObject[SETTINGS_RESPONSE_VALUE_KEY] = responseObjectForType("", true);
|
||||
connection->respond(HTTPConnection::StatusCode200, QJsonDocument(rootObject).toJson(), "application/json");
|
||||
// setup a JSON Object with descriptions and non-omitted settings
|
||||
const QString SETTINGS_RESPONSE_DESCRIPTION_KEY = "descriptions";
|
||||
const QString SETTINGS_RESPONSE_VALUE_KEY = "values";
|
||||
|
||||
QJsonObject rootObject;
|
||||
|
||||
bool forDomainSettings = (url.path() == SETTINGS_PATH_JSON);
|
||||
bool forContentSettings = (url.path() == CONTENT_SETTINGS_PATH_JSON);;
|
||||
|
||||
rootObject[SETTINGS_RESPONSE_DESCRIPTION_KEY] = forDomainSettings
|
||||
? _domainSettingsDescription : _contentSettingsDescription;
|
||||
|
||||
// grab a domain settings object for all types, filtered for the right class of settings
|
||||
// and exclude default values
|
||||
rootObject[SETTINGS_RESPONSE_VALUE_KEY] = settingsResponseObjectForType("", true,
|
||||
forDomainSettings, forContentSettings,
|
||||
true);
|
||||
|
||||
connection->respond(HTTPConnection::StatusCode200, QJsonDocument(rootObject).toJson(), "application/json");
|
||||
|
||||
return true;
|
||||
} else if (url.path() == SETTINGS_MENU_GROUPS_PATH) {
|
||||
connection->respond(HTTPConnection::StatusCode200, QJsonDocument(_settingsMenuGroups).toJson(), "application/json");
|
||||
|
||||
return true;
|
||||
} else if (url.path() == SETTINGS_BACKUP_PATH) {
|
||||
// grab the settings backup as an authenticated user
|
||||
// for the domain settings type only, excluding hidden and default values
|
||||
auto currentDomainSettingsJSON = settingsResponseObjectForType("", true, true, false, false, true);
|
||||
|
||||
// setup headers that tell the client to download the file wth a special name
|
||||
Headers downloadHeaders;
|
||||
downloadHeaders.insert("Content-Transfer-Encoding", "binary");
|
||||
|
||||
// create a timestamped filename for the backup
|
||||
const QString DATETIME_FORMAT { "yyyy-MM-dd_HH-mm-ss" };
|
||||
auto backupFilename = "domain-settings_" + QDateTime::currentDateTime().toString(DATETIME_FORMAT) + ".json";
|
||||
|
||||
downloadHeaders.insert("Content-Disposition",
|
||||
QString("attachment; filename=\"%1\"").arg(backupFilename).toLocal8Bit());
|
||||
|
||||
connection->respond(HTTPConnection::StatusCode200, QJsonDocument(currentDomainSettingsJSON).toJson(),
|
||||
"application/force-download", downloadHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject DomainServerSettingsManager::responseObjectForType(const QString& typeValue, bool isAuthenticated) {
|
||||
bool DomainServerSettingsManager::restoreSettingsFromObject(QJsonObject settingsToRestore, SettingsType settingsType) {
|
||||
QJsonArray& filteredDescriptionArray = settingsType == DomainSettings
|
||||
? _domainSettingsDescription : _contentSettingsDescription;
|
||||
|
||||
// grab a copy of the current config before restore, so that we can back out if something bad happens during
|
||||
QVariantMap preRestoreConfig = _configMap.getConfig();
|
||||
|
||||
bool shouldCancelRestore = false;
|
||||
|
||||
// enumerate through the settings in the description
|
||||
// if we have one in the restore then use it, otherwise clear it from current settings
|
||||
foreach(const QJsonValue& descriptionGroupValue, filteredDescriptionArray) {
|
||||
QJsonObject descriptionGroupObject = descriptionGroupValue.toObject();
|
||||
QString groupKey = descriptionGroupObject[DESCRIPTION_NAME_KEY].toString();
|
||||
QJsonArray descriptionGroupSettings = descriptionGroupObject[DESCRIPTION_SETTINGS_KEY].toArray();
|
||||
|
||||
// grab the matching group from the restore so we can look at its settings
|
||||
QJsonObject restoreGroup;
|
||||
QVariantMap* configGroupMap = nullptr;
|
||||
|
||||
if (groupKey.isEmpty()) {
|
||||
// this is for a setting at the root, use the full object as our restore group
|
||||
restoreGroup = settingsToRestore;
|
||||
|
||||
// the variant map for this "group" is just the config map since there's no group
|
||||
configGroupMap = &_configMap.getConfig();
|
||||
} else {
|
||||
if (settingsToRestore.contains(groupKey)) {
|
||||
restoreGroup = settingsToRestore[groupKey].toObject();
|
||||
}
|
||||
|
||||
// grab the variant for the group
|
||||
auto groupMapVariant = _configMap.valueForKeyPath(groupKey);
|
||||
|
||||
// if it existed, double check that it is a map - any other value is unexpected and should cancel a restore
|
||||
if (groupMapVariant) {
|
||||
if (groupMapVariant->canConvert<QVariantMap>()) {
|
||||
configGroupMap = static_cast<QVariantMap*>(groupMapVariant->data());
|
||||
} else {
|
||||
shouldCancelRestore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(const QJsonValue& descriptionSettingValue, descriptionGroupSettings) {
|
||||
|
||||
QJsonObject descriptionSettingObject = descriptionSettingValue.toObject();
|
||||
|
||||
// we'll override this setting with the default or what is in the restore as long as
|
||||
// it isn't specifically excluded from backups
|
||||
bool isBackedUpSetting = !descriptionSettingObject.contains(DESCRIPTION_BACKUP_FLAG_KEY)
|
||||
|| descriptionSettingObject[DESCRIPTION_BACKUP_FLAG_KEY].toBool();
|
||||
|
||||
if (isBackedUpSetting) {
|
||||
QString settingName = descriptionSettingObject[DESCRIPTION_NAME_KEY].toString();
|
||||
|
||||
// check if we have a matching setting for this in the restore
|
||||
QJsonValue restoreValue;
|
||||
if (restoreGroup.contains(settingName)) {
|
||||
restoreValue = restoreGroup[settingName];
|
||||
}
|
||||
|
||||
// we should create the value for this key path in our current config map
|
||||
// if we had value in the restore file
|
||||
bool shouldCreateIfMissing = !restoreValue.isNull();
|
||||
|
||||
// get a QVariant pointer to this setting in our config map
|
||||
QString fullSettingKey = !groupKey.isEmpty()
|
||||
? groupKey + "." + settingName : settingName;
|
||||
|
||||
QVariant* variantValue = _configMap.valueForKeyPath(fullSettingKey, shouldCreateIfMissing);
|
||||
|
||||
if (restoreValue.isNull()) {
|
||||
if (variantValue && !variantValue->isNull() && configGroupMap) {
|
||||
// we didn't have a value to restore, but there might be a value in the config map
|
||||
// so we need to remove the value in the config map which will set it back to the default
|
||||
qDebug() << "Removing" << fullSettingKey << "from settings since it is not in the restored JSON";
|
||||
configGroupMap->remove(settingName);
|
||||
}
|
||||
} else {
|
||||
// we have a value to restore, use update setting to set it
|
||||
|
||||
// we might need to re-grab config group map in case it didn't exist when we looked for it before
|
||||
// but was created by the call to valueForKeyPath before
|
||||
if (!configGroupMap) {
|
||||
auto groupMapVariant = _configMap.valueForKeyPath(groupKey);
|
||||
if (groupMapVariant && groupMapVariant->canConvert<QVariantMap>()) {
|
||||
configGroupMap = static_cast<QVariantMap*>(groupMapVariant->data());
|
||||
} else {
|
||||
shouldCancelRestore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "Updating setting" << fullSettingKey << "from restored JSON";
|
||||
|
||||
updateSetting(settingName, restoreValue, *configGroupMap, descriptionSettingObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldCancelRestore) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldCancelRestore) {
|
||||
// if we cancelled the restore, go back to our state before and return false
|
||||
qDebug() << "Restore cancelled, settings have not been changed";
|
||||
_configMap.getConfig() = preRestoreConfig;
|
||||
return false;
|
||||
} else {
|
||||
// restore completed, persist the new settings
|
||||
qDebug() << "Restore completed, persisting restored settings to file";
|
||||
persistToFile();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject DomainServerSettingsManager::settingsResponseObjectForType(const QString& typeValue, bool isAuthenticated,
|
||||
bool includeDomainSettings,
|
||||
bool includeContentSettings,
|
||||
bool includeDefaults, bool isForBackup) {
|
||||
QJsonObject responseObject;
|
||||
|
||||
if (!typeValue.isEmpty() || isAuthenticated) {
|
||||
|
@ -1036,8 +1327,16 @@ QJsonObject DomainServerSettingsManager::responseObjectForType(const QString& ty
|
|||
|
||||
const QString AFFECTED_TYPES_JSON_KEY = "assignment-types";
|
||||
|
||||
// enumerate the groups in the description object to find which settings to pass
|
||||
foreach(const QJsonValue& groupValue, _descriptionArray) {
|
||||
// only enumerate the requested settings type (domain setting or content setting)
|
||||
QJsonArray& filteredDescriptionArray = _descriptionArray;
|
||||
if (includeDomainSettings && !includeContentSettings) {
|
||||
filteredDescriptionArray = _domainSettingsDescription;
|
||||
} else if (includeContentSettings && !includeDomainSettings) {
|
||||
filteredDescriptionArray = _contentSettingsDescription;
|
||||
}
|
||||
|
||||
// enumerate the groups in the potentially filtered object to find which settings to pass
|
||||
foreach(const QJsonValue& groupValue, filteredDescriptionArray) {
|
||||
QJsonObject groupObject = groupValue.toObject();
|
||||
QString groupKey = groupObject[DESCRIPTION_NAME_KEY].toString();
|
||||
QJsonArray groupSettingsArray = groupObject[DESCRIPTION_SETTINGS_KEY].toArray();
|
||||
|
@ -1045,11 +1344,17 @@ QJsonObject DomainServerSettingsManager::responseObjectForType(const QString& ty
|
|||
QJsonObject groupResponseObject;
|
||||
|
||||
foreach(const QJsonValue& settingValue, groupSettingsArray) {
|
||||
|
||||
const QString VALUE_HIDDEN_FLAG_KEY = "value-hidden";
|
||||
|
||||
QJsonObject settingObject = settingValue.toObject();
|
||||
|
||||
if (!settingObject[VALUE_HIDDEN_FLAG_KEY].toBool()) {
|
||||
// consider this setting as long as it isn't hidden
|
||||
// and either this isn't for a backup or it's a value included in backups
|
||||
bool includedInBackups = !settingObject.contains(DESCRIPTION_BACKUP_FLAG_KEY)
|
||||
|| settingObject[DESCRIPTION_BACKUP_FLAG_KEY].toBool();
|
||||
|
||||
if (!settingObject[VALUE_HIDDEN_FLAG_KEY].toBool() && (!isForBackup || includedInBackups)) {
|
||||
QJsonArray affectedTypesArray = settingObject[AFFECTED_TYPES_JSON_KEY].toArray();
|
||||
if (affectedTypesArray.isEmpty()) {
|
||||
affectedTypesArray = groupObject[AFFECTED_TYPES_JSON_KEY].toArray();
|
||||
|
@ -1057,8 +1362,6 @@ QJsonObject DomainServerSettingsManager::responseObjectForType(const QString& ty
|
|||
|
||||
if (affectedTypesArray.contains(queryType) ||
|
||||
(queryType.isNull() && isAuthenticated)) {
|
||||
// this is a setting we should include in the responseObject
|
||||
|
||||
QString settingName = settingObject[DESCRIPTION_NAME_KEY].toString();
|
||||
|
||||
// we need to check if the settings map has a value for this setting
|
||||
|
@ -1074,28 +1377,31 @@ QJsonObject DomainServerSettingsManager::responseObjectForType(const QString& ty
|
|||
variantValue = _configMap.value(settingName);
|
||||
}
|
||||
|
||||
QJsonValue result;
|
||||
// final check for inclusion
|
||||
// either we include default values or we don't but this isn't a default value
|
||||
if (includeDefaults || !variantValue.isNull()) {
|
||||
QJsonValue result;
|
||||
|
||||
if (variantValue.isNull()) {
|
||||
// no value for this setting, pass the default
|
||||
if (settingObject.contains(SETTING_DEFAULT_KEY)) {
|
||||
result = settingObject[SETTING_DEFAULT_KEY];
|
||||
if (variantValue.isNull()) {
|
||||
// no value for this setting, pass the default
|
||||
if (settingObject.contains(SETTING_DEFAULT_KEY)) {
|
||||
result = settingObject[SETTING_DEFAULT_KEY];
|
||||
} else {
|
||||
// users are allowed not to provide a default for string values
|
||||
// if so we set to the empty string
|
||||
result = QString("");
|
||||
}
|
||||
} else {
|
||||
// users are allowed not to provide a default for string values
|
||||
// if so we set to the empty string
|
||||
result = QString("");
|
||||
result = QJsonValue::fromVariant(variantValue);
|
||||
}
|
||||
|
||||
} else {
|
||||
result = QJsonValue::fromVariant(variantValue);
|
||||
}
|
||||
|
||||
if (!groupKey.isEmpty()) {
|
||||
// this belongs in the group object
|
||||
groupResponseObject[settingName] = result;
|
||||
} else {
|
||||
// this is a value that should be at the root
|
||||
responseObject[settingName] = result;
|
||||
if (!groupKey.isEmpty()) {
|
||||
// this belongs in the group object
|
||||
groupResponseObject[settingName] = result;
|
||||
} else {
|
||||
// this is a value that should be at the root
|
||||
responseObject[settingName] = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1108,7 +1414,6 @@ QJsonObject DomainServerSettingsManager::responseObjectForType(const QString& ty
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return responseObject;
|
||||
}
|
||||
|
||||
|
@ -1140,6 +1445,8 @@ void DomainServerSettingsManager::updateSetting(const QString& key, const QJsonV
|
|||
settingMap[key] = sanitizedValue;
|
||||
}
|
||||
}
|
||||
} else if (newValue.isDouble()) {
|
||||
settingMap[key] = newValue.toDouble();
|
||||
} else if (newValue.isBool()) {
|
||||
settingMap[key] = newValue.toBool();
|
||||
} else if (newValue.isObject()) {
|
||||
|
@ -1212,7 +1519,8 @@ QJsonObject DomainServerSettingsManager::settingDescriptionFromGroup(const QJson
|
|||
return QJsonObject();
|
||||
}
|
||||
|
||||
bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject) {
|
||||
bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject,
|
||||
SettingsType settingsType) {
|
||||
static const QString SECURITY_ROOT_KEY = "security";
|
||||
static const QString AC_SUBNET_WHITELIST_KEY = "ac_subnet_whitelist";
|
||||
static const QString BROADCASTING_KEY = "broadcasting";
|
||||
|
@ -1222,6 +1530,8 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
|||
auto& settingsVariant = _configMap.getConfig();
|
||||
bool needRestart = false;
|
||||
|
||||
auto& filteredDescriptionArray = settingsType == DomainSettings ? _domainSettingsDescription : _contentSettingsDescription;
|
||||
|
||||
// Iterate on the setting groups
|
||||
foreach(const QString& rootKey, postedObject.keys()) {
|
||||
const QJsonValue& rootValue = postedObject[rootKey];
|
||||
|
@ -1236,7 +1546,7 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
|||
QJsonObject groupDescriptionObject;
|
||||
|
||||
// we need to check the description array to see if this is a root setting or a group setting
|
||||
foreach(const QJsonValue& groupValue, _descriptionArray) {
|
||||
foreach(const QJsonValue& groupValue, filteredDescriptionArray) {
|
||||
if (groupValue.toObject()[DESCRIPTION_NAME_KEY] == rootKey) {
|
||||
// we matched a group - keep this since we'll use it below to update the settings
|
||||
groupDescriptionObject = groupValue.toObject();
|
||||
|
@ -1257,7 +1567,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);
|
||||
|
||||
|
@ -1269,6 +1581,7 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
|||
|
||||
if (!matchingDescriptionObject.isEmpty()) {
|
||||
updateSetting(rootKey, rootValue, *thisMap, matchingDescriptionObject);
|
||||
|
||||
if (rootKey != SECURITY_ROOT_KEY && rootKey != BROADCASTING_KEY &&
|
||||
rootKey != SETTINGS_PATHS_KEY && rootKey != WIZARD_KEY) {
|
||||
needRestart = true;
|
||||
|
@ -1286,6 +1599,7 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
|||
if (!matchingDescriptionObject.isEmpty()) {
|
||||
const QJsonValue& settingValue = rootValue.toObject()[settingKey];
|
||||
updateSetting(settingKey, settingValue, *thisMap, matchingDescriptionObject);
|
||||
|
||||
if ((rootKey != SECURITY_ROOT_KEY && rootKey != BROADCASTING_KEY &&
|
||||
rootKey != DESCRIPTION_ROOT_KEY && rootKey != WIZARD_KEY) ||
|
||||
settingKey == AC_SUBNET_WHITELIST_KEY) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define hifi_DomainServerSettingsManager_h
|
||||
|
||||
#include <QtCore/QJsonArray>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
|
@ -28,6 +29,7 @@ const QString SETTINGS_PATHS_KEY = "paths";
|
|||
|
||||
const QString SETTINGS_PATH = "/settings";
|
||||
const QString SETTINGS_PATH_JSON = SETTINGS_PATH + ".json";
|
||||
const QString CONTENT_SETTINGS_PATH_JSON = "/content-settings.json";
|
||||
const QString AGENT_STANDARD_PERMISSIONS_KEYPATH = "security.standard_permissions";
|
||||
const QString AGENT_PERMISSIONS_KEYPATH = "security.permissions";
|
||||
const QString IP_PERMISSIONS_KEYPATH = "security.ip_permissions";
|
||||
|
@ -38,6 +40,10 @@ const QString GROUP_FORBIDDENS_KEYPATH = "security.group_forbiddens";
|
|||
|
||||
using GroupByUUIDKey = QPair<QUuid, QUuid>; // groupID, rankID
|
||||
|
||||
enum SettingsType {
|
||||
DomainSettings,
|
||||
ContentSettings
|
||||
};
|
||||
|
||||
class DomainServerSettingsManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -123,8 +129,11 @@ private slots:
|
|||
private:
|
||||
QStringList _argumentList;
|
||||
|
||||
QJsonObject responseObjectForType(const QString& typeValue, bool isAuthenticated = false);
|
||||
bool recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject);
|
||||
QJsonArray filteredDescriptionArray(bool isContentSettings);
|
||||
QJsonObject settingsResponseObjectForType(const QString& typeValue, bool isAuthenticated = false,
|
||||
bool includeDomainSettings = true, bool includeContentSettings = true,
|
||||
bool includeDefaults = true, bool isForBackup = false);
|
||||
bool recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject, SettingsType settingsType);
|
||||
|
||||
void updateSetting(const QString& key, const QJsonValue& newValue, QVariantMap& settingMap,
|
||||
const QJsonObject& settingDescription);
|
||||
|
@ -132,8 +141,17 @@ private:
|
|||
void sortPermissions();
|
||||
void persistToFile();
|
||||
|
||||
void splitSettingsDescription();
|
||||
|
||||
bool restoreSettingsFromObject(QJsonObject settingsToRestore, SettingsType settingsType);
|
||||
|
||||
double _descriptionVersion;
|
||||
|
||||
QJsonArray _descriptionArray;
|
||||
QJsonArray _domainSettingsDescription;
|
||||
QJsonArray _contentSettingsDescription;
|
||||
QJsonObject _settingsMenuGroups;
|
||||
|
||||
HifiConfigVariantMap _configMap;
|
||||
|
||||
friend class DomainServer;
|
||||
|
|
|
@ -79,7 +79,7 @@ bool HTTPManager::handleHTTPRequest(HTTPConnection* connection, const QUrl& url,
|
|||
QHash<QByteArray, QByteArray> redirectHeader;
|
||||
redirectHeader.insert(QByteArray("Location"), redirectLocation.toUtf8());
|
||||
|
||||
connection->respond(HTTPConnection::StatusCode301, "", HTTPConnection::DefaultContentType, redirectHeader);
|
||||
connection->respond(HTTPConnection::StatusCode302, "", HTTPConnection::DefaultContentType, redirectHeader);
|
||||
}
|
||||
|
||||
// if the last thing is a trailing slash then we want to look for index file
|
||||
|
|
Loading…
Reference in a new issue