initial work on comparison

This commit is contained in:
Tobias Brunner 2025-05-27 17:07:55 +02:00
parent 06b4cba4bc
commit 4cffe5a9e3
No known key found for this signature in database
6 changed files with 358 additions and 2 deletions

View file

@ -71,6 +71,12 @@
Show discount details
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="price_comparison" value="true" id="price_comparison" {% if show_price_comparison %}checked{% endif %}>
<label class="form-check-label" for="price_comparison">
Show external price comparisons
</label>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Apply Filters</button>
@ -153,6 +159,9 @@
<th>Discount Model</th>
<th>Discount Details</th>
{% endif %}
{% if show_price_comparison %}
<th>External Comparisons</th>
{% endif %}
<th class="final-price-header">Final Price</th>
</tr>
</thead>
@ -196,6 +205,39 @@
{% endif %}
</td>
{% 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 %}
</td>
{% endif %}
<td class="final-price-cell fw-bold">{{ row.final_price|floatformat:2 }}</td>
</tr>
{% endfor %}
@ -250,6 +292,12 @@ document.addEventListener('DOMContentLoaded', function() {
filterForm.submit();
});
// Add change event listener to price comparison checkbox
const priceComparisonCheckbox = document.getElementById('price_comparison');
priceComparisonCheckbox.addEventListener('change', function() {
filterForm.submit();
});
// Chart data for each service level
{% for group_name, service_levels in pricing_data_by_group_and_service_level.items %}
{% for service_level, pricing_data in service_levels.items %}