-
Notifications
You must be signed in to change notification settings - Fork 23
Update Admin Panel to work via iframes #799
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
d238b5b
wrap admin panel in iframe
WillNilges 3a867d2
slightly better
WillNilges 8577796
Extract object info and query it with the meshdb API
WillNilges dc55709
Move script to its own file
WillNilges 7db0687
Now if only I could get my admin map to behave
WillNilges 3fb5d51
Aha, I have to listen for messages
WillNilges 4eb5e15
Victory
WillNilges d545a8b
Allow map to change location of admin panel
WillNilges 1099bf4
Refactor style sheets
WillNilges c0c8983
Restore map.js
WillNilges f20e2a6
make it not crash
WillNilges 98baeba
Update environment variables
WillNilges d016323
Checkpoint: Subway refactor. This works!?
WillNilges 35a1c3e
another checkpoint
WillNilges e64d4c7
another checkpoint: going to refactor iframe_panel to admin_panel_iframe
WillNilges b007f38
Capture back button requests
WillNilges 3be7d48
Delete dead code
WillNilges 357fa37
getting the map to be resizable through css
WillNilges 35d1a44
computers are fucking dumb;
WillNilges b6cd4b4
some cleanup
WillNilges 9fd0a2c
debugging weird flow control stuff
WillNilges 93bf978
OK I think we have feature pairity
WillNilges eedd693
Pick up where we left off (protect against refreshes)
WillNilges 8b21202
Pass URL through to the Admin Panel iFrame
WillNilges 3e21134
Ope my code sucks
WillNilges 3c6cc25
I have no idea what is going on
WillNilges e79ad04
Fix admin panel using relative URLs
WillNilges 2fde80d
refactoring checkpoint
WillNilges d2f516e
Refactoring checkpoint 2
WillNilges 52db0e0
Strip 'panel' out of get_admin_url
WillNilges 27b0919
Skip iframe in search tests
WillNilges 75c25a3
same for list
WillNilges 5409788
same for change
WillNilges 4358d7c
Lint
WillNilges 149637e
Delete a bunch of stuff
WillNilges 3564bf2
checkpoint: delete more things
WillNilges 6d37aa9
fix layout issues
WillNilges 69ace4c
Swap /admin and /admin/panel
WillNilges 63dded2
Revert "same for change"
WillNilges f52d1cb
Revert "same for list"
WillNilges 8d37570
Revert "Skip iframe in search tests"
WillNilges dee6453
Add simple test
WillNilges eb9e896
Add a slightly more complex test
WillNilges 2a65892
Acutally, just add one test. See comment as to why
WillNilges da6abd4
whoops
WillNilges 33c38bb
Add a way to get to /admin/panel and update map button logic
WillNilges c46f4dd
Swap /admin out from under users
WillNilges 307222d
Fix URL if user goes to /admin/panel, I should probs make the URL a v…
WillNilges 820893a
Refactor
WillNilges 7ec13d0
andrew comments 1: Restore password reset, remove state override, fix…
WillNilges f42e5d7
andrew comments 2: Path
WillNilges 2058a85
lint
WillNilges 09cba15
Redirect top to login on logout
WillNilges 57e5908
Move iframe escape logic to onAdminPanelLoad
WillNilges f3b67a6
Make clicking an los work
WillNilges 764eec1
Fixes, disable map if on mobile
WillNilges 78a2221
Remove override that was breaking mobile
WillNilges c4825dc
Update src/meshweb/static/admin/iframe_check.js
WillNilges c0dcf94
Update src/meshweb/static/admin/map.js
WillNilges 6051f88
Fix variable and delete log lines
WillNilges d5eb255
Merge branch 'main' into wdn/map-iframe-2
WillNilges File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{% load static %} | ||
|
||
{% load env_extras %} | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script>let MAP_BASE_URL = "{% get_env_var 'ADMIN_MAP_BASE_URL' %}";</script> | ||
<link rel="stylesheet" href="{% static '/admin/iframed.css'%}"/> | ||
|
||
<link rel="stylesheet" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}"> | ||
{% block dark-mode-vars %} | ||
<link rel="stylesheet" href="{% static "admin/css/dark_mode.css" %}"> | ||
<script src="{% static "admin/js/theme.js" %}" defer></script> | ||
{% endblock %} | ||
<link rel="stylesheet" href="{% static "/admin/admin_ext.css" %}"> | ||
|
||
</head> | ||
<body> | ||
<div id="page_container"> | ||
<div id="admin_panel_div" class="frameGrow"> | ||
<iframe src="panel" id="admin_panel_iframe" class="frameGrow"></iframe> | ||
</div> | ||
|
||
<div class="floating-button"> | ||
<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> | ||
</div> | ||
|
||
<div id="map_controls"> | ||
<!-- This handle is always visible, unless you're resizing, in which case | ||
goes big and invisible to block the iframes from stealing focus --> | ||
<div class="handle" id="handle"> | ||
<span class="vert-align-helper"></span> | ||
<img class="handlebar" id="handlebar" src="{% static '/admin/map/img/handlebar.svg' %}" height="60px"/> | ||
</div> | ||
<!-- Only shows up during resizes --> | ||
<div class="handle hiddenDuringResize" id="substituteHandle"> | ||
<span class="vert-align-helper"></span> | ||
<img class="handlebar" id="substituteHandlebar" src="{% static '/admin/map/img/handlebar.svg' %}" height="60px"/> | ||
</div> | ||
<div class="floating-button"> | ||
<a href="#" class="button" style="display: inline-block" id="map_hide_button"> | ||
<img src="{% static '/admin/map/img/cross.png' %}" height="24px" title="Hide Map"> | ||
</a> | ||
</div> | ||
<div class="floating-button-below"> | ||
<a href="#" class="button" style="display: inline-block" id="map_recenter_button"> | ||
<img src="{% static '/admin/map/img/recenter.png' %}" height="24px" title="Recenter map"> | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<div id="map_panel_div"> | ||
<iframe src="{% get_env_var 'ADMIN_MAP_BASE_URL' %}" id="map_panel"></iframe> | ||
</div> | ||
</div> | ||
<script src="{% static '/admin/map.js' %}"></script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Embedded Page</title> | ||
</head> | ||
<body> | ||
<h2>Embedded</h2> | ||
<textarea cols="30" rows="10" disabled id="output">waiting</textarea> | ||
<input type="text" id="field" /> | ||
<button id="send">Send</button> | ||
<script> | ||
// set up references to DOM nodes | ||
const output = document.getElementById("output"); | ||
const button = document.getElementById("send"); | ||
const field = document.getElementById("field"); | ||
|
||
// create a variable for the parent window. We will assign it once we get the first message. | ||
let parent = null; | ||
|
||
// add an event listener to send messages when the button is clicked | ||
button.addEventListener("click", () => { | ||
// don't do anything if there is no parent reference yet | ||
if (parent === null) { | ||
return; | ||
} | ||
|
||
// otherwise get the field text, and send it to the parent | ||
const text = field.value; | ||
parent.postMessage(text); | ||
}); | ||
|
||
// add an event listener to run when a message is received | ||
window.addEventListener("message", ({ data, source }) => { | ||
console.log("Got message."); | ||
// if we don't have a reference to the parent window yet, set it now | ||
if (parent === null) { | ||
parent = source; | ||
} | ||
|
||
// now we can do whatever we want with the message data. | ||
// in this case, displaying it, and then sending it back | ||
// wrapped in an object | ||
output.textContent = JSON.stringify(data); | ||
const response = { | ||
success: true, | ||
request: { data }, | ||
}; | ||
parent.postMessage(response); | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.shortcuts import render | ||
from django.contrib.admin.views.decorators import staff_member_required | ||
|
||
@staff_member_required | ||
def admin_iframe_view(request): | ||
return render(request, 'admin/iframed.html') | ||
|
||
|
||
@staff_member_required | ||
def minimal_example_view(request): | ||
return render(request, 'admin/minimal_example.html') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
iframe { | ||
height: 100%; | ||
width: 100%; | ||
border: none; | ||
z-index: 1; | ||
} | ||
|
||
.frameGrow { | ||
flex-grow: 1; | ||
border: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#page_container { | ||
display: flex; | ||
flex-direction: row; | ||
height: 100%; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.