diff --git a/.settings/.gitignore b/.settings/.gitignore new file mode 100644 index 0000000..0612b9b --- /dev/null +++ b/.settings/.gitignore @@ -0,0 +1 @@ +/.jsdtscope diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..49c8cd4 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.JRE_CONTAINER \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..11006e2 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Global \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fe97a71..0519107 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ RUN apt update && apt install -y apache2 python3-pip RUN pip3 install jupyter_kernel_gateway RUN rm /var/www/html/index.html +COPY ./resources/apache2/000-default.conf /etc/apache2/sites-enabled/ + WORKDIR /var/www/html ADD ./notebook . diff --git a/notebook/author/author.html b/notebook/author/author.html index 1b6eaa6..58effa0 100644 --- a/notebook/author/author.html +++ b/notebook/author/author.html @@ -60,7 +60,13 @@
- +
diff --git a/notebook/author/css/author.css b/notebook/author/css/author.css index 2cd0616..f071cd1 100644 --- a/notebook/author/css/author.css +++ b/notebook/author/css/author.css @@ -6,7 +6,7 @@ body { } .std-border { - border: 1px solid lightgray; + border: 1px solid gray; border-radius: 5px; margin: 5px; } @@ -71,20 +71,35 @@ body { } } -.sty-navigation-panel { +.sty-navigation-block { flex: 15%; - max-height: 100%; + max-width: 80%; + height: 100%; + display: flex; + flex-direction: row; +} + +.sty-navigation-panel { + width: 100%; + height: 100%; display: flex; flex-direction: column; overflow: scroll; } +.sty-navigation-expansion { + width: 20px; + height: 100%; +} + .navigation-knot { max-width: 100%; } .sty-knot-panel { flex: 75%; + min-width: 20%; overflow: scroll; + height: 100%; } diff --git a/notebook/author/icons/icon-expand.svg b/notebook/author/icons/icon-expand.svg new file mode 100644 index 0000000..cb63171 --- /dev/null +++ b/notebook/author/icons/icon-expand.svg @@ -0,0 +1,76 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/notebook/author/icons/icon-retract.svg b/notebook/author/icons/icon-retract.svg new file mode 100644 index 0000000..7dd3cef --- /dev/null +++ b/notebook/author/icons/icon-retract.svg @@ -0,0 +1,76 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/notebook/author/js/dcc-author-server-address.js b/notebook/author/js/dcc-author-server-address.js index eeb6886..9b8fe06 100644 --- a/notebook/author/js/dcc-author-server-address.js +++ b/notebook/author/js/dcc-author-server-address.js @@ -1,4 +1,4 @@ (function() { - // DCCAuthorServer.serverAddress = "http://cloud.lis.ic.unicamp.br/case-notebook/v1/server/"; - DCCAuthorServer.serverAddress = "http://127.0.0.1:8888/"; -})(); \ No newline at end of file + DCCAuthorServer.serverAddress = "http://cloud.lis.ic.unicamp.br/case-notebook/latest/server/"; + //DCCAuthorServer.serverAddress = "http://127.0.0.1:8888/"; +})(); diff --git a/notebook/author/js/navigator.js b/notebook/author/js/navigator.js index 692f9ab..ad447f5 100644 --- a/notebook/author/js/navigator.js +++ b/notebook/author/js/navigator.js @@ -4,40 +4,25 @@ class Navigator { -/* -async _checkMiniatures() { - const knotPanel = document.querySelector("#knot-panel"); - - if (this._knots != null) { - for (let kn in this._knots) { - if (this._knots[kn].render && !this._knots[kn].miniature) { - let htmlKnot = await this._author._generateHTML(kn); - knotPanel.innerHTML = htmlKnot; - let promiseCapture = html2canvas(knotPanel, {scale: 0.2}); - this._knots[kn].miniature = await promiseCapture; - // this._knots[kn].miniature = canvas.toDataURL(); - } - } - } -} -*/ - constructor() { - this._mountTreeClicked = this._mountTreeClicked.bind(this); + this.expandClicked = this.expandClicked.bind(this); + window.messageBus.ext.subscribe("control/navigator/expand", this.expandClicked); + this.retractClicked = this.retractClicked.bind(this); + window.messageBus.ext.subscribe("control/navigator/retract", this.retractClicked); } async mountPlainCase(author, knots) { this._author = author; this._knots = knots; this._navigationPanel = document.querySelector("#navigation-panel"); + this._knotPanel = document.querySelector("#knot-panel"); + + this._navigationPanel.innerHTML = ""; + document.querySelector("#navigation-block").style.flex = "15%"; + this._knotPanel.style.flex = "75%"; this._capsule = await window.messageBus.ext.request("capsule/knot/get", "", "capsule/knot"); - let openTree = this._createKnotEntry("_opentree_"); - openTree.innerHTML = "

Gordon>

"; - openTree.addEventListener("click", this._mountTreeClicked); - this._navigationPanel.appendChild(openTree); - for (let kn in this._knots) { if (this._knots[kn].type == "knot") { let miniature = this._createKnotEntry("mini-" + kn.replace(/\./g, "_")); @@ -75,8 +60,16 @@ async _createMiniature(kn) { return iframe; } -async _mountTreeClicked(event) { +async expandClicked(topic, message) { this.mountTreeCase(this._author, this._knots); + document.querySelector("#button-expand").style.display = "none"; + document.querySelector("#button-retract").style.display = "initial"; +} + +async retractClicked(topic, message) { + this.mountPlainCase(this._author, this._knots); + document.querySelector("#button-expand").style.display = "initial"; + document.querySelector("#button-retract").style.display = "none"; } async mountTreeCase(author, knots) { @@ -88,8 +81,8 @@ async mountTreeCase(author, knots) { this._capsule = await window.messageBus.ext.request("capsule/knot/get", "", "capsule/knot"); this._navigationPanel.innerHTML = ""; + document.querySelector("#navigation-block").style.flex = "80%"; this._knotPanel.style.flex = "20%"; - this._navigationPanel.style.flex = "80%"; // building the visual tree let tree = {level: 0, children: []}; @@ -100,6 +93,7 @@ async mountTreeCase(author, knots) { for (let k in this._knots) { if (!this._knots[k].categories || this._knots[k].categories.indexOf("note") < 0) { let newKnot = {id: "mini-" + k.replace(/\./g, "_"), + knotid: k, title: this._knots[k].title, level: this._knots[k].level}; if (previousKnot == null || newKnot.level == previousKnot.level) @@ -129,11 +123,6 @@ async mountTreeCase(author, knots) { console.log(tree); // set the dimensions and margins of the graph - /* - let margin = {top: 10, right: 10, bottom: 10, left: 10}, - width = 2048 - margin.left - margin.right, - height = 1200 - margin.top - margin.bottom; - */ let margin = {top: 10, right: 10, bottom: 10, left: 10}, width = tree.width, height = tree.height; @@ -154,16 +143,6 @@ async mountTreeCase(author, knots) { var root = d3.hierarchy(tree).sum(function(d){return 1}); - /* - d3.treemap() - .size([width, height]) - .tile(d3.treemapSliceDice) - .paddingTop(28) - .paddingRight(7) - .paddingInner(3) - (root); - */ - let gs = svg .selectAll("rect") @@ -171,14 +150,6 @@ async mountTreeCase(author, knots) { .enter() .append("g"); - /* - gs.append("rect") - .attr('x', function (d) { return d.x0; }) - .attr('y', function (d) { return d.y0; }) - .attr('width', function (d) { return d.x1 - d.x0; }) - .attr('height', function (d) { return d.y1 - d.y0; }) - .style("opacity", function(d){ return 0.5}); - */ gs.append("rect") .attr("x", function (d) { return d.data.x; }) .attr("y", function (d) { return d.data.y; }) @@ -186,15 +157,6 @@ async mountTreeCase(author, knots) { .attr("height", function (d) { return d.data.height; }) .style("opacity", function(d){ return 0.5}); - /* - gs.append("foreignObject") - .attr('x', function (d) { return d.x0; }) - .attr('y', function (d) { return d.y0; }) - .attr("id", function(d){ return d.data.id; }) - .attr("width", function (d) { return d.x1 - d.x0; }) - .attr("height", function (d) { return d.y1 - d.y0; }); - */ - gs.append("foreignObject") .attr("x", function (d) { return d.data.x; }) .attr("y", function (d) { return d.data.y + d.data.titleSize; }) @@ -202,29 +164,26 @@ async mountTreeCase(author, knots) { .attr("width", function (d) { return d.data.width; }) .attr("height", function (d) { return d.data.height; }); - /* - svg - .selectAll("text") - .data(root.descendants().filter(function(d){return d.depth>=1})) - .enter() - .append("text") - .attr("x", function(d){ return d.x0+5}) - .attr("y", function(d){ return d.y0+20}) - .text(function(d){ return d.data.title; }) - .attr("font-size", function(d) {return ((4-d.data.level) * 10) + "px"}) - .attr("fill", "white"); - */ - - svg - .selectAll("text") + svg.selectAll("text") .data(root.descendants().filter(function(d){return d.depth>=1})) .enter() .append("text") + .attr("id", function(d) {return "t_" + d.data.id}) .attr("x", function(d){ return d.data.x + 5}) .attr("y", function(d){ return d.data.y + 20}) .text(function(d){ return d.data.title; }) .attr("font-size", function(d) {return d.data.titleSize + "px"}) - .attr("fill", "white"); + .attr("fill", "white") + .attr("cursor", "pointer") + .on("click", function(d) {window.messageBus.ext.publish("knot/" + d.data.knotid + "/selected")}) + .on("mouseover", function(d) { + let t = document.querySelector("#t_" + d.data.id); + t.removeChild(t.firstChild); + t.innerHTML = d.data.title + "[+]"}) + .on("mouseout", function(d) { + let t = document.querySelector("#t_" + d.data.id); + t.removeChild(t.firstChild); + t.innerHTML = d.data.title}); for (let kn in this._knots) { if (this._knots[kn].render) { diff --git a/notebook/cases/case000-report/case.md b/notebook/cases/case000-report/case.md deleted file mode 100644 index 7950891..0000000 --- a/notebook/cases/case000-report/case.md +++ /dev/null @@ -1,3 +0,0 @@ -# Case Report (start,report) # -Report: - diff --git a/notebook/cases/case000-report/html/css/player.css b/notebook/cases/case000-report/html/css/player.css deleted file mode 100644 index 77f2fa6..0000000 --- a/notebook/cases/case000-report/html/css/player.css +++ /dev/null @@ -1,68 +0,0 @@ -@charset "UTF-8"; - -body { - font-family: "Trebuchet MS", Helvetica, sans-serif; - font-size: 14pt; -} - -.std-border { - border: 1px solid lightgray; - border-radius: 5px; - margin: 5px; -} - -.sty-main-panel { - /* the main box (body) occupies all the visible area */ - position: absolute; - left: 0px; - right: 0px; - top: 0px; - bottom: 0px; - - /* eliminate margins etc. */ - margin: 0px; - padding: 0px; - border-width: 0px; - - display: flex; - flex-direction: column; -} - -.sty-control-panel { - flex: 10%; - max-height: 48px; - display: flex; - flex-direction: row; -} - -.control-button { - flex: 10%; - max-width: 48px; - max-height: 48px; - margin-right: 10px; -} - -.sty-work-panel { - flex: 90%; - height: 90%; - max-height: 90%; - height: 100%; - display: flex; -} - -@media (orientation: landscape) { - .work-panel { - flex-direction: row; - } -} - -@media (orientation: portrait) { - .work-panel { - flex-direction: column; - } -} - -.sty-knot-panel { - flex: 90%; - max-height: 100%; -} diff --git a/notebook/cases/case000-report/html/css/presentation.css b/notebook/cases/case000-report/html/css/presentation.css deleted file mode 100644 index 274e255..0000000 --- a/notebook/cases/case000-report/html/css/presentation.css +++ /dev/null @@ -1,33 +0,0 @@ -@charset "UTF-8"; - -/* Player Panel */ -.sty-player-panel { - flex: 10%; - max-height: 100%; - display: flex; - flex-direction: column; - overflow: hidden; -} - -.player-item { - max-width: 100%; -} - -/* Knot Rendering */ - -h1 { - text-align: center; -} - -.alert-message { - font-size: 20pt; - color: blue; - font-weight: bold; -} - -.central-buttons { - display: flex; - flex-direction: row; - max-width: 100%; - justify-content: center; -} \ No newline at end of file diff --git a/notebook/cases/case000-report/html/css/templates.css b/notebook/cases/case000-report/html/css/templates.css deleted file mode 100644 index d5adccd..0000000 --- a/notebook/cases/case000-report/html/css/templates.css +++ /dev/null @@ -1,110 +0,0 @@ -@charset "UTF-8"; - -/* Panel Left Picture (template) */ -/*********************************/ - -.panel-left-pict { - display: flex; - flex-direction: row; - flex: 100%; - max-height: 100%; - width: 100%; -} - -.panel-left-pict-image { - /* - flex-basis: auto; - max-height: 100%; - width: auto; - */ -} - -.panel-left-pict-image img { - max-height: 100%; -} - -.panel-left-pict-text { - /* flex: 70%; */ -} - -/* Presentation (template) */ -/***************************/ - -.template-presentation { - display: flex; - flex-direction: column; - font-size: 20pt; - width: 100%; -} - -.template-presentation img, .template-presentation dcc-trigger { - display: block; - margin-left: auto; - margin-right: auto; - width: 50%; -} - -/* Tablet (template) */ -/*********************/ - -.template-tablet { - width: 100%; - height: 100%; - - position: relative; - animation-name: template-tablet-displacement; - animation-duration: 2s; - background-image: url(../images/tablet.svg); - background-repeat: no-repeat; - background-size: 100% 100%; -} - -@keyframes template-tablet-displacement { - from {left: 100%;} - to {left: 0%;} -} - -.template-tablet-inside { - display: flex; - flex-direction: column; - font-size: 20pt; - width: auto; - height: 90%; - padding: 4% 15% 0% 10%; - overflow: scrool; -} - -.template-tablet-inside img, .template-tablet-inside dcc-trigger { - display: block; - margin-left: auto; - margin-right: auto; - width: 50%; -} - -/* Selector (template) */ -/***********************/ - -.template-selector { - width: 100%; - height: 100%; - - background-image: url(../images/tablet.svg); - background-repeat: no-repeat; - background-size: 100% 100%; -} - -.template-selector-inside { - width: auto; - height: 90%; - - padding: 4% 15% 0% 10%; - overflow: scrool; - font-size: 12pt; -} - -.template-selector-inside img, .template-selector-inside dcc-trigger { - display: block; - margin-left: auto; - margin-right: auto; - width: 50%; -} diff --git a/notebook/cases/case000-report/html/images/bubble-landscape.png b/notebook/cases/case000-report/html/images/bubble-landscape.png deleted file mode 100644 index 2836a26..0000000 Binary files a/notebook/cases/case000-report/html/images/bubble-landscape.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/bubble-portrait.png b/notebook/cases/case000-report/html/images/bubble-portrait.png deleted file mode 100644 index f3e8564..0000000 Binary files a/notebook/cases/case000-report/html/images/bubble-portrait.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/call-the-supervisor.svg b/notebook/cases/case000-report/html/images/call-the-supervisor.svg deleted file mode 100644 index 8e8f196..0000000 --- a/notebook/cases/case000-report/html/images/call-the-supervisor.svg +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/notebook/cases/case000-report/html/images/doctor-icon.png b/notebook/cases/case000-report/html/images/doctor-icon.png deleted file mode 100644 index 3b373e0..0000000 Binary files a/notebook/cases/case000-report/html/images/doctor-icon.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/doctor.png b/notebook/cases/case000-report/html/images/doctor.png deleted file mode 100644 index a8c9ec3..0000000 Binary files a/notebook/cases/case000-report/html/images/doctor.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/entrance.jpg b/notebook/cases/case000-report/html/images/entrance.jpg deleted file mode 100644 index 1dd4be7..0000000 Binary files a/notebook/cases/case000-report/html/images/entrance.jpg and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/generate-hypothesis.svg b/notebook/cases/case000-report/html/images/generate-hypothesis.svg deleted file mode 100644 index 57d3183..0000000 --- a/notebook/cases/case000-report/html/images/generate-hypothesis.svg +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/notebook/cases/case000-report/html/images/icon-back.svg b/notebook/cases/case000-report/html/images/icon-back.svg deleted file mode 100644 index 63a7be8..0000000 --- a/notebook/cases/case000-report/html/images/icon-back.svg +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/notebook/cases/case000-report/html/images/jacinto-icon.png b/notebook/cases/case000-report/html/images/jacinto-icon.png deleted file mode 100644 index 1662c3c..0000000 Binary files a/notebook/cases/case000-report/html/images/jacinto-icon.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/jacinto.png b/notebook/cases/case000-report/html/images/jacinto.png deleted file mode 100644 index 4f4a65f..0000000 Binary files a/notebook/cases/case000-report/html/images/jacinto.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/mono-slide.svg b/notebook/cases/case000-report/html/images/mono-slide.svg deleted file mode 100644 index 526a6ea..0000000 --- a/notebook/cases/case000-report/html/images/mono-slide.svg +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - image/svg+xml - - - - - Openclipart - - - - - - - - - - - diff --git a/notebook/cases/case000-report/html/images/more-information.svg b/notebook/cases/case000-report/html/images/more-information.svg deleted file mode 100644 index 637071c..0000000 --- a/notebook/cases/case000-report/html/images/more-information.svg +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/notebook/cases/case000-report/html/images/nurse-icon.png b/notebook/cases/case000-report/html/images/nurse-icon.png deleted file mode 100644 index 54bbf99..0000000 Binary files a/notebook/cases/case000-report/html/images/nurse-icon.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/nurse.png b/notebook/cases/case000-report/html/images/nurse.png deleted file mode 100644 index 3e57884..0000000 Binary files a/notebook/cases/case000-report/html/images/nurse.png and /dev/null differ diff --git a/notebook/cases/case000-report/html/images/tablet.svg b/notebook/cases/case000-report/html/images/tablet.svg deleted file mode 100644 index efb362a..0000000 --- a/notebook/cases/case000-report/html/images/tablet.svg +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/notebook/cases/case000-report/html/index.html b/notebook/cases/case000-report/html/index.html deleted file mode 100644 index 20059c0..0000000 --- a/notebook/cases/case000-report/html/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Player - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/README.md b/notebook/cases/case000-report/html/js/README.md deleted file mode 100644 index 0540e45..0000000 --- a/notebook/cases/case000-report/html/js/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Message Paths in the Bus - -## Persisted Messages - -All the internal paths are mapped to the external paths prefixing the path by: `/execution/`, where `` is the id of the case instance that is being executed. - -### Entity: `dcc-input` -* `set ` \[`/dcc-input/set/`\] - Notifies the input of a value by the user related to a ``. - -## Messages Not Persisted - -Messages to coordinate DCCs. - -### Entity: `dcc-block` - -Operations: -* `get xstyle` \[`/dcc-block/get/xstyle`\] - Requests to a DCC Styler the styling policy. - - return: \[`/dcc-block/xstyle`\] - one of the following values: - * `in ` - default style defined inside the DCC; - * `none` - no style defined; - * `out` - style defined externally. - -### Entity: `dcc-state-selector` - -Operations: -* `get states` \[`/dcc-state-selector/get/states`\] - Requests for an upper level DCC (e.g., an aggregattor DCC) or a group coordinator DCC the set of possible states present in the selector. - - return: \[`/dcc-state-selector/states`\] - List of states separated by commas. diff --git a/notebook/cases/case000-report/html/js/bus.js b/notebook/cases/case000-report/html/js/bus.js deleted file mode 100644 index 50b9e9b..0000000 --- a/notebook/cases/case000-report/html/js/bus.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Bus - */ - -class MessageBus { - constructor(externalized) { - this._externalized = externalized; - this._listeners = []; - } - - subscribe(topic, callback) { - let status = true; - - // Topic Filter: transform wildcards in regular expressions - if (topic.indexOf("+") > 0 || topic.indexOf("#") > 0) { - const reTopic = topic.replace("/", "\\/") - .replace("+", "\\w+") - .replace("#", "[\\w\\/]+"); - this._listeners.push({topic: topic, - regexp: new RegExp(reTopic), - callback: callback}); - - } else - this._listeners.push({topic: topic, - callback: callback}); - - return status; - } - - unsubscribe(topic, callback) { - let found = false; - for (let l = 0; l < this._listeners.length && !found; l++) - if (this._listeners[l].topic == topic && - this._listeners[l].callback == callback) { - this._listeners.splice(l, 1); - found = true; - } - } - - publish(topic, message) { - for (let l in this._listeners) - if (this.matchTopic(l, topic)) - this._listeners[l].callback(topic, message); - } - - /* Checks if this topic has a subscriber */ - hasSubscriber(topic) { - let hasSub = false; - for (let l = 0; !hasSub && l < this._listeners.length; l++) - hasSub = this.matchTopic(l, topic); - return hasSub; - } - - matchTopic(index, topic) { - let matched = false; - if (this._listeners[index].regexp) { - const matchStr = this._listeners[index].regexp.exec(topic); - if (matchStr != null && matchStr[0] === topic) - matched = true; - } else if (this._listeners[index].topic === topic) - matched = true; - return matched; - } -} - -(function() { - window.messageBus = { - int: new MessageBus(false), - ext: new MessageBus(true) - }; -})(); \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/case.js b/notebook/cases/case000-report/html/js/case.js deleted file mode 100644 index c88f894..0000000 --- a/notebook/cases/case000-report/html/js/case.js +++ /dev/null @@ -1 +0,0 @@ -(function() { DCCPlayerServer.playerObj ={"id":"case001-development","knots":{"Case Report":{"type":"knot","title":"Case Report","categories":["start","report"],"level":1,"_source":"# Case Report (start,report) #\nReport:\n\n","annotations":[],"content":[{"type":"text","content":"\nReport:\n\n","seq":2}]}},"start":"Case Report"}})(); \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/dcc-player-server-proxy.js b/notebook/cases/case000-report/html/js/dcc-player-server-proxy.js deleted file mode 100644 index f00d742..0000000 --- a/notebook/cases/case000-report/html/js/dcc-player-server-proxy.js +++ /dev/null @@ -1,149 +0,0 @@ -/** - * - */ - -class DCCPlayerServer { - /* - * Case services - * ************* - */ - - getCaseId() { - return DCCPlayerServer.playerObj.id; - } - - getStartKnot() { - return DCCPlayerServer.playerObj.start; - } - - /* - * Running Case services - * ********************* - */ - - generateRunningCase() { - const caseid = this.getCaseId(); - const profile = this.getCurrentProfile(); - - const currentDateTime = new Date(); - const casekey = profile.id + "#" + caseid + "#" + this.generateUID(); - profile.cases.push(casekey); - this.setProfile(profile); - this.setRunningCasekey(casekey); - - const casetrack = { - userid : profile.id, - caseid : caseid, - start : currentDateTime.toJSON(), - inputs : {}, - route : [] - }; - this.setCaseInstance(casekey, casetrack); - } - - generateUID() { - function s4() { - return Math.floor((1 + Math.random()) * 0x10000) - .toString(16) - .substring(1); - } - const currentDateTime = new Date(); - return currentDateTime.toJSON() + "-" + - s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); - } - - getRunningCasekey() { - return localStorage.getItem(DCCPlayerServer.storePrefix + "running-case"); - } - - resetRunningCase() { - localStorage.removeItem(DCCPlayerServer.storePrefix + "running-case"); - } - - setRunningCasekey(casekey) { - localStorage.setItem(DCCPlayerServer.storePrefix + "running-case", casekey); - } - - getCaseInstance(casekey) { - return JSON.parse(localStorage.getItem(DCCPlayerServer.storePrefix + casekey)); - } - - setCaseInstance(casekey, caseInstance) { - localStorage.setItem(DCCPlayerServer.storePrefix + casekey, JSON.stringify(caseInstance)); - } - - trackRoute(item) { - const casekey = this.getRunningCasekey(); - if (casekey != null) { - let casetrack = this.getCaseInstance(casekey); - this._addTrack(casetrack, item); - this.setCaseInstance(casekey, casetrack); - } - } - - recordInput(variable, value) { - const casekey = this.getRunningCasekey(); - if (casekey != null) { - let casetrack = this.getCaseInstance(casekey); - this._addTrack(casetrack, "#input(" + variable + "):" + value); - casetrack.inputs[variable] = value; - this.setCaseInstance(casekey, casetrack); - } - } - - _addTrack(casetrack, item) { - const currentDateTime = new Date(); - casetrack.route.push(item + "," + currentDateTime.toJSON()); - } - - /* - * User services - * ************* - */ - - getCurrentUser() { - return localStorage.getItem(DCCPlayerServer.storePrefix + "current-user"); - } - - setCurrentUser(userId) { - localStorage.setItem(DCCPlayerServer.storePrefix + "current-user", userId); - } - - getUsers() { - let usersStr = localStorage.getItem(DCCPlayerServer.storePrefix + "users"); - return (usersStr == null) ? {ids: []} : JSON.parse(usersStr); - } - - getCurrentProfile() { - return this.getProfile(this.getCurrentUser()); - } - - getProfile(userid) { - return JSON.parse(localStorage.getItem(DCCPlayerServer.storePrefix + "profile-" + userid)); - } - - addProfile(profile) { - this.setProfile(profile); - let users = this.getUsers(); - users.ids.push(profile.id); - localStorage.setItem(DCCPlayerServer.storePrefix + "users", JSON.stringify(users)); - } - - setProfile(profile) { - localStorage.setItem(DCCPlayerServer.storePrefix + "profile-" + profile.id, JSON.stringify(profile)); - } - - /* - * General services - * **************** - * provisory - */ - getPlayerObj() { - return DCCPlayerServer.playerObj; - } - -} - -(function() { - DCCPlayerServer.storePrefix = "casenote_"; -})(); \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/dccs/dcc-base.js b/notebook/cases/case000-report/html/js/dccs/dcc-base.js deleted file mode 100644 index 6f51b8f..0000000 --- a/notebook/cases/case000-report/html/js/dccs/dcc-base.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * DCC which is the basis of all components - */ - -class DCCBase extends HTMLElement { -} \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/dccs/dcc-block.js b/notebook/cases/case000-report/html/js/dccs/dcc-block.js deleted file mode 100644 index 7be7023..0000000 --- a/notebook/cases/case000-report/html/js/dccs/dcc-block.js +++ /dev/null @@ -1,168 +0,0 @@ -/* Block DCC - * - * xstyle - controls the behavior of the style - * * "in" or not defined -> uses the internal trigger-button style - * * "none" -> apply a minimal styling (just changes cursor to pointer) - * * "out" -> apply an style externally defined with the name "trigger-button-template" -**************************************************************************/ - -class DCCBlock extends DCCBase { - constructor() { - super(); - - this._pendingRequests = 0; - - this.defineXstyle = this.defineXstyle.bind(this); - this.defineLocation = this.defineLocation.bind(this); - this._renderInterface = this._renderInterface.bind(this); - } - - connectedCallback() { - if (!this.hasAttribute("xstyle") && window.messageBus.ext.hasSubscriber("dcc/request/xstyle")) { - window.messageBus.ext.subscribe("dcc/xstyle/" + this.id, this.defineXstyle); - window.messageBus.ext.publish("dcc/request/xstyle", this.id); - this._pendingRequests++; - } - if (!this.hasAttribute("location") && - window.messageBus.ext.hasSubscriber("dcc/request/location")) { - window.messageBus.ext.subscribe("dcc/location/" + this.id, this.defineLocation); - window.messageBus.ext.publish("dcc/request/location", this.id); - this._pendingRequests++; - } - this._checkRender(); - } - - defineXstyle(topic, message) { - window.messageBus.ext.unsubscribe("dcc/xstyle/" + this.id, this.defineXstyle); - this.xstyle = message; - this._pendingRequests--; - this._checkRender(); - } - - defineLocation(topic, message) { - window.messageBus.ext.unsubscribe("dcc/location/" + this.id, this.defineLocation); - this.location = message; - this._pendingRequests--; - this._checkRender(); - } - - _checkRender() { - if (this._pendingRequests == 0) { - if (document.readyState === "complete") - this._renderInterface(); - else - window.addEventListener("load", this._renderInterface); - } - } - - /* Attribute Handling */ - - static get observedAttributes() { - return ["id", "label", "image", "location", "xstyle"]; - } - - get id() { - return this.getAttribute("id"); - } - - set id(newValue) { - this.setAttribute("id", newValue); - } - - get label() { - return this.getAttribute("label"); - } - - set label(newValue) { - this.setAttribute("label", newValue); - } - - get image() { - return this.getAttribute("image"); - } - - set image(newValue) { - this.setAttribute("image", newValue); - } - - get location() { - return this.getAttribute("location"); - } - - set location(newValue) { - this.setAttribute("location", newValue); - } - - get xstyle() { - return this.getAttribute("xstyle"); - } - - set xstyle(newValue) { - this.setAttribute("xstyle", newValue); - } - - /* Rendering */ - - elementTag() { - return DCCBlock.elementTag; - } - - _renderInterface() { - let presentation = null; - if (!this.hasAttribute("xstyle")) - this.xstyle = "in"; - - let render; - switch (this.xstyle) { - case "in" : if (this.hasAttribute("image")) - render = "image-style" - else - render = "regular-style" - break; - case "none": render = ""; - break; - case "out-image": - case "out": render = this.elementTag() + "-template"; - break; - default: render = this.xstyle; - } - - if (this.xstyle.startsWith("out") && - this.hasAttribute("location") && this.location != "#in") { - presentation = document.querySelector("#" + this.location); - this._injectDCC(presentation, render); - let wrapper = document.querySelector("#" + this.location + "-wrapper"); - if (wrapper != null) { - if (wrapper.style.display) // html - delete wrapper.style.display; - if (wrapper.getAttribute("visibility")) // svg - delete wrapper.removeAttribute("visibility"); - } - } else { - let template = document.createElement("template"); - template.innerHTML = this._generateTemplate(render); - - let host = this; - if (this.xstyle == "in" || this.xstyle == "none") - host = this.attachShadow({mode: "open"}); - host.appendChild(template.content.cloneNode(true)); - presentation = host.querySelector("#presentation-dcc"); - } - return presentation; - } - - _computeTrigger() { - if (this.hasAttribute("label") || this.hasAttribute("action")) { - let eventLabel = (this.hasAttribute("action")) ? this.action : "navigate/trigger"; - let message = (this.hasAttribute("link")) ? this.link : this.label; - window.messageBus.ext.publish(eventLabel, message); - } - } -} - -(function() { - DCCBlock.elementTag = "dcc-block"; - - customElements.define(DCCBlock.elementTag, DCCBlock); - -})(); \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/dccs/dcc-character.js b/notebook/cases/case000-report/html/js/dccs/dcc-character.js deleted file mode 100644 index 96caf3d..0000000 --- a/notebook/cases/case000-report/html/js/dccs/dcc-character.js +++ /dev/null @@ -1,178 +0,0 @@ -/* Character DCC - **************/ -class DCCCharacter extends DCCBase { - connectedCallback() { - let templateHTML = - ` -
-
- [images] -
-
-
-
Name:
-
[character]
-
-
-
Role:
-
[role]
-
-
-
Description:
-
[description]
-
-
-
`; - - templateHTML = templateHTML.replace("[images]", this._imageElements()) - .replace("[character]", this.character) - .replace("[role]", this.role) - .replace("[description]", this.description); - - // building the template - const template = document.createElement("template"); - template.innerHTML = templateHTML; - let shadow = this.attachShadow({mode: "open"}); - shadow.appendChild(template.content.cloneNode(true)); - - this._presentation = shadow.querySelector("#presentation-dcc"); - this._recordImages = shadow.querySelector("#record-images"); - } - - /* Properties - **********/ - - static get observedAttributes() { - return ["image", "character", "role", "description"]; - } - - get image() { - return this.getAttribute("image"); - } - - set image(newValue) { - this.setAttribute("image", newValue); - } - - get character() { - return this.getAttribute("character"); - } - - set character(newValue) { - this.setAttribute("character", newValue); - } - - get role() { - return this.getAttribute("role"); - } - - set role(newValue) { - this.setAttribute("role", newValue); - } - - get description() { - return this.getAttribute("description"); - } - - set description(newValue) { - this.setAttribute("description", newValue); - } - - _imageElements() { - let extension = this.image.lastIndexOf("."); - let icon = this.image.substring(0, extension) + "-icon" + this.image.substring(extension); - - return "
" + - "
"; - } - - /* Editable Component */ - editDCC() { - if (!DCCCharacter.editableCode) { - editableDCCCharacter(); - DCCCharacter.editableCode = true; - } - this._editDCC(); - } - - editImage() { - this._editImage(); - } -} - -(function() { - DCCCharacter.editableCode = false; - customElements.define("dcc-character", DCCCharacter); -})(); \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/dccs/dcc-dialog.js b/notebook/cases/case000-report/html/js/dccs/dcc-dialog.js deleted file mode 100644 index 17518c5..0000000 --- a/notebook/cases/case000-report/html/js/dccs/dcc-dialog.js +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Talk DCC - * - * xstyle = out -> in the outer space it first looks for the specific name and then for the generic "character" name - */ -class DCCTalk extends DCCBase { - constructor() { - super(); - - this._pendingRequests = 0; - - this.defineSequence = this.defineSequence.bind(this); - this.defineXstyle = this.defineXstyle.bind(this); - this._renderInterface = this._renderInterface.bind(this); - } - - connectedCallback() { - if (window.messageBus.ext.hasSubscriber("dcc/request/talk-sequence")) { - window.messageBus.ext.subscribe("dcc/talk-sequence/" + this.id, this.defineSequence); - window.messageBus.ext.publish("dcc/request/talk-sequence", this.id); - this._pendingRequests++; - } - if (!this.hasAttribute("xstyle") && window.messageBus.ext.hasSubscriber("dcc/request/xstyle")) { - window.messageBus.ext.subscribe("dcc/xstyle/" + this.id, this.defineXstyle); - window.messageBus.ext.publish("dcc/request/xstyle", this.id); - this._pendingRequests++; - } - this._checkRender(); - } - - defineSequence(topic, message) { - window.messageBus.ext.unsubscribe("dcc/talk-sequence/" + this.id, this.defineSequence); - this.sequence = message; - this._pendingRequests--; - this._checkRender(); - } - - defineXstyle(topic, message) { - window.messageBus.ext.unsubscribe("dcc/xstyle/" + this.id, this.defineXstyle); - this.xstyle = message; - this._pendingRequests--; - this._checkRender(); - } - - _checkRender() { - if (this._pendingRequests == 0) { - if (document.readyState === "complete") - this._renderInterface(); - else - window.addEventListener("load", this._renderInterface); - } - } - - /* - * Property handling - */ - - static get observedAttributes() { - return ["sequence", "character", "speech", "xstyle"]; - } - - get sequence() { - return this.getAttribute("sequence"); - } - - set sequence(newValue) { - this.setAttribute("sequence", newValue); - } - - get character() { - return this.getAttribute("character"); - } - - set character(newValue) { - this.setAttribute("character", newValue); - } - - get speech() { - return this.getAttribute("speech"); - } - - set speech(newValue) { - this.setAttribute("speech", newValue); - } - - get xstyle() { - return this.getAttribute("xstyle"); - } - - set xstyle(newValue) { - this.setAttribute("xstyle", newValue); - } - - /* Rendering */ - - _renderInterface() { - if (this.hasAttribute("xstyle") && this.xstyle == "out") { - let character = this._injectTalkElement("#talk-character"); - if (character != null) - character.innerHTML = this.character; - - // works for SVG but not for HTML - let image = this._injectTalkElement("#talk-image"); - if (image != null) - image.setAttributeNS("http://www.w3.org/1999/xlink", "href", - "images/" + this.character.replace(/ /igm, "_").toLowerCase() + ".png"); - - if (this.hasAttribute("speech")) { - let speech = this._injectTalkElement("#talk-speech"); - if (speech != null) - speech.innerHTML = this.speech; - } - } else { - let charImg = "images/" + this.character.toLowerCase() - .replace(/ /igm, "_") + ".png"; - let template = document.createElement("template"); - - const speech = (this.hasAttribute("speech")) ? this.speech : ""; - template.innerHTML = DCCTalk.templateElements.replace("[image]",charImg) - .replace("[character]", this.character) - .replace("[speech]", speech); - this._shadow = this.attachShadow({mode: "open"}); - this._shadow.appendChild(template.content.cloneNode(true)); - this._presentation = this._shadow.querySelector("#presentation-dcc"); - } - } - - _injectTalkElement(prefix) { - const charLabel = this.character.replace(/ /igm, "_").toLowerCase(); - - // search sequence: by name, by number, generic - let target = document.querySelector(prefix + "-" + charLabel); - if (target == null && this.hasAttribute("sequence")) - target = document.querySelector(prefix + "-" + this.sequence); - if (target == null) - target = document.querySelector(prefix); - - return target; - } -} - -class DCCDialog extends DCCBase { - constructor() { - super(); - this._sequence = 0; - this.requestSequence = this.requestSequence.bind(this); - } - - connectedCallback() { - window.messageBus.ext.subscribe("dcc/request/talk-sequence", this.requestSequence); - } - - disconnectedCallback() { - window.messageBus.ext.unsubscribe("dcc/request/talk-sequence", this.requestSequence); - } - - requestSequence(topic, message) { - this._sequence++; - window.messageBus.ext.publish("dcc/talk-sequence/" + message, this._sequence); - } -} - -(function() { - DCCTalk.templateStyle = - ` -
- `; - - DCCTalk.templateElements = - `
-
[speech]
`; - - DCCDialog.editableCode = false; - customElements.define("dcc-dialog", DCCDialog); - DCCTalk.editableCode = false; - customElements.define("dcc-talk", DCCTalk); -})(); \ No newline at end of file diff --git a/notebook/cases/case000-report/html/js/dccs/dcc-input.js b/notebook/cases/case000-report/html/js/dccs/dcc-input.js deleted file mode 100644 index 6db7aef..0000000 --- a/notebook/cases/case000-report/html/js/dccs/dcc-input.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Input DCC - */ - - -class DCCInput extends DCCBlock { - constructor() { - super(); - this.submitInput = this.submitInput.bind(this); - this.inputTyped = this.inputTyped.bind(this); - this.inputChanged = this.inputChanged.bind(this); - } - - connectedCallback() { - super.connectedCallback(); - - window.messageBus.ext.publish("/var/" + this.variable + "/input/ready", DCCInput.elementTag); - - window.messageBus.ext.subscribe("get-input/" + this.variable, this.submitInput); - window.messageBus.ext.subscribe("checkout", this.submitInput); - } - - /* - * Redesign - */ - submitInput(topic, message) { - /* - const value = document.querySelector("#" + this.variable).value; - window.messageBus.ext.publish("input/" + this.variable, value); - */ - } - - /* - * Property handling - */ - - static get observedAttributes() { - return DCCBlock.observedAttributes.concat(["variable", "rows", "vocabulary"]); - } - - get variable() { - return this.getAttribute("variable"); - } - - set variable(newValue) { - this.setAttribute("variable", newValue); - } - - get rows() { - return this.getAttribute("rows"); - } - - set rows(newValue) { - this.setAttribute("rows", newValue); - } - - get vocabulary() { - return this.getAttribute("vocabulary"); - } - - set vocabulary(newValue) { - this.setAttribute("vocabulary", newValue); - } - - /* Event handling */ - - inputTyped() { - window.messageBus.ext.publish("/var/" + this.variable + "/typed", - {sourceType: DCCInput.elementTag, - value: this._inputVariable.value}); - } - - inputChanged() { - window.messageBus.ext.publish("/var/" + this.variable + "/changed", - {sourceType: DCCInput.elementTag, - value: this._inputVariable.value}); - } - - /* Rendering */ - - elementTag() { - return DCCInput.elementTag; - } - - _injectDCC(presentation, render) { - presentation.innerHTML = this._generateTemplate(render); - this._inputVariable = presentation.querySelector("#" + this.variable); - this._inputVariable.addEventListener("input", this.inputTyped); - this._inputVariable.addEventListener("change", this.inputChanged); - } - - _generateTemplate(render) { - let elements = null; - if (this.hasAttribute("rows") && this.rows > 1) - elements = DCCInput.templateElements.area.replace("[rows]", this.rows) - .replace("[variable]", this.variable) - .replace("[render]", render); - else - elements = DCCInput.templateElements.text.replace("[variable]", this.variable) - .replace("[render]", render); - - return elements; - } -} - -(function() { - // temporary (size = 50) - DCCInput.templateElements = { - text: "", - area: "