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 fa77bcd  ISIS-2949 visualize number success/running/erroneous/views in 
statusbar
fa77bcd is described below

commit fa77bcdc6e57c73d5e9fc0b0356c40bdcacc1826
Author: Jörg Rade <[email protected]>
AuthorDate: Sun Jan 30 13:35:04 2022 +0100

    ISIS-2949 visualize number success/running/erroneous/views in statusbar
---
 .../kroviz/core/aggregator/ErrorDispatcher.kt      |  2 +-
 .../isis/client/kroviz/core/event/EventStore.kt    |  7 +++-
 .../isis/client/kroviz/core/event/LogEntry.kt      |  8 +++++
 .../isis/client/kroviz/core/event/StatusPo.kt      |  3 ++
 .../apache/isis/client/kroviz/to/bs3/FieldSet.kt   |  9 +++--
 .../isis/client/kroviz/ui/core/RoStatusBar.kt      | 42 +++++++++++++---------
 .../isis/client/kroviz/ui/core/ViewManager.kt      |  6 ++--
 .../isis/client/kroviz/ui/dialog/ErrorDialog.kt    |  2 +-
 8 files changed, 54 insertions(+), 25 deletions(-)

diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ErrorDispatcher.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ErrorDispatcher.kt
index 97391b3..3b6cec5 100644
--- 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ErrorDispatcher.kt
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/aggregator/ErrorDispatcher.kt
@@ -32,7 +32,7 @@ class ErrorDispatcher : BaseAggregator() {
         val message = error.getMessage()
         val reSpec = ResourceSpecification(url)
         SessionManager.getEventStore().fault(reSpec, message)
-        ErrorDialog(logEntry).open()
+//        ErrorDialog(logEntry).open()
     }
 
 }
diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt
index 9a16ed6..47946a3 100644
--- 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt
@@ -124,7 +124,12 @@ class EventStore {
     }
 
     internal fun updateStatus(entry: LogEntry) {
-        ViewManager.updateStatus(entry)
+        val successNo = log.count { le -> le.isSuccess() }
+        val runningNo = log.count { le -> le.isRunning() }
+        val errorNo = log.count { le -> le.isError() }
+        val viewNo = log.count { le -> le.isView() }
+        val status = StatusPo(successNo, runningNo, errorNo, viewNo)
+        ViewManager.updateStatus(status)
     }
 
     /**
diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
index 91c787f..9432868 100644
--- 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
@@ -211,6 +211,14 @@ data class LogEntry(
 
 //end region response
 
+    fun isSuccess(): Boolean {
+        return state.name.startsWith("SUCCESS")
+    }
+
+    fun isRunning(): Boolean {
+        return state == EventState.RUNNING
+    }
+
     fun isView(): Boolean {
         return isOpenView() || isClosedView()
     }
diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/StatusPo.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/StatusPo.kt
new file mode 100644
index 0000000..515530e
--- /dev/null
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/StatusPo.kt
@@ -0,0 +1,3 @@
+package org.apache.isis.client.kroviz.core.event
+
+class StatusPo(val successNo: Int, val runningNo: Int, val errorNo: Int, val 
viewsNo: Int)
\ No newline at end of file
diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs3/FieldSet.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs3/FieldSet.kt
index 8d6f16d..6c02044 100644
--- 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs3/FieldSet.kt
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/to/bs3/FieldSet.kt
@@ -29,9 +29,12 @@ class FieldSet(node: Node) {
 
     init {
         val dyNode = node.asDynamic()
-        name = dyNode.getAttribute("name") as String
-        id = dyNode.getAttribute("id") as String
-
+        if (dyNode.hasOwnProperty("name")) {
+            name = dyNode.getAttribute("name") as String
+        }
+        if (dyNode.hasOwnProperty("id")) {
+            id = dyNode.getAttribute("id") as String
+        }
         val nl = node.childNodes.asList()
         val actList = nl.filter { it.nodeName.equals("cpt:action") }
         for (n: Node in actList) {
diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt
index b94ee36..42973a3 100644
--- 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt
@@ -25,9 +25,9 @@ import io.kvision.navbar.Nav
 import io.kvision.navbar.Navbar
 import io.kvision.navbar.NavbarType
 import io.kvision.panel.SimplePanel
-import kotlinx.browser.window
 import org.apache.isis.client.kroviz.core.event.EventState
 import org.apache.isis.client.kroviz.core.event.LogEntry
+import org.apache.isis.client.kroviz.core.event.StatusPo
 import org.apache.isis.client.kroviz.core.model.DiagramDM
 import org.apache.isis.client.kroviz.ui.diagram.ClassDiagram
 import org.apache.isis.client.kroviz.ui.dialog.DiagramDialog
@@ -40,8 +40,10 @@ class RoStatusBar {
     private val nav = Nav(rightAlign = true)
     private val userBtn: Button = buildButton("", "Me", 
ButtonStyle.OUTLINEWARNING)
     private val classDiagram = buildButton("", "Diagram", 
ButtonStyle.OUTLINEWARNING)
-    private val lastError = buildButton("OK", "OK", ButtonStyle.OUTLINESUCCESS)
-    private val alert = buildButton("", "Notification", 
ButtonStyle.OUTLINESUCCESS)
+    private val success = buildButton("0", "OK", ButtonStyle.OUTLINESUCCESS)
+    private val running = buildButton("0", "Run", ButtonStyle.OUTLINEWARNING)
+    private val errors = buildButton("0", "Error", ButtonStyle.OUTLINEDANGER)
+    private val views = buildButton("0", "Visualize", ButtonStyle.OUTLINEINFO)
 
     private fun buildButton(text: String, iconName: String, style: 
ButtonStyle): Button {
         return Button(
@@ -59,10 +61,18 @@ class RoStatusBar {
         navbar.add(nav)
 //        nav.add(isisButton())
 //        nav.add(kvisionButton())
-        nav.add(lastError)
-        nav.add(classDiagram)
+        nav.add(success)
+        nav.add(running)
+        nav.add(errors)
+        nav.add(views)
         nav.add(userBtn)
-        nav.add(alert)
+    }
+
+    fun update(status: StatusPo) {
+        success.text = status.successNo.toString()
+        running.text = status.runningNo.toString()
+        errors.text = status.errorNo.toString()
+        views.text = status.viewsNo.toString()
     }
 
     fun updateDiagram(dd: DiagramDM) {
@@ -80,16 +90,16 @@ class RoStatusBar {
     }
 
     private fun notify(text: String) {
-        alert.setAttribute(name = "title", value = text)
-        alert.style = ButtonStyle.OUTLINEDANGER
-        alert.onClick {
+        views.setAttribute(name = "title", value = text)
+        views.style = ButtonStyle.OUTLINEDANGER
+        views.onClick {
             NotificationDialog(text).open()
         }
     }
 
     fun acknowledge() {
-        alert.setAttribute(name = "title", value = "no new notifications")
-        alert.style = ButtonStyle.OUTLINELIGHT
+        views.setAttribute(name = "title", value = "no new notifications")
+        views.style = ButtonStyle.OUTLINELIGHT
     }
 
     fun update(le: LogEntry?) {
@@ -110,12 +120,12 @@ class RoStatusBar {
     private fun turnRed(logEntry: LogEntry) {
         var text = logEntry.url
         if (text.length > 50) text = text.substring(0, 49)
-        lastError.text = text
-        lastError.style = ButtonStyle.OUTLINEDANGER
-        lastError.icon = IconManager.find("Error")
+        errors.text = text
+        errors.style = ButtonStyle.OUTLINEDANGER
+        errors.icon = IconManager.find("Error")
         notify(text)
     }
-
+/*
     private fun isisButton(): Button {
         val classes = "isis-logo-button-image logo-button"
         val b = Button("", style = ButtonStyle.LINK)
@@ -133,5 +143,5 @@ class RoStatusBar {
             window.open("https://kvision.io";)
         }
     }
-
+*/
 }
diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ViewManager.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ViewManager.kt
index a30dc27..40c1883 100644
--- 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ViewManager.kt
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/ViewManager.kt
@@ -31,7 +31,7 @@ import 
org.apache.isis.client.kroviz.core.aggregator.BaseAggregator
 import org.apache.isis.client.kroviz.core.aggregator.ObjectAggregator
 import org.apache.isis.client.kroviz.core.aggregator.UndefinedDispatcher
 import org.apache.isis.client.kroviz.core.event.EventStore
-import org.apache.isis.client.kroviz.core.event.LogEntry
+import org.apache.isis.client.kroviz.core.event.StatusPo
 import org.apache.isis.client.kroviz.core.model.CollectionDM
 import org.apache.isis.client.kroviz.core.model.ObjectDM
 import org.apache.isis.client.kroviz.to.TObject
@@ -143,8 +143,8 @@ object ViewManager {
         setNormalCursor()
     }
 
-    fun updateStatus(entry: LogEntry) {
-        getRoStatusBar().update(entry)
+    fun updateStatus(status: StatusPo) {
+        getRoStatusBar().update(status)
         setNormalCursor()
     }
 
diff --git 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/ErrorDialog.kt
 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/ErrorDialog.kt
index 1eb91eb..c2cff9e 100644
--- 
a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/ErrorDialog.kt
+++ 
b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/ErrorDialog.kt
@@ -42,7 +42,7 @@ class ErrorDialog(val logEntry: LogEntry) : Controller() {
             items = formItems,
             controller = this,
             widthPerc = 80,
-            heightPerc = 70
+            heightPerc = 50
         ).open()
     }
 

Reply via email to