Commit da5727d7 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[feature] Display application state

parent 35ac65e97de0
......@@ -12,6 +12,7 @@
<body>
<div id="root"></div>
<script type="text/javascript" src="main.js"></script></body>
<script id="main-script" type="text/javascript" src="main.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -452,6 +452,18 @@ class MainViewer {
while (root.hasChildNodes()) {
root.removeChild(root.lastChild);
}
let links = getAllNodes(document.head, "link");
for (var i = 0; i != links.length; i++) {
document.head.removeChild(links[i]);
}
let styles = getAllNodes(document.head, "style");
for (var i = 0; i != styles.length; i++) {
document.head.removeChild(styles[i]);
}
let scripts = getAllNodes(document.body, "script");
for (var i = 0; i != scripts.length; i++) {
if (scripts[i].id != "main-script") document.body.removeChild(scripts[i]);
}
this.render(root);
}
......@@ -467,6 +479,10 @@ class MainViewer {
sub.style.marginBottom = "5vh";
if (this.state.stateType == StateType.Loading) {
let style = document.createElement("link");
style.href = "bootstrap.min.css";
style.rel = "stylesheet";
document.head.appendChild(style);
let div = document.createElement("div");
div.classList.add("alert");
div.classList.add("alert-info");
......@@ -474,6 +490,10 @@ class MainViewer {
div.appendChild(document.createTextNode(this.state.message));
sub.appendChild(div);
} else if (this.state.stateType == StateType.Error) {
let style = document.createElement("link");
style.href = "bootstrap.min.css";
style.rel = "stylesheet";
document.head.appendChild(style);
let div = document.createElement("div");
div.classList.add("alert");
div.classList.add("alert-danger");
......@@ -481,14 +501,6 @@ class MainViewer {
div.appendChild(document.createTextNode(this.state.message));
sub.appendChild(div);
} else if (this.state.stateType == StateType.Displaying) {
let styles = getAllNodes(document.head, "style");
for (var i = 0; i != styles.length; i++) {
document.head.removeChild(styles[i]);
}
let scripts = getAllNodes(document.body, "script");
for (var i = 0; i != scripts.length; i++) {
document.body.removeChild(scripts[i]);
}
let descriptor = this.state.registry.descriptors[
this.state.rendering.viewId
];
......@@ -510,6 +522,10 @@ class MainViewer {
}
sub.appendChild(this.state.rendering.dom);
} else {
let style = document.createElement("link");
style.href = "bootstrap.min.css";
style.rel = "stylesheet";
document.head.appendChild(style);
let div = document.createElement("div");
div.classList.add("alert");
div.classList.add("alert-danger");
......
......@@ -80,7 +80,13 @@ module.exports = [
},
plugins: [
new CopyWebpackPlugin(
[{ from: "src/ldbrowser/index.html", to: "ldbrowser/index.html" }],
[
{ from: "src/ldbrowser/index.html", to: "ldbrowser/index.html" },
{
from: "node_modules/bootstrap/dist/css/bootstrap.min.css",
to: "ldbrowser/bootstrap.min.css"
}
],
{}
)
]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment