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
commit f53e86ad3609772cde1ea7e5a06093e0b5938976 Author: Jörg Rade <[email protected]> AuthorDate: Fri Oct 15 14:35:44 2021 +0200 ISIS-2348 Replay User Events (1/n) --- .../isis/client/kroviz/core/event/EventStore.kt | 9 ---- .../isis/client/kroviz/core/event/ReplayCommand.kt | 50 ++++++++++++++++++++++ .../org/apache/isis/client/kroviz/ui/core/RoApp.kt | 21 ++++++++- .../apache/isis/client/kroviz/ui/core/RoMenuBar.kt | 9 +++- .../apache/isis/client/kroviz/ui/core/RoView.kt | 3 +- .../apache/isis/client/kroviz/ui/core/UiManager.kt | 15 +++++-- .../client/kroviz/ui/kv/override/RoTabPanel.kt | 9 ++-- .../apache/isis/client/kroviz/utils/IconManager.kt | 1 + 8 files changed, 95 insertions(+), 22 deletions(-) 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 80f212f..686911c 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 @@ -190,13 +190,4 @@ object EventStore { log.removeAll(log) } - fun getLinked(): List<LogEntry> { - // we use all LE's - eventually to be refined to a single LE (chain up and down) - val linked = mutableListOf<LogEntry>() - log.forEach { - if (it.obj is HasLinks) linked.add(it) - } - return linked - } - } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/ReplayCommand.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/ReplayCommand.kt new file mode 100644 index 0000000..4352db4 --- /dev/null +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/ReplayCommand.kt @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.client.kroviz.core.event + +import io.kvision.utils.createInstance +import org.apache.isis.client.kroviz.core.aggregator.BaseAggregator +import org.apache.isis.client.kroviz.to.Link +import org.apache.isis.client.kroviz.to.Represention +import org.apache.isis.client.kroviz.ui.core.RoApp + +class ReplayCommand { + + fun execute() { + val events = EventStore.log + EventStore.reset() + RoApp.reset() + + console.log("[ReplayCommand.execute]") + console.log(events) + val userActions = events.filter { + it.type == Represention.HOMEPAGE.name || + it.type == Represention.OBJECT_ACTION.name + } + + userActions.forEach { + val link = Link(href = it.url) + val clazz = it.getAggregator()::class + val aggregator = clazz.createInstance<BaseAggregator>() + //eventually put a thinkTime here + ResourceProxy().fetch(link,aggregator, it.subType) + } + + } +} \ No newline at end of file diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoApp.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoApp.kt index eb6bba1..e6d5ef0 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoApp.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoApp.kt @@ -24,17 +24,36 @@ import io.kvision.panel.HPanel import io.kvision.panel.SimplePanel object RoApp : SimplePanel() { + + private var roView: RoView? = null + init { + setup() + } + + private fun setup() { this.add(RoMenuBar.navbar) + roView = RoView() val view = HPanel() { width = CssSize(100, UNIT.perc) } view.addCssClass("main") view.add(RoIconBar.panel) - view.add(RoView.tabPanel) + view.add(roView!!.tabPanel) this.add(view) this.add(RoStatusBar.navbar) } + + fun reset() { + val kids = this.children + kids?.clear() + setup() + } + + fun getRoView(): RoView { + return roView!! + } + } 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 e101836..e841014 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 @@ -30,6 +30,7 @@ import io.kvision.panel.SimplePanel import io.kvision.panel.vPanel import kotlinx.browser.window import org.apache.isis.client.kroviz.core.event.EventStore +import org.apache.isis.client.kroviz.core.event.ReplayCommand import org.apache.isis.client.kroviz.to.mb.Menubars import org.apache.isis.client.kroviz.ui.chart.SampleChartModel import org.apache.isis.client.kroviz.ui.dialog.About @@ -83,6 +84,10 @@ object RoMenuBar : SimplePanel() { ) mainMenu.add( + buildMenuEntry("Replay", "Replay", { ReplayCommand().execute() }) + ) + + mainMenu.add( buildMenuEntry("History", "History", { UiManager.add("Log Entries", EventLogTable(EventStore.log)) }) ) @@ -108,12 +113,12 @@ object RoMenuBar : SimplePanel() { val imageTitle = "Sample Image" mainMenu.add( - buildMenuEntry(imageTitle, "Image", { RoView.addTab(imageTitle, ImageSample()) }) + buildMenuEntry(imageTitle, "Image", { UiManager.add(imageTitle, ImageSample) }) ) val aboutTitle = "About" mainMenu.add( - buildMenuEntry(aboutTitle, "Info", { RoView.addTab(aboutTitle, About().open()) }) + buildMenuEntry(aboutTitle, "Info", { UiManager.add(aboutTitle, About().open()) }) ) console.log("[RMB.buildMainMenu]") diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoView.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoView.kt index 6801f14..300e313 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoView.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoView.kt @@ -30,7 +30,7 @@ import org.apache.isis.client.kroviz.utils.IconManager * Contains: * @Item TabPanel with Tabs */ -object RoView { +class RoView() { val tabPanel = RoTabPanel() private var tabCount = 0 @@ -59,6 +59,7 @@ object RoView { } fun removeTab(tab: SimplePanel) { + console.log("[RoView.removeTab]") tabCount-- UiManager.closeView(tab) } diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/UiManager.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/UiManager.kt index 7645936..625fd9d 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/UiManager.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/UiManager.kt @@ -69,7 +69,7 @@ object UiManager { } private fun activeObject(): ObjectDM? { - val activeTab = RoView.findActive() + val activeTab = RoApp.getRoView().findActive() if (activeTab != null) { return (activeTab as RoDisplay).displayModel } @@ -77,10 +77,16 @@ object UiManager { } fun add(title: String, panel: SimplePanel, aggregator: BaseAggregator = UndefinedDispatcher()) { - RoView.addTab(title, panel) + RoApp.getRoView().addTab(title, panel) EventStore.addView(title, aggregator, panel) } + fun remove(panel: SimplePanel) { + console.log("[UiManager.remove]") + // EventStore.closeView(title) + RoApp.getRoView().removeTab(panel) + } + /** * SVG code added to Tabs disappears after a refresh, therefore an SVG object (code, uuid) * is added as attribute to the tab in order to being able to recreate it on refresh. @@ -97,8 +103,8 @@ object UiManager { DomUtil.appendTo(uuid, svgCode) val panel = buildSvgPanel(uuid) - RoView.addTab(title, panel) - val tab = RoView.findActive()!! as RoTab + RoApp.getRoView().addTab(title, panel) + val tab = RoApp.getRoView().findActive()!! as RoTab val svg = ScalableVectorGraphic(svgCode, uuid) tab.svg = svg @@ -108,6 +114,7 @@ object UiManager { } fun closeView(tab: SimplePanel) { + console.log("[UiManager.closeView]") val tt = tab.title if (tt != null) { EventStore.closeView(tt) diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/override/RoTabPanel.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/override/RoTabPanel.kt index 244a872..3f4da88 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/override/RoTabPanel.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/kv/override/RoTabPanel.kt @@ -26,12 +26,11 @@ package org.apache.isis.client.kroviz.ui.kv.override import com.github.snabbdom.VNode import io.kvision.core.* import io.kvision.panel.SimplePanel -import io.kvision.panel.Tab import io.kvision.panel.VPanel import io.kvision.routing.RoutingManager import io.kvision.utils.auto import io.kvision.utils.obj -import org.apache.isis.client.kroviz.ui.core.RoView +import org.apache.isis.client.kroviz.ui.core.UiManager /** * Tab position. @@ -188,7 +187,7 @@ open class RoTabPanel( */ open fun removeTab(index: Int): RoTabPanel { val tab = getTabs().get(index) - RoView.removeTab(tab as SimplePanel) + UiManager.remove(tab as SimplePanel) getTab(index)?.let { removeTab(it) @@ -313,8 +312,8 @@ open class RoTabPanel( * @return current container */ open fun addTab( - title: String, panel: Component, icon: String? = null, - image: ResString? = null, closable: Boolean = false, route: String? = null + title: String, panel: Component, icon: String? = null, + image: ResString? = null, closable: Boolean = false, route: String? = null ): RoTabPanel { addTab(RoTab(title, panel, icon, image, closable, route)) refresh() diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt index e5a7c6c..5887c7e 100644 --- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt +++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/utils/IconManager.kt @@ -79,6 +79,7 @@ object IconManager { "Primitives" to "hashtag", "Prototyping" to "object-group", "Queen" to "chess-queen", + "Replay" to "share", "Run" to "rocket", "Save" to "file", "Security" to "lock",
