UI: Improve multi OS display #205

Merged
Oleg-Komarov merged 40 commits from ui/multi-os into main 2024-07-16 07:24:07 +02:00
2 changed files with 39 additions and 1 deletions
Showing only changes of commit 4a2ac783e1 - Show all commits

View File

@ -107,6 +107,36 @@
return; return;
} }
// Show multi OS install buttons based on active platform
if (btnInstallActionItem.length > 1) {
btnInstallActionItem.forEach(function(item) {
// Hide all items by default
item.classList.add('d-none');
// Get item platform
const itemPlatform = item.getAttribute('data-platform');
const itemPlatformBase = itemPlatform.split('-')[0];
const itemPlatformBasePrefix = itemPlatformBase.substring(0, 3);
// Get active platform
/*
The navigator objects' 'platform' proporties are arbitrary, and specific to the browser.
For a light match, we can use the first 3 characters of the platform string.
*/
const activePlatform = navigator.platform.toLowerCase();
const activePlatformPrefix = activePlatform.substring(0, 3);
// Show button if item platform matches active platform
if (itemPlatformBasePrefix.startsWith(activePlatformPrefix)) {
item.classList.remove('d-none');
}
});
}
// Show btnInstallAction // Show btnInstallAction
btnInstall.addEventListener('click', function() { btnInstall.addEventListener('click', function() {
// Hide btnInstallGroup // Hide btnInstallGroup

View File

@ -193,6 +193,12 @@
<dd> <dd>
<ul class="ps-3"> <ul class="ps-3">
{% for file in latest.files.all %} {% for file in latest.files.all %}
{% comment %}
TODOs:
- @back-end (?) show only the largest size
- @front-end remove the list
{% endcomment %}
<li class="lh-sm"> <li class="lh-sm">
{{ file.size_bytes|filesizeformat }}<br> {{ file.size_bytes|filesizeformat }}<br>
<span class="fs-sm text-muted">({{ file.get_platforms|join:", " }})</span> <span class="fs-sm text-muted">({{ file.get_platforms|join:", " }})</span>
@ -272,7 +278,7 @@
</div> </div>
<div class="fade js-btn-install-action"> <div class="fade js-btn-install-action">
{% for download_item in download_list %} {% for download_item in download_list %}
<div class="btn-install-action-item js-btn-install-action-item" data-install-url="{{ request.scheme }}://{{ request.get_host }}{{ download_item.url }}" download="{{ download_item.name }}"> <div class="btn-install-action-item js-btn-install-action-item" data-install-url="{{ request.scheme }}://{{ request.get_host }}{{ download_item.url }}" data-platform="{{ download_item.platform }}" download="{{ download_item.name }}">
<div class="btn-install-drag-group js-btn-install-drag-group mb-2 rounded"> <div class="btn-install-drag-group js-btn-install-drag-group mb-2 rounded">
<button class="btn btn-flex btn-primary btn-install-drag cursor-move js-btn-install-drag w-100" draggable="true"> <button class="btn btn-flex btn-primary btn-install-drag cursor-move js-btn-install-drag w-100" draggable="true">
<i class="i-move"></i> <i class="i-move"></i>
@ -286,6 +292,8 @@
</small> </small>
</div> </div>
{% endfor %} {% endfor %}
{# TODO: add dropdown for other button install action items #}
</div> </div>
{# If JavaScript is disabled. #} {# If JavaScript is disabled. #}