Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use badge to indicate stderror rather than red text #83

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/Aspire.Dashboard/Components/Controls/LogViewer.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@
white-space: pre-wrap;
}

::deep .content.error {
color: red;
}

::deep .content.warning {
color: yellow;
::deep .content > fluent-badge {
margin-right: 1em;
user-select: none;
}
25 changes: 22 additions & 3 deletions src/Aspire.Dashboard/Components/Controls/LogViewer.razor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const template = createRowTemplate();
const stdErrorBadgeTemplate = createStdErrBadgeTemplate();

/**
* Clears all log entries from the log viewer and resets the
Expand Down Expand Up @@ -39,9 +40,7 @@ export function addLogEntries(logEntries) {
const content = lineArea.lastElementChild;
content.textContent = logEntry.content;
if (logEntry.type === "Error") {
content.classList.add("error");
} else if (logEntry.type === "Warning") {
content.classList.add("warning");
content.prepend(getStdErrorBadge());
}

insertSorted(container, rowContainer, logEntry.timestamp, logEntry.parentId, logEntry.lineIndex);
Expand Down Expand Up @@ -105,6 +104,14 @@ function getNewRowContainer() {
return template.cloneNode(true);
}

/**
* Clones the stderr badge template for use with a new log entry
* @returns
*/
function getStdErrorBadge() {
return stdErrorBadgeTemplate.cloneNode(true);
}

/**
* Creates the initial row container template that will be cloned
* for each log entry
Expand All @@ -129,6 +136,18 @@ function createRowTemplate() {
return rowTemplate;
}

/**
* Creates the initial stderr badge template that will be cloned
* for each log entry
* @returns {HTMLElement}
*/
function createStdErrBadgeTemplate() {
const badge = document.createElement("fluent-badge");
badge.setAttribute("appearance", "accent");
badge.textContent = "stderr";
return badge;
}

/**
* Checks to see if the specified scrolling container is scrolled all the way
* to the bottom
Expand Down