Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #323 from ggalmazor/new_version_notice
Browse files Browse the repository at this point in the history
Add note warning about a new Aggregate version
  • Loading branch information
yanokwa authored Oct 16, 2018
2 parents 9774219 + e4081da commit c19494f
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.opendatakit.aggregate.client;

import static org.opendatakit.aggregate.client.LayoutUtils.buildVersionNote;

import java.util.ArrayList;

import org.opendatakit.aggregate.client.form.ExportSummary;
Expand All @@ -37,6 +39,7 @@ public ExportSubTab() {

exportTable = new ExportTable();
add(exportTable);
add(buildVersionNote());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@

package org.opendatakit.aggregate.client;

import static org.opendatakit.aggregate.client.LayoutUtils.*;

import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.VerticalPanel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.opendatakit.aggregate.client.filter.ColumnFilter;
import org.opendatakit.aggregate.client.filter.Filter;
import org.opendatakit.aggregate.client.filter.FilterGroup;
Expand All @@ -34,15 +43,6 @@
import org.opendatakit.aggregate.client.widgets.SaveFilterGroupButton;
import org.opendatakit.aggregate.constants.common.UIConsts;

import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.VerticalPanel;

public class FiltersDataPanel extends ScrollPanel {

private Tree filtersTree;
Expand All @@ -62,8 +62,7 @@ public FiltersDataPanel(FilterSubTab parentPanel) {
getElement().setId("filters_container");

FlowPanel panel = new FlowPanel();
// panel.add( new HTML("<h2 id=\"filter_header\">" + HtmlConsts.SPACE + "Filters</h2>"));


FlexTable filterGroupButtons = new FlexTable();
filterGroupButtons.setWidget(0, 0, new SaveFilterGroupButton(parentSubTab));
copyButton = new SaveAsFilterGroupButton(parentSubTab);
Expand Down Expand Up @@ -91,6 +90,8 @@ public FiltersDataPanel(FilterSubTab parentPanel) {
filtersTree = new Tree();
panel.add(filtersTree);

panel.add(buildVersionNote());

// create the root as the new filter button
addFilter = new AddFilterButton(parentPanel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.opendatakit.aggregate.client;

import static org.opendatakit.aggregate.client.LayoutUtils.buildVersionNote;

import java.util.ArrayList;

import org.opendatakit.aggregate.client.form.FormSummary;
Expand Down Expand Up @@ -60,6 +62,7 @@ public FormsSubTab(AggregateUI baseUI) {
// add tables to panels
add(newForm);
add(listOfForms);
add(buildVersionNote());

}

Expand Down
35 changes: 35 additions & 0 deletions src/main/java/org/opendatakit/aggregate/client/LayoutUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.opendatakit.aggregate.client;

import static org.opendatakit.aggregate.buildconfig.BuildConfig.VERSION;

import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.ui.HTML;

public class LayoutUtils {
private static String latestVersion;

static native String getLatestVersion() /*-{
var req = new XMLHttpRequest();
req.open('GET', 'https://api.github.com/repos/opendatakit/aggregate/releases/latest', false);
req.send(null);
if (req.readyState === 4 && req.status === 200)
return JSON.parse(req.responseText).tag_name;
}-*/;

static HTML buildVersionNote() {
if (latestVersion == null)
latestVersion = getLatestVersion();
String shortVersion = VERSION.contains("-") ? VERSION.substring(0, VERSION.indexOf("-")) : VERSION;
String versionNote = shortVersion.equals(latestVersion)
? "You're up to date!"
: "<a href=\"https://github.com/opendatakit/aggregate/releases/latest\" target=\"_blank\">Update available</a>";
HTML html = new HTML("<small>" + shortVersion + " - " + versionNote + "</small>");
Style style = html.getElement().getStyle();
style.setProperty("position", "fixed");
style.setProperty("bottom", "0");
style.setProperty("left", "0");
style.setProperty("padding", "5px 10px");
style.setProperty("backgroundColor", "rgba(255,255,255,.9)");
return html;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.opendatakit.aggregate.client;

import static org.opendatakit.aggregate.client.LayoutUtils.buildVersionNote;

import org.opendatakit.aggregate.client.permissions.AccessConfigurationSheet;
import org.opendatakit.aggregate.constants.common.UIConsts;
import org.opendatakit.common.security.common.GrantedAuthorityName;
Expand Down Expand Up @@ -58,6 +60,7 @@ public void update() {
if ( accessConfig == null ) {
accessConfig = new AccessConfigurationSheet(this);
add(accessConfig);
add(buildVersionNote());
}
accessConfig.setVisible(true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.opendatakit.aggregate.client;

import static org.opendatakit.aggregate.client.LayoutUtils.buildVersionNote;

import org.opendatakit.aggregate.buildconfig.BuildConfig;
import org.opendatakit.aggregate.client.preferences.Preferences;
import org.opendatakit.aggregate.client.preferences.Preferences.PreferencesCompletionCallback;
Expand Down Expand Up @@ -236,6 +238,8 @@ public PreferencesSubTab() {
skipMalformedSubmissions = new SkipMalformedSubmissionsCheckbox(
Preferences.getSkipMalformedSubmissions(), settingsChange);
add(skipMalformedSubmissions);

add(buildVersionNote());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.opendatakit.aggregate.client;

import static org.opendatakit.aggregate.client.LayoutUtils.buildVersionNote;

import java.util.ArrayList;

import org.opendatakit.aggregate.client.externalserv.ExternServSummary;
Expand Down Expand Up @@ -57,6 +59,7 @@ public PublishSubTab() {
// add tables to panels
add(navTable);
add(publishTable);
add(buildVersionNote());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

package org.opendatakit.aggregate.client;

import java.util.ArrayList;
import static org.opendatakit.aggregate.client.LayoutUtils.buildVersionNote;

import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import java.util.ArrayList;
import org.opendatakit.aggregate.client.filter.FilterGroup;
import org.opendatakit.aggregate.client.form.FormServiceAsync;
import org.opendatakit.aggregate.client.form.FormSummary;
Expand All @@ -30,13 +37,6 @@
import org.opendatakit.aggregate.constants.common.UIConsts;
import org.opendatakit.common.security.common.GrantedAuthorityName;

import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;

public class SubmissionAdminSubTab extends AggregateSubTabBase {

private static final String SUBMISSION_TXT = "Manually Upload Submission Data";
Expand Down Expand Up @@ -78,12 +78,13 @@ public SubmissionAdminSubTab() {
add(navTable);
add(new Label("Incomplete Submissions:"));
add(submissions);
add(buildVersionNote());
}


@Override
public boolean canLeave() {
return true;
return true;
}

private class UpdateAction implements AsyncCallback<ArrayList<FormSummary>> {
Expand All @@ -103,17 +104,19 @@ public void onSuccess(ArrayList<FormSummary> formsFromService) {
// Make the call to get the published services
updateContent();
}
};
}

;

@Override
public void update() {
if ( AggregateUI.getUI().getUserInfo().getGrantedAuthorities().contains(GrantedAuthorityName.ROLE_DATA_OWNER)) {
if (AggregateUI.getUI().getUserInfo().getGrantedAuthorities().contains(GrantedAuthorityName.ROLE_DATA_OWNER)) {
formsBox.setVisible(true);
submissions.setVisible(true);
FormServiceAsync formSvc = SecureGWT.getFormService();
FormServiceAsync formSvc = SecureGWT.getFormService();

// Make the call to the form service.
formSvc.getForms(new UpdateAction());
// Make the call to the form service.
formSvc.getForms(new UpdateAction());
} else {
formsBox.setVisible(false);
submissions.setVisible(false);
Expand Down Expand Up @@ -153,13 +156,12 @@ public void onSuccess(SubmissionUISummary incompleteSubmissions) {

/**
* Handler to process the change in the form drop down
*
*/
private class ChangeDropDownHandler implements ChangeHandler {
@Override
public void onChange(ChangeEvent event) {
FormSummary form = formsBox.getSelectedForm();
if(form != null) {
if (form != null) {
selectedForm = form;
}
updateContent();
Expand Down

0 comments on commit c19494f

Please sign in to comment.