Several changes to the UI: * Use bindings to link ZUL items to controller methods. * Add Model for DashboardController * Implement methods to bring data and calculate progress KPI "Task Status" * Fetch PlanningState to get updated planning status * Add dumb Label to the view to do preliminary tests.
FEA: ItEr75S27PerProjectDashboard
This commit is contained in:
parent
edab490939
commit
c80e174c5d
5 changed files with 195 additions and 79 deletions
|
|
@ -1,8 +1,6 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -22,27 +20,26 @@
|
|||
package org.libreplan.web.dashboard;
|
||||
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.web.common.Util;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Label;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
/**
|
||||
* Controller for global resourceload view
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* Controller for dashboardfororder view
|
||||
* @author Nacho Barrientos <nacho@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class DashboardController extends GenericForwardComposer {
|
||||
|
||||
//@Autowired
|
||||
//private IResourceLoadModel resourceLoadModel;
|
||||
@Autowired
|
||||
private DashboardModel dashboardModel;
|
||||
|
||||
private Label testlabel;
|
||||
|
||||
private org.zkoss.zk.ui.Component parent;
|
||||
private Window dashboardWindow;
|
||||
|
||||
private Order order;
|
||||
|
||||
|
|
@ -52,11 +49,31 @@ public class DashboardController extends GenericForwardComposer {
|
|||
@Override
|
||||
public void doAfterCompose(org.zkoss.zk.ui.Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
this.parent = comp;
|
||||
this.testlabel.setValue("hello world");
|
||||
this.dashboardWindow = (Window)comp;
|
||||
Util.createBindingsFor(this.dashboardWindow);
|
||||
}
|
||||
|
||||
public void setCurrentOrder(Order order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
dashboardModel.setCurrentOrder(order);
|
||||
if (this.dashboardWindow != null) {
|
||||
Util.reloadBindings(this.dashboardWindow);
|
||||
}
|
||||
}
|
||||
|
||||
/* Test */
|
||||
public String getTextForLabel() {
|
||||
if (dashboardModel.getPercentageOfFinishedTasks() == null) {
|
||||
return "NULL";
|
||||
}
|
||||
String out = dashboardModel.getPercentageOfFinishedTasks().toString() + " " +
|
||||
dashboardModel.getPercentageOfInProgressTasks() + " " +
|
||||
dashboardModel.getPercentageOfReadyToStartTasks() + " " +
|
||||
dashboardModel.getPercentageOfBlockedTasks();
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.libreplan.web.dashboard;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.business.planner.entities.TaskElement;
|
||||
import org.libreplan.business.planner.entities.TaskStatusEnum;
|
||||
import org.libreplan.business.planner.entities.visitors.AccumulateTasksStatusVisitor;
|
||||
import org.libreplan.business.planner.entities.visitors.ResetTasksStatusVisitor;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Model for UI operations related to Order Dashboard View
|
||||
* @author Nacho Barrientos <nacho@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class DashboardModel {
|
||||
|
||||
private Order currentOrder;
|
||||
|
||||
private Map<TaskStatusEnum, BigDecimal> taskStatusStats;
|
||||
|
||||
public DashboardModel() {
|
||||
taskStatusStats = new EnumMap<TaskStatusEnum, BigDecimal>(TaskStatusEnum.class);
|
||||
}
|
||||
|
||||
public void setCurrentOrder(Order order) {
|
||||
this.currentOrder = order;
|
||||
this.calculateTaskStatusStatistics();
|
||||
}
|
||||
|
||||
public BigDecimal getPercentageOfFinishedTasks() {
|
||||
return taskStatusStats.get(TaskStatusEnum.FINISHED);
|
||||
}
|
||||
|
||||
public BigDecimal getPercentageOfInProgressTasks() {
|
||||
return taskStatusStats.get(TaskStatusEnum.IN_PROGRESS);
|
||||
}
|
||||
|
||||
public BigDecimal getPercentageOfReadyToStartTasks() {
|
||||
return taskStatusStats.get(TaskStatusEnum.READY_TO_START);
|
||||
}
|
||||
|
||||
public BigDecimal getPercentageOfBlockedTasks() {
|
||||
return taskStatusStats.get(TaskStatusEnum.BLOCKED);
|
||||
}
|
||||
|
||||
private void calculateTaskStatusStatistics() {
|
||||
AccumulateTasksStatusVisitor visitor = new AccumulateTasksStatusVisitor();
|
||||
TaskElement rootTask = getRootTask();
|
||||
if(rootTask != null) {
|
||||
resetTasksStatusInGraph();
|
||||
rootTask.acceptVisitor(visitor);
|
||||
}
|
||||
Map<TaskStatusEnum, Integer> count = visitor.getTaskStatusData();
|
||||
int totalTasks = this.countTasksInAResultMap(count);
|
||||
|
||||
for (Map.Entry<TaskStatusEnum, Integer> entry : count.entrySet()) {
|
||||
BigDecimal percentage;
|
||||
if(totalTasks == 0){
|
||||
percentage = BigDecimal.ZERO;
|
||||
|
||||
} else {
|
||||
percentage = new BigDecimal(100*(entry.getValue()/(1.0*totalTasks)),
|
||||
MathContext.DECIMAL32);
|
||||
}
|
||||
taskStatusStats.put(entry.getKey(), percentage);
|
||||
}
|
||||
}
|
||||
|
||||
private TaskElement getRootTask(){
|
||||
return currentOrder.getAssociatedTaskElement();
|
||||
}
|
||||
|
||||
private void resetTasksStatusInGraph() {
|
||||
ResetTasksStatusVisitor visitor = new ResetTasksStatusVisitor();
|
||||
getRootTask().acceptVisitor(visitor);
|
||||
}
|
||||
|
||||
private int countTasksInAResultMap(Map<? extends Object, Integer> map) {
|
||||
int sum = 0;
|
||||
for (Object count: map.values()) {
|
||||
sum += (Integer)count;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -25,13 +25,18 @@ import static org.libreplan.web.planner.tabs.MultipleTabsPlannerController.getSc
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.libreplan.business.common.IAdHocTransactionService;
|
||||
import org.libreplan.business.common.IOnTransaction;
|
||||
import org.libreplan.business.common.Registry;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.web.dashboard.DashboardController;
|
||||
import org.libreplan.web.planner.order.IOrderPlanningGate;
|
||||
import org.libreplan.web.planner.order.OrderPlanningController;
|
||||
import org.libreplan.web.planner.order.PlanningStateCreator;
|
||||
import org.libreplan.web.planner.order.PlanningStateCreator.IActionsOnRetrieval;
|
||||
import org.libreplan.web.planner.order.PlanningStateCreator.PlanningState;
|
||||
import org.libreplan.web.planner.tabs.CreatedOnDemandTab.IComponentCreator;
|
||||
import org.zkoss.ganttz.extensions.ITab;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zul.Image;
|
||||
import org.zkoss.zul.Label;
|
||||
|
|
@ -43,33 +48,26 @@ import org.zkoss.zul.Label;
|
|||
*/
|
||||
public class DashboardTabCreator {
|
||||
|
||||
private final IOrderPlanningGate orderPlanningGate;
|
||||
|
||||
public static ITab create(Mode mode,
|
||||
PlanningStateCreator planningStateCreator,
|
||||
DashboardController dashboardController,
|
||||
OrderPlanningController orderPlanningController,
|
||||
Component breadcrumbs,
|
||||
IOrderPlanningGate orderPlanningGate) {
|
||||
return new DashboardTabCreator(mode, dashboardController,
|
||||
orderPlanningController, orderPlanningGate,
|
||||
breadcrumbs)
|
||||
.build();
|
||||
Component breadcrumbs) {
|
||||
return new DashboardTabCreator(mode, planningStateCreator,
|
||||
dashboardController, breadcrumbs).build();
|
||||
}
|
||||
|
||||
private final PlanningStateCreator planningStateCreator;
|
||||
private final Mode mode;
|
||||
private final DashboardController dashboardController;
|
||||
private final OrderPlanningController orderPlanningController;
|
||||
private final Component breadcrumbs;
|
||||
|
||||
private DashboardTabCreator(Mode mode,
|
||||
PlanningStateCreator planningStateCreator,
|
||||
DashboardController dashboardController,
|
||||
OrderPlanningController orderPlanningController,
|
||||
IOrderPlanningGate orderPlanningGate,
|
||||
Component breadcrumbs) {
|
||||
this.mode = mode;
|
||||
this.planningStateCreator = planningStateCreator;
|
||||
this.dashboardController = dashboardController;
|
||||
this.orderPlanningController = orderPlanningController;
|
||||
this.orderPlanningGate = orderPlanningGate;
|
||||
this.breadcrumbs = breadcrumbs;
|
||||
}
|
||||
|
||||
|
|
@ -99,17 +97,34 @@ public class DashboardTabCreator {
|
|||
|
||||
@Override
|
||||
protected void afterShowAction() {
|
||||
Order order = orderPlanningController.getOrder();
|
||||
dashboardController.setCurrentOrder(order);
|
||||
PlanningState planningState = getPlanningState(mode.getOrder(), getDesktop());
|
||||
Order currentOrder = planningState.getOrder();
|
||||
dashboardController.setCurrentOrder(currentOrder);
|
||||
dashboardController.reload();
|
||||
breadcrumbs.getChildren().clear();
|
||||
breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR));
|
||||
breadcrumbs.appendChild(new Label(getSchedulingLabel()));
|
||||
breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR));
|
||||
breadcrumbs.appendChild(new Label(_("Order Dashboard")));
|
||||
breadcrumbs.appendChild(new Image(BREADCRUMBS_SEPARATOR));
|
||||
Order currentOrder = mode.getOrder();
|
||||
breadcrumbs.appendChild(new Label(currentOrder.getName()));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
PlanningState getPlanningState(final Order order, final Desktop desktop) {
|
||||
IAdHocTransactionService transactionService = Registry.getTransactionService();
|
||||
return transactionService.runOnTransaction(new IOnTransaction<PlanningState>() {
|
||||
public PlanningState execute() {
|
||||
return planningStateCreator.retrieveOrCreate(desktop,
|
||||
order, new IActionsOnRetrieval() {
|
||||
|
||||
@Override
|
||||
public void onRetrieval(PlanningState planningState) {
|
||||
planningState.reattach();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,32 +271,8 @@ public class MultipleTabsPlannerController implements Composer,
|
|||
|
||||
}, parameters);
|
||||
|
||||
dashboardTab = DashboardTabCreator.create(mode, dashboardController, orderPlanningController,
|
||||
breadcrumbs, new IOrderPlanningGate() {
|
||||
|
||||
@Override
|
||||
public void goToScheduleOf(Order order) {
|
||||
getTabsRegistry()
|
||||
.show(planningTab, changeModeTo(order));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void goToOrderDetails(Order order) {
|
||||
getTabsRegistry().show(ordersTab, changeModeTo(order));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void goToTaskResourceAllocation(Order order,
|
||||
TaskElement task) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void goToDashboard(Order order) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
});
|
||||
dashboardTab = DashboardTabCreator.create(mode, planningStateCreator,
|
||||
dashboardController, breadcrumbs);
|
||||
|
||||
final boolean isMontecarloVisible = isMonteCarloVisible();
|
||||
if (isMontecarloVisible) {
|
||||
|
|
|
|||
|
|
@ -1,34 +1,29 @@
|
|||
<!--
|
||||
This file is part of LibrePlan
|
||||
This file is part of LibrePlan
|
||||
|
||||
Copyright (C) 2010-2011 Igalia, S.L.
|
||||
Copyright (C) 2010-2011 Igalia, S.L.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<zk>
|
||||
|
||||
<zscript><![CDATA[
|
||||
dashboardController = arg.get("dashboardController");
|
||||
]]>
|
||||
dsController = arg.get("dashboardController");
|
||||
]]>
|
||||
</zscript>
|
||||
<div self="@{define(content)}" >
|
||||
<window apply="${dashboardController}">
|
||||
|
||||
<label id="testlabel"/>
|
||||
|
||||
<div self="@{define(content)}">
|
||||
<window id="dashboardWindow" apply="${dsController}">
|
||||
<label value="@{dsController.textForLabel}" />
|
||||
</window>
|
||||
</div>
|
||||
|
||||
</zk>
|
||||
Loading…
Add table
Reference in a new issue