-
Notifications
You must be signed in to change notification settings - Fork 32
✨ [Frontend] Pretty JSON objects #7710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mergify
merged 23 commits into
ITISFoundation:master
from
odeimaiz:feature/json-tree-viewer
May 21, 2025
Merged
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4a70eae
JsonTreeViewer
odeimaiz 285036d
minor
odeimaiz 8af3042
renaming
odeimaiz 1377ffc
minor
odeimaiz de20f45
minors
odeimaiz 8aa0884
json-formatter
odeimaiz 5176dde
curateFilterId
odeimaiz fd32d2a
Merge branch 'master' into feature/json-tree-viewer
odeimaiz 22da6c1
minor
odeimaiz cd0367f
init JsonFormatter
odeimaiz c6f66fc
working JSONFormatter
odeimaiz fa95839
minor
odeimaiz ad64a17
undo
odeimaiz cdbb141
refactor
odeimaiz 0b891a4
styling
odeimaiz 757acc4
minor
odeimaiz 1e3f5e1
minor
odeimaiz c365cdd
Hide "Object" and "Array(n)" labels
odeimaiz 905f22e
minor
odeimaiz 32382b4
Merge branch 'master' into feature/json-tree-viewer
odeimaiz 159a292
comments
odeimaiz b677106
Merge branch 'feature/json-tree-viewer' of github.com:odeimaiz/osparc…
odeimaiz 1b6d83d
Merge branch 'master' into feature/json-tree-viewer
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
services/static-webserver/client/source/class/osparc/wrapper/JsonFormatter.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| /* ************************************************************************ | ||
|
|
||
| osparc - the simcore frontend | ||
|
|
||
| https://osparc.io | ||
|
|
||
| Copyright: | ||
| 2022 IT'IS Foundation, https://itis.swiss | ||
|
|
||
| License: | ||
| MIT: https://opensource.org/licenses/MIT | ||
|
|
||
| Authors: | ||
| * Odei Maiz (odeimaiz) | ||
|
|
||
| ************************************************************************ */ | ||
|
|
||
| /** | ||
| * @asset(jsonFormatter/json-formatter-2.5.23.js) | ||
| * @asset(jsonFormatter/json-formatter-2.5.23.css) | ||
| * @ignore(JSONFormatter) | ||
| */ | ||
|
|
||
| /** | ||
| * A qooxdoo wrapper for | ||
| * <a href='https://azimi.me/json-formatter-js/' target='_blank'>JSONFormatter</a> | ||
| */ | ||
|
|
||
| qx.Class.define("osparc.wrapper.JsonFormatter", { | ||
| extend: qx.core.Object, | ||
| type: "singleton", | ||
|
|
||
| properties: { | ||
| libReady: { | ||
| nullable: false, | ||
| init: false, | ||
| check: "Boolean" | ||
| } | ||
| }, | ||
|
|
||
| statics: { | ||
| NAME: "JSONFormatter", | ||
| VERSION: "2.5.23", | ||
| URL: "https://azimi.me/json-formatter-js/", | ||
| }, | ||
|
|
||
| members: { | ||
| init: function() { | ||
| return new Promise((resolve, reject) => { | ||
| if (this.getLibReady()) { | ||
| resolve(); | ||
| return; | ||
| } | ||
|
|
||
| const jsonFormatterCss = "jsonFormatter/json-formatter-2.5.23.css"; | ||
| const jsonFormatterCssUri = qx.util.ResourceManager.getInstance().toUri(jsonFormatterCss); | ||
| qx.module.Css.includeStylesheet(jsonFormatterCssUri); | ||
|
|
||
| // initialize the script loading | ||
| const jsonFormatterPath = "jsonFormatter/json-formatter-2.5.23.js"; | ||
| const dynLoader = new qx.util.DynamicScriptLoader([ | ||
| jsonFormatterPath | ||
| ]); | ||
|
|
||
| dynLoader.addListenerOnce("ready", () => { | ||
| console.log(jsonFormatterPath + " loaded"); | ||
| this.setLibReady(true); | ||
| resolve(); | ||
| }, this); | ||
|
|
||
| dynLoader.addListener("failed", e => { | ||
| const data = e.getData(); | ||
| console.error("failed to load " + data.script); | ||
| reject(data); | ||
| }, this); | ||
|
|
||
| dynLoader.start(); | ||
| }); | ||
| }, | ||
|
|
||
| createContainer: function(divId) { | ||
| const container = new qx.ui.embed.Html("<div id='"+divId+"'></div>"); | ||
|
|
||
| // Inject custom CSS for the JSONFormatter container | ||
| const styleId = "json-formatter-custom-style"; | ||
| if (!document.getElementById(styleId)) { | ||
| const color = qx.theme.manager.Color.getInstance().resolve("text"); | ||
| const style = document.createElement("style"); | ||
| style.id = styleId; | ||
| style.innerHTML = ` | ||
| #${divId} * { | ||
| color: ${color} !important; /* Use your preferred color */ | ||
| font-family: "Manrope", sans-serif !important; | ||
| } | ||
| #${divId} .json-formatter-key { | ||
| font-size: 13px !important; /* actually keeping the default size */ | ||
| } | ||
| #${divId} .json-formatter-constructor-name { | ||
| display: none !important; /* Hide "Object" and "Array(n)" labels */ | ||
| } | ||
| `; | ||
| document.head.appendChild(style); | ||
| } | ||
|
|
||
| return container | ||
| }, | ||
|
|
||
| setData: function(myJSON, divId) { | ||
| // Remove previous content | ||
| const container = document.getElementById(divId); | ||
| container.innerHTML = ""; | ||
|
|
||
| // Render JSON | ||
| const formatter = new JSONFormatter(myJSON, 2); // 2 = expand depth | ||
| container.appendChild(formatter.render()); | ||
| }, | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
services/static-webserver/client/source/resource/jsonFormatter/json-formatter-2.5.23.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.