add some logging for #133

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2023-01-24 23:48:09 -03:00
parent af5b9b9680
commit f064719515
5 changed files with 38 additions and 15 deletions

View file

@ -247,7 +247,7 @@
<div class="draggable floating-window-title">
History
<div style="flex: 1"></div>
<button id="settings-btn" class="ui icon header-button">
<button id="history-logs-btn" class="ui icon header-button">
<div class="icon-scroll"></div>
</button>
</div>

View file

@ -8,6 +8,7 @@
* @property {() => void | Promise<void>} redo A method to redo whatever undo did
* @property {() => any | Promise<any>} export A method to export the command
* @property {{[key: string]: any}} state The state of the current command instance
* @property {{[key: string]: any}} extra Extra information saved with the command
*/
/**

View file

@ -1,4 +1,20 @@
(() => {
const historyLogBtn = document.getElementById("history-logs-btn");
historyLogBtn.addEventListener("click", () => {
let logs = "";
commands._history.forEach((entry) => {
if (entry.extra.log) logs += ` => ${entry.extra.log}\n`;
});
const blob = new Blob([logs], {type: "text/plain"});
const url = URL.createObjectURL(blob);
var link = document.createElement("a"); // Or maybe get it from the current document
link.href = url;
link.download = `${new Date().toISOString()}_openOutpaint_log.txt`;
link.click();
});
const historyView = document.getElementById("history");
const makeHistoryEntry = (index, id, title) => {

View file

@ -298,7 +298,8 @@ const selectTransformTool = () =>
` - rotation : ${
Math.round(1000 * ((180 * state.selected.rotation) / Math.PI)) /
1000
} degrees`
} degrees`,
false
);
// Draw Image

View file

@ -418,21 +418,26 @@ const stampTool = () =>
const resource = state.selected;
let commandLog = `Stamped image '${resource.name}' to x: ${resource.x} and y: ${resource.y}`;
const addline = (v, newline = true) => {
commandLog += v;
if (newline) commandLog += "\n";
};
addline(` - scaling : ${state.scale}`);
addline(
` - rotation: ${
Math.round(1000 * ((180 * rotation) / Math.PI)) / 1000
} degrees`
);
if (resource) {
const {canvas, bb} = cropCanvas(ovCanvas, {border: 10});
let commandLog = "";
const addline = (v, newline = true) => {
commandLog += v;
if (newline) commandLog += "\n";
};
addline(
`Stamped image '${resource.name}' to x: ${bb.x} and y: ${bb.y}`
);
addline(` - scaling : ${state.scale}`);
addline(
` - rotation: ${
Math.round(1000 * ((180 * rotation) / Math.PI)) / 1000
} degrees`,
false
);
commands.runCommand(
"drawImage",
"Image Stamp",