Search in sources :

Example 6 with AjaxCompositedIconButton

use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.

the class AuditLogViewerPanel method initLayout.

private void initLayout() {
    ContainerableListPanel<AuditEventRecordType, SelectableBean<AuditEventRecordType>> auditLogViewerTable = new ContainerableListPanel<>(ID_AUDIT_LOG_VIEWER_TABLE, AuditEventRecordType.class) {

        @Override
        protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createDefaultColumns() {
            return AuditLogViewerPanel.this.createColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return null;
        }

        @Override
        protected IColumn<SelectableBean<AuditEventRecordType>, String> createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
            return AuditLogViewerPanel.this.createNameColumn();
        }

        @Override
        protected IColumn<SelectableBean<AuditEventRecordType>, String> createCheckboxColumn() {
            return null;
        }

        @Override
        protected IColumn<SelectableBean<AuditEventRecordType>, String> createIconColumn() {
            return null;
        }

        @Override
        protected Search createSearch(Class<AuditEventRecordType> type) {
            // TODO: use storage?
            AuditLogStorage storage = (AuditLogStorage) getPageStorage();
            Search search = SearchFactory.createContainerSearch(new ContainerTypeSearchItem(new SearchValue(type, "")), AuditEventRecordType.F_TIMESTAMP, getPageBase(), true);
            DateSearchItem timestampItem = (DateSearchItem) search.findPropertySearchItem(AuditEventRecordType.F_TIMESTAMP);
            if (timestampItem != null && timestampItem.getFromDate() == null && timestampItem.getToDate() == null && !isCollectionViewPanelForWidget()) {
                Date todayDate = Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant());
                timestampItem.setFromDate(MiscUtil.asXMLGregorianCalendar(todayDate));
            }
            return search;
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER;
        }

        @Override
        protected String getStorageKey() {
            String collectionNameValue = null;
            if (isCollectionViewPanelForCompiledView()) {
                StringValue collectionName = getCollectionNameParameterValue();
                collectionNameValue = collectionName != null ? collectionName.toString() : "";
            }
            return getAuditStorageKey(collectionNameValue);
        }

        @Override
        protected ISelectableDataProvider createProvider() {
            PageStorage pageStorage = getPageStorage();
            SelectableBeanContainerDataProvider<AuditEventRecordType> provider = new SelectableBeanContainerDataProvider<AuditEventRecordType>(AuditLogViewerPanel.this, getSearchModel(), null, false) {

                @Override
                protected PageStorage getPageStorage() {
                    return pageStorage;
                }

                @Override
                protected Integer countObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) throws CommonException {
                    return getPageBase().getModelAuditService().countObjects(query, currentOptions, task, result);
                }

                @Override
                protected List<AuditEventRecordType> searchObjects(Class<? extends AuditEventRecordType> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result) throws CommonException {
                    return getPageBase().getModelAuditService().searchObjects(query, options, task, result);
                }

                @NotNull
                @Override
                protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
                    if (sortParam != null && sortParam.getProperty() != null) {
                        OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
                        return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(), sortParam.getProperty())), order));
                    } else {
                        return Collections.emptyList();
                    }
                }

                @Override
                protected ObjectQuery getCustomizeContentQuery() {
                    return AuditLogViewerPanel.this.getCustomizeContentQuery();
                }
            };
            provider.setSort(AuditEventRecordType.F_TIMESTAMP.getLocalPart(), SortOrder.DESCENDING);
            return provider;
        }

        @Override
        protected AuditEventRecordType getRowRealValue(SelectableBean<AuditEventRecordType> rowModelObject) {
            if (rowModelObject == null) {
                return null;
            }
            return rowModelObject.getValue();
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> buttonsList = new ArrayList<>();
            CsvDownloadButtonPanel exportDataLink = new CsvDownloadButtonPanel(idButton) {

                private static final long serialVersionUID = 1L;

                @Override
                protected String getFilename() {
                    return "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
                }

                @Override
                protected DataTable<?, ?> getDataTable() {
                    return getTable().getDataTable();
                }
            };
            exportDataLink.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_CSV_EXPORT_ACTION_URI);
                }
            });
            buttonsList.add(exportDataLink);
            AjaxCompositedIconButton createReport = new AjaxCompositedIconButton(idButton, WebComponentUtil.createCreateReportIcon(), getPageBase().createStringResource("MainObjectListPanel.createReport")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    createReportPerformed(target);
                }
            };
            createReport.add(AttributeAppender.append("class", "btn btn-default btn-sm btn-margin-right"));
            buttonsList.add(createReport);
            return buttonsList;
        }
    };
    auditLogViewerTable.setOutputMarkupId(true);
    add(auditLogViewerTable);
}
Also used : AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) Task(com.evolveum.midpoint.task.api.Task) GuiObjectColumnType(com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectColumnType) AuditLogStorage(com.evolveum.midpoint.web.session.AuditLogStorage) ContainerableListPanel(com.evolveum.midpoint.gui.impl.component.ContainerableListPanel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) StringValue(org.apache.wicket.util.string.StringValue) Component(org.apache.wicket.Component) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) PageStorage(com.evolveum.midpoint.web.session.PageStorage) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) LocalDate(java.time.LocalDate) CsvDownloadButtonPanel(com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 7 with AjaxCompositedIconButton

use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.

the class TaskOperationalButtonsPanel method createCleanupPerformanceButton.

private void createCleanupPerformanceButton(RepeatingView repeatingView) {
    AjaxCompositedIconButton cleanupPerformance = new AjaxCompositedIconButton(repeatingView.newChildId(), getTaskCleanupCompositedIcon(GuiStyleConstants.CLASS_ICON_PERFORMANCE), createStringResource("operationalButtonsPanel.cleanupEnvironmentalPerformance")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            ConfirmationPanel dialog = new ConfirmationPanel(getPageBase().getMainPopupBodyId(), createStringResource("operationalButtonsPanel.cleanupEnvironmentalPerformance.confirmation")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void yesPerformed(AjaxRequestTarget target) {
                    try {
                        deleteStatistics(target);
                    } catch (Exception e) {
                        LOGGER.error("Cannot delete task operation statistics, {}", e.getMessage(), e);
                        getSession().error(getPageBase().getString("PageTask.cleanup.operationStatistics.failed"));
                    }
                }
            };
            getPageBase().showMainPopup(dialog, target);
        }
    };
    cleanupPerformance.add(AttributeAppender.append("class", "btn-default btn-margin-left"));
    cleanupPerformance.add(new VisibleBehaviour(this::isNotRunning));
    repeatingView.add(cleanupPerformance);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 8 with AjaxCompositedIconButton

use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.

the class TaskOperationalButtonsPanel method createCleanupResultsButton.

private void createCleanupResultsButton(RepeatingView repeatingView) {
    AjaxCompositedIconButton cleanupResults = new AjaxCompositedIconButton(repeatingView.newChildId(), getTaskCleanupCompositedIcon(GuiStyleConstants.CLASS_ICON_TASK_RESULTS), createStringResource("operationalButtonsPanel.cleanupResults")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            ConfirmationPanel dialog = new ConfirmationPanel(getPageBase().getMainPopupBodyId(), createStringResource("operationalButtonsPanel.cleanupResults.confirmation")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void yesPerformed(AjaxRequestTarget target) {
                    try {
                        deleteItem(target, TaskType.F_RESULT, TaskType.F_RESULT_STATUS);
                    } catch (Exception e) {
                        LOGGER.error("Cannot clear task results: {}", e.getMessage());
                        getSession().error(getPageBase().getString("PageTask.cleanup.result.failed"));
                    }
                }
            };
            getPageBase().showMainPopup(dialog, target);
        }
    };
    cleanupResults.add(new VisibleBehaviour(this::isNotRunning));
    cleanupResults.add(AttributeAppender.append("class", "btn-default btn-margin-left"));
    repeatingView.add(cleanupResults);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 9 with AjaxCompositedIconButton

use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.

the class MainObjectListPanel method createCreateReportButton.

private AjaxCompositedIconButton createCreateReportButton(String buttonId) {
    final CompositedIconBuilder builder = new CompositedIconBuilder();
    builder.setBasicIcon(WebComponentUtil.createReportIcon(), IconCssStyle.IN_ROW_STYLE);
    IconType plusIcon = new IconType();
    plusIcon.setCssClass(GuiStyleConstants.CLASS_ADD_NEW_OBJECT);
    plusIcon.setColor("green");
    builder.appendLayerIcon(plusIcon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
    AjaxCompositedIconButton createReport = new AjaxCompositedIconButton(buttonId, builder.build(), getPageBase().createStringResource("MainObjectListPanel.createReport")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            createReportPerformed(target);
        }
    };
    createReport.add(AttributeAppender.append("class", "btn btn-default btn-sm btn-margin-right"));
    createReport.add(new VisibleBehaviour(() -> WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_CREATE_REPORT_BUTTON_URI)));
    return createReport;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)

Example 10 with AjaxCompositedIconButton

use of com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton in project midpoint by Evolveum.

the class MultifunctionalButton method initLayout.

private void initLayout() {
    AjaxCompositedIconButton mainButton = new AjaxCompositedIconButton(ID_MAIN_BUTTON, new PropertyModel<>(getModel(), MultiFunctinalButtonDto.F_MAIN_BUTTON)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (!additionalButtonsExist()) {
                buttonClickPerformed(target, null, null);
            }
        }
    };
    mainButton.add(AttributeAppender.append(" data-toggle", additionalButtonsExist() ? "dropdown" : ""));
    // if (!additionalButtonsExist()) {
    mainButton.add(new VisibleBehaviour(this::isMainButtonVisible));
    // }
    add(mainButton);
    MultiCompositedButtonPanel buttonsPanel = new MultiCompositedButtonPanel(ID_BUTTON, new PropertyModel<>(getModel(), MultiFunctinalButtonDto.F_ADDITIONAL_BUTTONS)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
            MultifunctionalButton.this.buttonClickPerformed(target, relationSpec, collectionViews);
        }
    };
    buttonsPanel.setOutputMarkupId(true);
    buttonsPanel.add(new VisibleBehaviour(this::additionalButtonsExist));
    add(buttonsPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) WebPage(org.apache.wicket.markup.html.WebPage) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation)

Aggregations

AjaxCompositedIconButton (com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton)10 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)4 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)2 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)2 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)2 WebPage (org.apache.wicket.markup.html.WebPage)2 IModel (org.apache.wicket.model.IModel)2 CsvDownloadButtonPanel (com.evolveum.midpoint.gui.api.component.button.CsvDownloadButtonPanel)1 ContainerableListPanel (com.evolveum.midpoint.gui.impl.component.ContainerableListPanel)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ObjectOrdering (com.evolveum.midpoint.prism.query.ObjectOrdering)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 OrderDirection (com.evolveum.midpoint.prism.query.OrderDirection)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1