All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.simiacryptus.skyenet.Retryable.kt Maven / Gradle / Ivy

There is a newer version: 1.2.21
Show newest version
package com.simiacryptus.skyenet

import com.simiacryptus.skyenet.webui.application.ApplicationInterface
import com.simiacryptus.skyenet.webui.session.SessionTask

open class Retryable(
    val ui: ApplicationInterface,
    task: SessionTask,
    val process: (StringBuilder) -> String
) : TabbedDisplay(task) {

    init {
        init()
    }

    open fun init() {
        val tabLabel = label(size)
        set(tabLabel, SessionTask.spinner)
        set(tabLabel, process(container))
    }

    override fun renderTabButtons(): String = """
    
${ tabs.withIndex().joinToString("\n") { (index, _) -> val tabId = "$index" """""" } } ${ ui.hrefLink("♻") { val idx = tabs.size val label = label(idx) val content = StringBuilder("Retrying..." + SessionTask.spinner) tabs.add(label to content) update() val newResult = process(content) content.clear() set(label, newResult) } }
""".trimIndent() }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy