Skip to content

Commit

Permalink
Add a way to get to /admin/panel and update map button logic
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges committed Jan 14, 2025
1 parent da6abd4 commit 33c38bb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/meshdb/templates/admin/base_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ <h1 id="site-name"><a href="{% url 'admin:index' %}"><img src="{% static 'meshwe

{% block userlinks %}
{{ block.super }}
<a href="#" class="hidden" style="margin-left: 5px; vertical-align: middle; border: none;" id="show_map_button">
<!--This will let people "show" the map by offering to navigate them to /admin/panel if they have found themselves at /admin-->
<a href="#" class="hidden" style="margin-left: 5px; vertical-align: middle; border: none;" id="navigate_to_panel_view">
<img src="{% static '/admin/map/img/map.png' %}" height="16px" title="Show Map">
</a>
<!--Script to quietly update the panel view link-->
<script src="{% static '/admin/panel_view_nav.js' %}"></script>
{% endblock %}

{% block footer %}
Expand Down
2 changes: 1 addition & 1 deletion src/meshdb/templates/admin/iframed.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<iframe src="/admin/" id="admin_panel_iframe" class="frameGrow"></iframe>
</div>

<div class="floating-button">
<div class="floating-button-above">
<a href="#" class="button" style="display: inline-block" id="show_map_button">
<img src="{% static '/admin/map/img/map.png' %}" height="16px" title="Show Map">
</a>
Expand Down
8 changes: 8 additions & 0 deletions src/meshweb/static/admin/admin_ext.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@
background: transparent;
}

.floating-button-above {
z-index: 100;
position: absolute;
top: 15px;
right: 10px;
padding: 0;
}

.floating-button {
z-index: 100;
position: absolute;
Expand Down
4 changes: 4 additions & 0 deletions src/meshweb/static/admin/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ function hideMapIfAppropriate() {
showMapButton.addEventListener("click", onShowMapClick, false);
}
} else {
// Hide the show map button
const showMapButton = document.getElementById('show_map_button');
showMapButton.classList.toggle("hidden");

const hideMapButton = document.getElementById("map_hide_button");

function onHideMapClick(event) {
Expand Down
18 changes: 18 additions & 0 deletions src/meshweb/static/admin/panel_view_nav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function checkIframed() {
// Check if we're in an iframe
const inIframe = window.self !== window.top;

// If not, show button
if (!inIframe) {
const panelViewButton = document.getElementById("navigate_to_panel_view");
panelViewButton.classList.toggle("hidden");

let panelURL = window.location.href;
console.log(panelURL);
panelURL = panelURL.replace("/admin", "/admin/panel");
console.log(panelURL);
panelViewButton.href = panelURL;
}
}

checkIframed();

0 comments on commit 33c38bb

Please sign in to comment.