Skip to content

Commit

Permalink
adding edit panel for dashboard report (MID-5525)
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jul 22, 2019
1 parent 5e6790b commit ff06a8b
Show file tree
Hide file tree
Showing 9 changed files with 421 additions and 163 deletions.
Expand Up @@ -51,6 +51,7 @@
import com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto;
import com.evolveum.midpoint.web.util.Base64Model;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportEngineSelectionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType;

/**
Expand Down Expand Up @@ -87,8 +88,6 @@ protected ReportDto load() {
return loadReport();
}
};

initLayout();
}

public PageReport(final ReportDto reportDto) {
Expand All @@ -99,14 +98,12 @@ protected ReportDto load() {
// never called
return reportDto;
}

};
initLayout();
}

private ReportDto loadReport() {
StringValue reportOid = getPageParameters().get(OnePageParameterEncoder.PARAMETER);

Task task = createSimpleTask(OPERATION_LOAD_REPORT);
OperationResult result = task.getResult();
PrismObject<ReportType> prismReport = WebModelServiceUtils.loadObject(ReportType.class, reportOid.toString(),
Expand All @@ -121,10 +118,17 @@ private ReportDto loadReport() {

// return prismReport;
}

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

private void initLayout() {
Form mainForm = new com.evolveum.midpoint.web.component.form.Form(ID_MAIN_FORM);
add(mainForm);
ReportEngineSelectionType reportEngineType = model.getObject().getReportEngineType();

List<ITab> tabs = new ArrayList<>();
tabs.add(new AbstractTab(createStringResource("PageReport.basic")) {
Expand All @@ -136,27 +140,30 @@ public WebMarkupContainer getPanel(String panelId) {
return new ReportConfigurationPanel(panelId, model);
}
});
tabs.add(new AbstractTab(createStringResource("PageReport.jasperTemplate")) {

private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer getPanel(String panelId) {
return new JasperReportConfigurationPanel(panelId, model);
// IModel<String> title = PageReport.this.createStringResource("PageReport.jasperTemplate");
// IModel<String> data = new Base64Model(new PrismPropertyModel<>(model, ReportType.F_TEMPLATE));
// return new AceEditorPanel(panelId, title, data);
}
});
tabs.add(new AbstractTab(createStringResource("PageReport.jasperTemplateStyle")) {

private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer getPanel(String panelId) {
IModel<String> title = PageReport.this.createStringResource("PageReport.jasperTemplateStyle");
IModel<String> data = new Base64Model(new PropertyModel(model, "templateStyle"));
return new AceEditorPanel(panelId, title, data);
}
});
if(!ReportEngineSelectionType.DASHBOARD.equals(reportEngineType)) {
tabs.add(new AbstractTab(createStringResource("PageReport.jasperTemplate")) {

private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer getPanel(String panelId) {
return new JasperReportConfigurationPanel(panelId, model);
// IModel<String> title = PageReport.this.createStringResource("PageReport.jasperTemplate");
// IModel<String> data = new Base64Model(new PrismPropertyModel<>(model, ReportType.F_TEMPLATE));
// return new AceEditorPanel(panelId, title, data);
}
});
tabs.add(new AbstractTab(createStringResource("PageReport.jasperTemplateStyle")) {

private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer getPanel(String panelId) {
IModel<String> title = PageReport.this.createStringResource("PageReport.jasperTemplateStyle");
IModel<String> data = new Base64Model(new PropertyModel(model, "templateStyle"));
return new AceEditorPanel(panelId, title, data);
}
});
}

// tabs.add(new AbstractTab(createStringResource("PageReport.fullXml")) {
//
// @Override
Expand Down
@@ -0,0 +1,36 @@
<!--
~ Copyright (c) 2010-2013 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.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<div class="row">
<h3 style="margin-left: 20px;"><wicket:message key="ReportConfigurationPanel.title.basic"/></h3>

<div class="form-group col-md-12" wicket:id="name" />
<div class="form-group col-md-12" wicket:id="description" />
<div class="form-group col-md-12">
<div class=" control-label col-md-2">
<span>
<wicket:message key="DashboardReportBasicConfigurationPanel.label.dashboard"/>
</span>
</div>
<div class="col-md-10" wicket:id="dashboard" />
</div>
</div>

</wicket:panel>
</html>
@@ -0,0 +1,98 @@
/*
* 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.page.admin.reports.component;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.impl.factory.ItemRealValueModel;
import com.evolveum.midpoint.gui.impl.prism.PrismReferencePanel;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.query.ObjectFilter;
import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty;
import com.evolveum.midpoint.web.component.form.DropDownFormGroup;
import com.evolveum.midpoint.web.component.form.TextAreaFormGroup;
import com.evolveum.midpoint.web.component.form.TextFormGroup;
import com.evolveum.midpoint.web.component.form.ValueChoosePanel;
import com.evolveum.midpoint.web.page.admin.reports.dto.ReportDto;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractRoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DashboardType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

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

import javax.xml.namespace.QName;

/**
* @author skublik
*
*/
public class DashboardReportBasicConfigurationPanel extends BasePanel<ReportDto> {

private static final String ID_NAME = "name";
private static final String ID_DESCRIPTION = "description";
private static final String ID_DASHBOARD = "dashboard";
private static final String ID_LABEL_SIZE = "col-md-2";
private static final String ID_INPUT_SIZE = "col-md-10";

public DashboardReportBasicConfigurationPanel(String id, IModel<ReportDto> model) {
super(id, model);
initLayout();
}

protected void initLayout() {
TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<>(getModel(), ID_NAME),
createStringResource("ObjectType.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
add(name);

TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION,
new PropertyModel<>(getModel(), ID_DESCRIPTION),
createStringResource("ObjectType.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
add(description);

ValueChoosePanel<ObjectReferenceType> panel =
new ValueChoosePanel<ObjectReferenceType>(ID_DASHBOARD,
new PropertyModel<ObjectReferenceType>(getModel(), ReportDto.F_DASHBOARD_REF)) {

private static final long serialVersionUID = 1L;

@Override
public List<QName> getSupportedTypes() {
return Arrays.asList(DashboardType.COMPLEX_TYPE);
}


@Override
protected <O extends ObjectType> Class<O> getDefaultType(List<QName> supportedTypes) {
return (Class<O>) DashboardType.class;
}

};
add(panel);

}
}
@@ -0,0 +1,39 @@
<!--
~ Copyright (c) 2010-2013 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.
-->
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<div class="row">
<div class="col-md-6">
<h3 style="margin-left: 20px;"><wicket:message key="ReportConfigurationPanel.title.basic"/></h3>

<div class="form-group" wicket:id="name" />
<div class="form-group" wicket:id="description" />
<div class="form-group" wicket:id="exportType" />

</div>
<div class="col-md-6">
<h3 style="margin-left: 20px;"><wicket:message key="ReportConfigurationPanel.title.advanced"/></h3>
<div class="form-group" wicket:id="maxPages" />
<div class="form-group" wicket:id="timeout" />
<div class="form-group" wicket:id="virtualizer" />
<div class="form-group" wicket:id="virtualizerKickOn" />
</div>
</div>

</wicket:panel>
</html>

0 comments on commit ff06a8b

Please sign in to comment.