Skip to content

Commit 8aa0884

Browse files
committed
json-formatter
1 parent de20f45 commit 8aa0884

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

services/static-webserver/client/source/class/osparc/jobs/Info.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ qx.Class.define("osparc.jobs.Info", {
4343
switch (id) {
4444
case "job-info-viewer": {
4545
control = new osparc.ui.basic.JsonTreeViewer();
46+
/*
47+
OM remove maybe
4648
const container = new qx.ui.container.Scroll();
4749
container.add(control);
48-
this._add(container);
50+
*/
51+
this._add(control);
4952
break;
5053
}
5154
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2022 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
/**
19+
* @asset(jsonFormatter/json-formatter-2.5.23.js)
20+
* @asset(jsonFormatter/json-formatter-2.5.23.css)
21+
* @ignore(JSONFormatter)
22+
*/
23+
24+
/**
25+
* A qooxdoo wrapper for
26+
* <a href='https://azimi.me/json-formatter-js/' target='_blank'>JSONFormatter</a>
27+
*/
28+
29+
qx.Class.define("osparc.wrapper.JsonFormatter", {
30+
extend: qx.core.Object,
31+
type: "singleton",
32+
33+
properties: {
34+
libReady: {
35+
nullable: false,
36+
init: false,
37+
check: "Boolean"
38+
}
39+
},
40+
41+
statics: {
42+
NAME: "JSONFormatter",
43+
VERSION: "2.5.23",
44+
URL: "https://azimi.me/json-formatter-js/",
45+
},
46+
47+
members: {
48+
init: function() {
49+
return new Promise((resolve, reject) => {
50+
if (this.getLibReady()) {
51+
resolve();
52+
return;
53+
}
54+
55+
const jsonFormatterCss = "jsonFormatter/json-formatter-2.5.23.css";
56+
const jsonFormatterCssUri = qx.util.ResourceManager.getInstance().toUri(jsonFormatterCss);
57+
qx.module.Css.includeStylesheet(jsonFormatterCssUri);
58+
59+
// initialize the script loading
60+
const jsonFormatterPath = "jsonFormatter/json-formatter-2.5.23.js";
61+
const dynLoader = new qx.util.DynamicScriptLoader([
62+
jsonFormatterPath
63+
]);
64+
65+
dynLoader.addListenerOnce("ready", () => {
66+
console.log(jsonFormatterPath + " loaded");
67+
this.setLibReady(true);
68+
resolve();
69+
}, this);
70+
71+
dynLoader.addListener("failed", e => {
72+
const data = e.getData();
73+
console.error("failed to load " + data.script);
74+
reject(data);
75+
}, this);
76+
77+
dynLoader.start();
78+
});
79+
},
80+
81+
setData: function(myJSON) {
82+
const formatter = new JSONFormatter(myJSON);
83+
document.body.appendChild(formatter.render());
84+
},
85+
}
86+
});

services/static-webserver/client/source/resource/jsonFormatter/json-formatter-2.5.23.css

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)