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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resource navigation buttons #293 #469

Merged
merged 5 commits into from
Jul 29, 2022
Merged

Add resource navigation buttons #293 #469

merged 5 commits into from
Jul 29, 2022

Conversation

lf32
Copy link

@lf32 lf32 commented Jul 22, 2022

Fixes #293

Fixes #293

Signed-off-by: Akhil Raj <lf32.dev@gmail.com>
Copy link
Contributor

@tdruez tdruez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments.
Also, your JavaScript code style is inconsistent. Some lines ends with ; while some do not.
In doubt, try to follow the codebase conventions when contributing ;)

scanpipe/templates/scanpipe/resource_detail.html Outdated Show resolved Hide resolved
scanpipe/templates/scanpipe/resource_detail.html Outdated Show resolved Hide resolved
scanpipe/templates/scanpipe/resource_detail.html Outdated Show resolved Hide resolved
@tdruez
Copy link
Contributor

tdruez commented Jul 25, 2022

Also, the logic of the code is broken somehow.
If I use the buttons in a given section, "Licenses" for examples, everything works fine, but if you start going to other section, the prev/next is acting weird.

Signed-off-by: Akhil Raj <lf32.dev@gmail.com>
@lf32
Copy link
Author

lf32 commented Jul 28, 2022

Also, the logic of the code is broken somehow. If I use the buttons in a given section, "Licenses" for examples, everything works fine, but if you start going to other section, the prev/next is acting weird.

Yes @tdruez, got it fixed in the cd674fb commit

Signed-off-by: Akhil Raj <lf32.dev@gmail.com>
Copy link
Contributor

@tdruez tdruez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new buttons UI look good.

I think the "Next" button should be disabled if there's only 1 match.

<p>
{{ object.name }}
| {{ object.size|filesizeformat }}
| <a class="has-text-white" href="{{ object.get_raw_url }}?as_attachment=1"><i class="fas fa-download"></i></a>
<br>
<span style="font-size: 10px;">{{ object.path }}</span>
</p>
<div>
<button class="button prev-btn is-dark" disabled onclick="previousValue();"><i class="fas fa-arrow-up"></i>&nbsp;Prev</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Previous" is better than "Prev".

Copy link
Author

@lf32 lf32 Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @tdruez.

Copy link
Author

@lf32 lf32 Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

<p>
{{ object.name }}
| {{ object.size|filesizeformat }}
| <a class="has-text-white" href="{{ object.get_raw_url }}?as_attachment=1"><i class="fas fa-download"></i></a>
<br>
<span style="font-size: 10px;">{{ object.path }}</span>
</p>
<div>
<button class="button prev-btn is-dark" disabled onclick="previousValue();"><i class="fas fa-arrow-up"></i>&nbsp;Prev</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline JavaScript is not consistent with the rest of the codebase, keep the function but assign the click action using the addEventListener.

Copy link
Author

@lf32 lf32 Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added eventlisteners for buttons.

<p>
{{ object.name }}
| {{ object.size|filesizeformat }}
| <a class="has-text-white" href="{{ object.get_raw_url }}?as_attachment=1"><i class="fas fa-download"></i></a>
<br>
<span style="font-size: 10px;">{{ object.path }}</span>
</p>
<div>
<button class="button prev-btn is-dark" disabled onclick="previousValue();"><i class="fas fa-arrow-up"></i>&nbsp;Prev</button>
<button class="button next-btn is-dark" disabled onclick="nextValue();"><i class="fas fa-arrow-down"></i>&nbsp;Next</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use &nbsp; for formatting/rendering. If you want some space between 2 elements, use the mr-* CSS classes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

{% endblock %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please configure your editor to stop adding blank line for template files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need a blank line at the end of files?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for templates.

Copy link
Author

@lf32 lf32 Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then, I'll fix this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

if (valueIndex >= detected_data.length - 1) return false;
valueIndex++;
editor.renderer.scrollToLine(detected_data[valueIndex].start_line - 1);
nextBtn.disabled = (valueIndex == detected_data.length - 1) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified to valueIndex == detected_data.length - 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

if (valueIndex <= 0) return false;
valueIndex--;
editor.renderer.scrollToLine(detected_data[valueIndex].start_line - 1);
prevBtn.disabled = (valueIndex == 0) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified to valueIndex == 0.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

@@ -102,28 +106,55 @@
editor.getSession().setAnnotations(annotations);
}

const $selectionButtons = getAll('.tabs a');
let valueIndex = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scrollPositionIndex maybe?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, fixed this.

Comment on lines 61 to 70
mode: "ace/mode/text",
autoScrollEditorIntoView: true,
wrap: true,
readOnly: true,
showPrintMargin: false,
highlightActiveLine: false,
highlightGutterLine: false,
fontSize: 15,
foldStyle: "manual",
fontFamily: "SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not change existing style conventions but adapt to it.

Copy link
Author

@lf32 lf32 Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation using prettifier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert and adapt to the existing style.
You're making the code review process more painful with those unwanted changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been using tab of 4 spaces, just switched to 2.

lf32 added 2 commits July 29, 2022 11:59
Signed-off-by: Akhil Raj <lf32.dev@gmail.com>
Signed-off-by: Akhil Raj <lf32.dev@gmail.com>
@tdruez tdruez merged commit 7d084c7 into main Jul 29, 2022
@tdruez tdruez deleted the resources-nav branch July 29, 2022 08:40
@tdruez
Copy link
Contributor

tdruez commented Jul 29, 2022

Thanks for your contribution @lf32 !

@lf32
Copy link
Author

lf32 commented Jul 29, 2022

Thanks for the merge @tdruez!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web UI: It is difficult to find a detected license when browsing a larger file
2 participants