Bake all inputs, not just the active tab.

Limits number of workers to number of cpu threads (4 if not supported)
Creates output tabs (switching doesn't work yet)
Disabled some highlighting for now.
This commit is contained in:
j433866 2019-03-27 09:05:10 +00:00
parent fbe1e2c2cc
commit 37428fbe3b
7 changed files with 272 additions and 56 deletions

View file

@ -25,6 +25,7 @@ class OutputWaiter {
this.dishBuffer = null;
this.dishStr = null;
this.outputs = [];
}
@ -38,6 +39,38 @@ class OutputWaiter {
}
/**
* Sets the output array for multiple outputs.
* Displays the active output in the output textarea
*
* @param {Array} outputs
*/
async multiSet(outputs) {
log.debug("Received " + outputs.length + " outputs.");
this.outputs = outputs;
const activeTab = this.manager.input.getActiveTab();
const tabs = document.getElementById("output-tabs").getElementsByTagName("li");
for (let i = tabs.length - 1; i >= 0; i--) {
document.getElementById("output-tabs").firstElementChild.removeChild(tabs.item(i));
}
for (let i = 0; i < outputs.length; i++) {
this.addTab(outputs[i].inputNum);
if (outputs[i].inputNum === activeTab) {
await this.set(outputs[i].data.result, outputs[i].data.type, outputs[0].data.duration);
}
}
// await this.set(this.outputs[0].data.result, this.outputs[0].data.type, this.outputs[0].data.duration);
// Create tabs
// Select active tab
// Display active tab data in textarea
}
/**
* Sets the output in the output textarea.
*
@ -542,6 +575,49 @@ class OutputWaiter {
this.manager.input.loadFile(new File([blob], fileName, {type: blob.type}));
}
/**
* Function to create a new tab
*
* @param inputNum
*/
addTab(inputNum) {
const tabWrapper = document.getElementById("output-tabs");
const tabsList = tabWrapper.firstElementChild;
if (tabsList.children.length > 0) {
tabWrapper.style.display = "block";
}
document.getElementById("output-wrapper").style.height = "calc(100% - var(--tab-height) - var(--title-height))";
document.getElementById("output-highlighter").style.height = "calc(100% - var(--tab-height) - var(--title-height))";
document.getElementById("output-file").style.height = "calc(100% - var(--tab-height) - var(--title-height))";
const newTab = document.createElement("li");
newTab.id = `output-tab-${inputNum}`;
if (inputNum === this.manager.input.getActiveTab()) {
newTab.classList.add("active-output-tab");
}
const newTabContent = document.createElement("div");
newTabContent.classList.add("output-tab-content");
newTabContent.innerText = `Tab ${inputNum}`;
newTab.appendChild(newTabContent);
tabsList.appendChild(newTab);
}
/**
* Function to change tabs
*
* @param {Element} tabElement
*/
changeTab(tabElement) {
const liItem = tabElement.parentElement;
const newTabNum = liItem.id.replace("input-tab-", "");
const currentTabNum = this.getActiveTab();
const outputText = document.getElementById("output-text");
}
}
export default OutputWaiter;