Skip to content

Commit

Permalink
Add FEature: Print call elapsed time and response chars size
Browse files Browse the repository at this point in the history
  • Loading branch information
baxtheman committed Apr 5, 2019
1 parent 1a29171 commit 3aef23e
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 51 deletions.
97 changes: 49 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
# `/api/jsonws extender`

Are you tired of the old api jsonws page? Take this new one with some extra features:

* Compact design, fluid layout, method details with accordion
* JSON result sintax highlight
* Fast clipboard copy
* Recall for previous call parameters (using local storage)

Tested on Liferay 7.1 CE

[Download the bundle jar](https://github.com/baxtheman/api-jsonws-ext/releases/download/7.1.0.2/it.baxtheman.liferay.apijsonwsext-7.1.0.2.jar)

![Old to new](/doc/new.gif)

## Roadmap

* Fast switch to change `com.liferay.portal.jsonwebservice` package log level
* Extend the history feature to save several call params

## Previous version

It's still available the same plugin for Liferay 6.2 [here](https://github.com/baxtheman/mqtt-liferay-plugins/tree/master/base-services-portlet)

## Credits

* [Clipboard.js by Zeno](https://github.com/zenorocha/clipboard.js/) (Why it's not bundled in AlloyUI?)
* [JavaScript code prettifier](https://github.com/google/code-prettify)
* [local-storage-fallback](https://www.npmjs.com/package/local-storage-fallback)

License
-------

This library, *api-jsonws-ext*, is free software ("Licensed Software"); you can
redistribute it and/or modify it under the terms of the [GNU Lesser General
Public License](http://www.gnu.org/licenses/lgpl-2.1.html) as published by the
Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; including but not limited to, the implied warranty of MERCHANTABILITY,
NONINFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.

You should have received a copy of the [GNU Lesser General Public
License](http://www.gnu.org/licenses/lgpl-2.1.html) along with this library; if
not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
Floor, Boston, MA 02110-1301 USA
# `/api/jsonws extender`

Are you tired of the old api jsonws page? Take this new one with some extra features:

* Compact design, fluid layout, method details with accordion
* JSON result sintax highlight
* Fast clipboard copy
* Recall for previous call parameters (using local storage)
* Print call elapsed time and response chars size

Tested on Liferay 7.1 CE

[Download the bundle jar](https://github.com/baxtheman/api-jsonws-ext/releases/download/7.1.0.4/it.baxtheman.liferay.apijsonwsext-7.1.0.4.jar)

![Old to new](/doc/new.gif)

## Roadmap

* Fast switch to change `com.liferay.portal.jsonwebservice` package log level
* Extend the history feature to save several call params

## Previous version

It's still available the same plugin for Liferay 6.2 [here](https://github.com/baxtheman/mqtt-liferay-plugins/tree/master/base-services-portlet)

## Credits

* [Clipboard.js by Zeno](https://github.com/zenorocha/clipboard.js/) (Why it's not bundled in AlloyUI?)
* [JavaScript code prettifier](https://github.com/google/code-prettify)
* [local-storage-fallback](https://www.npmjs.com/package/local-storage-fallback)

License
-------

This library, *api-jsonws-ext*, is free software ("Licensed Software"); you can
redistribute it and/or modify it under the terms of the [GNU Lesser General
Public License](http://www.gnu.org/licenses/lgpl-2.1.html) as published by the
Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; including but not limited to, the implied warranty of MERCHANTABILITY,
NONINFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.

You should have received a copy of the [GNU Lesser General Public
License](http://www.gnu.org/licenses/lgpl-2.1.html) along with this library; if
not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
Floor, Boston, MA 02110-1301 USA
4 changes: 3 additions & 1 deletion bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Bundle-Name: API JSONWS JSPs Ext
Bundle-Description: Overrides core/kernel API JSONWS JSPs
Bundle-SymbolicName: it.baxtheman.liferay.apijsonwsext
Bundle-Version: 7.1.0.3
Bundle-Version: 7.1.0.4
Created-By: Daniele Baggio @baxtheman
-sources: true
Web-ContextPath: /api-jsonws-ext
Liferay-JS-Config:/META-INF/resources/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ String signature = ParamUtil.getString(request, "signature");
refresh="<%= false %>"
>
<liferay-ui:section>
<div>
<button title="copy to clipboard" id="copy-clipboard" class="btn copy-clipboard" data-clipboard-target="#serviceOutput">
<i class="icon-copy"></i>
</button>
<span class="time-elapsed badge badge-info"></span>
<span class="response-size badge badge-info"></span>
</div>

<pre class="prettyprint linenums lang-js lfr-code-block" id="serviceOutput"></pre>
</liferay-ui:section>
Expand Down Expand Up @@ -340,15 +344,29 @@ String signature = ParamUtil.getString(request, "signature");

formEl = form.getDOM();

var startTime, endTime;
startTime = new Date();

Liferay.Service(
'<%= jsonWebServiceActionMapping.getPath() %>',
formEl,
function(obj) {
serviceOutput.html(PR.prettyPrintOne(A.Lang.String.escapeHTML(JSON.stringify(obj, null, 2))));

endTime = new Date();
var timeDiff = endTime - startTime;
var milliseconds = Math.round(timeDiff);

var jsontext = JSON.stringify(obj, null, 2);
var jsonsize = jsontext.length;

serviceOutput.html(PR.prettyPrintOne(A.Lang.String.escapeHTML(jsontext)));

output.removeClass('loading-results');

location.hash = '#serviceResults';

A.one('span.time-elapsed').text('call time: ' + milliseconds + ' ms');
A.one('span.response-size').text(jsonsize + ' chars lenght');
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ h3 {
font-size: 2.3em;
}

.badge {
font-size: 0.9em;
}

.loading-results {
background: url(<%= themeDisplay.getPathThemeImages() %>/aui/loading_indicator.gif) no-repeat 50%;
min-height: 2em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>

<footer>
<liferay-ui:message key="powered-by" /> <a href="https://twitter.com/baxtheman" rel="external">Liferay & @baxtheman</a>
<liferay-ui:message key="powered-by" /> <a href="https://twitter.com/baxtheman" rel="external">Liferay & @baxtheman (ver 7.1.0.4)</a>
</footer>
</div>
</c:if>

0 comments on commit 3aef23e

Please sign in to comment.