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

DEV UI Enhancing the Scores Page in RESTEasy Reactive #15384

Merged
merged 1 commit into from
Mar 12, 2021

Conversation

saumya1singh
Copy link
Contributor

This is draft PR for issue #15322 :)

CC @FroMage @geoand @phillip-kruger

@geoand
Copy link
Contributor

geoand commented Mar 1, 2021

I'll let @phillip-kruger follow up on this since I don't know anything about CSS nor do I have any artistic talent :)

@saumya1singh
Copy link
Contributor Author

So, Interestingly it took only 15 minutes to understand accordion and another 15 to implement it on a separate project - https://github.com/SaumyaSingh1/accordian-demo
But while doing the same on the Scores Page, I took much time 🙈

Right now after adding accordion, my page is like this :
image
image

I am liking frontend work :)
I am looking forward to adding the Gauge per score. Then other meta-data in tabular form as @phillip-kruger advised :)

@phillip-kruger
Copy link
Member

I like it ! Better than what we have at the moment, right ?

@saumya1singh
Copy link
Contributor Author

Yeah, I am now doing my research for the gauge part :)

Copy link
Member

@phillip-kruger phillip-kruger left a comment

Choose a reason for hiding this comment

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

LGTM

@gsmet
Copy link
Member

gsmet commented Mar 1, 2021

I think it's a bit of a shame we lose the color indicator in the main view? It was a good visual hint.

@saumya1singh
Copy link
Contributor Author

saumya1singh commented Mar 1, 2021

I think it's a bit of a shame we lose the color indicator in the main view? It was a good visual hint.

I will add that, it is not final yet. It is on the to-do!
Have to add several changes :)

@phillip-kruger
Copy link
Member

Yea maybe make the percentage in color ?

@saumya1singh
Copy link
Contributor Author

Yea maybe make the percentage in color ?

of course, this is the plan.
You explained this earlier as well & this is in my mind :)

@saumya1singh
Copy link
Contributor Author

And even if that will not look much cool so we will put that in the badge inside span as was already there :)

@geoand
Copy link
Contributor

geoand commented Mar 2, 2021

Also, don't forget to update https://quarkus.io/guides/dev-ui when you are done

@saumya1singh
Copy link
Contributor Author

Also, don't forget to update https://quarkus.io/guides/dev-ui when you are done

sure
Thanks for letting me know, oh then I need to do it for the Endpoints Page as well, that has been changed a lot. Right? @geoand @FroMage

Today was looking at the Prod issue, understood Jenkins flow 🙈 so didn't get time to work on this :) will get back here maybe tomorrow or a day after that.

@geoand
Copy link
Contributor

geoand commented Mar 2, 2021

No rush at all.

Yeah, when you do update the docs, include all updates

gauge.querySelector(".gauge__cover").textContent = `${Math.round(value * 100)}%`;
}

setGaugeValue(gaugeElement, \{diagnostic.score}/100);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line @mkouba
Replacing {diagnostic.score} with numeric value is working fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so you can either remove the unparsed character data section, i.e. {| and |} and escape the first bracket for {value / 2} and {Math.round(value * 100)} - we need to ignore these during rendering:

  const gaugeElement = document.querySelector(".gauge");
  function setGaugeValue(gauge, value) {
    if (value < 0 || value > 1) {
      return;
    }
    gauge.querySelector(".gauge__fill").style.transform = `rotate($\{value / 2}turn)`;
    gauge.querySelector(".gauge__cover").textContent = `$\{Math.round(value * 100)}%`;
  }
  setGaugeValue(gaugeElement, {diagnostic.score}/100);

Alternatively, you can end the unparsed character data section right before the {diagnostic.score} expr. And of course, you can't escape the {diagnostic.score} expr because you need to output the value (not ignore ;-).

{| <script>
  const gaugeElement = document.querySelector(".gauge");
  function setGaugeValue(gauge, value) {
   if (value < 0 || value > 1) {
     return;
   }
  gauge.querySelector(".gauge__fill").style.transform = `rotate(${value / 2}turn)`;
  gauge.querySelector(".gauge__cover").textContent = `${Math.round(value * 100)}%`;
  }
|}
setGaugeValue(gaugeElement, {diagnostic.score}/100);

BTW I noticed several JS errors in the console:
Uncaught SyntaxError: redeclaration of const gaugeElement <anonymous> http://localhost:8080/q/dev/io.quarkus.quarkus-resteasy-reactive/scores:247

Copy link
Contributor

Choose a reason for hiding this comment

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

And FYI we now throw an exception if a property is not found in an expression, just rebase this PR on master ;-).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

perfect this is working
I did the alternative way you suggested :)

Uncaught SyntaxError: redeclaration of const gaugeElement http://localhost:8080/q/dev/io.quarkus.quarkus-resteasy-reactive/scores:247

Where you caught this, it's not showing on running mvn quarkus:dev nor in logs.

But yes I got the point, the JS snippet is in for loop and for each endpoint it is getting declared and do you know the JS snippet is working only for 1st time. after that I think it stops due to redeclaration of const gaugeElement

I think I need to declare const gaugeElement = document.querySelector(".gauge"); globally somewhere

Copy link
Contributor

Choose a reason for hiding this comment

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

Where you caught this, it's not showing on running mvn quarkus:dev nor in logs.

In the browser console, it's a JS error ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of const, made gaugeElement a variable and no issues in Console now :)
image

@saumya1singh
Copy link
Contributor Author

Yesterday I tried several gauge designs, and finally decided to use this https://github.com/SaumyaSingh1/Responsive-Gauge-Pure-CSS. It has little bit of JS involved else pure CSS.

I guess I need to give more finishing in terms of margins, colors and styling but here is how the page is rn :

image

As you will observe, the Gauge is showing Full Green for 100% in only the 1st category which is correct. But for other gauges perhaps the JS Snippet is not working. well, it is working in the side project I made for gauge yesterday. Maybe I will need some help with the JS part :)
image

Filters is same : collapsible
image

@saumya1singh
Copy link
Contributor Author

I am feeling like I have got too much Web Dev knowledge now. we learn more when we do things practically 🙈

@geoand
Copy link
Contributor

geoand commented Mar 5, 2021

Looking nice!

This may be a dump question: Why are the second and third gauges at 100% but not "fully loaded"?

@saumya1singh
Copy link
Contributor Author

Looking nice!

This may be a dump question: Why are the second and third gauges at 100% but not "fully loaded"?

No this is the right question, this is what I explained above that screenshot

Writing here again :)

As you will observe, the Gauge is showing fully loaded for 100% in only the 1st category which is correct. But for other gauges perhaps the JS Snippet is not working. well, it is working in the side project I made for gauge yesterday.
I am checking this issue. Perhaps will need some help with the JS part :)

@saumya1singh
Copy link
Contributor Author

And perhaps this conflict is due to #15406 that we merged in master. Tried manually resolving conflicts but ig I did something wrong
image

image

@geoand
Copy link
Contributor

geoand commented Mar 5, 2021

Fixing git conflicts is definitely an adventure the first few times :). After you've done it, it becomes easier :)

</div>

{| <script>
var gaugeElement = document.querySelector(".gauge");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

JS snippet is working fine, but only the 1st Gauge is loaded correctly, as we can see in this picture as well.
If there is a simple mistake I am making here, but not able to figure it out? @FroMage @phillip-kruger
I am sure this is not Qute issue.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even in the personal demo project for Gauges, when I am adding for loop around the gauge part, other gauges(except 1st) are not getting correctly loaded.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I had replied yesterday but forgot to click send :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohh, no problem at all :)

@phillip-kruger
Copy link
Member

I'll have a look a.s.a.p

return;
}

gauge.querySelector(".gauge__fill").style.transform = `rotate(${value / 2}turn)`;
Copy link
Member

Choose a reason for hiding this comment

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

So I can tell you here that the issue is that this JS script is in a loop, so it will end up multiple times in the generated HTML. So you have multiple global variables called gaugeElement and setGaugeValue, which should not be a problem in JS, but the query selector you're doing gets called multiple times, and every time you call it, it applies to every element, not just this one.

So there are several ways to do this. My favourite is to set the diagnostic.score in a data attribute somewhere, and then use it in JS in a global single query call.

Something like:

<div class="gauge" data-score="{diagnostic.score}">

And then a single selector script pass at the end of the page:

for(var gauge in document.querySelectorAll(".gauge")){
 setGaugeValue(gauge, gauge.getAttribute("data-score"));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then a single selector script pass at the end of the page

End of the page meaning after all the for loops and just above the body tag 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Yes, end of the body.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Copy link
Contributor

Choose a reason for hiding this comment

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

<tr>
<td style="width:30%;">Filters</td>
<td style="width:70%;">
<span class="badge badge-light" id="collapse-list" data-toggle="collapse" data-target="#filter">
Copy link
Member

Choose a reason for hiding this comment

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

Can we make the entire row clickable for expand/collapse? I hate tiny > buttons :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure :)

{#for diagnostic in diagnosticEntry.value}
<div class="col-4">
<div class="row">
<div class="gauge">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FroMage
Here I already have a gauge class so is it a good idea to put the data-score here like :

<div class="gauge" data-score="{diagnostic.score}">

Copy link
Member

Choose a reason for hiding this comment

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

Sure.

<td style="width:70%;">
<span class="badge badge-light" id="collapse-list" data-toggle="collapse" data-target="#filter">
<td style="width:70%;" id="collapse-list" data-toggle="collapse" data-target="#filter">
<span class="badge badge-light">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now with this new commit, the complete row is clickable :) But I didn't remove the icon >, should I @FroMage? I was not sure if a blank row will look nice :)

{/for}
<script>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FroMage I used the method of data attribute to fix that Gauge Loading issue but it's not giving desired results 🤔

return;
}

gauge.querySelector(".gauge__fill").style.transform = `rotate(${value / 2}turn)`;
Copy link
Member

Choose a reason for hiding this comment

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

Well you need to get rid of this, as it will conflict with your end-of-body script

@phillip-kruger
Copy link
Member

Hi @SaumyaSingh1 - can you share your example app (the one that you took the screenshots from)
Then I can have a quick look.
Thanks

@saumya1singh
Copy link
Contributor Author

saumya1singh commented Mar 9, 2021

can you share your example app (the one that you took the screenshots from)

Hi @phillip-kruger, sure here is the separate repo that I used for Gauge Part - https://github.com/SaumyaSingh1/Responsive-Gauge-Pure-CSS

The screenshots of the score page are from this piece of code only that I am committing to branch issue-15322 :)

@phillip-kruger
Copy link
Member

But you are using some Quarkus app to test against that branch ? That is what I am after :)

@saumya1singh
Copy link
Contributor Author

But you are using some Quarkus app to test against that branch ? That is what I am after :)

oh, I see you are asking for the quarkus app the one I named as demoapp. Just a min, pushing it on Github :)

@saumya1singh
Copy link
Contributor Author

@phillip-kruger Here is the Quarkus App - https://github.com/SaumyaSingh1/QuarkusDemoApp

@phillip-kruger
Copy link
Member

Thanks. Looking at it now.

@phillip-kruger
Copy link
Member

scorepage

@saumya1singh
Copy link
Contributor Author

This commit gave a beautiful finishing touch to the Scores Page 🎉
Thanks a lot, @phillip-kruger :)

The changes helped me understand what better I could have done, id part of the accordion was a must update :P

@saumya1singh
Copy link
Contributor Author

saumya1singh commented Mar 11, 2021

Hi,

With these commits I did the following :

  • Removed "not needed details" from the Filter Name
    Example: previously if the Filter Name was: Filters$GeneratedServerRequestFilter$sampleFilter_SubClass so now it is clearer Filters::sampleFilter

  • In firefox, the color change on Gauge was visible but not in chrome, that also fixed - thanks Phillip for the hints :)

  • Added different colors for Gauge Loading to have a stronger indication of the level (Red, Orange, Green) - Tested also with different score values

Can we have a final review for the Scores Page :)?
@FroMage @phillip-kruger

Filters Screenshot:
image

Copy link
Member

@FroMage FroMage left a comment

Choose a reason for hiding this comment

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

Looks much better, thanks both of you!

@phillip-kruger
Copy link
Member

Looks good !!

@saumya1singh saumya1singh marked this pull request as ready for review March 11, 2021 14:23
@saumya1singh saumya1singh changed the title WIP : DEV UI Enhancing the Scores Page in RESTEasy Reactive DEV UI Enhancing the Scores Page in RESTEasy Reactive Mar 12, 2021
DEV UI: added accordion

DEV UI: added gauge in scores screen, not final

added gauge for scores part

added gauge code

DEV UI: added accordion, gauge

filter complete row clickable, fixing gauge loading part

Suggested changes to score page.
Signed-off-by:Phillip Kruger <phillip.kruger@gmail.com>

Fix chrome issue: use Transform

Filter Name: Removed unnecessary data

Added Different Colors to Gauge based on score value, Tested
@gsmet
Copy link
Member

gsmet commented Mar 12, 2021

I force pushed to relaunch CI.

@FroMage FroMage merged commit 9612f82 into quarkusio:master Mar 12, 2021
@quarkus-bot quarkus-bot bot added this to the 1.13 - master milestone Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants