Search in sources :

Example 1 with LinksPanel

use of com.evolveum.midpoint.web.page.self.component.LinksPanel in project midpoint by Evolveum.

the class PageSelfDashboard method initLayout.

private void initLayout() {
    DashboardSearchPanel dashboardSearchPanel = new DashboardSearchPanel(ID_SEARCH_PANEL);
    List<String> searchPanelActions = Arrays.asList(AuthorizationConstants.AUTZ_UI_USERS_ALL_URL, AuthorizationConstants.AUTZ_UI_USERS_URL, AuthorizationConstants.AUTZ_UI_RESOURCES_ALL_URL, AuthorizationConstants.AUTZ_UI_RESOURCES_URL, AuthorizationConstants.AUTZ_UI_TASKS_ALL_URL, AuthorizationConstants.AUTZ_UI_TASKS_URL);
    dashboardSearchPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.SEARCH);
            return WebComponentUtil.getElementVisibility(visibilityType, searchPanelActions);
        }
    });
    add(dashboardSearchPanel);
    LinksPanel linksPanel = new LinksPanel(ID_LINKS_PANEL, Model.ofList(loadLinksList()));
    linksPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.SHORTCUTS);
            return WebComponentUtil.getElementVisibility(visibilityType);
        }
    });
    add(linksPanel);
    // TODO is this correct? [med]
    application = getApplication();
    final Session session = Session.get();
    AsyncDashboardPanel<Object, List<CaseWorkItemType>> workItemsPanel = new AsyncDashboardPanel<>(ID_WORK_ITEMS_PANEL, createStringResource("PageSelfDashboard.workItems"), GuiStyleConstants.CLASS_OBJECT_WORK_ITEM_ICON, GuiStyleConstants.CLASS_OBJECT_WORK_ITEM_BOX_CSS_CLASSES, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected SecurityContextAwareCallable<CallableResult<List<CaseWorkItemType>>> createCallable(Authentication auth, IModel callableParameterModel) {
            return new SecurityContextAwareCallable<>(getSecurityContextManager(), auth) {

                @Override
                public CallableResult<List<CaseWorkItemType>> callWithContextPrepared() {
                    // it is ignored anyway - FIXME
                    return new CallableResult<>(emptyList(), null);
                }
            };
        }

        @Override
        protected Component getMainComponent(String markupId) {
            CaseWorkItemsPanel workItemsPanel = new CaseWorkItemsPanel(markupId, CaseWorkItemsPanel.View.DASHBOARD) {

                private static final long serialVersionUID = 1L;

                @Override
                protected ObjectFilter getCaseWorkItemsFilter() {
                    return QueryUtils.filterForNotClosedStateAndAssignees(getPrismContext().queryFor(CaseWorkItemType.class), AuthUtil.getPrincipalUser(), OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, getRelationRegistry()).desc(F_CREATE_TIMESTAMP).buildFilter();
                }
            };
            workItemsPanel.setOutputMarkupId(true);
            return workItemsPanel;
        }
    };
    workItemsPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_WORKITEMS);
            return getCaseManager().isEnabled() && WebComponentUtil.getElementVisibility(visibilityType);
        }
    });
    add(workItemsPanel);
    AsyncDashboardPanel<Object, List<CaseType>> myRequestsPanel = new AsyncDashboardPanel<>(ID_REQUESTS_PANEL, createStringResource("PageSelfDashboard.myRequests"), GuiStyleConstants.CLASS_SHADOW_ICON_REQUEST, GuiStyleConstants.CLASS_OBJECT_SERVICE_BOX_CSS_CLASSES, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected SecurityContextAwareCallable<CallableResult<List<CaseType>>> createCallable(Authentication auth, IModel callableParameterModel) {
            return new SecurityContextAwareCallable<>(getSecurityContextManager(), auth) {

                @Override
                public CallableResult<List<CaseType>> callWithContextPrepared() {
                    // it is ignored anyway - FIXME
                    return new CallableResult<>(emptyList(), null);
                }
            };
        }

        @Override
        protected Component getMainComponent(String markupId) {
            return new CasesTablePanel(markupId) {

                @Override
                protected ObjectFilter getCasesFilter() {
                    return QueryUtils.filterForMyRequests(getPrismContext().queryFor(CaseType.class), AuthUtil.getPrincipalUser().getOid()).desc(ItemPath.create(CaseType.F_METADATA, MetadataType.F_CREATE_TIMESTAMP)).buildFilter();
                }

                @Override
                protected boolean isDashboard() {
                    return true;
                }

                @Override
                protected UserProfileStorage.TableId getTableId() {
                    return UserProfileStorage.TableId.PAGE_CASE_CHILD_CASES_TAB;
                }
            };
        }
    };
    myRequestsPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_REQUESTS);
            return getCaseManager().isEnabled() && WebComponentUtil.getElementVisibility(visibilityType);
        }
    });
    add(myRequestsPanel);
    initMyAccounts(session);
    initAssignments();
}
Also used : IModel(org.apache.wicket.model.IModel) LinksPanel(com.evolveum.midpoint.web.page.self.component.LinksPanel) SecurityContextAwareCallable(com.evolveum.midpoint.web.component.SecurityContextAwareCallable) DashboardSearchPanel(com.evolveum.midpoint.web.page.self.component.DashboardSearchPanel) CaseWorkItemsPanel(com.evolveum.midpoint.web.page.admin.cases.CaseWorkItemsPanel) AsyncDashboardPanel(com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) Authentication(org.springframework.security.core.Authentication) CasesTablePanel(com.evolveum.midpoint.web.page.admin.server.CasesTablePanel) PrismObject(com.evolveum.midpoint.prism.PrismObject) Collections.emptyList(java.util.Collections.emptyList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) CallableResult(com.evolveum.midpoint.web.component.util.CallableResult) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult) Session(org.apache.wicket.Session)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)1 SecurityContextAwareCallable (com.evolveum.midpoint.web.component.SecurityContextAwareCallable)1 CallableResult (com.evolveum.midpoint.web.component.util.CallableResult)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 CaseWorkItemsPanel (com.evolveum.midpoint.web.page.admin.cases.CaseWorkItemsPanel)1 AsyncDashboardPanel (com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel)1 AccountCallableResult (com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)1 CasesTablePanel (com.evolveum.midpoint.web.page.admin.server.CasesTablePanel)1 DashboardSearchPanel (com.evolveum.midpoint.web.page.self.component.DashboardSearchPanel)1 LinksPanel (com.evolveum.midpoint.web.page.self.component.LinksPanel)1 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)1 Collections.emptyList (java.util.Collections.emptyList)1 Session (org.apache.wicket.Session)1 IModel (org.apache.wicket.model.IModel)1 Authentication (org.springframework.security.core.Authentication)1