From df68d33f354b11e9d17763b21590f1419cb23868 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Thu, 20 Sep 2018 15:01:41 -0400 Subject: [PATCH 1/2] Display an empty state in place of budget chart and spend table, when the Workspace has no environments --- templates/workspaces/reports/index.html | 609 ++++++++++++------------ 1 file changed, 297 insertions(+), 312 deletions(-) diff --git a/templates/workspaces/reports/index.html b/templates/workspaces/reports/index.html index 563a7838..a908755f 100644 --- a/templates/workspaces/reports/index.html +++ b/templates/workspaces/reports/index.html @@ -2,6 +2,7 @@ {% from "components/alert.html" import Alert %} {% from "components/icon.html" import Icon %} +{% from "components/empty_state.html" import EmptyState %} {% block workspace_content %} @@ -102,341 +103,325 @@ {% set two_months_ago_index = two_months_ago.strftime('%m/%Y') %} {% set reports_url = url_for("workspaces.workspace_reports", workspace_id=workspace.id) %} - -
-
-

Cumulative Budget

+ {% if not monthly_totals['environments'] %} + {% set message = 'This Workspace has no Cloud Environments setup, hence there is no spending data to report. Create a Project with some Cloud Environments to get started.' + if can_create_projects + else 'This Workspace has no Cloud Environments setup, hence there is no spending data to report. Contact the Workspace Owner to set up some Cloud Environments.' + %} -
-
-
-
Monthly Spend
-
Monthly spend visual key
-
+ {{ EmptyState( + 'Nothing to report', + action_label='Add a New Project' if can_create_projects else None, + action_href=url_for('workspaces.new_project', workspace_id=workspace.id) if can_create_projects else None, + icon='chart', + sub_message=message + ) }} + {% else %} -
-
Accumulated Spend
-
Accumulated spend visual key
-
-
-
-
-
Projected
-
-
Projected monthly spend visual key
-
Projected accumulated spend visual key
-
-
-
-
-
- - - - - - - - - - - {# spend/projected budget path lines #} - - - - {# max budget line #} - - - - - {# make this clickable to focus on that month #} - - - - - - - - - - -  |  - - - {# container block #} - - - {# budget bar #} - - - {# projected budget bar #} - - - {# task order expiration line #} - - - {# task order expiration label #} - T.O. Expires - - {# cumulative dot #} - - - {# abbreviated cumulative label #} - - - {# abbreviated spend label #} - - - {# month label #} - - - {# year label #} - - - - - Total Budget - - -
-
- -
-
-

Total spend per month

- - -
- - - - - - - - - - +
+
+

Cumulative Budget

-
- - - - - - - - +
+
+
+
Monthly Spend
+
Monthly spend visual key
+
-
- - - +
+
Accumulated Spend
+
Accumulated spend visual key
+
+ +
+
+
Projected
+
+
Projected monthly spend visual key
+
Projected accumulated spend visual key
+
+
+
+ + - + - - - + + + + + + - - + {# spend/projected budget path lines #} + + - - + {# max budget line #} + - + - + {# make this clickable to focus on that month #} + - + + + + + + - - - + + <span v-html='month.date.month + " " + month.date.year'></span> | <!-- + --><template v-if='month.cumulativeTotal'><!-- + --><template v-if='month.budget && month.budget.spend'>Spend:</template><!-- + --><template v-else>Projected Spend:</template><!-- + --><span v-html='month.spendAmount'></span><!-- + --> | <!-- + --><template v-if='month.budget'>Total:</template><!-- + --><template v-else>Projected Total:</template><!-- + --><span v-html='month.cumulativeAmount'></span><!-- + --></template><!-- - {# {% for project_name, project_totals in monthly_totals['projects'].items() %} - <tbody is='tbody-toggler' class='spend-table__project'> + --><template v-else>No spend for this month</template> + + + {# container block #} + + + {# budget bar #} + + + {# projected budget bar #} + + + {# task order expiration line #} + + + {# task order expiration label #} + T.O. Expires + + {# cumulative dot #} + + + {# abbreviated cumulative label #} + + + {# abbreviated spend label #} + + + {# month label #} + + + {# year label #} + + + + + Total Budget + + + + + +
+
+

Total spend per month

+ + +
+ + +
Spending scope{{ two_months_ago.strftime('%B %Y') }}{{ prev_month.strftime('%B %Y') }}{{ current_month.strftime('%B %Y') }}
Workspace Total{{ workspace_totals.get(two_months_ago_index, 0) | dollars }}{{ workspace_totals.get(prev_month_index, 0) | dollars }}{{ workspace_totals.get(current_month_index, 0) | dollars }} - -
- - - - - - - - - - -
-
-
- - {{ Icon('link') }} - - - - - - - - -
+ + + + + + + + + + + + + + + + + + + - - - + + + + + + - {% for env_name, env_totals in monthly_totals['environments'][project_name].items() %} - - - - - - - - {% endfor %} + + - - - {% endfor %} #} -
Spending scope{{ two_months_ago.strftime('%B %Y') }}{{ prev_month.strftime('%B %Y') }}{{ current_month.strftime('%B %Y') }}
Workspace Total{{ workspace_totals.get(two_months_ago_index, 0) | dollars }}{{ workspace_totals.get(prev_month_index, 0) | dollars }}{{ workspace_totals.get(current_month_index, 0) | dollars }} + +
- {{ project_totals.get(two_months_ago_index, 0) | dollars }}{{ project_totals.get(prev_month_index, 0) | dollars }}{{ project_totals.get(current_month_index, 0) | dollars }} + + + + + + - {{ (100 * (project_totals.get(current_month_index, 0) / workspace_totals.get(current_month_index, 1))) | round | int }}% - + + + + +
+
{{ Icon('link') }} {{ env_name }}{{ env_totals.get(two_months_ago_index, 0) | dollars }}{{ env_totals.get(prev_month_index, 0) | dollars }}{{ env_totals.get(current_month_index, 0) | dollars }}
+ + {{ Icon('link') }} + + +
-
-
+ + + + + + + + + + + + + + + + + + + + {% endif %} {% endblock %} From 14daa16ef0528b2ceff0c8cb59611d938704c125 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Thu, 20 Sep 2018 15:12:33 -0400 Subject: [PATCH 2/2] add permission check for can_create_projects --- templates/workspaces/reports/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/workspaces/reports/index.html b/templates/workspaces/reports/index.html index a908755f..18198ea5 100644 --- a/templates/workspaces/reports/index.html +++ b/templates/workspaces/reports/index.html @@ -104,6 +104,8 @@ {% set reports_url = url_for("workspaces.workspace_reports", workspace_id=workspace.id) %} {% if not monthly_totals['environments'] %} + + {% set can_create_projects = user_can(permissions.ADD_APPLICATION_IN_WORKSPACE) %} {% set message = 'This Workspace has no Cloud Environments setup, hence there is no spending data to report. Create a Project with some Cloud Environments to get started.' if can_create_projects else 'This Workspace has no Cloud Environments setup, hence there is no spending data to report. Contact the Workspace Owner to set up some Cloud Environments.'