-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from moov-io/file-filter-pattern
webui: basic exact pattern filtering when listing files
- Loading branch information
Showing
9 changed files
with
133 additions
and
210 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,32 @@ | ||
window.onload = function() { | ||
// Register a handler on the filter form | ||
var form = document.querySelector("#filter"); | ||
form.addEventListener("keydown", function (event) { | ||
if (event.key === "Enter") { | ||
event.preventDefault(); | ||
|
||
var filenameElm = document.querySelector("#filename"); | ||
filterFileListing(filenameElm.value); | ||
} | ||
}); | ||
|
||
// Populate the filter with any current pattern from the URL | ||
populateCurrentPatternForm(); | ||
}; | ||
|
||
function filterFileListing(pattern) { | ||
const url = new URL(window.location.href); | ||
url.searchParams.set("pattern", pattern); | ||
|
||
window.location.href = url.toString(); // redirect | ||
} | ||
|
||
function populateCurrentPatternForm() { | ||
const url = new URL(window.location.href); | ||
|
||
const currentPattern = url.searchParams.get("pattern"); | ||
if (currentPattern) { | ||
var filenameElm = document.querySelector("#filename"); | ||
filenameElm.value = currentPattern; | ||
} | ||
} |
This file contains 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