Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub-style filter for columns (fix #37) #58

Merged
merged 32 commits into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5428fa0
Separate data of table from its UI handling
Ethkuil Feb 10, 2023
1089205
Add GitHub-style filter for columns
Ethkuil Feb 10, 2023
62e94c0
Adjust position of filter box
Ethkuil Feb 13, 2023
2318d5f
Apply change in filter field automatically
Ethkuil Feb 13, 2023
1967f20
Edit the placeholder of filter field
Ethkuil Feb 13, 2023
e3fc24a
Fix wrong message display after filtering
Ethkuil Feb 23, 2023
c51abe2
Update the way to deal with invalid filter pattern
Ethkuil Feb 23, 2023
2a8616d
Fix logic to parse filter pattern
Ethkuil Feb 26, 2023
120a681
Replace "Export table as CSV" with "Export table below as CSV"
Ethkuil Feb 26, 2023
9c446d3
Add single-letter aliases for each column
Ethkuil Mar 1, 2023
0ca2586
Fix bug of overwriting error msg with empty msg
Ethkuil Mar 5, 2023
c511135
Show and hide filter field automatically
Ethkuil Mar 6, 2023
6b2f980
Apply little refactor and formatting
Ethkuil Mar 7, 2023
985843b
Fix small formatting issue
payne911 Mar 7, 2023
26cff66
Reducing area of "git blame"
payne911 Mar 7, 2023
96c7c83
Add some more aliases
payne911 Mar 15, 2023
f7363da
Tooltip for the search field
payne911 Mar 15, 2023
c296c9b
Fix incompatibility with progress bar display
Ethkuil Mar 15, 2023
199c24d
Separete scaning state msgs from non-error msgs
Ethkuil Mar 16, 2023
dd898a8
Make the filter function global
Ethkuil Mar 17, 2023
86d555a
style
payne911 Mar 22, 2023
229d0ce
Avoid querying a duplicated result (resolve #59)
payne911 Mar 22, 2023
909e35a
Remove the ahead filter from the settings
payne911 Mar 22, 2023
9217b48
Less emphasis on the filter field
payne911 Mar 22, 2023
ad2ea73
Dynamically adjust the appearance of the filter field
payne911 Mar 22, 2023
2d25117
Fix filter update
Ethkuil Mar 22, 2023
52e3d8c
Adding a comment
payne911 Mar 23, 2023
bb44d78
Change filtering syntax to be simpler
payne911 Mar 24, 2023
610fabd
Extract constants out of for-loops
payne911 Mar 24, 2023
dd064ba
Extract repeated value for better maintainability
payne911 Mar 24, 2023
ede116b
Extract the date regex
payne911 Mar 24, 2023
b6c6312
Update date regex to be more robust
payne911 Mar 25, 2023
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
24 changes: 6 additions & 18 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,6 @@
<section class="modal-card-body">
<p>Settings will be saved on your local browser and will apply to your future queries.</p><br/>

<!-- Amount of commit diffs for the automatic filtering. -->
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Ahead filter:</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input id="uf_settings_filter" class="input is-small is-fullwidth has-tooltip-arrow"
type="number" value="0" min="1"
placeholder="Default is 0" required>
</div>
<p class="help mb-2"><strong>Default is 0.</strong> If the amount of 'ahead' commits is less than or equal to this value, the fork is automatically removed from the list.</p>
</div>
</div>
</div>

<!-- Relationship used for the commit diff count. -->
<div class="field is-horizontal">
<div class="field-label is-normal">
Expand Down Expand Up @@ -195,7 +178,7 @@
Display
</label>
</div>
<p class="help mb-2"><strong>Default is checked.</strong> Determines whether to display or not the "<span class="is-family-monospace">Export table as CSV</span>" button when a scan ends.</p>
<p class="help mb-2"><strong>Default is checked.</strong> Determines whether to display or not the "<span class="is-family-monospace">Export table below as CSV</span>" button when a scan ends.</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -231,6 +214,11 @@
</button>
</p>
</div>
<div class="control" id="filterContainer" hidden>
<input class="input" type="text" id="filter" name="filter"
title='There are aliases too (e.g. "a" for "ahead", "d" for the date, etc.). There is an implicit AND boolean operator in between each filter.'
placeholder="Type your filter here. eg: ahead>=1 behind<5" />
</div>
</div>
</div>
<div class="container" id="useful_forks_inject">
Expand Down
12 changes: 4 additions & 8 deletions website/src/csv-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@ const EXPORT_DIV_BTN = "uf_csv_export_btn";
const EXPORT_BTN = $('<a>', {id: EXPORT_DIV_BTN, class: "button is-dark is-outlined is-small"})
.attr("href", "#")
.prepend($('<img>', {src: "assets/csv_dl.svg", class: "mr-2", alt: "csv", width: "26", height: "26"}))
.append("Export table as CSV");
.append("Export table below as CSV");
const EXPORT_DIV = $('<div>', {id: EXPORT_DIV_ID, class: "mt-2"}).append(EXPORT_BTN);


function displayCsvExportBtn() {
if (!UF_SETTINGS_CSV_DISPLAY) {
return;
}
if (!tableIsEmpty()) {
JQ_ID_HEADER.append(EXPORT_DIV);
setClickEvent();
}
JQ_ID_HEADER.append(EXPORT_DIV);
setClickEvent();
}
function hideExportCsvBtn() {
if (!UF_SETTINGS_CSV_DISPLAY) {
return;
}
if (!tableIsEmpty()) {
getJqId_$(EXPORT_DIV_ID).remove();
}
getJqId_$(EXPORT_DIV_ID).remove();
}
function setClickEvent() {
EXPORT_BTN.on('click', function (event) {
Expand Down
37 changes: 35 additions & 2 deletions website/src/queries-init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const SELF_URL = "https://useful-forks.github.io/";

const JQ_REPO_FIELD = $('#repo');
const JQ_FILTER_FIELD = $('#filter');
const JQ_FILTER_CONTAINER = $('#filterContainer');
const JQ_SEARCH_BTN = $('#searchBtn');
const JQ_TOTAL_CALLS = $('#totalApiCalls');

Expand All @@ -21,11 +23,15 @@ const UF_MSG_API_RATE = "<b>GitHub API rate-limits exceeded.</b> Consider pr
// list of messages which should not be cleared when the request ends
const UF_PRESERVED_MSGS = [
UF_MSG_NO_FORKS,
UF_MSG_EMPTY_FILTER,
Ethkuil marked this conversation as resolved.
Show resolved Hide resolved
UF_MSG_ERROR,
UF_MSG_API_RATE
];

// messages about the current state of the scan but not about the results
const UF_MSGS_SCAN_STATE = [
UF_MSG_SCANNING,
UF_MSG_SLOWER
];

const EXAMPLE_LINK_1 = `<a href="${buildAutoQueryURL('payne911/PieMenu')}"
onclick="ga_shortExampleLink();">payne911/PieMenu</a>`;
Expand Down Expand Up @@ -102,18 +108,30 @@ function setMsg(msg) {
.css("border-color", "rgba(0,0,0,0.25)")
.css("border-style", "solid");
}

function isMsgEmpty() {
return JQ_ID_MSG.html() === "";
}

function clearMsg() {
JQ_ID_MSG
.empty()
.removeClass("box")
.css("border-style", "");
removeProgressBar();
}
function clearNonErrorMsg() {
const msg = JQ_ID_MSG.html();
if (!UF_PRESERVED_MSGS.includes(msg))
clearMsg();
}

function clearNonScanStateMsg() {
const msg = JQ_ID_MSG.html();
if (!UF_MSGS_SCAN_STATE.includes(msg) && !UF_PRESERVED_MSGS.includes(msg)) {
clearMsg();
}
}

function setHeader(msg) {
JQ_ID_HEADER.html(msg);
}
Expand Down Expand Up @@ -151,6 +169,21 @@ function getQueryOrDefault(defaultVal) {
return JQ_REPO_FIELD.val();
}

function hideFilterContainer() {
JQ_FILTER_CONTAINER.hide();
}

function showFilterContainer() {
JQ_FILTER_CONTAINER.show();
}

function getFilterOrDefault(defaultVal) {
if (!JQ_FILTER_FIELD.val()) {
JQ_FILTER_FIELD.val(defaultVal);
}
return JQ_FILTER_FIELD.val();
}

function setApiCallsLabel(total) {
JQ_TOTAL_CALLS.html(total + " calls");
}
Expand Down
Loading