From bc3bdc48d2b647a5d18ecc26c769b2bec0b406cf Mon Sep 17 00:00:00 2001 From: Hemna Date: Mon, 8 Apr 2024 10:16:08 -0400 Subject: [PATCH] Removed json-viewer --- .../static/json-viewer/jquery.json-viewer.css | 57 ------- .../static/json-viewer/jquery.json-viewer.js | 158 ------------------ .../static/json-viewer/jquery.json-viewer.css | 57 ------- .../static/json-viewer/jquery.json-viewer.js | 158 ------------------ aprsd/wsgi.py | 3 +- 5 files changed, 1 insertion(+), 432 deletions(-) delete mode 100644 aprsd/web/admin/static/json-viewer/jquery.json-viewer.css delete mode 100644 aprsd/web/admin/static/json-viewer/jquery.json-viewer.js delete mode 100644 aprsd/web/chat/static/json-viewer/jquery.json-viewer.css delete mode 100644 aprsd/web/chat/static/json-viewer/jquery.json-viewer.js diff --git a/aprsd/web/admin/static/json-viewer/jquery.json-viewer.css b/aprsd/web/admin/static/json-viewer/jquery.json-viewer.css deleted file mode 100644 index 57aa450..0000000 --- a/aprsd/web/admin/static/json-viewer/jquery.json-viewer.css +++ /dev/null @@ -1,57 +0,0 @@ -/* Root element */ -.json-document { - padding: 1em 2em; -} - -/* Syntax highlighting for JSON objects */ -ul.json-dict, ol.json-array { - list-style-type: none; - margin: 0 0 0 1px; - border-left: 1px dotted #ccc; - padding-left: 2em; -} -.json-string { - color: #0B7500; -} -.json-literal { - color: #1A01CC; - font-weight: bold; -} - -/* Toggle button */ -a.json-toggle { - position: relative; - color: inherit; - text-decoration: none; -} -a.json-toggle:focus { - outline: none; -} -a.json-toggle:before { - font-size: 1.1em; - color: #c0c0c0; - content: "\25BC"; /* down arrow */ - position: absolute; - display: inline-block; - width: 1em; - text-align: center; - line-height: 1em; - left: -1.2em; -} -a.json-toggle:hover:before { - color: #aaa; -} -a.json-toggle.collapsed:before { - /* Use rotated down arrow, prevents right arrow appearing smaller than down arrow in some browsers */ - transform: rotate(-90deg); -} - -/* Collapsable placeholder links */ -a.json-placeholder { - color: #aaa; - padding: 0 1em; - text-decoration: none; -} -a.json-placeholder:hover { - text-decoration: underline; -} diff --git a/aprsd/web/admin/static/json-viewer/jquery.json-viewer.js b/aprsd/web/admin/static/json-viewer/jquery.json-viewer.js deleted file mode 100644 index 611411b..0000000 --- a/aprsd/web/admin/static/json-viewer/jquery.json-viewer.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * jQuery json-viewer - * @author: Alexandre Bodelot - * @link: https://github.com/abodelot/jquery.json-viewer - */ -(function($) { - - /** - * Check if arg is either an array with at least 1 element, or a dict with at least 1 key - * @return boolean - */ - function isCollapsable(arg) { - return arg instanceof Object && Object.keys(arg).length > 0; - } - - /** - * Check if a string represents a valid url - * @return boolean - */ - function isUrl(string) { - var urlRegexp = /^(https?:\/\/|ftps?:\/\/)?([a-z0-9%-]+\.){1,}([a-z0-9-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:/?#[\]@!$&'()*+,;=%]+)?)?$/i; - return urlRegexp.test(string); - } - - /** - * Transform a json object into html representation - * @return string - */ - function json2html(json, options) { - var html = ''; - if (typeof json === 'string') { - // Escape tags and quotes - json = json - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/'/g, ''') - .replace(/"/g, '"'); - - if (options.withLinks && isUrl(json)) { - html += '' + json + ''; - } else { - // Escape double quotes in the rendered non-URL string. - json = json.replace(/"/g, '\\"'); - html += '"' + json + '"'; - } - } else if (typeof json === 'number') { - html += '' + json + ''; - } else if (typeof json === 'boolean') { - html += '' + json + ''; - } else if (json === null) { - html += 'null'; - } else if (json instanceof Array) { - if (json.length > 0) { - html += '[
    '; - for (var i = 0; i < json.length; ++i) { - html += '
  1. '; - // Add toggle button if item is collapsable - if (isCollapsable(json[i])) { - html += ''; - } - html += json2html(json[i], options); - // Add comma if item is not last - if (i < json.length - 1) { - html += ','; - } - html += '
  2. '; - } - html += '
]'; - } else { - html += '[]'; - } - } else if (typeof json === 'object') { - var keyCount = Object.keys(json).length; - if (keyCount > 0) { - html += '{}'; - } else { - html += '{}'; - } - } - return html; - } - - /** - * jQuery plugin method - * @param json: a javascript object - * @param options: an optional options hash - */ - $.fn.jsonViewer = function(json, options) { - // Merge user options with default options - options = Object.assign({}, { - collapsed: false, - rootCollapsable: true, - withQuotes: false, - withLinks: true - }, options); - - // jQuery chaining - return this.each(function() { - - // Transform to HTML - var html = json2html(json, options); - if (options.rootCollapsable && isCollapsable(json)) { - html = '' + html; - } - - // Insert HTML in target DOM element - $(this).html(html); - $(this).addClass('json-document'); - - // Bind click on toggle buttons - $(this).off('click'); - $(this).on('click', 'a.json-toggle', function() { - var target = $(this).toggleClass('collapsed').siblings('ul.json-dict, ol.json-array'); - target.toggle(); - if (target.is(':visible')) { - target.siblings('.json-placeholder').remove(); - } else { - var count = target.children('li').length; - var placeholder = count + (count > 1 ? ' items' : ' item'); - target.after('' + placeholder + ''); - } - return false; - }); - - // Simulate click on toggle button when placeholder is clicked - $(this).on('click', 'a.json-placeholder', function() { - $(this).siblings('a.json-toggle').click(); - return false; - }); - - if (options.collapsed == true) { - // Trigger click to collapse all nodes - $(this).find('a.json-toggle').click(); - } - }); - }; -})(jQuery); diff --git a/aprsd/web/chat/static/json-viewer/jquery.json-viewer.css b/aprsd/web/chat/static/json-viewer/jquery.json-viewer.css deleted file mode 100644 index 57aa450..0000000 --- a/aprsd/web/chat/static/json-viewer/jquery.json-viewer.css +++ /dev/null @@ -1,57 +0,0 @@ -/* Root element */ -.json-document { - padding: 1em 2em; -} - -/* Syntax highlighting for JSON objects */ -ul.json-dict, ol.json-array { - list-style-type: none; - margin: 0 0 0 1px; - border-left: 1px dotted #ccc; - padding-left: 2em; -} -.json-string { - color: #0B7500; -} -.json-literal { - color: #1A01CC; - font-weight: bold; -} - -/* Toggle button */ -a.json-toggle { - position: relative; - color: inherit; - text-decoration: none; -} -a.json-toggle:focus { - outline: none; -} -a.json-toggle:before { - font-size: 1.1em; - color: #c0c0c0; - content: "\25BC"; /* down arrow */ - position: absolute; - display: inline-block; - width: 1em; - text-align: center; - line-height: 1em; - left: -1.2em; -} -a.json-toggle:hover:before { - color: #aaa; -} -a.json-toggle.collapsed:before { - /* Use rotated down arrow, prevents right arrow appearing smaller than down arrow in some browsers */ - transform: rotate(-90deg); -} - -/* Collapsable placeholder links */ -a.json-placeholder { - color: #aaa; - padding: 0 1em; - text-decoration: none; -} -a.json-placeholder:hover { - text-decoration: underline; -} diff --git a/aprsd/web/chat/static/json-viewer/jquery.json-viewer.js b/aprsd/web/chat/static/json-viewer/jquery.json-viewer.js deleted file mode 100644 index 611411b..0000000 --- a/aprsd/web/chat/static/json-viewer/jquery.json-viewer.js +++ /dev/null @@ -1,158 +0,0 @@ -/** - * jQuery json-viewer - * @author: Alexandre Bodelot - * @link: https://github.com/abodelot/jquery.json-viewer - */ -(function($) { - - /** - * Check if arg is either an array with at least 1 element, or a dict with at least 1 key - * @return boolean - */ - function isCollapsable(arg) { - return arg instanceof Object && Object.keys(arg).length > 0; - } - - /** - * Check if a string represents a valid url - * @return boolean - */ - function isUrl(string) { - var urlRegexp = /^(https?:\/\/|ftps?:\/\/)?([a-z0-9%-]+\.){1,}([a-z0-9-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:/?#[\]@!$&'()*+,;=%]+)?)?$/i; - return urlRegexp.test(string); - } - - /** - * Transform a json object into html representation - * @return string - */ - function json2html(json, options) { - var html = ''; - if (typeof json === 'string') { - // Escape tags and quotes - json = json - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/'/g, ''') - .replace(/"/g, '"'); - - if (options.withLinks && isUrl(json)) { - html += '' + json + ''; - } else { - // Escape double quotes in the rendered non-URL string. - json = json.replace(/"/g, '\\"'); - html += '"' + json + '"'; - } - } else if (typeof json === 'number') { - html += '' + json + ''; - } else if (typeof json === 'boolean') { - html += '' + json + ''; - } else if (json === null) { - html += 'null'; - } else if (json instanceof Array) { - if (json.length > 0) { - html += '[
    '; - for (var i = 0; i < json.length; ++i) { - html += '
  1. '; - // Add toggle button if item is collapsable - if (isCollapsable(json[i])) { - html += ''; - } - html += json2html(json[i], options); - // Add comma if item is not last - if (i < json.length - 1) { - html += ','; - } - html += '
  2. '; - } - html += '
]'; - } else { - html += '[]'; - } - } else if (typeof json === 'object') { - var keyCount = Object.keys(json).length; - if (keyCount > 0) { - html += '{
    '; - for (var key in json) { - if (Object.prototype.hasOwnProperty.call(json, key)) { - html += '
  • '; - var keyRepr = options.withQuotes ? - '"' + key + '"' : key; - // Add toggle button if item is collapsable - if (isCollapsable(json[key])) { - html += '' + keyRepr + ''; - } else { - html += keyRepr; - } - html += ': ' + json2html(json[key], options); - // Add comma if item is not last - if (--keyCount > 0) { - html += ','; - } - html += '
  • '; - } - } - html += '
}'; - } else { - html += '{}'; - } - } - return html; - } - - /** - * jQuery plugin method - * @param json: a javascript object - * @param options: an optional options hash - */ - $.fn.jsonViewer = function(json, options) { - // Merge user options with default options - options = Object.assign({}, { - collapsed: false, - rootCollapsable: true, - withQuotes: false, - withLinks: true - }, options); - - // jQuery chaining - return this.each(function() { - - // Transform to HTML - var html = json2html(json, options); - if (options.rootCollapsable && isCollapsable(json)) { - html = '' + html; - } - - // Insert HTML in target DOM element - $(this).html(html); - $(this).addClass('json-document'); - - // Bind click on toggle buttons - $(this).off('click'); - $(this).on('click', 'a.json-toggle', function() { - var target = $(this).toggleClass('collapsed').siblings('ul.json-dict, ol.json-array'); - target.toggle(); - if (target.is(':visible')) { - target.siblings('.json-placeholder').remove(); - } else { - var count = target.children('li').length; - var placeholder = count + (count > 1 ? ' items' : ' item'); - target.after('' + placeholder + ''); - } - return false; - }); - - // Simulate click on toggle button when placeholder is clicked - $(this).on('click', 'a.json-placeholder', function() { - $(this).siblings('a.json-toggle').click(); - return false; - }); - - if (options.collapsed == true) { - // Trigger click to collapse all nodes - $(this).find('a.json-toggle').click(); - } - }); - }; -})(jQuery); diff --git a/aprsd/wsgi.py b/aprsd/wsgi.py index 7e3cd3f..487a5e4 100644 --- a/aprsd/wsgi.py +++ b/aprsd/wsgi.py @@ -188,10 +188,9 @@ def save(): def log_entries(): """The url that the server can call to update the logs.""" entries = request.json - LOG.debug(f"Log entries called {len(entries)}") + LOG.info(f"Log entries called {len(entries)}") for entry in entries: logging_queue.put(entry) - LOG.debug("log_entries done") return json.dumps({"messages": "saved"})