Merge pull request #846 from kasenvr/fix/domain-server-create-id

Fix domain-server settings "Create new domain ID" dialog.
This commit is contained in:
kasenvr 2020-11-06 20:07:37 -05:00 committed by GitHub
commit 66ccfab9c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -365,7 +365,7 @@ $(document).ready(function(){
confirmButtonText: "Create", confirmButtonText: "Create",
closeOnConfirm: false, closeOnConfirm: false,
html: true html: true
}, function(inputValue){ }, function (inputValue) {
if (inputValue === false) { if (inputValue === false) {
swal.close(); swal.close();
@ -375,7 +375,7 @@ $(document).ready(function(){
} }
} else { } else {
// we're going to change the alert to a new one with a spinner while we create this domain // we're going to change the alert to a new one with a spinner while we create this domain
showSpinnerAlert('Creating domain ID'); // showSpinnerAlert('Creating domain ID');
createNewDomainID(inputValue, justConnected); createNewDomainID(inputValue, justConnected);
} }
}); });
@ -387,7 +387,12 @@ $(document).ready(function(){
"label": label "label": label
} }
$.post("/api/domains", domainJSON, function(data){ $.post("/api/domains", domainJSON, function(data) {
if (data.status === "failure") {
failedToCreateDomainID(data, justConnected);
return;
}
// we successfully created a domain ID, set it on that field // we successfully created a domain ID, set it on that field
var domainID = data.domain.domainId; var domainID = data.domain.domainId;
console.log("Setting domain id to ", data, domainID); console.log("Setting domain id to ", data, domainID);
@ -408,40 +413,50 @@ $(document).ready(function(){
text: successText, text: successText,
html: true, html: true,
confirmButtonText: 'Save' confirmButtonText: 'Save'
}, function(){ }, function () {
saveSettings(); saveSettings();
}); });
}, 'json').fail(function(){ }, 'json').fail(function (data) {
failedToCreateDomainID(data, justConnected);
});
}
function failedToCreateDomainID(data, justConnected) {
var errorText = "There was a problem creating your new domain ID. Do you want to try again or";
var errorText = "There was a problem creating your new domain ID. Do you want to try again or"; if (data && data.status === "failure") {
errorText = "Error: " + data.error + "</br>Do you want to try again or";
console.log("Error: " + data.error);
} else {
console.log("Error: Failed to post to metaverse.");
}
if (justConnected) { if (justConnected) {
errorText += " just save your new access token?</br></br>You can always create a new domain ID later."; errorText += " just save your new access token?</br></br>You can always create a new domain ID later.";
} else {
errorText += " cancel?"
}
// we failed to create the new domain ID, show a sweet-alert that lets them try again or cancel
swal({
title: '',
type: 'error',
text: errorText,
html: true,
confirmButtonText: 'Try again',
showCancelButton: true,
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
// they want to try creating a domain ID again
showDomainCreationAlert(justConnected);
} else { } else {
errorText += " cancel?" // they want to cancel
} if (justConnected) {
// since they just connected we need to save the access token here
// we failed to create the new domain ID, show a sweet-alert that lets them try again or cancel saveSettings();
swal({
title: '',
type: 'error',
text: errorText,
html: true,
confirmButtonText: 'Try again',
showCancelButton: true,
closeOnConfirm: false
}, function(isConfirm){
if (isConfirm) {
// they want to try creating a domain ID again
showDomainCreationAlert(justConnected);
} else {
// they want to cancel
if (justConnected) {
// since they just connected we need to save the access token here
saveSettings();
}
} }
}); }
}); });
} }