Browse Source

show apps that will install with a new bubble

tags/v0.5.2
Jonathan Cobb 4 years ago
parent
commit
eb9bbacdb7
4 changed files with 33 additions and 5 deletions
  1. +5
    -4
      bubble-server/src/main/java/bubble/model/bill/BubblePlan.java
  2. +25
    -0
      bubble-server/src/main/java/bubble/resources/bill/BubblePlansResource.java
  3. +2
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  4. +1
    -1
      bubble-web

+ 5
- 4
bubble-server/src/main/java/bubble/model/bill/BubblePlan.java View File

@@ -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<BubbleApp> apps;

}

+ 25
- 0
bubble-server/src/main/java/bubble/resources/bill/BubblePlansResource.java View File

@@ -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<BubblePlan, Bubble

public BubblePlansResource() { super(null); }

@Autowired private BubblePlanAppDAO planAppDAO;
@Autowired private BubbleAppDAO appDAO;

@Override protected BubblePlan setReferences(ContainerRequest ctx, Account caller, BubblePlan bubblePlan) {
if (empty(bubblePlan.getChargeName())) throw invalidEx("err.chargeName.required");
if (bubblePlan.getChargeName().length() > MAX_CHARGENAME_LEN) throw invalidEx("err.chargeName.length");
@@ -39,4 +51,17 @@ public class BubblePlansResource extends AccountOwnedResource<BubblePlan, Bubble
return configuration.subResource(BubblePlanAppsResource.class, caller, plan);
}

@Override protected BubblePlan populate(ContainerRequest ctx, BubblePlan plan) {
final List<BubbleApp> apps = getAppsForPlan(plan);
plan.setApps(apps);
return super.populate(ctx, plan);
}

private Map<String, List<BubbleApp>> appCache = new ExpirationMap<>();

private List<BubbleApp> getAppsForPlan(BubblePlan plan) {
return appCache.computeIfAbsent(plan.getUuid(), planUuid -> appDAO.findByUuids(planAppDAO.findByPlan(planUuid).stream()
.map(BubblePlanApp::getApp)
.collect(Collectors.toSet())));
}
}

+ 2
- 0
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties View File

@@ -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


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit fb396f3541900e24b3e98e5eb32c7af9345b45d6
Subproject commit 239fdd0878a96e703e338377015a8a174afdfca1

Loading…
Cancel
Save