This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch 7815 in repository https://gitbox.apache.org/repos/asf/storm.git
commit 9ba73048f81ab4a1261691d4ee7d11a085f520a6 Author: Richard Zowalla <[email protected]> AuthorDate: Mon Mar 16 10:21:12 2026 +0100 #7815 - Use package manager for 3rd party JS in Storm-UI - Replace third-party jsonFormatter plugin with ASF-licensed reimplementation (uses JSON.parse instead of eval) - Update LICENSE-binary paths and versions for npm packages --- LICENSE-binary | 84 +++------- pom.xml | 2 - storm-webapp/src/main/webapp/js/main-entry.js | 4 +- storm-webapp/src/main/webapp/lib/jsonFormatter.css | 46 ++++++ storm-webapp/src/main/webapp/lib/jsonFormatter.js | 177 +++++++++++++++++++++ .../src/main/webapp/lib/jsonFormatter.min.css | 1 - .../src/main/webapp/lib/jsonFormatter.min.js | 2 - 7 files changed, 247 insertions(+), 69 deletions(-) diff --git a/LICENSE-binary b/LICENSE-binary index fee0853c7..ee63ad6aa 100644 --- a/LICENSE-binary +++ b/LICENSE-binary @@ -203,7 +203,7 @@ ----------------------------------------------------------------------- -For jQuery 3.5.1 (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/jquery-3.5.1.min.js) +For jQuery 3.5.1 (bundled via npm package "jquery" into storm-webapp webpack output) MIT license selected: @@ -230,7 +230,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- -For jQuery Cookies 2.2.0 (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/jquery.cookies.2.2.0.min.js) +For js-cookie (bundled via npm package "js-cookie" into storm-webapp webpack output; +replaces the former jQuery Cookies 2.2.0 plugin) Copyright (c) 2005 - 2010, James Auldridge @@ -255,7 +256,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- -For typeahead jquery 0.10.5 (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/typeahead.jquery.min.js) +For typeahead.js 0.11.1 (bundled via npm package "typeahead.js" into storm-webapp webpack output) Copyright (c) 2013-2014 Twitter, Inc @@ -279,7 +280,7 @@ THE SOFTWARE. ----------------------------------------------------------------------- -For js-yaml.min.js (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/js-yaml.min.js) +For js-yaml 3.14.1 (bundled via npm package "js-yaml" into storm-webapp webpack output) (The MIT License) @@ -305,7 +306,7 @@ THE SOFTWARE. ----------------------------------------------------------------------- -For dagre.min.js (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/dagre.min.js) +For dagre 0.8.5 (bundled via npm package "dagre" into storm-webapp webpack output) Copyright (c) 2012-2014 Chris Pettitt @@ -329,7 +330,8 @@ THE SOFTWARE. ----------------------------------------------------------------------- -For cytoscape.min.js and cytoscape-dagre.js (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/cytoscape.min.js and storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/cytoscape-dagre.js) +For cytoscape 3.30.4 and cytoscape-dagre 2.5.0 (bundled via npm packages "cytoscape" +and "cytoscape-dagre" into storm-webapp webpack output) Copyright (c) 2016 The Cytoscape Consortium @@ -353,7 +355,7 @@ SOFTWARE. ----------------------------------------------------------------------- -For esprima.js (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/esprima.min.js) +For esprima 4.0.1 (bundled via npm package "esprima" into storm-webapp webpack output) Copyright JS Foundation and other contributors, https://js.foundation/ @@ -379,7 +381,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------- -For mustache.js (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/jquery.mustache.js) +For mustache.js 4.2.0 (bundled via npm package "mustache" into storm-webapp webpack output) The MIT License @@ -406,7 +408,7 @@ THE SOFTWARE. ----------------------------------------------------------------------- -For moment.js (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/moment.min.js) +For moment.js 2.29.4 (bundled via npm package "moment" into storm-webapp webpack output) Copyright (c) 2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors @@ -434,18 +436,17 @@ OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- -For Jquery url plugin (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/url.min.js) +For domurl 2.3.4 (bundled via npm package "domurl" into storm-webapp webpack output; +replaces the former jQuery URL plugin v1.8.6) -Jquery Url (A Jquery plugin for URL parser) v1.8.6 -Source repository: https://github.com/websanova/js-url -Licensed under an MIT-style license. Seehttps://github.com/websanova/js-url#license for details. +Source repository: https://github.com/Mikhus/domurl +Licensed under an MIT-style license. See https://github.com/Mikhus/domurl/blob/master/LICENSE for details. ----------------------------------------------------------------------- -For jquery.blockUI.min.js (storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/jquery.blockUI.min.js) +For jQuery BlockUI 2.7.0 (bundled via npm package "jquery-blockui" into storm-webapp webpack output) -jQuery BlockUI; v20131009 http://jquery.malsup.com/block/ Copyright (c) 2013 M. Alsup; Dual licensed: MIT/GPL @@ -468,12 +469,8 @@ use the BlockUI plugin in commercial projects as long as the copyright header is ----------------------------------------------------------------------- -For jquery dataTables v1.10.4 - -(storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/jquery.dataTables.1.10.4.min.js -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/css/jquery.dataTables.1.10.4.min.css -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/images/{{back, forward}_{disabled, enabled, enabled_hover}}.png -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/images/{sort_{asc, asc_disabled, both, desc, desc_disabled}}.png) +For DataTables 2.3.7 (bundled via npm packages "datatables.net" and "datatables.net-dt" +into storm-webapp webpack output) Copyright (c) 2008-2013 SpryMedia Limited http://datatables.net @@ -498,15 +495,11 @@ THE SOFTWARE. ----------------------------------------------------------------------- -For jquery dataTables bootstrap integration - -(storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/jquery.dataTables.1.10.4.min.js -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/dataTables.bootstrap.min.js -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/css/dataTables.bootstrap.css) +For DataTables Bootstrap 3 integration 2.3.7 (bundled via npm package "datatables.net-bs" +into storm-webapp webpack output) Copyright (c) 2013-2014 SpryMedia Limited http://datatables.net/license -https://github.com/DataTables/Plugins/tree/master/integration/bootstrap/3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -529,9 +522,7 @@ THE SOFTWARE. ----------------------------------------------------------------------- -For bootstrap v3.3.1 -(storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/bootstrap-3.3.1.min.js -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/css/bootstrap-3.3.1.min.css) +For Bootstrap 3.3.1 (bundled via npm package "bootstrap" into storm-webapp webpack output) Bootstrap v3.3.1 (http://getbootstrap.com) Copyright 2011-2014 Twitter, Inc. @@ -539,35 +530,6 @@ Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) ----------------------------------------------------------------------- -For jQuery JSONFormatter 1.0.1 2015-02-28 -(storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/jsonFormatter.min.js -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/css/jsonFormatter.min.css) -http://www.jqueryscript.net/other/jQuery-Plugin-For-Pretty-JSON-Formatting-jsonFormatter.htmlA - -The MIT License (MIT) - -Copyright (c) 2015 Matthew Heironimus - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - ------------------------------------------------------------------------ - For statistic image storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/images/statistic.png @@ -607,9 +569,7 @@ This product bundles PMML Sample Files, which are available under a ----------------------------------------------------------------------- -For vis.js 4.16.1 2016-04-18 -(storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/js/vis.min.js -storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/css/vis.min.css) +For vis.js 4.21.0 (bundled via npm package "vis" into storm-webapp webpack output) vis.js https://github.com/almende/vis diff --git a/pom.xml b/pom.xml index 490a35661..e247524c8 100644 --- a/pom.xml +++ b/pom.xml @@ -266,8 +266,6 @@ <!-- storm-webapp static assets and frontend build artifacts --> <exclude>**/src/main/java/org/apache/storm/daemon/ui/WEB-INF/images/* </exclude> - <exclude>**/src/main/webapp/lib/jsonFormatter.min.js</exclude> - <exclude>**/src/main/webapp/lib/jsonFormatter.min.css</exclude> <!-- npm / webpack artifacts --> <exclude>**/node_modules/**</exclude> <exclude>**/package-lock.json</exclude> diff --git a/storm-webapp/src/main/webapp/js/main-entry.js b/storm-webapp/src/main/webapp/js/main-entry.js index fbe132734..f001edee4 100644 --- a/storm-webapp/src/main/webapp/js/main-entry.js +++ b/storm-webapp/src/main/webapp/js/main-entry.js @@ -28,7 +28,7 @@ require('bootstrap/dist/css/bootstrap.min.css'); require('datatables.net-dt/css/dataTables.dataTables.css'); require('datatables.net-bs/css/dataTables.bootstrap.css'); -require('../lib/jsonFormatter.min.css'); +require('../lib/jsonFormatter.css'); require('../css/style.css'); // --- jQuery (must be first, made global for inline scripts) --- @@ -88,7 +88,7 @@ $.url = function (param) { require('jquery-blockui'); // --- JSON Formatter (project-local jQuery plugin, no npm equivalent) --- -require('../lib/jsonFormatter.min.js'); +require('../lib/jsonFormatter.js'); // --- npm libraries --- require('typeahead.js'); diff --git a/storm-webapp/src/main/webapp/lib/jsonFormatter.css b/storm-webapp/src/main/webapp/lib/jsonFormatter.css new file mode 100644 index 000000000..e113a69b8 --- /dev/null +++ b/storm-webapp/src/main/webapp/lib/jsonFormatter.css @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Styles for the jsonFormatter jQuery plugin */ +PRE.jsonFormatter-codeContainer { margin-top: 0; margin-bottom: 0; } +PRE.jsonFormatter-codeContainer .jsonFormatter-objectBrace { color: #0a0; font-weight: bold; } +PRE.jsonFormatter-codeContainer .jsonFormatter-arrayBrace { color: #03f; font-weight: bold; } +PRE.jsonFormatter-codeContainer .jsonFormatter-propertyName { color: #c00; font-weight: bold; } +PRE.jsonFormatter-codeContainer .jsonFormatter-string { color: #077; } +PRE.jsonFormatter-codeContainer .jsonFormatter-number { color: #a0a; } +PRE.jsonFormatter-codeContainer .jsonFormatter-boolean { color: #00f; } +PRE.jsonFormatter-codeContainer .jsonFormatter-function { color: #a63; font-style: italic; } +PRE.jsonFormatter-codeContainer .jsonFormatter-null { color: #00f; } +PRE.jsonFormatter-codeContainer .jsonFormatter-coma { color: #000; font-weight: bold; } + +PRE.jsonFormatter-codeContainer .jsonFormatter-expander { + display: inline-block; + width: 16px; + height: 11px; + cursor: pointer; + vertical-align: middle; +} +PRE.jsonFormatter-codeContainer .jsonFormatter-expanded::before { + content: '\25BC'; /* down triangle */ + font-size: 10px; + color: #666; +} +PRE.jsonFormatter-codeContainer .jsonFormatter-collapsed::before { + content: '\25B6'; /* right triangle */ + font-size: 10px; + color: #666; +} diff --git a/storm-webapp/src/main/webapp/lib/jsonFormatter.js b/storm-webapp/src/main/webapp/lib/jsonFormatter.js new file mode 100644 index 000000000..6b72f1071 --- /dev/null +++ b/storm-webapp/src/main/webapp/lib/jsonFormatter.js @@ -0,0 +1,177 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * jQuery plugin for pretty-printing JSON values inside table cells. + * Replaces the third-party jsonFormatter plugin (which used eval()). + * + * Usage: $('td').jsonFormatter(); + * + * Produces syntax-highlighted, collapsible JSON using the same CSS + * class names as the original plugin for backward compatibility. + */ +(function ($) { + 'use strict'; + + var defaults = { + tab: ' ', + quoteKeys: true, + collapsible: true, + hideOriginal: true + }; + + function escapeHtml(str) { + return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); + } + + function indent(level, text, settings) { + var pad = ''; + for (var i = 0; i < level; i++) { + pad += settings.tab; + } + if (text && text.charAt(text.length - 1) !== '\n') { + text += '\n'; + } + return pad + text; + } + + function processValue(value, level, hasTrailingComma, isChild, settings) { + var comma = hasTrailingComma ? "<span class='jsonFormatter-coma'>,</span> " : ''; + var type = typeof value; + + if (value === null) { + return span('null', '', comma, level, isChild, 'jsonFormatter-null', settings); + } + + if (type === 'undefined') { + return span('undefined', '', comma, level, isChild, 'jsonFormatter-null', settings); + } + + if (type === 'number') { + return span(value, '', comma, level, isChild, 'jsonFormatter-number', settings); + } + + if (type === 'boolean') { + return span(value, '', comma, level, isChild, 'jsonFormatter-boolean', settings); + } + + if (type === 'string') { + return span(escapeHtml(value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')), '"', comma, level, isChild, 'jsonFormatter-string', settings); + } + + if (Array.isArray(value)) { + return processArray(value, level, comma, isChild, settings); + } + + if (type === 'object') { + return processObject(value, level, comma, isChild, settings); + } + + return span(escapeHtml(String(value)), '', comma, level, isChild, 'jsonFormatter-string', settings); + } + + function span(val, quote, comma, level, addIndent, cssClass, settings) { + var html = "<span class='" + cssClass + "'>" + quote + val + quote + comma + "</span>"; + return addIndent ? indent(level, html, settings) : html; + } + + function processArray(arr, level, comma, isChild, settings) { + if (arr.length === 0) { + return indent(level, "<span class='jsonFormatter-arrayBrace'>[ ]</span>" + comma, settings); + } + + var expander = settings.collapsible + ? "<span class='jsonFormatter-expander jsonFormatter-expanded'></span><span class='jsonFormatter-collapsible'>" + : ''; + var closer = settings.collapsible ? '</span>' : ''; + var html = indent(level, "<span class='jsonFormatter-arrayBrace'>[</span>" + expander, settings); + + for (var i = 0; i < arr.length; i++) { + html += processValue(arr[i], level + 1, i < arr.length - 1, true, settings); + } + + html += indent(level, closer + "<span class='jsonFormatter-arrayBrace'>]</span>" + comma, settings); + return html; + } + + function processObject(obj, level, comma, isChild, settings) { + var keys = Object.keys(obj); + if (keys.length === 0) { + return indent(level, "<span class='jsonFormatter-objectBrace'>{ }</span>" + comma, settings); + } + + var expander = settings.collapsible + ? "<span class='jsonFormatter-expander jsonFormatter-expanded'></span><span class='jsonFormatter-collapsible'>" + : ''; + var closer = settings.collapsible ? '</span>' : ''; + var html = indent(level, "<span class='jsonFormatter-objectBrace'>{</span>" + expander, settings); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var q = settings.quoteKeys ? '"' : ''; + html += indent(level + 1, + "<span class='jsonFormatter-propertyName'>" + q + escapeHtml(key) + q + "</span>: " + + processValue(obj[key], level + 1, i < keys.length - 1, false, settings), + settings); + } + + html += indent(level, closer + "<span class='jsonFormatter-objectBrace'>}</span>" + comma, settings); + return html; + } + + $.fn.jsonFormatter = function (options) { + var settings = $.extend({}, defaults, options); + + return this.each(function () { + var $el = $(this); + var raw = $el.html().trim(); + if (raw === '') { + raw = '""'; + } + + var obj; + try { + obj = JSON.parse(raw); + } catch (e) { + // Not valid JSON, leave the element unchanged + return; + } + + var html = processValue(obj, 0, false, false, settings); + var $original = $el.wrapInner("<div class='jsonFormatter-original'></div>"); + if (settings.hideOriginal) { + $original.find('.jsonFormatter-original').hide(); + } + $original.append("<PRE class='jsonFormatter-codeContainer'>" + html + '</PRE>'); + + // Collapsible click handler + if (settings.collapsible) { + $el.on('click', '.jsonFormatter-expander', function () { + var $sibling = $(this).next(); + if ($sibling.length < 1) return; + if ($(this).hasClass('jsonFormatter-expanded')) { + $sibling.hide(); + $(this).removeClass('jsonFormatter-expanded').addClass('jsonFormatter-collapsed'); + } else { + $sibling.show(); + $(this).removeClass('jsonFormatter-collapsed').addClass('jsonFormatter-expanded'); + } + }); + } + }); + }; +})(jQuery); diff --git a/storm-webapp/src/main/webapp/lib/jsonFormatter.min.css b/storm-webapp/src/main/webapp/lib/jsonFormatter.min.css deleted file mode 100755 index 37761dbbe..000000000 --- a/storm-webapp/src/main/webapp/lib/jsonFormatter.min.css +++ /dev/null @@ -1 +0,0 @@ -PRE.jsonFormatter-codeContainer{margin-top:0;margin-bottom:0}PRE.jsonFormatter-codeContainer .jsonFormatter-objectBrace{color:#0a0;font-weight:bold}PRE.jsonFormatter-codeContainer .jsonFormatter-arrayBrace{color:#03f;font-weight:bold}PRE.jsonFormatter-codeContainer .jsonFormatter-propertyName{color:#c00;font-weight:bold}PRE.jsonFormatter-codeContainer .jsonFormatter-string{color:#077}PRE.jsonFormatter-codeContainer .jsonFormatter-number{color:#a0a}PRE.jsonFormatter-codeContainer .jsonFo [...] \ No newline at end of file diff --git a/storm-webapp/src/main/webapp/lib/jsonFormatter.min.js b/storm-webapp/src/main/webapp/lib/jsonFormatter.min.js deleted file mode 100755 index f2ffcecd7..000000000 --- a/storm-webapp/src/main/webapp/lib/jsonFormatter.min.js +++ /dev/null @@ -1,2 +0,0 @@ -(function($){$.fn.jsonFormatter=function(n){var _settings,u=new Date,r=new RegExp,i=function(n,t,i){for(var r="",u=0;u<n&&!i;u++)r+=_settings.tab;return t!=null&&t.length>0&&t.charAt(t.length-1)!="\n"&&(t=t+"\n"),r+t},f=function(n,t){for(var r,u,f="",i=0;i<n;i++)f+=_settings.tab;for(r=t.toString().split("\n"),u="",i=0;i<r.length;i++)u+=(i==0?"":f)+r[i]+"\n";return u},t=function(n,t,r,u,f,e){typeof n=="string"&&(n=n.split("<").join("<").split(">").join(">"));var o="<span class='"+e [...] -//# sourceMappingURL=jsonFormatter.min.js.map
