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

display Fetch Job stats via icon click #114

Merged
merged 7 commits into from
Jun 4, 2021
Merged

Conversation

peterVG
Copy link
Member

@peterVG peterVG commented Feb 21, 2021

Making use of the Fetch Job statistics that are already being stored in the database, this commit displays them on the Storage Service template. Rather than clutter the screen with stats for multiple Fetch Jobs, it only reveals the stats when clicking an Info icon. Clicking the icon again re-hides the stats info.

Connected to #47

@peterVG peterVG requested review from tw4l and ross-spencer February 21, 2021 20:04
@peterVG peterVG changed the title display Fetch Job stats via icon hover display Fetch Job stats via icon click Feb 24, 2021
Copy link
Contributor

@tw4l tw4l left a comment

Choose a reason for hiding this comment

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

Hi @peterVG - this is looking great! I've left some suggestions and a few nits, but this is already solid so I'm approving and you can make those changes before squashing and merging. Nice work! 💪

<td>{{ mets_fetch_job.total_packages }}</td>
<td>{{ mets_fetch_job.total_packages }} packages
<i class="fa fa-info-circle fa-lg" id="{{ mets_fetch_job.id }}" style="margin-left: 5px;"></i><br/>
<div id="stats-{{ mets_fetch_job.id }}" class="stats" style="font-size:80%; color: #999;">
Copy link
Contributor

@tw4l tw4l Feb 25, 2021

Choose a reason for hiding this comment

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

I'd recommend using Bootstrap tags and classes instead of a custom style tag to manage the styles. So for instance, inside this <div> you could do something like

<span class="text-muted">
  <small>
    {{ mets_fetch_job.total_aips }} AIPs<br>
    {{ mets_fetch_job.total_sips }} SIPs<br>
    {{ mets_fetch_job.total_dips }} DIPs<br>
    {{ mets_fetch_job.total_replicas }} replicated AIPs<br>
    {{ mets_fetch_job.total_replicas }} deleted AIPs
  </small>
</span>

We do that elsewhere in the code base as well, e.g.: https://github.com/artefactual-labs/AIPscan/blob/main/AIPscan/Reporter/templates/report_largest_files.html#L74. The main advantage this change would give is if we want to change what our text-muted style looks like, we can do so in one place and have it apply to the whole project.

Full transparency, this on my mind because I think the low contrast might be a bit of an accessibility issue, and so we might want to find a less-muted shade of grey. But that's a codebase-wide issue and might be better addressed in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, custom inline CSS is a bad temp hack. Thanks for this cleanup suggestion. Done.

@@ -49,7 +49,16 @@
<tr>
<td>{{ mets_fetch_job.download_start }}</td>
<td>{% if mets_fetch_job.download_end %} {{ mets_fetch_job.download_end - mets_fetch_job.download_start }} {% endif %}</td>
<td>{{ mets_fetch_job.total_packages }}</td>
<td>{{ mets_fetch_job.total_packages }} packages
<i class="fa fa-info-circle fa-lg" id="{{ mets_fetch_job.id }}" style="margin-left: 5px;"></i><br/>
Copy link
Contributor

Choose a reason for hiding this comment

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

For HTML5, the preferred line break tag is <br>, no trailing space/slash needed: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/br

Copy link
Member Author

Choose a reason for hiding this comment

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

themoreyouknow

Copy link
Member Author

Choose a reason for hiding this comment

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

I learned basic HTML back in the 90's and this was considered very important (yet totally irrelevant in the end) practice.

{{ mets_fetch_job.total_aips }} AIPs <br />
{{ mets_fetch_job.total_sips }} SIPs <br />
{{ mets_fetch_job.total_dips }} DIPs <br />
{{ mets_fetch_job.total_replicas }} replicated AIPs <br />
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: We often call these "replicated AIPs", but it's a bit ambiguous whether that means the original or the replica. I think it might be more accurate or at least unambiguous to call them "AIP replicas".

Copy link
Member Author

Choose a reason for hiding this comment

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

+1 Yes agreed.

Copy link
Member Author

@peterVG peterVG Jun 4, 2021

Choose a reason for hiding this comment

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

Also, great nit-picking. I do this kind of semantic hair splitting all the time and appreciate it when others do it too. Accuracy is in our field is important. Starting with how we describe and display the features in our systems.

Comment on lines 79 to 85
$('.stats').hide();
$('.fa-info-circle').click(function() {
if($('#stats-'+this.id).is(':visible'))
$('#stats-'+this.id).hide();
else
$('#stats-'+this.id).show();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Succinct, readable, and effective - nice job!

One minor nit/linting issue is that it'd be great to have opening and closing curly braces aligned - these are fairly small closures so not an immediate practical need maybe, but having them properly aligned really helps with readability when code grows. In practical terms I think it would just mean moving the closing });s here two spaces to the left.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the sort of thing that we will ideally eventually have a JS linter to help spot (and potentially even auto-correct for us, like black does for our Python). And it's absolutely a nit, so I'll leave it up to you to decide if it's worth the time.

Copy link
Member Author

@peterVG peterVG Jun 4, 2021

Choose a reason for hiding this comment

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

I'll take any suggestions on improving the readability of Javascript / JQuery, lol.
Have we shortlisted JS Linters yet? I'll gladly install one.

I was actually trying to be consitent with 2-space indents on my JS code but this just goes to show how impossible that is to maintain manually without a Linter. I fixed the indent issue you found. There are probably more :-)

Screen Shot 2021-06-04 at 10 45 07 AM

@peterVG peterVG merged commit 4d4ba90 into main Jun 4, 2021
@mcantelon mcantelon deleted the dev/package-stats-GUI branch February 14, 2023 23:44
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.

2 participants