Skip to content

Commit

Permalink
MID-6271 operation results, done
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed May 11, 2022
1 parent bb32dfa commit 78c63a1
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 143 deletions.
10 changes: 3 additions & 7 deletions gui/admin-gui/src/frontend/scss/midpoint-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ th.cog, td.cog {
&.card-body {
border: 0px;
border-left: 3px solid;
padding: 0.25rem 0 0 0.5rem;
padding: 0.5rem 0 0 0.5rem;
}
}

Expand Down Expand Up @@ -1036,13 +1036,9 @@ span.tree-content > table tr td:first-child {
}

.stacktrace {
font-family: monospace;
font-family: $font-family-monospace !important;
font-size: $font-size-sm !important;
white-space: pre-wrap;
font-size: 11px;
}

dd.stacktrace::before {
content: none;
}

// Shopping cart
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
~ Copyright (c) 2020 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->
<html xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:border>
<dt class="col-12 col-sm-3 col-md-2 col-xxl-1 text-secondary" wicket:id="label"/>
<dd class="col-12 col-sm-9 col-md-10 col-xxl-11">
<wicket:body/>
</dd>
</wicket:border>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.api.component.result;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.border.Border;
import org.apache.wicket.model.IModel;

/**
* Created by Viliam Repan (lazyman).
*/
public class DetailsPanel extends Border {

private static final long serialVersionUID = 1L;

private static final String ID_LABEL = "label";

private IModel<String> label;

public DetailsPanel(String id, IModel<String> label) {
super(id);

this.label = label;

initLayout();
}

private void initLayout() {
Label title = new Label(ID_LABEL, label);
addToBorder(title);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,52 +36,42 @@ <h3 class="card-title" wicket:id="message">
</div>
<div class="feedback-message card-body" wicket:id="details">
<dl class="feedback-message row">
<wicket:enclosure child="operationLabel">
<dt class="col-12 col-sm-3 col-md-2 col-xxl-1 text-secondary" wicket:id="operationLabel"></dt>
<dd class="col-12 col-sm-9 col-md-10 col-xxl-11">
<b wicket:id="operation"/>
</dd>
</wicket:enclosure>
<wicket:enclosure child="messageLabel">
<dt class="col-12 col-sm-3 col-md-2 col-xxl-1 text-secondary" wicket:id="messageLabel"></dt>
<dd class="col-12 col-sm-9 col-md-10 col-xxl-11" wicket:id="resultMessage"></dd>
</wicket:enclosure>
<wicket:enclosure child="paramsLabel">
<dt class="col-12 col-sm-3 col-md-2 col-xxl-1 text-secondary" wicket:id="paramsLabel"/>
<dd class="col-12 col-sm-9 col-md-10 col-xxl-11">
<table class="paramtable">
<tr class="paramtable-row" wicket:id="params">
<th class="paramtable-name" wicket:id="paramName"/>
<td class="paramtable-value" wicket:id="paramValue"/>
</tr>
</table>
</dd>
</wicket:enclosure>
<wicket:enclosure child="contextsLabel">
<dt class="col-12 col-sm-3 col-md-2 col-xxl-1 text-secondary" wicket:id="contextsLabel"/>
<dd class="col-12 col-sm-9 col-md-10 col-xxl-11">
<table class="paramtable">
<tr class="paramtable-row" wicket:id="contexts">
<th class="paramtable-name" wicket:id="contextName"/>
<td class="paramtable-value" wicket:id="contextValue"/>
</tr>
</table>
</dd>
</wicket:enclosure>
<wicket:enclosure child="countLabel">
<dt class="col-12 col-sm-3 col-md-2 col-xxl-1 text-secondary" wicket:id="countLabel"/>
<dd class="col-12 col-sm-9 col-md-10 col-xxl-11" wicket:id="count"/>
</wicket:enclosure>
<wicket:enclosure child="errorLabel">
<dt class="col-12 col-sm-3 col-md-2 col-xxl-1 text-secondary" wicket:id="errorLabel"/>
<dd class="col-12 col-sm-9 col-md-10 col-xxl-11" wicket:id="errorMessage"/>
<dd><a wicket:id="errorStackTraceLink">show</a></dd>
<dd class="stacktrace" wicket:id="errorStackTrace"/>
</wicket:enclosure>
<wicket:container wicket:id="operation">
<b wicket:id="operationBody"/>
</wicket:container>
<wicket:container wicket:id="message">
<span wicket:id="resultMessage"/>
</wicket:container>
<wicket:container wicket:id="paramsContainer">
<table class="paramtable">
<tr class="paramtable-row" wicket:id="params">
<th class="paramtable-name" wicket:id="paramName"/>
<td class="paramtable-value" wicket:id="paramValue"/>
</tr>
</table>
</wicket:container>
<wicket:container wicket:id="contextsContainer">
<table class="paramtable">
<tr class="paramtable-row" wicket:id="contexts">
<th class="paramtable-name" wicket:id="contextName"/>
<td class="paramtable-value" wicket:id="contextValue"/>
</tr>
</table>
</wicket:container>
<wicket:container wicket:id="countContainer">
<span wicket:id="count"/>
</wicket:container>
<wicket:container wicket:id="errorContainer">
<div class="d-flex flex-column gap-1">
<span wicket:id="errorMessage"/>
<a wicket:id="errorStackTraceLink"><span wicket:id="linkText"/></a>
<span class="stacktrace" wicket:id="errorStackTrace"/>
</div>
</wicket:container>
</dl>
<div wicket:id="subresults">
<wicket:container wicket:id="subresults">
<div wicket:id="subresult" />
</div>
</wicket:container>
</div>
</div>
</wicket:panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,86 +304,74 @@ private void initDetails(WebMarkupContainer box) {
details.add(new VisibleBehaviour(() -> getModelObject().isShowMore()));
box.add(details);

Label operationLabel = new Label("operationLabel", createStringResource("FeedbackAlertMessageDetails.operation"));
operationLabel.setOutputMarkupId(true);
details.add(operationLabel);

Label operation = new Label("operation", () -> {
DetailsPanel operation = new DetailsPanel("operation", createStringResource("FeedbackAlertMessageDetails.operation"));
details.add(operation);
Label operationBody = new Label("operationBody", () -> {
OpResult result = getModelObject();

String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
return getString(resourceKey, null, result.getOperation());
});
operation.setOutputMarkupId(true);
details.add(operation);

Label count = new Label("countLabel", createStringResource("FeedbackAlertMessageDetails.count"));
count.add(new VisibleBehaviour(() -> getModelObject().getCount() > 1));
details.add(count);
details.add(initCountPanel(getModel()));

Label message = new Label("resultMessage", new PropertyModel<String>(getModel(), "message").getObject());
message.setOutputMarkupId(true);
operation.add(operationBody);

DetailsPanel message = new DetailsPanel("message", createStringResource("FeedbackAlertMessageDetails.message"));
message.add(new VisibleBehaviour(() -> StringUtils.isNotBlank(getModelObject().getMessage())));

details.add(message);
Label resultMessage = new Label("resultMessage", new PropertyModel<String>(getModel(), "message").getObject());
resultMessage.setRenderBodyOnly(true);
message.add(resultMessage);

Label messageLabel = new Label("messageLabel", createStringResource("FeedbackAlertMessageDetails.message"));
messageLabel.setOutputMarkupId(true);

messageLabel.add(new VisibleBehaviour(() -> StringUtils.isNotBlank(getModelObject().getMessage())));
initParams(details);
initContexts(details);

details.add(messageLabel);
DetailsPanel countContainer = new DetailsPanel("countContainer", createStringResource("FeedbackAlertMessageDetails.count"));
countContainer.add(new VisibleBehaviour(() -> getModelObject().getCount() > 1));
details.add(countContainer);

initParams(details, getModel());
initContexts(details, getModel());
initError(details, getModel());
}
Label count = new Label("count", () -> getModelObject().getCount());
count.add(new VisibleBehaviour(() -> getModelObject().getCount() > 1));
countContainer.add(count);

private void initParams(WebMarkupContainer operationContent, final IModel<OpResult> model) {
Label paramsLabel = new Label("paramsLabel", createStringResource("FeedbackAlertMessageDetails.params"));
paramsLabel.setOutputMarkupId(true);
paramsLabel.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(model.getObject().getParams())));
operationContent.add(paramsLabel);
initError(details);

ListView<Param> params = new ListView<>(ID_PARAMS, createParamsModel(model)) {
ListView<OpResult> subresults = new ListView<>("subresults", createSubresultsModel(getModel())) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<Param> item) {
item.add(new Label("paramName", new PropertyModel<>(item.getModel(), "name")));
item.add(new Label("paramValue", new PropertyModel<>(item.getModel(), "value")));
protected void populateItem(final ListItem<OpResult> item) {
Panel subresult = new OperationResultPanel("subresult", item.getModel());
subresult.add(new VisibleBehaviour(() -> item.getModel() != null && item.getModelObject() != null));
subresult.setOutputMarkupId(true);
item.add(subresult);
}
};
params.setOutputMarkupId(true);
params.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(model.getObject().getParams())));
subresults.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(getModelObject().getSubresults())));
details.add(subresults);
}

operationContent.add(params);
private void initParams(WebMarkupContainer details) {
DetailsPanel paramsContainer = new DetailsPanel("paramsContainer", createStringResource("FeedbackAlertMessageDetails.params"));
paramsContainer.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(getModelObject().getParams())));
details.add(paramsContainer);

ListView<OpResult> subresults = new ListView<>("subresults", createSubresultsModel(model)) {
ListView<Param> params = new ListView<>(ID_PARAMS, createParamsModel(getModel())) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(final ListItem<OpResult> item) {
Panel subresult = new OperationResultPanel("subresult", item.getModel());
subresult.add(new VisibleBehaviour(() -> item.getModel() != null && item.getModelObject() != null));
subresult.setOutputMarkupId(true);
item.add(subresult);
protected void populateItem(ListItem<Param> item) {
item.add(new Label("paramName", new PropertyModel<>(item.getModel(), "name")));
item.add(new Label("paramValue", new PropertyModel<>(item.getModel(), "value")));
}
};
subresults.setOutputMarkupId(true);
subresults.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(model.getObject().getSubresults())));
operationContent.add(subresults);
paramsContainer.add(params);
}

private void initContexts(WebMarkupContainer operationContent, final IModel<OpResult> model) {
Label contextsLabel = new Label("contextsLabel", createStringResource("FeedbackAlertMessageDetails.contexts"));
contextsLabel.setOutputMarkupId(true);
contextsLabel.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(model.getObject().getContexts())));
operationContent.add(contextsLabel);
private void initContexts(WebMarkupContainer details) {
DetailsPanel contextsContainer = new DetailsPanel("contextsContainer", createStringResource("FeedbackAlertMessageDetails.contexts"));
contextsContainer.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(getModelObject().getContexts())));
details.add(contextsContainer);

ListView<Context> contexts = new ListView<>("contexts", createContextsModel(model)) {
ListView<Context> contexts = new ListView<>("contexts", createContextsModel(getModel())) {
private static final long serialVersionUID = 1L;

@Override
Expand All @@ -392,48 +380,39 @@ protected void populateItem(ListItem<Context> item) {
item.add(new Label("contextValue", new PropertyModel<>(item.getModel(), "value")));
}
};
contexts.setOutputMarkupId(true);
contexts.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(model.getObject().getContexts())));
operationContent.add(contexts);
contextsContainer.add(contexts);
}

private void initError(WebMarkupContainer operationPanel, final IModel<OpResult> model) {
Label errorLabel = new Label("errorLabel", createStringResource("FeedbackAlertMessageDetails.error"));
errorLabel.add(new VisibleBehaviour(() -> StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace())));
errorLabel.setOutputMarkupId(true);
operationPanel.add(errorLabel);
private void initError(WebMarkupContainer details) {
DetailsPanel errorContainer = new DetailsPanel("errorContainer", createStringResource("FeedbackAlertMessageDetails.error"));
errorContainer.add(new VisibleBehaviour(() -> StringUtils.isNotBlank(getModelObject().getExceptionsStackTrace())));
details.add(errorContainer);

Label errorMessage = new Label("errorMessage", () -> getModelObject().getExceptionMessage());
errorContainer.add(errorMessage);

Label errorMessage = new Label("errorMessage", new PropertyModel<String>(model, "exceptionMessage"));
errorMessage.add(new VisibleBehaviour(() -> StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace())));
errorMessage.setOutputMarkupId(true);
operationPanel.add(errorMessage);
Label errorStackTrace = new Label(ID_ERROR_STACK_TRACE, () -> getModelObject().getExceptionsStackTrace());
errorStackTrace.add(new VisibleBehaviour(() -> getModelObject().isShowError()));
errorContainer.add(errorStackTrace);

final Label errorStackTrace = new Label(ID_ERROR_STACK_TRACE, new PropertyModel<String>(model, "exceptionsStackTrace"));
errorStackTrace.add(new VisibleBehaviour(() -> model.getObject().isShowError()));
errorStackTrace.setOutputMarkupId(true);
operationPanel.add(errorStackTrace);
Label linkText = new Label("linkText", () -> {
String key = getModelObject().isShowError() ? "operationResultPanel.hideStack" : "operationResultPanel.showStack";
return getString(key);
});

AjaxLink<Void> errorStackTraceLink = new AjaxLink<>("errorStackTraceLink") {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
OpResult result = OperationResultPanel.this.getModelObject();
result.setShowError(!model.getObject().isShowError());
result.setShowError(!result.isShowError());
result.setAlreadyShown(false); // hack to be able to expand/collapse OpResult after rendered.
target.add(OperationResultPanel.this);
}

};
errorStackTraceLink.setOutputMarkupId(true);
errorStackTraceLink.add(new VisibleBehaviour(() -> StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace())));
operationPanel.add(errorStackTraceLink);
}

private Label initCountPanel(final IModel<OpResult> model) {
Label count = new Label("count", new PropertyModel<String>(model, "count"));
count.add(new VisibleBehaviour(() -> model.getObject().getCount() > 1));
return count;
errorStackTraceLink.add(linkText);
errorContainer.add(errorStackTraceLink);
}

private void showHideAll(final boolean show, AjaxRequestTarget target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
public class Popover extends Border {

private static final long serialVersionUID = 1L;

private static final String ID_POPOVER = "popover";
private static final String ID_TITLE = "title";

Expand Down

0 comments on commit 78c63a1

Please sign in to comment.