price comparison improved

This commit is contained in:
Tobias Brunner 2025-05-30 13:36:09 +02:00
parent e06105942b
commit d987f62471
No known key found for this signature in database
3 changed files with 68 additions and 46 deletions

View file

@ -146,6 +146,7 @@
<thead class="table-dark">
<tr>
<th>Compute Plan</th>
<th>Cloud Provider</th>
<th>vCPUs</th>
<th>RAM (GB)</th>
<th>Term</th>
@ -167,8 +168,9 @@
</thead>
<tbody>
{% for row in pricing_data %}
<tr>
<tr class="servala-row">
<td>{{ row.compute_plan }}</td>
<td>{{ row.cloud_provider }}</td>
<td>{{ row.vcpus }}</td>
<td>{{ row.ram }}</td>
<td>{{ row.term }}</td>
@ -207,39 +209,61 @@
{% endif %}
{% if show_price_comparison %}
<td>
{% if row.external_comparisons %}
<small>
{% for comparison in row.external_comparisons %}
<div class="mb-2 border-bottom pb-1">
<strong>{{ comparison.provider }}</strong>: {{ comparison.plan_name }}<br>
<span class="text-primary">{{ comparison.amount|floatformat:2 }} {{ row.currency }}</span>
{% if comparison.difference > 0 %}
<span class="badge ms-1">+{{ comparison.difference|floatformat:2 }}</span>
{% elif comparison.difference < 0 %}
<span class="badge ms-1">{{ comparison.difference|floatformat:2 }}</span>
{% endif %}
{% if comparison.ratio %}
<br><small class="text-muted">Price ratio: {{ comparison.ratio|floatformat:2 }}x</small>
{% endif %}
{% if comparison.description %}
<br><small class="text-muted">{{ comparison.description }}</small>
{% endif %}
{% if comparison.vcpus or comparison.ram %}
<br><small class="text-muted">
{% if comparison.vcpus %}{{ comparison.vcpus }} vCPU{% endif %}
{% if comparison.ram %}{{ comparison.ram }} GB RAM{% endif %}
</small>
{% endif %}
</div>
{% endfor %}
</small>
{% else %}
<small class="text-muted">No comparisons</small>
{% endif %}
<span class="badge">-</span>
</td>
{% endif %}
<td class="final-price-cell fw-bold">{{ row.final_price|floatformat:2 }}</td>
</tr>
{% if show_price_comparison and row.external_comparisons %}
{% for comparison in row.external_comparisons %}
<tr class="table-light comparison-row">
<td class="text-muted">{{ comparison.plan_name }}</td>
<td class="text-muted">{{ comparison.provider }}</td>
<td class="text-muted">
{% if comparison.vcpus %}{{ comparison.vcpus }}{% else %}-{% endif %}
</td>
<td class="text-muted">
{% if comparison.ram %}{{ comparison.ram }}{% else %}-{% endif %}
</td>
<td class="text-muted">{{ row.term }}</td>
<td class="text-muted">{{ comparison.currency }}</td>
<td class="text-muted">-</td>
<td class="text-muted">-</td>
<td class="text-muted">-</td>
<td class="text-muted">-</td>
<td class="text-muted">-</td>
{% if show_discount_details %}
<td class="text-muted">-</td>
<td class="text-muted">-</td>
{% endif %}
<td>
<small>
<span class="badge bg-secondary">{% if comparison.source %}<span class="text-muted"><a href="{{ comparison.source }}" target="_blank">{{ comparison.provider }}</a></span>{% else %}{{ comparison.provider }}{% endif %}</span><br>
{% if comparison.description %}
<span class="text-muted">{{ comparison.description }}</span><br>
{% endif %}
{% if comparison.storage %}
<span class="text-muted">Storage: {{ comparison.storage }} GB</span><br>
{% endif %}
{% if comparison.replicas %}
<span class="text-muted">Replicas: {{ comparison.replicas }}</span><br>
{% endif %}
{% if comparison.ratio %}
<span class="text-muted">Price ratio: {{ comparison.ratio|floatformat:2 }}x</span><br>
{% endif %}
</small>
</td>
<td class="fw-bold">
{{ comparison.amount|floatformat:2 }} {{ comparison.currency }}
{% if comparison.difference > 0 %}
<span class="badge bg-danger ms-1">+{{ comparison.difference|floatformat:2 }}</span>
{% elif comparison.difference < 0 %}
<span class="badge bg-success ms-1">{{ comparison.difference|floatformat:2 }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>