From fc9e869a4a135551e56b7e29c65b97b99b57b55c Mon Sep 17 00:00:00 2001 From: Alan Richardson Date: Sat, 9 Mar 2024 13:41:21 +0000 Subject: [PATCH] tidied ui --- .../co/compendiumdev/challenge/ChallengerConfig.java | 4 ++-- .../compendiumdev/challenge/gui/ChallengerWebGUI.java | 10 ++++++++-- .../challenge/persistence/AwsS3Storage.java | 4 ++-- .../challenge/persistence/PersistenceLayer.java | 8 -------- .../src/main/resources/public/js/challengerui.js | 8 ++++---- thingifier/src/main/resources/public/css/default.css | 5 +++++ 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/challenger/src/main/java/uk/co/compendiumdev/challenge/ChallengerConfig.java b/challenger/src/main/java/uk/co/compendiumdev/challenge/ChallengerConfig.java index 45c9f123..57a6b506 100644 --- a/challenger/src/main/java/uk/co/compendiumdev/challenge/ChallengerConfig.java +++ b/challenger/src/main/java/uk/co/compendiumdev/challenge/ChallengerConfig.java @@ -14,7 +14,7 @@ public void setToMultiPlayerMode() { } public void setToCloudPersistenceMode() { - persistenceLayer.setToCloud(); + persistenceLayer = new PersistenceLayer(PersistenceLayer.StorageType.CLOUD); } public void setGuiToKeepSessionAlive() { @@ -22,7 +22,7 @@ public void setGuiToKeepSessionAlive() { } public void setToNoPersistenceMode() { - persistenceLayer.switchOffPersistence(); + persistenceLayer = new PersistenceLayer(PersistenceLayer.StorageType.NONE); } public void enableAdminApi() { diff --git a/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java b/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java index 3f1a9768..dca7e957 100644 --- a/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java +++ b/challenger/src/main/java/uk/co/compendiumdev/challenge/gui/ChallengerWebGUI.java @@ -155,9 +155,11 @@ public void setup(final Challengers challengers, if (persistence != null) { persistenceReason = persistence.getErrorMessage(); } + html.append("
"); html.append(String.format("

Unknown Challenger ID %s

", persistenceReason)); html.append(showCurrentStatus()); + html.append("
"); html.append( multiUserShortHelp( persistenceLayer.willAutoSaveChallengerStatusToPersistenceLayer(), @@ -182,15 +184,18 @@ public void setup(final Challengers challengers, html.append(storeThingifierDatabaseNameCookie(xChallenger)); html.append(storeCurrentGuidInLocalStorage(xChallenger)); + html.append("
"); html.append(String.format("

Progress For Challenger ID %s

", xChallenger)); html.append(showCurrentStatus()); - html.append(showPreviousGuids()); html.append(inputAChallengeGuidScript()); + html.append("
"); }else { html.append(storeThingifierDatabaseNameCookie(xChallenger)); html.append(storeCurrentGuidInLocalStorage(xChallenger)); + html.append("
"); html.append(showCurrentStatus()); + html.append("
"); } html.append(renderChallengeData(challengeDefinitions, challenger)); @@ -288,7 +293,8 @@ private String playerChallengesIntro() { final StringBuilder html = new StringBuilder(); html.append("
"); html.append("

Use the Descriptions of the challenges below to explore the API and solve the challenges." + - " Remember to use the API documentation to see the format of POST requests.

"); + " Remember to use the API documentation to see the format of POST requests." + + "

"); html.append("
"); return html.toString(); } diff --git a/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/AwsS3Storage.java b/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/AwsS3Storage.java index aa9eff55..a3ba7fad 100644 --- a/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/AwsS3Storage.java +++ b/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/AwsS3Storage.java @@ -58,7 +58,7 @@ public PersistenceResponse saveChallengerStatus(final ChallengerAuthData data) { } catch (Exception e) { logger.error("Error storing data to bucket for guid: {}", data.getXChallenger(), e); - return new PersistenceResponse().withSuccess(false).withErrorMessage(e.getMessage()); + return new PersistenceResponse().withSuccess(false).withErrorMessage("Error storing data to S3"); } } @@ -95,7 +95,7 @@ public PersistenceResponse loadChallengerStatus(final String guid) { logger.error("Error Reading Challenge Status From S3: {}", guid, e); return new PersistenceResponse(). withSuccess(false). - withErrorMessage(e.getMessage()); + withErrorMessage("Error Reading Challenges Status from S3"); } } diff --git a/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/PersistenceLayer.java b/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/PersistenceLayer.java index 37de06a7..929c3a3d 100644 --- a/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/PersistenceLayer.java +++ b/challenger/src/main/java/uk/co/compendiumdev/challenge/persistence/PersistenceLayer.java @@ -18,14 +18,6 @@ public class PersistenceLayer { boolean allowSaveToS3 = false; boolean allowLoadFromS3 = false; - public void setToCloud() { - storeOn = PersistenceLayer.StorageType.CLOUD; - } - - public void switchOffPersistence() { - storeOn=StorageType.NONE; - } - public PersistenceResponse tryToLoadChallenger(final Challengers challengers, final String xChallengerGuid) { diff --git a/challenger/src/main/resources/public/js/challengerui.js b/challenger/src/main/resources/public/js/challengerui.js index 41559c16..ddd04d5c 100644 --- a/challenger/src/main/resources/public/js/challengerui.js +++ b/challenger/src/main/resources/public/js/challengerui.js @@ -121,12 +121,12 @@ function showCurrentStatus(){ var doneCount = Object.values(challengerData.challengeStatus).filter(x=>x).length; var totalCount = Object.values(challengerData.challengeStatus).length; var leftCount = totalCount - doneCount; - document.writeln(`

${totalCount} Challenges: ${doneCount} complete, ${leftCount} remain.`); + document.writeln(`

${totalCount} Challenges: ${doneCount} complete, ${leftCount} remain.
`); // only allow save if not in localStorage or is different from local storage if(localStorage.getItem(`${xChallengerGuid}.progress`)!==JSON.stringify(challengerData)){ if(!autoSaveOn){ - document.writeln(``); + document.writeln(``); }else{ saveChallengerProgressToLocalStorage(challengerData); } @@ -142,13 +142,13 @@ function showCurrentStatus(){ if(databaseData && databaseData.todos){ document.writeln(`

${databaseData.todos.length} todos in database. `); - document.writeln(`View Todos `) + document.writeln(`View Todos
`) // only allow save button if not in localStorage or is different from local storage document.databaseData.todos.sort((a,b)=>a.id-b.id); if(localStorage.getItem(`${xChallengerGuid}.data`)!==JSON.stringify(document.databaseData)){ if(!autoSaveOn){ - document.writeln(``); + document.writeln(``); }else{ saveChallengerTodosToLocalStorage(databaseData,challengerData); } diff --git a/thingifier/src/main/resources/public/css/default.css b/thingifier/src/main/resources/public/css/default.css index ef9aac6e..3f6a5842 100644 --- a/thingifier/src/main/resources/public/css/default.css +++ b/thingifier/src/main/resources/public/css/default.css @@ -119,4 +119,9 @@ pre.json{ .normal{ font-family: sans-serif; font-size: 1.0rem; +} + +.standoutblock{ + background: aliceblue; + padding: 1em; } \ No newline at end of file