From 07628bf5046ecf9983a6a5ba850f0404a820ae9d Mon Sep 17 00:00:00 2001 From: Sorin Date: Thu, 12 Oct 2023 14:41:28 +0300 Subject: [PATCH] Add support for downloading important files #8 * Created a JS listener for button events * UI optimizations * Moved the modals from AdminTools.WebHome to Macro.vm * Created macros for the modals * Modified translations --- .../admintools/rest/AdminToolsResource.java | 11 +- application-admintools-default/pom.xml | 2 +- .../rest/DefaultAdminToolsResource.java | 6 +- .../templates/configurationTemplate.vm | 24 +- .../templates/filesSectionTemplate.vm | 6 +- .../resources/templates/securityTemplate.vm | 2 - .../rest/DefaultAdminToolsResourceTest.java | 8 +- .../main/resources/AdminTools/Code/Macros.xml | 134 +++++++++ .../AdminTools/Code/Translations.xml | 38 +-- .../src/main/resources/AdminTools/WebHome.xml | 255 ++++++++++++------ 10 files changed, 350 insertions(+), 136 deletions(-) create mode 100644 application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml diff --git a/application-admintools-api/src/main/java/com/xwiki/admintools/rest/AdminToolsResource.java b/application-admintools-api/src/main/java/com/xwiki/admintools/rest/AdminToolsResource.java index b4bc5d97..a70616b4 100644 --- a/application-admintools-api/src/main/java/com/xwiki/admintools/rest/AdminToolsResource.java +++ b/application-admintools-api/src/main/java/com/xwiki/admintools/rest/AdminToolsResource.java @@ -19,8 +19,8 @@ */ package com.xwiki.admintools.rest; +import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @@ -54,17 +54,18 @@ public interface AdminToolsResource extends XWikiRestComponent * @return an archive with files. * @throws XWikiRestException if an error occurred while getting the archive. */ - @POST + @GET @Path("/files") Response getFiles() throws XWikiRestException; /** * Get last n lines of server logs. * + * @param noLines number of lines to be retrieved from the log file. * @return a file containing the last n lines of server logs. * @throws XWikiRestException if an error occurred while retrieving the logs file . */ - @POST - @Path("/files/logs") - Response getLastLogs() throws XWikiRestException; + @GET + @Path("/files/logs/{noLines}") + Response getLastLogs(@PathParam("noLines") @DefaultValue("1000") String noLines) throws XWikiRestException; } diff --git a/application-admintools-default/pom.xml b/application-admintools-default/pom.xml index 87145d42..2c0d7374 100644 --- a/application-admintools-default/pom.xml +++ b/application-admintools-default/pom.xml @@ -63,6 +63,6 @@ - 0.66 + 0.81 \ No newline at end of file diff --git a/application-admintools-default/src/main/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResource.java b/application-admintools-default/src/main/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResource.java index 8e482856..25cf7e41 100644 --- a/application-admintools-default/src/main/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResource.java +++ b/application-admintools-default/src/main/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResource.java @@ -114,16 +114,14 @@ public Response getFiles() } @Override - public Response getLastLogs() + public Response getLastLogs(String input) { if (!isAdmin()) { logger.warn("Failed to get the logs due to restricted rights."); throw new WebApplicationException(Response.Status.UNAUTHORIZED); } try { - XWikiContext wikiContext = xcontextProvider.get(); - XWikiRequest xWikiRequest = wikiContext.getRequest(); - String noLines = xWikiRequest.getParameter("noLines"); + String noLines = input; if (noLines == null || noLines.equals("")) { noLines = "1000"; } diff --git a/application-admintools-default/src/main/resources/templates/configurationTemplate.vm b/application-admintools-default/src/main/resources/templates/configurationTemplate.vm index d0895cfc..1ed56a35 100644 --- a/application-admintools-default/src/main/resources/templates/configurationTemplate.vm +++ b/application-admintools-default/src/main/resources/templates/configurationTemplate.vm @@ -17,8 +17,8 @@ ## Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ## 02110-1301 USA, or see the FSF site: http://www.fsf.org. ## --------------------------------------------------------------------------- +#viewLastNLinesMoldal("configuration") {{html clean='false'}} - #if ($configuration['serverFound'] == 'true')

$services.icon.renderHTML('world') @@ -27,39 +27,39 @@
  • - $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.xwiki.version')) + $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.xwiki.version')): $configuration['xwikiVersion']
  • - $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.java')) + $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.java')): $configuration['javaVersion']
  • - $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.usedServer')) + $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.usedServer')): $configuration['usedServer']
  • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.legend'))
      -
    • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.name')) +
    • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.name')): $configuration['osName']
    • -
    • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.version')) +
    • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.version')): $configuration['osVersion']
    • -
    • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.architecture')) +
    • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.os.architecture')): $configuration['osArch']
  • #if ($configuration['database'] != $null) -
  • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.usedDB')) +
  • $escapetool.xml($services.localization.render('adminTools.dashboard.section.backend.usedDB')): $configuration['database']
  • #else #set($warningDatabaseMessage = $escapetool.xml( - $services.localization.render('adminTools.dashboard.section.backend.supportedDB.error'))) + $services.localization.render('adminTools.dashboard.section.backend.supportedDB.error')) + ':') #set($warningDatabaseMessage = $warningDatabaseMessage + $stringtool.join($services.admintools.getSupportedDatabases(), ', '))
  • $escapetool.xml( @@ -68,15 +68,13 @@ #end

- #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')) + $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-default/src/main/resources/templates/filesSectionTemplate.vm b/application-admintools-default/src/main/resources/templates/filesSectionTemplate.vm index 669f8347..af5ea634 100644 --- a/application-admintools-default/src/main/resources/templates/filesSectionTemplate.vm +++ b/application-admintools-default/src/main/resources/templates/filesSectionTemplate.vm @@ -18,6 +18,8 @@ ## 02110-1301 USA, or see the FSF site: http://www.fsf.org. ## --------------------------------------------------------------------------- #set($adminToolsFilesPath = "$request.getContextPath()/rest/admintools/files") +#viewLastNLinesMoldal("files") +#downloadFiles("files") {{html clean='false'}} #if ($found == 'true')
@@ -27,7 +29,7 @@
diff --git a/application-admintools-default/src/main/resources/templates/securityTemplate.vm b/application-admintools-default/src/main/resources/templates/securityTemplate.vm index 8e073d09..18cc16bf 100644 --- a/application-admintools-default/src/main/resources/templates/securityTemplate.vm +++ b/application-admintools-default/src/main/resources/templates/securityTemplate.vm @@ -17,9 +17,7 @@ ## 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($security['serverFound'] == 'true')

$services.icon.renderHTML('lock') diff --git a/application-admintools-default/src/test/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResourceTest.java b/application-admintools-default/src/test/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResourceTest.java index 055445e3..aec14923 100644 --- a/application-admintools-default/src/test/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResourceTest.java +++ b/application-admintools-default/src/test/java/com/xwiki/admintools/internal/rest/DefaultAdminToolsResourceTest.java @@ -197,7 +197,7 @@ void getLastLogs() throws Exception { when(downloadManager.getFile(LogsDataResource.HINT, "30")).thenReturn(new byte[] { 2 }); when(xWikiRequest.getParameter("noLines")).thenReturn("30"); - assertEquals(200, defaultAdminToolsResource.getLastLogs().getStatus()); + assertEquals(200, defaultAdminToolsResource.getLastLogs("30").getStatus()); } @Test @@ -208,7 +208,7 @@ void getLastDownloadManagerError() throws Exception when(downloadManager.getFile(LogsDataResource.HINT, "1000")).thenThrow(new IOException("FILE NOT FOUND")); - assertEquals(404, defaultAdminToolsResource.getLastLogs().getStatus()); + assertEquals(404, defaultAdminToolsResource.getLastLogs("").getStatus()); verify(logger).warn("Could not retrieve logs from server. Root cause: [{}]", "IOException: FILE NOT FOUND"); } @@ -220,7 +220,7 @@ void getLastLogsDownloadManagerError() throws Exception when(downloadManager.getFile(LogsDataResource.HINT, "1000")).thenThrow(new Exception("INTERNAL ERROR")); Exception exception = assertThrows(Exception.class, () -> { - this.defaultAdminToolsResource.getLastLogs(); + this.defaultAdminToolsResource.getLastLogs(null); }); assertEquals("HTTP 500 Internal Server Error", exception.getMessage()); verify(logger).warn("Failed to get logs. Root cause: [{}]", "Exception: INTERNAL ERROR"); @@ -234,7 +234,7 @@ void getLastLogsNotAdmin() when(authorizationManager.hasAccess(Right.ADMIN, user, wikiReference)).thenReturn(false); Exception exception = assertThrows(Exception.class, () -> { - this.defaultAdminToolsResource.getLastLogs(); + this.defaultAdminToolsResource.getLastLogs("1000"); }); assertEquals("HTTP 401 Unauthorized", exception.getMessage()); verify(logger).warn("Failed to get the logs due to restricted rights."); diff --git a/application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml b/application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml new file mode 100644 index 00000000..9bb40d66 --- /dev/null +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml @@ -0,0 +1,134 @@ + + + + + AdminTools.Code + Macros + + + 0 + xwiki:XWiki.Admin + AdminTools.WebHome + xwiki:XWiki.Admin + xwiki:XWiki.Admin + 1.1 + Macros + + false + xwiki/2.1 + true + {{velocity output="false"}} +#macro (viewLastNLinesMoldal $id) + #set ($modalId = $id + "ViewLastNLinesModal") + #set ($formId = $id + "LastNLogLinesForm") + #set ($inputId = $id + "NoLines") + {{html clean='false'}} + <div class="modal fade" id="$modalId" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> + <div class="modal-dialog modal-sm" role="document"> + <div class="modal-content"> + <div class="logs-modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">&times;</span></button> + <h1 class="modal-title" id="viewLastNLinesModalLabel"> + $escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.title')) + </h1> + </div> + <div class="modal-body"> + <form class="xform" id="$formId" action="$request.getContextPath()/rest/admintools/files/logs"> + <dl> + <dt> + <label for="noLines">$escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.nLines.label')) </label> + <span class="xHint">max 50000</span> + </dt> + <dd><input type="number" id="$inputId" name="noLines" placeholder="1000"></dd> + </dl> + </form> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary"> + $escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.submit'))</button> + <button type="button" class="btn btn-default" data-dismiss="modal"> + $escapetool.xml($services.localization.render('cancel'))</button> + </div> + </div> + </div> + </div> + </div> + {{/html}} +#end + +#macro (downloadFiles $id) + #set ($modalId = $id + "DownloadFilesModal") + #set ($formId = $id + "DownloadForm") + + {{html clean='false'}} + <div class="modal fade" id="$modalId" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">&times;</span></button> + <h1 class="modal-title downloadFilesModalTitle"> + $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.title')) + </h1> + </div> + <div class="modal-body"> + <form id="$formId" action="$request.getContextPath()/rest/admintools/files"> + <div class="download-modal-content"> + <dl> + <dt><label><input type="checkbox" name="files" value="xwikiConfig" checked> + $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.xwikiConfig.title')) + </label> + </dt> + <dt><label><input type="checkbox" name="files" value="xwikiProperties" checked> + $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.xwikiProperties.title')) + </label> + </dt> + <dt><label><input type="checkbox" name="files" value="dataProviderResource" checked> + $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.provided'))</label> + </dt> + <dt><label><input type="checkbox" name="files" value="logsDataResource" checked> Logs</label></dt> + <dt> + <div class="dateFields"> + <label for="from">$escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.date.from')) + </label> <input type="date" id="from" name="from"> + <label for="to">$escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.date.to')) + </label> <input type="date" id="to" name="to"> + </div> + </dt> + </dl> + </div> + </form> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary"> + $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.button'))</button> + <button type="button" class="btn btn-default" data-dismiss="modal"> + $escapetool.xml($services.localization.render('cancel'))</button> + </div> + </div> + </div> + </div> + {{/html}} +#end +{{/velocity}} + \ 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 714c71af..45c04f2c 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml @@ -51,44 +51,44 @@ adminTools.dashboard.download.modal.title=Select Files adminTools.dashboard.download.modal.xwikiConfig.title=xwiki.cfg adminTools.dashboard.download.modal.xwikiProperties.title=xwiki.properties adminTools.dashboard.download.modal.logs.title=logs -adminTools.dashboard.logs.modal.submit=View logs +adminTools.dashboard.logs.modal.submit=View adminTools.dashboard.logs.modal.nLines.label=Number of extracted lines -adminTools.dashboard.logs.modal.title=Show latest n lines of log -adminTools.dashboard.showLogs=View +adminTools.dashboard.logs.modal.title=Show last n lines of log +adminTools.dashboard.showLogs=View last n lines of log... ## Dashboard sections ## Config 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: -adminTools.dashboard.section.backend.os.architecture=OS architecture: -adminTools.dashboard.section.backend.os.legend=OS info: -adminTools.dashboard.section.backend.os.name=OS name: -adminTools.dashboard.section.backend.os.version=OS version: -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.java=Detected java version +adminTools.dashboard.section.backend.os.architecture=OS architecture +adminTools.dashboard.section.backend.os.legend=OS info +adminTools.dashboard.section.backend.os.name=OS name +adminTools.dashboard.section.backend.os.version=OS version +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 -adminTools.dashboard.section.backend.usedDB=Used database: -adminTools.dashboard.section.backend.usedServer=Used server: -adminTools.dashboard.section.backend.xwiki.version=XWiki installation version: +adminTools.dashboard.section.backend.usedDB=Used database +adminTools.dashboard.section.backend.usedServer=Used server +adminTools.dashboard.section.backend.xwiki.version=XWiki installation version ## Files adminTools.dashboard.section.download.description=Get the files you need. View them directly in the browser or download them as an archive. adminTools.dashboard.section.download.modal.open=Export files needed for getting support adminTools.dashboard.section.download.title=Files adminTools.dashboard.section.download.view.configuration=XWiki configuration file -adminTools.dashboard.section.download.view.description=View files content: +adminTools.dashboard.section.download.view.description=View files content 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! ## Security -adminTools.dashboard.section.security.activeEncoding=Active encoding: -adminTools.dashboard.section.security.configurationEncoding=Configuration encoding: +adminTools.dashboard.section.security.activeEncoding=Active encoding +adminTools.dashboard.section.security.configurationEncoding=Configuration encoding adminTools.dashboard.section.security.description=See an overview of your security information. adminTools.dashboard.section.security.error=Error while gathering security information. -adminTools.dashboard.section.security.fileEncoding=File encoding: -adminTools.dashboard.section.security.lang=Used language: -adminTools.dashboard.section.security.pwd=Working directory: +adminTools.dashboard.section.security.fileEncoding=File encoding +adminTools.dashboard.section.security.lang=Used language +adminTools.dashboard.section.security.pwd=Working directory adminTools.dashboard.section.security.title=Security diff --git a/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml b/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml index 821e7e94..34e751c0 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml @@ -34,92 +34,10 @@ false xwiki/2.1 false - {{dashboard/}} + {{include reference="AdminTools.Code.Macros"/}} -{{velocity}} -{{html clean='false'}} -<div class="modal fade" id="downloadFilesModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">&times;</span></button> - <h1 class="modal-title" id="downloadFilesModalLabel"> - $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.title')) - </h1> - </div> - <div class="modal-body"> - <form id="downloadForm" action="$request.getContextPath()/rest/admintools/files" method="POST"> - <div class="download-modal-content"> - <dl> - <dt><label><input type="checkbox" name="files" value="xwikiConfig" checked> - $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.xwikiConfig.title')) - </label> - </dt> - <dt><label><input type="checkbox" name="files" value="xwikiProperties" checked> - $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.xwikiProperties.title')) - </label> - </dt> - <dt><label><input type="checkbox" name="files" value="dataProviderResource" checked> - $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.provided'))</label> - </dt> - <dt><label><input type="checkbox" name="files" value="logsDataResource" checked> Logs</label></dt> - <dt> - <div id="dateFields"> - <label>$escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.date.from')) - </label> <input type="date" id="from" name="from"> - <label>$escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.date.to')) - </label> <input type="date" id="to" name="to"> - </div> - </dt> - </dl> - </div> - <div class="download-button"> - <input class="btn btn-primary btn-lg" type="submit" - value="$escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.button'))"> - </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal"> - $escapetool.xml($services.localization.render('cancel'))</button> - </div> - </div> - </div> -</div> - -<div class="modal fade" id="viewLastNLinesModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="logs-modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">&times;</span></button> - <h1 class="modal-title" id="viewLastNLinesModalLabel"> - $escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.title')) - </h1> - </div> - <div class="modal-body"> - <form id="downloadForm" action="$request.getContextPath()/rest/admintools/files/logs" - method="POST" target="_blank"> - <dl> - <dt><label>$escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.nLines.label')) </label></dt> - <dd><input type="number" id="noLines" name="noLines" placeholder="100"></dd> - </dl> - <input class="btn btn-primary btn-lg" type="submit" - value="$escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.submit'))"> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-default" data-dismiss="modal"> - $escapetool.xml($services.localization.render('cancel'))</button> - </div> - </div> - </div> - </div> -</div> -{{/html}} -{{/velocity}} +{{dashboard/}} + AdminTools.WebHome 0 @@ -312,6 +230,167 @@ $services.admintools.getConfigurationData('configuration') + + AdminTools.WebHome + 0 + XWiki.JavaScriptExtension + db26a9ff-8a2e-4a46-83c2-697aa46eef7a + + XWiki.JavaScriptExtension + + + + + + + + + 0 + long + 0 + select + forbidden + 0 + 0 + cache + 5 + Caching policy + 0 + + |, + 1 + 0 + long|short|default|forbid + com.xpn.xwiki.objects.classes.StaticListClass + + + PureText + 0 + PureText + code + 2 + Code + 0 + 20 + 50 + 0 + com.xpn.xwiki.objects.classes.TextAreaClass + + + 0 + name + 1 + Name + 30 + 0 + com.xpn.xwiki.objects.classes.StringClass + + + 0 + select + yesno + parse + 4 + Parse content + 0 + com.xpn.xwiki.objects.classes.BooleanClass + + + 0 + 0 + select + forbidden + 0 + 0 + use + 3 + Use this extension + 0 + + |, + 1 + 0 + currentPage|onDemand|always + com.xpn.xwiki.objects.classes.StaticListClass + + + + default + + + require(['jquery'], function($) { + $(document).on('click', '#filesDownloadFilesModal .btn-primary', function(event) { + event.preventDefault() + var downloadForm = $(document.getElementById("filesDownloadForm")); + var form = downloadForm.serialize() + var link = document.createElement('a'); + link.href = downloadForm.attr('action'); + link.href += "?" + form; + link.click(); + }); + + $(document).on('click', '#filesViewLastNLinesModal .btn-primary', function(event) { + event.preventDefault() + var downloadForm = $(document.getElementById("filesLastNLogLinesForm")); + var noLines = $("#filesNoLines").val(); + if(noLines == ""){ + noLines = "1000"; + } + var link = document.createElement('a'); + link.href = downloadForm.attr('action'); + debugger; + link.href += "/" + noLines; + link.target="_blank"; + link.click(); + }); + + $(document).on('click', '#configurationViewLastNLinesModal .btn-primary', function(event) { + event.preventDefault() + var downloadForm = $(document.getElementById("configurationLastNLogLinesForm")); + var noLines = $("#configurationNoLines").val(); + if(noLines == ""){ + noLines = "1000"; + } + var link = document.createElement('a'); + link.href = downloadForm.attr('action'); + debugger; + link.href += "/" + noLines; + link.target="_blank"; + link.click(); + }); + + $(document).ready(function() { + var logsCheckbox = $('input[name="files"][value="logsDataResource"]'); + var dateFields = $('.dateFields'); + + if (!logsCheckbox.is(':checked')) { + dateFields.hide(); + } else { + dateFields.show(); + } + + logsCheckbox.change(function() { + if (this.checked) { + dateFields.show(); + } else { + dateFields.hide(); + } + }); +}); +}); + + + + + AdminToolsJavaScript + + + 0 + + + currentPage + + AdminTools.WebHome 0 @@ -435,12 +514,16 @@ $services.admintools.getConfigurationData('configuration') text-align: center; } -#downloadFilesModalLabel{ +.downloadFilesModalTitle{ text-align: center; } .download-modal-content{ padding-left: 5rem; +} + +.dateFields { + margin: 2rem 4rem; }