Skip to content

Commit

Permalink
adding configurable dashboard, addd repo support for dashboardType, a…
Browse files Browse the repository at this point in the history
…dding proportional expression evaluator
  • Loading branch information
skublik committed Feb 13, 2019
1 parent be8f051 commit f01daf6
Show file tree
Hide file tree
Showing 16 changed files with 132,396 additions and 3 deletions.
Expand Up @@ -104,6 +104,7 @@
import com.evolveum.midpoint.web.page.admin.configuration.*;
import com.evolveum.midpoint.web.page.admin.home.PageDashboard;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardAdmin;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardConfigurable;
import com.evolveum.midpoint.web.page.admin.home.PageDashboardInfo;
import com.evolveum.midpoint.web.page.admin.reports.*;
import com.evolveum.midpoint.web.page.admin.resources.*;
Expand Down Expand Up @@ -1943,6 +1944,24 @@ private MainMenuItem createHomeItems() {

addMenuItem(item, "PageAdmin.menu.dashboard.info", PageDashboardInfo.class);
addMenuItem(item, "PageAdmin.menu.dashboard.admin", PageDashboardAdmin.class);

OperationResult result = new OperationResult("Search Dashboard");
List<PrismObject<DashboardType>> dashboards = WebModelServiceUtils.searchObjects(DashboardType.class, null, result, this);
if(dashboards != null) {
dashboards.forEach(prismObject -> {
DashboardType dashboard = prismObject.getRealValue();
StringResourceModel label = null;
if(dashboard.getDisplay() != null && dashboard.getDisplay().getLabel() != null) {
label = createStringResource(dashboard.getDisplay().getLabel().getOrig());
} else {
label = createStringResource(dashboard.getName());
}
PageParameters pageParameters = new PageParameters();
pageParameters.add(PageDashboardConfigurable.PARAM_DASHBOARD_ID, "e159a3ac-1d8a-11e9-83b6-e79f71fe88b7");
MenuItem menu = new MenuItem(label, "", PageDashboardConfigurable.class, pageParameters, null, null);
item.getItems().add(menu);
});
}

return item;
}
Expand Down

Large diffs are not rendered by default.

@@ -0,0 +1,36 @@
<!--
~ 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.
-->

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<div class="col-lg-3 col-xs-6">
<div class="small-box" wicket:id="infoBox">
<div class="inner">
<h3 wicket:id="number"/>
<p wicket:id="message"/>
</div>
<div class="icon">
<i wicket:id="icon"></i>
</div>
<div class="small-box-footer" wicket:id="moreInfoBox">
<div wicket:id="moreInfoBoxLabel"/>
<i class="fa fa-arrow-circle-right" wicket:id="moreInfoBoxIcon"/>
</div>
</div>
</div>
</wicket:panel>
</html>
@@ -0,0 +1,125 @@
/**
* 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.gui.impl.component.box;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.component.IRequestablePage;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DashboardWidgetSourceTypeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.DashboardWidgetType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectCollectionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;

/**
* @author skublik
*/
public class SmallInfoBoxPanel extends InfoBoxPanel{
private static final long serialVersionUID = 1L;

private static final Trace LOGGER = TraceManager.getTrace(SmallInfoBoxPanel.class);

private static final String ID_MORE_INFO_BOX = "moreInfoBox";
private static final String ID_MORE_INFO_BOX_ICON = "moreInfoBoxIcon";
private static final String ID_MORE_INFO_BOX_LABEL = "moreInfoBoxLabel";

public SmallInfoBoxPanel(String id, IModel<DashboardWidgetType> model, PageBase pageBase) {
super(id, model, pageBase);
}

@Override
protected void customInitLayout(WebMarkupContainer parentInfoBox) {
IModel<DashboardWidgetType> model = (IModel<DashboardWidgetType>)getDefaultModel();
WebMarkupContainer moreInfoBox = new WebMarkupContainer(ID_MORE_INFO_BOX);
parentInfoBox.add(moreInfoBox);
WebMarkupContainer moreInfoBoxIcon = new WebMarkupContainer(ID_MORE_INFO_BOX_ICON);
moreInfoBox.add(moreInfoBoxIcon);
Label moreInfoBoxLabel = new Label(ID_MORE_INFO_BOX_LABEL, getPageBase().createStringResource("PageDashboard.infobox.moreInfo"));
moreInfoBox.add(moreInfoBoxLabel);

Class<? extends IRequestablePage> linkPage = getLinkRef();
if (linkPage != null) {
moreInfoBox.add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 1L;

@Override
protected void onEvent(AjaxRequestTarget target) {
setResponsePage(linkPage);
}
});
moreInfoBox.add(AttributeModifier.append("class", "cursor-pointer"));
} else {
LOGGER.warn("Link is not found for widget " + model.getObject());
setInvisible(moreInfoBoxIcon);
setInvisible(moreInfoBoxLabel);
moreInfoBox.add(AttributeModifier.append("style", "height: 26px; background:rgba(0, 0, 0, 0.1) !important;"));
}

}

// @Override
// protected void customInitLayout(WebMarkupContainer parentInfoBox, IModel<InfoBoxType> model,
// Class<? extends IRequestablePage> linkPage) {
//
// WebMarkupContainer moreInfoBox = new WebMarkupContainer(ID_MORE_INFO_BOX);
// parentInfoBox.add(moreInfoBox);
// WebMarkupContainer moreInfoBoxIcon = new WebMarkupContainer(ID_MORE_INFO_BOX_ICON);
// moreInfoBox.add(moreInfoBoxIcon);
// Label moreInfoBoxLabel = new Label(ID_MORE_INFO_BOX_LABEL, this.pageBase.createStringResource("PageDashboard.infobox.moreInfo"));
// moreInfoBox.add(moreInfoBoxLabel);
//
// if (linkPage != null) {
// moreInfoBox.add(new AjaxEventBehavior("click") {
// private static final long serialVersionUID = 1L;
//
// @Override
// protected void onEvent(AjaxRequestTarget target) {
// setResponsePage(linkPage);
// }
// });
// moreInfoBox.add(AttributeModifier.append("class", "cursor-pointer"));
// } else {
// setInvisible(moreInfoBoxIcon);
// setInvisible(moreInfoBoxLabel);
// moreInfoBox.add(AttributeModifier.append("style", "height: 26px;"));
// }
// }

private void setInvisible(Component component) {
component.add(new VisibleEnableBehaviour(){
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
return false;
}
});
}
}
@@ -0,0 +1,27 @@
<?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">
<body>
<wicket:extend>
<div class="row" wicket:id="widgets">
<div wicket:id="widget"/>
</div>
</wicket:extend>
</body>
</html>

0 comments on commit f01daf6

Please sign in to comment.