Search in sources :

Example 1 with RemoveAdmin

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

the class GroupManagersTabItem method fillContentGroups.

private Widget fillContentGroups(final GetAdminGroups admins, TabMenu menu) {
    admins.clearTableSelectedSet();
    boolean isMembersGroup = group.isCoreGroup();
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromGroup());
    if (!isMembersGroup) {
        CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToGroup(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new AddGroupManagerGroupTabItem(group, events), true);
            }
        });
        if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
            addButton.setEnabled(false);
        menu.addWidget(1, addButton);
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<Group> itemsToRemove = admins.getTableSelectedList();
                String text = "Members of following groups won't be group managers anymore.";
                UiElements.showDeleteConfirm(itemsToRemove, text, 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.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                            } else {
                                request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
                            }
                            request.removeGroupAdminGroup(group, itemsToRemove.get(i));
                        }
                    }
                });
            }
        });
        menu.addWidget(2, removeButton);
    } else {
        // is core group
        menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
        Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
        a.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
            }
        });
        menu.addWidget(2, a);
    }
    // get the table
    CellTable<Group> table = admins.getTable(new FieldUpdater<Group, String>() {

        public void update(int i, Group grp, String s) {
            session.getTabManager().addTab(new GroupDetailTabItem(grp));
        }
    });
    removeButton.setEnabled(false);
    if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
        JsonUtils.addTableManagedButton(admins, table, removeButton);
    }
    table.setStyleName("perun-table");
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) VoManagersTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 2 with RemoveAdmin

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

the class GroupManagersTabItem method fillContentUsers.

private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
    admins.clearTableSelectedSet();
    boolean isMembersGroup = group.isCoreGroup();
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromGroup());
    if (!isMembersGroup) {
        CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToGroup(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new AddGroupManagerTabItem(group), true);
            }
        });
        if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
            addButton.setEnabled(false);
        menu.addWidget(1, addButton);
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<User> itemsToRemove = admins.getTableSelectedList();
                String text = "Following users won't be group managers anymore.";
                UiElements.showDeleteConfirm(itemsToRemove, text, 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.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                            } else {
                                request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
                            }
                            request.removeGroupAdmin(group, itemsToRemove.get(i));
                        }
                    }
                });
            }
        });
        menu.addWidget(2, removeButton);
    } else {
        // is core group
        menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
        Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
        a.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
            }
        });
        menu.addWidget(2, a);
    }
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = admins.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = admins.getTable();
    }
    removeButton.setEnabled(false);
    if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
        JsonUtils.addTableManagedButton(admins, table, removeButton);
    }
    table.setStyleName("perun-table");
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) VoManagersTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 3 with RemoveAdmin

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

the class VoManagersTabItem method fillContentUsers.

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

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

        public void onClick(ClickEvent event) {
            final ArrayList<User> adminsForRemoving = admins.getTableSelectedList();
            String text = "Following users 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.removeVoAdmin(vo, adminsForRemoving.get(i));
                    }
                }
            });
        }
    });
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = admins.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = admins.getTable();
    }
    // 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(admins, table, removeButton);
    return table;
}
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) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 4 with RemoveAdmin

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

the class CreateFacilityTabItem method fillContentGroups.

private Widget fillContentGroups(final GetAdminGroups jsonCallback, TabMenu menu) {
    jsonCallback.clearTableSelectedSet();
    // get the table
    CellTable<Group> table = jsonCallback.getTable(new FieldUpdater<Group, String>() {

        @Override
        public void update(int i, Group grp, String s) {
            session.getTabManager().addTab(new GroupDetailTabItem(grp));
        }
    });
    menu.addWidget(0, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToFacility(), new ClickHandler() {

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

        public void onClick(ClickEvent event) {
            final ArrayList<Group> list = jsonCallback.getTableSelectedList();
            String text = "Members of following groups 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.removeFacilityAdminGroup(facility, list.get(i));
                        } else {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeFacilityAdminGroup(facility, list.get(i));
                        }
                    }
                }
            });
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
    table.addStyleName("perun-table");
    return table;
}
Also used : ArrayList(java.util.ArrayList) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 5 with RemoveAdmin

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

the class FacilityManagersTabItem method fillContentGroups.

private Widget fillContentGroups(final GetAdminGroups jsonCallback, TabMenu menu) {
    jsonCallback.clearTableSelectedSet();
    // get the table
    CellTable<Group> table = jsonCallback.getTable(new FieldUpdater<Group, String>() {

        @Override
        public void update(int i, Group grp, String s) {
            session.getTabManager().addTab(new GroupDetailTabItem(grp));
        }
    });
    menu.addWidget(0, UiElements.getRefreshButton(this));
    menu.addWidget(1, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToFacility(), new ClickHandler() {

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

        public void onClick(ClickEvent event) {
            final ArrayList<Group> list = jsonCallback.getTableSelectedList();
            String text = "Members of following groups 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.removeFacilityAdminGroup(facility, list.get(i));
                        } else {
                            RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeFacilityAdminGroup(facility, list.get(i));
                        }
                    }
                }
            });
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
    table.addStyleName("perun-table");
    return table;
}
Also used : 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)

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