Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
My requests panel is added to user dashboard page
- Loading branch information
1 parent
4d764a9
commit 6de46d5
Showing
6 changed files
with
205 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/self/PageSelfDashboard.properties
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...dmin-gui/src/main/java/com/evolveum/midpoint/web/page/self/component/MyRequestsPanel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
~ 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 wicket:id="requestsTable"/> | ||
</wicket:panel> | ||
</html> |
84 changes: 84 additions & 0 deletions
84
...dmin-gui/src/main/java/com/evolveum/midpoint/web/page/self/component/MyRequestsPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.evolveum.midpoint.web.page.self.component; | ||
|
||
import com.evolveum.midpoint.prism.xml.XmlTypeConverter; | ||
import com.evolveum.midpoint.web.component.data.TablePanel; | ||
import com.evolveum.midpoint.web.component.data.column.LinkColumn; | ||
import com.evolveum.midpoint.web.component.util.ListDataProvider; | ||
import com.evolveum.midpoint.web.component.util.SimplePanel; | ||
import com.evolveum.midpoint.web.page.admin.workflow.PageProcessInstance; | ||
import com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto; | ||
import com.evolveum.midpoint.web.util.OnePageParameterEncoder; | ||
import org.apache.commons.lang.time.DurationFormatUtils; | ||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; | ||
import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.repeater.Item; | ||
import org.apache.wicket.model.AbstractReadOnlyModel; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.request.mapper.parameter.PageParameters; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by Kate on 03.10.2015. | ||
*/ | ||
public class MyRequestsPanel extends SimplePanel<List<ProcessInstanceDto>> { | ||
private static final String ID_REQUESTS_TABLE = "requestsTable"; | ||
|
||
public MyRequestsPanel(String id) { | ||
super(id, null); | ||
} | ||
|
||
public MyRequestsPanel(String id, IModel<List<ProcessInstanceDto>> model) { | ||
super(id, model); | ||
} | ||
|
||
@Override | ||
protected void initLayout() { | ||
List<IColumn<ProcessInstanceDto, String>> columns = new ArrayList<IColumn<ProcessInstanceDto, String>>(); | ||
columns.add(new LinkColumn<ProcessInstanceDto>(createStringResource("MyRequestsPanel.waitingFor"), "name") { | ||
|
||
@Override | ||
public void onClick(AjaxRequestTarget target, IModel<ProcessInstanceDto> rowModel) { | ||
ProcessInstanceDto piDto = rowModel.getObject(); | ||
itemDetailsPerformed(target, false, piDto.getProcessInstance().getProcessInstanceId()); | ||
} | ||
}); | ||
columns.add(new AbstractColumn<ProcessInstanceDto, String>(createStringResource("MyRequestsPanel.started")) { | ||
|
||
@Override | ||
public void populateItem(Item<ICellPopulator<ProcessInstanceDto>> item, String componentId, | ||
final IModel<ProcessInstanceDto> rowModel) { | ||
item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() { | ||
|
||
@Override | ||
public Object getObject() { | ||
ProcessInstanceDto pi = rowModel.getObject(); | ||
Date started = XmlTypeConverter.toDate(pi.getProcessInstance().getStartTimestamp()); | ||
if (started == null) { | ||
return "?"; | ||
} else { | ||
// todo i18n | ||
return DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - started.getTime(), true, true) + " ago"; | ||
} | ||
} | ||
})); | ||
} | ||
}); | ||
ISortableDataProvider provider = new ListDataProvider(this, getModel()); | ||
TablePanel accountsTable = new TablePanel<ProcessInstanceDto>(ID_REQUESTS_TABLE, provider, columns); | ||
add(accountsTable); | ||
} | ||
|
||
private void itemDetailsPerformed(AjaxRequestTarget target, boolean finished, String pid) { | ||
PageParameters parameters = new PageParameters(); | ||
parameters.add(OnePageParameterEncoder.PARAMETER, pid); | ||
parameters.add(PageProcessInstance.PARAM_PROCESS_INSTANCE_FINISHED, finished); | ||
setResponsePage(new PageProcessInstance(parameters, this.getPageBase())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters