Search in sources :

Example 6 with RemoveAdmin

use of cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin in project perun by CESNET.

the class FacilityManagersTabItem method fillContentUsers.

private Widget fillContentUsers(final GetRichAdminsWithAttributes jsonCallback, TabMenu menu) {
    jsonCallback.clearTableSelectedSet();
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = jsonCallback.getTable(new FieldUpdater<User, String>() {

            @Override
            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = jsonCallback.getTable();
    }
    menu.addWidget(0, UiElements.getRefreshButton(this));
    menu.addWidget(1, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToFacility(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddFacilityManagerTabItem(facility), true);
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromFacility());
    menu.addWidget(2, removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<User> list = jsonCallback.getTableSelectedList();
            String text = "Following users won't be facility managers anymore and won't be able to manage this facility in Perun.";
            UiElements.showDeleteConfirm(list, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < list.size(); i++) {
                        if (i == list.size() - 1) {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
                            request.removeFacilityAdmin(facility, list.get(i));
                        } else {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeFacilityAdmin(facility, list.get(i));
                        }
                    }
                }
            });
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
    table.addStyleName("perun-table");
    return table;
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ArrayList(java.util.ArrayList)

Example 7 with RemoveAdmin

use of cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin in project perun by CESNET.

the class VoManagersTabItem method fillContentGroups.

private Widget fillContentGroups(final GetAdminGroups adminGroups, TabMenu menu) {
    adminGroups.clearTableSelectedSet();
    // refresh
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(adminGroups);
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToVo(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddVoManagerGroupTabItem(vo, events), true);
        }
    });
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    menu.addWidget(1, addButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromVo());
    menu.addWidget(2, removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<Group> adminsForRemoving = adminGroups.getTableSelectedList();
            String text = "Members of following groups won't be VO managers anymore.";
            UiElements.showDeleteConfirm(adminsForRemoving, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < adminsForRemoving.size(); i++) {
                        RemoveAdmin request;
                        if (i == adminsForRemoving.size() - 1) {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeVoAdminGroup(vo, adminsForRemoving.get(i));
                    }
                }
            });
        }
    });
    // get the table
    CellTable<Group> table = adminGroups.getTable(new FieldUpdater<Group, String>() {

        public void update(int i, Group grp, String s) {
            session.getTabManager().addTab(new GroupDetailTabItem(grp));
        }
    });
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(adminGroups, table, removeButton);
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 8 with RemoveAdmin

use of cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin in project perun by CESNET.

the class CreateFacilityTabItem method fillContentUsers.

private Widget fillContentUsers(final GetRichAdminsWithAttributes jsonCallback, TabMenu menu) {
    jsonCallback.clearTableSelectedSet();
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = jsonCallback.getTable(new FieldUpdater<User, String>() {

            @Override
            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = jsonCallback.getTable();
    }
    menu.addWidget(0, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToFacility(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddFacilityManagerTabItem(facility), true);
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromFacility());
    menu.addWidget(1, removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<User> list = jsonCallback.getTableSelectedList();
            String text = "Following users won't be facility managers anymore and won't be able to manage this facility in Perun.";
            UiElements.showDeleteConfirm(list, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < list.size(); i++) {
                        if (i == list.size() - 1) {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
                            request.removeFacilityAdmin(facility, list.get(i));
                        } else {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeFacilityAdmin(facility, list.get(i));
                        }
                    }
                }
            });
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
    table.addStyleName("perun-table");
    return table;
}
Also used : FieldUpdater(com.google.gwt.cell.client.FieldUpdater) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ArrayList(java.util.ArrayList)

Example 9 with RemoveAdmin

use of cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin in project perun by CESNET.

the class SecurityTeamMembersTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(securityTeam.getName()) + ": " + "members");
    // Get vos request
    final GetAdmins teams = new GetAdmins(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.addMemberToSecurityTeam(), new ClickHandler() {

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

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<User> 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++) {
                        RemoveAdmin request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveAdmin(PerunEntity.SECURITY_TEAM, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeSecurityTeamAdmin(securityTeam, itemsToRemove.get(i));
                    }
                }
            });
        }
    });
    tabMenu.addWidget(removeButton);
    final TabItem tab = this;
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        // get the table with custom onclick
        table = teams.getTable(new FieldUpdater<User, String>() {

            @Override
            public void update(int i, User user, String string) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
                session.getTabManager().closeTab(tab, false);
            }
        });
    } 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) 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) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin) GetAdmins(cz.metacentrum.perun.webgui.json.authzResolver.GetAdmins)

Aggregations

RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)9 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)9 ArrayList (java.util.ArrayList)9 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)5 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)5 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)5 User (cz.metacentrum.perun.webgui.model.User)4 Group (cz.metacentrum.perun.webgui.model.Group)3 GroupDetailTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem)3 VoManagersTabItem (cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem)2 GetAdmins (cz.metacentrum.perun.webgui.json.authzResolver.GetAdmins)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1