diff --git a/application-admintools-default/src/main/java/com/xwiki/admintools/internal/AdminToolsManager.java b/application-admintools-default/src/main/java/com/xwiki/admintools/internal/AdminToolsManager.java index 6585ee16..adeb9276 100644 --- a/application-admintools-default/src/main/java/com/xwiki/admintools/internal/AdminToolsManager.java +++ b/application-admintools-default/src/main/java/com/xwiki/admintools/internal/AdminToolsManager.java @@ -32,6 +32,7 @@ import com.xpn.xwiki.web.XWikiRequest; import com.xwiki.admintools.DataProvider; import com.xwiki.admintools.internal.data.identifiers.CurrentServer; +import com.xwiki.admintools.internal.download.DownloadManager; /** * Manages the data providers. @@ -55,6 +56,9 @@ public class AdminToolsManager @Inject private CurrentServer currentServer; + @Inject + private DownloadManager downloadManager; + @Inject private Provider xcontextProvider; /** @@ -122,4 +126,14 @@ public String getContextPath() return xWikiRequest.getContextPath(); } + /** + * Get the rendered template for accessing the downloads UI. + * + * @return a {@link String} representation of the template. + */ + public String getDownloadTemplate() + { + return this.downloadManager.renderTemplate(); + } + } diff --git a/application-admintools-default/src/main/java/com/xwiki/admintools/internal/download/DownloadManager.java b/application-admintools-default/src/main/java/com/xwiki/admintools/internal/download/DownloadManager.java index f8ccc366..9b44b91d 100644 --- a/application-admintools-default/src/main/java/com/xwiki/admintools/internal/download/DownloadManager.java +++ b/application-admintools-default/src/main/java/com/xwiki/admintools/internal/download/DownloadManager.java @@ -30,12 +30,16 @@ import javax.inject.Inject; import javax.inject.Provider; import javax.inject.Singleton; +import javax.script.ScriptContext; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.xwiki.component.annotation.Component; +import org.xwiki.script.ScriptContextManager; +import org.xwiki.template.TemplateManager; import com.xwiki.admintools.download.DataResource; +import com.xwiki.admintools.internal.data.identifiers.CurrentServer; import com.xwiki.admintools.internal.download.resources.LogsDataResource; /** @@ -55,6 +59,15 @@ public class DownloadManager @Inject private Provider> dataResources; + @Inject + private TemplateManager templateManager; + + @Inject + private ScriptContextManager scriptContextManager; + + @Inject + private CurrentServer currentServer; + @Inject private Logger logger; @@ -110,6 +123,28 @@ public byte[] downloadMultipleFiles(Map request) } } + /** + * Get the data in a format given by the associated template. + * + * @return the rendered template as a {@link String}. + */ + public String renderTemplate() + { + try { + String found = "false"; + if (currentServer.getCurrentServer() != null) { + found = "true"; + } + ScriptContext scriptContext = this.scriptContextManager.getScriptContext(); + scriptContext.setAttribute("found", found, ScriptContext.ENGINE_SCOPE); + return this.templateManager.render("downloadTemplate.vm"); + } catch (Exception e) { + this.logger.warn("Failed to render custom template. Root cause is: [{}]", + ExceptionUtils.getRootCauseMessage(e)); + return null; + } + } + private DataResource findDataResource(String hint) { for (DataResource archiverDataResource : dataResources.get()) { diff --git a/application-admintools-default/src/main/java/com/xwiki/admintools/script/AdminToolsScriptService.java b/application-admintools-default/src/main/java/com/xwiki/admintools/script/AdminToolsScriptService.java index d324e8db..c9001cbb 100644 --- a/application-admintools-default/src/main/java/com/xwiki/admintools/script/AdminToolsScriptService.java +++ b/application-admintools-default/src/main/java/com/xwiki/admintools/script/AdminToolsScriptService.java @@ -95,4 +95,14 @@ public String getContextPath() { return this.adminToolsManager.getContextPath(); } + + /** + * Get the rendered template for accessing the downloads UI. + * + * @return a {@link String} representation of the template. + */ + public String getDownloadTemplate() + { + return this.adminToolsManager.getDownloadTemplate(); + } } diff --git a/application-admintools-default/src/main/resources/templates/configurationTemplate.vm b/application-admintools-default/src/main/resources/templates/configurationTemplate.vm index 331f36de..376d5231 100644 --- a/application-admintools-default/src/main/resources/templates/configurationTemplate.vm +++ b/application-admintools-default/src/main/resources/templates/configurationTemplate.vm @@ -18,6 +18,8 @@ ## 02110-1301 USA, or see the FSF site: http://www.fsf.org. ## --------------------------------------------------------------------------- + + {{html clean='false'}} #if ($configuration['serverFound'] == 'true') @@ -33,8 +35,8 @@
  • @@ -80,4 +82,33 @@ #warning($warningMessage) #end + {{/html}} \ No newline at end of file diff --git a/application-admintools-default/src/main/resources/templates/downloadTemplate.vm b/application-admintools-default/src/main/resources/templates/downloadTemplate.vm index e2154b9c..2b45f680 100644 --- a/application-admintools-default/src/main/resources/templates/downloadTemplate.vm +++ b/application-admintools-default/src/main/resources/templates/downloadTemplate.vm @@ -17,3 +17,123 @@ ## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ## 02110-1301 USA, or see the FSF site: http://www.fsf.org. ## --------------------------------------------------------------------------- + + + +{{html clean='false'}} + +#if ($found == 'true') +
    +

    $services.icon.renderHTML('download') + $escapetool.xml($services.localization.render('adminTools.dashboard.section.download.title'))

    +

    $escapetool.xml($services.localization.render('adminTools.dashboard.section.download.description'))

    +
    + + + #warning($escapetool.xml($services.localization.render('adminTools.dashboard.section.download.warning'))) + +
    + +#else + #set($warningMessage = + $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.configuration.error'))+ '
    ') + #set($warningMessage = $warningMessage + + $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.supportedServers.error')) + + $stringtool.join($services.admintools.getSupportedServers(), ', ')) + + #warning($warningMessage) +#end + + + + +{{/html}} \ No newline at end of file diff --git a/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml b/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml index 7d5dc9c0..8ccfbcdd 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml @@ -39,6 +39,22 @@ AdminTools.Code.ConfigurationClass_serverLocation=Server location AdminTools.Code.ConfigurationClass_serverLocation.hint=Path to the server location admin.admintools.description=Configure Admin Tools Application + adminTools.dashboard.modal.button.close=Close + adminTools.dashboard.modal.logs.title=Show the latest logs + adminTools.dashboard.modal.logs.selection=Insert the number of lines to show: + adminTools.dashboard.modal.logs.button=View logs + adminTools.dashboard.modal.download.title=Select Files to Download + adminTools.dashboard.modal.download.provided=Configuration info + adminTools.dashboard.modal.download.date.from=From: + adminTools.dashboard.modal.download.date.to=To: + adminTools.dashboard.modal.download.button=Download selected files + adminTools.dashboard.section.download.description=Get the files you need. View them directly in browser or download them as an archive. + adminTools.dashboard.section.download.title=Important files + adminTools.dashboard.section.download.modal.open=Export files needed for getting support + adminTools.dashboard.section.download.view.description=View files content: + adminTools.dashboard.section.download.view.configuration=XWiki configuration file + adminTools.dashboard.section.download.view.properties=XWiki properties file + adminTools.dashboard.section.download.warning=Before downloading and sending the files, please make sure you introduced the lines that may contain sensitive info in Admin Tools configuration page! adminTools.dashboard.section.backend.configuration.error=Server path was not found. Please manually add the path to the server on the Admin Tools configuration page. adminTools.dashboard.section.backend.description=Get info about your backend adminTools.dashboard.section.backend.java=Detected java version: @@ -46,7 +62,7 @@ adminTools.dashboard.section.backend.os.legend=OS info: adminTools.dashboard.section.backend.os.architecture=OS architecture: adminTools.dashboard.section.backend.os.name=OS name: adminTools.dashboard.section.backend.os.version=OS version: -adminTools.dashboard.section.backend.showLogs=Show latest logs +adminTools.dashboard.showLogs=Show the latest logs adminTools.dashboard.section.backend.supportedDB.error=Database not found. Currently supported databases: adminTools.dashboard.section.backend.supportedServers.error=Currently supported servers: adminTools.dashboard.section.backend.title=Backend diff --git a/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml b/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml index a3e6c5e7..3ffb8e0f 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml @@ -161,6 +161,71 @@ $services.admintools.getConfigurationData('configuration') + + AdminTools.WebHome + 2 + XWiki.GadgetClass + ec745b5d-c64a-4597-a519-57fbd98b7115 + + XWiki.GadgetClass + + + + + + + + + 0 + --- + content + 2 + 0 + content + 5 + 40 + 0 + + + com.xpn.xwiki.objects.classes.TextAreaClass + + + 0 + position + 3 + 0 + position + 30 + 0 + + + com.xpn.xwiki.objects.classes.StringClass + + + <disabled>0</disabled> + <name>title</name> + <number>1</number> + <picker>0</picker> + <prettyName>title</prettyName> + <size>30</size> + <unmodifiable>0</unmodifiable> + <validationMessage/> + <validationRegExp/> + <classType>com.xpn.xwiki.objects.classes.StringClass</classType> + + + + {{velocity}} + $services.admintools.getDownloadTemplate() + {{/velocity}} + + + 2, 1 + + + + + AdminTools.WebHome 0 @@ -272,6 +337,8 @@ $services.admintools.getConfigurationData('configuration') .adminToolsDashboardItem{ background-color: $theme.pageBackgroundColor; border-color: $theme.pageContentBackgroundColor; + min-height: 330px; + padding: 6px 11px 0px 11px; }