Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sknull committed Apr 20, 2024
1 parent 8553364 commit 965c974
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class ColorWheel(

private val log: Logger = LoggerFactory.getLogger(javaClass)

override fun toHtml(configHolder: ConfigHolder): String {
override fun toHtml(configHolder: ConfigHolder?): String {
return toHtml(configHolder, false)
}

fun toHtml(configHolder: ConfigHolder, oddEven: Boolean): String {
fun toHtml(configHolder: ConfigHolder?, oddEven: Boolean): String {
val wheelId = id!!.replace(" ", "")

val sb = StringBuilder()
Expand Down Expand Up @@ -50,17 +50,17 @@ class ColorWheel(
sb.append("\t\t</div><!-- colorwheel-panel -->\n")
}

private fun renderScript(sb: StringBuilder, wheelId: String, oddEven: Boolean, configHolder: ConfigHolder) {
private fun renderScript(sb: StringBuilder, wheelId: String, oddEven: Boolean, configHolder: ConfigHolder?) {
if (oddEven) {
sb.append("\t\t<script type=\"application/javascript\">\n")

val hexColorOdd = configHolder.getColor("${wheelId}Odd")?:"000000"
val hexColorOdd = configHolder?.getColor("${wheelId}Odd")?:"000000"
sb.append("\t\t\tvar colorWheel${wheelId}Odd = new iro.ColorPicker(\"#colorwheel-${wheelId}Odd\", {\n")
sb.append("\t\t\t\twheelLightness: false,\n")
sb.append("\t\t\t\tcolor: \"${hexColorOdd}\"\n")
sb.append("\t\t\t});\n\n")

val hexColorEven = configHolder.getColor("${wheelId}Even")?:"000000"
val hexColorEven = configHolder?.getColor("${wheelId}Even")?:"000000"
sb.append("\t\t\tvar colorWheel${wheelId}Even = new iro.ColorPicker(\"#colorwheel-${wheelId}Even\", {\n")
sb.append("\t\t\t\twheelLightness: false,\n")
sb.append("\t\t\t\tcolor: \"${hexColorEven}\"\n")
Expand All @@ -80,9 +80,9 @@ class ColorWheel(

sb.append("\t\t</script>\n")
} else {
val hexColor = configHolder.getFadeable(wheelId)
val hexColor = configHolder?.getFadeable(wheelId)
?.getRgbColor()?.web()
?:configHolder.getColor(wheelId)
?:configHolder?.getColor(wheelId)
?:"000000"
sb.append("\t\t<script type=\"application/javascript\">\n")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ColorWheelOddEven(
val id: String? = null
) : HtmlRenderable {

override fun toHtml(configHolder: ConfigHolder): String {
override fun toHtml(configHolder: ConfigHolder?): String {
return " <div class=\"colorwheel-wrapper\">\n" +
"\t\t<div class=\"colorwheel-title\"><span class=\"label\">COLORPICKER</span></div>\n" +
"\t\t<div class=\"colorwheel-panel\">\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package de.visualdigits.kotlin.klanglicht.rest.lightmanager.model.html
import de.visualdigits.kotlin.klanglicht.rest.configuration.ConfigHolder

interface HtmlRenderable {
fun toHtml(configHolder: ConfigHolder): String?

fun toHtml(configHolder: ConfigHolder? = null): String?

fun renderLabel(sb: StringBuilder, label: String?) {
sb.append("<span class=\"label\">").append(label).append("</span>\n")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LMHtmlActor(
val actor: LMActor
) : HtmlRenderable {

override fun toHtml(configHolder: ConfigHolder): String {
override fun toHtml(configHolder: ConfigHolder?): String {
val sb = StringBuilder()
sb.append(" <div class=\"panel\">\n")
renderLabel(sb, actor.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ class LMHtmlScene(
val scene: LMScene
) : HtmlRenderable {

override fun toHtml(configHolder: ConfigHolder): String {
override fun toHtml(configHolder: ConfigHolder?): String {
return toHtml(configHolder, "")
}

fun toHtml(configHolder: ConfigHolder, group: String): String {
fun toHtml(configHolder: ConfigHolder?, group: String): String {
// val url = configHolder.preferences?.getService("lmair")?.url
val url = configHolder.preferences?.ownUrl
val url = configHolder?.preferences?.ownUrl
val sb = StringBuilder()
sb.append(" <div class=\"button\"")
if (scene.color.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class LMHtmlScenes(
val scene: LMScenes
) : HtmlRenderable {

override fun toHtml(configHolder: ConfigHolder): String {
override fun toHtml(configHolder: ConfigHolder?): String {
val sb = StringBuilder()
sb.append("<div class=\"title\" onclick=\"toggleFullScreen();\" title=\"Toggle Fullscreen\">")
.append(scene.name)
.append("</div>\n")
sb.append("<div class=\"center-category\">\n")
renderLabel(sb, "C U R R E N T S C E N E")
sb.append("<div class=\"center-group\">\n")
configHolder.currentScene?.fadeables()?.forEach { fadeable ->
configHolder?.currentScene?.fadeables()?.forEach { fadeable ->
val color = fadeable.getRgbColor()?.web()?:"#000000"
val html = renderPanel("circle", color, "")
sb.append(html)
Expand Down Expand Up @@ -49,7 +49,7 @@ class LMHtmlScenes(
}

private fun renderScenesGroup(
configHolder: ConfigHolder,
configHolder: ConfigHolder?,
sceneGroup: LMSceneGroup
): String {
val sb = StringBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class LMHtmlZone(
val zone: LMZone
): HtmlRenderable {

override fun toHtml(configHolder: ConfigHolder): String {
override fun toHtml(configHolder: ConfigHolder?): String {
val sb = StringBuilder()
sb.append(" <div class=\"group\">\n")
renderLabel(sb, zone.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class LMHtmlZones(
val zones: LMZones
) : HtmlRenderable {

override fun toHtml(configHolder: ConfigHolder): String {
override fun toHtml(configHolder: ConfigHolder?): String {
val sb = StringBuilder()
sb.append("<div class=\"title\" onclick=\"toggleFullScreen();\" title=\"Toggle Fullscreen\">")
.append(zones.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ShellyStatus : HtmlRenderable {
sb.append(" </div> <!-- ").append(clazz).append(" -->\n")
}

override fun toHtml(configHolder: ConfigHolder): String? {
override fun toHtml(configHolder: ConfigHolder?): String? {
return null
}
}

0 comments on commit 965c974

Please sign in to comment.