Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Service plan cost when selecting a service plan (if not free) #2959

Merged
merged 9 commits into from
Nov 9, 2018

Conversation

irfanhabib
Copy link
Contributor

@irfanhabib irfanhabib commented Sep 6, 2018

Fixes #2958

Displays it like this:
image

@cfdreddbot
Copy link

Hey irfanhabib!

Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you and the commit authors have already signed the CLA.

@codecov
Copy link

codecov bot commented Sep 6, 2018

Codecov Report

Merging #2959 into v2-master will decrease coverage by 0.03%.
The diff coverage is 50%.

@@              Coverage Diff              @@
##           v2-master    #2959      +/-   ##
=============================================
- Coverage      71.13%   71.09%   -0.04%     
=============================================
  Files            632      632              
  Lines          27683    27768      +85     
  Branches        6297     6314      +17     
=============================================
+ Hits           19691    19742      +51     
- Misses          7992     8026      +34

@nwmac nwmac added the needs attention This PR needs attention label Sep 7, 2018
Copy link
Contributor

@nwmac nwmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check the spec: https://github.com/openservicebrokerapi/servicebroker/blob/v2.14/spec.md

I tried this with IBM Cloud and they have different cost metadata than is described in the specification (no amount field).

We should handle this gracefully - I suspect they use a costs model pre-dating the OSRB spec?? Need to check.

@@ -16,6 +16,11 @@
<span *ngIf="(getPlanAccessibility(selPlan.entity) | async) !== 'ok'"> ({{ getAccessibilityMessage(selPlan.entity) | async }})</span>
</app-metadata-item>
<app-metadata-item label="Free"> {{ isFree(selPlan) | titlecase}} </app-metadata-item>
<ng-container *ngIf="!isFree(selPlan)">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be false as isFree is a string - need to use *ngIf="!selPlan.entity.entity.free">

@irfanhabib
Copy link
Contributor Author

@nwmac Updated the PR to handle missing amount more gracefully

@gberche-orange
Copy link
Contributor

gberche-orange commented Sep 10, 2018

thanks @irfanhabib

Is there a mapping between the spec unit field https://github.com/openservicebrokerapi/servicebroker/blob/master/profile.md#cost-object with examples such as "MONTHLY", "HOURLY", "Request", "GB" and the actual label displayed in the UI, which in the screenshot shows as "Month" ? Can you point me to this mapping logic (as I couldn't easily review it) ?

The service catalogs from PWS marketplace, seems to indeed stick to spec example and use the "MONTHLY" unit string.

$ CF_TRACE=true cf m -s elephantsql | grep costs
        "extra": "{\"displayName\":\"Tiny Turtle\",\"bullets\":[\"Shared high performance cluster\",\"20 MB data\",\"4 concurrent connections\"],\"costs\":[{\"amount\":{\"usd\":0},\"unit\":\"MONTHLY\"}]}",
        "extra": "{\"displayName\":\"Pretty Panda\",\"bullets\":[\"Shared high performance cluster\",\"2 GB data\",\"20 concurrent connections\"],\"costs\":[{\"amount\":{\"usd\":19.0},\"unit\":\"MONTHLY\"}]}",
        "extra": "{\"displayName\":\"Happy Hippo\",\"bullets\":[\"Dedicated server\",\"100 GB data\",\"1.7 GB RAM\",\"300 concurrent connections\"],\"costs\":[{\"amount\":{\"usd\":99.0},\"unit\":\"MONTHLY\"}]}",
        "extra": "{\"displayName\":\"Enormous Elephant\",\"bullets\":[\"Dedicated server\",\"7.5 GB RAM\",\"1000 GB data\",\"EBS optimized, 500 Mbps\",\"300 concurrent connections\"],\"costs\":[{\"amount\":{\"usd\":499.0},\"unit\":\"MONTHLY\"}]}",

I'm wondering whether a label such as the following would better accommodate the current specs, including the prefix/postfix display variation depending on currencies.

Cost (unit=$unit currency=$currency): $amount
e.g.

  • Cost (unit=monthly currency=Euro): 10
  • Cost (unit=hourly currency=USD): 20
  • Cost (unit=hour currency=USD): 20
  • Cost (unit=GB currency=GBP): 10
  • Cost (unit=1,000 API calls currency=Euro): 10.5

Alternative: Cost : $amount ($currency , $unit)

  • Cost: : 10 (Euro, monthly)
  • Cost: 20 (USD, hourly)
  • Cost: 20 (GBP, GB)
  • Cost: 10.5 (Euro, 1,000 API calls)

It's less nice looking, but might be more accurate (without going into complex wording logic).

@irfanhabib
Copy link
Contributor Author

@gberche-orange The code is agnostic to what the actual unit in question is. It can be anything (month, GB etc..)

In the example you'be provided, for example, the card would show the following:

Cost (unit=1,000 API calls currency=Euro): 10.5 => Cost per 1,000 API calls: ..

@gberche-orange
Copy link
Contributor

@irfanhabib with the unit example of the OSB specifications where the unit example is MONTHLY and with a currency set to EUR, would the price then be displayed as Cost per MONTHLY: EUR 10 (which would be grammatically odd, and EUR currency commonly expected to be located after the digits)

This unusual wording is to be compared with an alternative display such as Cost (unit=MONTHLY currency=EUR): 10.5 which might be harder to read in common cases, but more friendly to non USD units, and specified currency units.

@irfanhabib
Copy link
Contributor Author

@gberche-orange I've changed the format to:

Cost per UNIT In CURRENCY

I.e
image

@irfanhabib
Copy link
Contributor Author

@gberche-orange
A final change, the cost + currency is shown in the European format, if the currency is Euro.
image

Otherwise it defaults to American English format
image

@irfanhabib irfanhabib added comments-addressed and removed needs attention This PR needs attention labels Sep 24, 2018
@gberche-orange
Copy link
Contributor

@irfanhabib looks great, thanks. I guess the currency logic (prefix vs suffix) can be extended in the future with other currencies (e.g. yens...)

@KlapTrap
Copy link
Contributor

KlapTrap commented Nov 5, 2018

@irfanhabib Should we remove the Free: false is there is a cost shown?

@richard-cox
Copy link
Contributor

For testing, IBM has some funky pricing. See Cloudant service

- Changed create service - select service step loading indicator to common step `blocked` indicator
- Don't show the service plan cost if its not in OSRB format (aka more complex IBM format)
@richard-cox
Copy link
Contributor

I've tweaked the output after reviewing. It looked like we were displaying the MONTHLY unit text after all. Given the new changes the example costs object from the open service broker docs would look like...
image
The format of the currency value remains unchanged (0.99EUR or [others]0.99). We'll update this when we implement i18n.
I've tested this on PWS and it looks good. For IBM we won't show costs at all (their pricing structure is more complex and I'd rather not show anything at all than something that's incorrect).
@gberche-orange If you're happy with the new format I'll get this merged once it's passed our CI

@richard-cox richard-cox merged commit 25f29bb into v2-master Nov 9, 2018
@richard-cox richard-cox deleted the add-dashboard-url branch November 9, 2018 11:46
@gberche-orange
Copy link
Contributor

thanks @richard-cox, this seems a good balance to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants