diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2018-09-07 00:32:51 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2018-09-07 00:32:51 +0200 |
commit | 78d7c8d75a5f55ab56dd018edc85ebce9aa033bb (patch) | |
tree | 2ad9da977667b79236cfdd827d0446a5bf9fea18 /src/public | |
download | Luxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.tar.gz Luxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.zip |
:construction: Add pre-v1 project
Because of some stupid mistakes with the repo, I decided to delete the
git history. Create a new, fresh repo, and move all the code there.
Since all this is pre-v1, everything is in a testing-phase anyways. So i
do not think we are going to feel the need for any history. The old repo
is renamed to Luxcena-Neo-Old, and will be there until i convince
myself i won't need the history.
Diffstat (limited to 'src/public')
-rw-r--r-- | src/public/app.js | 17 | ||||
-rw-r--r-- | src/public/app.scss | 9 | ||||
-rw-r--r-- | src/public/components/sidenav.js | 22 | ||||
-rw-r--r-- | src/public/js/general.js | 10 | ||||
-rw-r--r-- | src/public/js/index.js | 68 | ||||
-rw-r--r-- | src/public/js/logviewer.js | 64 | ||||
-rw-r--r-- | src/public/js/neo_ide.js | 4 | ||||
-rw-r--r-- | src/public/js/scripts.js | 71 | ||||
-rw-r--r-- | src/public/scss/general.scss | 44 | ||||
-rw-r--r-- | src/public/scss/neo_ide.scss | 254 | ||||
-rw-r--r-- | src/public/scss/scripts.scss | 35 | ||||
-rw-r--r-- | src/public/scss/setup.scss | 0 | ||||
-rw-r--r-- | src/public/scss/update.scss | 62 |
13 files changed, 660 insertions, 0 deletions
diff --git a/src/public/app.js b/src/public/app.js new file mode 100644 index 0000000..5e6b22b --- /dev/null +++ b/src/public/app.js @@ -0,0 +1,17 @@ +// General JavaScript +require ("./js/general")(); + +// Page-specific JavaScript +const pageName = document.getElementsByTagName("body")[0].id; +try { + require("./js/" + pageName)(); +} catch (error) { + console.log( + "Something went wrong when loading the js for this page...\n" + + "The pageName is \"" + pageName + "\".\n" + + "If it was excpected to get js for this page, please check the filename, and recompile webpack." + ); +} + +// Require all styles +require("./app.scss"); diff --git a/src/public/app.scss b/src/public/app.scss new file mode 100644 index 0000000..845d36a --- /dev/null +++ b/src/public/app.scss @@ -0,0 +1,9 @@ +// This file is probably not needed anymore, as all the files are loaded directly by our sass-loader +// General scss +@import "./scss/general.scss"; + +// Page-specific css +@import "./scss/scripts.scss"; +@import "./scss/neo_ide.scss"; +@import "./scss/setup.scss"; +@import "./scss/update.scss"; diff --git a/src/public/components/sidenav.js b/src/public/components/sidenav.js new file mode 100644 index 0000000..a024750 --- /dev/null +++ b/src/public/components/sidenav.js @@ -0,0 +1,22 @@ +module.exports = ` +<ul id="slide-out" class="sidenav sidenav-fixed"> + <li> + <div class="user-view"> + <div class="background"> + <img src="./logo/150h/Icon.png"> + </div> + <!--<a href="#!user"><img class="circle" src="https://picsum.photos/200/300/?random"></a> + <a href="#!name"><span class="white-text name">John Doe</span></a> + <a href="#!email"><span class="white-text email">Guest</span></a>--> + </div> + </li> + <li><div class="divider"></div></li> + <li><a class="waves-effect" href="/"><i class="material-icons">dashboard</i> Dashboard</a></li> + <li><a class="waves-effect" href="/scripts"><i class="material-icons">cloud</i> Scripts</a></li> + <li><a class="waves-effect" href="/logviewer"><i class="material-icons">timeline</i> LogViewer</a></li> + <li><div class="divider"></div></li> + <li><a class="subheader">Settings</a></li> + <li><a class="waves-effect" href="strip_setup"><i class="material-icons">straighten</i> Strip setup</a></li> + <li><a class="waves-effect" href="/settings"><i class="material-icons">settings</i> Settings</a></li> +</ul> +`;
\ No newline at end of file diff --git a/src/public/js/general.js b/src/public/js/general.js new file mode 100644 index 0000000..b0b04d2 --- /dev/null +++ b/src/public/js/general.js @@ -0,0 +1,10 @@ +let sidenav = require("../components/sidenav"); + +module.exports = () => { + const pageName = document.getElementsByTagName("body")[0].id; + if (pageName == "neo_ide") { return; } + + document.getElementById("sidenav").innerHTML = sidenav; + + M.AutoInit(); +}; diff --git a/src/public/js/index.js b/src/public/js/index.js new file mode 100644 index 0000000..5b67de2 --- /dev/null +++ b/src/public/js/index.js @@ -0,0 +1,68 @@ +let socket = io(); + +module.exports = () => { + M.AutoInit(); + setupSocket(); + + setInterval(() => { + socket.emit("GetGeneralInfo"); + }, 500); + + socket.emit("GetLog", {filter: "success error event", entryN: 10}); +}; + +function setupSocket() { + + socket.on("lastLogEntries", (entries) => { + let list = ""; + entries.forEach((entry) => { + list += "<tr><td>" + prettifyType(entry.type) + "</td><td>" + entry.time + "</td><td>" + entry.details + "</td></tr>"; + }); + + document.getElementById("log-table-body").innerHTML = list; + M.AutoInit(); + }); + + socket.on("newLogEntry", (entry) => { + // Start with parsing the new entry, no reason to select the DOM-element and stuff, if we are filtering out the entry anyway. + let type = entry.type; + if ( (type.toUpperCase() !== "SUCCESS") && (type.toUpperCase() !== "ERROR") && (type.toUpperCase() !== "EVENT") && (type.toUpperCase() !== "INFO")) { + return; + } + + let logTable = document.getElementById("log-table-body"); + + let LTable = logTable.rows.length; + logTable.deleteRow(LTable - 1); // Since length outputs a 1-based number + + let newEntry = logTable.insertRow(0); + newEntry.insertCell(0).innerHTML = prettifyType(entry.type); + newEntry.insertCell(1).innerHTML = entry.time; + newEntry.insertCell(2).innerHTML = entry.details; + M.AutoInit(); + newEntry.className = "newLogEntry"; + }); + + socket.on("generalInfo", (info) => { + if (info["scriptIsExited"]) { + document.getElementById("currentScript").innerHTML = info["currentScript"] + " (exited)"; + } else { + document.getElementById("currentScript").innerHTML = info["currentScript"]; + } + document.getElementById("uptime").innerHTML = info["uptime"] + " seconds"; + }); + +} + +function prettifyType(type) { + let prettyTable = { + "DEBUG": `<span class="tooltipped" data-position="top" data-tooltip="Debug-log">đ¸</span>`, + "INFO": `<span class="tooltipped" data-position="top" data-tooltip="Just some information">âšī¸</span>`, + "WARNING": `<span class="tooltipped" data-position="top" data-tooltip="A warning">â ī¸</span>`, + "EVENT": `<span class="tooltipped" data-position="top" data-tooltip="Event">âĄī¸</span>`, + "SUCCESS": `<span class="tooltipped" data-position="top" data-tooltip="Something exited successfully">â
</span>`, + "ERROR": `<span class="tooltipped" data-position="top" data-tooltip="Error">đ´</span>`, + "PYTHON": `<span class="tooltipped" data-position="top" data-tooltip="Output from user-script">đ</span>` + }; + return prettyTable[type]; +} diff --git a/src/public/js/logviewer.js b/src/public/js/logviewer.js new file mode 100644 index 0000000..d376196 --- /dev/null +++ b/src/public/js/logviewer.js @@ -0,0 +1,64 @@ +let socket = io(); + +module.exports = () => { + M.AutoInit(); + + socket.emit("GetLog", {filter: "success error event debug python info warning", entryN: 1000}); + socket.on("lastLogEntries", (entries) => { + M.toast({html: "Loading log-files..."}); + console.log("Log-entries received: " + entries.length); + let HTMLBasicTable = ""; + let HTMLAdvancedTable = ""; + let HTMLScriptTable = ""; + let HTMLRAWTable = ""; + + entries.forEach((entry) => { + let strHTML = "<tr><td>" + prettifyType(entry.type) + "</td><td>" + entry.time + "</td><td>" + entry.details + "</td></tr>"; + + if (entry.type === "SUCCESS") { HTMLBasicTable += strHTML; } + if (entry.type === "ERROR") { HTMLBasicTable += strHTML; } + if (entry.type === "EVENT") { HTMLBasicTable += strHTML; } + if (entry.type === "PYTHON") { HTMLScriptTable += strHTML; } + if (entry.type !== "PYTHON") { HTMLAdvancedTable += strHTML; } + + //HTMLRAWTable += entry.join(" "); + }); + + document.getElementById("log-table-basic").innerHTML = HTMLBasicTable; + document.getElementById("log-table-script").innerHTML = HTMLScriptTable; + document.getElementById("log-table-advanced").innerHTML = HTMLAdvancedTable; + //document.getElementById("log-table-raw").innerHTML = HTMLRAWTable; + + }); + + socket.on("newLogEntry", (entry) => { + if (entry.type === "SUCCESS") { appendEntryToTable("log-table-basic", entry); } + if (entry.type === "ERROR") { appendEntryToTable("log-table-basic", entry); } + if (entry.type === "EVENT") { appendEntryToTable("log-table-basic", entry); } + if (entry.type === "PYTHON") { appendEntryToTable("log-table-script", entry); } + if (entry.type !== "PYTHON") { appendEntryToTable("log-table-advanced", entry); } + }); + +}; + +function appendEntryToTable(tableName, entry) { + let newEntry = document.getElementById(tableName).insertRow(0); + newEntry.insertCell(0).innerHTML = prettifyType(entry.type); + newEntry.insertCell(1).innerHTML = entry.time; + newEntry.insertCell(2).innerHTML = entry.details; + M.AutoInit(); + newEntry.className = "newLogEntry"; +} + +function prettifyType(type) { + let prettyTable = { + "DEBUG": `<span class="tooltipped" data-position="top" data-tooltip="Debug-log">đ¸</span>`, + "INFO": `<span class="tooltipped" data-position="top" data-tooltip="Just some information">âšī¸</span>`, + "WARNING": `<span class="tooltipped" data-position="top" data-tooltip="A warning">â ī¸</span>`, + "EVENT": `<span class="tooltipped" data-position="top" data-tooltip="Event">âĄī¸</span>`, + "SUCCESS": `<span class="tooltipped" data-position="top" data-tooltip="Something exited successfully">â
</span>`, + "ERROR": `<span class="tooltipped" data-position="top" data-tooltip="Error">đ´</span>`, + "PYTHON": `<span class="tooltipped" data-position="top" data-tooltip="Output from user-script">đ</span>` + }; + return prettyTable[type]; +}
\ No newline at end of file diff --git a/src/public/js/neo_ide.js b/src/public/js/neo_ide.js new file mode 100644 index 0000000..6108be4 --- /dev/null +++ b/src/public/js/neo_ide.js @@ -0,0 +1,4 @@ +module.exports = () => { + + +};
\ No newline at end of file diff --git a/src/public/js/scripts.js b/src/public/js/scripts.js new file mode 100644 index 0000000..ccad3cf --- /dev/null +++ b/src/public/js/scripts.js @@ -0,0 +1,71 @@ +module.exports = () => { + let socket = io(); + socket.emit("GetScripts", {}); + + socket.on("updatedScriptList", (scriptList) => { + let localScriptsHTML = ""; + let remoteScriptsHTML = ""; + + for (let i = 0; i < scriptList.length; i++) { + if (scriptList[i].loc !== "local") { continue; } + let HTMLElem = "<li><div class=\"col s12 m4\"><div class=\"card blue darken-1\"><div class=\"card-content white-text\"><p class=\"card-title\">{{script_name}}</p><p>{{badges}}</p></div><div class=\"card-action white\">{{buttons}}</div></div></div></li>"; + if (scriptList[i].loc === "local") { + HTMLElem = HTMLElem.replace("{{badges}}", ""); + HTMLElem = HTMLElem.replace("{{script_name}}", scriptList[i].name); + HTMLElem = HTMLElem.replace("{{buttons}}", + "<a class=\"selectScript\" data-path=" + scriptList[i].path + "><i class=\"material-icons\">play_arrow</i></a>" + + "<a class=\"editScript\" data-path=" + scriptList[i].path + "><i class=\"material-icons\">edit</i></a>" + + "<a class=\"deleteScript\" data-path=" + scriptList[i].path + "><i class=\"material-icons\">delete_forever</i></a>" + ); + localScriptsHTML += HTMLElem; + } else if (scriptList[i].loc === "remote") { + HTMLElem = HTMLElem.replace("{{badges}}", "<span class=\"badge yellow darken-1 white-text\">GitHub</span>"); + HTMLElem = HTMLElem.replace("{{script_name}}", scriptList[i].name); + remoteScriptsHTML += HTMLElem; + } + } + + document.getElementById("local-scripts").innerHTML = localScriptsHTML; + document.getElementById("remote-scripts").innerHTML = remoteScriptsHTML; + + }); + + /* + The delays here with settimeout, is set to a second deliberately, because, rather than making a whole checking-thing. + We just wait a second, and assume, that if it worked, the change should show now. Else, check the logViewer. + */ + function clickHandler(event) { + let element = event.target.parentElement; + + if (element.className === "selectScript") { + M.toast({html: "Now selecting script: " + element.dataset.path}); + socket.emit("SelectScript", {"scriptPath": element.dataset.path}); + + } else if (element.className === "editScript") { + window.location.href = ( + "http://" + window.location.hostname + ":" + window.location.port + + "/neo_ide?scriptName=" + btoa(element.dataset.path) + ); + + } else if (element.className === "deleteScript") { + if (confirm("Do you really want to delete this script?\n" + element.dataset.path + "\n\nYou can not undo this action, and the script will be lost forever...")) { + M.toast({html: "Trying to create script. If no change after a second. Check the logViewer."}); + socket.emit("DeleteScript", {"scriptPath": element.dataset.path}); + setTimeout(() => {socket.emit("GetScripts", {})}, 1000); + } + + } else if (element.id === "createEmptyScript") { + var scriptName = prompt("Please enter the name of the new script:"); + if (scriptName != null || scriptName != "") { + M.toast({html: "Trying to create script. If no change after a second. Check the logViewer."}); + socket.emit("CreateEmptyScript", {"scriptName": scriptName}); + setTimeout(() => {socket.emit("GetScripts", {})}, 1000); + } + + } + + } + + addEventListener("click", clickHandler, false); + +}; diff --git a/src/public/scss/general.scss b/src/public/scss/general.scss new file mode 100644 index 0000000..cbbc654 --- /dev/null +++ b/src/public/scss/general.scss @@ -0,0 +1,44 @@ +.general { + + header, main, footer { + padding-left: 300px; + } + + header .brand-logo { + padding-left: 15px; + } + + @media only screen and (max-width : 992px) { + header, main, footer { + padding-left: 0; + } + } + + .user-view { + margin-top: 5px; + height: 150px; + } + + .user-view .background { + margin-left: 85px; + } + + .log-table { + + + + + } + + @keyframes highlightNew { + 0% {background-color:#ffc107;} + 100% {background-color:white;} + } + + .newLogEntry { + -webkit-animation-name: highlightNew; /* Safari 4.0 - 8.0 */ + -webkit-animation-duration: 4s; /* Safari 4.0 - 8.0 */ + animation-name: highlightNew; + animation-duration: 4s; + } +} diff --git a/src/public/scss/neo_ide.scss b/src/public/scss/neo_ide.scss new file mode 100644 index 0000000..fb10885 --- /dev/null +++ b/src/public/scss/neo_ide.scss @@ -0,0 +1,254 @@ +.neo_ide { + + html, + body { + height: 100%; + font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; + padding: 0; + margin: 0; + /*margin-top: -20px;*/ + overflow: auto; + } + + #editor { + width: 100%; + height: 100%; + margin: -10px; + } + + .page-container { + display: flex; + flex-direction: column; + justify-content: center; + } + + .nav-container { + width: 100%; + height: 45px; + background-color: #333333; + + ul { + display: flex; + flex-direction: row; + justify-content: space-between; + flex: 1; + align-self: center; + width: 100%; + list-style: none; + } + + ul .left { + color: white; + padding: 15px; + margin-left: -40px; + margin-top: -19px; + font-size: 20px; + } + + ul .center { + color: white; + } + + ul .right { + width: 80px; + margin-right: 174px; + color: white; + } + + ul .right .button { + padding: 15px; + margin-top: -15px; + } + + .fileName { + color: grey; + } + + ul .button { + + } + + ul .button:hover { + background-color: black; + } + } + + @keyframes menuBarIn { + from {height: 0;} + to {height: 25px;} + } + + @keyframes menuBarOut { + from {height: 25px;} + to {height: 0;} + } + + .menuBarIn { + animation-name: menuBarIn; + animation-duration: 0.5s; + height: 25px !important; + } + + .menuBarOut { + animation-name: menuBarOut; + animation-duration: 0.5s; + height: 0px !important; + } + + .menubar-container { + background-color: #4e4e4e; + height: 0; + + ul { + display: flex; + flex-direction: row; + flex: 1; + width: 100%; + list-style: none; + margin-top: 2px; + margin-left: -30px; + } + + .button { + background-color: #3e3e3e; + color: white; + padding: 3px 10px 3px 10px; + margin-right: 4px; + font-size: 13px; + border-radius: 7px; + } + + .button:hover { + background-color: black; + } + + } + + .panel-container { + display: flex; + flex-direction: column; + flex: 1; + overflow: hidden; + + .panel-top { + flex: 0 0 auto; + padding: 10px; + height: 80%; + width: 100%; + white-space: nowrap; + background: #838383; + color: white; + } + + .splitter { + flex: 0 0 auto; + margin-top: -20px; + height: 25px; + background: url(https://raw.githubusercontent.com/RickStrahl/jquery-resizable/master/assets/hsizegrip.png) center center no-repeat #535353; + cursor: row-resize; + } + + .splitter .text { + margin-left: 10px; + margin-top: 4px; + color: #cccccc; + + span { + margin-left: 5px; + } + } + + .panel-bottom { + flex: 1 1 auto; + padding: 10px; + /*min-height: 200px;*/ + background: black; + color: white; + + overflow-y: scroll; + } + + .panel-bottom pre { + margin-top: -10px; + + .stdout { + color: white; + } + + .stderr { + color: red; + } + + .close { + color: yellow; + } + } + } + + label { + font-size: 1.2em; + display: block; + font-weight: bold; + margin: 30px 0 10px; + } + + + + + + .page-loader { + position: absolute; + margin: 0; + padding: 0; + border: 0; + width: 100vw; + height: 100vh; + background-color: #1fa2ed; + color: #fff; + + // LET THE LOADING BEGIN + .loader { + display: flex; + justify-content: center; + flex-flow: nowrap column; + align-items: center; + min-height: 100vh; + } + .loading { + display: flex; + margin: 24px 0; + } + .loading__element { + font: normal 100 2rem/1 Roboto; + letter-spacing: .5em; + } + [class*="el"] { + animation: bouncing 3s infinite ease; + } + + @for $i from 1 through 19 { + $delay: percentage($i); + .el#{$i} { + animation-delay: $delay / 1000% + s; + } + } + + @keyframes bouncing { + 0%, 100% { + transform: scale3d(1,1,1); + } + 50% { + transform: scale3d(0,0,1); + } + } + + .current-event { + color: rgba(255, 255, 255, 0.53); + font: normal 100 1rem/1 Roboto; + letter-spacing: .1em; + } + + } + + +} diff --git a/src/public/scss/scripts.scss b/src/public/scss/scripts.scss new file mode 100644 index 0000000..400c5f1 --- /dev/null +++ b/src/public/scss/scripts.scss @@ -0,0 +1,35 @@ +#scripts { + + .script-list .badge { + margin-left: 0; + float: none; + } + + .card { + /*margin-bottom: 60px;*/ + } + + @media only screen and (max-width: 599px) { + .card-action { + border-top: 0 !important; + padding: 0 !important; + height: 0; + transition: padding 0.5s ease 0s, + height 0.5s ease 0s; + } + + .card-action a i { + transform: scale(0); + transition: transform 0.1s ease 0.1s; + } + .card:hover > .card-action { + height: 55px; + padding: 16px 24px !important; + } + + .card:hover > .card-action > a > i { + transform: scale(1); + } + } + +}
\ No newline at end of file diff --git a/src/public/scss/setup.scss b/src/public/scss/setup.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/public/scss/setup.scss diff --git a/src/public/scss/update.scss b/src/public/scss/update.scss new file mode 100644 index 0000000..8e9d2f2 --- /dev/null +++ b/src/public/scss/update.scss @@ -0,0 +1,62 @@ +#update { + * { + margin: 0; + padding: 0; + border: 0; + box-sizing: border-box; + &:before, &:after { + box-sizing: inherit; + } + } + html { + width: 100vw; + height: 100vh; + } + body { + background-color: #1fa2ed; + color: #fff; + } + + // LET THE LOADING BEGIN + .start-screen { + display: flex; + justify-content: center; + flex-flow: nowrap column; + align-items: center; + min-height: 100vh; + } + .loading { + display: flex; + margin: 24px 0; + } + .loading__element { + font: normal 100 2rem/1 Roboto; + letter-spacing: .5em; + } + [class*="el"] { + animation: bouncing 3s infinite ease; + } + + @for $i from 1 through 19 { + $delay: percentage($i); + .el#{$i} { + animation-delay: $delay / 1000% + s; + } + } + + @keyframes bouncing { + 0%, 100% { + transform: scale3d(1,1,1); + } + 50% { + transform: scale3d(0,0,1); + } + } + + .current-event { + color: rgba(255, 255, 255, 0.53); + font: normal 100 1rem/1 Roboto; + letter-spacing: .1em; + } + +} |