From 4c1de14cbbda078172e95e9bb9c24362945b1b4f Mon Sep 17 00:00:00 2001 From: Kalila L Date: Wed, 21 Oct 2020 00:56:55 -0400 Subject: [PATCH] Add input error handling and notice. --- domain-server/resources/web/js/shared.js | 2 -- domain-server/resources/web/wizard/js/wizard.js | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/domain-server/resources/web/js/shared.js b/domain-server/resources/web/js/shared.js index 0395106297..bffd512890 100644 --- a/domain-server/resources/web/js/shared.js +++ b/domain-server/resources/web/js/shared.js @@ -522,8 +522,6 @@ function createDomainIDPrompt(callback) { if (callback) { callback(inputValue); } - - swal.close(); }); } diff --git a/domain-server/resources/web/wizard/js/wizard.js b/domain-server/resources/web/wizard/js/wizard.js index 6c46a3b35c..6039c68cfa 100644 --- a/domain-server/resources/web/wizard/js/wizard.js +++ b/domain-server/resources/web/wizard/js/wizard.js @@ -179,7 +179,14 @@ function promptToCreateDomainID() { "label": label }; - $.post("/api/domains", domainJSON, function (data) { + $.post("/api/domainsss", domainJSON, function (data) { + if (data.status === "failure") { + swal.showInputError("Error: " + data.error); + return; + } + + swal.close(); + // we successfully created a domain ID, set it on that field var domainID = data.domain.domainId; console.log("Setting domain ID to ", data, domainID); @@ -192,9 +199,13 @@ function promptToCreateDomainID() { // POST the form JSON to the domain-server settings.json endpoint so the settings are saved postSettings(formJSON, goToNextStep); - }, 'json').fail(function () { + }, 'json').fail(function (data) { + if (data && data.status === "failure") { + swal.showInputError("Error: " + data.error); + } else { + swal.showInputError("Error: Failed to post to metaverse."); + } console.log("Failed to create domain ID..."); - goToNextStep(); }); }); }, 500); // Apparently swal needs time before opening another prompt.