Search in sources :

Example 1 with ResourceAllocationChart

use of io.imunity.furms.ui.charts.ResourceAllocationChart in project furms by unity-idm.

the class ProjectAllocationsDetailsView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    Optional<String> projectId = event.getLocation().getQueryParameters().getParameters().getOrDefault("projectId", List.of()).stream().findAny();
    Optional<ProjectAllocation> projectAllocation = ofNullable(parameter).filter(id -> projectId.isPresent()).flatMap(id -> handleExceptions(() -> projectAllocationService.findByProjectIdAndId(projectId.get(), id))).flatMap(Function.identity());
    if (projectAllocation.isPresent()) {
        getContent().removeAll();
        breadCrumbParameter = new BreadCrumbParameter(parameter, projectAllocation.get().name, getTranslation("view.user-settings.projects.page.details.bread-crumb"));
        ResourceAllocationChart resourceAllocationChart = new ResourceAllocationChart(chartPowerService.getChartDataForProjectAlloc(projectAllocation.get().projectId, projectAllocation.get().id), jsonExporter.getJsonForProjectAllocation(projectAllocation.get().projectId, projectAllocation.get().id), csvExporter.getCsvForProjectAllocation(projectAllocation.get().projectId, projectAllocation.get().id), true);
        getContent().add(resourceAllocationChart);
    }
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) Optional.ofNullable(java.util.Optional.ofNullable) ResourceUsageJSONExporter(io.imunity.furms.api.export.ResourceUsageJSONExporter) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) Route(com.vaadin.flow.router.Route) OptionalParameter(com.vaadin.flow.router.OptionalParameter) List(java.util.List) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Optional(java.util.Optional) ResourceUsageCSVExporter(io.imunity.furms.api.export.ResourceUsageCSVExporter) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) CommunityAdminMenu(io.imunity.furms.ui.views.community.CommunityAdminMenu) ChartPowerService(io.imunity.furms.ui.charts.ChartPowerService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart)

Example 2 with ResourceAllocationChart

use of io.imunity.furms.ui.charts.ResourceAllocationChart in project furms by unity-idm.

the class ProjectResourceAllocationsDetailsView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    Optional<String> projectId = event.getLocation().getQueryParameters().getParameters().getOrDefault("projectId", List.of()).stream().findAny();
    Optional<ProjectAllocation> projectAllocation = ofNullable(parameter).filter(id -> projectId.isPresent()).flatMap(id -> handleExceptions(() -> projectAllocationService.findByProjectIdAndId(projectId.get(), id))).flatMap(Function.identity());
    if (projectAllocation.isPresent()) {
        getContent().removeAll();
        breadCrumbParameter = new BreadCrumbParameter(parameter, projectAllocation.get().name, getTranslation("view.user-settings.projects.page.details.bread-crumb"));
        ResourceAllocationChart resourceAllocationChart = new ResourceAllocationChart(chartPowerService.getChartDataForProjectAlloc(projectAllocation.get().projectId, projectAllocation.get().id), jsonExporter.getJsonForProjectAllocation(projectAllocation.get().projectId, projectAllocation.get().id), csvExporter.getCsvForProjectAllocation(projectAllocation.get().projectId, projectAllocation.get().id));
        getContent().add(resourceAllocationChart);
    }
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) Optional.ofNullable(java.util.Optional.ofNullable) ResourceUsageJSONExporter(io.imunity.furms.api.export.ResourceUsageJSONExporter) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) Route(com.vaadin.flow.router.Route) OptionalParameter(com.vaadin.flow.router.OptionalParameter) List(java.util.List) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Optional(java.util.Optional) ResourceUsageCSVExporter(io.imunity.furms.api.export.ResourceUsageCSVExporter) UserSettingsMenu(io.imunity.furms.ui.views.user_settings.UserSettingsMenu) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) ChartPowerService(io.imunity.furms.ui.charts.ChartPowerService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ProjectAllocation(io.imunity.furms.domain.project_allocation.ProjectAllocation) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart)

Example 3 with ResourceAllocationChart

use of io.imunity.furms.ui.charts.ResourceAllocationChart in project furms by unity-idm.

the class CommunityAllocationsDetailsView method setParameter.

@Override
public void setParameter(BeforeEvent event, @OptionalParameter String parameter) {
    Optional<CommunityAllocation> communityAllocation = ofNullable(parameter).flatMap(id -> handleExceptions(() -> communityAllocationService.findById(id))).flatMap(Function.identity());
    if (communityAllocation.isPresent()) {
        getContent().removeAll();
        breadCrumbParameter = new BreadCrumbParameter(parameter, communityAllocation.get().name, getTranslation("view.fenix-admin.community.resource-allocations.details.page.bread-crumb"));
        ResourceAllocationChart resourceAllocationChart = new ResourceAllocationChart(chartPowerService.getChartDataForCommunityAlloc(communityAllocation.get().communityId, communityAllocation.get().id), jsonExporter.getJsonForCommunityAllocation(communityAllocation.get().communityId, communityAllocation.get().id), csvExporter.getCsvForCommunityAllocation(communityAllocation.get().communityId, communityAllocation.get().id), true);
        getContent().add(resourceAllocationChart);
    }
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) Optional.ofNullable(java.util.Optional.ofNullable) CommunityAllocation(io.imunity.furms.domain.community_allocation.CommunityAllocation) ResourceUsageJSONExporter(io.imunity.furms.api.export.ResourceUsageJSONExporter) CommunityAllocationService(io.imunity.furms.api.community_allocation.CommunityAllocationService) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) Function(java.util.function.Function) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) Route(com.vaadin.flow.router.Route) OptionalParameter(com.vaadin.flow.router.OptionalParameter) FenixAdminMenu(io.imunity.furms.ui.views.fenix.menu.FenixAdminMenu) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Optional(java.util.Optional) ResourceUsageCSVExporter(io.imunity.furms.api.export.ResourceUsageCSVExporter) ChartPowerService(io.imunity.furms.ui.charts.ChartPowerService) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ResourceAllocationChart(io.imunity.furms.ui.charts.ResourceAllocationChart) CommunityAllocation(io.imunity.furms.domain.community_allocation.CommunityAllocation)

Aggregations

BeforeEvent (com.vaadin.flow.router.BeforeEvent)3 OptionalParameter (com.vaadin.flow.router.OptionalParameter)3 Route (com.vaadin.flow.router.Route)3 ResourceUsageCSVExporter (io.imunity.furms.api.export.ResourceUsageCSVExporter)3 ResourceUsageJSONExporter (io.imunity.furms.api.export.ResourceUsageJSONExporter)3 ChartPowerService (io.imunity.furms.ui.charts.ChartPowerService)3 ResourceAllocationChart (io.imunity.furms.ui.charts.ResourceAllocationChart)3 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)3 PageTitle (io.imunity.furms.ui.components.PageTitle)3 BreadCrumbParameter (io.imunity.furms.ui.components.layout.BreadCrumbParameter)3 VaadinExceptionHandler.handleExceptions (io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions)3 Optional (java.util.Optional)3 Optional.ofNullable (java.util.Optional.ofNullable)3 Function (java.util.function.Function)3 ProjectAllocationService (io.imunity.furms.api.project_allocation.ProjectAllocationService)2 ProjectAllocation (io.imunity.furms.domain.project_allocation.ProjectAllocation)2 List (java.util.List)2 CommunityAllocationService (io.imunity.furms.api.community_allocation.CommunityAllocationService)1 CommunityAllocation (io.imunity.furms.domain.community_allocation.CommunityAllocation)1 CommunityAdminMenu (io.imunity.furms.ui.views.community.CommunityAdminMenu)1