forked from Normation/rudder
-
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.
- Loading branch information
Showing
8 changed files
with
237 additions
and
197 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
54 changes: 27 additions & 27 deletions
54
webapp/sources/rudder/rudder-web/src/main/elm/secret/sources/DataTypes.elm
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 |
---|---|---|
@@ -1,50 +1,50 @@ | ||
module DataTypes exposing(..) | ||
|
||
import Http exposing (Error) | ||
import Toasty | ||
import Toasty.Defaults | ||
|
||
type alias Secret = | ||
{ name : String | ||
{ info : SecretInfo | ||
, value : String | ||
} | ||
|
||
type alias SecretInfo = | ||
{ name : String | ||
, description : String | ||
} | ||
|
||
|
||
type alias Model = | ||
{ contextPath : String | ||
, secrets : List Secret | ||
, focusOn : Maybe Secret | ||
, newSecretInput : Maybe Secret | ||
, isOpenCreateModal : Bool | ||
, isOpenEditModal : Bool | ||
, stateInputs : List StateInput | ||
{ contextPath : String | ||
, secrets : List SecretInfo | ||
, focusOn : Maybe SecretInfo | ||
, newSecretInput : Maybe Secret | ||
, openModalMode : Mode | ||
, stateInputs : List StateInput | ||
, openedDescription : List String | ||
} | ||
|
||
type WriteAction | ||
type Mode | ||
= Edit | ||
| Add | ||
| Delete | ||
| Read | ||
|
||
type StateInput | ||
= InvalidName | ||
| InvalidValue | ||
| InvalidDescription | ||
= EmptyInputName | ||
| EmptyInputValue | ||
| EmptyInputDescription | ||
|
||
type Msg | ||
= GetAllSecrets (Result Error (List Secret)) | ||
| GetSecret (Result Error Secret) | ||
| AddSecret (Result Error Secret) | ||
| DeleteSecret (Result Error String) | ||
| UpdateSecret (Result Error Secret) | ||
= GetAllSecrets (Result Error (List SecretInfo)) | ||
| GetSecret (Result Error (List SecretInfo)) | ||
| AddSecret (Result Error (List SecretInfo)) | ||
| DeleteSecret (Result Error (List SecretInfo)) | ||
| UpdateSecret (Result Error (List SecretInfo)) | ||
| CallApi (Model -> Cmd Msg) | ||
| OpenCreateModal | ||
| OpenEditModal Secret | ||
| OpenModal Mode (Maybe SecretInfo) | ||
| CloseModal | ||
| InputName String | ||
| InputValue String | ||
| InputDescription String | ||
| SubmitSecret WriteAction | ||
| OpenDescription Secret | ||
-- | ||
-- -- NOTIFICATIONS | ||
--| ToastyMsg (Toasty.Msg Toasty.Defaults.Toast) | ||
--| Notification (Toasty.Msg Toasty.Defaults.Toast) | ||
| SubmitSecret Mode | ||
| OpenDescription SecretInfo |
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
26 changes: 9 additions & 17 deletions
26
webapp/sources/rudder/rudder-web/src/main/elm/secret/sources/JsonDecoder.elm
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 |
---|---|---|
@@ -1,23 +1,15 @@ | ||
module JsonDecoder exposing (..) | ||
|
||
import DataTypes exposing (Secret) | ||
import DataTypes exposing (Secret, SecretInfo) | ||
import Json.Decode as D exposing (Decoder) | ||
import Json.Decode.Pipeline exposing (required) | ||
import Json.Decode.Pipeline exposing (hardcoded, optional, required) | ||
|
||
decodeGetAllSecrets : Decoder (List Secret) | ||
decodeGetAllSecrets = | ||
D.at [ "data" ] ( D.at [ "secrets" ] (D.list <| decodeSecret) ) | ||
decodeSecretsApi : Decoder (List SecretInfo) | ||
decodeSecretsApi = | ||
D.at [ "data" ] ( D.at [ "secrets" ] (D.list <| decodeSecretInfo) ) | ||
|
||
decodeOneSecret : Decoder Secret | ||
decodeOneSecret = | ||
D.at [ "data" ] ( D.at [ "secret" ] decodeSecret) | ||
|
||
decodeDeleteSecret : Decoder String | ||
decodeDeleteSecret = | ||
D.at [ "data" ] ( D.at [ "secretName" ] D.string ) | ||
|
||
decodeSecret : Decoder Secret | ||
decodeSecret = | ||
D.succeed Secret | ||
decodeSecretInfo : Decoder SecretInfo | ||
decodeSecretInfo = | ||
D.succeed SecretInfo | ||
|> required "name" D.string | ||
|> required "value" D.string | ||
|> required "description" D.string |
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
Oops, something went wrong.