Skip to content

Some improvements to Web Workflow static web pages #7869

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 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
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
Binary file removed supervisor/shared/web_workflow/static/blinka_16x16.ico
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion supervisor/shared/web_workflow/static/directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<title></title>
<meta charset="UTF-8">
<script src="/directory.js" defer=true></script>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css">
</head>
Expand All @@ -21,4 +20,5 @@ <h1><a href="/"><img src="/favicon.ico"/></a>&nbsp;<span id="path"></span></h1>
<label>Upload progress:<progress value="0"></progress></label>
<hr>
+📁&nbsp;<input type="text" id="name"><button type="submit" id="mkdir">Create Directory</button>
<script src="/directory.js" defer=true></script>
</body></html>
10 changes: 10 additions & 0 deletions supervisor/shared/web_workflow/static/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,13 @@ new_directory_name.oninput = () => {
}

window.onhashchange = refresh_list;

window.addEventListener("pageshow", function (event) {
var historyTraversal = event.persisted ||
(typeof window.performance != "undefined" &&
window.performance.navigation.type === 2);
if (historyTraversal) {
// Handle page restore.
window.location.reload();
}
});
3 changes: 2 additions & 1 deletion supervisor/shared/web_workflow/static/serial.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>Simple client</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/serial.js" defer=true></script>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css">
</head>
Expand All @@ -16,11 +15,13 @@
<div id="controls" style="flex: none; display: flex;">
<fieldset style="display: inline-block; padding: 0;">
<legend>Ctrl</legend>
<button id="b">B</button>
<button id="c">C</button>
<button id="d">D</button>
</fieldset>
<textarea id="input" rows="1" spellcheck="false" wrap="off" style="resize: none; flex: auto; font-size: 1rem;" autocapitalize="none" autocomplete="off" autocorrect="off"></textarea>
<button onclick="onSubmit(); return false;">Send</button>
</div>
<script src="/serial.js" defer=true></script>
</body>
</html>
11 changes: 11 additions & 0 deletions supervisor/shared/web_workflow/static/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ input.addEventListener("beforeinput", function(e) {
}
});

window.addEventListener("unload", function() {
if (ws.readyState == WebSocket.OPEN) {
ws.close();
}
});

let ctrl_b = document.querySelector("#b");
ctrl_b.onclick = function() {
ws.send("\x02");
}

let ctrl_c = document.querySelector("#c");
ctrl_c.onclick = function() {
ws.send("\x03");
Expand Down
2 changes: 1 addition & 1 deletion supervisor/shared/web_workflow/static/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<title>CircuitPython</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/welcome.js" defer=true></script>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css">
</head>
Expand All @@ -30,5 +29,6 @@ <h2>Device Info:</h2>
<h2>Here are other CircuitPython devices on your network:</h2>
<ul id="devices">
</ul>
<script src="/welcome.js" defer=true></script>
</body>
</html>
4 changes: 2 additions & 2 deletions supervisor/shared/web_workflow/web_workflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ STATIC_FILE(edit_js);
STATIC_FILE(style_css);
STATIC_FILE(serial_html);
STATIC_FILE(serial_js);
STATIC_FILE(blinka_16x16_ico);
STATIC_FILE(blinka_32x32_ico);

static void _reply_static(socketpool_socket_obj_t *socket, _request *request, const uint8_t *response, size_t response_len, const char *content_type) {
uint32_t total_length = response_len;
Expand Down Expand Up @@ -1303,7 +1303,7 @@ static bool _reply(socketpool_socket_obj_t *socket, _request *request) {
} else if (strcmp(request->path, "/favicon.ico") == 0) {
// TODO: Autogenerate this based on the blinka bitmap and change the
// palette based on MAC address.
_REPLY_STATIC(socket, request, blinka_16x16_ico);
_REPLY_STATIC(socket, request, blinka_32x32_ico);
} else {
_reply_missing(socket, request);
}
Expand Down