mirror of https://github.com/MISP/MISP
new: Add search shortcut for events and attributes + fix bug that triggered shortcuts when dropdown menus were focused
parent
6d79a08b22
commit
4a38cb3d6a
|
@ -93,5 +93,6 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" class="keyboardShortcutsConfig" value="/shortcuts/event_index.json" />
|
||||
<?php
|
||||
if (!$ajax) echo $this->element('side_menu', array('menuList' => 'event-collection', 'menuItem' => 'index'));
|
||||
|
|
|
@ -3269,6 +3269,7 @@ let keyboardShortcutsManager = {
|
|||
|
||||
shortcutKeys: new Map(),
|
||||
shortcutListToggled: false,
|
||||
escapedTagNames: ["INPUT", "TEXTAREA", "SELECT"],
|
||||
|
||||
/**
|
||||
* Fetches the keyboard shortcut config files and populates this.shortcutJSON.
|
||||
|
@ -3303,7 +3304,7 @@ let keyboardShortcutsManager = {
|
|||
addShortcutListToHTML() {
|
||||
let html = "<ul>";
|
||||
for(let shortcut of this.shortcutKeys.values()) {
|
||||
html += `<li><strong>${shortcut.key}</strong>: ${shortcut.description}</li>`
|
||||
html += `<li><strong>${shortcut.key.toUpperCase()}</strong>: ${shortcut.description}</li>`
|
||||
}
|
||||
html += "</ul>"
|
||||
$('#shortcuts').html(html);
|
||||
|
@ -3327,7 +3328,7 @@ let keyboardShortcutsManager = {
|
|||
window.onkeyup = (keyboardEvent) => {
|
||||
if(this.shortcutKeys.has(keyboardEvent.key)) {
|
||||
let activeElement = document.activeElement.tagName;
|
||||
if( activeElement !== "TEXTAREA" && activeElement !== "INPUT") {
|
||||
if( !this.escapedTagNames.includes(activeElement)) {
|
||||
eval(this.shortcutKeys.get(keyboardEvent.key).action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"shortcuts": [
|
||||
{
|
||||
"key": "s",
|
||||
"description": "Focus the filter events bar",
|
||||
"action": "$('#quickFilterField').focus()"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -13,7 +13,12 @@
|
|||
{
|
||||
"key": "a",
|
||||
"description": "Add an attribute",
|
||||
"action": "console.log($('#liaddAttribute').children()[0].click())"
|
||||
"action": "$('#liaddAttribute').children()[0].click()"
|
||||
},
|
||||
{
|
||||
"key": "s",
|
||||
"description": "Focus the filter attribute bar",
|
||||
"action": "$('#attributesFilterField').focus()"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue