Search in sources :

Example 1 with GetGroupsCount

use of cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount in project perun by CESNET.

the class StatisticsTabItem method draw.

public Widget draw() {
    // PAGE CONTENTS
    ScrollPanel scroll = new ScrollPanel();
    final VerticalPanel vp = new VerticalPanel();
    vp.setStyleName("perun-table");
    vp.setSpacing(5);
    scroll.setWidget(vp);
    scroll.setStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(scroll, 350, this);
    final DisclosurePanel vosStatistics = new DisclosurePanel();
    vosStatistics.setWidth("100%");
    // vosStatistics.setOpen(true);
    FlexTable vosHeader = new FlexTable();
    vosHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
    vosHeader.setWidget(0, 1, new HTML("<h3>Virtual Organizations</h3>"));
    vosHeader.setTitle("Click to show/hide VOs statistics");
    vosStatistics.setHeader(vosHeader);
    vp.add(vosStatistics);
    // the general statistics table
    final FlexTable statisticsTable = new FlexTable();
    statisticsTable.addStyleName("statisticsTable");
    // the VOs table
    final FlexTable vosTable = new FlexTable();
    vosTable.addStyleName("statisticsTable");
    vosTable.setWidget(0, 0, new HTML("<strong>" + "VO name" + "</strong>"));
    vosTable.setWidget(0, 1, new HTML("<strong>" + "Members" + "</strong>"));
    vosTable.setWidget(0, 2, new HTML("<strong>" + "Valid members" + "</strong>"));
    vosTable.setWidget(0, 3, new HTML("<strong>" + "Invalid members" + "</strong>"));
    vosTable.setWidget(0, 4, new HTML("<strong>" + "Expired members" + "</strong>"));
    vosTable.setWidget(0, 5, new HTML("<strong>" + "Disabled members" + "</strong>"));
    vosTable.setWidget(0, 6, new HTML("<strong>" + "Groups" + "</strong>"));
    vosTable.setWidget(0, 7, new HTML("<strong>" + "Resources" + "</strong>"));
    // vos events - adds the VOs to the table and calls how many members the VO has
    JsonCallbackEvents vosEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            // conversion
            ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
            vos = new TableSorter<VirtualOrganization>().sortByName(vos);
            // iterating VOs
            for (int i = 0; i < vos.size(); i++) {
                VirtualOrganization vo = vos.get(i);
                // call the request for number of members
                GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
                countMembers.retrieveData();
                GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
                countValidMembers.retrieveData();
                GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
                countInvalidMembers.retrieveData();
                GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
                countExpiredMembers.retrieveData();
                GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
                countDisabledMembers.retrieveData();
                // call the request for number of resources
                GetResourcesCount countResources = new GetResourcesCount(vo.getId());
                countResources.retrieveData();
                GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
                countGroups.retrieveData();
                // adds the VO to the table
                vosTable.setText(i + 1, 0, vo.getName());
                vosTable.setWidget(i + 1, 1, countMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 2, countValidMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 3, countInvalidMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 4, countExpiredMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 5, countDisabledMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 6, countGroups.getGroupsCountHyperlink());
                vosTable.setWidget(i + 1, 7, countResources.getResourcesCountHyperlink());
            }
        }
    };
    // requests
    final GetVos vos = new GetVos(vosEvents);
    vosHeader.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (vosStatistics.getContent() == null) {
                // retrieve data
                vosStatistics.setContent(vosTable);
                vos.retrieveData();
            }
        }
    });
    this.contentWidget.setWidget(scroll);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) TableSorter(cz.metacentrum.perun.webgui.client.resources.TableSorter) GetGroupsCount(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetMembersCount(cz.metacentrum.perun.webgui.json.membersManager.GetMembersCount) GetResourcesCount(cz.metacentrum.perun.webgui.json.resourcesManager.GetResourcesCount)

Example 2 with GetGroupsCount

use of cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount in project perun by CESNET.

the class VoOverviewTabItem method draw.

public Widget draw() {
    // main panel
    ScrollPanel scroll = new ScrollPanel();
    final VerticalPanel vp2 = new VerticalPanel();
    vp2.setStyleName("perun-table");
    scroll.setWidget(vp2);
    scroll.setStyleName("perun-tableScrollPanel");
    vp2.setSpacing(5);
    // tools panel
    final DisclosurePanel tools = new DisclosurePanel();
    tools.setWidth("100%");
    tools.setOpen(true);
    FlexTable toolsHeader = new FlexTable();
    toolsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.settingToolsIcon()));
    toolsHeader.setWidget(0, 1, new HTML("<h3>Quick tools</h3>"));
    toolsHeader.setTitle("Click to show/hide VO quick tools");
    tools.setHeader(toolsHeader);
    // tools panel content
    FlexTable toolsLayout = new FlexTable();
    toolsLayout.setSize("100%", "100%");
    toolsLayout.setCellSpacing(5);
    tools.setContent(toolsLayout);
    toolsLayout.getFlexCellFormatter().setWidth(0, 0, "220px");
    toolsLayout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(2, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(3, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(4, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(5, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(6, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    CustomButton addMember = new CustomButton(ButtonTranslation.INSTANCE.addMemberButton() + "…", ButtonTranslation.INSTANCE.addMemberToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddMemberToVoTabItem(vo), true);
        }
    });
    CustomButton addServiceMember = new CustomButton(ButtonTranslation.INSTANCE.createServiceMemberButton() + "…", ButtonTranslation.INSTANCE.createServiceMember(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new CreateServiceMemberInVoTabItem(vo));
        }
    });
    CustomButton inviteUser = new CustomButton("Invite member…", "Invite person to become member of your Virtual organization.", SmallIcons.INSTANCE.emailAddIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new InviteUserTabItem(vo, null));
        }
    });
    CustomButton addManager = new CustomButton(ButtonTranslation.INSTANCE.addManagerButton() + "…", ButtonTranslation.INSTANCE.addManagerToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddVoManagerTabItem(vo), true);
        }
    });
    CustomButton createGroup = new CustomButton(ButtonTranslation.INSTANCE.createGroupButton() + "…", ButtonTranslation.INSTANCE.createGroup(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
        }
    });
    CustomButton addToResource = new CustomButton(ButtonTranslation.INSTANCE.addMemberToResourceButton() + "…", ButtonTranslation.INSTANCE.addMemberToResource(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddMemberToResourceTabItem(vo), true);
        }
    });
    toolsLayout.setWidget(0, 0, addMember);
    toolsLayout.setWidget(1, 0, addServiceMember);
    toolsLayout.setWidget(2, 0, inviteUser);
    toolsLayout.setWidget(3, 0, addManager);
    toolsLayout.setWidget(4, 0, createGroup);
    toolsLayout.setWidget(5, 0, addToResource);
    if (!session.isVoAdmin(voId))
        addMember.setEnabled(false);
    if (!session.isVoAdmin(voId))
        addServiceMember.setEnabled(false);
    if (!session.isVoAdmin(voId))
        inviteUser.setEnabled(false);
    if (!session.isVoAdmin(voId))
        addManager.setEnabled(false);
    if (!session.isVoAdmin(voId))
        createGroup.setEnabled(false);
    if (!session.isVoAdmin(voId))
        addToResource.setEnabled(false);
    toolsLayout.setHTML(0, 1, "Add new member into your VO. Candidates can be searched for in VO's external sources or among user already existing in Perun.");
    toolsLayout.setHTML(1, 1, "Create new member which represent service account (account usually used by more users with separate login and password).");
    toolsLayout.setHTML(2, 1, "Invite person to become member of your Virtual organization.");
    toolsLayout.setHTML(3, 1, "Add new manager which can manage your VO in Perun.");
    toolsLayout.setHTML(4, 1, "Create new group in your VO.");
    toolsLayout.setHTML(5, 1, "Add selected member to specific resource (grant some type of access to Facility resources).");
    vp2.add(tools);
    // statistics - json
    // call the request for number of members
    final GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
    final GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
    final GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
    final GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
    final GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
    // call the request for number of resources
    final GetResourcesCount countResources = new GetResourcesCount(vo.getId());
    // call the request for number of groups
    final GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
    // statistics
    final DisclosurePanel statistics = new DisclosurePanel();
    statistics.setWidth("100%");
    // statistics.setOpen(true);
    FlexTable statHeader = new FlexTable();
    statHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.statisticsIcon()));
    statHeader.setWidget(0, 1, new HTML("<h3>Statistics</h3>"));
    statHeader.setTitle("Click to show/hide VO statistics");
    statistics.setHeader(statHeader);
    final FlexTable vosTable = new FlexTable();
    vosTable.addStyleName("statisticsTable");
    statHeader.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (statistics.getContent() == null) {
                countMembers.retrieveData();
                countValidMembers.retrieveData();
                countInvalidMembers.retrieveData();
                countExpiredMembers.retrieveData();
                countDisabledMembers.retrieveData();
                countResources.retrieveData();
                countGroups.retrieveData();
                statistics.setContent(vosTable);
            }
        }
    });
    vosTable.setWidget(0, 0, new HTML("<strong>" + "Members" + "</strong>"));
    vosTable.setWidget(0, 1, countMembers.getMembersCountLabel());
    vosTable.setWidget(1, 0, new HTML(" - valid"));
    vosTable.setWidget(1, 1, countValidMembers.getMembersCountLabel());
    vosTable.setWidget(2, 0, new HTML(" - invalid"));
    vosTable.setWidget(2, 1, countInvalidMembers.getMembersCountLabel());
    vosTable.setWidget(3, 0, new HTML(" - expired"));
    vosTable.setWidget(3, 1, countExpiredMembers.getMembersCountLabel());
    vosTable.setWidget(4, 0, new HTML(" - disabled"));
    vosTable.setWidget(5, 1, countDisabledMembers.getMembersCountLabel());
    vosTable.setWidget(5, 0, new HTML("<strong>" + "Resources" + "</strong>"));
    vosTable.setWidget(5, 1, countResources.getResourcesCountLabel());
    vosTable.setWidget(6, 0, new HTML("<strong>" + "Groups" + "</strong>"));
    vosTable.setWidget(6, 1, countGroups.getGroupsCountLabel());
    vp2.add(statistics);
    session.getUiElements().resizeSmallTabPanel(scroll, 350, this);
    contentWidget.setWidget(scroll);
    return getWidget();
}
Also used : GetGroupsCount(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount) CreateServiceMemberInVoTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.CreateServiceMemberInVoTabItem) AddMemberToResourceTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToResourceTabItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CreateGroupTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.CreateGroupTabItem) InviteUserTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.InviteUserTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GetMembersCount(cz.metacentrum.perun.webgui.json.membersManager.GetMembersCount) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) AddMemberToVoTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToVoTabItem) GetResourcesCount(cz.metacentrum.perun.webgui.json.resourcesManager.GetResourcesCount)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 GetGroupsCount (cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount)2 GetMembersCount (cz.metacentrum.perun.webgui.json.membersManager.GetMembersCount)2 GetResourcesCount (cz.metacentrum.perun.webgui.json.resourcesManager.GetResourcesCount)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 TableSorter (cz.metacentrum.perun.webgui.client.resources.TableSorter)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)1 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)1 CreateGroupTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.CreateGroupTabItem)1 AddMemberToResourceTabItem (cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToResourceTabItem)1 AddMemberToVoTabItem (cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToVoTabItem)1 CreateServiceMemberInVoTabItem (cz.metacentrum.perun.webgui.tabs.memberstabs.CreateServiceMemberInVoTabItem)1 InviteUserTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.InviteUserTabItem)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1