Modernize JS and tighten things#3388
Modernize JS and tighten things#3388PromoFaux merged 4 commits intopi-hole:developmentfrom XhmikosR:xmr/js
Conversation
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
Conflicts have been resolved. |
|
This is ready for review. I don't mark it as ready because I want to rebase to squash the autofix patches before the merge. Can someone please review so that we move forward? |
|
Tests are not passing and it's in draft status. It is not known if these failing conditions are intentional or not. |
|
All tests pass, it's CodeFactor that complains about the two/three TODO comments I have added that would be nice to address, but we can live with it for now if it helps moving forward. The PR is still in draft because I want to rebase the autofix patches before the merge. I only split them to make review easier. |
|
Okay, I don't remember offhand if changing from Draft to Ready will remove any existing approvals. Would it be better to set the PR as Ready with Squash for the merge strategy? |
|
It needs a manual rebase unfortunately. IIRC this report doesn't have the
enforcement you described.
…On Tue, Apr 22, 2025, 20:21 Dan Schaper ***@***.***> wrote:
Okay, I don't remember offhand if changing from Draft to Ready will remove
any existing approvals. Would it be better to set the PR as Ready with
Squash for the merge strategy?
—
Reply to this email directly, view it on GitHub
<#3388 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVLNNZ2VWHWLZL6ZPIECT22Z3BBAVCNFSM6AAAAAB2QVB7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMRRHE4TEMJUHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
*dschaper* left a comment (pi-hole/web#3388)
<#3388 (comment)>
Okay, I don't remember offhand if changing from Draft to Ready will remove
any existing approvals. Would it be better to set the PR as Ready with
Squash for the merge strategy?
—
Reply to this email directly, view it on GitHub
<#3388 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVLNNZ2VWHWLZL6ZPIECT22Z3BBAVCNFSM6AAAAAB2QVB7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMRRHE4TEMJUHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
| const XForwardedFor = globalThis.atob(advancedInfoSource.data("xff") ?? ""); | ||
| const starttime = parseFloat(advancedInfoSource.data("starttime")); | ||
| const endtime = parseFloat(advancedInfoSource.data("endtime")); | ||
| const XForwardedFor = globalThis.atob(advancedInfoSource.data("xff") || "") || null; |
There was a problem hiding this comment.
I note we go from a "If null then blank string" to "if null then blank string, but if that's null then null"
What difference is made here?
There was a problem hiding this comment.
This was wrong before. I changed it so that it gets properly set to null thus the line where it's checked can use the ?? operator.
$("#client-id").text(XForwardedFor ?? clientIP);
| timeLineChart.data.datasets.push({ | ||
| data: [], | ||
| // If we ran out of colors, make a random one | ||
| backgroundColor: colors[i], |
There was a problem hiding this comment.
I know this isn't part of your changeset, but how does colors[i] make a random one? Maybe a comment that no longer matches the code?
There was a problem hiding this comment.
Not sure if the comment is right TBH.
Lines 165 to 168 in f7a07c7
There was a problem hiding this comment.
It's possible that either the comment is wrong or the code wasn't copied from the other location fully.
Someone closer to the code here might be best placed to answer -though it's not a blocker for this PR.
There was a problem hiding this comment.
This was a copy paste error.
If you look at line 51 you will see colors[] has only 4 items. This is used for the first graphic (containing up to 4 items: Blocked, permitted, cached and other). This will never need extra random colors.
The comment about "creating random colors" was copied from lines 161-174, where random colors are actually created if there are more clients than available colors in THEME_COLORS[i].
There was a problem hiding this comment.
It's possible that either the comment is wrong or the code wasn't copied from the other location fully.
I think the code was initially copied (probably as a "template") and changed, but the comment was left.
The comment can be removed.
|
No blockers from a code point of view but I have not had time to test it yet (though I can't see anything that would cause any issues per se) Happy to ignore the TODO warnings from codefactor. I'm also not precious about squashing the commits, makes it easier to follow each change. |
Signed-off-by: XhmikosR <xhmikosr@gmail.com>
Signed-off-by: XhmikosR <xhmikosr@gmail.com>
|
Your call. I would squash the autofix patches because that's what I initially did, but not going to lose my sleep over it either :) |
|
This is the rebased branch development...XhmikosR:web:xmr/js-2. Let me know and I can force push it here. |
|
OK, given each page a look through - and everything appears to still be working. Please FP the branch you mentioned |
Signed-off-by: XhmikosR <xhmikosr@gmail.com>
Signed-off-by: XhmikosR <xhmikosr@gmail.com>
|
@XhmikosR can you push something to this PR please? Codefactor is being... annoying. Maybe close it, delete the branch and then recreate the PR? |
|
You will need to bypass Code factor because of the newly added TODO
comments.
…On Thu, Apr 24, 2025, 20:10 Adam Warner ***@***.***> wrote:
*PromoFaux* left a comment (pi-hole/web#3388)
<#3388 (comment)>
@XhmikosR <https://github.com/XhmikosR> can you push something to this PR
please? Codefactor is being... annoying. Maybe close it, delete the branch
and then recreate the PR?
—
Reply to this email directly, view it on GitHub
<#3388 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVLNM6O56H53YV4NR6RJT23ELJJAVCNFSM6AAAAAB2QVB7IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMRYGMYDSNBSG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yep - that's what I was trying to do, but had to uninstall it from the org and add it again. It's being really stupid. But I've got it back working for me at least now (nobody else can access the config though) |
|
Holy crap that was hard work |
This is #3338 rebased.
The changes are split but I want to squash the autofix-patches before merging.
Non-whitespace diff: https://github.com/pi-hole/web/pull/3388/files?w=1
TODO for this PR, feel free to push to this branch:
TODO for later, but feel free to push to this branch:
reduceAlready tackled in my jQuery branchfor...inusage. We should usefor...ofalong withObjectmethods because this way we only loop through own keys only so no need to check forObject.hasOwnglobalThisso that it's clearvaranymore from now on; this is now enforced by the xo ruleswe should enable strict mode; I'll try to fix this later, but xo by default enforcestype: moduleso it might be trickyThank you for your contribution to the Pi-hole Community!
Please read the comments below to help us consider your Pull Request.
We are all volunteers and completing the process outlined will help us review your commits quicker.
Please make sure you
What does this PR aim to accomplish?:
How does this PR accomplish the above?:
Link documentation PRs if any are needed to support this PR:
By submitting this pull request, I confirm the following:
git rebase)