diff --git a/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/json/managers/RegistrarManager.java b/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/json/managers/RegistrarManager.java index b14b5878..54a115b9 100644 --- a/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/json/managers/RegistrarManager.java +++ b/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/json/managers/RegistrarManager.java @@ -80,6 +80,24 @@ public static Request getApplicationsForUser(int userId, JsonEvents events) { } + /** + * Retrieve open applications for User. + * + * @param userId ID of user to get applications for or 0 if user unknown (search by authorization) + * @param events Events done on callback + * + * @return Request unique request + */ + public static Request getOpenApplicationsForUser(int userId, JsonEvents events) { + + JsonClient client = new JsonClient(events); + if (userId > 0) { + client.put("id", userId); + } + return client.call(REGISTRAR_MANAGER + "getOpenApplicationsForUser"); + + } + /** * Retrieve applications for Member. * diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation.java index 819f3573..f4a35820 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation.java @@ -255,6 +255,15 @@ public interface PerunRegistrarTranslation extends PerunTranslation { @DefaultMessage("Submitted registrations") public String submittedTitle(); + @DefaultMessage("Open applications") + public String openAppsOnly(); + + @DefaultMessage("All applications") + public String allApps(); + + @DefaultMessage("This operation may take a while.") + public String slowOperation(); + @DefaultMessage("Submitted") public String submittedOn(); diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.java b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.java index a6a712d7..106c7229 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.java +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.java @@ -19,6 +19,7 @@ import cz.metacentrum.perun.wui.registrar.model.ApplicationColumnProvider; import cz.metacentrum.perun.wui.widgets.PerunButton; import cz.metacentrum.perun.wui.widgets.PerunDataGrid; +import org.gwtbootstrap3.client.ui.AnchorListItem; import org.gwtbootstrap3.client.ui.html.Text; /** @@ -40,6 +41,15 @@ interface AppsViewUiBinder extends UiBinder { @UiField PerunButton refresh; + @UiField + AnchorListItem openAppsOnly; + + @UiField + AnchorListItem allApps; + + @UiField + PerunButton filterButton; + private PerunRegistrarTranslation translation = GWT.create(PerunRegistrarTranslation.class); @Inject @@ -48,6 +58,10 @@ public AppsView(AppsViewUiBinder binder) { initWidget(binder.createAndBindUi(this)); text.setText(translation.submittedTitle()); refresh.setTooltipText(translation.refresh()); + openAppsOnly.setText(translation.openAppsOnly()); + allApps.setText(translation.allApps()); + allApps.setTitle(translation.slowOperation()); + filterButton.setText(translation.filter()); grid.setHeight("100%"); } @@ -57,34 +71,83 @@ public void refresh(ClickEvent event) { draw(); } + @UiHandler(value = "filterButton") + public void filterButton(ClickEvent event) { + draw(); + } + + @UiHandler(value = "allApps") + public void allApps(ClickEvent event) { + allApps.setActive(true); + openAppsOnly.setActive(false); + draw(); + } + + @UiHandler(value = "openAppsOnly") + public void openAppsOnly(ClickEvent event) { + openAppsOnly.setActive(true); + allApps.setActive(false); + draw(); + } + public void draw() { - // make sure we search by identity and user session info - RegistrarManager.getApplicationsForUser(0, new JsonEvents() { - - JsonEvents retry = this; - - @Override - public void onFinished(JavaScriptObject jso) { - grid.setList(JsUtils.jsoAsList(jso)); - } - - @Override - public void onError(PerunException error) { - grid.getLoaderWidget().onError(error, new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - RegistrarManager.getApplicationsForUser(0, retry); - } - }); - } - - @Override - public void onLoadingStart() { - grid.clearTable(); - grid.getLoaderWidget().onLoading(translation.loadingApplications()); - } - }); + + if (openAppsOnly.isActive()) { + // make sure we search by identity and user session info + RegistrarManager.getOpenApplicationsForUser(0, new JsonEvents() { + + JsonEvents retry = this; + + @Override + public void onFinished(JavaScriptObject jso) { + grid.setList(JsUtils.jsoAsList(jso)); + } + + @Override + public void onError(PerunException error) { + grid.getLoaderWidget().onError(error, new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + RegistrarManager.getOpenApplicationsForUser(0, retry); + } + }); + } + + @Override + public void onLoadingStart() { + grid.clearTable(); + grid.getLoaderWidget().onLoading(translation.loadingApplications()); + } + }); + } else { + // make sure we search by identity and user session info + RegistrarManager.getApplicationsForUser(0, new JsonEvents() { + + JsonEvents retry = this; + + @Override + public void onFinished(JavaScriptObject jso) { + grid.setList(JsUtils.jsoAsList(jso)); + } + + @Override + public void onError(PerunException error) { + grid.getLoaderWidget().onError(error, new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + RegistrarManager.getApplicationsForUser(0, retry); + } + }); + } + + @Override + public void onLoadingStart() { + grid.clearTable(); + grid.getLoaderWidget().onLoading(translation.loadingApplications()); + } + }); + } } diff --git a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.ui.xml b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.ui.xml index 82cea7d8..4a5f4814 100644 --- a/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.ui.xml +++ b/perun-wui-registrar/src/main/java/cz/metacentrum/perun/wui/registrar/pages/AppsView.ui.xml @@ -15,7 +15,15 @@ - + + + Filter + + + Open applications + All applications + + diff --git a/perun-wui-registrar/src/main/resources/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation_cs.properties b/perun-wui-registrar/src/main/resources/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation_cs.properties index 78c45259..00c14d1d 100644 --- a/perun-wui-registrar/src/main/resources/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation_cs.properties +++ b/perun-wui-registrar/src/main/resources/cz/metacentrum/perun/wui/registrar/client/resources/PerunRegistrarTranslation_cs.properties @@ -100,6 +100,9 @@ submittedOn=Podáno state=Stav type=Typ virtualOrganization=Virtuální organizace +openAppsOnly=Otevřené přihlášky +allApps=Všechny přihlášky +slowOperation=Tato operace může chvíli trvat. group=Skupina showDetail=Zobrazit mailVerificationText=Zkontrolujte si prosím doručenou poštu pro {0}. Pokud jste neobdrželi zprávu pro ověření mailové adresy, zkontrolujte si složku pro SPAM nebo použijte tlačítko pro opětovné odeslání.