Skip to content

Commit

Permalink
new acra config format
Browse files Browse the repository at this point in the history
  • Loading branch information
F43nd1r committed Jun 28, 2021
1 parent a796c10 commit e75a1bd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import com.vaadin.flow.component.HasComponents
import com.vaadin.flow.component.HasElement
import com.vaadin.flow.component.Text
import org.slf4j.LoggerFactory
import kotlin.streams.toList
import java.util.*
import kotlin.streams.asSequence

interface HasSlottedComponents<S : HasSlottedComponents.Slot> : HasElement {
companion object {
Expand All @@ -15,7 +16,7 @@ interface HasSlottedComponents<S : HasSlottedComponents.Slot> : HasElement {

fun add(slot: S, vararg components: Component) {
for (component in components) {
component.element.setAttribute(SLOT, slot.name.toLowerCase())
component.element.setAttribute(SLOT, slot.name.lowercase(Locale.getDefault()))
element.appendChild(component.element)
}
}
Expand All @@ -32,21 +33,22 @@ interface HasSlottedComponents<S : HasSlottedComponents.Slot> : HasElement {
LoggerFactory.getLogger(HasComponents::class.java).debug("Remove of a component with no parent does nothing.")
false
}
component.element.getAttribute(SLOT) == slot.name.toLowerCase() -> {
require(this.getElement() == parent) { "The given component ($component) is not a child of this component" }
component.element.getAttribute(SLOT) == slot.name.lowercase(Locale.getDefault()) -> {
require(this.element == parent) { "The given component ($component) is not a child of this component" }
true
}
else -> false
}
}.map { it.element }.toTypedArray())
}

fun get(slot: S): List<Component> = element.children.toList()
.filter { it.getAttribute(SLOT) == slot.name.toLowerCase() }
fun get(slot: S): List<Component> = element.children.asSequence()
.filter { it.getAttribute(SLOT) == slot.name.lowercase(Locale.getDefault()) }
.mapNotNull { it.component.toNullable() }
.toList()

fun removeAll(slot: S) {
element.removeChild(*element.children.filter { it.getAttribute(SLOT) == slot.name.toLowerCase() }.toArray { arrayOfNulls(it) })
element.removeChild(*element.children.filter { it.getAttribute(SLOT) == slot.name.lowercase(Locale.getDefault()) }.toArray { arrayOfNulls(it) })
}

interface Slot {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ ssl=Nutze SSL
databaseName=Datenbankname
importSuccess=Import erfolgreich für %s von %s Berichten.
acrarium=Acrarium
configurationLabel=Notiere die folgende ACRA Konfiguration. Sie kann später nicht mehr angezeigt werden:<br><code>\
@AcraCore(reportFormat = StringFormat.JSON)<br>\
@AcraHttpSender(uri = "%s%s" /*Muss möglicherweise angepasst werden*/,<br>\
basicAuthLogin = "%s",<br>\
basicAuthPassword = "%s",<br>\
httpMethod = HttpSender.Method.POST)<br></code>
configurationLabel=Notiere die folgende ACRA Konfiguration. Sie kann später nicht mehr angezeigt werden:<br><pre>\
initAcra {\n\
\treportFormat = StringFormat.JSON\n\
\thttpSender {\n\
\t\turi = "%s%s" /*Muss möglicherweise angepasst werden*/\n\
\t\tbasicAuthLogin = "%s"\n\
\t\tbasicAuthPassword = "%s"\n\
\t\thttpMethod = HttpSender.Method.POST\n\
\t}\n\
}</pre>
create=Erzeugen
close=Schließen
yes=Ja
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ ssl=Use SSL
databaseName=Database Name
importSuccess=Import successful for %s of %s reports.
acrarium=Acrarium
configurationLabel=Take note of the following ACRA configuration. It cannot be viewed later:<br><code>\
@AcraCore(reportFormat = StringFormat.JSON)<br>\
@AcraHttpSender(uri = "%s%s" /*best guess, you may need to adjust this*/,<br>\
basicAuthLogin = "%s",<br>\
basicAuthPassword = "%s",<br>\
httpMethod = HttpSender.Method.POST)<br></code>
configurationLabel=Take note of the following ACRA configuration. It cannot be viewed later:<br><pre>\
initAcra {\n\
\treportFormat = StringFormat.JSON\n\
\thttpSender {\n\
\t\turi = "%s%s" /*best guess, you may need to adjust this*/\n\
\t\tbasicAuthLogin = "%s"\n\
\t\tbasicAuthPassword = "%s"\n\
\t\thttpMethod = HttpSender.Method.POST\n\
\t}\n\
}</pre>
create=Create
close=Close
yes=Yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ ssl=Gebruik SSL
databaseName=Gegevens bestandnaam
importSuccess=Importering voor %s van %s rapporteringen geslaagd.
acrarium=Acrarium
configurationLabel=Noteer nu deze ACRA configuratie want ze is uitsluitend nu zichtbaar:<br><code>\
@AcraCore(reportFormat = StringFormat.JSON)<br>\
@AcraHttpSender(uri = "%s%s" /* dit moet u mogelijk nog aanpassen*/,<br>\
basicAuthLogin = "%s",<br>\
basicAuthPassword = "%s",<br>\
httpMethod = HttpSender.Method.POST)<br></code>
configurationLabel=Noteer nu deze ACRA configuratie want ze is uitsluitend nu zichtbaar:<br><pre>\
initAcra {\n\
\treportFormat = StringFormat.JSON\n\
\thttpSender {\n\
\t\turi = "%s%s" /*dit moet u mogelijk nog aanpassen*/\n\
\t\tbasicAuthLogin = "%s"\n\
\t\tbasicAuthPassword = "%s"\n\
\t\thttpMethod = HttpSender.Method.POST\n\
\t}\n\
}</pre>
create=Aanmaken
close=Sluiten
yes=Ja
Expand Down

0 comments on commit e75a1bd

Please sign in to comment.