mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Setup Wizard
This commit is contained in:
parent
390dae3918
commit
203a419f2a
16 changed files with 1080 additions and 165 deletions
|
@ -1522,6 +1522,29 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "wizard",
|
||||
"label": "Setup Wizard",
|
||||
"restart": false,
|
||||
"hidden": true,
|
||||
"settings": [
|
||||
{
|
||||
"name": "cloud_domain",
|
||||
"type": "checkbox",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "steps_completed",
|
||||
"type": "int",
|
||||
"default": 0
|
||||
},
|
||||
{
|
||||
"name": "completed_once",
|
||||
"type": "checkbox",
|
||||
"default": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -244,6 +244,20 @@ table .headers + .headers td {
|
|||
animation-delay: -0.16s;
|
||||
}
|
||||
|
||||
.col-centered {
|
||||
float: none;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.centered-hack-parent {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.centered-hack {
|
||||
text-align: left;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@-webkit-keyframes bouncedelay {
|
||||
0%, 80%, 100% { -webkit-transform: scale(0.0) }
|
||||
40% { -webkit-transform: scale(1.0) }
|
||||
|
@ -271,7 +285,7 @@ table .headers + .headers td {
|
|||
from { transform: scale(1) rotate(0deg);}
|
||||
to { transform: scale(1) rotate(360deg);}
|
||||
}
|
||||
|
||||
|
||||
@-webkit-keyframes spinw {
|
||||
from { -webkit-transform: rotate(0deg);}
|
||||
to { -webkit-transform: rotate(360deg);}
|
||||
|
@ -292,3 +306,27 @@ table .headers + .headers td {
|
|||
font-size: 30px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
#visit-domain-link,
|
||||
.blue-link {
|
||||
font-size: 14px;
|
||||
text-decoration-line: underline;
|
||||
font-weight: normal;
|
||||
color: #2F80ED;
|
||||
}
|
||||
|
||||
#cloud-domains-alert {
|
||||
position:fixed; top: 55px; width: 100%; z-index: 99;
|
||||
}
|
||||
|
||||
#cloud-domains-alert .glyphicon {
|
||||
font-size: 11px;
|
||||
color: #000000;
|
||||
mix-blend-mode: normal;
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
#manage-cloud-domains-link {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
|
|
@ -40,11 +40,16 @@
|
|||
<li><a href="/settings/">Settings</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-right navbar-nav">
|
||||
<li><a id="visit-domain-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>
|
||||
</ul>
|
||||
</div>
|
||||
</div><!-- /.container-fluid -->
|
||||
</nav>
|
||||
<div id="cloud-domains-alert" class="alert alert-info" role="alert" style="display: none;">
|
||||
<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>
|
||||
<a href="javascript:void(0);" class="glyphicon glyphicon-remove pull-right"></a>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="restart-modal">
|
||||
<div class="modal-dialog">
|
||||
|
|
25
domain-server/resources/web/images/checkmark.svg
Normal file
25
domain-server/resources/web/images/checkmark.svg
Normal file
|
@ -0,0 +1,25 @@
|
|||
<svg width="676" height="676" viewBox="0 0 676 676" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>CongratulationImage</title>
|
||||
<desc>Created using Figma</desc>
|
||||
<g id="Canvas" transform="matrix(4 0 0 4 -21208 -17980)">
|
||||
<g id="CongratulationImage">
|
||||
<g id="Ellipse">
|
||||
<use xlink:href="#path0_fill" transform="translate(5302 4495)" fill="#FFFFFF"/>
|
||||
<mask id="mask0_outline_ins">
|
||||
<use xlink:href="#path0_fill" fill="white" transform="translate(5302 4495)"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_outline_ins)">
|
||||
<use xlink:href="#path1_stroke_2x" transform="translate(5302 4495)" fill="#219653"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Vector 2">
|
||||
<use xlink:href="#path2_stroke" transform="translate(5355 4559)" fill="#219653"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<path id="path0_fill" d="M 169 84.5C 169 131.168 131.168 169 84.5 169C 37.8319 169 0 131.168 0 84.5C 0 37.8319 37.8319 0 84.5 0C 131.168 0 169 37.8319 169 84.5Z"/>
|
||||
<path id="path1_stroke_2x" d="M 154 84.5C 154 122.884 122.884 154 84.5 154L 84.5 184C 139.452 184 184 139.452 184 84.5L 154 84.5ZM 84.5 154C 46.1162 154 15 122.884 15 84.5L -15 84.5C -15 139.452 29.5477 184 84.5 184L 84.5 154ZM 15 84.5C 15 46.1162 46.1162 15 84.5 15L 84.5 -15C 29.5477 -15 -15 29.5477 -15 84.5L 15 84.5ZM 84.5 15C 122.884 15 154 46.1162 154 84.5L 184 84.5C 184 29.5477 139.452 -15 84.5 -15L 84.5 15Z"/>
|
||||
<path id="path2_stroke" d="M 5.18747 19.8031C 2.19593 16.9382 -2.5517 17.0408 -5.41666 20.0323C -8.28162 23.0238 -8.17901 27.7715 -5.18747 30.6364L 5.18747 19.8031ZM 20.6541 45L 15.4667 50.4167C 18.3816 53.2083 22.9831 53.1924 25.8787 50.3809L 20.6541 45ZM 72.2246 5.38085C 75.1964 2.49539 75.2663 -2.25283 72.3809 -5.2246C 69.4954 -8.19636 64.7472 -8.26632 61.7754 -5.38085L 72.2246 5.38085ZM -5.18747 30.6364L 15.4667 50.4167L 25.8416 39.5833L 5.18747 19.8031L -5.18747 30.6364ZM 25.8787 50.3809L 72.2246 5.38085L 61.7754 -5.38085L 15.4295 39.6191L 25.8787 50.3809Z"/>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
|
@ -1,6 +1,5 @@
|
|||
Settings = {
|
||||
showAdvanced: false,
|
||||
METAVERSE_URL: 'https://staging.highfidelity.com',
|
||||
ADVANCED_CLASS: 'advanced-setting',
|
||||
DEPRECATED_CLASS: 'deprecated-setting',
|
||||
TRIGGER_CHANGE_CLASS: 'trigger-change',
|
||||
|
@ -44,6 +43,11 @@ Settings = {
|
|||
DATA_ROW_INDEX: 'data-row-index'
|
||||
};
|
||||
|
||||
var URLs = {
|
||||
METAVERSE_URL: 'https://metaverse.highfidelity.com',
|
||||
PLACE_URL: 'https://hifi.place',
|
||||
};
|
||||
|
||||
Strings = {
|
||||
LOADING_SETTINGS_ERROR: "There was a problem loading the domain settings.\nPlease refresh the page to try again.",
|
||||
|
||||
|
@ -79,6 +83,9 @@ Strings = {
|
|||
ADD_PLACE_NO_PLACES_BUTTON: "Create new place",
|
||||
ADD_PLACE_UNABLE_TO_LOAD_ERROR: "We were unable to load your place names. Please try again later.",
|
||||
ADD_PLACE_LOADING_DIALOG: "Loading your places...",
|
||||
|
||||
ADD_PLACE_NOT_CONNECTED_TITLE: "Access token required",
|
||||
ADD_PLACE_NOT_CONNECTED_MESSAGE: "You must have an access token to query your High Fidelity places.<br><br>Please follow the instructions on the settings page to add an access token.",
|
||||
};
|
||||
|
||||
var DOMAIN_ID_TYPE_NONE_OR_UNKNOWN = 0;
|
||||
|
@ -154,6 +161,8 @@ function chooseFromHighFidelityPlaces(accessToken, forcePathTo, onSuccessfullyAd
|
|||
|
||||
modal_body = $('<div>');
|
||||
|
||||
modal_body.append($("<p>Choose a place name that you own or <a href='" + URLs.METAVERSE_URL + "/user/places' target='_blank'>register a new place name</a></p>"));
|
||||
|
||||
var currentDomainIDType = getCurrentDomainIDType();
|
||||
if (currentDomainIDType === DOMAIN_ID_TYPE_TEMP) {
|
||||
var warning = "<div class='domain-loading-error alert alert-warning'>";
|
||||
|
@ -216,7 +225,7 @@ function chooseFromHighFidelityPlaces(accessToken, forcePathTo, onSuccessfullyAd
|
|||
metaverse: {
|
||||
id: domainID
|
||||
}
|
||||
}
|
||||
}
|
||||
var dialog = showLoadingDialog("Waiting for Domain Server to restart...");
|
||||
$.ajax('/settings.json', {
|
||||
data: JSON.stringify(jsonSettings),
|
||||
|
@ -287,7 +296,7 @@ function chooseFromHighFidelityPlaces(accessToken, forcePathTo, onSuccessfullyAd
|
|||
modal_buttons["success"] = {
|
||||
label: Strings.ADD_PLACE_NO_PLACES_BUTTON,
|
||||
callback: function() {
|
||||
window.open(Settings.METAVERSE_URL + "/user/places", '_blank');
|
||||
window.open(URLs.METAVERSE_URL + "/user/places", '_blank');
|
||||
}
|
||||
}
|
||||
modal_body = Strings.ADD_PLACE_NO_PLACES_MESSAGE;
|
||||
|
@ -313,9 +322,67 @@ function chooseFromHighFidelityPlaces(accessToken, forcePathTo, onSuccessfullyAd
|
|||
|
||||
} else {
|
||||
bootbox.alert({
|
||||
message: "You must have an access token to query your High Fidelity places.<br><br>" +
|
||||
"Please follow the instructions on the settings page to add an access token.",
|
||||
title: "Access token required"
|
||||
title: Strings.ADD_PLACE_NOT_CONNECTED_TITLE,
|
||||
message: Strings.ADD_PLACE_NOT_CONNECTED_MESSAGE
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function sendCreateDomainRequest(onSuccess, onError) {
|
||||
$.ajax({
|
||||
url: '/api/domains',
|
||||
type: 'POST',
|
||||
data: { label: "" },
|
||||
success: function(data) {
|
||||
//if (data.status === 'success') {
|
||||
onSuccess(data.domain_id);
|
||||
//} else {
|
||||
//onError();
|
||||
//}
|
||||
},
|
||||
error: onError
|
||||
});
|
||||
}
|
||||
|
||||
function waitForDomainServerBackUp(callback) {
|
||||
function checkForDomainUp() {
|
||||
$.ajax('', {
|
||||
success: function() {
|
||||
console.log("Domain is back up");
|
||||
callback();
|
||||
},
|
||||
error: function() {
|
||||
setTimeout(checkForDomainUp, 50);
|
||||
console.log("Fail");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(checkForDomainUp, 10);
|
||||
|
||||
}
|
||||
|
||||
function prepareAccessTokenPrompt(callback) {
|
||||
swal({
|
||||
title: "Connect Account",
|
||||
type: "input",
|
||||
text: "Paste your created access token here." +
|
||||
"</br></br>If you did not successfully create an access token click cancel below and attempt to connect your account again.</br></br>",
|
||||
showCancelButton: true,
|
||||
closeOnConfirm: false,
|
||||
html: true
|
||||
}, function(inputValue){
|
||||
if (inputValue === false) return false;
|
||||
|
||||
if (inputValue === "") {
|
||||
swal.showInputError("Please paste your access token in the input field.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(inputValue);
|
||||
}
|
||||
|
||||
swal.close();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
<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>
|
||||
|
||||
|
@ -41,6 +44,10 @@
|
|||
|
||||
<script id="panels-template" type="text/template">
|
||||
<% _.each(descriptions, function(group){ %>
|
||||
<% if (group.hidden) { %>
|
||||
<% $("a[href=#" + group.name + "]").remove() %>
|
||||
<% return %>
|
||||
<% } %>
|
||||
<% 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]) %>
|
||||
|
@ -86,9 +93,9 @@
|
|||
<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>
|
||||
<script src='js/form2js.min.js'></script>
|
||||
<script src='js/sha256.js'></script>
|
||||
<!--#include virtual="page-end.html"-->
|
||||
|
|
|
@ -288,7 +288,11 @@ $(document).ready(function(){
|
|||
|
||||
$('#' + Settings.FORM_ID).on('click', '#' + Settings.CONNECT_ACCOUNT_BTN_ID, function(e){
|
||||
$(this).blur();
|
||||
prepareAccessTokenPrompt();
|
||||
prepareAccessTokenPrompt(function(accessToken) {
|
||||
// we have an access token - set the access token input with this and save settings
|
||||
$(Settings.ACCESS_TOKEN_SELECTOR).val(accessToken).change();
|
||||
saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
var panelsSource = $('#panels-template').html()
|
||||
|
@ -323,6 +327,29 @@ $(document).ready(function(){
|
|||
});
|
||||
});
|
||||
|
||||
function getShareName(callback) {
|
||||
getDomainFromAPI(function(data){
|
||||
// check if we have owner_places (for a real domain) or a name (for a temporary domain)
|
||||
if (data && data.status == "success") {
|
||||
var shareName;
|
||||
if (data.domain.default_place_name) {
|
||||
shareName = data.domain.default_place_name;
|
||||
} else if (data.domain.name) {
|
||||
shareName = data.domain.name;
|
||||
} else if (data.domain.network_address) {
|
||||
shareName = data.domain.network_address;
|
||||
if (data.domain.network_port !== 40102) {
|
||||
shareName += ':' + data.domain.network_port;
|
||||
}
|
||||
}
|
||||
|
||||
callback(true, shareName);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleAction() {
|
||||
// check if we were passed an action to handle
|
||||
var action = qs["action"];
|
||||
|
@ -331,16 +358,8 @@ function handleAction() {
|
|||
// figure out if we already have a stored domain ID
|
||||
if (Settings.data.values.metaverse.id.length > 0) {
|
||||
// we need to ask the API what a shareable name for this domain is
|
||||
getDomainFromAPI(function(data){
|
||||
// check if we have owner_places (for a real domain) or a name (for a temporary domain)
|
||||
if (data && data.status == "success") {
|
||||
var shareName;
|
||||
if (data.domain.owner_places) {
|
||||
shareName = data.domain.owner_places[0].name
|
||||
} else if (data.domain.name) {
|
||||
shareName = data.domain.name;
|
||||
}
|
||||
|
||||
getShareName(function(success, shareName){
|
||||
if (success) {
|
||||
var shareLink = "hifi://" + shareName;
|
||||
|
||||
console.log(shareLink);
|
||||
|
@ -438,7 +457,7 @@ function setupHFAccountButton() {
|
|||
buttonSetting.button_label = "Connect High Fidelity Account";
|
||||
buttonSetting.html_id = Settings.CONNECT_ACCOUNT_BTN_ID;
|
||||
|
||||
buttonSetting.href = Settings.METAVERSE_URL + "/user/tokens/new?for_domain_server=true";
|
||||
buttonSetting.href = URLs.METAVERSE_URL + "/user/tokens/new?for_domain_server=true";
|
||||
|
||||
// since we do not have an access token we change hide domain ID and auto networking settings
|
||||
// without an access token niether of them can do anything
|
||||
|
@ -471,57 +490,6 @@ function disonnectHighFidelityAccount() {
|
|||
});
|
||||
}
|
||||
|
||||
function prepareAccessTokenPrompt() {
|
||||
swal({
|
||||
title: "Connect Account",
|
||||
type: "input",
|
||||
text: "Paste your created access token here." +
|
||||
"</br></br>If you did not successfully create an access token click cancel below and attempt to connect your account again.</br></br>",
|
||||
showCancelButton: true,
|
||||
closeOnConfirm: false,
|
||||
html: true
|
||||
}, function(inputValue){
|
||||
if (inputValue === false) return false;
|
||||
|
||||
if (inputValue === "") {
|
||||
swal.showInputError("Please paste your access token in the input field.")
|
||||
return false
|
||||
}
|
||||
|
||||
// we have an input value - set the access token input with this and save settings
|
||||
$(Settings.ACCESS_TOKEN_SELECTOR).val(inputValue).change();
|
||||
|
||||
console.log("Prepping access token prompt");
|
||||
|
||||
swal.close();
|
||||
saveSettings();
|
||||
});
|
||||
}
|
||||
|
||||
function showDomainIDChoiceAlert() {
|
||||
swal({
|
||||
title: 'Domain ID',
|
||||
type: 'info',
|
||||
text: "You do not currently have a domain ID." +
|
||||
"</br></br>This is required to point place names at your domain and to use automatic networking.</br></br>" +
|
||||
"Would you like to create a domain ID via the Metaverse API?</br></br>",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Create new domain ID",
|
||||
cancelButtonText: "Skip",
|
||||
closeOnConfirm: false,
|
||||
html: true
|
||||
}, function(isConfirm){
|
||||
if (isConfirm) {
|
||||
// show the swal to create a new domain via API
|
||||
showDomainCreationAlert(true);
|
||||
} else {
|
||||
// user cancelled, close this swal and save the access token we got
|
||||
swal.close();
|
||||
saveSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showSpinnerAlert(title) {
|
||||
swal({
|
||||
title: title,
|
||||
|
@ -557,12 +525,10 @@ function showDomainCreationAlert(justConnected) {
|
|||
});
|
||||
}
|
||||
|
||||
//function createDomainID()
|
||||
|
||||
function createNewDomainID(label, justConnected) {
|
||||
// get the JSON object ready that we'll use to create a new domain
|
||||
var domainJSON = {
|
||||
"label": label
|
||||
"label": label
|
||||
//"access_token": $(Settings.ACCESS_TOKEN_SELECTOR).val()
|
||||
}
|
||||
|
||||
|
@ -661,7 +627,7 @@ function setupDomainLabelSetting() {
|
|||
if (!domainIDIsSet() || !accessTokenIsSet()) {
|
||||
$(".panel#label").hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var html = "<div>"
|
||||
html += "<label class='control-label'>Specify a label for your domain</label> <a class='domain-loading-hide' href='#'>Edit</a>";
|
||||
|
@ -779,8 +745,8 @@ function setupDomainNetworkingSettings() {
|
|||
form = $(form);
|
||||
|
||||
form.find('#edit-network-address-port').click(function(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
ev.preventDefault();
|
||||
|
||||
var address = DomainInfo.network_address === null ? '' : DomainInfo.network_address;
|
||||
var port = DomainInfo.network_port === null ? '' : DomainInfo.network_port;
|
||||
var modal_body = "<div class='form-group'>";
|
||||
|
@ -887,7 +853,7 @@ function setupPlacesTable() {
|
|||
label: 'Places',
|
||||
html_id: Settings.PLACES_TABLE_ID,
|
||||
help: "The following places currently point to this domain.</br>To point places to this domain, "
|
||||
+ " go to the <a href='" + Settings.METAVERSE_URL + "/user/places'>My Places</a> "
|
||||
+ " go to the <a href='" + URLs.METAVERSE_URL + "/user/places'>My Places</a> "
|
||||
+ "page in your High Fidelity Metaverse account.",
|
||||
read_only: true,
|
||||
can_add_new_rows: false,
|
||||
|
@ -1001,16 +967,6 @@ function placeTableRowForPlaceObject(place) {
|
|||
return placeTableRow(place.name, placePathOrIndex, false, place.id);
|
||||
}
|
||||
|
||||
function getDomainFromAPI2(callback) {
|
||||
// we only need to do this if we have a current domain ID
|
||||
var domainID = Settings.data.values.metaverse.id;
|
||||
if (domainID.length > 0) {
|
||||
var domainURL = Settings.METAVERSE_URL + "/api/v1/domains/" + domainID;
|
||||
|
||||
$.getJSON(domainURL, callback).fail(callback);
|
||||
}
|
||||
}
|
||||
|
||||
function getDomainFromAPI(callback) {
|
||||
var domainID = Settings.data.values.metaverse.id;
|
||||
$.ajax({
|
||||
|
@ -1093,22 +1049,6 @@ function showDomainSettingsModal(clickedButton) {
|
|||
})
|
||||
}
|
||||
|
||||
function sendCreateDomainRequest(onSuccess, onError) {
|
||||
$.ajax({
|
||||
url: '/api/domains',
|
||||
type: 'POST',
|
||||
data: { label: "" },
|
||||
success: function(data) {
|
||||
//if (data.status === 'success') {
|
||||
onSuccess(data.domain_id);
|
||||
//} else {
|
||||
//onError();
|
||||
//}
|
||||
},
|
||||
error: onError
|
||||
});
|
||||
}
|
||||
|
||||
function editHighFidelityPlace(placeID, name, path) {
|
||||
var dialog;
|
||||
|
||||
|
@ -1237,7 +1177,7 @@ function chooseFromHighFidelityDomains(clickedButton) {
|
|||
modal_buttons["success"] = {
|
||||
label: 'Create new domain',
|
||||
callback: function() {
|
||||
window.open(Settings.METAVERSE_URL + "/user/domains", '_blank');
|
||||
window.open(URLs.METAVERSE_URL + "/user/domains", '_blank');
|
||||
}
|
||||
}
|
||||
modal_body = "<p>You do not have any domains in your High Fidelity account." +
|
||||
|
@ -1284,7 +1224,7 @@ function createTemporaryDomain() {
|
|||
showSpinnerAlert('Creating temporary place name');
|
||||
|
||||
// make a get request to get a temporary domain
|
||||
$.post(Settings.METAVERSE_URL + '/api/v1/domains/temporary', function(data){
|
||||
$.post(URLs.METAVERSE_URL + '/api/v1/domains/temporary', function(data){
|
||||
if (data.status == "success") {
|
||||
var domain = data.data.domain;
|
||||
|
||||
|
@ -1311,24 +1251,6 @@ function createTemporaryDomain() {
|
|||
});
|
||||
}
|
||||
|
||||
function waitForDomainServerBackUp(callback) {
|
||||
function checkForDomainUp() {
|
||||
$.ajax('', {
|
||||
success: function() {
|
||||
console.log("Domain is back up");
|
||||
callback();
|
||||
},
|
||||
error: function() {
|
||||
setTimeout(checkForDomainUp, 50);
|
||||
console.log("Fail");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(checkForDomainUp, 10);
|
||||
|
||||
}
|
||||
|
||||
function reloadSettings(callback) {
|
||||
$.getJSON('/settings.json', function(data){
|
||||
_.extend(data, viewHelpers)
|
||||
|
@ -1354,6 +1276,26 @@ function reloadSettings(callback) {
|
|||
if (Settings.data.values.metaverse.id.length > 0) {
|
||||
// now, ask the API for what places, if any, point to this domain
|
||||
reloadDomainInfo();
|
||||
|
||||
// we need to ask the API what a shareable name for this domain is
|
||||
getShareName(function(success, shareName) {
|
||||
if (success) {
|
||||
var shareLink = "https://hifi.place/" + shareName;
|
||||
$('#visit-domain-link').attr("href", shareLink).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Settings.data.values.wizard.cloud_domain) {
|
||||
$('#manage-cloud-domains-link').show();
|
||||
|
||||
var cloudWizardExit = qs["cloud-wizard-exit"];
|
||||
if (cloudWizardExit != undefined) {
|
||||
$('#cloud-domains-alert').show();
|
||||
$('#cloud-domains-alert .glyphicon').on('click', function() {
|
||||
$('#cloud-domains-alert').remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// setup any bootstrap switches
|
||||
|
|
89
domain-server/resources/web/wizard/css/style.css
Normal file
89
domain-server/resources/web/wizard/css/style.css
Normal file
|
@ -0,0 +1,89 @@
|
|||
label {
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
line-height: 24px;
|
||||
font-size: 16px;
|
||||
|
||||
color: #373A3C;
|
||||
}
|
||||
|
||||
.step-title {
|
||||
margin-bottom: 20px;
|
||||
line-height: 26px;
|
||||
font-size: 24px;
|
||||
|
||||
color: #373A3C;
|
||||
}
|
||||
|
||||
.step-description {
|
||||
line-height: 24px;
|
||||
font-size: 16px;
|
||||
|
||||
color: #818A91;
|
||||
}
|
||||
|
||||
.step-info {
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
line-height: 24px;
|
||||
font-size: 16px;
|
||||
|
||||
color: #373A3C;
|
||||
}
|
||||
|
||||
#admin-row {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#connect-question {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#connect-account-btn {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 205px;
|
||||
}
|
||||
|
||||
#place-name-group {
|
||||
margin-top: 42px;
|
||||
margin-bottom: 140px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#place-name-link {
|
||||
line-height: 38px;
|
||||
font-size: 32px;
|
||||
|
||||
display: inline-block;
|
||||
|
||||
color: #373A3C;
|
||||
}
|
||||
|
||||
#place-name-edit {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#change-place-name {
|
||||
line-height: 24px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
#rez-options-row {
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
#verify-password-row {
|
||||
margin-bottom: 33px;
|
||||
}
|
||||
|
||||
#checkmark-image {
|
||||
margin-top: 66px;
|
||||
margin-bottom: 59px;
|
||||
width: 169px;
|
||||
height: 169px;
|
||||
}
|
||||
|
||||
#visit-domain-row {
|
||||
margin-bottom: 68px;
|
||||
}
|
30
domain-server/resources/web/wizard/header.html
Normal file
30
domain-server/resources/web/wizard/header.html
Normal file
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>domain-server</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||
<link href="/stats/css/json.human.css" rel="stylesheet" media="screen">
|
||||
<link href="/css/style.css" rel="stylesheet" media="screen">
|
||||
<link href="/wizard/css/style.css" rel="stylesheet" media="screen">
|
||||
<link href="/css/sweetalert.css" rel="stylesheet" media="screen">
|
||||
<link href="/css/bootstrap-switch.min.css" rel="stylesheet" media="screen">
|
||||
|
||||
<script src='/js/sweetalert.min.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<a class="navbar-brand step-info" href="#">Setup Wizard (Domain Server Settings)</a>
|
||||
|
||||
<div class="navbar-form navbar-right">
|
||||
<button id="skip-wizard-button" type="button" class="btn btn-default" style="display:none;">Skip Wizard</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.container-fluid -->
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
229
domain-server/resources/web/wizard/index.shtml
Normal file
229
domain-server/resources/web/wizard/index.shtml
Normal file
|
@ -0,0 +1,229 @@
|
|||
<!--#include virtual="wizard/header.html"-->
|
||||
<div class="wizard-step desktop-only col-md-6 col-centered" style="display: none;">
|
||||
<h4 class="step-title"></h4>
|
||||
<dl class="row">
|
||||
<dd class="col-md-12">
|
||||
<span class='step-description'>By connecting you High Fidelity Account you will be granting access to your account information.</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dd class="col-md-12">
|
||||
<a id="connect-account-btn" role="button" class="btn btn-primary btn-md btn-block" href="https://staging.highfidelity.com/user/tokens/new?for_domain_server=true" target="_blank">Connect your High Fidelity account</a>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<dl class="row">
|
||||
<dd class="col-md-3">
|
||||
<button type="button" class="btn btn-md btn-block btn-default next-button">Skip</button>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step col-md-8 col-centered" style="display: none;">
|
||||
<h4 class="step-title"></h4>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<span class='step-description'>
|
||||
<a target='_blank' href='https://docs.highfidelity.com/create-and-explore/start-working-in-your-sandbox/place-names'>Place names</a> are similar to web addresses. Users who want to visit your domain can
|
||||
enter its Place Name in High Fidelity's Interface. You can choose a Place Name for your domain.</br>
|
||||
People can also use your <b>domain's IP address (shown below)</b> to visit your High Fidelity domain.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="centered-hack-parent">
|
||||
<div id="place-name-group" class="centered-hack">
|
||||
<p id="place-name-link"></p>
|
||||
<div id="place-name-edit">
|
||||
<span class='glyphicon glyphicon-pencil'></span>
|
||||
<a href="javascript:void(0);" id="change-place-name">Choose a custom Place Name instead</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dl class="row">
|
||||
<dd class="col-md-3">
|
||||
<button type="button" class="btn btn-md btn-block btn-default back-button">Back</button>
|
||||
</dd>
|
||||
<dd class="col-md-3 col-md-offset-6">
|
||||
<button type="button" class="btn btn-md btn-block btn-primary next-button">Next</button>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step col-md-9 col-centered" style="display: none;">
|
||||
<h4 class="step-title"></h4>
|
||||
<div class="row">
|
||||
<p id="permissions-description" class="col-md-12 step-info"><b>Localhost</b> has been granted administrator privileges to this domain. (Localhost is any</br>user on the same machine as the High Fidelity Server)</p>
|
||||
</div>
|
||||
<div id="admin-row" class="row">
|
||||
<p class="col-md-6">
|
||||
<span id="admin-description" class="step-info"><b>Add your High Fidelity username</b> and any other usernames to grant administrator privileges.</span>
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle="tooltip" title="Users who will have all the permissions for this domain."></span>
|
||||
</p>
|
||||
<div class="col-md-6">
|
||||
<input id="admin-usernames" type="text" class="form-control">
|
||||
<span class="help-block text-right">separate by commas (user1, user2,..)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<span class="step-description">Grant basic permissions to other users. You can change these later.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p id="connect-question" class="step-info">
|
||||
Who can connect to your domain?
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='You can set this to allow a user to connect to this domain.'></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<p class="col-md-2">
|
||||
<label>
|
||||
<input id="connect-none" name="connect-radio" type="radio" value="none" checked> None
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='Only the admins of this domain'></span>
|
||||
</label>
|
||||
</p>
|
||||
<p class="col-md-3">
|
||||
<label>
|
||||
<input id="connect-friends" name="connect-radio" type="radio" value="friends"> Friends
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='Users who are your Friends in High Fidelity'></span>
|
||||
</label>
|
||||
</p>
|
||||
<p class="col-md-5">
|
||||
<label>
|
||||
<input id="connect-logged-in" name="connect-radio" type="radio" value="logged-in"> Users logged in to High Fidelity
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='Users who are currently logged into High Fidelity'></span>
|
||||
</label>
|
||||
</p>
|
||||
<p class="col-md-2">
|
||||
<label>
|
||||
<input id="connect-everyone" name="connect-radio" type="radio" value="everyone"> Everyone
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title="Users who aren't logged into High Fidelity"></span>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="step-info">
|
||||
Who can rez items in your domain?
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='You can set this to allow a user to create entities in this domain.'></span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="rez-options-row" class="row">
|
||||
<p class="col-md-2">
|
||||
<label>
|
||||
<input id="rez-none" name="rez-radio" type="radio" value="none" checked> None
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='Only the admins of this domain'></span>
|
||||
</label>
|
||||
</p>
|
||||
<p class="col-md-3">
|
||||
<label>
|
||||
<input id="rez-friends" name="rez-radio" type="radio" value="friends"> Friends
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='Users who are your Friends in High Fidelity'></span>
|
||||
</label>
|
||||
</p>
|
||||
<p class="col-md-5">
|
||||
<label>
|
||||
<input id="rez-logged-in" name="rez-radio" type="radio" value="logged-in"> Users logged in to High Fidelity
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title='Users who are currently logged into High Fidelity'></span>
|
||||
</label>
|
||||
</p>
|
||||
<p class="col-md-2">
|
||||
<label>
|
||||
<input id="rez-everyone" name="rez-radio" type="radio" value="everyone"> Everyone
|
||||
<span class='glyphicon glyphicon-info-sign' data-toggle='tooltip' title="Users who aren't logged into High Fidelity"></span>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3 col-md-offset-9">
|
||||
<button id="save-permissions" type="button" class="btn btn-md btn-block btn-primary">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step cloud-only col-md-7 col-centered" style="display: none;">
|
||||
<h4 class="step-title"></h4>
|
||||
<dl class="row">
|
||||
<dd class="col-md-12">
|
||||
<span class='step-description'>
|
||||
Your server settings are currently accessible without a username and password.
|
||||
Adding credentials will ensure that only authorized users have access to modify the settings.
|
||||
</span>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<div class="row">
|
||||
<p class="col-md-12 step-info">Create a username and password to secure the access to your domain server settings.</p>
|
||||
</div>
|
||||
<dl class="row">
|
||||
<dt class="col-md-4 step-info">Username</dt>
|
||||
<dd class="col-md-8">
|
||||
<input id="http_username" type="text" class="form-control">
|
||||
<span class='help-block'>This does not have to be your High Fidelity username</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="row">
|
||||
<dt class="col-md-4 step-info">Enter password</dt>
|
||||
<dd class="col-md-8">
|
||||
<input id="http_password" type="password" class="form-control">
|
||||
<span class='help-block'>This should not be the same as your High Fidelity password</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl id="verify-password-row" class="row">
|
||||
<dt class="col-md-4 step-info">Re-enter password</dt>
|
||||
<dd class="col-md-8">
|
||||
<input id="verify_http_password" type="password" class="form-control">
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<dl class="row">
|
||||
<dd class="col-md-3 col-md-offset-9">
|
||||
<button id="save-username-password" type="button" class="btn btn-md btn-block btn-primary">Finish</button>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="wizard-step cloud-only col-md-7 col-centered" style="display: none;">
|
||||
<div class="row">
|
||||
<div class="col-xs-4 col-centered">
|
||||
<img id="checkmark-image" src="../images/checkmark.svg">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<p class="step-info">Congratulations! You have successfully setup and configured your cloud hosted domain.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="visit-domain-row" class="row">
|
||||
<div class="col-md-12">
|
||||
<label><input id="go-to-domain" class="form-check-input" type="checkbox"> Visit domain in VR now</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dl class="row">
|
||||
<dd class="col-md-5 col-md-offset-7">
|
||||
<button id="explore-settings" type="button" class="btn btn-md btn-block btn-primary">Explore all domain server settings</button>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<!--#include virtual="footer.html"-->
|
||||
<script src='/js/underscore-min.js'></script>
|
||||
<script src='/js/bootbox.min.js'></script>
|
||||
<script src='/js/sha256.js'></script>
|
||||
<script src='/js/shared.js'></script>
|
||||
<script src='js/wizard.js'></script>
|
||||
<!--#include virtual="page-end.html"-->
|
468
domain-server/resources/web/wizard/js/wizard.js
Normal file
468
domain-server/resources/web/wizard/js/wizard.js
Normal file
|
@ -0,0 +1,468 @@
|
|||
var Metaverse = {
|
||||
accessToken: null
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
Strings.ADD_PLACE_NOT_CONNECTED_MESSAGE = "You must have an access token to query your High Fidelity places.<br><br>" +
|
||||
"Please go back and connect your account.";
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
$('body').on('click', '.next-button', function() {
|
||||
goToNextStep();
|
||||
});
|
||||
|
||||
$('body').on('click', '.back-button', function() {
|
||||
goToPreviousStep();
|
||||
});
|
||||
|
||||
$('body').on('click', '#skip-wizard-button', function() {
|
||||
skipWizard();
|
||||
})
|
||||
|
||||
$('body').on('click', '#connect-account-btn', function() {
|
||||
$(this).blur();
|
||||
prepareAccessTokenPrompt(function(accessToken) {
|
||||
Metaverse.accessToken = accessToken;
|
||||
saveAccessToken();
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('click', '#save-permissions', function() {
|
||||
savePermissions();
|
||||
});
|
||||
|
||||
function triggerSaveUsernamePassword(event) {
|
||||
if (event.keyCode === 13) {
|
||||
$("#save-username-password").click();
|
||||
}
|
||||
}
|
||||
$("#http_username").keyup(triggerSaveUsernamePassword);
|
||||
$("#http_password").keyup(triggerSaveUsernamePassword);
|
||||
$("#verify_http_password").keyup(triggerSaveUsernamePassword);
|
||||
$('body').on('click', '#save-username-password', function() {
|
||||
saveUsernamePassword();
|
||||
});
|
||||
|
||||
$('body').on('click', '#change-place-name', function() {
|
||||
chooseFromHighFidelityPlaces(Settings.data.values.metaverse.access_token, "/0,-10,0", function(placeName) {
|
||||
updatePlaceNameLink(placeName);
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('click', '#explore-settings', function() {
|
||||
console.log('explore-settings')
|
||||
exploreSettings();
|
||||
});
|
||||
|
||||
reloadSettings(function(success) {
|
||||
if (success) {
|
||||
setupWizardSteps();
|
||||
updatePlaceNameDisplay();
|
||||
updateUsernameDisplay();
|
||||
} else {
|
||||
swal({
|
||||
title: '',
|
||||
type: 'error',
|
||||
text: "There was a problem loading the domain settings.\nPlease refresh the page to try again.",
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function setupWizardSteps() {
|
||||
var stepsCompleted = Settings.data.values.wizard.steps_completed;
|
||||
var steps = null;
|
||||
|
||||
if (Settings.data.values.wizard.cloud_domain) {
|
||||
$('.desktop-only').remove();
|
||||
$('.wizard-step').find('.back-button').hide();
|
||||
|
||||
steps = $('.wizard-step');
|
||||
$(steps).each(function(i) {
|
||||
$(this).children(".step-title").text("Step " + (i + 1) + " of " + (steps.length - 1));
|
||||
});
|
||||
|
||||
$('#permissions-description').html('You <span id="username-display"></span>have been assigned administrator privileges to this domain.');
|
||||
$('#admin-description').html('Add more High Fidelity usernames to grant administrator privileges.');
|
||||
} else {
|
||||
$('.cloud-only').remove();
|
||||
$('#save-permissions').text("Finish");
|
||||
|
||||
steps = $('.wizard-step');
|
||||
$(steps).each(function(i) {
|
||||
$(this).children(".step-title").text("Step " + (i + 1) + " of " + steps.length);
|
||||
});
|
||||
|
||||
if (stepsCompleted == 0) {
|
||||
$('#skip-wizard-button').show();
|
||||
}
|
||||
}
|
||||
|
||||
var currentStep = steps[stepsCompleted];
|
||||
$(currentStep).show();
|
||||
}
|
||||
|
||||
function updatePlaceNameLink(address) {
|
||||
if (address) {
|
||||
$('#place-name-link').html('Your domain is reachable at: <a target="_blank" href="' + URLs.PLACE_URL + '/' + address + '">' + address + '</a>');
|
||||
}
|
||||
}
|
||||
|
||||
function updatePlaceNameDisplay() {
|
||||
if (Settings.data.values.metaverse.id) {
|
||||
$.getJSON(URLs.METAVERSE_URL + '/api/v1/domains/' + Settings.data.values.metaverse.id, function(data) {
|
||||
|
||||
if (data.status === 'success') {
|
||||
if (data.domain.default_place_name) {
|
||||
// Place name
|
||||
updatePlaceNameLink(data.domain.default_place_name);
|
||||
} else if (data.domain.name) {
|
||||
// Temporary name
|
||||
updatePlaceNameLink(data.domain.name);
|
||||
} else if (data.domain.network_address) {
|
||||
if (data.domain.network_port !== 40102) {
|
||||
// IP:PORT
|
||||
updatePlaceNameLink(data.domain.network_address + ':' + data.domain.network_port);
|
||||
} else {
|
||||
// IP
|
||||
updatePlaceNameLink(data.domain.network_address);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.warn('Request Failed');
|
||||
}
|
||||
}).fail(function() {
|
||||
console.warn('Request Failed');
|
||||
});
|
||||
} else {
|
||||
console.warn('No metaverse domain ID!');
|
||||
}
|
||||
}
|
||||
|
||||
function updateUsernameDisplay() {
|
||||
var permissions = Settings.data.values.security.permissions;
|
||||
if (permissions.length > 0) {
|
||||
$('#username-display').html('<b>(' + permissions[0].permissions_id + ')</b> ');
|
||||
}
|
||||
}
|
||||
|
||||
function reloadSettings(callback) {
|
||||
$.getJSON('/settings.json', function(data){
|
||||
Settings.data = data;
|
||||
|
||||
if (callback) {
|
||||
// call the callback now that settings are loaded
|
||||
callback(true);
|
||||
}
|
||||
}).fail(function() {
|
||||
if (callback) {
|
||||
// call the failure object since settings load failed
|
||||
callback(false)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function postSettings(jsonSettings, callback) {
|
||||
console.log("----- SAVING ------");
|
||||
console.log(JSON.stringify(jsonSettings));
|
||||
|
||||
// POST the form JSON to the domain-server settings.json endpoint so the settings are saved
|
||||
$.ajax('/settings.json', {
|
||||
data: JSON.stringify(jsonSettings),
|
||||
contentType: 'application/json',
|
||||
type: 'POST'
|
||||
}).done(function(data){
|
||||
if (data.status == "success") {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
reloadSettings();
|
||||
} else {
|
||||
swal("Error", Strings.LOADING_SETTINGS_ERROR)
|
||||
reloadSettings();
|
||||
}
|
||||
}).fail(function(){
|
||||
swal("Error", Strings.LOADING_SETTINGS_ERROR)
|
||||
reloadSettings();
|
||||
});
|
||||
}
|
||||
|
||||
function goToNextStep() {
|
||||
$('#skip-wizard-button').hide();
|
||||
|
||||
var currentStep = $('body').find('.wizard-step:visible');
|
||||
var nextStep = currentStep.next('.wizard-step');
|
||||
|
||||
var formJSON = {
|
||||
"wizard": {}
|
||||
}
|
||||
|
||||
if (nextStep.length > 0) {
|
||||
currentStep.hide();
|
||||
nextStep.show();
|
||||
|
||||
var currentStepNumber = parseInt(Settings.data.values.wizard.steps_completed) + 1;
|
||||
|
||||
postSettings({
|
||||
"wizard": {
|
||||
"steps_completed": currentStepNumber.toString()
|
||||
}
|
||||
});
|
||||
} else {
|
||||
postSettings({
|
||||
"wizard": {
|
||||
"steps_completed": "0",
|
||||
"completed_once": true
|
||||
}
|
||||
}, redirectToSettings);
|
||||
}
|
||||
}
|
||||
|
||||
function goToPreviousStep() {
|
||||
var currentStep = $('body').find('.wizard-step:visible');
|
||||
var previousStep = currentStep.prev('.wizard-step');
|
||||
|
||||
var formJSON = {
|
||||
"wizard": {}
|
||||
}
|
||||
|
||||
if (previousStep.length > 0) {
|
||||
currentStep.hide();
|
||||
previousStep.show();
|
||||
|
||||
var currentStepNumber = parseInt(Settings.data.values.wizard.steps_completed) - 1;
|
||||
|
||||
postSettings({
|
||||
"wizard": {
|
||||
"steps_completed": currentStepNumber.toString()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function skipWizard() {
|
||||
postSettings({
|
||||
"wizard": {
|
||||
"steps_completed": "0",
|
||||
"completed_once": true
|
||||
}
|
||||
}, redirectToSettings);
|
||||
}
|
||||
|
||||
function redirectToSettings() {
|
||||
var redirectURL = "/settings" + location.search;
|
||||
if (Settings.data.values.wizard.cloud_domain) {
|
||||
if (location.search.length > 0) {
|
||||
redirectURL += "&";
|
||||
} else {
|
||||
redirectURL += "?";
|
||||
}
|
||||
redirectURL += "cloud-wizard-exit";
|
||||
}
|
||||
location.href = redirectURL;
|
||||
}
|
||||
|
||||
function saveAccessToken() {
|
||||
var formJSON = {
|
||||
"metaverse": {}
|
||||
}
|
||||
if (Metaverse.accessToken) {
|
||||
formJSON.metaverse.access_token = Metaverse.accessToken;
|
||||
}
|
||||
|
||||
// remove focus from the button
|
||||
$(this).blur();
|
||||
|
||||
// POST the form JSON to the domain-server settings.json endpoint so the settings are saved
|
||||
postSettings(formJSON, goToNextStep);
|
||||
}
|
||||
|
||||
function getSettingDescriptionForKey(groupKey, settingKey) {
|
||||
for (var i in Settings.data.descriptions) {
|
||||
var group = Settings.data.descriptions[i];
|
||||
if (group.name === groupKey) {
|
||||
for (var j in group.settings) {
|
||||
var setting = group.settings[j];
|
||||
if (setting.name === settingKey) {
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function savePermissions() {
|
||||
var localhostPermissions = (Settings.data.values.wizard.cloud_domain !== true)
|
||||
var anonymousCanConnect = false;
|
||||
var friendsCanConnect = false;
|
||||
var loggedInCanConnect = false;
|
||||
var anonymousCanRez = false;
|
||||
var friendsCanRez = false;
|
||||
var loggedInCanRez = false;
|
||||
|
||||
var connectValue = $('input[name=connect-radio]:checked').val();
|
||||
var rezValue = $('input[name=rez-radio]:checked').val();
|
||||
|
||||
switch (connectValue) {
|
||||
case "friends":
|
||||
friendsCanConnect = true;
|
||||
break;
|
||||
case "logged-in":
|
||||
friendsCanConnect = true;
|
||||
loggedInCanConnect = true;
|
||||
break;
|
||||
case "everyone":
|
||||
anonymousCanConnect = true;
|
||||
friendsCanConnect = true;
|
||||
loggedInCanConnect = true;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (rezValue) {
|
||||
case "friends":
|
||||
friendsCanRez = true;
|
||||
break;
|
||||
case "logged-in":
|
||||
friendsCanRez = true;
|
||||
loggedInCanRez = true;
|
||||
break;
|
||||
case "everyone":
|
||||
anonymousCanRez = true;
|
||||
friendsCanRez = true;
|
||||
loggedInCanRez = true;
|
||||
break;
|
||||
}
|
||||
|
||||
var admins = $('#admin-usernames').val().split(',');
|
||||
|
||||
var existingAdmins = Settings.data.values.security.permissions.map(function(value) {
|
||||
return value.permissions_id;
|
||||
});
|
||||
admins = admins.concat(existingAdmins);
|
||||
|
||||
// Filter out unique values
|
||||
admins = _.uniq(admins.map(function(username) {
|
||||
return username.trim();
|
||||
})).filter(function(username) {
|
||||
return username !== "";
|
||||
});
|
||||
|
||||
var formJSON = {
|
||||
"security": {
|
||||
"standard_permissions": [
|
||||
{
|
||||
"id_can_connect": anonymousCanConnect,
|
||||
"id_can_rez": anonymousCanRez,
|
||||
"id_can_rez_certified": anonymousCanRez,
|
||||
"id_can_rez_tmp": anonymousCanRez,
|
||||
"id_can_rez_tmp_certified": anonymousCanRez,
|
||||
"permissions_id": "anonymous"
|
||||
},
|
||||
{
|
||||
"id_can_connect": friendsCanConnect,
|
||||
"id_can_rez": friendsCanRez,
|
||||
"id_can_rez_certified": friendsCanRez,
|
||||
"id_can_rez_tmp": friendsCanRez,
|
||||
"id_can_rez_tmp_certified": friendsCanRez,
|
||||
"permissions_id": "friends"
|
||||
},
|
||||
{
|
||||
"id_can_connect": loggedInCanConnect,
|
||||
"id_can_rez": loggedInCanRez,
|
||||
"id_can_rez_certified": loggedInCanRez,
|
||||
"id_can_rez_tmp": loggedInCanRez,
|
||||
"id_can_rez_tmp_certified": loggedInCanRez,
|
||||
"permissions_id": "logged-in"
|
||||
},
|
||||
{
|
||||
"id_can_adjust_locks": localhostPermissions,
|
||||
"id_can_connect": localhostPermissions,
|
||||
"id_can_connect_past_max_capacity": localhostPermissions,
|
||||
"id_can_kick": localhostPermissions,
|
||||
"id_can_replace_content": localhostPermissions,
|
||||
"id_can_rez": localhostPermissions,
|
||||
"id_can_rez_tmp": localhostPermissions,
|
||||
"id_can_write_to_asset_server": localhostPermissions,
|
||||
"permissions_id": "localhost"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (admins.length > 0) {
|
||||
formJSON.security.permissions = [];
|
||||
|
||||
var permissionsDesc = getSettingDescriptionForKey("security", "permissions");
|
||||
for (var i in admins) {
|
||||
var admin = admins[i];
|
||||
var perms = {};
|
||||
for (var i in permissionsDesc.columns) {
|
||||
var name = permissionsDesc.columns[i].name;
|
||||
if (name === "permissions_id") {
|
||||
perms[name] = admin;
|
||||
} else {
|
||||
perms[name] = true;
|
||||
}
|
||||
}
|
||||
formJSON.security.permissions.push(perms);
|
||||
}
|
||||
}
|
||||
|
||||
// remove focus from the button
|
||||
$(this).blur();
|
||||
|
||||
postSettings(formJSON, goToNextStep);
|
||||
}
|
||||
|
||||
function saveUsernamePassword() {
|
||||
var username = $("#http_username").val();
|
||||
var password = $("#http_password").val();
|
||||
var verify_password = $("#verify_http_password").val();
|
||||
|
||||
if (username.length == 0) {
|
||||
bootbox.alert({ "message": "You must set a username!", "title": "Username Error" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length == 0) {
|
||||
bootbox.alert({ "message": "You must set a password!", "title": "Password Error" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (password != verify_password) {
|
||||
bootbox.alert({ "message": "Passwords must match!", "title": "Password Error" });
|
||||
return;
|
||||
}
|
||||
|
||||
var currentStepNumber = parseInt(Settings.data.values.wizard.steps_completed) + 1;
|
||||
|
||||
var formJSON = {
|
||||
"security": {
|
||||
"http_username": username,
|
||||
"http_password": sha256_digest(password)
|
||||
},
|
||||
"wizard": {
|
||||
"steps_completed": currentStepNumber.toString()
|
||||
}
|
||||
}
|
||||
|
||||
// remove focus from the button
|
||||
$(this).blur();
|
||||
|
||||
// POST the form JSON to the domain-server settings.json endpoint so the settings are saved
|
||||
postSettings(formJSON, function() {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function exploreSettings() {
|
||||
if ($('#go-to-domain').is(":checked")) {
|
||||
var link = $('#place-name-link a:first');
|
||||
if (link.length > 0) {
|
||||
window.open(link.attr("href"));
|
||||
}
|
||||
}
|
||||
|
||||
goToNextStep();
|
||||
}
|
|
@ -1760,11 +1760,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
|
||||
// allow sub-handlers to handle requests that do not require authentication
|
||||
if (_settingsManager.handlePublicHTTPRequest(connection, url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if this is a request for a scripted assignment (with a temp unique UUID)
|
||||
const QString ASSIGNMENT_REGEX_STRING = QString("\\%1\\/(%2)\\/?$").arg(URI_ASSIGNMENT).arg(UUID_REGEX_STRING);
|
||||
QRegExp assignmentRegex(ASSIGNMENT_REGEX_STRING);
|
||||
|
@ -1825,6 +1820,31 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
return true;
|
||||
}
|
||||
|
||||
// Check if we should redirect/prevent access to the wizard
|
||||
if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
|
||||
const QString URI_WIZARD = "/wizard/";
|
||||
const QString WIZARD_COMPLETED_ONCE_KEY_PATH = "wizard.completed_once";
|
||||
const QVariant* wizardCompletedOnce = valueForKeyPath(_settingsManager.getSettingsMap(), WIZARD_COMPLETED_ONCE_KEY_PATH);
|
||||
const bool completedOnce = wizardCompletedOnce && wizardCompletedOnce->toBool();
|
||||
|
||||
if (url.path() != URI_WIZARD && url.path().endsWith('/') && !completedOnce) {
|
||||
// First visit, redirect to the wizard
|
||||
QUrl redirectedURL = url;
|
||||
redirectedURL.setPath(URI_WIZARD);
|
||||
|
||||
Headers redirectHeaders;
|
||||
redirectHeaders.insert("Location", redirectedURL.toEncoded());
|
||||
|
||||
connection->respond(HTTPConnection::StatusCode302,
|
||||
QByteArray(), HTTPConnection::DefaultContentType, redirectHeaders);
|
||||
return true;
|
||||
} else if (url.path() == URI_WIZARD && completedOnce) {
|
||||
// Wizard already completed, return 404
|
||||
connection->respond(HTTPConnection::StatusCode404, "Resource not found.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (connection->requestOperation() == QNetworkAccessManager::GetOperation) {
|
||||
if (url.path() == "/assignments.json") {
|
||||
// user is asking for json list of assignments
|
||||
|
@ -1937,7 +1957,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
return;
|
||||
}
|
||||
|
||||
static const char* CONTENT_TYPE_JSON { "application/json" };
|
||||
connection->respond(HTTPConnection::StatusCode200, reply->readAll());
|
||||
});
|
||||
return true;
|
||||
|
@ -1964,7 +1983,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
return;
|
||||
}
|
||||
|
||||
static const char* CONTENT_TYPE_JSON { "application/json" };
|
||||
connection->respond(HTTPConnection::StatusCode200, reply->readAll());
|
||||
});
|
||||
return true;
|
||||
|
@ -1989,7 +2007,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
return;
|
||||
}
|
||||
|
||||
static const char* CONTENT_TYPE_JSON { "application/json" };
|
||||
connection->respond(HTTPConnection::StatusCode200, reply->readAll());
|
||||
});
|
||||
return true;
|
||||
|
@ -2073,8 +2090,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
// this is an entity file upload, ask the HTTPConnection to parse the data
|
||||
QList<FormData> formData = connection->parseFormData();
|
||||
|
||||
Headers redirectHeaders;
|
||||
|
||||
if (formData.size() > 0 && formData[0].second.size() > 0) {
|
||||
// invoke our method to hand the new octree file off to the octree server
|
||||
QMetaObject::invokeMethod(this, "handleOctreeFileReplacement",
|
||||
|
@ -2219,7 +2234,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
return;
|
||||
}
|
||||
|
||||
static const char* CONTENT_TYPE_JSON { "application/json" };
|
||||
connection->respond(HTTPConnection::StatusCode200, reply->readAll());
|
||||
});
|
||||
return true;
|
||||
|
@ -2284,7 +2298,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
|||
return;
|
||||
}
|
||||
|
||||
static const char* CONTENT_TYPE_JSON { "application/json" };
|
||||
connection->respond(HTTPConnection::StatusCode200, reply->readAll());
|
||||
});
|
||||
return true;
|
||||
|
|
|
@ -960,29 +960,6 @@ QVariant DomainServerSettingsManager::valueOrDefaultValueForKeyPath(const QStrin
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
bool DomainServerSettingsManager::handlePublicHTTPRequest(HTTPConnection* connection, const QUrl &url) {
|
||||
if (connection->requestOperation() == QNetworkAccessManager::GetOperation && url.path() == SETTINGS_PATH_JSON) {
|
||||
// this is a GET operation for our settings
|
||||
|
||||
// check if there is a query parameter for settings affecting a particular type of assignment
|
||||
const QString SETTINGS_TYPE_QUERY_KEY = "type";
|
||||
QUrlQuery settingsQuery(url);
|
||||
QString typeValue = settingsQuery.queryItemValue(SETTINGS_TYPE_QUERY_KEY);
|
||||
|
||||
if (!typeValue.isEmpty()) {
|
||||
QJsonObject responseObject = responseObjectForType(typeValue);
|
||||
|
||||
connection->respond(HTTPConnection::StatusCode200, QJsonDocument(responseObject).toJson(), "application/json");
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -1214,6 +1191,7 @@ bool DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJ
|
|||
static const QString SECURITY_ROOT_KEY = "security";
|
||||
static const QString AC_SUBNET_WHITELIST_KEY = "ac_subnet_whitelist";
|
||||
static const QString BROADCASTING_KEY = "broadcasting";
|
||||
static const QString WIZARD_KEY = "wizard";
|
||||
static const QString DESCRIPTION_ROOT_KEY = "descriptors";
|
||||
|
||||
auto& settingsVariant = _configMap.getConfig();
|
||||
|
@ -1266,7 +1244,8 @@ 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 ) {
|
||||
if (rootKey != SECURITY_ROOT_KEY && rootKey != BROADCASTING_KEY &&
|
||||
rootKey != SETTINGS_PATHS_KEY && rootKey != WIZARD_KEY) {
|
||||
needRestart = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -1282,8 +1261,9 @@ 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)
|
||||
|| settingKey == AC_SUBNET_WHITELIST_KEY) {
|
||||
if ((rootKey != SECURITY_ROOT_KEY && rootKey != BROADCASTING_KEY &&
|
||||
rootKey != DESCRIPTION_ROOT_KEY && rootKey != WIZARD_KEY) ||
|
||||
settingKey == AC_SUBNET_WHITELIST_KEY) {
|
||||
needRestart = true;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -43,7 +43,6 @@ class DomainServerSettingsManager : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DomainServerSettingsManager();
|
||||
bool handlePublicHTTPRequest(HTTPConnection* connection, const QUrl& url);
|
||||
bool handleAuthenticatedHTTPRequest(HTTPConnection* connection, const QUrl& url);
|
||||
|
||||
void setupConfigMap(const QStringList& argumentList);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <QtCore/QUrl>
|
||||
|
||||
namespace NetworkingConstants {
|
||||
const QUrl METAVERSE_SERVER_URL = QUrl("https://staging.highfidelity.com");
|
||||
const QUrl METAVERSE_SERVER_URL = QUrl("https://metaverse.highfidelity.com");
|
||||
}
|
||||
|
||||
#endif // hifi_NetworkingConstants_h
|
||||
|
|
Loading…
Reference in a new issue