Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
markiantorno committed Jun 16, 2021
2 parents 9692769 + f27dbf4 commit 7edbad4
Show file tree
Hide file tree
Showing 26 changed files with 760 additions and 43 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kotlin.code.style=official
kotlin.js.generate.executable.default=false

# versions
fhirCoreVersion=5.3.11
fhirCoreVersion=5.4.3
jacksonVersion=2.11.1
junitVersion=5.7.1
koinVersion=2.1.6
Expand Down
2 changes: 2 additions & 0 deletions src/commonMain/kotlin/constants/Endpoints.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ const val CONTEXT_ENDPOINT = "context"
const val IG_ENDPOINT = "ig"
const val VERSIONS_ENDPOINT = "versions"
const val TERMINOLOGY_ENDPOINT = "terminology"
const val TX_SERVER_STATUS_ENDPOINT = "txStatus"
const val PACKAGES_SERVER_STATUS_ENDPOINT = "packStatus"
const val DEBUG_ENDPOINT = "debug"
Binary file added src/commonMain/resources/images/bug_report_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/commonMain/resources/images/download_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/commonMain/resources/images/github_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions src/commonMain/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
<!-- Courier Prime -->
<link href="https://fonts.googleapis.com/css2?family=Courier+Prime:ital,wght@0,400;0,700;1,400;1,700&display=swap"
rel="stylesheet">

<!-- LEGACY FONTS TODO DELETE -->
<link href="https://fonts.googleapis.com/css2?family=DotGothic16&family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Source+Code+Pro:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,900;1,200;1,300;1,400;1,500;1,600;1,700;1,900&display=swap"
rel="stylesheet">

<style>
div.base {
height: 100vh;
min-height: 100vh;
}
</style>
</head>
<body style="margin: 0; padding: 0;">
<div id="root">
<body style="margin: 0; padding: 0; height: 100%;">
<div id="root" class="base">
<p>Loading...</p>
</div>
<script src="validator-wrapper.js"></script>
Expand Down
42 changes: 26 additions & 16 deletions src/jsMain/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import reactredux.containers.header
import styled.StyleSheet
import styled.css
import styled.styledDiv
import ui.components.footer.footer
import ui.components.header.HeaderStyle
import ui.components.main.sectionTitle
import ui.components.tabs.tabLayout
Expand All @@ -27,27 +28,35 @@ class App : RComponent<AppProps, RState>() {
styledDiv {
css {
+LandingPageStyle.mainDiv
flexDirection = FlexDirection.column
}
header {}
when (props.appScreen) {
AppScreen.VALIDATOR -> {
sectionTitle {
// TODO once localization is updated
// majorText = props.polyglot.t("heading_validate")
majorText = "Validate Resources"
minorText = "Manually enter, or upload resources for validation."
}
tabLayout {}
styledDiv {
css {
paddingTop = HeaderStyle.HEADER_HEIGHT
display = Display.flex
flexDirection = FlexDirection.column
flex(flexGrow = 1.0, flexShrink = 1.0, flexBasis = FlexBasis.auto)
}
AppScreen.SETTINGS -> {
sectionTitle {
majorText = "Validation Options"
minorText = "Modify setting for validating resources."
when (props.appScreen) {
AppScreen.VALIDATOR -> {
sectionTitle {
// TODO once localization is updated
// majorText = props.polyglot.t("heading_validate")
majorText = "Validate Resources"
minorText = "Manually enter, or upload resources for validation."
}
tabLayout {}
}
AppScreen.SETTINGS -> {
sectionTitle {
majorText = "Validation Options"
minorText = "Modify setting for validating resources."
}
optionsPage {}
}
optionsPage {}
}
}
footer { }
}
}
}
Expand All @@ -57,8 +66,9 @@ class App : RComponent<AppProps, RState>() {
*/
object LandingPageStyle : StyleSheet("LandingPageStyle", isStatic = true) {
val mainDiv by css {
paddingTop = HeaderStyle.HEADER_HEIGHT
display = Display.flex
flexDirection = FlexDirection.column
height = 100.vh
}
}

20 changes: 20 additions & 0 deletions src/jsMain/kotlin/api/Client.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package api

import io.ktor.client.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import kotlinx.browser.window
import kotlinx.serialization.json.Json

val endpoint = window.location.origin + "/" // only needed until https://github.com/ktorio/ktor/issues/1695 is resolved

val jsonClient = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(kotlinx.serialization.json.Json {
prettyPrint = true
isLenient = true
ignoreUnknownKeys = true
useArrayPolymorphism = true
})
}
}
14 changes: 14 additions & 0 deletions src/jsMain/kotlin/api/StatusApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package api

import constants.PACKAGES_SERVER_STATUS_ENDPOINT
import constants.TX_SERVER_STATUS_ENDPOINT
import io.ktor.client.request.*

suspend fun isTerminologyServerUp(): Boolean {
return jsonClient.get(urlString = endpoint + TX_SERVER_STATUS_ENDPOINT)
}

suspend fun isPackagesServerUp(): Boolean {
return jsonClient.get(urlString = endpoint + PACKAGES_SERVER_STATUS_ENDPOINT)
}

14 changes: 0 additions & 14 deletions src/jsMain/kotlin/api/ValidatorApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ import kotlinx.browser.window
import kotlinx.serialization.json.Json
import model.*


val endpoint = window.location.origin + "/" // only needed until https://github.com/ktorio/ktor/issues/1695 is resolved

val jsonClient = HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer(Json {
prettyPrint = true
isLenient = true
ignoreUnknownKeys = true
useArrayPolymorphism = true
})
}
}

suspend fun sendValidationRequest(validationRequest: ValidationRequest): ValidationResponse {
return jsonClient.post(urlString = endpoint + VALIDATION_ENDPOINT) {
contentType(ContentType.Application.Json)
Expand Down
116 changes: 116 additions & 0 deletions src/jsMain/kotlin/ui/components/footer/Footer.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package ui.components.footer

import Polyglot
import css.const.BORDER_GRAY
import css.const.WHITE
import css.text.TextStyle
import kotlinx.css.*
import model.AppScreen
import react.*
import styled.*
import utils.Language

external interface FooterProps : RProps {
var language: Language //TODO
var polyglot: Polyglot //TODO
}

class Footer : RComponent<FooterProps, RState>() {

override fun RBuilder.render() {
styledFooter {
css {
+FooterStyle.footerContainer
}
styledDiv {
css {
+FooterStyle.footerColumn
}
styledSpan {
css {
+FooterStyle.footerTitleLarge
}
+"validator-wrapper"
}
styledSpan {
css {
+FooterStyle.footerTitleSmall
}
+"running validator v5.4.3"
}
}
styledDiv {
css {
+FooterStyle.footerColumn
}
footerLineItem {
href = "https://github.com/hapifhir/org.hl7.fhir.validator-wrapper"
icon = "images/github_white.png"
label = "view project on github"
}
footerLineItem {
href = "https://github.com/hapifhir/org.hl7.fhir.validator-wrapper/issues/new/choose"
icon = "images/bug_report_white.png"
label = "log an issue with the team"
}
footerLineItem {
href =
"https://github.com/hapifhir/org.hl7.fhir.validator-wrapper/releases/latest/download/validator_cli.jar"
icon = "images/download_white.png"
label = "download the latest cli"
}
}
styledDiv {
css {
+FooterStyle.footerColumn
}
footerLineItem {
href = "https://confluence.hl7.org/display/FHIR/Using+the+FHIR+Validator"
icon = "images/documentation_white.png"
label = "view the validator documentation"
}
}
}
}
}

/**
* Convenience method for instantiating the component.
*/
fun RBuilder.footer(handler: FooterProps.() -> Unit): ReactElement {
return child(Footer::class) {
this.attrs(handler)
}
}

/**
* CSS
*/
object FooterStyle : StyleSheet("FooterStyle", isStatic = true) {
private val FOOTER_HEIGHT = 200.px
val footerContainer by css {
display = Display.flex
flexDirection = FlexDirection.row
width = 100.pct
height = FOOTER_HEIGHT
backgroundColor = BORDER_GRAY
}
val footerColumn by css {
width = 33.pc
padding(all = 32.px)
display = Display.flex
flexDirection = FlexDirection.column
}
val footerTitleLarge by css {
fontFamily = TextStyle.FONT_FAMILY_MAIN
fontSize = 16.pt
fontWeight = FontWeight.w800
color = WHITE
}
val footerTitleSmall by css {
fontFamily = TextStyle.FONT_FAMILY_MAIN
fontSize = 12.pt
fontWeight = FontWeight.w400
color = WHITE
}
}
75 changes: 75 additions & 0 deletions src/jsMain/kotlin/ui/components/footer/FooterLineItem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package ui.components.footer

import css.const.HL7_RED
import css.const.WHITE
import css.text.TextStyle
import kotlinx.css.*
import kotlinx.css.properties.TextDecoration
import react.*
import styled.*

external interface FooterLineItemProps : RProps {
var icon: String
var href: String
var label: String
}

class FooterLineItem : RComponent<FooterLineItemProps, RState>() {

override fun RBuilder.render() {
styledA(href = props.href) {
css {
+FooterLineItemStyle.lineItem
}
styledImg {
css {
+FooterLineItemStyle.lineItemIcon
}
attrs {
src = props.icon
}
}
styledSpan {
css {
+FooterLineItemStyle.lineItemLabel
}
+props.label
}
}
}
}

/**
* Convenience method for instantiating the component.
*/
fun RBuilder.footerLineItem(handler: FooterLineItemProps.() -> Unit): ReactElement {
return child(FooterLineItem::class) {
this.attrs(handler)
}
}

/**
* CSS
*/
object FooterLineItemStyle : StyleSheet("FooterLineItemStyle", isStatic = true) {
private val FOOTER_HEIGHT = 200.px
val lineItem by css {
display = Display.flex
flexDirection = FlexDirection.row
alignContent = Align.center
textDecoration = TextDecoration.none
margin(bottom = 6.px)
}
val lineItemIcon by css {
alignSelf = Align.center
height = 18.px
}
val lineItemLabel by css {
fontFamily = TextStyle.FONT_FAMILY_MAIN
fontSize = 12.pt
margin(left = 12.px)
fontWeight = FontWeight.w400
alignSelf = Align.center
color = WHITE
}
}
Loading

0 comments on commit 7edbad4

Please sign in to comment.