You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2022/01/27 14:52:03 UTC
[isis] branch master updated: ISIS-2928 [kroviz] Show Application Logo in MenuBar
This is an automated email from the ASF dual-hosted git repository.
joergrade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 0f34bd6 ISIS-2928 [kroviz] Show Application Logo in MenuBar
new 19e31b6 Merge branch 'master' of https://github.com/apache/isis
0f34bd6 is described below
commit 0f34bd6166eeb0d7bec718c79bb68d9303f295b6
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Thu Jan 27 15:49:17 2022 +0100
ISIS-2928 [kroviz] Show Application Logo in MenuBar
---
.../org/apache/isis/client/kroviz/core/Session.kt | 4 +---
.../kroviz/core/aggregator/SystemAggregator.kt | 10 +++++++---
.../apache/isis/client/kroviz/ui/core/Constants.kt | 3 +--
.../apache/isis/client/kroviz/ui/core/RoMenuBar.kt | 19 +++++++++++++++----
.../isis/client/kroviz/ui/core/SessionManager.kt | 7 +++++++
.../apache/isis/client/kroviz/utils/ImageUtils.kt | 2 +-
.../resources/img/1200px-DEU_Hamburg_COA.svg.png | Bin 84730 -> 0 bytes
.../kroviz/src/main/resources/img/gift_48.png | Bin 7020 -> 0 bytes
.../src/main/resources/img/incode_we_share.jpg | Bin 0 -> 214773 bytes
.../main/resources/img/wv-amsterdam-favicon-05.png | Bin 3999 -> 0 bytes
10 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/Session.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/Session.kt
index bbd954f..71af81f 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/Session.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/Session.kt
@@ -35,9 +35,7 @@ class Session {
this.user = user
this.pw = pw
this.baseUrl = url
- if (url.contains("8080")) {
- this.resString = Constants.demoImage as ResString
- } else {
+ if (url.contains("incode")) {
this.resString = Constants.demoRemoteImage as ResString
}
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/SystemAggregator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/SystemAggregator.kt
index 3314056..82c9d6b 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/SystemAggregator.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/SystemAggregator.kt
@@ -23,6 +23,7 @@ import org.apache.isis.client.kroviz.core.model.SystemDM
import org.apache.isis.client.kroviz.to.DomainTypes
import org.apache.isis.client.kroviz.to.User
import org.apache.isis.client.kroviz.to.Version
+import org.apache.isis.client.kroviz.ui.core.SessionManager
import org.apache.isis.client.kroviz.utils.ImageUtils
import org.apache.isis.client.kroviz.utils.UrlUtils
@@ -33,7 +34,6 @@ class SystemAggregator() : BaseAggregator() {
}
override fun update(logEntry: LogEntry, subType: String) {
-
when (val obj = logEntry.getTransferObject()) {
is User -> dpm.addData(obj)
is Version -> dpm.addData(obj)
@@ -44,12 +44,16 @@ class SystemAggregator() : BaseAggregator() {
val url = logEntry.url
val isApplicationIcon = UrlUtils.isApplicationIcon(url)
when (isApplicationIcon) {
- url.contains("48") -> (dpm as SystemDM).addSmallIcon(icon)
+ url.contains("48") -> {
+ (dpm as SystemDM).addSmallIcon(icon)
+ val iconUrl = icon.image.src
+ SessionManager.setApplicationIcon(iconUrl)
+ }
url.contains("256") -> (dpm as SystemDM).addLargeIcon(icon)
else -> log(logEntry)
}
} else {
- console.log("[SA.update] TODO ISIS-2768 no blob/image due to CORS")
+ console.log("[SA.update] blob/image is null")
}
}
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt
index 9115225..16ddc52 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt
@@ -36,11 +36,10 @@ object Constants {
// docker run -d --name kroki -p 8080:8000 yuzutech/kroki
const val demoUrl = "http://localhost:8080/"
- val demoImage = io.kvision.require("img/1200px-DEU_Hamburg_COA.svg.png")
const val demoUser = "sven"
const val demoPass = "pass"
const val demoUrlRemote = "https://demo-wicket.jdo.isis.incode.work/"
- val demoRemoteImage = io.kvision.require("img/wv-amsterdam-favicon-05.png")
+ val demoRemoteImage = io.kvision.require("img/incode_we_share.jpg")
const val domoxUrl = "http://localhost:8081/"
const val spacing = 10
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt
index d663c45..bddecef 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoMenuBar.kt
@@ -75,14 +75,17 @@ class RoMenuBar : SimplePanel() {
}
private fun mainEntryContains(baseUrl: String): Boolean {
+ val link = findEntryBy(baseUrl)
+ return (link != null)
+ }
+
+ private fun findEntryBy(baseUrl: String): Link? {
mainEntry.getChildren().forEach {
if (it is Link) {
- if ((it as Link).label == baseUrl) {
- return true
- }
+ if (it.label == baseUrl) return it
}
}
- return false
+ return null
}
fun switch(session: Session) {
@@ -97,6 +100,14 @@ class RoMenuBar : SimplePanel() {
ViewManager.setNormalCursor()
}
+ fun updateIcon(session: Session) {
+ val resString = session.resString
+ mainEntry.image = resString
+ val baseUrl = session.baseUrl
+ val link = findEntryBy(baseUrl)
+ link?.image = resString
+ }
+
private fun buildMenuEntryWithImage(label: String, image: ResString?, action: dynamic): Link {
val link = Link(label, image = image, className = "dropdown-item").apply { appIconStyle }
link.onClick { e ->
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/SessionManager.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/SessionManager.kt
index f95ace5..98496dc 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/SessionManager.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/SessionManager.kt
@@ -62,4 +62,11 @@ object SessionManager {
return activeSession?.getCredentials()
}
+ fun setApplicationIcon(iconUrl: String) {
+ console.log("[SM.setApplicationIcon] $iconUrl")
+ activeSession?.resString = iconUrl
+ val menuBar = ViewManager.getRoApp().roMenuBar
+ menuBar.updateIcon(activeSession!!)
+ }
+
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/ImageUtils.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/ImageUtils.kt
index 80436f3..52018c6 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/ImageUtils.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/ImageUtils.kt
@@ -32,7 +32,7 @@ object ImageUtils {
return Icon(image)
}
- fun Blob.toImage(): Image {
+ private fun Blob.toImage(): Image {
val url = URL.createObjectURL(this)
val image = Image()
image.src = url
diff --git a/incubator/clients/kroviz/src/main/resources/img/1200px-DEU_Hamburg_COA.svg.png b/incubator/clients/kroviz/src/main/resources/img/1200px-DEU_Hamburg_COA.svg.png
deleted file mode 100644
index 294cca0..0000000
Binary files a/incubator/clients/kroviz/src/main/resources/img/1200px-DEU_Hamburg_COA.svg.png and /dev/null differ
diff --git a/incubator/clients/kroviz/src/main/resources/img/gift_48.png b/incubator/clients/kroviz/src/main/resources/img/gift_48.png
deleted file mode 100644
index 86154c4..0000000
Binary files a/incubator/clients/kroviz/src/main/resources/img/gift_48.png and /dev/null differ
diff --git a/incubator/clients/kroviz/src/main/resources/img/incode_we_share.jpg b/incubator/clients/kroviz/src/main/resources/img/incode_we_share.jpg
new file mode 100644
index 0000000..ac44d08
Binary files /dev/null and b/incubator/clients/kroviz/src/main/resources/img/incode_we_share.jpg differ
diff --git a/incubator/clients/kroviz/src/main/resources/img/wv-amsterdam-favicon-05.png b/incubator/clients/kroviz/src/main/resources/img/wv-amsterdam-favicon-05.png
deleted file mode 100644
index 66ad072..0000000
Binary files a/incubator/clients/kroviz/src/main/resources/img/wv-amsterdam-favicon-05.png and /dev/null differ