Search in sources :

Example 1 with PLUS_CIRCLE

use of com.vaadin.flow.component.icon.VaadinIcon.PLUS_CIRCLE in project furms by unity-idm.

the class SitesView method fillGrid.

private void fillGrid() {
    grid.addHierarchyColumn(model -> Optional.ofNullable(model.siteName).orElse("")).setHeader(getTranslation("view.project-admin.sites.grid.1")).setSortable(true).setFlexGrow(25);
    grid.addComponentColumn(model -> new StatusLayout(model.status, model.message, getContent())).setHeader(getTranslation("view.project-admin.sites.grid.2")).setSortable(true).setFlexGrow(6);
    grid.addColumn(model -> model.userName).setHeader(getTranslation("view.project-admin.sites.grid.3")).setSortable(true).setFlexGrow(25);
    grid.addColumn(model -> model.userEmail).setHeader(getTranslation("view.project-admin.sites.grid.4")).setSortable(true).setFlexGrow(25);
    grid.addColumn(model -> Optional.ofNullable(model.userAccessStatus).map(status -> status.status.isEnabled() ? getTranslation("view.project-admin.sites.enabled") : getTranslation("view.project-admin.sites.disabled")).orElse("")).setHeader(getTranslation("view.project-admin.sites.grid.5")).setSortable(true).setFlexGrow(25);
    grid.addComponentColumn(model -> Optional.ofNullable(model.userAccessStatus).map(status -> (Component) new StatusLayout(getTranslation("view.project-admin.sites." + status.status.name()), status.message, getContent())).orElse(new Div())).setHeader(getTranslation("view.project-admin.sites.grid.6")).setSortable(true).setFlexGrow(25);
    grid.addComponentColumn(resourceAccessModel -> {
        if (resourceAccessModel.userAccessStatus == null || resourceAccessModel.userAccessStatus.status.isPending()) {
            IconButton iconButton = new IconButton(REFRESH.create());
            iconButton.addClickListener(event -> loadGridContent());
            return iconButton;
        } else {
            GridActionMenu contextMenu = new GridActionMenu();
            if (resourceAccessModel.userAccessStatus.status.isInstalled()) {
                contextMenu.addItem(new MenuButton(getTranslation("view.project-admin.sites.revoke"), MINUS_CIRCLE), event -> {
                    userSiteAccessService.removeAccess(resourceAccessModel.siteId, projectId, resourceAccessModel.userId);
                    loadGridContent();
                });
            } else {
                contextMenu.addItem(new MenuButton(getTranslation("view.project-admin.sites.grant"), PLUS_CIRCLE), event -> {
                    userSiteAccessService.addAccess(resourceAccessModel.siteId, projectId, resourceAccessModel.userId);
                    loadGridContent();
                });
            }
            return new GridActionsButtonLayout(contextMenu.getTarget());
        }
    }).setHeader(getTranslation("view.project-admin.sites.grid.7")).setTextAlign(ColumnTextAlign.END);
    grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
    loadGridContent();
}
Also used : ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) UsersSitesAccesses(io.imunity.furms.domain.user_site_access.UsersSitesAccesses) Component(com.vaadin.flow.component.Component) IconButton(io.imunity.furms.ui.components.IconButton) Div(com.vaadin.flow.component.html.Div) 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) REFRESH(com.vaadin.flow.component.icon.VaadinIcon.REFRESH) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Map(java.util.Map) ProjectInstallationsService(io.imunity.furms.api.project_installation.ProjectInstallationsService) DenseTreeGrid(io.imunity.furms.ui.views.project.resource_access.DenseTreeGrid) ProjectUpdateJobStatus(io.imunity.furms.domain.project_installation.ProjectUpdateJobStatus) MINUS_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.MINUS_CIRCLE) UserSiteAccessService(io.imunity.furms.api.user_site_access.UserSiteAccessService) ProjectAdminMenu(io.imunity.furms.ui.views.project.ProjectAdminMenu) GridVariant(com.vaadin.flow.component.grid.GridVariant) Set(java.util.Set) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) Collectors(java.util.stream.Collectors) TreeGrid(com.vaadin.flow.component.treegrid.TreeGrid) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) StatusLayout(io.imunity.furms.ui.components.StatusLayout) Optional(java.util.Optional) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) Div(com.vaadin.flow.component.html.Div) IconButton(io.imunity.furms.ui.components.IconButton) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) StatusLayout(io.imunity.furms.ui.components.StatusLayout) MenuButton(io.imunity.furms.ui.components.MenuButton) Component(com.vaadin.flow.component.Component) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent)

Aggregations

Component (com.vaadin.flow.component.Component)1 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)1 GridVariant (com.vaadin.flow.component.grid.GridVariant)1 Div (com.vaadin.flow.component.html.Div)1 MINUS_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.MINUS_CIRCLE)1 PLUS_CIRCLE (com.vaadin.flow.component.icon.VaadinIcon.PLUS_CIRCLE)1 REFRESH (com.vaadin.flow.component.icon.VaadinIcon.REFRESH)1 TreeGrid (com.vaadin.flow.component.treegrid.TreeGrid)1 Route (com.vaadin.flow.router.Route)1 ProjectInstallationsService (io.imunity.furms.api.project_installation.ProjectInstallationsService)1 UserSiteAccessService (io.imunity.furms.api.user_site_access.UserSiteAccessService)1 ProjectUpdateJobStatus (io.imunity.furms.domain.project_installation.ProjectUpdateJobStatus)1 UsersSitesAccesses (io.imunity.furms.domain.user_site_access.UsersSitesAccesses)1 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)1 GridActionMenu (io.imunity.furms.ui.components.GridActionMenu)1 GridActionsButtonLayout (io.imunity.furms.ui.components.GridActionsButtonLayout)1 IconButton (io.imunity.furms.ui.components.IconButton)1 MenuButton (io.imunity.furms.ui.components.MenuButton)1 PageTitle (io.imunity.furms.ui.components.PageTitle)1 StatusLayout (io.imunity.furms.ui.components.StatusLayout)1