From 5901a3eeb4d54a759ffad77eeb8bc5979d0d8f91 Mon Sep 17 00:00:00 2001 From: Olivier Maury <Olivier.Maury@inrae.fr> Date: Fri, 8 Mar 2024 10:42:25 +0100 Subject: [PATCH 1/2] Ajouter les liens dans la barre du haut et le pied de page. fixes #32 --- .../www/client/i18n/AppConstants.java | 60 ++++++++++++++-- .../client/presenter/ContactPresenter.java | 14 +++- .../www/client/ui/AgroclimAppsMenu.java | 8 +++ .../www/client/view/LayoutView.java | 69 +++++++++++++------ .../client/i18n/AppConstants_fr.properties | 8 ++- 5 files changed, 131 insertions(+), 28 deletions(-) diff --git a/www-client/src/main/java/fr/agrometinfo/www/client/i18n/AppConstants.java b/www-client/src/main/java/fr/agrometinfo/www/client/i18n/AppConstants.java index d914d2d..322575e 100644 --- a/www-client/src/main/java/fr/agrometinfo/www/client/i18n/AppConstants.java +++ b/www-client/src/main/java/fr/agrometinfo/www/client/i18n/AppConstants.java @@ -8,12 +8,6 @@ package fr.agrometinfo.www.client.i18n; */ public interface AppConstants extends com.google.gwt.i18n.client.ConstantsWithLookup { - /** - * @return translation - */ - @DefaultStringValue("About") - String about(); - /** * @return translation */ @@ -135,12 +129,30 @@ public interface AppConstants extends com.google.gwt.i18n.client.ConstantsWithLo @DefaultStringValue("Contact us") String contactUs(); + /** + * @return translation + */ + @DefaultStringValue("Credits") + String credits(); + + /** + * @return translation + */ + @DefaultStringValue("en/credits.html") + String creditsPath(); + /** * @return translation */ @DefaultStringValue("Daily values") String dailyValues(); + /** + * @return translation + */ + @DefaultStringValue("Documentation") + String documentation(); + /** * @return translation */ @@ -165,12 +177,36 @@ public interface AppConstants extends com.google.gwt.i18n.client.ConstantsWithLo @DefaultStringValue("HTTP status text:") String failureStatusText(); + /** + * @return translation + */ + @DefaultStringValue("guide.html") + String guidePath(); + /** * @return translation */ @DefaultStringValue("Invalid e-mail address") String invalidEmailAddress(); + /** + * @return translation + */ + @DefaultStringValue("Legal notice") + String legalNotice(); + + /** + * @return translation + */ + @DefaultStringValue("en/legal-notice.html") + String legalNoticePath(); + + /** + * @return translation + */ + @DefaultStringValue("Your message was sent to AgroMetInfo team.") + String messageSent(); + /** * @return translation */ @@ -203,6 +239,18 @@ public interface AppConstants extends com.google.gwt.i18n.client.ConstantsWithLo @DefaultStringValue("Other AgroClim's services and tools") String otherAgroclimApps(); + /** + * @return translation + */ + @DefaultStringValue("Release notes") + String releaseNotes(); + + /** + * @return translation + */ + @DefaultStringValue("release-notes.html") + String releaseNotesPath(); + /** * @return translation */ diff --git a/www-client/src/main/java/fr/agrometinfo/www/client/presenter/ContactPresenter.java b/www-client/src/main/java/fr/agrometinfo/www/client/presenter/ContactPresenter.java index 834a028..5988819 100644 --- a/www-client/src/main/java/fr/agrometinfo/www/client/presenter/ContactPresenter.java +++ b/www-client/src/main/java/fr/agrometinfo/www/client/presenter/ContactPresenter.java @@ -2,9 +2,13 @@ package fr.agrometinfo.www.client.presenter; import java.util.StringJoiner; +import org.dominokit.domino.ui.notifications.Notification; + +import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window.Navigator; +import fr.agrometinfo.www.client.i18n.AppConstants; import fr.agrometinfo.www.client.util.ApplicationUtils; import fr.agrometinfo.www.client.util.UiUtils; import fr.agrometinfo.www.client.view.BaseView; @@ -30,6 +34,11 @@ public final class ContactPresenter implements Presenter { void close(); } + /** + * I18N constants. + */ + private static final AppConstants CSTS = GWT.create(AppConstants.class); + /** * The layout handling the panel. */ @@ -66,7 +75,10 @@ public final class ContactPresenter implements Presenter { dto.setMessage(sj.toString()); ApplicationServiceFactory.INSTANCE// .sendMessage(dto) // - .onSuccess(v -> view.close()) // + .onSuccess(v -> { + view.close(); + Notification.createSuccess(CSTS.messageSent()).show(); + }) // .onFailed(layoutView::failureNotification) // .send(); } diff --git a/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java b/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java index 70c4e3f..c33e3d2 100644 --- a/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java +++ b/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java @@ -37,6 +37,13 @@ public class AgroclimAppsMenu extends Menu<String> { addMenuItem("TEMPO", "app/img/logo_tempo.png", "https://tempo.pheno.fr/"); super.add(Elements.div().css("menu-item").add(Elements.a("https://agroclim.inrae.fr/services-et-outils") .attr("target", "_blank").textContent(CSTS.otherAgroclimApps()))); + // patch to display on mobile + super.addOpenHandler(() -> { + final String top = AgroclimAppsMenu.this.element().style.top; + if (top != null && top.startsWith("-")) { + AgroclimAppsMenu.this.element().style.top = "0px"; + } + }); } /** @@ -58,4 +65,5 @@ public class AgroclimAppsMenu extends Menu<String> { } super.getItemsContainer().add(link); } + } diff --git a/www-client/src/main/java/fr/agrometinfo/www/client/view/LayoutView.java b/www-client/src/main/java/fr/agrometinfo/www/client/view/LayoutView.java index ce7538b..f69eb81 100644 --- a/www-client/src/main/java/fr/agrometinfo/www/client/view/LayoutView.java +++ b/www-client/src/main/java/fr/agrometinfo/www/client/view/LayoutView.java @@ -111,6 +111,18 @@ public final class LayoutView extends AbstractBaseView<LayoutPresenter> implemen return sj.toString(); } + /** + * @param relativePath documentation path relative to documentation root + */ + private static void goToDocumentation(final String relativePath) { + final String documentationRootUrl = "../"; + if (relativePath.isEmpty()) { + DomGlobal.location.assign(documentationRootUrl); + } else { + DomGlobal.window.open(documentationRootUrl + relativePath, "_blank"); + } + } + /** * Choice from the user. */ @@ -230,7 +242,9 @@ public final class LayoutView extends AbstractBaseView<LayoutPresenter> implemen GWT.log("LayoutView.initFooter()"); layout.showFooter(); layout.fixFooter(); - appendFooterMenuItem(CSTS.about(), e -> this.notification("Not yet implemented")); + appendFooterMenuItem(CSTS.credits(), e -> goToDocumentation(CSTS.creditsPath())); + appendFooterMenuItem(CSTS.legalNotice(), e -> goToDocumentation(CSTS.legalNoticePath())); + appendFooterMenuItem(CSTS.releaseNotes(), e -> goToDocumentation(CSTS.releaseNotesPath())); appendFooterMenuItem(CSTS.contactUs(), e -> getPresenter().showContactView()); } @@ -327,14 +341,41 @@ public final class LayoutView extends AbstractBaseView<LayoutPresenter> implemen private void initTopBar() { GWT.log("LayoutView.initTopBar()"); - layout.getTopBar() // - .css("agrometinfo-topbar") // - .appendChild(DominoElement.of(li() // + // Click on branch "AgroMetInfo" redirect to documentation home + layout.getNavigationBar().getTitle().addClickListener(e -> goToDocumentation("")); + // top bar links + layout.getTopBar().css("agrometinfo-topbar"); + // Menu to hide right panel + layout.getTopBar().appendChild(DominoElement.of(li() // .css(Styles.pull_right) // .add(a() // .on(EventType.click, e -> toggleRightPanel()) // .title(CSTS.toggleRightPanel()) // .add(Icons.ALL.menu_open_mdi().clickable())))); + // "..." menu + layout.getTopBar().appendChild(DominoElement.of(li() // + .css(Styles.pull_right) // + .add(a() // + .add(Icons.ALL.dots_vertical_mdi().clickable()))) + .showOn(ScreenMedia.SMALL_AND_DOWN) // + .hideOn(ScreenMedia.MEDIUM_AND_UP) // + .setDropMenu(dotDropMenu)); + // AgroClim's apps + layout.getTopBar().appendChild(DominoElement.of(li() // + .css(Styles.pull_right) // + .add(a()// + .title(CSTS.agroclimApps()) // + .add(Icons.ALL.apps_mdi().clickable()))) // + .setDropMenu(new AgroclimAppsMenu())); + // Link to documentation + layout.getTopBar().appendChild(DominoElement.of(li() // + .css(Styles.pull_right) // + .add(a() // + .on(EventType.click, e -> goToDocumentation(CSTS.guidePath())) // + .title(CSTS.documentation()) // + .add(Icons.ALL.book_open_page_variant_mdi().clickable()))) // + .showOn(ScreenMedia.MEDIUM_AND_UP) // + .hideOn(ScreenMedia.SMALL_AND_DOWN)); } /** @@ -442,24 +483,10 @@ public final class LayoutView extends AbstractBaseView<LayoutPresenter> implemen .css(Styles.pull_right) // .add(a() // .title("Dev") // - .add(Icons.ALL.settings_applications().clickable()))) // - .showOn(ScreenMedia.MEDIUM_AND_UP) // - .hideOn(ScreenMedia.SMALL_AND_DOWN) // - .setDropMenu(devDropMenu)) // - .appendChild(DominoElement.of(li() // - .css(Styles.pull_right) // - .add(a()// - .title(CSTS.agroclimApps()) // - .add(Icons.ALL.apps().clickable()))) // + .add(Icons.ALL.code_parentheses_box_mdi().clickable()))) // .showOn(ScreenMedia.MEDIUM_AND_UP) // .hideOn(ScreenMedia.SMALL_AND_DOWN) // - .setDropMenu(new AgroclimAppsMenu())) // - .appendChild(DominoElement.of(li() // - .css(Styles.pull_right).add(a() // - .add(Icons.ALL.dots_vertical_mdi().clickable()))) - .showOn(ScreenMedia.SMALL_AND_DOWN) // - .hideOn(ScreenMedia.MEDIUM_AND_UP) // - .setDropMenu(dotDropMenu)); + .setDropMenu(devDropMenu)); addMenuItem(devDropMenu, "Démo rapport", Icons.ALL.email_box_mdi(), "https://www.agrometinfo.fr/demo_rapport/"); @@ -471,6 +498,8 @@ public final class LayoutView extends AbstractBaseView<LayoutPresenter> implemen addMenuItem(devDropMenu, "Compile", Icons.ALL.code_parentheses_box_mdi(), compileUrl); addMenuItem(dotDropMenu, "Compile", Icons.ALL.code_parentheses_box_mdi(), compileUrl); } + addMenuItem(dotDropMenu, CSTS.documentation(), Icons.ALL.book_open_page_variant_mdi(), + "../" + CSTS.guidePath()); } /** diff --git a/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/AppConstants_fr.properties b/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/AppConstants_fr.properties index cabef82..cc4d5a9 100644 --- a/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/AppConstants_fr.properties +++ b/www-client/src/main/resources/fr/agrometinfo/www/client/i18n/AppConstants_fr.properties @@ -1,5 +1,4 @@ # Ce fichier est encodé en UTF-8. -about = À propos agroclimApps = Les applications d’AgroClim applicationLoading = Chargement de l’application… averageMonthlyValues = Valeurs moyennes mensuelles @@ -20,18 +19,25 @@ contactSeeFAQ2 = L’objet de votre demande s’y trouve peut-être déjà . Vous contactSeeFAQ = Avez-vous pris connaissance de notre FAQ ? contactSendMessage= Envoyer contactUs = Contactez-nous +credits = Crédits +creditsPath = credits.html dailyValues = Valeurs journalières downloadChart = Télécharger le graphique failureBody = Corps : failureHeaders = Entêtes HTTP : failureStatusText = Texte d’état HTTP : invalidEmailAddress = Adresse courriel invalide +legalNotice = Mentions légales +legalNoticePath = legal-notice.html +messageSent = Votre message a bien été envoyé à l’équipe d’AgroMetInfo. metropolitanFrance = France métropolitaine no= Non normalComparison= Comparaison à la normale normalComparisonTooltip= <b>La comparaison à la normale</b> se calcule en soustrayant <b>la moyenne de l’indicateur choisi</b> pour les trente dernières années (1990-2020) de <b>l’année sélectionnée</b>. otherAgroclimApps = Autres services et outils d’AgroClim requiredErrorMessage = * Ce champ est obligatoire. +releaseNotes = Notes de version +releaseNotesPath = release-notes.html seePrivacyPolicy = Consultez le paragraphe « Données personnelles » dans les mentions légales. toggleRightPanel = Afficher / masquer le panneau de droite yes= Oui -- GitLab From ece0bd16388f807a5f62fdb05985d7c56c26dbc7 Mon Sep 17 00:00:00 2001 From: Olivier Maury <Olivier.Maury@inrae.fr> Date: Fri, 8 Mar 2024 10:55:30 +0100 Subject: [PATCH 2/2] PMD --- .../java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java b/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java index c33e3d2..8a2be70 100644 --- a/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java +++ b/www-client/src/main/java/fr/agrometinfo/www/client/ui/AgroclimAppsMenu.java @@ -39,9 +39,9 @@ public class AgroclimAppsMenu extends Menu<String> { .attr("target", "_blank").textContent(CSTS.otherAgroclimApps()))); // patch to display on mobile super.addOpenHandler(() -> { - final String top = AgroclimAppsMenu.this.element().style.top; + final String top = element().style.top; if (top != null && top.startsWith("-")) { - AgroclimAppsMenu.this.element().style.top = "0px"; + element().style.top = "0px"; } }); } -- GitLab