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 1 commit
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
38 changes: 33 additions & 5 deletions graph/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@
<!-- 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">
Expand All @@ -80,7 +81,7 @@
<a class="navbar-link">Infrastructure</a>
<div class="navbar-dropdown">
<a class="navbar-item">Production</a>
<a class="navbar-item">Staging</a>
<!-- <a class="navbar-item">Staging</a> -> Removing / unavaialbe -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if only production works, lets remove the whole selector

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I needed a second opinion on this, hence commenting it out :) Will do!

</div>
</div>
</div>
Expand Down Expand Up @@ -146,6 +147,33 @@
</body>

<script id="js">
let selectedStream = 'stable'; // default

function handleStreamDropdown(stream) {
selectedStream = stream;
}

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;
}

navigateToLink();
});
});

function navigateToLink() {
const url = `https://builds.coreos.fedoraproject.org/graph?stream=${selectedStream}&basearch=x86_64&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