Search in sources :

Example 1 with DenseGrid

use of io.imunity.furms.ui.components.DenseGrid in project furms by unity-idm.

the class ProjectAllocationComponent method createCommunityGrid.

private Grid<ProjectAllocationGridModel> createCommunityGrid() {
    Grid<ProjectAllocationGridModel> grid = new DenseGrid<>(ProjectAllocationGridModel.class);
    grid.addComponentColumn(model -> {
        Icon icon = grid.isDetailsVisible(model) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create();
        return new Div(icon, new Text(model.siteName));
    }).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.1")).setSortable(true);
    grid.addComponentColumn(model -> {
        if (hasTerminalStatus(model))
            return new RouterLink(model.name, ProjectAllocationFormView.class, model.id);
        return new Text(model.name);
    }).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.2")).setSortable(true).setComparator(model -> model.name.toLowerCase());
    grid.addColumn(model -> model.resourceTypeName).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.3")).setSortable(true);
    grid.addColumn(model -> model.amountWithUnit).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.4")).setSortable(true).setComparator(comparing(c -> c.amountWithUnit.amount));
    grid.addColumn(model -> model.consumedWithUnit).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.5")).setSortable(true).setComparator(comparing(c -> c.consumedWithUnit.amount));
    grid.addColumn(model -> model.remainingWithUnit).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.6")).setSortable(true).setComparator(comparing(c -> c.remainingWithUnit.amount));
    grid.addComponentColumn(c -> {
        Optional<ProjectAllocationInstallation> projectAllocationInstallations = projectDataSnapshot.getAllocation(c.id);
        Optional<ProjectDeallocation> deallocation = projectDataSnapshot.getDeallocationStatus(c.id);
        if (deallocation.isPresent()) {
            int statusId = deallocation.get().status.getPersistentId();
            return new StatusLayout(getTranslation("view.community-admin.project-allocation.deallocation-status." + statusId), deallocation.flatMap(x -> x.errorMessage).map(x -> x.message).orElse(null), getContent());
        }
        return projectAllocationInstallations.map(installation -> {
            final int statusId = installation.status.getPersistentId();
            return new StatusLayout(getTranslation("view.community-admin.project-allocation.status." + statusId), installation.errorMessage.map(x -> x.message).orElse(null), getContent());
        }).orElseGet(StatusLayout::new);
    }).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.7")).setSortable(true);
    grid.addComponentColumn(model -> new ResourceProgressBar(model.amountWithUnit.amount, model.consumedWithUnit.amount, 0)).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.8")).setTextAlign(ColumnTextAlign.CENTER);
    grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.community-admin.project-allocation.grid.column.9")).setTextAlign(ColumnTextAlign.END);
    grid.setItemDetailsRenderer(new ComponentRenderer<>(x -> new Div(AllocationDetailsComponentFactory.create(x.creationTime, x.validFrom, x.validTo), AllocationDetailsComponentFactory.create(projectDataSnapshot.getChunks(x.id), x.amountWithUnit.unit))));
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    return grid;
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) Component(com.vaadin.flow.component.Component) Composite(com.vaadin.flow.component.Composite) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) Div(com.vaadin.flow.component.html.Div) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) Supplier(java.util.function.Supplier) REFRESH(com.vaadin.flow.component.icon.VaadinIcon.REFRESH) ProjectAllocationInstallation(io.imunity.furms.domain.project_allocation_installation.ProjectAllocationInstallation) DenseGrid(io.imunity.furms.ui.components.DenseGrid) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) Map(java.util.Map) RouterLink(com.vaadin.flow.router.RouterLink) ProjectDeallocationStatus(io.imunity.furms.domain.project_allocation_installation.ProjectDeallocationStatus) SPLINE_CHART(com.vaadin.flow.component.icon.VaadinIcon.SPLINE_CHART) UI(com.vaadin.flow.component.UI) ANGLE_RIGHT(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_RIGHT) Comparator.comparing(java.util.Comparator.comparing) Icon(com.vaadin.flow.component.icon.Icon) QueryParameters(com.vaadin.flow.router.QueryParameters) Text(com.vaadin.flow.component.Text) AllocationDetailsComponentFactory(io.imunity.furms.ui.components.AllocationDetailsComponentFactory) Grid(com.vaadin.flow.component.grid.Grid) RemovalOfConsumedProjectAllocationIsFirbiddenException(io.imunity.furms.api.validation.exceptions.RemovalOfConsumedProjectAllocationIsFirbiddenException) TRASH(com.vaadin.flow.component.icon.VaadinIcon.TRASH) EDIT(com.vaadin.flow.component.icon.VaadinIcon.EDIT) MenuItem(com.vaadin.flow.component.contextmenu.MenuItem) RouterGridLink(io.imunity.furms.ui.components.RouterGridLink) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar) ANGLE_DOWN(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_DOWN) Button(com.vaadin.flow.component.button.Button) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ProjectDeallocation(io.imunity.furms.domain.project_allocation_installation.ProjectDeallocation) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) StatusLayout(io.imunity.furms.ui.components.StatusLayout) ProjectService(io.imunity.furms.api.projects.ProjectService) ProjectAllocationDataSnapshot(io.imunity.furms.ui.project_allocation.ProjectAllocationDataSnapshot) Optional(java.util.Optional) Dialog(com.vaadin.flow.component.dialog.Dialog) Collections(java.util.Collections) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Text(com.vaadin.flow.component.Text) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar) Div(com.vaadin.flow.component.html.Div) RouterLink(com.vaadin.flow.router.RouterLink) ProjectAllocationInstallation(io.imunity.furms.domain.project_allocation_installation.ProjectAllocationInstallation) ProjectDeallocation(io.imunity.furms.domain.project_allocation_installation.ProjectDeallocation) StatusLayout(io.imunity.furms.ui.components.StatusLayout) Icon(com.vaadin.flow.component.icon.Icon)

Example 2 with DenseGrid

use of io.imunity.furms.ui.components.DenseGrid in project furms by unity-idm.

the class AlarmsView method createAlarmGrid.

private Grid<AlarmGridModel> createAlarmGrid() {
    Grid<AlarmGridModel> grid = new DenseGrid<>(AlarmGridModel.class);
    grid.addComponentColumn(model -> new RouterLink(model.name, AlarmFormView.class, model.id.id.toString())).setHeader(getTranslation("view.project-admin.alarms.page.grid.1")).setSortable(true).setComparator(x -> x.name.toLowerCase());
    grid.addColumn(model -> model.allocationName).setHeader(getTranslation("view.project-admin.alarms.page.grid.2")).setSortable(true);
    grid.addColumn(model -> model.threshold + "%").setHeader(getTranslation("view.project-admin.alarms.page.grid.3")).setSortable(true);
    grid.addComponentColumn(model -> new DisableCheckbox(model.allUsers)).setHeader(getTranslation("view.project-admin.alarms.page.grid.4")).setSortable(true).setComparator(model -> model.allUsers);
    grid.addComponentColumn(model -> {
        Label label = new Label(model.users.stream().limit(3).collect(Collectors.joining()) + (model.users.size() > 3 ? "..." : ""));
        Tooltip tooltip = new Tooltip();
        tooltip.add(String.join(", ", model.users));
        tooltip.attachToComponent(label);
        getContent().add(tooltip);
        return label;
    }).setHeader(getTranslation("view.project-admin.alarms.page.grid.5")).setSortable(true).setComparator(model -> model.users.toString());
    grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.project-admin.alarms.page.grid.6")).setTextAlign(ColumnTextAlign.END);
    grid.setClassNameGenerator(model -> model.fired ? "light-red-row" : "usual-row");
    return grid;
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) AssignedPolicyRemovingException(io.imunity.furms.api.validation.exceptions.AssignedPolicyRemovingException) Component(com.vaadin.flow.component.Component) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) Label(com.vaadin.flow.component.html.Label) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) PLUS_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.PLUS_CIRCLE) DenseGrid(io.imunity.furms.ui.components.DenseGrid) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Map(java.util.Map) RouterLink(com.vaadin.flow.router.RouterLink) UI(com.vaadin.flow.component.UI) Comparator.comparing(java.util.Comparator.comparing) ProjectAdminMenu(io.imunity.furms.ui.views.project.ProjectAdminMenu) Grid(com.vaadin.flow.component.grid.Grid) TRASH(com.vaadin.flow.component.icon.VaadinIcon.TRASH) EDIT(com.vaadin.flow.component.icon.VaadinIcon.EDIT) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) AlarmId(io.imunity.furms.domain.alarms.AlarmId) Collectors(java.util.stream.Collectors) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) Tooltip(com.vaadin.componentfactory.Tooltip) Button(com.vaadin.flow.component.button.Button) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) AlarmService(io.imunity.furms.api.alarms.AlarmService) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) Dialog(com.vaadin.flow.component.dialog.Dialog) Collections(java.util.Collections) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) RouterLink(com.vaadin.flow.router.RouterLink) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Tooltip(com.vaadin.componentfactory.Tooltip) Label(com.vaadin.flow.component.html.Label)

Example 3 with DenseGrid

use of io.imunity.furms.ui.components.DenseGrid in project furms by unity-idm.

the class ResourceAllocationsView method createCommunityGrid.

private Grid<ProjectAllocationGridModel> createCommunityGrid() {
    Grid<ProjectAllocationGridModel> grid = new DenseGrid<>(ProjectAllocationGridModel.class);
    grid.addComponentColumn(allocation -> {
        Icon icon = grid.isDetailsVisible(allocation) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create();
        return new Div(icon, new Label(allocation.siteName));
    }).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.1")).setSortable(true);
    grid.addColumn(model -> model.name).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.2")).setSortable(true).setComparator(model -> model.name.toLowerCase());
    grid.addColumn(model -> model.resourceTypeName).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.3")).setSortable(true);
    grid.addColumn(model -> model.amountWithUnit).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.4")).setSortable(true).setComparator(comparing(model -> model.amountWithUnit.amount));
    grid.addColumn(model -> model.consumedWithUnit).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.5")).setSortable(true).setComparator(comparing(model -> model.consumedWithUnit.amount));
    grid.addColumn(model -> model.remainingWithUnit).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.6")).setSortable(true).setComparator(comparing(model -> model.remainingWithUnit.amount));
    grid.addComponentColumn(c -> {
        Optional<ProjectAllocationInstallation> projectAllocationInstallations = projectDataSnapshot.getAllocation(c.id);
        Optional<ProjectDeallocation> deallocation = projectDataSnapshot.getDeallocationStatus(c.id);
        if (deallocation.isPresent()) {
            int statusId = deallocation.get().status.getPersistentId();
            return new StatusLayout(getTranslation("view.community-admin.project-allocation.deallocation-status." + statusId), deallocation.flatMap(x -> x.errorMessage).map(x -> x.message).orElse(null), getContent());
        }
        return projectAllocationInstallations.map(installation -> {
            final int statusId = installation.status.getPersistentId();
            return new StatusLayout(getTranslation("view.community-admin.project-allocation.status." + statusId), installation.errorMessage.map(x -> x.message).orElse(null), getContent());
        }).orElseGet(StatusLayout::new);
    }).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.7")).setSortable(true);
    grid.addComponentColumn(model -> new ResourceProgressBar(model.amountWithUnit.amount, model.consumedWithUnit.amount, projectDataSnapshot.getAlarmThreshold(model.id))).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.8")).setTextAlign(ColumnTextAlign.CENTER);
    grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.project-admin.resource-allocations.grid.column.9")).setTextAlign(ColumnTextAlign.END);
    grid.setItemDetailsRenderer(new ComponentRenderer<>(c -> AllocationDetailsComponentFactory.create(projectDataSnapshot.getChunks(c.id), c.amountWithUnit.unit)));
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    return grid;
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) Component(com.vaadin.flow.component.Component) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) Div(com.vaadin.flow.component.html.Div) Label(com.vaadin.flow.component.html.Label) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) REFRESH(com.vaadin.flow.component.icon.VaadinIcon.REFRESH) ProjectAllocationInstallation(io.imunity.furms.domain.project_allocation_installation.ProjectAllocationInstallation) DenseGrid(io.imunity.furms.ui.components.DenseGrid) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) SPLINE_CHART(com.vaadin.flow.component.icon.VaadinIcon.SPLINE_CHART) ANGLE_RIGHT(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_RIGHT) Comparator.comparing(java.util.Comparator.comparing) Icon(com.vaadin.flow.component.icon.Icon) ProjectAdminMenu(io.imunity.furms.ui.views.project.ProjectAdminMenu) AllocationDetailsComponentFactory(io.imunity.furms.ui.components.AllocationDetailsComponentFactory) Grid(com.vaadin.flow.component.grid.Grid) RouterGridLink(io.imunity.furms.ui.components.RouterGridLink) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar) ANGLE_DOWN(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_DOWN) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ProjectDeallocation(io.imunity.furms.domain.project_allocation_installation.ProjectDeallocation) AlarmService(io.imunity.furms.api.alarms.AlarmService) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) StatusLayout(io.imunity.furms.ui.components.StatusLayout) ProjectAllocationDataSnapshot(io.imunity.furms.ui.project_allocation.ProjectAllocationDataSnapshot) Optional(java.util.Optional) ProjectAllocationResolved(io.imunity.furms.domain.project_allocation.ProjectAllocationResolved) Collections(java.util.Collections) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Label(com.vaadin.flow.component.html.Label) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar) Div(com.vaadin.flow.component.html.Div) ProjectAllocationInstallation(io.imunity.furms.domain.project_allocation_installation.ProjectAllocationInstallation) ProjectDeallocation(io.imunity.furms.domain.project_allocation_installation.ProjectDeallocation) StatusLayout(io.imunity.furms.ui.components.StatusLayout) Icon(com.vaadin.flow.component.icon.Icon)

Example 4 with DenseGrid

use of io.imunity.furms.ui.components.DenseGrid in project furms by unity-idm.

the class ProjectView method createCommunityGrid.

private Grid<ProjectAllocationGridModel> createCommunityGrid() {
    Grid<ProjectAllocationGridModel> grid = new DenseGrid<>(ProjectAllocationGridModel.class);
    grid.addComponentColumn(allocation -> {
        Icon icon = grid.isDetailsVisible(allocation) ? ANGLE_DOWN.create() : ANGLE_RIGHT.create();
        return new Div(icon, new Label(allocation.siteName));
    }).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.1")).setSortable(true);
    grid.addColumn(model -> model.name).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.2")).setSortable(true).setComparator(model -> model.name.toLowerCase());
    grid.addColumn(model -> model.resourceTypeName).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.3")).setSortable(true);
    grid.addColumn(model -> model.amountWithUnit).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.4")).setSortable(true).setComparator(comparing(model -> model.amountWithUnit.amount));
    grid.addColumn(model -> model.consumedWithUnit).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.5")).setSortable(true).setComparator(comparing(model -> model.consumedWithUnit.amount));
    grid.addColumn(model -> model.remainingWithUnit).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.6")).setSortable(true).setComparator(comparing(model -> model.remainingWithUnit.amount));
    grid.addComponentColumn(c -> {
        Optional<ProjectAllocationInstallation> projectAllocationInstallations = projectDataSnapshot.getParent().getAllocation(c.id);
        Optional<ProjectDeallocation> deallocation = projectDataSnapshot.getParent().getDeallocationStatus(c.id);
        if (deallocation.isPresent()) {
            int statusId = deallocation.get().status.getPersistentId();
            return new StatusLayout(getTranslation("view.community-admin.project-allocation.deallocation-status." + statusId), deallocation.flatMap(x -> x.errorMessage).map(x -> x.message).orElse(null), getContent());
        }
        return projectAllocationInstallations.map(installation -> {
            final int statusId = installation.status.getPersistentId();
            return new StatusLayout(getTranslation("view.community-admin.project-allocation.status." + statusId), installation.errorMessage.map(x -> x.message).orElse(null), getContent());
        }).orElseGet(StatusLayout::new);
    }).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.7")).setSortable(true);
    grid.addColumn(x -> getEnabledValue(x.id, x.accessibleForAllProjectMembers)).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.8")).setSortable(true);
    grid.addComponentColumn(model -> new ResourceProgressBar(model.amountWithUnit.amount, model.consumedWithUnit.amount, projectDataSnapshot.projectAllocationDataSnapshot.getAlarmThreshold(model.id))).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.9")).setTextAlign(ColumnTextAlign.CENTER);
    grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.user-settings.project-allocation.grid.column.10")).setTextAlign(ColumnTextAlign.END);
    grid.setItemDetailsRenderer(new ComponentRenderer<>(c -> AllocationDetailsComponentFactory.create(projectDataSnapshot.getParent().getChunks(c.id), c.amountWithUnit.unit)));
    grid.setSelectionMode(Grid.SelectionMode.NONE);
    return grid;
}
Also used : ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) Component(com.vaadin.flow.component.Component) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) Label(com.vaadin.flow.component.html.Label) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) BeforeEvent(com.vaadin.flow.router.BeforeEvent) ResourceAccessService(io.imunity.furms.api.resource_access.ResourceAccessService) Route(com.vaadin.flow.router.Route) GRANTED_STATUES(io.imunity.furms.domain.resource_access.AccessStatus.GRANTED_STATUES) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ANGLE_RIGHT(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_RIGHT) AllocationDetailsComponentFactory(io.imunity.furms.ui.components.AllocationDetailsComponentFactory) UserGrant(io.imunity.furms.domain.resource_access.UserGrant) RouterGridLink(io.imunity.furms.ui.components.RouterGridLink) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar) BreadCrumbParameter(io.imunity.furms.ui.components.layout.BreadCrumbParameter) ANGLE_DOWN(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_DOWN) OptionalParameter(com.vaadin.flow.router.OptionalParameter) List(java.util.List) AlarmService(io.imunity.furms.api.alarms.AlarmService) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) StatusLayout(io.imunity.furms.ui.components.StatusLayout) Function.identity(java.util.function.Function.identity) Optional(java.util.Optional) UserWithoutFenixIdValidationError(io.imunity.furms.api.validation.exceptions.UserWithoutFenixIdValidationError) ProjectAllocationResolved(io.imunity.furms.domain.project_allocation.ProjectAllocationResolved) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) Project(io.imunity.furms.domain.projects.Project) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) Div(com.vaadin.flow.component.html.Div) REFRESH(com.vaadin.flow.component.icon.VaadinIcon.REFRESH) ProjectAllocationInstallation(io.imunity.furms.domain.project_allocation_installation.ProjectAllocationInstallation) ProjectAllocationService(io.imunity.furms.api.project_allocation.ProjectAllocationService) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) SPLINE_CHART(com.vaadin.flow.component.icon.VaadinIcon.SPLINE_CHART) UserSettingsMenu(io.imunity.furms.ui.views.user_settings.UserSettingsMenu) Comparator.comparing(java.util.Comparator.comparing) Icon(com.vaadin.flow.component.icon.Icon) Grid(com.vaadin.flow.component.grid.Grid) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) Collectors.toList(java.util.stream.Collectors.toList) ProjectDeallocation(io.imunity.furms.domain.project_allocation_installation.ProjectDeallocation) ProjectService(io.imunity.furms.api.projects.ProjectService) ProjectAllocationDataSnapshot(io.imunity.furms.ui.project_allocation.ProjectAllocationDataSnapshot) Collections(java.util.Collections) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Label(com.vaadin.flow.component.html.Label) ResourceProgressBar(io.imunity.furms.ui.components.ResourceProgressBar) Div(com.vaadin.flow.component.html.Div) ProjectAllocationInstallation(io.imunity.furms.domain.project_allocation_installation.ProjectAllocationInstallation) ProjectDeallocation(io.imunity.furms.domain.project_allocation_installation.ProjectDeallocation) StatusLayout(io.imunity.furms.ui.components.StatusLayout) Icon(com.vaadin.flow.component.icon.Icon)

Example 5 with DenseGrid

use of io.imunity.furms.ui.components.DenseGrid in project furms by unity-idm.

the class ProjectsView method createProjectGrid.

private Grid<ProjectGridModel> createProjectGrid() {
    Grid<ProjectGridModel> grid = new DenseGrid<>(ProjectGridModel.class);
    Grid.Column<ProjectGridModel> firstColumn = grid.addComponentColumn(project -> {
        Component component = new Span(project.name);
        if (project.status.equals(ACTIVE))
            component = new RouterLink(project.name, ProjectView.class, project.id);
        return component;
    }).setHeader(getTranslation("view.user-settings.projects.grid.column.1")).setSortable(true).setComparator(comparing(project -> project.name)).setComparator(project -> project.name.toLowerCase());
    grid.addColumn(project -> project.description).setHeader(getTranslation("view.user-settings.projects.grid.column.2")).setSortable(true);
    grid.addColumn(project -> getTranslation(project.status.gridText)).setHeader(getTranslation("view.user-settings.projects.grid.column.3")).setTextAlign(ColumnTextAlign.END).setSortable(true);
    grid.addComponentColumn(this::createLastColumnContent).setHeader(getTranslation("view.user-settings.projects.grid.column.4")).setTextAlign(ColumnTextAlign.END);
    grid.sort(ImmutableList.of(new GridSortOrder<>(firstColumn, SortDirection.ASCENDING)));
    return grid;
}
Also used : VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) SortDirection(com.vaadin.flow.data.provider.SortDirection) Component(com.vaadin.flow.component.Component) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) HashSet(java.util.HashSet) PLUS_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.PLUS_CIRCLE) ImmutableList(com.google.common.collect.ImmutableList) DenseGrid(io.imunity.furms.ui.components.DenseGrid) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) PIE_CHART(com.vaadin.flow.component.icon.VaadinIcon.PIE_CHART) RouterLink(com.vaadin.flow.router.RouterLink) UserSettingsMenu(io.imunity.furms.ui.views.user_settings.UserSettingsMenu) Comparator.comparing(java.util.Comparator.comparing) TextField(com.vaadin.flow.component.textfield.TextField) SEARCH(com.vaadin.flow.component.icon.VaadinIcon.SEARCH) ValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode) CheckboxGroupVariant(com.vaadin.flow.component.checkbox.CheckboxGroupVariant) MINUS_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.MINUS_CIRCLE) REQUESTED(io.imunity.furms.ui.views.user_settings.projects.UserStatus.REQUESTED) Grid(com.vaadin.flow.component.grid.Grid) ApplicationNotExistingException(io.imunity.furms.api.validation.exceptions.ApplicationNotExistingException) TRASH(com.vaadin.flow.component.icon.VaadinIcon.TRASH) RouterGridLink(io.imunity.furms.ui.components.RouterGridLink) ACTIVE(io.imunity.furms.ui.views.user_settings.projects.UserStatus.ACTIVE) Set(java.util.Set) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) ProjectApplicationsService(io.imunity.furms.api.applications.ProjectApplicationsService) GridSortOrder(com.vaadin.flow.component.grid.GridSortOrder) UserAlreadyInvitedException(io.imunity.furms.api.validation.exceptions.UserAlreadyInvitedException) Tooltip(com.vaadin.componentfactory.Tooltip) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) ProjectService(io.imunity.furms.api.projects.ProjectService) CheckboxGroup(com.vaadin.flow.component.checkbox.CheckboxGroup) UserWithoutFenixIdValidationError(io.imunity.furms.api.validation.exceptions.UserWithoutFenixIdValidationError) Dialog(com.vaadin.flow.component.dialog.Dialog) Collections(java.util.Collections) Span(com.vaadin.flow.component.html.Span) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) NotificationUtils.showSuccessNotification(io.imunity.furms.ui.utils.NotificationUtils.showSuccessNotification) RouterLink(com.vaadin.flow.router.RouterLink) GridSortOrder(com.vaadin.flow.component.grid.GridSortOrder) DenseGrid(io.imunity.furms.ui.components.DenseGrid) DenseGrid(io.imunity.furms.ui.components.DenseGrid) Grid(com.vaadin.flow.component.grid.Grid) Component(com.vaadin.flow.component.Component) FlexComponent(com.vaadin.flow.component.orderedlayout.FlexComponent) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Span(com.vaadin.flow.component.html.Span)

Aggregations

Grid (com.vaadin.flow.component.grid.Grid)11 DenseGrid (io.imunity.furms.ui.components.DenseGrid)11 Component (com.vaadin.flow.component.Component)10 GridActionMenu (io.imunity.furms.ui.components.GridActionMenu)10 MenuButton (io.imunity.furms.ui.components.MenuButton)10 ViewHeaderLayout (io.imunity.furms.ui.components.ViewHeaderLayout)10 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)9 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)9 Route (com.vaadin.flow.router.Route)9 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)9 GridActionsButtonLayout (io.imunity.furms.ui.components.GridActionsButtonLayout)9 PageTitle (io.imunity.furms.ui.components.PageTitle)9 FurmsDialog (io.imunity.furms.ui.components.FurmsDialog)8 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)8 VaadinExceptionHandler.handleExceptions (io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions)8 Comparator.comparing (java.util.Comparator.comparing)8 List (java.util.List)8 Collectors.toList (java.util.stream.Collectors.toList)8 Dialog (com.vaadin.flow.component.dialog.Dialog)7 TRASH (com.vaadin.flow.component.icon.VaadinIcon.TRASH)7