Skip to content

Commit 2caa430

Browse files
authored
Merge pull request #32555 from phillip-kruger/devui-testing-stacked-bar
Change pie to bar in continuous-testing dev ui
2 parents 8c8720f + b43f0d6 commit 2caa430

File tree

3 files changed

+136
-59
lines changed

3 files changed

+136
-59
lines changed

extensions/vertx-http/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ InternalImportMapBuildItem createKnownInternalImportMap(NonApplicationRootPathBu
7373
internalImportMapBuildItem.add("echarts/", contextRoot + "echarts/");
7474
internalImportMapBuildItem.add("echarts-gauge-grade", contextRoot + "echarts/echarts-gauge-grade.js");
7575
internalImportMapBuildItem.add("echarts-pie", contextRoot + "echarts/echarts-pie.js");
76+
internalImportMapBuildItem.add("echarts-horizontal-stacked-bar",
77+
contextRoot + "echarts/echarts-horizontal-stacked-bar.js");
7678

7779
// Other assets
7880
internalImportMapBuildItem.add("icon/", contextRoot + "icon/");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { EchartsAbstractCanvas } from './echarts-abstract-canvas.js';
2+
/**
3+
* This wraps the Horizontal Stacked Bar echart into a component
4+
* see https://echarts.apache.org/examples/en/editor.html?c=bar-y-category-stack
5+
*/
6+
class EchartsHorizontalStackedBar extends EchartsAbstractCanvas {
7+
8+
static get properties() {
9+
return {
10+
name: {type: String},
11+
height: {type: String},
12+
sectionTitles: { type: String},
13+
sectionValues: { type: String},
14+
sectionColors: { type: String},
15+
};
16+
}
17+
18+
constructor() {
19+
super();
20+
this.name = "Bar";
21+
this.height = "40px";
22+
this.sectionTitles = "";
23+
this.sectionValues = "";
24+
this.sectionColors = "grey";
25+
this.primaryTextColor = "--lumo-body-text-color";
26+
}
27+
28+
getOption(){
29+
30+
let textColor = this.primaryTextColor;
31+
if(textColor.startsWith('--')){
32+
textColor = getComputedStyle(this.shadowRoot.host).getPropertyValue(textColor);
33+
}
34+
35+
const sectionColorsArray = this.sectionColors.split(',');
36+
const colors = [];
37+
38+
for (var cc = 0; cc < sectionColorsArray.length; cc++) {
39+
let colorString = sectionColorsArray[cc];
40+
if(colorString.startsWith("--")){
41+
colorString = getComputedStyle(this.shadowRoot.host).getPropertyValue(colorString);
42+
}
43+
colors.push(colorString);
44+
}
45+
46+
const sectionTitlesArray = this.sectionTitles.split(',');
47+
const sectionValuesArray = this.sectionValues.split(',');
48+
49+
const option = new Object();
50+
// Tooltip
51+
option.tooltip = new Object();
52+
option.tooltip.trigger = "axis";
53+
// Legend
54+
option.legend = new Object();
55+
option.legend.show = false;
56+
// Grid
57+
option.grid = new Object();
58+
option.grid.left = '3%';
59+
option.grid.right = '4%';
60+
option.grid.bottom = '3%';
61+
option.grid.containLabel = false;
62+
// AxisLabel
63+
option.axisLabel = new Object();
64+
option.axisLabel.color = textColor;
65+
// X Axis
66+
option.xAxis = new Object();
67+
option.xAxis.type = 'value';
68+
// Y Axis
69+
option.yAxis = new Object();
70+
option.yAxis.type = 'category';
71+
option.yAxis.data = [this.name];
72+
option.yAxis.show = false;
73+
// Height
74+
option.height = this.height;
75+
76+
// Series
77+
option.series = [];
78+
79+
for (var count = 0; count < sectionTitlesArray.length; count++) {
80+
let title = sectionTitlesArray[count];
81+
let value = sectionValuesArray[count];
82+
let color = colors[count];
83+
84+
const serie = new Object();
85+
serie.name = title;
86+
serie.type = 'bar';
87+
serie.stack = 'total';
88+
serie.data = [value],
89+
serie.color = color;
90+
option.series.push(serie);
91+
}
92+
93+
return option;
94+
}
95+
96+
}
97+
customElements.define('echarts-horizontal-stacked-bar', EchartsHorizontalStackedBar);

extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-continuous-testing.js

+37-59
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { columnBodyRenderer } from '@vaadin/grid/lit.js';
1010
import { gridRowDetailsRenderer } from '@vaadin/grid/lit.js';
1111
import '@vaadin/progress-bar';
1212
import '@vaadin/checkbox';
13-
import 'echarts-pie';
13+
import 'echarts-horizontal-stacked-bar';
1414

1515
/**
1616
* This component shows the Continuous Testing Page
@@ -26,13 +26,11 @@ export class QwcContinuousTesting extends QwcHotReloadElement {
2626
}
2727
.menubar{
2828
border-bottom: 1px solid var(--lumo-contrast-5pct);
29-
}
30-
.center {
31-
width: 100%;
3229
display: flex;
33-
gap: 10px;
34-
flex-direction: column;
30+
align-items: center;
31+
justify-content: space-between;
3532
}
33+
3634
.results {
3735
display: flex;
3836
gap: 10px;
@@ -55,29 +53,19 @@ export class QwcContinuousTesting extends QwcHotReloadElement {
5553
display: flex;
5654
flex-direction: column;
5755
overflow: hidden;
58-
margin-left: 10px;
56+
margin-left: 40px;
5957
margin-top: 10px;
60-
}
61-
vaadin-button {
62-
cursor: pointer;
58+
height: 100%;
6359
}
6460
65-
.logDetails {
66-
background: var(--lumo-contrast-5pct);
67-
overflow: hidden;
68-
margin-right: 5px;
69-
margin-left: 5px;
70-
border-radius: 15px 15px 0px 0px;
71-
display: flex;
72-
flex-direction: column;
61+
.progress {
62+
padding-right: 20px;
63+
width: 50%;
7364
}
74-
.rightSideInfo {
75-
display: flex;
76-
flex-direction: column;
77-
}
78-
echarts-pie {
79-
width: 400px;
80-
height: 400px;
65+
66+
.total {
67+
padding-right: 20px;
68+
text-align: center;
8169
}
8270
`;
8371

@@ -142,20 +130,21 @@ export class QwcContinuousTesting extends QwcHotReloadElement {
142130
render() {
143131
return html`
144132
${this._renderMenuBar()}
145-
<div class="results">
146-
${this._renderResultSet()}
147-
${this._renderState()}
148-
</div>
133+
${this._renderResultSet()}
134+
${this._renderBarChart()}
149135
`;
150136
}
151137

152138
_renderMenuBar(){
153139
if(this._state){
154140
return html`<div class="menubar">
155-
${this._renderStopStartButton()}
156-
${this._renderRunAllButton()}
157-
${this._renderRunFailedButton()}
158-
${this._renderToggleBrokenOnly()}
141+
<div>
142+
${this._renderStopStartButton()}
143+
${this._renderRunAllButton()}
144+
${this._renderRunFailedButton()}
145+
${this._renderToggleBrokenOnly()}
146+
</div>
147+
${this._renderBusyIndicator()}
159148
</div>`;
160149
}else{
161150
return html`<div class="menubar">
@@ -164,19 +153,19 @@ export class QwcContinuousTesting extends QwcHotReloadElement {
164153
}
165154
}
166155

167-
_renderState(){
156+
_renderBarChart(){
168157
if(this._state && this._state.running && this._state.run > 0){
169-
return html`<div class="rightSideInfo">
170-
${this._renderStateChart()}
171-
${this._renderBusyIndicator()}
172-
</div>`;
173-
}else if(this._state && this._state.running && this._state.run === 0){
174-
return html`${this._renderProgressBar("Starting ...")}`;
158+
let values = [this._state.passed, this._state.failed, this._state.skipped];
159+
return html`<echarts-horizontal-stacked-bar name = "Tests"
160+
sectionTitles="${this._chartTitles.toString()}"
161+
sectionValues="${values.toString()}"
162+
sectionColors="${this._chartColors.toString()}">
163+
</echarts-horizontal-stacked-bar>`;
175164
}
176165
}
177166

178167
_renderStateChart(){
179-
let values = [this._state.passed, this._state.failed, this._state.skipped]
168+
let values = [this._state.passed, this._state.failed, this._state.skipped];
180169
return html`<echarts-pie name = "Tests"
181170
sectionTitles="${this._chartTitles.toString()}"
182171
sectionValues="${values.toString()}"
@@ -186,13 +175,13 @@ export class QwcContinuousTesting extends QwcHotReloadElement {
186175

187176
_renderBusyIndicator(){
188177
if(this._state && this._state.inProgress){
189-
return html`${this._renderProgressBar("Running ...")}`;
190-
}else if(this._results){
178+
return html`<vaadin-progress-bar class="progress" indeterminate></vaadin-progress-bar>`;
179+
}else if(this._results && this._state && this._state.running){
191180

192-
return html`<span style="text-align: center;">
193-
Total time:
194-
<qui-badge><span>${this._results.totalTime}ms</span></qui-badge>
195-
</span>`
181+
return html`<span class="total">
182+
Total time:
183+
<qui-badge><span>${this._results.totalTime}ms</span></qui-badge>
184+
</span>`
196185
}
197186

198187
}
@@ -206,9 +195,7 @@ export class QwcContinuousTesting extends QwcHotReloadElement {
206195

207196
var allResults = failingResults.concat(passingResults, skippedResults);
208197

209-
return html`<div class="center">
210-
${this._renderResults(allResults)}
211-
</div>`;
198+
return html`${this._renderResults(allResults)}`;
212199
}
213200

214201
}
@@ -410,14 +397,5 @@ export class QwcContinuousTesting extends QwcHotReloadElement {
410397
this._busy = false;
411398
});
412399
}
413-
414-
_renderProgressBar(message){
415-
return html`
416-
<div style="color: var(--lumo-secondary-text-color);width: 95%;" >
417-
<div>${message}</div>
418-
<vaadin-progress-bar indeterminate></vaadin-progress-bar>
419-
</div>
420-
`;
421-
}
422400
}
423401
customElements.define('qwc-continuous-testing', QwcContinuousTesting);

0 commit comments

Comments
 (0)