Skip to content

Commit dfcca73

Browse files
committed
add SHIFT+S key-combination for quick-save (fix #71)
1 parent 095ba24 commit dfcca73

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Version 0
44

5+
### 0.0.25
6+
7+
* Disable data-refresh if in background
8+
* Allow to save current form by using SHIFT+S
9+
10+
----
11+
512
### 0.0.24-2
613

714
* Cleanup job-stati on startup

docs/source/usage/4_config.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
4 - Config
77
==========
88

9+
**Tip**: You can use the key-combination :code:`SHIFT + S` to quick-safe your changes.
10+
911
WebUI
1012
*****
1113

src/ansibleguy-webui/aw/static/js/aw.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,20 @@ function capitalizeFirstLetter(string) {
238238
return string.charAt(0).toUpperCase() + string.slice(1);
239239
}
240240

241+
pressed_shift = false;
242+
function shift_s_handler() {
243+
for (let f of document.getElementsByTagName('form')) {
244+
if (f.action.includes('/api')) {
245+
// NOTE: form.submit is not working as we want to catch it later on
246+
let saveButtons = f.querySelectorAll("button[title=Save]");
247+
if (saveButtons.length > 0) {
248+
saveButtons[0].click();
249+
}
250+
}
251+
}
252+
$('html, body').animate({ scrollTop: 0 }, 'fast');
253+
}
254+
241255
// API CALLS
242256
const CSRF_TOKEN = getCookie('csrftoken');
243257

@@ -534,4 +548,17 @@ $( document ).ready(function() {
534548
$(".aw-main").on("input", ".aw-fs-exists", function(){
535549
apiFsExists(jQuery(this));
536550
});
551+
$(document).on("keyup", function(e){
552+
if (e.keyCode == 16) {
553+
pressed_shift = false;
554+
}
555+
});
556+
$(document).on("keydown", function(e){
557+
if (e.keyCode == 16) {
558+
pressed_shift = true;
559+
}
560+
if (e.keyCode == 83 && pressed_shift === true) {
561+
shift_s_handler();
562+
}
563+
});
537564
});

0 commit comments

Comments
 (0)