Skip to content

Commit

Permalink
Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
hpehl committed Nov 19, 2024
1 parent cc0a76e commit 4e63ec0
Show file tree
Hide file tree
Showing 19 changed files with 361 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ public interface ModelDescriptionConstants {
String PROCESSING_TIME = "processing-time";
String PRODUCES = "produces";
String PRODUCT_NAME = "product-name";
String PRODUCT_INFO = "product-info";
String PRODUCT_VERSION = "product-version";
String PROFILE = "profile";
String PROFILE_NAME = "profile-name";
Expand Down
2 changes: 1 addition & 1 deletion meta/src/main/java/org/jboss/hal/meta/AddressTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public AddressTemplate parent() {
}
}

public AddressTemplate anonymous() {
public AddressTemplate anonymiseLast() {
if (isEmpty()) {
return AddressTemplate.of("");
} else if (!"*".equals(last().value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@
@ApplicationScoped
public class MetadataRepository {

// TODO: Add support for 2nd level cache!
// TODO Do not cache specific resources (they have different attributes/operations depending on their state):
// /host=*
// /host=*server=*
// /server-group=* ?
// anything else?

// TODO Add support for 2nd level cache!
private static final int FIRST_LEVEL_CACHE_SIZE = 500;
private static final Logger logger = Logger.getLogger(MetadataRepository.class.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,31 @@
package org.jboss.hal.op.dashboard;

import org.jboss.elemento.IsElement;
import org.patternfly.component.card.CardActions;
import org.patternfly.component.emptystate.EmptyState;
import org.patternfly.style.Size;

import elemental2.dom.HTMLElement;

import static org.patternfly.component.button.Button.button;
import static org.patternfly.component.card.CardActions.cardActions;
import static org.patternfly.component.emptystate.EmptyState.emptyState;
import static org.patternfly.icon.IconSets.fas.redo;
import static org.patternfly.style.Size.xs;

interface DashboardCard extends IsElement<HTMLElement> {

void refresh();

/**
* @return an empty state of size {@link Size#sm} for usage in a dashboard card.
* @return an empty state of size {@link Size#xs} for usage in a dashboard card.
*/
static EmptyState emptyState() {
return EmptyState.emptyState().size(xs);
static EmptyState dashboardEmptyState() {
return emptyState().size(xs);
}

void refresh();

default CardActions refreshActions() {
return cardActions()
.add(button().plain().icon(redo()).onClick((e, c) -> refresh()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import org.jboss.hal.env.Environment;
import org.jboss.hal.meta.StatementContext;
import org.jboss.hal.model.deployment.Deployments;
import org.patternfly.layout.flex.Direction;
import org.patternfly.layout.flex.FlexItem;
import org.patternfly.layout.flex.Gap;

import elemental2.dom.HTMLElement;

Expand All @@ -39,6 +42,10 @@
import static org.patternfly.component.page.PageMainSection.pageMainSection;
import static org.patternfly.component.text.TextContent.textContent;
import static org.patternfly.component.title.Title.title;
import static org.patternfly.layout.flex.Direction.column;
import static org.patternfly.layout.flex.Flex.flex;
import static org.patternfly.layout.flex.FlexShorthand._1;
import static org.patternfly.layout.flex.Gap.md;
import static org.patternfly.layout.grid.Grid.grid;
import static org.patternfly.layout.grid.GridItem.gridItem;
import static org.patternfly.style.Brightness.light;
Expand Down Expand Up @@ -73,26 +80,25 @@ public DashboardPage(Environment environment,
public Iterable<HTMLElement> elements(Place place, Parameter parameter, LoadedData data) {
DashboardCard deploymentCard = new DeploymentCard(environment, deployments);
DashboardCard documentationCard = new DocumentationCard(environment);
DashboardCard domainCard = new DomainCard();
DashboardCard healthCard = new HealthCard(dispatcher);
DashboardCard logCard = new LogCard(dispatcher);
DashboardCard productInfoCard = new ProductInfoCard(environment);
DashboardCard runtimeCard = new RuntimeCard(dispatcher);
DashboardCard runtimeCard = new RuntimeCard(statementContext, dispatcher);

if (environment.standalone()) {
cards.addAll(asList(
deploymentCard,
documentationCard,
healthCard,
logCard,
productInfoCard,
runtimeCard,
healthCard));
runtimeCard));
} else {
cards.addAll(asList(
deploymentCard,
documentationCard,
domainCard,
productInfoCard));
productInfoCard,
runtimeCard));
}

HTMLElement header = pageMainSection().limitWidth().background(light)
Expand All @@ -107,23 +113,23 @@ public Iterable<HTMLElement> elements(Place place, Parameter parameter, LoadedDa
grid
.addItem(gridItem().span(12)
.add(productInfoCard))
.addItem(gridItem().span(12)
.add(deploymentCard))
.addItem(gridItem().span(12)
.addItem(gridItem().span(8)
.add(runtimeCard))
.addItem(gridItem().span(12)
.add(logCard))
.addItem(gridItem().span(12)
.add(healthCard))
.addItem(gridItem().span(12)
.addItem(gridItem().span(4).rowSpan(3)
.add(flex().direction(column).gap(md)
.addItem(FlexItem.flexItem().flex(_1).add(logCard))
.addItem(FlexItem.flexItem().flex(_1).add(healthCard))))
.addItem(gridItem().span(8)
.add(deploymentCard))
.addItem(gridItem().span(8)
.add(documentationCard));
} else {
grid
.addItem(gridItem().span(12)
.add(productInfoCard))
.addItem(gridItem().span(12)
.add(domainCard))
.addItem(gridItem().span(12)
.addItem(gridItem().span(6)
.add(runtimeCard))
.addItem(gridItem().span(6)
.add(deploymentCard))
.addItem(gridItem().span(12)
.add(documentationCard));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@

import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;
import static org.jboss.elemento.Elements.a;
import static org.jboss.elemento.Elements.div;
import static org.jboss.elemento.Elements.removeChildrenFrom;
import static org.jboss.hal.op.dashboard.DashboardCard.emptyState;
import static org.patternfly.component.button.Button.button;
import static org.jboss.hal.op.dashboard.DashboardCard.dashboardEmptyState;
import static org.patternfly.component.card.Card.card;
import static org.patternfly.component.card.CardActions.cardActions;
import static org.patternfly.component.card.CardBody.cardBody;
import static org.patternfly.component.card.CardFooter.cardFooter;
import static org.patternfly.component.card.CardHeader.cardHeader;
import static org.patternfly.component.card.CardTitle.cardTitle;
import static org.patternfly.component.divider.Divider.divider;
Expand All @@ -50,33 +46,30 @@
import static org.patternfly.icon.IconSets.fas.exclamationCircle;
import static org.patternfly.icon.IconSets.fas.pauseCircle;
import static org.patternfly.icon.IconSets.fas.question;
import static org.patternfly.icon.IconSets.fas.redo;
import static org.patternfly.icon.IconSets.fas.timesCircle;
import static org.patternfly.layout.flex.Display.inlineFlex;
import static org.patternfly.layout.flex.Flex.flex;
import static org.patternfly.layout.flex.SpaceItems.sm;
import static org.patternfly.style.Classes.util;
import static org.patternfly.style.Orientation.vertical;
import static org.patternfly.style.Variable.globalVar;

class DeploymentCard implements DashboardCard {

private final Environment environment;
private final Deployments deployments;
private final HTMLElement root;
private final CardTitle cardTitle;
private final CardBody cardBody;
private final HTMLElement root;

DeploymentCard(Environment environment, Deployments deployments) {
this.environment = environment;
this.deployments = deployments;
this.root = card()
this.root = card().css(util("h-100"))
.addHeader(cardHeader()
.addActions(cardActions()
.add(button().plain().icon(redo()).onClick((e, c) -> refresh()))))
.addTitle(cardTitle = cardTitle().style("text-align", "center"))
.addTitle(cardTitle = cardTitle())
.addActions(refreshActions()))
.addBody(cardBody = cardBody().style("text-align", "center"))
.addFooter(cardFooter()
.add(a("#").textContent("View deployments")))
.element();
}

Expand All @@ -88,10 +81,11 @@ public HTMLElement element() {
@Override
public void refresh() {
removeChildrenFrom(cardBody);

if (environment.standalone()) {
deployments.readStandaloneDeployments().then(deployments -> {
if (deployments.isEmpty()) {
cardBody.add(emptyState()
cardBody.add(dashboardEmptyState()
.addHeader(emptyStateHeader()
.icon(IconSets.fas.ban())
.text("No deployments"))
Expand Down Expand Up @@ -126,7 +120,7 @@ public void refresh() {
});
} else {
// TODO Add support for domain mode
cardBody.add(emptyState()
cardBody.add(dashboardEmptyState()
.addHeader(emptyStateHeader()
.icon(exclamationCircle())
.text("Domain mode"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class DocumentationCard implements DashboardCard {

DocumentationCard(Environment environment) {
this.version = environment.productVersionLink();
this.root = card()
.add(flex()
this.root = card().add(flex()
.alignItems(AlignItems.stretch)
.alignSelf(AlignSelf.stretch)
.addItem(flexItem().flex(_1)
Expand Down

This file was deleted.

Loading

0 comments on commit 4e63ec0

Please sign in to comment.