Search in sources :

Example 1 with AuditMessage

use of cz.metacentrum.perun.webgui.model.AuditMessage in project perun by CESNET.

the class AuditLogTabItem method draw.

public Widget draw() {
    // page main tab
    final VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // number of messages
    final TextBox tb = new TextBox();
    tb.setText(String.valueOf(count));
    tb.setWidth("100px");
    // menu panel
    TabMenu menu = new TabMenu();
    mainTab.add(menu);
    mainTab.setCellHeight(menu, "30px");
    CustomButton refreshButton = TabMenu.getPredefinedButton(ButtonType.REFRESH, ButtonTranslation.INSTANCE.refreshAuditMessages());
    // retrieve messages
    final GetAuditMessagesByCount call = new GetAuditMessagesByCount(JsonCallbackEvents.disableButtonEvents(refreshButton));
    call.setCount(count);
    CellTable<AuditMessage> table = call.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    mainTab.add(sp);
    // resize perun table to correct size on screen
    session.getUiElements().resizePerunTable(sp, 350, this);
    // refresh button action
    refreshButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (JsonUtils.checkParseInt(tb.getText())) {
                call.clearTable();
                count = Integer.parseInt(tb.getText());
                call.setCount(count);
                call.retrieveData();
            } else {
                JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
            }
        }
    });
    menu.addWidget(refreshButton);
    // enter key = refresh on count text box
    tb.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (JsonUtils.checkParseInt(tb.getText())) {
                    call.clearTable();
                    count = Integer.parseInt(tb.getText());
                    call.setCount(count);
                    call.retrieveData();
                } else {
                    JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
                }
            }
        }
    });
    // add textbox into menu
    menu.addWidget(new HTML("<strong>Number of messages: </strong>"));
    menu.addWidget(tb);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : AuditMessage(cz.metacentrum.perun.webgui.model.AuditMessage) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAuditMessagesByCount(cz.metacentrum.perun.webgui.json.auditMessagesManager.GetAuditMessagesByCount) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 2 with AuditMessage

use of cz.metacentrum.perun.webgui.model.AuditMessage in project perun by CESNET.

the class GetAuditMessagesByCount method getTable.

public CellTable<AuditMessage> getTable() {
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<AuditMessage>(list);
    // Cell table
    table = new PerunTable<AuditMessage>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<AuditMessage> columnSortHandler = new ListHandler<AuditMessage>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AuditMessage>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No audit messages found.");
    if (checkable) {
        // checkbox column column
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Message ID", null, 120);
    // Event name column
    Column<AuditMessage, String> eventNameColumn = JsonUtils.addColumn(new CustomTextCell(), this::getAuditEventName, null);
    eventNameColumn.setSortable(true);
    columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (getAuditEventName(o1)).compareToIgnoreCase(getAuditEventName(o2)));
    // Event objects column
    Column<AuditMessage, String> objectsColumn = JsonUtils.addColumn(new CustomTextCell(), AuditMessage::getAuditEventObjectsMessage, null);
    eventNameColumn.setSortable(true);
    columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (o1.getAuditEventObjectsMessage()).compareToIgnoreCase(o2.getAuditEventObjectsMessage()));
    // Actor column
    Column<AuditMessage, String> actorColumn = JsonUtils.addColumn(new CustomTextCell(), AuditMessage::getActor, null);
    eventNameColumn.setSortable(true);
    columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (o1.getActor()).compareToIgnoreCase(o2.getActor()));
    // TIME COLUMN
    TextColumn<AuditMessage> timeColumn = new TextColumn<AuditMessage>() {

        public String getValue(AuditMessage msg) {
            if (msg.getCreatedAt().contains(".")) {
                return msg.getCreatedAt().substring(0, msg.getCreatedAt().indexOf("."));
            } else {
                // oracle timestamp doesn't have ending ".12345" in "2020-01-01 12:00:00.12345"
                return msg.getCreatedAt();
            }
        }
    };
    timeColumn.setSortable(true);
    columnSortHandler.setComparator(timeColumn, new Comparator<AuditMessage>() {

        public int compare(AuditMessage o1, AuditMessage o2) {
            return o1.getCreatedAt().compareToIgnoreCase(o2.getCreatedAt());
        }
    });
    table.addColumn(timeColumn, "Created at");
    table.setColumnWidth(timeColumn, "180px");
    table.addColumn(eventNameColumn, "Event name");
    table.setColumnWidth(eventNameColumn, "250px");
    table.addColumn(actorColumn, "Actor");
    table.setColumnWidth(actorColumn, "150px");
    table.addColumn(objectsColumn, "Related objects");
    return table;
}
Also used : AuditMessage(cz.metacentrum.perun.webgui.model.AuditMessage) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) CustomTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomTextCell) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 3 with AuditMessage

use of cz.metacentrum.perun.webgui.model.AuditMessage in project perun by CESNET.

the class GetAuditMessages method getTable.

public CellTable<AuditMessage> getTable() {
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<AuditMessage>(list);
    // Cell table
    table = new PerunTable<AuditMessage>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<AuditMessage> columnSortHandler = new ListHandler<AuditMessage>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AuditMessage>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No audit messages found.");
    if (checkable) {
        // checkbox column column
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Message ID", null, 120);
    // MESSAGE COLUMN
    Column<AuditMessage, String> messageColumn = JsonUtils.addColumn(new CustomTextCell(), new JsonUtils.GetValue<AuditMessage, String>() {

        public String getValue(AuditMessage msg) {
            return msg.getActor() + ": " + msg.getMessage();
        }
    }, null);
    messageColumn.setSortable(true);
    columnSortHandler.setComparator(messageColumn, new Comparator<AuditMessage>() {

        public int compare(AuditMessage o1, AuditMessage o2) {
            return (o1.getActor() + ": " + o1.getMessage()).compareToIgnoreCase(o2.getActor() + ": " + o2.getMessage());
        }
    });
    // TIME COLUMN
    TextColumn<AuditMessage> timeColumn = new TextColumn<AuditMessage>() {

        public String getValue(AuditMessage msg) {
            return msg.getCreatedAt().substring(0, msg.getCreatedAt().indexOf("."));
        }
    };
    timeColumn.setSortable(true);
    columnSortHandler.setComparator(timeColumn, new Comparator<AuditMessage>() {

        public int compare(AuditMessage o1, AuditMessage o2) {
            return o1.getCreatedAt().compareToIgnoreCase(o2.getCreatedAt());
        }
    });
    table.addColumn(timeColumn, "Created at");
    table.setColumnWidth(timeColumn, "180px");
    table.addColumn(messageColumn, "Message");
    return table;
}
Also used : AuditMessage(cz.metacentrum.perun.webgui.model.AuditMessage) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) CustomTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomTextCell) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Aggregations

AuditMessage (cz.metacentrum.perun.webgui.model.AuditMessage)3 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)2 TextColumn (com.google.gwt.user.cellview.client.TextColumn)2 CustomTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomTextCell)2 GetAuditMessagesByCount (cz.metacentrum.perun.webgui.json.auditMessagesManager.GetAuditMessagesByCount)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1