Skip to content

Commit

Permalink
Merge pull request #1281 from ds-wizard/release/4.13.0
Browse files Browse the repository at this point in the history
Release 4.13.0
  • Loading branch information
janslifka authored Dec 5, 2024
2 parents b33280c + 4827b01 commit 63833c6
Show file tree
Hide file tree
Showing 71 changed files with 2,535 additions and 1,033 deletions.
1 change: 1 addition & 0 deletions elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"elm-community/json-extra": "4.3.0",
"elm-community/list-extra": "8.7.0",
"elm-community/maybe-extra": "5.3.0",
"elm-community/result-extra": "2.4.0",
"enbala/elm-form": "1.0.0",
"gingko/time-distance": "2.4.0",
"hecrj/html-parser": "2.4.0",
Expand Down
2 changes: 1 addition & 1 deletion engine-registry/elm/Registry/Pages/ForgottenToken.elm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ successView appState =
Page.illustratedMessage
{ image = Undraw.confirmation
, heading = gettext "Token recovery successful!" appState.locale
, msg = gettext "Check your email address for the recovery link." appState.locale
, msg = gettext "Check your email for the recovery link." appState.locale
}


Expand Down
27 changes: 26 additions & 1 deletion engine-shared/elm/Shared/Api/DocumentTemplateDrafts.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ module Shared.Api.DocumentTemplateDrafts exposing
, getFileContent
, getFiles
, getPreview
, moveFolder
, postDraft
, postFile
, putAsset
, putDraft
, putFile
, putFileContent
, putPreviewSettings
, uploadAsset
Expand All @@ -22,7 +25,7 @@ import Http
import Json.Decode as D
import Json.Encode as E
import Shared.AbstractAppState exposing (AbstractAppState)
import Shared.Api exposing (ToMsg, authorizationHeaders, expectMetadataAndJson, jwtDelete, jwtFetch, jwtFetchFileWithData, jwtFetchPut, jwtGet, jwtGetString, jwtPutString)
import Shared.Api exposing (ToMsg, authorizationHeaders, expectMetadataAndJson, jwtDelete, jwtFetch, jwtFetchFileWithData, jwtFetchPut, jwtGet, jwtGetString, jwtPost, jwtPut, jwtPutString)
import Shared.Data.DocumentTemplate.DocumentTemplateAsset as DocumentTemplateAsset exposing (DocumentTemplateAsset)
import Shared.Data.DocumentTemplate.DocumentTemplateFile as DocumentTemplateFile exposing (DocumentTemplateFile)
import Shared.Data.DocumentTemplateDraft as DocumentTemplateDraft exposing (DocumentTemplateDraft)
Expand Down Expand Up @@ -82,6 +85,11 @@ postFile templateId file fileContent =
jwtFetch ("/document-template-drafts/" ++ templateId ++ "/files") DocumentTemplateFile.decoder (DocumentTemplateFile.encode file fileContent)


putFile : String -> DocumentTemplateFile -> String -> AbstractAppState a -> ToMsg () msg -> Cmd msg
putFile templateId file fileContent =
jwtPut ("/document-template-drafts/" ++ templateId ++ "/files/" ++ Uuid.toString file.uuid) (DocumentTemplateFile.encode file fileContent)


putFileContent : String -> Uuid -> String -> AbstractAppState a -> ToMsg () msg -> Cmd msg
putFileContent templateId fileUuid fileContent =
jwtPutString ("/document-template-drafts/" ++ templateId ++ "/files/" ++ Uuid.toString fileUuid ++ "/content") "text/plain;charset=utf-8" fileContent
Expand All @@ -102,6 +110,11 @@ getAsset templateId assetUuid =
jwtGet ("/document-template-drafts/" ++ templateId ++ "/assets/" ++ Uuid.toString assetUuid) DocumentTemplateAsset.decoder


putAsset : String -> DocumentTemplateAsset -> AbstractAppState a -> ToMsg () msg -> Cmd msg
putAsset templateId asset =
jwtPut ("/document-template-drafts/" ++ templateId ++ "/assets/" ++ Uuid.toString asset.uuid) (DocumentTemplateAsset.encode asset)


deleteAsset : String -> Uuid -> AbstractAppState a -> ToMsg () msg -> Cmd msg
deleteAsset templateId fileUuid =
jwtDelete ("/document-template-drafts/" ++ templateId ++ "/assets/" ++ Uuid.toString fileUuid)
Expand Down Expand Up @@ -132,3 +145,15 @@ uploadAsset templateId fileName =
jwtFetchFileWithData ("/document-template-drafts/" ++ templateId ++ "/assets")
[ Http.stringPart "fileName" fileName ]
DocumentTemplateAsset.decoder


moveFolder : String -> String -> String -> AbstractAppState a -> ToMsg () msg -> Cmd msg
moveFolder templateId currentPath newPath =
let
body =
E.object
[ ( "current", E.string currentPath )
, ( "new", E.string newPath )
]
in
jwtPost ("/document-template-drafts/" ++ templateId ++ "/folders/move") body
44 changes: 16 additions & 28 deletions engine-shared/elm/Shared/Api/Tenants.elm
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
module Shared.Api.Tenants exposing
( deletePlan
, getCurrentConfig
, getCurrentPlans
( getCurrentConfig
, getTenant
, getTenantUsage
, getTenants
, postPlan
, postTenant
, putCurrentConfig
, putPlan
, putTenant
, putTenantLimits
)

import Json.Decode as D
import Json.Encode as E
import Shared.AbstractAppState exposing (AbstractAppState)
import Shared.Api exposing (ToMsg, jwtDelete, jwtGet, jwtPost, jwtPut)
import Shared.Api exposing (ToMsg, jwtGet, jwtPost, jwtPut)
import Shared.Common.UuidOrCurrent as UuidOrCurrent exposing (UuidOrCurrent)
import Shared.Data.EditableConfig as EditableConfig exposing (EditableConfig)
import Shared.Data.Pagination as Pagination exposing (Pagination)
import Shared.Data.PaginationQueryFilters as PaginationQueryFilters exposing (PaginationQueryFilters)
import Shared.Data.PaginationQueryString as PaginationQueryString exposing (PaginationQueryString)
import Shared.Data.Plan as Plan exposing (Plan)
import Shared.Data.Tenant as Tenant exposing (Tenant)
import Shared.Data.TenantDetail as TenantDetail exposing (TenantDetail)
import Shared.Data.Usage as Usage exposing (Usage)
import Uuid exposing (Uuid)


Expand Down Expand Up @@ -57,26 +55,6 @@ putTenant uuid =
jwtPut ("/tenants/" ++ Uuid.toString uuid)


postPlan : Uuid -> E.Value -> AbstractAppState a -> ToMsg () msg -> Cmd msg
postPlan uuid =
jwtPost ("/tenants/" ++ Uuid.toString uuid ++ "/plans")


putPlan : Uuid -> Uuid -> E.Value -> AbstractAppState a -> ToMsg () msg -> Cmd msg
putPlan tenantUuid planUuid =
jwtPut ("/tenants/" ++ Uuid.toString tenantUuid ++ "/plans/" ++ Uuid.toString planUuid)


deletePlan : Uuid -> Uuid -> AbstractAppState a -> ToMsg () msg -> Cmd msg
deletePlan tenantUuid planUuid =
jwtDelete ("/tenants/" ++ Uuid.toString tenantUuid ++ "/plans/" ++ Uuid.toString planUuid)


getCurrentPlans : AbstractAppState a -> ToMsg (List Plan) msg -> Cmd msg
getCurrentPlans =
jwtGet "/tenants/current/plans" (D.list Plan.decoder)


getCurrentConfig : AbstractAppState a -> ToMsg EditableConfig msg -> Cmd msg
getCurrentConfig =
jwtGet "/tenants/current/config" EditableConfig.decoder
Expand All @@ -85,3 +63,13 @@ getCurrentConfig =
putCurrentConfig : E.Value -> AbstractAppState a -> ToMsg () msg -> Cmd msg
putCurrentConfig =
jwtPut "/tenants/current/config"


getTenantUsage : UuidOrCurrent -> AbstractAppState a -> ToMsg Usage msg -> Cmd msg
getTenantUsage tenantUuid =
jwtGet ("/tenants/" ++ UuidOrCurrent.toString tenantUuid ++ "/usages/wizard") Usage.decoder


putTenantLimits : Uuid -> E.Value -> AbstractAppState a -> ToMsg () msg -> Cmd msg
putTenantLimits tenantUuid =
jwtPut ("/tenants/" ++ Uuid.toString tenantUuid ++ "/limits")
10 changes: 0 additions & 10 deletions engine-shared/elm/Shared/Api/Usage.elm

This file was deleted.

11 changes: 9 additions & 2 deletions engine-shared/elm/Shared/Common/ByteUnits.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import Round


toReadable : Int -> String
toReadable =
toReadable num =
let
sign =
if num < 0 then
"-"

else
""

units =
[ "B", "kB", "MB", "GB", "TB", "PB" ]

Expand All @@ -27,4 +34,4 @@ toReadable =
[] ->
""
in
fold units << toFloat
sign ++ fold units (toFloat (abs num))
92 changes: 1 addition & 91 deletions engine-shared/elm/Shared/Common/TimeUtils.elm
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module Shared.Common.TimeUtils exposing
( fromYMD
, isAfter
, isBefore
, isBetween
, monthToInt
( monthToInt
, monthToString
, toReadableDate
, toReadableDateTime
Expand All @@ -12,7 +8,6 @@ module Shared.Common.TimeUtils exposing

import Gettext exposing (gettext)
import Time exposing (Month(..))
import Time.Extra as Time


toReadableDateTime : Time.Zone -> Time.Posix -> String
Expand Down Expand Up @@ -63,12 +58,6 @@ toReadableTime timeZone time =
hour ++ ":" ++ min


fromYMD : Time.Zone -> Int -> Int -> Int -> Time.Posix
fromYMD timeZone year month day =
Time.partsToPosix timeZone <|
Time.Parts year (intToMonth month) day 0 0 0 0


monthToInt : Month -> Int
monthToInt month =
case month of
Expand Down Expand Up @@ -109,46 +98,6 @@ monthToInt month =
12


intToMonth : Int -> Month
intToMonth month =
case month of
1 ->
Jan

2 ->
Feb

3 ->
Mar

4 ->
Apr

5 ->
May

6 ->
Jun

7 ->
Jul

8 ->
Aug

9 ->
Sep

10 ->
Oct

11 ->
Nov

_ ->
Dec


monthToString : { a | locale : Gettext.Locale } -> Month -> String
monthToString appState month =
case month of
Expand Down Expand Up @@ -187,42 +136,3 @@ monthToString appState month =

Dec ->
gettext "December" appState.locale


isBetween : Time.Posix -> Time.Posix -> Time.Posix -> Bool
isBetween start end time =
let
startMillis =
Time.posixToMillis start

endMillis =
Time.posixToMillis end

timeMillis =
Time.posixToMillis time
in
startMillis < timeMillis && endMillis > timeMillis


isBefore : Time.Posix -> Time.Posix -> Bool
isBefore expected time =
let
expectedMillis =
Time.posixToMillis expected

timeMillis =
Time.posixToMillis time
in
timeMillis < expectedMillis


isAfter : Time.Posix -> Time.Posix -> Bool
isAfter expected time =
let
expectedMillis =
Time.posixToMillis expected

timeMillis =
Time.posixToMillis time
in
timeMillis < expectedMillis
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module Shared.Data.DocumentTemplate.DocumentTemplateAsset exposing
( DocumentTemplateAsset
, decoder
, encode
)

import Json.Decode as D exposing (Decoder)
import Json.Decode.Extra as D
import Json.Decode.Pipeline as D
import Json.Encode as E
import Time
import Uuid exposing (Uuid)

Expand All @@ -27,3 +29,10 @@ decoder =
|> D.required "contentType" D.string
|> D.required "url" D.string
|> D.required "urlExpiration" D.datetime


encode : DocumentTemplateAsset -> E.Value
encode asset =
E.object
[ ( "fileName", E.string asset.fileName )
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Json.Encode as E
import Json.Encode.Extra as E
import Shared.Data.KnowledgeModel.Annotation as Annotation exposing (Annotation)
import Shared.Data.KnowledgeModel.Question exposing (Question(..))
import Shared.Data.KnowledgeModel.Question.QuestionValidation as QuestionValidation exposing (QuestionValidation)
import Shared.Data.KnowledgeModel.Question.QuestionValueType as QuestionValueType exposing (QuestionValueType)


Expand All @@ -20,6 +21,7 @@ type alias AddQuestionValueEventData =
, requiredPhaseUuid : Maybe String
, tagUuids : List String
, valueType : QuestionValueType
, validations : List QuestionValidation
, annotations : List Annotation
}

Expand All @@ -32,6 +34,7 @@ decoder =
|> D.required "requiredPhaseUuid" (D.nullable D.string)
|> D.required "tagUuids" (D.list D.string)
|> D.required "valueType" QuestionValueType.decoder
|> D.required "validations" (D.list QuestionValidation.decoder)
|> D.required "annotations" (D.list Annotation.decoder)


Expand All @@ -43,6 +46,7 @@ encode data =
, ( "requiredPhaseUuid", E.maybe E.string data.requiredPhaseUuid )
, ( "tagUuids", E.list E.string data.tagUuids )
, ( "valueType", QuestionValueType.encode data.valueType )
, ( "validations", E.list QuestionValidation.encode data.validations )
, ( "annotations", E.list Annotation.encode data.annotations )
]

Expand All @@ -60,4 +64,5 @@ toQuestion uuid data =
, annotations = data.annotations
}
{ valueType = QuestionValueType.StringQuestionValueType
, validations = data.validations
}
6 changes: 6 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditEventSetters.elm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module Shared.Data.Event.EditEventSetters exposing
, setText
, setTitle
, setUrl
, setValidations
, setValueType
, setWidgetUrl
)
Expand Down Expand Up @@ -276,6 +277,11 @@ setUrl value data =
{ data | url = EventField.create value True }


setValidations : a -> { b | validations : EventField a } -> { b | validations : EventField a }
setValidations value data =
{ data | validations = EventField.create value True }


setValueType : a -> { b | valueType : EventField a } -> { b | valueType : EventField a }
setValueType value data =
{ data | valueType = EventField.create value True }
Expand Down
Loading

0 comments on commit 63833c6

Please sign in to comment.