use the component's color in issue overview - fixes #580

Thu, 30 Jan 2025 19:47:21 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 30 Jan 2025 19:47:21 +0100
changeset 346
860bbccf33e7
parent 345
7a515768c481
child 347
d1edd8d9c8a1

use the component's color in issue overview - fixes #580

src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt file | annotate | diff | comparison | revisions
src/main/kotlin/de/uapcore/lightpit/types/WebColor.kt file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/changelogs/changelog-de.jspf file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/changelogs/changelog.jspf file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/site.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jspf/issue-list.jspf file | annotate | diff | comparison | revisions
src/main/webapp/lightpit.css file | annotate | diff | comparison | revisions
src/main/webapp/projects.css file | annotate | diff | comparison | revisions
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Thu Jan 30 19:47:21 2025 +0100
@@ -500,7 +500,7 @@
             p.description as project_description,
             p.vcs as project_vcs,
             p.repourl as project_repourl,
-            component, c.name as componentname, c.node as componentnode,
+            component, c.name as componentname, c.node as componentnode, c.color as componentcolor,
             status, phase, category, subject, i.description,
             userid, username, givenname, lastname, mail,
             created, updated, eta, affected, resolved
@@ -518,6 +518,7 @@
                 Component(it, proj.id).apply {
                     name = getString("componentname")
                     node = getString("componentnode")
+                    color = WebColor(getString("componentcolor"))
                 }
         }
         val issue = Issue(getInt("issueid"), proj).apply {
--- a/src/main/kotlin/de/uapcore/lightpit/types/WebColor.kt	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/types/WebColor.kt	Thu Jan 30 19:47:21 2025 +0100
@@ -25,6 +25,8 @@
  */
 package de.uapcore.lightpit.types
 
+import java.lang.Integer.parseInt
+
 
 /**
  * Represents a web color in hexadecimal representation.
@@ -49,4 +51,15 @@
     override fun toString(): String {
         return color
     }
+
+    /**
+     * Returns "light-text" or "dark-text" depending on the luminance of this color.
+     */
+    fun getTextColorClass(): String {
+        val red = parseInt(color.substring(1, 3), 16)
+        val green = parseInt(color.substring(3, 5), 16)
+        val blue = parseInt(color.substring(5), 16)
+        val luminance = (0.2126 * red + 0.7152 * green + 0.0722 * blue) / 255.0
+        return if (luminance > 0.5) "dark-text" else "light-text"
+    }
 }
\ No newline at end of file
--- a/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/webapp/WEB-INF/changelogs/changelog-de.jspf	Thu Jan 30 19:47:21 2025 +0100
@@ -33,6 +33,7 @@
         Query Parameter <code>in_project</code> zu globalen Vorgangs-URLs hinzugefügt,
         der von Tools benutzt werden kann, um Vorgänge direkt in der Projektansicht zu öffnen.
     </li>
+    <li>Die Anzeige von Komponenten in der Vorgangsliste nutzt nun die der Komponente zugewiesene Farbe.</li>
     <li>Fehler behoben, bei dem der "Assignee"-Filter im RSS-Feed nicht auf Kommentare angewendet wurde.</li>
     <li>Versionsinformationen werden nun korrekt in die Vorgangshistorie geschrieben (relevant für RSS-Feeds).</li>
     <li>
--- a/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/webapp/WEB-INF/changelogs/changelog.jspf	Thu Jan 30 19:47:21 2025 +0100
@@ -33,6 +33,7 @@
         Add optional query parameter <code>in_project</code> for global issue URLs
         that can be used by tools to directly open an issue in the project view.
     </li>
+    <li>Change that the component labels in the issue view now use their assigned color.</li>
     <li>Fix that assignee filter does not work for comments in RSS feed.</li>
     <li>
         Fix missing affected and target versions in issue history
--- a/src/main/webapp/WEB-INF/jsp/site.jsp	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/webapp/WEB-INF/jsp/site.jsp	Thu Jan 30 19:47:21 2025 +0100
@@ -31,7 +31,7 @@
 <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
 
 <%-- Version suffix for forcing browsers to update the CSS / JS files --%>
-<c:set scope="page" var="versionSuffix" value="20241109"/>
+<c:set scope="page" var="versionSuffix" value="20250130"/>
 
 <%-- Make the base href easily available at request scope --%>
 <c:set scope="page" var="baseHref" value="${requestScope[Constants.REQ_ATTR_BASE_HREF]}"/>
--- a/src/main/webapp/WEB-INF/jspf/issue-list.jspf	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/webapp/WEB-INF/jspf/issue-list.jspf	Thu Jan 30 19:47:21 2025 +0100
@@ -48,14 +48,15 @@
                 <div class="issue-tag phase-${issue.status.phase.number}">
                     <fmt:message key="issue.status.${issue.status}" />
                 </div>
+                <c:if test="${showComponentInfo and issue.component != null}">
+                    <div class="issue-tag-auto-color ${issue.component.color.textColorClass}"
+                         style="background-color: ${issue.component.color}">
+                        <c:out value="${issue.component.name}"/>
+                    </div>
+                </c:if>
                 <c:if test="${showVersionInfo and issue.resolved != null}">
-                <div class="issue-tag">
-                    <c:out value="${issue.resolved.name}"/>
-                </div>
-                </c:if>
-                <c:if test="${showComponentInfo and issue.component != null}">
                     <div class="issue-tag">
-                        <c:out value="${issue.component.name}"/>
+                        <c:out value="${issue.resolved.name}"/>
                     </div>
                 </c:if>
             </td>
--- a/src/main/webapp/lightpit.css	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/webapp/lightpit.css	Thu Jan 30 19:47:21 2025 +0100
@@ -51,6 +51,14 @@
     margin: 0.25em 0;
 }
 
+.light-text {
+    color: white;
+}
+
+.dark-text {
+    color: #1c204e;
+}
+
 textarea, input, button, select {
     font-family: inherit;
     font-size: inherit;
--- a/src/main/webapp/projects.css	Tue Jan 14 20:12:25 2025 +0100
+++ b/src/main/webapp/projects.css	Thu Jan 30 19:47:21 2025 +0100
@@ -65,7 +65,7 @@
     background: green;
 }
 
-.issue-tag, .version-tag {
+.issue-tag, .version-tag, .issue-tag-auto-color {
     padding: .1em 2ex .1em 2ex;
     display: inline-block;
     box-sizing: border-box;
@@ -77,6 +77,9 @@
     text-align: center;
     font-weight: bolder;
     font-size: x-small;
+}
+
+.issue-tag, .version-tag {
     color: whitesmoke;
 }
 

mercurial