Frontend for new SSH page #22
Loading…
Reference in a new issue
No description provided.
Delete branch "#7-multiple-ssh-keys"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Might need some final testing/changes
Closes #7
Going to give a review of this.
We know that it works fine so mostly formatting and naming
added 1 commit
9b9ea812
- fix : removed testing api endpoints with actualCompare with previous version
This is just a suggestion but I tend to go for
$common_$identifier
in my vars, so in this case it would be:This way its very easy to see related vars (this is mostly based on the fact that we read left to right)
Another option isntead of this would be to call
function get_keys()
here, to always ensure that the keys displayed here match teh database)Id say reduce the newlines here
Is this really needed?
Ideally each function has no external state like this.
Address will need to be updated
Could it be worth returning early?
Returning early helps to reduce nesting
Could be worth displaying the error:
This lets the backend set the message
You could have a call to a function in here to delete and re-create the table, making it ready for the keys.
Same as above
Again consider returning early to reduce nesting (like ye actually have on line 41)
Again, same as above
maybe just call this
row
?A more egronomic way of doign this would be
Basically this creates teh string directly instead of adding 3 strings together.
if some of the previous recommendations are taken (such as deleting and recreating teh table in "get keys") then this shouldnt be nessessary, right?
Seems ye pushed this patch out while I was reviewing
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in version 3 of the diff
changed this line in version 3 of the diff
added 1 commit
202c89ca
- fix : early return, logging errors into frontendCompare with previous version
Wouldn't this make allow for unnecessary calls to the api, when only one is needed. Remaking the table every time is also wasteful albeit not that much but still something. Imo some state > loss of performance.
Ye this is just a suggestion, there are pros and cons to both approaches (part of why I asked teh question was to make ye aware of it)
If your okay with keeping state, would prefer to keep this here. Some of it could be moved into the function but I think its better to keep it next to the listener and avoid calling the function to check.
Yep (kinda the stange area of it being state and at the same time not state)
(and newlines incresed?)
Was thinkin g more like this
added 1 commit
c6e07144
- fmt : newlineCompare with previous version
sorry(the formatter made me do it), fixed now
Tested everything again with mockoon, seems to be good. Might some more testing with the actual LDAP & backend server.
added 12 commits
compsoc1/skynet/ldap:main
a12bd3e0
- Merge branch 'main' of https://gitlab.skynet.ie/compsoc1/skynet/ldap/frontend...Compare with previous version
changed this line in version 6 of the diff
changed this line in version 6 of the diff
added 1 commit
7100dad7
- fix : moved ssh stuff int src/Compare with previous version
resolved all threads
added 2 commits
7c2a3e64
- fix : now can catch any errors thrown by awaiting req.json()cb806ad8
- fix : rename ssh.jsCompare with previous version
could ye remove the ssh option from the modify.html page?
and for the lib.js seems like a lot of changes, ye sure git picked up that it was whitespace changes?
added 1 commit
c215c710
- fix : remove ssh from modify page , added ssh page to index.htmlCompare with previous version
and for the lib.js seems like a lot of changes, ye sure git picked up that it was whitespace changes?
- unsure what this means, this is what lib.js looks like now.I am going off of https://gitlab.skynet.ie/compsoc1/skynet/ldap/frontend/-/merge_requests/12/diffs#diff-content-51615cdbd65f5e0f94e679f596b05006d3cfee15
added 1 commit
5f11bbce
- feat : changed post_request to be more general and return true/false based on responseCompare with previous version
Whats wrong with it?
Just home so can actually see it on computer.
See how there is a huge red and green block?
With teh contents near identical?
It is often best if thesse are avoided as it cna make going back through teh history tos ee why a change happened harder.
Why it happened here was because you made too many non-whitespace changes (and also introduced some possible bugs in the process).
So if ye replace it with (exactly (aside from indentation)) this:
if (req.status !== 200) {
to just above} catch (e) {
should eb indented.By doing so I am pretty sure the diff will be more concise
This will cause issues with L55
Still not fond of this.
Take a look at https://gitlab.skynet.ie/compsoc1/skynet/ldap/frontend/-/blob/main/src/signup.js?ref_type=heads
Ye can see how events are attached. (L3-L4)
Also this will also block the user from getting data from teh source of truth (backend).
Say for example they submit a key, the local table is updated but something happens in the backend that it dosent get added to the database.
But because the table gets updated here the user thinks that its all fine.
That is an edge case I would rather avoid.
If ye would rather not having to do anotehr get request after adding/deleting then it could be worth modifying the backend to return an array of all valid keys on sucessful modification.
That would mean on L45,L64 here ye could use the return value, delete the table and recreate it.
Say for example they submit a key, the local table is updated but something happens in the backend that it dosent get added to the database. But because the table gets updated here the user thinks that its all fine. That is an edge case I would rather avoid.
The code highlighted here isnt how the key actually gets added unless im misunderstanding, key only gets added when it returns true/success, so this edge case doesnt exist unless im misunderstanding your example.
Yeah i think this could easily be solved with some more state(dictionary), re constructing the keys might be a bit hard. Will have to look into it more in a few days, bit busy rn.
User presses the button a second time, data in the table remains unchanged (because the update is blocked by the flag)
Basically you are assuming that the local state matches the backend, I am pointing out that that assumption may be false.
Ye could always have the fullkey as the ID of the row or something, or even embedded in the delete button like on https://gitlab.skynet.ie/compsoc1/skynet/ldap/frontend/-/merge_requests/12/diffs#a9b67728c126b35b94bb66c258c6ffb01ae64cbe_0_93 ye could have a second parm there that is the key, passed in directly
The reason why I say that line specifically is because that function has the pure, unaltered key, splitting it apart and rejoining it isnt perfect (and makes its pwn assumptions that each key will have a comment)
Fun fact, the keys can be in the format of
command="link to script" ssh-rsa AAAAAAAAAAAA comment
mentioned in commit backend@96f86985eec772a835e7867852ee6452fd9548b6
added 1 commit
dcbce994
- Table now refreshes after deleting / adding keyCompare with previous version
Should be resolved now
Added keys as attribute fixed this atleast in my testing so far.
added 1 commit
318b4136
- fix : correct api endpointsCompare with previous version
added 1 commit
e4a48864
- fix : trailing slashCompare with previous version
resolved all threads
Code looks good now.
Main final thing is formatting.
Maybe add word wrap on the keys so it dosent go off screen.
Also ad a bit of a margin to all text in the table so its not banging up against the cell wall.
added 1 commit
0851e993
- fix : styling and word wrapCompare with previous version
added 1 commit
92a83a20
- fmt , made default textarea biggerCompare with previous version
Should be resolved now ☕
resolved all threads
All looks good to me
approved this merge request
mentioned in commit
36c5e5bbae