From eb9bbacdb7c3119799251ca1ed214d300b1513ad Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Tue, 4 Feb 2020 16:10:11 -0500 Subject: [PATCH] show apps that will install with a new bubble --- .../java/bubble/model/bill/BubblePlan.java | 9 ++++--- .../resources/bill/BubblePlansResource.java | 25 +++++++++++++++++++ .../post_auth/ResourceMessages.properties | 2 ++ bubble-web | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java b/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java index 62602bfc..9f2edfeb 100644 --- a/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java +++ b/bubble-server/src/main/java/bubble/model/bill/BubblePlan.java @@ -3,6 +3,7 @@ package bubble.model.bill; import bubble.cloud.compute.ComputeNodeSizeType; import bubble.model.account.Account; import bubble.model.account.HasAccount; +import bubble.model.app.BubbleApp; import bubble.model.cloud.BubbleNetwork; import lombok.Getter; import lombok.NoArgsConstructor; @@ -16,11 +17,9 @@ import org.cobbzilla.wizard.validation.HasValue; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; +import javax.persistence.*; import javax.validation.constraints.Size; +import java.util.List; import static bubble.ApiConstants.EP_PLANS; import static org.cobbzilla.util.daemon.ZillaRuntime.die; @@ -123,4 +122,6 @@ public class BubblePlan extends IdentifiableBaseParentEntity implements HasAccou @Column(nullable=false, updatable=false) @Getter @Setter private Integer additionalBandwidthPerGbPrice; + @Transient @Getter @Setter private transient List apps; + } diff --git a/bubble-server/src/main/java/bubble/resources/bill/BubblePlansResource.java b/bubble-server/src/main/java/bubble/resources/bill/BubblePlansResource.java index c0a56d7c..65466c56 100644 --- a/bubble-server/src/main/java/bubble/resources/bill/BubblePlansResource.java +++ b/bubble-server/src/main/java/bubble/resources/bill/BubblePlansResource.java @@ -1,16 +1,25 @@ package bubble.resources.bill; +import bubble.dao.app.BubbleAppDAO; +import bubble.dao.bill.BubblePlanAppDAO; import bubble.dao.bill.BubblePlanDAO; import bubble.model.account.Account; +import bubble.model.app.BubbleApp; import bubble.model.bill.BubblePlan; +import bubble.model.bill.BubblePlanApp; import bubble.resources.account.AccountOwnedResource; import lombok.extern.slf4j.Slf4j; +import org.cobbzilla.util.collection.ExpirationMap; import org.glassfish.jersey.server.ContainerRequest; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import static bubble.ApiConstants.EP_APPS; import static bubble.ApiConstants.PLANS_ENDPOINT; @@ -24,6 +33,9 @@ public class BubblePlansResource extends AccountOwnedResource MAX_CHARGENAME_LEN) throw invalidEx("err.chargeName.length"); @@ -39,4 +51,17 @@ public class BubblePlansResource extends AccountOwnedResource apps = getAppsForPlan(plan); + plan.setApps(apps); + return super.populate(ctx, plan); + } + + private Map> appCache = new ExpirationMap<>(); + + private List getAppsForPlan(BubblePlan plan) { + return appCache.computeIfAbsent(plan.getUuid(), planUuid -> appDAO.findByUuids(planAppDAO.findByPlan(planUuid).stream() + .map(BubblePlanApp::getApp) + .collect(Collectors.toSet()))); + } } diff --git a/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties b/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties index 98b930e2..8fd1b228 100644 --- a/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties +++ b/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties @@ -201,6 +201,8 @@ field_description_network_fork_host=The current Sage Launcher will be forked ont field_label_network_domain=Domain field_label_plan=Plan field_label_show_advanced_plan_options=Show All Options +field_label_plan_fork_apps=All app templates will be copied to fork +field_label_plan_node_apps=Your Bubble will include these apps: field_label_region=Location field_label_footprint=Footprint field_label_network_ssh_key=SSH Key diff --git a/bubble-web b/bubble-web index fb396f35..239fdd08 160000 --- a/bubble-web +++ b/bubble-web @@ -1 +1 @@ -Subproject commit fb396f3541900e24b3e98e5eb32c7af9345b45d6 +Subproject commit 239fdd0878a96e703e338377015a8a174afdfca1