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

graph/index.html: Add onclick listener to fix navbar #51

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions graph/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,31 @@
<!-- Navbar -->
<nav class="navbar is-light" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="."><img src="https://fedoraproject.org/assets/images/coreos-logo-light.png"/></a>
<a class="navbar-item" href="https://builds.coreos.fedoraproject.org/graph?stream=stable&basearch=x86_64"><img src="https://fedoraproject.org/assets/images/coreos-logo-light.png"/></a>
</div>

<div class="navbar-end">
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">Stream</a>
<a class="navbar-link" onclick="handleStreamClick()">Stream</a>
<div class="navbar-dropdown">
<a class="navbar-item">Stable</a>
<a class="navbar-item">Testing</a>
<a class="navbar-item" onclick="handleStreamDropdown('stable')">Stable</a>
<a class="navbar-item" onclick="handleStreamDropdown('testing')">Testing</a>
<a class="navbar-item" onclick="handleStreamDropdown('next')">Next</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">Architecture</a>
<div class="navbar-dropdown">
<a class="navbar-item">x86_64</a>
<a class="navbar-item" onclick="handleArchDropdown('aarch64')">aarch64</a>
<a class="navbar-item" onclick="handleArchDropdown('ppc64le')">ppc64le</a>
<a class="navbar-item" onclick="handleArchDropdown('s390x')">s390x</a>
<a class="navbar-item" onclick="handleArchDropdown('x86_64')">x86_64</a>
</div>
</div>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">Infrastructure</a>
<div class="navbar-dropdown">
<a class="navbar-item">Production</a>
<a class="navbar-item">Staging</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -146,6 +149,41 @@
</body>

<script id="js">
let selectedStream = 'stable'; // default
let selectedArch = 'x86_64'; // default
function handleStreamDropdown(stream) {
selectedStream = stream;
}
function handleArchDropdown(arch) {
selectedArch = arch;
}

document.querySelectorAll('.navbar-item.has-dropdown a').forEach(item => {
item.addEventListener('click', function () {
const optionType = this.parentElement.previousElementSibling.textContent; // Stream/Arch/Infra
const optionValue = this.textContent;

switch (optionType) {
case 'Stream':
if (['stable', 'testing', 'next'].includes(optionValue)) {
selectedStream = optionValue;
}
break;
case 'Arch':
if (['aarch64', 'ppc64le', 's390x', 'x86_64'].includes(optionValue)) {
selectedArch = optionValue;
}
break;
}

navigateToLink();
});
});

function navigateToLink() {
const url = `https://builds.coreos.fedoraproject.org/graph?stream=${selectedStream}&basearch=${selectedArch}&infra=prod`;
window.location.href = url; // executes the above and goes to the URL
}
// Return Cincinnati URL.
function templateUrl() {
const urlParams = new URLSearchParams(window.location.search);
Expand Down