diff --git a/demo/src/main/java/com/example/application/Application.java b/demo/src/main/java/com/example/application/Application.java index 21392b5f..ce9ae94b 100644 --- a/demo/src/main/java/com/example/application/Application.java +++ b/demo/src/main/java/com/example/application/Application.java @@ -1,8 +1,6 @@ package com.example.application; import com.vaadin.flow.component.page.AppShellConfigurator; -import com.vaadin.flow.component.page.Push; -import com.vaadin.flow.shared.ui.Transport; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -19,7 +17,6 @@ @SpringBootApplication @Theme("nps") @PWA(shortName = "Feedback", name = "Feedback") -@Push(transport = Transport.WEBSOCKET) public class Application implements AppShellConfigurator { public static void main(String[] args) { diff --git a/demo/src/main/java/com/example/application/data/FeedbackSheet.java b/demo/src/main/java/com/example/application/data/FeedbackSheet.java index 18f3b739..3aa9512f 100644 --- a/demo/src/main/java/com/example/application/data/FeedbackSheet.java +++ b/demo/src/main/java/com/example/application/data/FeedbackSheet.java @@ -45,15 +45,11 @@ public class FeedbackSheet { private String sheetId; - private FeedbackSheet(String sheetId, String credentialsFilePath) { + public FeedbackSheet(String sheetId, String credentialsFilePath) { this.sheetId = sheetId; this.credentialsFilePath = credentialsFilePath; } - public static FeedbackSheet getSheet(String sheetId, String credentialsFilePath) { - return new FeedbackSheet(sheetId, credentialsFilePath); - } - /** * Append a user score to the spreadsheet. *

diff --git a/demo/src/main/java/com/example/application/views/feedback/NPSView.java b/demo/src/main/java/com/example/application/views/feedback/NPSView.java index f3e6003e..18a216ab 100644 --- a/demo/src/main/java/com/example/application/views/feedback/NPSView.java +++ b/demo/src/main/java/com/example/application/views/feedback/NPSView.java @@ -18,7 +18,7 @@ @Route(value = "") public class NPSView extends VerticalLayout { - public static final String DEFAULT_LINK_TEXT = "Go back to vaadin.com"; + public static final String DEFAULT_LINK_TEXT = "Visit vaadin.com"; public static final String DEFAULT_LINK = "https://vaadin.com/"; public static final String DEFAULT_HEADER = "Thank you for visiting us."; public static final String DEFAULT_QUESTION = NPS.DEFAULT_NPS_QUESTION; @@ -28,11 +28,14 @@ public class NPSView extends VerticalLayout { private static final String DEVELOPMENT_CREDENTIAL_FILE = "/workspaces/nps/.devcontainer/local/service_account_credentials.json"; private static final String DEFAULT_SHEET_ID = "1aTfU2_XuZU-HgUhSBu4_oB_gB4hhro-RzNsdN9_8YX8"; + private static final String SHEET_LINK = "https://docs.google.com/spreadsheets/d/1aTfU2_XuZU-HgUhSBu4_oB_gB4hhro-RzNsdN9_8YX8"; + private static final String SHEET_LINK_TEXT = "See responses"; NPS nps = new NPS(); H2 header = new H2(DEFAULT_HEADER); Paragraph thankYou = new Paragraph(DEFAULT_THANK_YOU); Anchor closeLink = new Anchor(DEFAULT_LINK, DEFAULT_LINK_TEXT); + Anchor sheetLink = new Anchor(SHEET_LINK, SHEET_LINK_TEXT); String productName = "default"; @@ -47,11 +50,15 @@ public NPSView() { nps.addValueChangeListener(e -> { header.setVisible(false); replace(nps, thankYou); + add(sheetLink); add(closeLink); + String credentialFileName = getCredentialFileName(); + String sheetId = getSheetId(); // Store the results into a Google Sheet - FeedbackSheet.getSheet(getSheetId(), getCredentialFileName()) - .append(productName,"" + UI.getCurrent().hashCode(), e.getValue()); + FeedbackSheet feedbackSheet = new FeedbackSheet(sheetId, + credentialFileName); + feedbackSheet.append(productName,"" + UI.getCurrent().hashCode(), e.getValue()); }); // Styling