From 2546639171a78e4c999433ce028c17e38d7395ee Mon Sep 17 00:00:00 2001 From: Kalila L Date: Mon, 12 Oct 2020 01:17:00 -0400 Subject: [PATCH] Add domain label creation step 1 of wizard. --- domain-server/resources/web/js/shared.js | 27 ++++++++++++++++ .../resources/web/wizard/js/wizard.js | 31 ++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/domain-server/resources/web/js/shared.js b/domain-server/resources/web/js/shared.js index 5469125162..b52928914a 100644 --- a/domain-server/resources/web/js/shared.js +++ b/domain-server/resources/web/js/shared.js @@ -500,6 +500,33 @@ function prepareAccessTokenPrompt(callback) { }); } +function createDomainIDPrompt(callback) { + swal({ + title: 'Finish Registering Domain', + type: 'input', + text: 'Enter a label for this machine.

This will help you identify which domain ID belongs to which machine.

This is a required step for registration.

', + showCancelButton: true, + confirmButtonText: "Create", + closeOnConfirm: false, + html: true + }, function(inputValue){ + if (inputValue === false) { + return false; + } + + if (inputValue === "") { + swal.showInputError("Please enter a valid label for your machine.") + return false + } + + if (callback) { + callback(inputValue); + } + + swal.close(); + }); +} + function getMetaverseUrl(callback) { $.ajax('/api/metaverse_info', { success: function(data) { diff --git a/domain-server/resources/web/wizard/js/wizard.js b/domain-server/resources/web/wizard/js/wizard.js index 2603eca5c6..995c34d9ec 100644 --- a/domain-server/resources/web/wizard/js/wizard.js +++ b/domain-server/resources/web/wizard/js/wizard.js @@ -50,6 +50,7 @@ $(document).ready(function(){ prepareAccessTokenPrompt(function(accessToken) { Metaverse.accessToken = accessToken; saveAccessToken(); + promptToCreateDomainID(); }); }); @@ -171,6 +172,34 @@ function setupWizardSteps() { $(currentStep).show(); } +function promptToCreateDomainID() { + setTimeout(function(){ + createDomainIDPrompt(function(label) { + var domainJSON = { + "label": label + } + + $.post("/api/domains", domainJSON, function(data){ + // we successfully created a domain ID, set it on that field + var domainID = data.domain.domainId; + console.log("Setting domain ID to ", data, domainID); + + var formJSON = { + "metaverse": { + "id": domainID + } + } + + // POST the form JSON to the domain-server settings.json endpoint so the settings are saved + postSettings(formJSON, goToNextStep); + }, 'json').fail(function(){ + console.log("Failed to create domain ID..."); + goToNextStep(); + }); + }); + }, 500); // Apparently swal needs time before opening another prompt. +} + function updatePlaceNameLink(address) { if (address) { var url = URLs.PLACE_URL + '/' + address; @@ -341,7 +370,7 @@ function saveAccessToken() { $(this).blur(); // POST the form JSON to the domain-server settings.json endpoint so the settings are saved - postSettings(formJSON, goToNextStep); + postSettings(formJSON); } function getSettingDescriptionForKey(groupKey, settingKey) {