Skip to content

Commit

Permalink
Merge pull request #5611 from jay-hodgson/SWC-7067
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson authored Jan 8, 2025
2 parents 9aef163 + f9f6bff commit 3617cc9
Show file tree
Hide file tree
Showing 14 changed files with 314 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.sagebionetworks.web.client.presenter.ComingSoonPresenter;
import org.sagebionetworks.web.client.presenter.DataAccessApprovalTokenPresenter;
import org.sagebionetworks.web.client.presenter.DataAccessManagementPresenter;
import org.sagebionetworks.web.client.presenter.DataCatalogPagePresenter;
import org.sagebionetworks.web.client.presenter.DownPresenter;
import org.sagebionetworks.web.client.presenter.DownloadCartPresenter;
import org.sagebionetworks.web.client.presenter.EmailInvitationPresenter;
Expand Down Expand Up @@ -346,6 +347,8 @@ public interface PortalGinInjector extends Ginjector {

DownloadCartPresenter getDownloadCartPresenter();

DataCatalogPagePresenter getDataCatalogPagePresenter();

ChangeUsernamePresenter getChangeUsernamePresenter();

TrashPresenter getTrashPresenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import org.sagebionetworks.web.client.view.DataAccessApprovalTokenViewImpl;
import org.sagebionetworks.web.client.view.DataAccessManagementView;
import org.sagebionetworks.web.client.view.DataAccessManagementViewImpl;
import org.sagebionetworks.web.client.view.DataCatalogPageView;
import org.sagebionetworks.web.client.view.DataCatalogPageViewImpl;
import org.sagebionetworks.web.client.view.DivView;
import org.sagebionetworks.web.client.view.DivViewImpl;
import org.sagebionetworks.web.client.view.DownView;
Expand Down Expand Up @@ -1368,6 +1370,7 @@ protected void configure() {
bind(PreviewConfigView.class).to(PreviewConfigViewImpl.class);
bind(SynapseFormConfigView.class).to(SynapseFormConfigViewImpl.class);
bind(DownloadCartPageView.class).to(DownloadCartPageViewImpl.class);
bind(DataCatalogPageView.class).to(DataCatalogPageViewImpl.class);
bind(EditFileMetadataModalView.class)
.to(EditFileMetadataModalViewImpl.class);
bind(EditFileMetadataModalWidget.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.sagebionetworks.web.client.jsinterop;

import java.util.Map;
import jsinterop.annotations.JsFunction;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsPropertyMap;

@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class CardConfiguration {

String type;
double secondaryLabelLimit;
GenericCardSchema genericCardSchema;

@JsOverlay
public static CardConfiguration create(
String type,
int secondaryLabelLimit,
GenericCardSchema genericCardSchema
) {
CardConfiguration config = new CardConfiguration();
config.type = type;
config.secondaryLabelLimit = secondaryLabelLimit;
config.genericCardSchema = genericCardSchema;
return config;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.sagebionetworks.web.client.jsinterop;

import java.util.Map;
import jsinterop.annotations.JsNullable;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsPropertyMap;

@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
public class GenericCardSchema {

String type;
String title;
String subTitle;
String description;
String[] secondaryLabels;

@JsOverlay
public static GenericCardSchema create(
String type,
String title,
String subTitle,
String description,
String[] secondaryLabels
) {
GenericCardSchema config = new GenericCardSchema();
config.type = type;
config.title = title;
config.subTitle = subTitle;
config.description = description;
config.secondaryLabels = secondaryLabels;
return config;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,35 @@ public interface OnViewSharingSettingsHandler {
@JsNullable
boolean defaultShowPlots;

@JsNullable
boolean defaultShowSearchBox;

@JsNullable
boolean hideCopyToClipboard;

@JsNullable
boolean hideDownload;

boolean showLastUpdatedOn;

@JsNullable
CardConfiguration cardConfiguration;

@JsOverlay
public static QueryWrapperPlotNavProps create(
String sql,
String initQueryJson,
OnQueryCallback onQueryChange,
OnQueryResultBundleCallback onQueryResultBundleChange,
OnViewSharingSettingsHandler onViewSharingSettingsClicked,
boolean hideSqlEditorControl
boolean hideSqlEditorControl,
Boolean defaultShowPlots,
Boolean defaultShowSearchBox,
Boolean hideCopyToClipboard,
Boolean hideDownload,
SynapseTableProps tableConfiguration,
CardConfiguration cardConfiguration,
String name
) {
QueryWrapperPlotNavProps props = new QueryWrapperPlotNavProps();
props.sql = sql;
Expand All @@ -73,13 +92,35 @@ public static QueryWrapperPlotNavProps create(
props.onQueryChange = onQueryChange;
props.onQueryResultBundleChange = onQueryResultBundleChange;
props.onViewSharingSettingsClicked = onViewSharingSettingsClicked;
props.tableConfiguration = SynapseTableProps.create();
if (tableConfiguration != null) {
props.tableConfiguration = tableConfiguration;
}
props.shouldDeepLink = false;
props.name = "Items";
if (name != null) {
props.name = name;
}
props.downloadCartPageUrl = "DownloadCart:0";
props.showLastUpdatedOn = false;
// SWC-6138 - hide charts by default
props.defaultShowPlots = false;
if (defaultShowPlots != null) {
//unbox
props.defaultShowPlots = defaultShowPlots;
}
if (defaultShowSearchBox != null) {
//unbox
props.defaultShowSearchBox = defaultShowSearchBox;
}
if (hideCopyToClipboard != null) {
//unbox
props.hideCopyToClipboard = hideCopyToClipboard;
}
if (hideDownload != null) {
//unbox
props.hideDownload = hideDownload;
}
props.cardConfiguration = cardConfiguration;
return props;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.sagebionetworks.web.client.place.Challenges;
import org.sagebionetworks.web.client.place.ChangeUsername;
import org.sagebionetworks.web.client.place.ComingSoon;
import org.sagebionetworks.web.client.place.DataCatalogPagePlace;
import org.sagebionetworks.web.client.place.Down;
import org.sagebionetworks.web.client.place.EmailInvitation;
import org.sagebionetworks.web.client.place.ErrorPlace;
Expand Down Expand Up @@ -105,6 +106,7 @@ public AppActivityMapper(
openAccessPlaces.add(AccessRequirementPlace.class);
openAccessPlaces.add(TrustCenterPlace.class);
openAccessPlaces.add(PlansPlace.class);
openAccessPlaces.add(DataCatalogPagePlace.class);

excludeFromLastPlace = new ArrayList<Class>();
excludeFromLastPlace.add(Home.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.sagebionetworks.web.client.place.ComingSoon;
import org.sagebionetworks.web.client.place.DataAccessApprovalTokenPlace;
import org.sagebionetworks.web.client.place.DataAccessManagementPlace;
import org.sagebionetworks.web.client.place.DataCatalogPagePlace;
import org.sagebionetworks.web.client.place.Down;
import org.sagebionetworks.web.client.place.DownloadCartPlace;
import org.sagebionetworks.web.client.place.EmailInvitation;
Expand Down Expand Up @@ -102,6 +103,7 @@
TrustCenterPlace.Tokenizer.class,
ChatPlace.Tokenizer.class,
PlansPlace.Tokenizer.class,
DataCatalogPagePlace.Tokenizer.class,
}
)
public interface AppPlaceHistoryMapper extends PlaceHistoryMapper {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.sagebionetworks.web.client.place;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;
import com.google.gwt.place.shared.Prefix;

public class DataCatalogPagePlace extends Place {

private String token;

public DataCatalogPagePlace(String token) {
this.token = token;
}

public String toToken() {
return token;
}

@Prefix("DataCatalog")
public static class Tokenizer
implements PlaceTokenizer<DataCatalogPagePlace> {

@Override
public String getToken(DataCatalogPagePlace place) {
return place.toToken();
}

@Override
public DataCatalogPagePlace getPlace(String token) {
return new DataCatalogPagePlace(token);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.sagebionetworks.web.client.place.ComingSoon;
import org.sagebionetworks.web.client.place.DataAccessApprovalTokenPlace;
import org.sagebionetworks.web.client.place.DataAccessManagementPlace;
import org.sagebionetworks.web.client.place.DataCatalogPagePlace;
import org.sagebionetworks.web.client.place.Down;
import org.sagebionetworks.web.client.place.DownloadCartPlace;
import org.sagebionetworks.web.client.place.EmailInvitation;
Expand Down Expand Up @@ -548,6 +549,24 @@ public void onSuccess() {
presenter.start(panel, eventBus);
}

@Override
public void onFailure(Throwable caught) {
loadError(caught);
}
}
);
} else if (place instanceof DataCatalogPagePlace) {
GWT.runAsync(
DataCatalogPagePlace.class,
new RunAsyncCallback() {
@Override
public void onSuccess() {
DataCatalogPagePresenter presenter =
ginjector.getDataCatalogPagePresenter();
presenter.setPlace((DataCatalogPagePlace) place);
presenter.start(panel, eventBus);
}

@Override
public void onFailure(Throwable caught) {
loadError(caught);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.sagebionetworks.web.client.presenter;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Inject;
import org.sagebionetworks.web.client.view.DataCatalogPageView;

public class DataCatalogPagePresenter
extends AbstractActivity
implements
Presenter<org.sagebionetworks.web.client.place.DataCatalogPagePlace> {

private DataCatalogPageView view;

@Inject
public DataCatalogPagePresenter(DataCatalogPageView view) {
this.view = view;
}

@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
panel.setWidget(view.asWidget());
}

@Override
public void setPlace(
final org.sagebionetworks.web.client.place.DataCatalogPagePlace place
) {
view.render();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sagebionetworks.web.client.view;

import com.google.gwt.user.client.ui.IsWidget;

public interface DataCatalogPageView extends IsWidget {
public void render();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.sagebionetworks.web.client.view;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import java.util.HashMap;
import java.util.Map;
import org.sagebionetworks.web.client.context.SynapseReactClientFullContextPropsProvider;
import org.sagebionetworks.web.client.jsinterop.CardConfiguration;
import org.sagebionetworks.web.client.jsinterop.GenericCardSchema;
import org.sagebionetworks.web.client.widget.header.Header;
import org.sagebionetworks.web.client.widget.table.explore.QueryWrapperPlotNav;

public class DataCatalogPageViewImpl implements DataCatalogPageView {

SimplePanel container;

private Header headerWidget;
private SynapseReactClientFullContextPropsProvider propsProvider;

@Inject
public DataCatalogPageViewImpl(
Header headerWidget,
SynapseReactClientFullContextPropsProvider propsProvider
) {
container = new SimplePanel();
container.addStyleName("padding-30");
this.headerWidget = headerWidget;
this.propsProvider = propsProvider;
}

@Override
public void render() {
Window.scrollTo(0, 0); // scroll user to top of page
headerWidget.configure();

String[] secondaryLabels = { "contributors", "individuals", "id", "link" };
GenericCardSchema genericCardSchema = GenericCardSchema.create(
"dataset",
"name",
"community",
"description",
secondaryLabels
);
CardConfiguration cardConfiguration = CardConfiguration.create(
"GENERIC_CARD",
4,
genericCardSchema
);

QueryWrapperPlotNav plotNav = new QueryWrapperPlotNav(
propsProvider,
"SELECT * FROM syn61609402 WHERE includedInDataCatalog = 'true'",
null,
null,
newBundle -> {},
null,
true,
false,
true,
true,
true,
null,
cardConfiguration,
"Data Catalog"
);
container.clear();
container.setWidget(plotNav);
}

@Override
public Widget asWidget() {
return container.asWidget();
}
}
Loading

0 comments on commit 3617cc9

Please sign in to comment.