Search in sources :

Example 1 with GetBlacklistWithDescription

use of cz.metacentrum.perun.webgui.json.securityTeamsManager.GetBlacklistWithDescription in project perun by CESNET.

the class FacilityBlacklistTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Blacklist");
    // main panel
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    final GetBlacklistWithDescription securityTeams = new GetBlacklistWithDescription(PerunEntity.FACILITY, facilityId);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addFilterWidget(new ExtendedSuggestBox(securityTeams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            securityTeams.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterSecurityTeam());
    CellTable<Pair<User, String>> table;
    if (session.isPerunAdmin() || session.isSecurityAdmin()) {
        table = securityTeams.getTable(new FieldUpdater<Pair<User, String>, String>() {

            @Override
            public void update(int index, Pair<User, String> object, String value) {
                session.getTabManager().addTab(new UserDetailTabItem(object.getLeft()));
            }
        });
    } else {
        table = securityTeams.getTable();
    }
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    // add menu and the table to the main panel
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) GetBlacklistWithDescription(cz.metacentrum.perun.webgui.json.securityTeamsManager.GetBlacklistWithDescription) Pair(cz.metacentrum.perun.webgui.model.Pair)

Example 2 with GetBlacklistWithDescription

use of cz.metacentrum.perun.webgui.json.securityTeamsManager.GetBlacklistWithDescription in project perun by CESNET.

the class SecurityTeamBlacklistTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(securityTeam.getName()) + ": " + "blacklist");
    // Get vos request
    final GetBlacklistWithDescription teams = new GetBlacklistWithDescription(PerunEntity.SECURITY_TEAM, securityTeamId);
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(teams);
    TabMenu tabMenu = new TabMenu();
    // add menu to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // do not display to sec admins only
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addUsersToBlacklist(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddUserToBlacklistTabItem(securityTeam), true);
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, buttonTranslation.removeSelectedUsersFromBlacklist());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Pair<User, String>> itemsToRemove = teams.getTableSelectedList();
            UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        RemoveUserFromBlacklist request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new RemoveUserFromBlacklist(securityTeamId, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveUserFromBlacklist(securityTeamId, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeUserFromBlacklist(itemsToRemove.get(i).getLeft().getId());
                    }
                }
            });
        }
    });
    tabMenu.addWidget(removeButton);
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(teams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            teams.filterTable(text);
        }
    }, buttonTranslation.filterBlacklist());
    final TabItem tab = this;
    CellTable<Pair<User, String>> table;
    if (session.isPerunAdmin()) {
        // get the table with custom onclick
        table = teams.getTable(new FieldUpdater<Pair<User, String>, String>() {

            @Override
            public void update(int i, Pair<User, String> pair, String string) {
                session.getTabManager().addTab(new UserDetailTabItem(pair.getLeft()));
                session.getTabManager().closeTab(tab, isRefreshParentOnClose());
            }
        });
    } else {
        table = teams.getTable();
    }
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    // add the table to the main panel
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, 0, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) RemoveUserFromBlacklist(cz.metacentrum.perun.webgui.json.securityTeamsManager.RemoveUserFromBlacklist) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) GetBlacklistWithDescription(cz.metacentrum.perun.webgui.json.securityTeamsManager.GetBlacklistWithDescription) Pair(cz.metacentrum.perun.webgui.model.Pair)

Aggregations

FieldUpdater (com.google.gwt.cell.client.FieldUpdater)2 GetBlacklistWithDescription (cz.metacentrum.perun.webgui.json.securityTeamsManager.GetBlacklistWithDescription)2 Pair (cz.metacentrum.perun.webgui.model.Pair)2 User (cz.metacentrum.perun.webgui.model.User)2 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)2 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)2 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 RemoveUserFromBlacklist (cz.metacentrum.perun.webgui.json.securityTeamsManager.RemoveUserFromBlacklist)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 ArrayList (java.util.ArrayList)1