-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make feed.name optional
- Loading branch information
Showing
35 changed files
with
333 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...-laminar/src/main/scala/EditElement.scala → .../ru/d10xa/jsonlogviewer/EditElement.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
...tend-laminar/src/main/scala/Router0.scala → ...cala/ru/d10xa/jsonlogviewer/Router0.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
frontend-laminar/src/main/scala/ru/d10xa/jsonlogviewer/ViewElement.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package ru.d10xa.jsonlogviewer | ||
|
||
import cats.effect.IO | ||
import cats.effect.unsafe.implicits.global | ||
import com.monovore.decline.Help | ||
import com.raquo.airstream.core.Signal | ||
import com.raquo.airstream.eventbus.EventBus | ||
import com.raquo.airstream.ownership.Owner | ||
import com.raquo.laminar.DomApi | ||
import com.raquo.laminar.api.L.* | ||
import ru.d10xa.jsonlogviewer.decline.Config | ||
import ru.d10xa.jsonlogviewer.decline.yaml.ConfigYaml | ||
import ru.d10xa.jsonlogviewer.decline.yaml.Feed | ||
|
||
import scala.util.chaining.* | ||
|
||
object ViewElement { | ||
|
||
def stringsToHtmlElement(strings: List[String]): HtmlElement = | ||
strings | ||
.map(Ansi2HtmlWithClasses.apply) | ||
.mkString("<div>", "", "</div>") | ||
.pipe(DomApi.unsafeParseHtmlString) | ||
.pipe(foreignHtmlElement) | ||
|
||
def modifyConfigForInlineInput(string: String, config: Config): Config = | ||
config.copy(configYaml = | ||
Some( | ||
ConfigYaml( | ||
filter = None, | ||
formatIn = None, | ||
commands = None, | ||
feeds = Some( | ||
List( | ||
Feed( | ||
name = None, | ||
commands = List.empty, | ||
inlineInput = Some(string), | ||
filter = config.filter, | ||
formatIn = config.formatIn | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
||
def render( | ||
logLinesSignal: Signal[String], | ||
configSignal: Signal[Either[Help, Config]] | ||
)(implicit owner: Owner): HtmlElement = { | ||
val eventBus = new EventBus[HtmlElement] | ||
logLinesSignal | ||
.combineWith(configSignal) | ||
.foreach { | ||
case (string, Right(c)) => | ||
LogViewerStream | ||
.stream(modifyConfigForInlineInput(string, c)) | ||
.compile | ||
.toList | ||
.map(stringsToHtmlElement) | ||
.flatMap(e => IO(eventBus.writer.onNext(e))) | ||
.unsafeRunAndForget() | ||
|
||
case (_, Left(help)) => | ||
eventBus.writer.onNext(pre(cls := "text-light", help.toString)) | ||
}(owner) | ||
|
||
pre( | ||
cls := "bg-dark font-monospace text-white", | ||
child <-- eventBus.events | ||
) | ||
} | ||
} |
Oops, something went wrong.