Skip to content

Commit

Permalink
[huge] did a lot of development, but mainly the web log
Browse files Browse the repository at this point in the history
  • Loading branch information
Grovkillen committed Jan 9, 2020
1 parent 95d9017 commit cb6efd4
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 42 deletions.
2 changes: 1 addition & 1 deletion build/0.0.nightly.1/info/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gui-easy",
"timestamp": 1578441855177,
"timestamp": 1578443627149,
"version": "0.0.1",
"author": "Jimmy 'Grovkillen' Westberg <jimmy@grovkillen.com> (https://grovkillen.com)",
"license": "GPL-3.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion build/0.0.nightly.1/info/source_files.json

Large diffs are not rendered by default.

Binary file modified build/0.0.nightly.1/src-0.0.nightly.1.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gui-easy",
"timestamp": 1578441855177,
"timestamp": 1578443627149,
"version": "0.0.1",
"author": "Jimmy 'Grovkillen' Westberg <jimmy@grovkillen.com> (https://grovkillen.com)",
"license": "GPL-3.0-or-later",
Expand Down
38 changes: 25 additions & 13 deletions src/gui_easy.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
}
/* Scrollbar handle */
::-webkit-scrollbar-thumb {
background: var(--main-inverted-color-rgba);
background: rgba(var(--main-inverted-color), 0.75);
}
div.modal div.row::-webkit-scrollbar-thumb {
background: var(--main-font-color-rgba);
background: rgba(var(--main-font-color), 0.5);
}
/* the "scrollbar" prop. is the upcoming standard remove webkit above once they have implemented it */
div.modal div.row,
Expand Down Expand Up @@ -973,7 +973,7 @@ div.modal > div.message {
transform: translate(-50%,-35%);
min-width: 400px;
max-width: calc(0.6 * var(--max-width-page-size, 1400px));
max-height: 80vh;
max-height: 85vh;
border-radius: calc(0.25 * var(--default-height-size, 20) / var(--button-radius-size, 2));
}
div.modal div.area-title,
Expand Down Expand Up @@ -1063,25 +1063,25 @@ div.wave-text > svg {
height: calc(4 * var(--default-height-size, 20));
}
div.weblog {
width: calc(100% - 14px);
min-height: 70vh;
max-height: 70vh;
font-family: monospace;
width: 100%;
text-align: left;
font-size: calc(0.8 * var(--default-font-size, 19pt));
overflow-y: scroll;
display: block;
margin: 2px 4px 4px;
padding: 1px;
border-radius: calc(0.2 * var(--default-height-size, 20) / var(--button-radius-size, 2));
border: 2px solid rgba(var(--main-inverted-color), 0.35);
background: rgba(0, 0 ,0 , 0.55);
}
textarea::-webkit-scrollbar,
div.weblog::-webkit-scrollbar {
div.weblog:empty {
content: 'Fetching log entries...';
}
#weblog-filters {
width: 100%;
}
textarea::-webkit-scrollbar {
width: 12px;
}
textarea::-webkit-scrollbar-thumb,
div.weblog::-webkit-scrollbar-thumb {
textarea::-webkit-scrollbar-thumb {
max-height: 5%;
border-radius: calc(0.2 * var(--default-height-size, 20) / var(--button-radius-size, 2));
background: rgba(var(--main-bg-color), 0.5);
Expand Down Expand Up @@ -1393,6 +1393,9 @@ input[type="search"] {
text-align: left;
font-size: calc(0.9 * var(--default-font-size, 19pt));
}
input[type="search"]#weblog-filter-input {
margin-top: 6px;
}
input[type="text"],
input[type="password"] {
padding-left: 4px;
Expand Down Expand Up @@ -1513,6 +1516,10 @@ div.entry > div {
div.entry > div.timestamp {
color: rgba(var(--main-font-color), 0.5);
}
div.entry > div.timestamp::after {
content: ':';
color: rgba(var(--main-font-color), 0.25);
}
div.entry > div.main-info {
color: var(--main-info-color-rgba);
background: transparent;
Expand All @@ -1529,6 +1536,10 @@ div.entry > div.main-success {
color: var(--main-success-color-rgba);
background: transparent;
}
div.entry > div.main-bg {
color: var(--main-bg-color-rgba);
background: transparent;
}
label.checkbox {
position: relative;
white-space: nowrap;
Expand Down Expand Up @@ -1571,6 +1582,7 @@ label.checkbox:active::after {
#modal-input-upload-storage-free,
#modal-input-upload-storage-occupied {
margin-bottom: 5px;
margin-top: 3px;
height: calc(0.6 * var(--default-height-size, 20));
}
select:hover ~ label.select,
Expand Down
5 changes: 5 additions & 0 deletions src/gui_easy_butler.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ guiEasy.butler = async function (processID, processType) {
}
helpEasy.addToLogDOM("pageSize", 1);
helpEasy.processDone(processID, processType);
};

guiEasy.butler.notification = function () {
//this one get's info from the server, it is also called "once per hour" from the tender to see if new info is present

};
9 changes: 9 additions & 0 deletions src/gui_easy_curly.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,4 +555,13 @@ guiEasy.curly.drawer.theme.family = function (variable, defaultValue) {
}
startHTML += 'data-default-index="' + v + '" data-default-value="' + defaultValue + '">';
return startHTML + optionHTML + "</select>";
};

guiEasy.curly.info = function (what) {
if (what[0] === "message") {
helpEasy.addToLogDOM("message", 0, "info");
}
if (what[0] === "footer") {
helpEasy.addToLogDOM("footer", 0, "info");
}
};
53 changes: 41 additions & 12 deletions src/gui_easy_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const helpEasy = {
}
)
.catch(error => {
helpEasy.addToLogDOM('Error fetching (' + endpoint + '): ' + error, 0, "warn");
helpEasy.addToLogDOM('Error fetching (' + endpoint + '): ' + error, 0, "error");
array[index].stats.error++;
let nextRun = Date.now() + array[index].stats[endpoint].TTL_fallback;
array[index]["scheduler"].push([nextRun, endpoint]);
Expand Down Expand Up @@ -620,7 +620,7 @@ const helpEasy = {
html += "</table></div>";
set(guiEasy.nodes[index], "modal.table.files", html);
},
'logListBacklog': function () {
'logListBacklog': function (iStart) {
let listHTML = "";
let level = {
"1":"success",
Expand All @@ -634,27 +634,56 @@ const helpEasy = {
"9":"warning"
};
let history = guiEasy.nodes[helpEasy.getCurrentIndex()].log;
for (let i = 0; i < history.length; i++) {
if (history === undefined) {
guiEasy.nodes[helpEasy.getCurrentIndex()].stats.logjson.timestampLast = 0;
return "";
}
history = history.slice(-3000); // Slice to only populate the last 3000 chunks of log data
if (iStart === undefined) {
iStart = 0;
}
for (let i = iStart; i < history.length; i++) {
let timestamp = history[i].timestamp;
let entries = history[i].entries;
let random = Math.random() * (999999 - 100000) + 100000;
let id = "";
if (entries.length > 0) {
//add to list
listHTML += `<div class='entry' id='` + Date.now() + `.` + timestamp + `.` + random + `'
data-web-log-text="` + entries[i].text + `"
data-web-log-level="` + level[entries[i].level] + `"
for (let k = 0; k < entries.length; k++) {
//add to list
id = Date.now() + "." + timestamp + "." + random;
listHTML += `<div class='entry' id='` + id + `'
data-web-log-text="` + entries[k].text + `"
data-web-log-level="` + entries[k].level + `"
data-web-log-timestamp="` + timestamp + `"
>
<div class='timestamp>'` + entries[i].timestamp + `</div>
<div class='main-` + level[entries[i].level] + `'>` + entries[i].text + `</div>
<div class='timestamp'>` + entries[k].timestamp + `</div>
<div class='main-` + level[entries[k].level] + `'>` + entries[k].text + `</div>
</div>`;
}
guiEasy.nodes[helpEasy.getCurrentIndex()].stats.logjson.timestampLast = timestamp;
guiEasy.nodes[helpEasy.getCurrentIndex()].stats.logjson.lastEntryID = id;
}
guiEasy.nodes[helpEasy.getCurrentIndex()].stats.lastLogCheck = timestamp;
}
console.log(listHTML);
return listHTML;
},
'logListLive': function (timestampIN) {

let logList = guiEasy.nodes[helpEasy.getCurrentIndex()].log;
if (logList === undefined) {
return "";
}
logList = logList.slice(-3000);
let fromTimestamp = 0;
for (let i = (logList.length - 1); i > -1; i--) {
let timestamp = logList[i].timestamp;
if (timestamp > timestampIN) {
fromTimestamp = i;
break;
}
if (i === 0) {
return "";
}
}
return helpEasy.logListBacklog(fromTimestamp);
},
'timingstatsList': function (timingArray, index) {
let unsorted = [];
Expand Down
10 changes: 6 additions & 4 deletions src/gui_easy_pitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ guiEasy.pitcher = function (processID, processType) {
let x = setInterval(function () {
LCX++;
if (LCX > maxLoopsX) {
helpEasy.addToLogDOM("'live' not working!", 0, "warning");
helpEasy.addToLogDOM("'live' not working!", 0, "warn");
helpEasy.processDone(processID, processType);
return;
}
Expand All @@ -41,7 +41,7 @@ guiEasy.pitcher = function (processID, processType) {
let y = setInterval(function () {
LCY++;
if (LCY > maxLoopsY) {
helpEasy.addToLogDOM("'gui' not working!", 0, "warning");
helpEasy.addToLogDOM("'gui' not working!", 0, "warn");
helpEasy.processDone(processID, processType);
return;
}
Expand All @@ -60,7 +60,7 @@ guiEasy.pitcher = function (processID, processType) {
let z = setInterval(function () {
LCZ++;
if (LCZ > maxLoopsZ) {
helpEasy.addToLogDOM("'config' not working!", 0, "warning");
helpEasy.addToLogDOM("'config' not working!", 0, "warn");
helpEasy.processDone(processID, processType);
return;
}
Expand All @@ -82,7 +82,7 @@ guiEasy.pitcher = function (processID, processType) {
let u = setInterval(function () {
LCU++;
if (LCU > maxLoopsU) {
helpEasy.addToLogDOM("'live'/'gui'/'config' not working!", 0, "warning");
helpEasy.addToLogDOM("'live'/'gui'/'config' not working!", 0, "warn");
helpEasy.processDone(processID, processType);
return;
}
Expand All @@ -93,9 +93,11 @@ guiEasy.pitcher = function (processID, processType) {
) {
clearInterval(u);
guiEasy.pitcher.createLists();
//TEST ONLY
setTimeout(function () {
helpEasy.logListBacklog();
},10 * 1000);
//TEST ONLY
//take care of url parameters...
guiEasy.popper.tab({"args":["tab",urlParams.tab]});
console.log(urlParams);
Expand Down
72 changes: 69 additions & 3 deletions src/gui_easy_popper.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,43 @@ guiEasy.popper.modal = function (modalToOpen) {
z.modal = "yep";
z.button.close = "yep";
z.action.close = "stop-log";
z.title = "web log";
let level = {};
level["0"] = "no web log set";
level["1"] = "error";
level["2"] = "info";
level["3"] = "debug";
level["4"] = "debug more";
level["5"] = "not used";
level["6"] = "not used";
level["7"] = "not used";
level["8"] = "not used";
level["9"] = "debug development";
let currentLevel = level[guiEasy.nodes[helpEasy.getCurrentIndex()].settings.config.log.web_level];
z.title = "web log (" + currentLevel + ")";
z.button.copy = "yep";
z.action.copy = "clipboard-log";
//z.table = guiEasy.nodes[index].modal.table.sysinfo_json;
z.info = `
<div class='weblog' id='weblog-container'>Fetching log entries...</div>
`;
let autoScrollToggle = helpEasy.addInput(
{
"type": "toggle",
"alt": "settings-change",
"title": "auto-scroll",
"settingsTrue": 0,
"settingsFalse": 1,
"falseText": "scrolling on",
"trueText": "scrolling off",
"default":true
}
);
z.setup = `
<div class="column">
<div class="row"><div id="weblog-filters" class="is-left"><div class="tag with-close">test</div></div></div>
<div class="row"><input id="weblog-filter-input" type="search" placeholder="Filter log..."><label class="search-icon"></label></div>
` + autoScrollToggle + `
</div>
`;
}
if (x === "info" && y === "json") {
// just open the json endpoint in a new tab... since we're not adding the "a" to DOM it'll be garbage collected
Expand Down Expand Up @@ -763,6 +796,39 @@ guiEasy.popper.modal = function (modalToOpen) {
}
}
}
if (x === "info" && y === "log") {
let backlog = helpEasy.logListBacklog();
if (backlog.length > 0) {
document.getElementById("weblog-container").innerHTML = backlog;
let element = guiEasy.nodes[helpEasy.getCurrentIndex()].stats.logjson.lastEntryID;
if (element !== undefined) {
document.getElementById(element).scrollIntoView();
}
}
guiEasy.weblogLoop = setInterval(function () {
let timestamp = guiEasy.nodes[helpEasy.getCurrentIndex()].stats.logjson.timestampLast;
if (timestamp === undefined) {
timestamp = 0;
}
let timestamp2 = guiEasy.nodes[helpEasy.getCurrentIndex()].stats.logjson.timestamp;
if (timestamp === timestamp2) {
// no need to do more
} else {
let weblogContainer = document.getElementById("weblog-container");
let newEntries = helpEasy.logListLive(timestamp);
let innerText = weblogContainer.innerText;
if (innerText === "Fetching log entries..." && newEntries.length !== 0) {
weblogContainer.innerHTML = newEntries;
} else if (newEntries.length !== 0) {
weblogContainer.insertAdjacentHTML('beforeend', newEntries);
}
let element = guiEasy.nodes[helpEasy.getCurrentIndex()].stats.logjson.lastEntryID;
if (element !== undefined) {
document.getElementById(element).scrollIntoView({behavior: "smooth"});
}
}
}, 500)
}
//Countdown...
if (z.countdown > 0) {
let countdownElement = document.getElementById("modal-title-button-close");
Expand Down Expand Up @@ -795,7 +861,7 @@ guiEasy.popper.stop = function (what) {
};
guiEasy.popper.tryCallEvent(eventDetails);
// stop the log list ...

clearInterval(guiEasy.weblogLoop);
}
};

Expand Down
Loading

0 comments on commit cb6efd4

Please sign in to comment.