Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 21, 2019
2 parents d9db0a7 + 3e5df91 commit be983b1
Show file tree
Hide file tree
Showing 83 changed files with 2,435 additions and 629 deletions.
Expand Up @@ -153,7 +153,10 @@ private IModel<String> createHeaderModel() {
}
String objectTemplateNameValue = objectTemplate.getTargetName().toString();
StringBuilder sb = new StringBuilder();
sb.append(typeValue.getLocalPart()).append(" - ").append(objectTemplateNameValue);
if(typeValue != null) {
sb.append(typeValue.getLocalPart()).append(" - ");
}
sb.append(objectTemplateNameValue);
return Model.of(sb.toString());
}
PrismProperty<String> name = getModelObject().asPrismContainerValue().findProperty(ObjectType.F_NAME);
Expand Down
Expand Up @@ -46,6 +46,7 @@
import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty;
import com.evolveum.midpoint.prism.util.PolyStringUtils;
import com.evolveum.midpoint.repo.api.CacheDispatcher;
import com.evolveum.midpoint.repo.api.CounterManager;
import com.evolveum.midpoint.repo.common.ObjectResolver;
import com.evolveum.midpoint.repo.common.expression.Expression;
import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext;
Expand Down Expand Up @@ -311,6 +312,9 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {

@SpringBean
private MidpointFunctions midpointFunctions;

@SpringBean
private CounterManager counterManager;

private List<Breadcrumb> breadcrumbs;

Expand Down Expand Up @@ -472,6 +476,10 @@ public LocalizationService getLocalizationService() {
public MidpointFunctions getMidpointFunctions() {
return midpointFunctions;
}

public CounterManager getCounterManager() {
return counterManager;
}

@Contract(pure = true)
public PrismContext getPrismContext() {
Expand Down
Expand Up @@ -155,6 +155,7 @@ protected void configure(HttpSecurity http) throws Exception {
}

http.headers().disable();
http.headers().frameOptions().deny();

if (Arrays.stream(environment.getActiveProfiles()).anyMatch(p -> p.equalsIgnoreCase("cas"))) {
http.addFilterAt(casFilter(), CasAuthenticationFilter.class);
Expand Down
Expand Up @@ -63,7 +63,7 @@ public DropDownFormGroup(String id, IModel<T> value, IModel<List<T>> choices, IC

public DropDownFormGroup(String id, IModel<T> value, IModel<List<T>> choices, IChoiceRenderer<T> renderer,
IModel<String> label, String tooltipKey, boolean isTooltipInModal, String labelCssClass, String textCssClass, boolean required) {
this(id, value, choices, renderer, label, null, false, labelCssClass, textCssClass, required, false);
this(id, value, choices, renderer, label, tooltipKey, isTooltipInModal, labelCssClass, textCssClass, required, false);
}

public DropDownFormGroup(String id, IModel<T> value, IModel<List<T>> choices, IChoiceRenderer<T> renderer, IModel<String> label, String tooltipKey,
Expand Down
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="row">
<div wicket:id="defaultValuePanel"/>
</div>
<div wicket:id="fullDataContainer">
<div class="row">
<div class="col-md-4"><wicket:message key="PolyStringEditorPanel.defaultLabel" /></div>
<div class="col-md-8" wicket:id="origValue"/>
</div>
<div class="row">
<div class="col-md-4"><wicket:message key="PolyStringEditorPanel.keyLabel" /></div>
<div class="col-md-8" wicket:id="keyValue"/>
</div>
<div wicket:id="languagesRepeater" class="row">
<div class="col-md-4" wicket:id="languageName" />
<div class="col-md-8" wicket:id="translation"/>
</div>
</div>
<div class="show-empty-button" wicket:id="showHideLanguages"/>

</wicket:panel>
</html>
@@ -0,0 +1,136 @@
/*
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.web.component.prism;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.input.TextPanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationArgumentType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.util.ArrayList;
import java.util.List;

/**
* Created by honchar
*/
public class PolyStringEditorPanel extends BasePanel<PolyStringType>{
private static final long serialVersionUID = 1L;

private static final String ID_DEFAULT_VALUE_PANEL = "defaultValuePanel";
private static final String ID_FULL_DATA_CONTAINER = "fullDataContainer";
private static final String ID_ORIG_VALUE = "origValue";
private static final String ID_KEY_VALUE = "keyValue";
private static final String ID_LANGUAGES_REPEATER = "languagesRepeater";
private static final String ID_LANGUAGE_NAME = "languageName";
private static final String ID_TRANSLATION = "translation";
private static final String ID_SHOW_HIDE_LANGUAGES = "showHideLanguages";

private boolean showFullData = false;

public PolyStringEditorPanel(String id, IModel<PolyStringType> model){
super(id, model);
}

@Override
protected void onInitialize(){
initLayout();
}

private void initLayout(){
TextPanel<String> defaultValuePanel = new TextPanel<String>(ID_DEFAULT_VALUE_PANEL, Model.of(getDefaultPolyStringValue()));
defaultValuePanel.setOutputMarkupId(true);
defaultValuePanel.add(new VisibleBehaviour(() -> !showFullData));
add(defaultValuePanel);

WebMarkupContainer fullDataContainer = new WebMarkupContainer(ID_FULL_DATA_CONTAINER);
fullDataContainer.setOutputMarkupId(true);
fullDataContainer.add(new VisibleBehaviour(() -> showFullData));
add(fullDataContainer);

TextPanel<String> origValue = new TextPanel<String>(ID_ORIG_VALUE, Model.of(getDefaultPolyStringValue()));
origValue.setOutputMarkupId(true);
fullDataContainer.add(origValue);

TextPanel<String> keyValue = new TextPanel<String>(ID_KEY_VALUE, Model.of(getKeyValue()));
keyValue.setOutputMarkupId(true);
fullDataContainer.add(keyValue);

ListView<PolyStringTranslationArgumentType> languagesContainer =
new ListView<PolyStringTranslationArgumentType>(ID_LANGUAGES_REPEATER, Model.ofList(getTranslationArgumentList())) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<PolyStringTranslationArgumentType> listItem) {
Label languageName = new Label(ID_LANGUAGE_NAME, Model.of(listItem.getModelObject().getValue()));
languageName.setOutputMarkupId(true);
listItem.add(languageName);

//TODO what value do we need to display?
TextPanel<String> translation = new TextPanel<String>(ID_TRANSLATION, Model.of(listItem.getModelObject().getTranslation().toString()));
translation.setOutputMarkupId(true);
listItem.add(translation);

}
};
languagesContainer.setOutputMarkupId(true);
fullDataContainer.add(languagesContainer);


AjaxButton showHideLanguagesButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES, showFullData ? createStringResource("PolyStringEditorPanel.hideLanguages") :
createStringResource("PolyStringEditorPanel.showLanguages")) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
showFullData = !showFullData;
target.add(PolyStringEditorPanel.this);
}
};
showHideLanguagesButton.setOutputMarkupId(true);
showHideLanguagesButton.add(AttributeAppender.append("style", "cursor: pointer;"));
add(showHideLanguagesButton);

}

private String getDefaultPolyStringValue(){
return "";
}

private String getKeyValue(){
return "";
}

private List<PolyStringTranslationArgumentType> getTranslationArgumentList(){
if (getModel() == null || getModelObject() == null || getModelObject().getTranslation() == null ||
getModelObject().getTranslation().getArgument() == null){
return new ArrayList<>();
}
return getModelObject().getTranslation().getArgument();
}

}
Expand Up @@ -18,6 +18,28 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>

<div class="row">

<div class="col-md-12">
<h3><wicket:message key="PageInternals.title.thresholds.counters"/></h3>
<table class="table table-bordered">
<tbody>
<tr wicket:id="thresholdCountersTable">
<th wicket:id="counterTask"/>
<td wicket:id="counterPolicyRule"/>
<td wicket:id="counterCount"/>
<td>
<a class="btn btn-primary" wicket:id="resetThresholdCounter">
<wicket:message key="InternalsCountersPanel.threshold.reset.button"/>
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="row">

<div class="col-md-6">
Expand Down
@@ -1,15 +1,22 @@
package com.evolveum.midpoint.web.page.admin.configuration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.repo.api.CounterSepcification;
import com.evolveum.midpoint.schema.internals.InternalCounters;
import com.evolveum.midpoint.schema.internals.InternalMonitor;
import com.evolveum.midpoint.web.component.dialog.ConfirmationPanel;

public class InternalsCountersPanel extends BasePanel<ListView<InternalCounters>> {

Expand All @@ -18,7 +25,14 @@ public class InternalsCountersPanel extends BasePanel<ListView<InternalCounters>
private static final String ID_COUNTERS_TABLE = "countersTable";
private static final String ID_COUNTER_LABEL = "counterLabel";
private static final String ID_COUNTER_VALUE = "counterValue";

private static final String ID_THRESHOLD_COUNTER = "thresholdCounter";
private static final String ID_THRESHOLD_COUNTERS_TABLE = "thresholdCountersTable";
private static final String ID_COUNTER_TASK_LABEL = "counterTask";
private static final String ID_COUNTER_POLICY_RULE_LABEL = "counterPolicyRule";
private static final String ID_COUNTER_COUNT_LABEL = "counterCount";
private static final String ID_RESET_THRESHOLD_COUNTER = "resetThresholdCounter";


public InternalsCountersPanel(String id) {
super(id);
}
Expand All @@ -29,6 +43,49 @@ protected void onInitialize() {

setOutputMarkupId(true);

Label thresholdCounter = new Label(ID_THRESHOLD_COUNTER, createStringResource("InternalsCountersPanel.thresholds"));
add(thresholdCounter);

ListView<CounterSepcification> thresholdCountersTable = new ListView<CounterSepcification>(ID_THRESHOLD_COUNTERS_TABLE, createThresholdCounterModel()) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem<CounterSepcification> item) {
CounterSepcification counter = item.getModelObject();
Label task = new Label(ID_COUNTER_TASK_LABEL, counter.getTaskName());
item.add(task);

Label policyRule = new Label(ID_COUNTER_POLICY_RULE_LABEL, counter.getPolicyRuleName());
item.add(policyRule);

Label count = new Label(ID_COUNTER_COUNT_LABEL, counter.getCount());
item.add(count);

AjaxLink<Void> resetCounter = new AjaxLink<Void>(ID_RESET_THRESHOLD_COUNTER) {

private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
ConfirmationPanel confirmPanel = new ConfirmationPanel(getPageBase().getMainPopupBodyId(), createStringResource("InternalsCountersPanel.reset.confirm.message", counter.getTaskName(), counter.getPolicyRuleName())) {

private static final long serialVersionUID = 1L;

public void yesPerformed(AjaxRequestTarget target) {
getPageBase().getCounterManager().removeCounter(counter);
target.add(InternalsCountersPanel.this);
};
};
getPageBase().showMainPopup(confirmPanel, target);
target.add(InternalsCountersPanel.this);
}
};
item.add(resetCounter);
}

};
add(thresholdCountersTable);

ListView<InternalCounters> countersTable = new ListView<InternalCounters>(ID_COUNTERS_TABLE,
Arrays.asList(InternalCounters.values())) {
private static final long serialVersionUID = 1L;
Expand All @@ -54,4 +111,17 @@ public String getObject() {
};
add(countersTable);
}
}

private IModel<List<CounterSepcification>> createThresholdCounterModel() {
return new IModel<List<CounterSepcification>>() {
private static final long serialVersionUID = 1L;

@Override
public List<CounterSepcification> getObject() {
Collection<CounterSepcification> thresholdCounters = getPageBase().getCounterManager().listCounters();
return new ArrayList<>(thresholdCounters);
}
};
}

}
Expand Up @@ -115,7 +115,6 @@ protected List<QName> getSupportedObjectTypes(boolean includeAbstractTypes) {
List<QName> objectTypes = WebComponentUtil.createAssignmentHolderTypeQnamesList();
objectTypes.remove(ShadowType.COMPLEX_TYPE);
objectTypes.remove(ObjectType.COMPLEX_TYPE);
objectTypes.remove(AssignmentHolderType.COMPLEX_TYPE);
return objectTypes;
}

Expand Down

0 comments on commit be983b1

Please sign in to comment.