Change message of new LibrePlan version.

i18n.
(cherry picked from commit 88cb119)
This commit is contained in:
Vova Perebykivskiy 2016-02-17 13:41:34 +02:00 committed by Tester
parent b071eca84d
commit a2a936b313
4 changed files with 180 additions and 167 deletions

View file

@ -67,10 +67,10 @@ public class VersionInformation {
private VersionInformation() { private VersionInformation() {
} }
private void loadNewVersionFromURL(boolean allowToGatherUsageStatsEnabled) { private void loadNewVersionFromURL() {
lastVersionCachedDate = new Date(); lastVersionCachedDate = new Date();
try { try {
URL url = getURL(allowToGatherUsageStatsEnabled); URL url = getURL();
String lastVersion = (new BufferedReader(new InputStreamReader( String lastVersion = (new BufferedReader(new InputStreamReader(
url.openStream()))).readLine(); url.openStream()))).readLine();
if (projectVersion != null && lastVersion != null) { if (projectVersion != null && lastVersion != null) {
@ -86,13 +86,8 @@ public class VersionInformation {
} }
} }
private URL getURL(boolean allowToGatherUsageStatsEnabled) private URL getURL() throws MalformedURLException {
throws MalformedURLException {
String url = LIBREPLAN_VERSION_URL; String url = LIBREPLAN_VERSION_URL;
if (allowToGatherUsageStatsEnabled) {
url += "?" + LIBREPLAN_USAGE_STATS_PARAM + "=1";
url += "&" + LIBREPLAN_VERSION_PARAM + "=" + projectVersion;
}
return new URL(url); return new URL(url);
} }
@ -113,18 +108,14 @@ public class VersionInformation {
public void setProjectVersion(String argVersion) { public void setProjectVersion(String argVersion) {
projectVersion = argVersion; projectVersion = argVersion;
loadNewVersionFromURL(false); loadNewVersionFromURL();
} }
/** /**
* Returns true if a new version of the project is published. * Returns true if a new version of the project is published.
*
* @param isCheckNewVersionEnabled
* If true LibrePlan developers will process the requests to check
* the new versions to generate usages statistics
*/ */
public static boolean isNewVersionAvailable(boolean isCheckNewVersionEnabled) { public static boolean isNewVersionAvailable() {
return singleton.checkIsNewVersionAvailable(isCheckNewVersionEnabled); return singleton.checkIsNewVersionAvailable();
} }
/** /**
@ -132,15 +123,28 @@ public class VersionInformation {
* Otherwise, during one day it returns the cached value. And it checks it * Otherwise, during one day it returns the cached value. And it checks it
* again after that time. * again after that time.
*/ */
private boolean checkIsNewVersionAvailable(boolean isCheckNewVersionEnabled) { private boolean checkIsNewVersionAvailable() {
if ( !newVersionCached ) { if ( !newVersionCached ) {
long oneDayLater = lastVersionCachedDate.getTime() long oneDayLater = lastVersionCachedDate.getTime()
+ DELAY_TO_CHECK_URL; + DELAY_TO_CHECK_URL;
if ( oneDayLater < new Date().getTime() ) { if ( oneDayLater < new Date().getTime() ) {
loadNewVersionFromURL(isCheckNewVersionEnabled); loadNewVersionFromURL();
} }
} }
return newVersionCached; return newVersionCached;
} }
public static String getLastVersion() {
String lastVersion = "";
try {
URL url = new URL(LIBREPLAN_VERSION_URL);
lastVersion = (new BufferedReader(new InputStreamReader(
url.openStream()))).readLine();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return lastVersion;
}
} }

View file

@ -49,6 +49,7 @@ import org.zkoss.zul.Window;
* Controller to manage UI operations from main template. * Controller to manage UI operations from main template.
* *
* @author Manuel Rego Casasnovas <mrego@igalia.com> * @author Manuel Rego Casasnovas <mrego@igalia.com>
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
*/ */
@org.springframework.stereotype.Component @org.springframework.stereotype.Component
@Scope(BeanDefinition.SCOPE_PROTOTYPE) @Scope(BeanDefinition.SCOPE_PROTOTYPE)
@ -66,13 +67,14 @@ public class TemplateController extends GenericForwardComposer {
private IMessagesForUser windowMessages; private IMessagesForUser windowMessages;
private String lastVersionNumber = "";
@Override @Override
public void doAfterCompose(Component comp) throws Exception { public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp); super.doAfterCompose(comp);
if (templateModel.isScenariosVisible()) { if ( templateModel.isScenariosVisible() ) {
window = (Window) comp.getFellow("changeScenarioWindow"); window = (Window) comp.getFellow("changeScenarioWindow");
windowMessages = new MessagesForUser(window windowMessages = new MessagesForUser(window.getFellow("messagesContainer"));
.getFellow("messagesContainer"));
} }
} }
@ -219,11 +221,14 @@ public class TemplateController extends GenericForwardComposer {
} }
public boolean isNewVersionAvailable() { public boolean isNewVersionAvailable() {
if ( !templateModel.isCheckNewVersionEnabled() ) { if ( templateModel.isCheckNewVersionEnabled() ) {
return false; if ( VersionInformation.isNewVersionAvailable() ){
lastVersionNumber = VersionInformation.getLastVersion();
return true;
}
} }
return VersionInformation.isNewVersionAvailable(templateModel.isCheckNewVersionEnabled()); return false;
} }
public String getUsername() { public String getUsername() {
@ -234,4 +239,9 @@ public class TemplateController extends GenericForwardComposer {
return user.getUsername(); return user.getUsername();
} }
public String getVersionMessage(){
return _("A new version ") + lastVersionNumber +
_(" of LibrePlan is available. Please check next link for more information:");
}
} }

View file

@ -5596,10 +5596,12 @@ msgstr ""
msgid "Original" msgid "Original"
msgstr "" msgstr ""
#: libreplan-webapp/src/main/webapp/common/layout/template.zul:179 #: libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java:245
msgid "" msgid "A new version "
"A new version of LibrePlan is available. Please check next link for more " msgstr ""
"information:"
#: libreplan-webapp/src/main/java/org/libreplan/web/common/TemplateController.java:246
msgid " of LibrePlan is available. Please check next link for more information:"
msgstr "" msgstr ""
#: libreplan-webapp/src/main/webapp/planner/stretches_function.zul:31 #: libreplan-webapp/src/main/webapp/planner/stretches_function.zul:31
@ -9311,4 +9313,4 @@ msgstr ""
#: libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java:247 #: libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationController.java:247
msgid "Check fields" msgid "Check fields"
msgstr "" msgstr ""

View file

@ -25,14 +25,14 @@
<?link rel="stylesheet" type="text/css" href="/common/css/perspectives.css"?> <?link rel="stylesheet" type="text/css" href="/common/css/perspectives.css"?>
<?component name="customMenu" inline="true" macroURI="_customMenu.zul"?> <?component name="customMenu" inline="true" macroURI="_customMenu.zul"?>
<?xel-method prefix="project" name="passwd_control" class="org.libreplan.business.common.Configuration" <?xel-method prefix="project" name="passwd_control" class="org.libreplan.business.common.Configuration"
signature="java.lang.Boolean isDefaultPasswordsControl()"?> signature="java.lang.Boolean isDefaultPasswordsControl()"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?> <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?component name="button" extends="button" mold="trendy"?> <?component name="button" extends="button" mold="trendy"?>
<zk> <zk>
<zscript> <zscript>
<![CDATA[ <![CDATA[
contextPath = Executions.getCurrent().getContextPath(); contextPath = Executions.getCurrent().getContextPath();
templateCtrl = templateController; templateCtrl = templateController;
idAdminUser = templateController.getIdAdminUser(); idAdminUser = templateController.getIdAdminUser();
@ -44,152 +44,149 @@ signature="java.lang.Boolean isDefaultPasswordsControl()"?>
idOutsourcing = templateController.getIdOutsourcingUser(); idOutsourcing = templateController.getIdOutsourcingUser();
idReports = templateController.getIdReportsUser(); idReports = templateController.getIdReportsUser();
]]> ]]>
</zscript> </zscript>
<div xmlns:n="http://www.zkoss.org/2005/zk/native" apply="${templateCtrl}" height="100%"> <div xmlns:n="http://www.zkoss.org/2005/zk/native" apply="${templateCtrl}" height="100%">
<timer repeats="true" running="true" delay="20000" onTimer=""/>
<borderlayout height="100%" width="100%">
<north border="none">
<n:div>
<timer repeats="true" running="true" delay="20000" onTimer=""/> <n:table width="100%" border="0" cellpadding="0" cellspacing="0">
<borderlayout height="100%" width="100%" > <n:tr>
<north border="none"> <n:td valign="center" class="logo-area">
<n:div> <n:a href="${contextPath}/">
<n:img src="${templateCtrl.companyLogoURL}" if="${templateCtrl.companyLogoURL!=''}" />
<n:img src="${contextPath}/common/img/logo.png" if="${templateCtrl.companyLogoURL==''}" />
</n:a></n:td>
<n:td valign="top">
<n:table width="100%" border="0" cellspacing="0" cellpadding="0">
<n:tr>
<n:td>
<n:table width="100%" border="0" cellpadding="0" cellspacing="0"> <customMenu top_id="customMenu" title="${i18n:_('Main menu')}"/>
<n:tr>
<n:td valign="center" class="logo-area">
<n:a href="${contextPath}/">
<n:img src="${templateCtrl.companyLogoURL}" if="${templateCtrl.companyLogoURL!=''}" />
<n:img src="${contextPath}/common/img/logo.png" if="${templateCtrl.companyLogoURL==''}" />
</n:a></n:td>
<n:td valign="top">
<n:table width="100%" border="0" cellspacing="0" cellpadding="0">
<n:tr>
<n:td>
<customMenu top_id="customMenu" title="${i18n:_('Main menu')}"/> </n:td>
</n:tr>
</n:table></n:td>
</n:tr>
</n:table>
</n:td> <n:div class="user-area">
</n:tr> <n:table width="100%" border="0" cellspacing="0" cellpadding="0">
</n:table></n:td> <n:tr>
</n:tr> <n:td class="usuario">
</n:table> <div if="${templateCtrl.scenariosVisible}">
${i18n:_('scenario')}:
<button onClick="templateCtrl.changeScenario();"
label="${templateCtrl.scenario.name}" />
<window id="changeScenarioWindow" visible="false"
title="${i18n:_('Change scenario')}"
style="width : 240px;">
<div id="messagesContainer" />
<grid>
<rows>
<row>
<label value="${i18n:_('Select scenario')}" />
<bandboxSearch
id="scenarioBandboxSearch"
finder="ScenarioBandboxFinder"
model="@{templateCtrl.scenarios}"
selectedElement="@{templateCtrl.scenario}" />
</row>
</rows>
</grid>
<button onClick="templateCtrl.accept();"
label="${i18n:_('Accept')}" />
<button onClick="templateCtrl.cancel();"
label="${i18n:_('Cancel')}" />
</window>
</div>
</n:td>
<n:td class="usuario">${i18n:_('user')}: ${templateCtrl.username}</n:td>
<n:td><n:a href="${contextPath}/j_spring_security_logout" class="cerrar_sesion">[${i18n:_('Log out')}]</n:a></n:td>
</n:tr>
</n:table>
</n:div>
</n:div>
</north>
<n:div class="user-area"> <center border="none">
<n:table width="100%" border="0" cellspacing="0" cellpadding="0"> <borderlayout width="auto" height="100%">
<n:tr> <!-- borderlayout class="main-layout" height="2000px" width="2000px"-->
<n:td class="usuario"> <west class="perspectives-column" width="90px" >
<div if="${templateCtrl.scenariosVisible}"> <vbox vflex="1" height="100%">
${i18n:_('scenario')}: <hbox id="perspectiveButtonsInsertionPoint" sclass="toolbar-box global-commands" height="30px" width="100%">
<button onClick="templateCtrl.changeScenario();" <button id="createOrderButton" image="/common/img/ico_add.png" sclass="planner-icon"
label="${templateCtrl.scenario.name}" /> tooltiptext="${i18n:_('Create New Project')}" />
<window id="changeScenarioWindow" visible="false" </hbox>
title="${i18n:_('Change scenario')}" <vbox id="registeredItemsInsertionPoint" width="90px" style="overflow-y:auto;overflow-x:hidden;display:block" vflex="1" />
style="width : 240px;"> </vbox>
<div id="messagesContainer" /> </west>
<grid> <center self="@{insert(content)}" class="main-area" autoscroll="true" />
<rows>
<row>
<label value="${i18n:_('Select scenario')}" />
<bandboxSearch
id="scenarioBandboxSearch"
finder="ScenarioBandboxFinder"
model="@{templateCtrl.scenarios}"
selectedElement="@{templateCtrl.scenario}" />
</row>
</rows>
</grid>
<button onClick="templateCtrl.accept();"
label="${i18n:_('Accept')}" />
<button onClick="templateCtrl.cancel();"
label="${i18n:_('Cancel')}" />
</window>
</div>
</n:td>
<n:td class="usuario">${i18n:_('user')}: ${templateCtrl.username}</n:td>
<n:td><n:a href="${contextPath}/j_spring_security_logout" class="cerrar_sesion">[${i18n:_('Log out')}]</n:a></n:td>
</n:tr>
</n:table>
</n:div>
</n:div>
</north>
<center border="none"> </borderlayout>
<borderlayout width="auto" height="100%">
<!-- borderlayout class="main-layout" height="2000px" width="2000px"--> </center>
<west class="perspectives-column" width="90px" > <south border="none" if="${templateCtrl.userAdmin}">
<vbox vflex="1" height="100%"> <n:table width="100%">
<hbox id="perspectiveButtonsInsertionPoint" sclass="toolbar-box global-commands" height="30px" width="100%"> <n:tr class="footer">
<button id="createOrderButton" image="/common/img/ico_add.png" sclass="planner-icon" <n:td valign="center">
tooltiptext="${i18n:_('Create New Project')}" /> <n:div if="${project:passwd_control()}" id="warningDefaultPasswdadmin"
</hbox> class="footer-messages-area"
<vbox id="registeredItemsInsertionPoint" width="90px" style="overflow-y:auto;overflow-x:hidden;display:block" vflex="1" /> style="display:${templateCtrl.defaultPasswdAdminVisible}">
</vbox> <div>
</west> <n:span>${i18n:_("The admin's account password remains the default one. This is insecure")}.</n:span>
<center self="@{insert(content)}" class="main-area" autoscroll="true" /> <n:a class="command" href="${contextPath}/users/users.zul#edit%3D${idAdminUser}">[${i18n:_('Change the password')}]</n:a>
</div>
</n:div>
<n:div if="${project:passwd_control()}" id="warningDefaultPasswdOthers"
class="footer-messages-area"
style="display:${templateCtrl.defaultPasswdVisible}">
<div>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWsreader}"
id="warningDefaultPasswdWsreader"
style="display:${templateCtrl.defaultPasswdWsreaderVisible}">[wsreader]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWswriter}"
id="warningDefaultPasswdWswriter"
style="display:${templateCtrl.defaultPasswdWswriterVisible}">[wswriter]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWssubcontracting}"
id="warningDefaultPasswdWssubcontracting"
style="display:${templateCtrl.defaultPasswdWssubcontractingVisible}">[wssubcontracting]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idManager}"
id="warningDefaultPasswdManager"
style="display:${templateCtrl.defaultPasswdManagerVisible}">[manager]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idHresources}"
id="warningDefaultPasswdHresources"
style="display:${templateCtrl.defaultPasswdHresourcesVisible}">[hresources]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idOutsourcing}"
id="warningDefaultPasswdOutsourcing"
style="display:${templateCtrl.defaultPasswdOutsourcingVisible}">[outsourcing]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idReports}"
id="warningDefaultPasswdReports"
style="display:${templateCtrl.defaultPasswdReportsVisible}">[reports]</n:a>
<n:span class="footer-messages-area">
${i18n:_('default password was not changed')}.
</n:span>
</div>
</n:div>
<n:div if="${templateCtrl.newVersionAvailable}" id="warningNewVersion"
class="footer-messages-area">
<div>
<n:span>
${templateCtrl.versionMessage}
<n:strong><n:a href="http://www.libreplan.com/download/" target="_blank">http://www.libreplan.com/download/</n:a></n:strong>
</n:span>
</div>
</n:div>
</n:td>
<n:td height="40" align="right" valign="bottom">
</n:td>
</n:tr>
</n:table>
</south>
</borderlayout> </borderlayout>
</center>
<south border="none" if="${templateCtrl.userAdmin}">
<n:table width="100%">
<n:tr class="footer">
<n:td valign="center">
<n:div if="${project:passwd_control()}" id="warningDefaultPasswdadmin"
class="footer-messages-area"
style="display:${templateCtrl.defaultPasswdAdminVisible}">
<div>
<n:span>${i18n:_("The admin's account password remains the default one. This is insecure")}.</n:span>
<n:a class="command" href="${contextPath}/users/users.zul#edit%3D${idAdminUser}">[${i18n:_('Change the password')}]</n:a>
</div>
</n:div>
<n:div if="${project:passwd_control()}" id="warningDefaultPasswdOthers"
class="footer-messages-area"
style="display:${templateCtrl.defaultPasswdVisible}">
<div>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWsreader}"
id="warningDefaultPasswdWsreader"
style="display:${templateCtrl.defaultPasswdWsreaderVisible}">[wsreader]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWswriter}"
id="warningDefaultPasswdWswriter"
style="display:${templateCtrl.defaultPasswdWswriterVisible}">[wswriter]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idWssubcontracting}"
id="warningDefaultPasswdWssubcontracting"
style="display:${templateCtrl.defaultPasswdWssubcontractingVisible}">[wssubcontracting]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idManager}"
id="warningDefaultPasswdManager"
style="display:${templateCtrl.defaultPasswdManagerVisible}">[manager]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idHresources}"
id="warningDefaultPasswdHresources"
style="display:${templateCtrl.defaultPasswdHresourcesVisible}">[hresources]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idOutsourcing}"
id="warningDefaultPasswdOutsourcing"
style="display:${templateCtrl.defaultPasswdOutsourcingVisible}">[outsourcing]</n:a>
<n:a href="${contextPath}/users/users.zul#edit%3D${idReports}"
id="warningDefaultPasswdReports"
style="display:${templateCtrl.defaultPasswdReportsVisible}">[reports]</n:a>
<n:span class="footer-messages-area">
${i18n:_('default password was not changed')}.
</n:span>
</div>
</n:div>
<n:div if="${templateCtrl.newVersionAvailable}" id="warningNewVersion"
class="footer-messages-area">
<div>
<n:span>
${i18n:_("A new version of LibrePlan is available. Please check next link for more information:")}
<n:strong><n:a href="http://www.libreplan.com/download/" target="_blank">http://www.libreplan.com/download/</n:a></n:strong>
</n:span>
</div>
</n:div>
</n:td>
<n:td height="40" align="right" valign="bottom">
</n:td>
</n:tr>
</n:table>
</south>
</borderlayout>
</div> </div>
</zk> </zk>